feat(agent): control reasoning visibility
This commit is contained in:
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user