feat(v3): T27 会话式智能体(多轮上下文/停止/对话式 UI,对齐 dsh 范式)
- ToolLoop 增 history 参数(既往轮次折叠为对话上下文,近 6 轮)
- 会话制:AgentSession/SessionStore 持久化 agent_runs/sessions/{sid}.json,
/agent/sessions CRUD + /agent 带 session_id(继承会话工作区与执行者配置,busy 并发控制)
- POST /agent/{id}/cancel:取消运行中任务
- AgentView 重构为对话式:会话列表 + 居中消息流(用户蓝气泡/助手白卡)+ 底部 composer
(工作区/执行者/命令 chips,Enter 发送,运行中红色停止钮),工具过程折叠收纳
- 工具步数统计统一至事件写入层并透出 status.tool_calls
- fix(tests): 会话存储测试隔离,防测试数据泄漏进真实 sessions 目录
- 测试 +4,全量 281 passed
This commit is contained in:
+3
-3
@@ -1,14 +1,14 @@
|
||||
{
|
||||
"schemaVersion": "mimosa-hook-status/v1",
|
||||
"recordedAt": "2026-09-01T11:06:34.610Z",
|
||||
"recordedAt": "2026-09-01T14:21:11.564Z",
|
||||
"sessionId": "sess_e50d4f25-3ac6-43f2-b2f3-8833b3150465",
|
||||
"event": "PostToolUse",
|
||||
"toolName": "Edit",
|
||||
"file": "src/style.css",
|
||||
"file": "src/views/AgentView.vue",
|
||||
"outcome": "clear",
|
||||
"coverage": "complete",
|
||||
"findingCount": 0,
|
||||
"durationMs": 3,
|
||||
"durationMs": 7,
|
||||
"hostState": "hook_complete",
|
||||
"reportHint": ".mimosa/reports/"
|
||||
}
|
||||
|
||||
+70
-2
@@ -345,22 +345,90 @@ export interface AgentStatus {
|
||||
workspace?: string
|
||||
executor_model?: string
|
||||
mode?: 'single' | 'dual'
|
||||
tool_calls?: number
|
||||
}
|
||||
|
||||
/** POST /agent:提交智能体任务(executorPoolId 可选:两级模式的执行者/本地小模型) */
|
||||
export async function startAgent(task: string, poolId?: string, workspace?: string, executorPoolId?: string) {
|
||||
/** POST /agent:提交智能体任务(sessionId 可选:会话式多轮) */
|
||||
export async function startAgent(
|
||||
task: string, poolId?: string, workspace?: string,
|
||||
executorPoolId?: string, sessionId?: string,
|
||||
) {
|
||||
const { data } = await http.post<{
|
||||
request_id: string; status: string; model: string
|
||||
workspace?: string; mode?: 'single' | 'dual'; executor_model?: string
|
||||
session_id?: string | null
|
||||
}>('/agent', {
|
||||
task,
|
||||
pool_id: poolId || undefined,
|
||||
workspace: workspace || undefined,
|
||||
executor_pool_id: executorPoolId || undefined,
|
||||
session_id: sessionId || undefined,
|
||||
})
|
||||
return data
|
||||
}
|
||||
|
||||
/** POST /agent/{id}/cancel:停止运行中的智能体任务 */
|
||||
export async function cancelAgent(requestId: string) {
|
||||
const { data } = await http.post<{ ok: boolean; detail?: string }>(
|
||||
`/agent/${requestId}/cancel`)
|
||||
return data
|
||||
}
|
||||
|
||||
// ── 智能体会话(dsh 式多轮) ─────────────────────────────────────────────────
|
||||
|
||||
export interface AgentSessionBrief {
|
||||
id: string
|
||||
title: string
|
||||
workspace?: string
|
||||
created_at?: number
|
||||
updated_at?: number
|
||||
busy?: boolean
|
||||
pool_id?: string
|
||||
executor_pool_id?: string
|
||||
turns: number | unknown[]
|
||||
}
|
||||
|
||||
export interface AgentSessionDetail extends AgentSessionBrief {
|
||||
turns: {
|
||||
request_id: string
|
||||
task: string
|
||||
response: string
|
||||
state: string
|
||||
tool_calls: number
|
||||
tokens: number
|
||||
error?: string | null
|
||||
ts?: number
|
||||
}[]
|
||||
}
|
||||
|
||||
/** POST /agent/sessions:创建会话 */
|
||||
export async function createAgentSession(workspace?: string, executorPoolId?: string, title?: string) {
|
||||
const { data } = await http.post<AgentSessionDetail>('/agent/sessions', {
|
||||
title: title || undefined,
|
||||
workspace: workspace || undefined,
|
||||
executor_pool_id: executorPoolId || undefined,
|
||||
})
|
||||
return data
|
||||
}
|
||||
|
||||
/** GET /agent/sessions:会话列表 */
|
||||
export async function listAgentSessions() {
|
||||
const { data } = await http.get<AgentSessionBrief[]>('/agent/sessions')
|
||||
return data
|
||||
}
|
||||
|
||||
/** GET /agent/sessions/{sid}:会话详情(含轮次) */
|
||||
export async function getAgentSession(sid: string) {
|
||||
const { data } = await http.get<AgentSessionDetail>(`/agent/sessions/${sid}`)
|
||||
return data
|
||||
}
|
||||
|
||||
/** DELETE /agent/sessions/{sid}:删除会话 */
|
||||
export async function deleteAgentSession(sid: string) {
|
||||
const { data } = await http.delete<{ ok: boolean }>(`/agent/sessions/${sid}`)
|
||||
return data
|
||||
}
|
||||
|
||||
/** GET /agent/{id}/status */
|
||||
export async function getAgentStatus(requestId: string) {
|
||||
const { data } = await http.get<AgentStatus>(`/agent/${requestId}/status`)
|
||||
|
||||
+486
-440
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user