mirror of
https://github.com/aiclientproxy/proxycast.git
synced 2026-09-24 23:10:56 +08:00
release: v0.91.0
This commit is contained in:
@@ -7,6 +7,8 @@ Lime 已完整集成 aster-rust 框架,包括凭证池桥接。
|
||||
## 当前事实源
|
||||
|
||||
- `Aster thread / turn / item runtime` 是运行态事实源。
|
||||
- Aster shared runtime store 与全局 session store 必须在 Lime bootstrap 启动期显式初始化;启动恢复时由 runtime support 统一完成 legacy queue 迁移与 queued session 枚举。
|
||||
- 运行时命令与 service 只允许读取已准备好的 shared store / shared queue service,不再在热路径偷偷 fallback 到默认路径。
|
||||
- Lime 只负责事件映射、数据库投影和 UI 派生,不再伪造核心 runtime item。
|
||||
- 会话删除统一收口到存储边界;命令层和 Dev Bridge 不应直接调用 `AgentDao::delete_session`。
|
||||
- 需要恢复运行态时,优先从 Aster runtime 恢复,再映射到 Lime timeline。
|
||||
|
||||
@@ -23,9 +23,12 @@ Tauri 命令是前端与 Rust 后端通信的边界,但前端业务代码**不
|
||||
|
||||
## 当前事实源
|
||||
|
||||
- 聊天主命令:`chat_*`
|
||||
- Agent / Codex 主命令:`agent_runtime_*`
|
||||
- 运行态摘要主链:Aster `runtime_status` item -> timeline `turn_summary`
|
||||
- `chat_*` 已停止注册,且不再纳入 `commands::mod` 编译图;旧 General / Creator / 历史桥接如仍需恢复,必须显式走新的 compat 评审
|
||||
- 旧 `general_chat_*` 前端 compat 网关与 Rust 命令已删除
|
||||
- 当前剩余治理重点:统计、记忆等旁路仍在读取 `general_chat_*` 历史表
|
||||
- `Tauri runtime_status` 事件只保留前端瞬时状态用途,不再作为 timeline 事实源
|
||||
- 当前剩余治理重点:统计、记忆等旁路继续按 `runtime context` 与 `durable knowledge` 分层收口
|
||||
|
||||
## 治理案例:记忆系统
|
||||
|
||||
@@ -45,7 +48,8 @@ Tauri 命令是前端与 Rust 后端通信的边界,但前端业务代码**不
|
||||
4. 如果存在旧命令又无任何调用,就直接删掉命令注册、桥接和 mock,不要继续保留空兼容壳
|
||||
|
||||
同理,对话系统也不应该重新引回已经删除的 `general_chat_*` 命令;
|
||||
后续如需扩展聊天能力,应继续收敛到 `chat_*` 与对应网关。
|
||||
后续如需扩展 Agent / Codex 工作流,应继续收敛到 `agent_runtime_*` 与对应网关;
|
||||
`chat_*` 只允许作为 dead-candidate 参考,不应重新回到 `commands::mod` 或 `generate_handler!`。
|
||||
|
||||
## 目录结构
|
||||
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
↓
|
||||
用户发送消息 → useAgentChatUnified.sendMessage()
|
||||
↓
|
||||
统一收口到 useAsterAgentChat / agent_runtime_*
|
||||
统一收口到 useAgentChatUnified / useAsterAgentChat / agent_runtime_*
|
||||
↓
|
||||
第一条消息时注入 systemPrompt → 发送到 Aster Agent
|
||||
↓
|
||||
@@ -40,7 +40,7 @@ src/components/
|
||||
│ └── parser.ts # A2UI 和 write_file 解析器
|
||||
├── agent/chat/
|
||||
│ ├── hooks/
|
||||
│ │ ├── index.ts # useAgentChatUnified 统一入口
|
||||
│ │ ├── index.ts # Agent chat hooks 导出入口
|
||||
│ │ └── useAsterAgentChat.ts # Agent 聊天主 Hook
|
||||
│ ├── components/
|
||||
│ │ ├── StreamingRenderer.tsx # 流式渲染(解析 write_file)
|
||||
@@ -119,7 +119,7 @@ export function parseAIResponse(
|
||||
- `write_file` - 完整的文件写入
|
||||
- `pending_write_file` - 流式传输中的文件写入
|
||||
|
||||
### 3. useAgentChatUnified / useAsterAgentChat - systemPrompt 注入
|
||||
### 3. useAsterAgentChat - systemPrompt 注入
|
||||
|
||||
在发送第一条消息时注入 systemPrompt,并通过现役 runtime adapter 提交到 `agent_runtime_*`。
|
||||
|
||||
|
||||
@@ -177,7 +177,7 @@ npm run governance:legacy-report
|
||||
|
||||
例如:
|
||||
|
||||
> 聊天能力后续统一收敛到 `useUnifiedChat + chat_* + ChatDao`。
|
||||
> 聊天能力后续统一收敛到 `useAgentChatUnified -> useAsterAgentChat -> agent_runtime_* + lime_core::database::agent_session_repository`。
|
||||
|
||||
### 第三步:优先做减法
|
||||
|
||||
@@ -207,8 +207,8 @@ npm run governance:legacy-report
|
||||
|
||||
以聊天系统为例,遇到新旧并存时,必须同时问这几个问题:
|
||||
|
||||
- 前端唯一入口是不是 `useAgentChatUnified` / `useAsterAgentChat`,还是 `useChat` / `useAgentChat` 还在继续长逻辑?
|
||||
- Rust 唯一入口是不是 `chat_*`,还是 `general_chat_*` / `agent_*` / `aster_agent_*` 还在平行演进?
|
||||
- 前端唯一入口是不是 `useAgentChatUnified -> useAsterAgentChat`,还是 `useChat` / `useAgentChat` / `useUnifiedChat` 还在继续长逻辑?
|
||||
- Rust 唯一入口是不是 `agent_runtime_*`,还是 `chat_*` / `general_chat_*` / `agent_*` / `aster_agent_*` 还在平行演进?
|
||||
- 数据事实源是不是同一组表 / 同一套 Repository,还是还在同时写 `agent_*` 与 `general_chat_*`?
|
||||
- 统计、记忆等旁路是不是已经切到新路径,还是还在读旧表?
|
||||
|
||||
|
||||
+10
-56
@@ -9,7 +9,6 @@
|
||||
```
|
||||
src/hooks/
|
||||
├── index.ts # 导出入口
|
||||
├── useUnifiedChat.ts # 统一对话 Hook(新)
|
||||
├── useProviderPool.ts # 凭证池管理
|
||||
├── useOAuthCredentials.ts # OAuth 凭证
|
||||
├── useFlowEvents.ts # 流量事件
|
||||
@@ -22,69 +21,24 @@ src/hooks/
|
||||
|
||||
- 新的前端能力优先落在 `src/lib/api/*`,再由 Hook 或组件消费。
|
||||
- 历史 `useTauri.ts` 兼容聚合层已删除,不要重新引入新的“大一统 API Hook”。
|
||||
- 旧聊天链路优先迁移到 `@/hooks/useUnifiedChat`,不要继续扩散 `useChat` / compat Hook。
|
||||
- Agent 工作台统一走 `src/components/agent/chat/hooks/index.ts` 暴露的 `useAgentChatUnified`,底层实现委托 `useAsterAgentChat`。
|
||||
- 历史 `@/hooks/useUnifiedChat` 与 `src/lib/api/unified-chat.ts` 已删除,不要重建 compat Hook / API。
|
||||
|
||||
## 核心 Hooks
|
||||
|
||||
### useUnifiedChat(统一对话)
|
||||
### useAgentChatUnified / useAsterAgentChat(现役 Agent 对话)
|
||||
|
||||
统一的对话 Hook,支持三种模式:Agent、General、Creator。
|
||||
现役 Agent / Codex 工作台事实源:
|
||||
|
||||
```typescript
|
||||
import { useUnifiedChat } from "@/hooks/useUnifiedChat";
|
||||
|
||||
// Agent 模式 - 支持工具调用
|
||||
const { messages, sendMessage, stopGeneration } = useUnifiedChat({
|
||||
mode: "agent",
|
||||
providerType: "claude",
|
||||
model: "claude-sonnet-4-20250514",
|
||||
});
|
||||
|
||||
// Creator 模式 - 支持画布输出
|
||||
const creatorChat = useUnifiedChat({
|
||||
mode: "creator",
|
||||
systemPrompt: "你是内容创作助手...",
|
||||
harnessConfig: {
|
||||
theme: "social-media",
|
||||
artifactMode: "version-chain",
|
||||
},
|
||||
onHarnessEvent: (event) => {
|
||||
/* 接收阶段推进、产物创建等语义事件 */
|
||||
},
|
||||
onArtifactUpdate: (artifact) => {
|
||||
/* 接收产物快照 */
|
||||
},
|
||||
onCanvasUpdate: (path, content) => {
|
||||
/* 更新画布 */
|
||||
},
|
||||
onWriteFile: (content, fileName) => {
|
||||
/* 文件写入 */
|
||||
},
|
||||
});
|
||||
|
||||
// General 模式 - 纯文本对话
|
||||
const generalChat = useUnifiedChat({ mode: "general" });
|
||||
```
|
||||
|
||||
**返回值**:
|
||||
|
||||
- `session` - 当前会话
|
||||
- `messages` - 消息列表
|
||||
- `isLoading` / `isSending` - 状态
|
||||
- `createSession()` / `loadSession()` / `deleteSession()` - 会话管理
|
||||
- `sendMessage()` / `stopGeneration()` - 消息操作
|
||||
- `configureProvider()` - Provider 配置
|
||||
|
||||
**补充说明**:
|
||||
|
||||
- Creator 模式现在支持 `harnessConfig`、`onHarnessEvent`、`onArtifactUpdate`
|
||||
- 社媒内容推荐把 `<write_file>` 结果投影为“版本链产物”,而不是只按文件名覆盖
|
||||
- `useAgentChatUnified -> useAsterAgentChat -> useAgentContext / useAgentSession / useAgentTools / useAgentStream`
|
||||
- 命令主链:`agent_runtime_submit_turn -> runtime items(plan / runtime_status / artifact / tool / action) -> action_required -> respond_action`
|
||||
- 适用场景:Agent 工作台、任务执行、工具审批、timeline 渲染
|
||||
|
||||
**相关文件**:
|
||||
|
||||
- 类型定义:`src/types/chat.ts`
|
||||
- API 封装:`src/lib/api/unified-chat.ts`
|
||||
- 架构文档:`docs/prd/chat-architecture-redesign.md`
|
||||
- 统一入口:`src/components/agent/chat/hooks/index.ts`
|
||||
- Hook 实现:`src/components/agent/chat/hooks/useAsterAgentChat.ts`
|
||||
- API 封装:`src/lib/api/agentRuntime.ts`
|
||||
|
||||
### useProviderPool
|
||||
|
||||
|
||||
@@ -22,7 +22,7 @@ src-tauri/src/services/
|
||||
## 核心服务
|
||||
|
||||
> 注意:`general_chat/` 兼容壳已删除。
|
||||
> 新功能与新治理都应直接落到 unified chat / `chat_*` 体系,不要重新引回旧入口。
|
||||
> 新功能与新治理都应直接落到 `agent_runtime_*` 与现役 `agent/chat` 体系,不要重新引回旧入口。
|
||||
> `ProviderPoolService::select_credential_with_fallback_legacy` 也已删除,凭证选择统一走现役 `select_credential_with_fallback`。
|
||||
|
||||
### ProviderPoolService
|
||||
|
||||
Reference in New Issue
Block a user