Skip to content

feat(dashboard): add live MemOS backend - #4

Open
majh3 wants to merge 3 commits into
hugegraph:dashboardfrom
majh3:feat/dashboard-live-backend
Open

majh3 wants to merge 3 commits into
hugegraph:dashboardfrom
majh3:feat/dashboard-live-backend

Conversation

@majh3

@majh3 majh3 commented Oct 25, 2026 •

Copy link
Copy Markdown

Purpose of the PR

Refs #1

为 MemOS Dashboard 提供真实数据后端,完成 Issue #1 中记忆管理、调用日志、工作区和用量统计的服务端接入,并保持原版前端源代码。

Main Changes

P0:记忆管理、调用日志与运行信息

  • 从 MemOS REST 读取真实记忆,集中处理六个标签页与四类原生记忆的映射、分页、关键词及时间/主体筛选、详情和统计。默认统计 activated 记忆,列表通过白名单投影控制响应体积。
  • 提供指定记忆 ID 的软删除,保留图节点、关系和向量,并同步删除状态。
  • 从 MCP 网关审计 JSONL 提供日志列表、筛选、分页及详情,兼容历史缺字段记录;按记录中的工作区和密钥归属隔离数据。
  • /api/meta 返回 mode: live、上游健康状态和运行信息。

P1:工作区与用量

  • 提供工作区管理、选择状态持久化,以及 Dashboard 项目、原生用户和记忆空间之间的显式映射。
  • 从同一份审计 JSONL 按天聚合调用量,提供工作区/API Key 维度及全事件计数;按 Issue 约定将 token 计数字段设为 0。

接口契约与架构

  • 对齐原 37 条接口的统一响应、四种列表键、pageNum/pageSize 及日志详情 JSON 字符串格式。知识库、额度/订阅、技能共 11 条接口按 Issue 约定提供占位响应。
  • 新增与 server/mock/ 并列的 TypeScript BFF server/live/,前端通过 VITE_API_BASE 接入。
  • 配套原生 Python 扩展,提供指定 ID 软删除、工作区 Prompt 和运行时模型清单;网关扩展负责密钥配置热加载及可信审计归属。
  • BFF、Node 测试和部署辅助工具使用 TypeScript,运行环境为 Node 22.18+。部署文档包含配套镜像、配置和卷挂载要求,管理端访问控制由私网或外部鉴权网关提供。

P2/P3 与页面兼容

  • 实现工作区 Prompt 的读取、保存、生成、调试,以及同步文本精细抽取中的生效。
  • 实现 API Key 列表、创建、复制、撤销和网关鉴权;提供工作区范围的属性树模板管理接口。
  • 为当前模型页面补充运行时模型清单接口,展示已初始化组件的模型、用途和类型。

整体设计思路

以保留现有 Dashboard 交互、复用 MemOS 记忆能力为前提,将页面契约适配与记忆引擎分开演进。

  • 独立 BFF 承接页面契约。 相比让前端逐个适配原生 REST,集中处理 DTO、校验和聚合可保持原版页面稳定;相比把全部管理接口放入 MemOS,可减少 UI 状态和报表逻辑与记忆引擎的耦合。代价是增加独立进程及配套部署要求。
  • 数据保持明确归属。 记忆内容、原生类型和状态来自 MemOS;调用事实来自 MCP 网关 JSONL;工作区绑定、模板和密钥元数据由 BFF 持久化。日志和用量共用同一调用源。
  • 身份贯穿读写与审计。 BFF 从可信配置将 projectId 映射到原生 userId/cubeId,网关从凭据确定调用身份。历史日志按记录中的 cube/key 归属过滤,缺失归属的记录保留明确标记。
  • 能力按执行位置划分。 展示转换与统计放在 BFF;过滤、计数、排序、分页下推到受控原生查询,列表返回小投影,详情按精确 ID 读取。软删除、Prompt 和模型清单通过有限原生扩展接入存储或运行时。
  • 轻量部署配合可恢复状态。 当前管理状态采用单写者文件持久化,跨系统创建使用恢复日志及补偿,撤销优先保证凭据失效。多实例并发与更高审计吞吐可进一步升级状态协调和索引存储。
flowchart TB
  Goal[现有Dashboard管理真实MemOS] --> Contract[保留前端交互与接口契约]
  Goal --> Reuse[复用原生记忆与MCP链路]
  Contract --> BFF[独立BFF:校验、DTO与管理聚合]
  Reuse --> BFF
  BFF --> Scope[可信project / user / cube绑定]
  Scope --> Memory[MemOS:记忆与有界查询]
  Scope --> Audit[网关JSONL:日志与用量]
  Scope --> State[管理状态:持久化与恢复]
  Memory --> Extension[有限原生扩展:查询、软删除、Prompt、模型清单]
  State --> Boundary[可信管理入口与单写者部署]
  Audit --> Boundary
  Extension --> Boundary
Loading

完整方案比较、数据归属与执行边界见整体设计说明;受控查询的升级顺序见部署与恢复说明。

