logo
2
0
WeChat Login

feat: 重构后端为 TypeScript 版本 (Phase 1-3)#3

Open
created 1 months ago
main
refactor/backend-python-to-typescript
Edit
OverviewCommits
2
Files changed
67
Attachments

Summary

将后端 `backend/` 从 Python 重构为 TypeScript 版本 `backend-ts/`,使用 Node.js + Hono,保持与 Python 版 API 完全兼容。

变更内容

Phase 1: 项目脚手架 + 配置层

  • 初始化 `backend-ts/` 项目:`package.json`、`tsconfig.json`、`vitest.config.ts`
  • 18 个配置模块从 Pydantic 迁移到 Zod(model、sandbox、tool、memory、skills 等)
  • `Paths` 路径管理(线程目录、沙箱挂载、虚拟路径解析)
  • 主配置加载器 `AppConfig`:YAML 加载 + `$ENV_VAR` 解析 + 文件变更自动重载

Phase 2: Gateway 层 (FastAPI → Hono)

  • 应用入口 + 生命周期管理
  • 依赖注入框架 (StreamBridge / RunManager / Checkpointer / Store)
  • 13 个 Router 模块:health, models, mcp, memory, skills, artifacts, uploads, threads, agents, suggestions, channels, assistants-compat, thread-runs, runs
  • SSE 流式响应(兼容 LangGraph Platform 协议,`useStream` React hook 可直接使用)

Phase 3: Runtime 层

  • `RunManager` + `RunRecord` + `RunStatus` / `DisconnectMode`
  • `MemoryStreamBridge`(内存事件日志 + 心跳 + Last-Event-ID 重连)
  • `MemoryStore`(线程元数据存储)
  • 序列化工具(LangChain 消息对象 → JSON-safe dicts)

验证

  • TypeScript strict 编译:0 errors
  • 所有 API 路径与 Python 版保持一致

后续 Phase

  • Phase 4: Agent 核心引擎 (LangGraph Agent 工厂 + 14 个 Middleware)
  • Phase 5: Tools + Sandbox + Skills + Memory + Channels + 其他

Closes #1

owner

@CodeBuddy 修复冲突

No conflicts between the source branch and the target branch
Merge
Reviewer
None yet
Assignee
None yet
Label
None yet
Participant