chore: commit workspace updates
This commit is contained in:
21
web/src/lib/canvas/agent-error-presentation.ts
Normal file
21
web/src/lib/canvas/agent-error-presentation.ts
Normal file
@@ -0,0 +1,21 @@
|
||||
import { ApiError } from "@/services/api/request";
|
||||
import { AgentStreamError } from "@/services/api/agent";
|
||||
|
||||
export function agentErrorPresentation(cause: unknown, fallback = "Agent 执行失败") {
|
||||
const text = typeof cause === "string" ? cause.trim() : cause instanceof Error ? cause.message : fallback;
|
||||
if ((cause instanceof ApiError || cause instanceof AgentStreamError) && cause.status === 404) {
|
||||
return {
|
||||
title: "Agent 接口或资源不存在",
|
||||
text: text || "当前后端未找到请求的 Agent 接口或会话资源。",
|
||||
meta: "请确认后端已加载 Agent 路由,以及画布、会话和模型仍可访问;旧进程需要更新后重启。",
|
||||
};
|
||||
}
|
||||
if (cause instanceof ApiError && cause.status === 501) {
|
||||
return {
|
||||
title: "当前 Agent 能力尚未开放",
|
||||
text: text || "当前请求的 Agent 能力尚未开放,请使用 capabilities 返回的权限和工具范围。",
|
||||
};
|
||||
}
|
||||
// 渠道、鉴权、配额等业务错误保留真实语义,不能按 message 猜测为服务未部署。
|
||||
return { title: fallback, text: text || fallback };
|
||||
}
|
||||
Reference in New Issue
Block a user