feat(engine): add opt-in image timeout and scene-paint hedging

IMAGE_TIMEOUT_MS sets a per-attempt hard deadline (AbortSignal.timeout);
IMAGE_HEDGE_MS races a second identical scene-paint request when the
first is still pending past the threshold. Both default to OFF when
unset, preserving historical behavior for self-hosted deploys.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
yuanzonghao
2026-06-13 11:21:47 +08:00
parent c4ffc16498
commit e68e7e1690
8 changed files with 223 additions and 28 deletions
+13
View File
@@ -367,6 +367,19 @@ export type EngineConfig = {
tts?: TtsConfig;
/** When true the renderer returns a placeholder PNG instead of calling the image API. */
mockImage?: boolean;
/**
* Per-attempt hard timeout (ms) for image-generation requests. Unset → no
* client-side timeout (only the provider's own gateway limits apply, e.g.
* Runware kills tasks at ~55s with a 504).
*/
imageTimeoutMs?: number;
/**
* Painter scene-paint hedge threshold (ms). When the Tier-A (referenced)
* paint hasn't completed after this long, a second identical request races
* the first and the earlier result wins. Unset/0 → hedging disabled.
* Derived from healthy-day Runware p95 (~14s); recommended 15000.
*/
imageHedgeMs?: number;
};
// ──────────────────────────────────────────────────────────────────────