fix: unblock local news page generation

This commit is contained in:
john
2026-07-25 21:55:00 +08:00
parent 793e64bfbc
commit 6b6f9ed01c
16 changed files with 1075 additions and 47 deletions
+17 -3
View File
@@ -88,6 +88,20 @@ const INSUFFICIENT_BALANCE_NOTICE = '余额不足,请充值后继续使用';
const REPLY_RECOVERY_SYNC_DELAYS_MS = [1500, 5000, 12000];
const FINISH_SYNC_RETRY_DELAYS_MS = [500, 1500, 3000];
const ACTIVE_REQUEST_MISSING_GRACE_MS = 2500;
function createAgentRunFailedError(message: string) {
const error = new Error(message) as Error & { code: string };
error.code = 'AGENT_RUN_FAILED';
return error;
}
function errorCode(error: unknown) {
if (error instanceof ApiError) return error.code;
if (error && typeof error === 'object' && 'code' in error) {
return String((error as { code?: unknown }).code ?? '');
}
return '';
}
const DIRECT_CHAT_SESSION_PREFIX = 'h5direct_';
export { INSUFFICIENT_BALANCE_NOTICE };
@@ -198,7 +212,7 @@ async function waitForAgentRunWithDirectChatPreview(
return;
}
if (run.status === 'failed') {
settle(() => reject(new Error(run.error || '后台任务失败,请稍后重试')));
settle(() => reject(createAgentRunFailedError(run.error || '后台任务失败,请稍后重试')));
}
};
@@ -235,7 +249,7 @@ async function waitForAgentRunWithDirectChatPreview(
return;
}
if (run.status === 'failed') {
settle(() => reject(new Error(run.error || '后台任务失败,请稍后重试')));
settle(() => reject(createAgentRunFailedError(run.error || '后台任务失败,请稍后重试')));
return;
}
settle(() =>
@@ -1671,7 +1685,7 @@ export function useTKMindChat(
shouldKeepStreamingAfterRunError(
undefined,
err instanceof Error ? err.message : String(err),
err instanceof ApiError ? err.code : '',
errorCode(err),
)
) {
// Goose may report its session concurrency guard as a failed run