页面功能截图

截图使用原版前端连接隔离的真实 MemOS、Neo4j、Qdrant 和 live BFF。记忆为虚构验收数据,原生 SDK 写入用于验证分类和读取映射;调用日志来自实际 MCP 请求。

记忆列表、事件/用户记忆与完整详情

列表与分页

记忆列表与分页

原生 Context / InsightMemory 事件视图

事件记忆

原生 UserMemory 用户记忆视图

用户记忆

按 ID 独立读取详情

记忆详情

调用日志与原始请求详情

调用日志

日志详情

用量趋势与运行时模型清单

用量页展示日期范围和趋势。截图时原始日志/API共4次调用,页面显示3次,画像读取事件尚未被原版页面计入,见下方前端限制。

用量监控

运行时模型

本轮补充验证包含真实10,000条记忆的BFF读取链路,首页面响应32,233字节;Node回归249项通过、5项TODO,候选镜像Python测试44项通过。真实抽取仍受模型认证401阻塞;持续上游502时,原版记忆页停留在加载态,对应错误展示验收未通过。

Verifying these changes

  • Trivial rework / code cleanup without any test coverage. (No Need)
  • Already covered by existing tests, including memory mapping, workspace isolation, audit aggregation, keys, Prompt and contract regression tests.
  • Need tests and can be verified as follows:
    • 类型检查、lint、格式及生产构建:pnpm verify。
    • 前端源文件一致性:node scripts/issue-acceptance/verify-frontend-unchanged.ts。
    • BFF、契约和安全回归:pnpm test:live、pnpm test:issue、pnpm test:issue:safety。
    • OpenAPI 校验:npx --yes @redocly/cli@2.67.1 lint openapi.json。
    • 原生扩展单测覆盖鉴权、软删除、运行时模型清单及安装补丁。

真实服务验收覆盖了原生写入与页面 ID/内容比对、工作区切换、软删除后的存储状态、MCP 调用与原始 JSONL 对照、密钥与 Prompt 生效,以及模型页面内容。性能和健壮性检查覆盖单页记忆响应体积、万行日志首屏响应、上游故障提示及历史日志缺字段。复现命令、环境配置和测试范围见 测试文档及真实服务验收说明。

Remaining frontend limitations

以下 Issue #1 验收项仍需前端接入:

验收项 当前页面实现与阻塞原因 所需前端接入
记忆的时间、主体筛选 Memories.tsx 的请求包含工作区、记忆类型、分页和关键词,尚无时间范围、主体类型/ID的控件及参数绑定。 增加筛选控件,将条件传给已有记忆查询接口。
用量分页、搜索 Usage.tsx 按日期范围获取 dailyStats 后直接渲染全部日记录,缺少分页、搜索控件及对应状态逻辑。 为日统计列表增加分页与搜索交互;现有日期范围切换可继续使用。
全事件调用总数展示 页面仍按 addMessage.calls + searchMemory.calls 计算总数,尚未读取后端的 totalCalls 和 callsByEvent,其他事件未计入展示。 使用全事件计数更新总量及事件分类展示。
模板列表与详情(加分项) ProfileTemplates.tsx 当前渲染 ComingSoon,尚无模板列表、详情视图及接口调用。 接入模板管理接口并补齐列表和详情页面。

这些页面能力补齐后,可复验对应的 Issue 验收项。

Does this PR potentially affect the following parts?

  • Dependencies:新增 ajv、ajv-formats,均为 MIT;许可证及运行镜像保留方式见 依赖说明。
  • Modify configurations:BFF 环境变量、原生扩展开关与令牌、网关配置及 Docker 卷挂载。
  • The public API:Dashboard 接口实现、审计/用量扩展字段及模型清单接口。
  • Other affects:Node 最低版本提升至 22.18,BFF 与原生扩展需配套部署。
  • Nope

Documentation Status

  • Doc - TODO
  • Doc - Done
  • Doc - No Need

Documentation files in this PR:

majh3 and others added 2 commits October 22, 2026 17:31
Connect the unchanged dashboard to real MemOS data through an independent BFF, with scoped native extensions and explicit acceptance boundaries.

👾 Generated with [Letta Code](https://letta.com)

Co-Authored-By: Letta Code <noreply@letta.com>
- Run the live backend and acceptance tools as TypeScript on Node 22.18+.
- Expose authenticated runtime model inventory for the Dashboard.
- Align browser checks and deployment guidance with the Issue 1 contract.

Refs hugegraph#1

👾 Generated with [Letta Code](https://letta.com)

Co-Authored-By: Letta Code <noreply@letta.com>
@coderabbitai

coderabbitai Bot commented Oct 25, 2026 •

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 1cafb547-a7b2-409d-80bd-69e6533ea848

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

Keep large workspaces within response budgets and preserve scoped reads and management state through failures. Document the overall design with live feature screenshots.

👾 Generated with [Letta Code](https://letta.com)

Co-Authored-By: Letta Code <noreply@letta.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant