feat(ai): 阶段 2 Ask|Agent 共用 aitools Runtime 真查库

- 侧栏 Ask|Agent 分段;Ask 仍走 /api/ai/chat,Agent 走 /api/ai/agent
- RunAgent 多轮 tool call → 进程内 aitools(与 MCP 同源只读/白名单/审计)
- 回复下步骤时间线;openai-chat tools(DeepSeek);agent-accept 冒烟
This commit is contained in:
logan committed 2026-10-15 11:51:39 +08:00
1 parent b8134c4503
commit cd319ce7bd
14 files changed
+1270 -182

No files matched your search

+19 -3
View File
@@ -189,13 +189,26 @@ export type ConfirmRequest = {
items?: string[];
};
export type AiAgentStepView = {
tool: string;
args?: string;
ok: boolean;
summary: string;
error?: string;
ms: number;
};
export type AiMessage = {
id: string;
role: "user" | "assistant" | "system";
content: string;
at: string;
/** Agent 工具步骤时间线(仅 assistant) */
steps?: AiAgentStepView[];
};
export type AiChatMode = "ask" | "agent";
export type ViewMode = "workbench" | "picker";
export type PickerMode = "list" | "drivers";
@@ -236,6 +249,8 @@ type State = {
aiAsk: string;
aiModel: string;
aiBusy: boolean;
/** Ask=不调工具;Agent=多轮 aitools */
aiMode: AiChatMode;
status: string;
notifyModal: NotifyPayload | null;
notifyToasts: NotifyPayload[];
@@ -305,7 +320,7 @@ type State = {
updateActiveSql: (sql: string) => void;
/** AI 异步返回只写入原标签;用户编辑或切库后跳过。 */
updateTabSqlIfUnchanged: (id: string, originalSql: string, connectionId: string | undefined, database: string | undefined, sql: string) => boolean;
pushAi: (role: AiMessage["role"], content: string) => void;
pushAi: (role: AiMessage["role"], content: string, steps?: AiAgentStepView[]) => void;
setSession: (connectionId: string, sessionId: string | null) => void;
pushHistory: (item: Omit<QueryHistoryItem, "id" | "at"> & { at?: number }) => void;
clearHistory: () => void;
@@ -465,6 +480,7 @@ export const useWorkspaceStore = create<State>((set, get) => ({
aiAsk: "",
aiModel: "opsxdb-stub",
aiBusy: false,
aiMode: "ask",
status: "就绪",
notifyModal: null,
notifyToasts: [],
@@ -878,11 +894,11 @@ export const useWorkspaceStore = create<State>((set, get) => ({
return true;
},
pushAi: (role, content) =>
pushAi: (role, content, steps) =>
set((s) => ({
aiMessages: [
...s.aiMessages,
{ id: crypto.randomUUID(), role, content, at: new Date().toLocaleTimeString() },
{ id: crypto.randomUUID(), role, content, at: new Date().toLocaleTimeString(), steps },
],
})),