fix(prompt-gate): harden internal prompt dispatch

This commit is contained in:
YeonGyu-Kim
2026-05-19 16:02:18 +09:00
parent 6c63372ef9
commit 1492bffd20
49 changed files with 1488 additions and 141 deletions
+24
View File
@@ -0,0 +1,24 @@
export function extractPromptFailureMessage(error: unknown): string {
if (typeof error === "string") return error
if (error instanceof Error) return error.message
if (typeof error === "object" && error !== null) {
const record = error as Record<string, unknown>
if (typeof record.message === "string") return record.message
try {
return JSON.stringify(error)
} catch {
return ""
}
}
return String(error)
}
export function isAmbiguousPromptDispatchFailure(error: unknown): boolean {
const message = extractPromptFailureMessage(error).toLowerCase()
return (
message.includes("unexpected eof")
|| message.includes("json parse error")
|| message.includes("unexpected end of json input")
|| message.includes("timed out")
)
}