feat(v3): T24 智能体工作区选择 UI + harness 风格工具卡
- 工作区选择栏(当前目录徽标 + 选择目录按钮 + 允许执行命令开关) - 目录选择器模态:盘符→逐级浏览、上级、手输路径、不存在可新建、最近工作区快选 - edit_file 渲染为红/绿 diff 卡;run_command 渲染 $ 命令卡;文件面板随所选目录切换
This commit is contained in:
+45
-10
@@ -336,12 +336,13 @@ export interface AgentStatus {
|
||||
error?: string | null
|
||||
started_at?: number
|
||||
finished_at?: number
|
||||
workspace?: string
|
||||
}
|
||||
|
||||
/** POST /agent:提交智能体任务 */
|
||||
export async function startAgent(task: string, poolId?: string) {
|
||||
const { data } = await http.post<{ request_id: string; status: string; model: string }>(
|
||||
'/agent', { task, pool_id: poolId || undefined })
|
||||
/** POST /agent:提交智能体任务(workspace 可选:选中工作目录) */
|
||||
export async function startAgent(task: string, poolId?: string, workspace?: string) {
|
||||
const { data } = await http.post<{ request_id: string; status: string; model: string; workspace?: string }>(
|
||||
'/agent', { task, pool_id: poolId || undefined, workspace: workspace || undefined })
|
||||
return data
|
||||
}
|
||||
|
||||
@@ -357,20 +358,54 @@ export async function getAgentEvents(requestId: string) {
|
||||
return data
|
||||
}
|
||||
|
||||
/** GET /agent/workspace?path=...:浏览工作区目录 */
|
||||
export async function listAgentWorkspace(path = '') {
|
||||
/** GET /agent/workspace?path=&root=:浏览工作区目录(root 可指定选中工作区) */
|
||||
export async function listAgentWorkspace(path = '', root = '') {
|
||||
const { data } = await http.get<{
|
||||
ok: boolean
|
||||
entries?: { name: string; type: string; size?: number }[]
|
||||
error?: string
|
||||
}>('/agent/workspace', { params: path ? { path } : {} })
|
||||
}>('/agent/workspace', { params: { ...(path ? { path } : {}), ...(root ? { root } : {}) } })
|
||||
return data
|
||||
}
|
||||
|
||||
/** GET /agent/file?path=...:读取工作区文件 */
|
||||
export async function readAgentFile(path: string) {
|
||||
/** GET /agent/file?path=&root=:读取工作区文件 */
|
||||
export async function readAgentFile(path: string, root = '') {
|
||||
const { data } = await http.get<{ ok: boolean; content: string; truncated: boolean; error?: string }>(
|
||||
'/agent/file', { params: { path } })
|
||||
'/agent/file', { params: { path, ...(root ? { root } : {}) } })
|
||||
return data
|
||||
}
|
||||
|
||||
// ── 智能体:工作区选择(参考 deepseek-harness 的打开文件夹体验) ─────────────
|
||||
|
||||
export interface FsBrowse {
|
||||
ok: boolean
|
||||
path: string
|
||||
parent: string
|
||||
dirs: string[]
|
||||
error?: string
|
||||
}
|
||||
|
||||
export interface WorkspacesInfo {
|
||||
current: string
|
||||
recent: string[]
|
||||
}
|
||||
|
||||
/** GET /agent/fs?path=:浏览本地目录(目录选择器,只列子目录) */
|
||||
export async function browseFs(path = '') {
|
||||
const { data } = await http.get<FsBrowse>('/agent/fs', { params: path ? { path } : {} })
|
||||
return data
|
||||
}
|
||||
|
||||
/** GET /agent/workspaces:当前工作区 + 最近列表 */
|
||||
export async function getAgentWorkspaces() {
|
||||
const { data } = await http.get<WorkspacesInfo>('/agent/workspaces')
|
||||
return data
|
||||
}
|
||||
|
||||
/** POST /agent/workspaces:打开(或新建)工作目录并设为当前 */
|
||||
export async function openWorkspace(path: string, create = false) {
|
||||
const { data } = await http.post<{ ok: boolean; current: string; recent: string[] }>(
|
||||
'/agent/workspaces', { path, create })
|
||||
return data
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user