feat: 对接设计 Agent Gateway WebSocket
需求:服务端统一 Agent Gateway 将设计任务状态流切换为 WebSocket,客户端需要实时展示生成任务并支持断线恢复。 实现:Electron Main 管理 Session、一次性 Ticket、WebSocket 心跳与游标续传,按关闭码回收会话;Renderer 继续通过本机 Host API 的 SSE 投影接收任务事件,并保留 REST 降级同步。 验证:typecheck、变更文件 ESLint、37 个聚焦测试及 build:vite 通过。
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
import { AppError } from '@/lib/error-model';
|
||||
import {
|
||||
createHostEventSource,
|
||||
ensureHostApiToken,
|
||||
getHostApiBase,
|
||||
hostApiFetch,
|
||||
@@ -159,6 +160,13 @@ export function fetchImageWorkspaceTasks(
|
||||
);
|
||||
}
|
||||
|
||||
export async function openImageWorkspaceTaskEvents(workspaceId: string): Promise<EventSource> {
|
||||
await ensureHostApiToken();
|
||||
return createHostEventSource(
|
||||
`${IMAGE_WORKSPACE_API_PATH}/workspaces/${encodeURIComponent(workspaceId)}/events`,
|
||||
);
|
||||
}
|
||||
|
||||
export async function resolveImageWorkspaceAssetUrl(contentPath: string): Promise<string> {
|
||||
const token = await ensureHostApiToken();
|
||||
const separator = contentPath.includes('?') ? '&' : '?';
|
||||
|
||||
Reference in New Issue
Block a user