refactor: extract utility modules from main.tsx
- Split 1504-line monolithic main.tsx into 5 utility modules: - src/utils/tool-maps.ts (TOOL_GROUPS, TOOL_TO_UI, MODEL_OPTIONS, QUICK_PROMPTS) - src/utils/input-handling.ts (keyboard shortcuts, textarea, event listeners) - src/utils/thread-management.ts (deduplication, thread helpers) - src/utils/message-rendering.ts (tool call extraction, UI matching) - src/utils/api-client.ts (LangGraph API client operations) - Add missing deps: unist-util-visit, hast - Update agent model configs (opus for backend, haiku for tester) Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Haiku 4.5
parent
179aab55f0
commit
aec776e60c
@@ -24,6 +24,8 @@ tools:
|
||||
- mcp__v0__getChat
|
||||
- mcp__v0__getUser
|
||||
- mcp__v0__sendChatMessage
|
||||
skills:
|
||||
- agent-browser
|
||||
---
|
||||
|
||||
# so-c-chat-clone 后端开发 Agent
|
||||
@@ -62,8 +64,9 @@ tools:
|
||||
- **Daytona Sandbox** — 受控代码执行
|
||||
|
||||
### 协议与接入
|
||||
- **SSE** — 流式输出到前端
|
||||
- **HTTP API** — 前端接入层(非 FastAPI,使用 Litestar)
|
||||
- **SSE** — 流式输出到前端(streamMode: ["values","messages"] + streamSubgraphs: true)
|
||||
- **HTTP API** — Hono middleware(安全头过滤)+ LangGraph Server 内置路由
|
||||
- **@langchain/langgraph-sdk@1.8.8** — 支持 streamSubgraphs
|
||||
|
||||
## 功能模块与开发顺序
|
||||
|
||||
@@ -94,44 +97,28 @@ tools:
|
||||
- Azure Service Bus 异步任务
|
||||
- LangGraph checkpoint 持久化和恢复
|
||||
|
||||
## 接口清单
|
||||
## LangGraph Server 端点
|
||||
|
||||
```
|
||||
GET /health
|
||||
GET /api/conversations
|
||||
POST /api/conversations
|
||||
GET /api/conversations/{id}
|
||||
PATCH /api/conversations/{id}
|
||||
DELETE /api/conversations/{id}
|
||||
POST /api/chat/stream ← 核心 SSE 接口
|
||||
GET /api/tickets/summary
|
||||
GET /api/tickets
|
||||
GET /api/tickets/{id}
|
||||
POST /api/search/internal
|
||||
POST /api/search/external
|
||||
POST /api/documents/generate
|
||||
GET /api/documents/{task_id}
|
||||
POST /api/attachments
|
||||
GET /api/attachments/{id}
|
||||
POST /api/sandbox/run
|
||||
GET /ok ← 健康检查(langgraphjs 内置)
|
||||
GET /info ← 服务信息(graphs 列表)
|
||||
POST /threads ← 创建线程
|
||||
GET /threads/{id} ← 线程详情
|
||||
POST /runs/stream ← SSE 流式调用(核心)
|
||||
POST /assistants/search ← 查询 assistants
|
||||
```
|
||||
|
||||
## 前端对接契约
|
||||
|
||||
前端 `GeminiChat.tsx` 中的 `simulateAIResponse()` 替换为真实 API 调用,格式:
|
||||
|
||||
前端使用 `@langchain/langgraph-sdk/react` 的 `useStream` hook:
|
||||
```typescript
|
||||
// main.tsx
|
||||
thread.submit({ messages }, {
|
||||
streamMode: ["values", "messages"],
|
||||
streamSubgraphs: true,
|
||||
});
|
||||
```
|
||||
POST /api/chat/stream
|
||||
{
|
||||
"message": "用户输入",
|
||||
"conversation_id": "conv-{timestamp}",
|
||||
"tools": ["search", "knowledge", "sandbox", "document"],
|
||||
"model": "flash" | "pro"
|
||||
}
|
||||
→ SSE 流,最终 content 为 Markdown 文本
|
||||
```
|
||||
|
||||
工单摘要:`GET /api/tickets/summary` → 替换前端 `MOCK_TICKETS`
|
||||
SSE 事件名格式:`event: values|searcher|coder|writer`(子图名)
|
||||
|
||||
## 外部服务环境变量
|
||||
|
||||
@@ -180,7 +167,7 @@ DATABASE_URL=postgresql://azuredb:...@dataope.postgres.database.azure.com:5432/s
|
||||
|
||||
1. 开发前必须先读 `/Users/gongzhiyong/go/SOC/gpthd.md` 了解完整功能方案
|
||||
2. 修改前先 Read 理解现有代码,使用 Edit 做最小化修改
|
||||
3. 前端路径 `frontend/` 下的所有文件只读,未经明确指定不允许修改
|
||||
4. 本地用 `.env` 读取环境变量,生产通过 Azure Web App 应用设置配置
|
||||
3. 前端路径 `langgraph/src/components/` 和 `langgraph/src/agent-uis/` 下的文件只读,未经明确指定不允许修改
|
||||
4. 本地用 `.env` 读取环境变量,生产通过 Azure Container App 环境变量配置
|
||||
5. 遇到 Azure 资源组限制时立即停止并告知用户
|
||||
6. 每次任务完成后使用 `mcp__cursor-project-memory__memory_write` 写入开发日志
|
||||
|
||||
Reference in New Issue
Block a user