feat(mcp): resume queued calculation jobs
This commit is contained in:
@@ -468,6 +468,7 @@ export const buildToolProgressDetail = (
|
||||
params: Record<string, unknown>,
|
||||
reason: string,
|
||||
error?: string,
|
||||
output?: string,
|
||||
) => {
|
||||
const toolName = toolLabels[tool] ?? tool;
|
||||
const reasonText = reason ? `;说明:${containsForbiddenPersistentContent(reason) ? "[redacted]" : reason}` : "";
|
||||
@@ -478,6 +479,8 @@ export const buildToolProgressDetail = (
|
||||
return `${toolName} 调用失败${reasonText}${paramsText}${errorText}`;
|
||||
}
|
||||
if (status === "completed") {
|
||||
const calculation = calculationProgress(output);
|
||||
if (calculation) return `${toolName}:${calculation.label};计算任务:${calculation.jobId}${reasonText}${paramsText}`;
|
||||
return `${toolName} 已执行完成${reasonText}${paramsText}`;
|
||||
}
|
||||
if (status === "pending") {
|
||||
@@ -486,8 +489,28 @@ export const buildToolProgressDetail = (
|
||||
return `${toolName} 正在执行${reasonText}${paramsText}`;
|
||||
};
|
||||
|
||||
export const getToolProgressTitle = (tool: string, status: string) => {
|
||||
const calculationProgress = (output?: string) => {
|
||||
if (!output || output.length > 100_000) return null;
|
||||
try {
|
||||
const value = JSON.parse(output);
|
||||
if (value?.semantics !== "task" || typeof value.data?.job_id !== "string" ||
|
||||
!/^[0-9a-f-]{36}$/i.test(value.data.job_id)) return null;
|
||||
const labels: Record<string, string> = {
|
||||
queued: "已提交,等待计算", running: "后台计算中", cancel_requested: "已请求取消,等待计算停止",
|
||||
succeeded: "计算已完成", failed: "计算失败", cancelled: "计算已取消",
|
||||
interrupted: "计算已中断", timed_out: "计算执行超时",
|
||||
};
|
||||
const label = labels[value.data.status];
|
||||
return label ? { label, jobId: value.data.job_id } : null;
|
||||
} catch { return null; }
|
||||
};
|
||||
|
||||
export const getToolProgressTitle = (tool: string, status: string, output?: string) => {
|
||||
const toolName = toolLabels[tool] ?? tool;
|
||||
if (status === "completed") {
|
||||
const calculation = calculationProgress(output);
|
||||
if (calculation) return `${toolName}:${calculation.label}`;
|
||||
}
|
||||
if (status === "completed") return `${toolName} 已完成`;
|
||||
if (status === "error") return `${toolName} 执行失败`;
|
||||
if (status === "pending") return `准备调用 ${toolName}`;
|
||||
|
||||
Reference in New Issue
Block a user