返回 DeepSeek-Reasonix
historyToolStatus.ts
根目录 / desktop / frontend / src / lib / historyToolStatus.ts
1 import type { HistoryMessage, HistoryToolCall } from "./types";
2 import type { ToolStatus } from "./useController";
3
4 /** Missing resident payload is not evidence that execution stopped. */
5 export function historyToolStatus(result: HistoryMessage | undefined, call?: HistoryToolCall, error?: string): ToolStatus {
6 const evidence = result?.execution?.state ?? call?.resultObservation?.state;
7 if (evidence === "cancelled" || evidence === "not_started") return "stopped";
8 if (evidence === "failed" || evidence === "error") return "error";
9 if (error) return "error";
10 if (evidence === "completed" || evidence === "user_confirmed") return "done";
11 if (evidence === "running" || evidence === "started" || evidence === "pending" || call?.pending) return "running";
12 return result ? "done" : "unknown";
13 }
14
14 lines TYPESCRIPT