feat(agent): control reasoning visibility

This commit is contained in:
2026-07-17 14:05:54 +08:00
parent bfaf2ebf67
commit a879dc2ff1
18 changed files with 368 additions and 51 deletions

View File

@@ -222,6 +222,8 @@ export const api = {
export async function streamDebugAgent(
payload: Record<string, unknown>,
onChunk: (chunk: string) => void,
onReasoning: (chunk: string) => void,
onStatus: (status: { message: string; reasoningVisible: boolean }) => void,
onComplete: (result: AgentDebugStreamComplete) => void,
signal?: AbortSignal,
) {
@@ -256,9 +258,14 @@ export async function streamDebugAgent(
const parsed = JSON.parse(data) as AgentDebugStreamComplete & {
type?: string;
content?: string;
reasoningVisible?: boolean;
};
if (parsed.type === "error") throw new Error(parsed.message || "Agent 调试失败");
if (parsed.type === "content" && parsed.content) onChunk(parsed.content);
if (parsed.type === "reasoning" && parsed.content) onReasoning(parsed.content);
if (parsed.type === "status") {
onStatus({ message: parsed.message || "思考中", reasoningVisible: Boolean(parsed.reasoningVisible) });
}
if (parsed.type === "complete") onComplete(parsed);
}
}