@@ -13,7 +13,11 @@ import {
|
13 | 13 | sanitizeConfiguredModelProviderRequest, |
14 | 14 | type ProviderOperationDeadline, |
15 | 15 | } from "openclaw/plugin-sdk/provider-http"; |
16 | | -import { asFiniteNumber, normalizeOptionalString } from "openclaw/plugin-sdk/string-coerce-runtime"; |
| 16 | +import { |
| 17 | +asFiniteNumber, |
| 18 | +asSafeIntegerInRange, |
| 19 | +normalizeOptionalString, |
| 20 | +} from "openclaw/plugin-sdk/string-coerce-runtime"; |
17 | 21 | import type { |
18 | 22 | GeneratedVideoAsset, |
19 | 23 | VideoGenerationProvider, |
@@ -34,6 +38,7 @@ const DEFAULT_TIMEOUT_MS = 300_000;
|
34 | 38 | const POLL_INTERVAL_MS = 5_000; |
35 | 39 | const MAX_POLL_ATTEMPTS = 180; |
36 | 40 | const MAX_DURATION_SECONDS = 15; |
| 41 | +const PIXVERSE_SEED_MAX = 2_147_483_647; |
37 | 42 | const PIXVERSE_VIDEO_MODELS = ["v6", "c1"] as const; |
38 | 43 | const PIXVERSE_TEXT_ASPECT_RATIOS = [ |
39 | 44 | "16:9", |
@@ -134,12 +139,16 @@ function appendOptionalNumber(body: Record<string, unknown>, key: string, value:
|
134 | 139 | } |
135 | 140 | |
136 | 141 | function appendOptionalInt32Seed(body: Record<string, unknown>, value: unknown): void { |
137 | | -const seed = asFiniteNumber(value); |
138 | | -if (seed != null && Number.isSafeInteger(seed) && seed >= 0 && seed <= 2_147_483_647) { |
| 142 | +const seed = asSafeIntegerInRange(value, { min: 0, max: PIXVERSE_SEED_MAX }); |
| 143 | +if (seed !== undefined) { |
139 | 144 | body.seed = seed; |
140 | 145 | } |
141 | 146 | } |
142 | 147 | |
| 148 | +function readPixVerseSeed(value: unknown): number | undefined { |
| 149 | +return asSafeIntegerInRange(value, { min: 0, max: PIXVERSE_SEED_MAX }); |
| 150 | +} |
| 151 | + |
143 | 152 | function appendOptionalString(body: Record<string, unknown>, key: string, value: unknown): void { |
144 | 153 | const stringValue = normalizeOptionalString(value); |
145 | 154 | if (stringValue) { |
@@ -498,7 +507,7 @@ export function buildPixVerseVideoGenerationProvider(): VideoGenerationProvider
|
498 | 507 | endpoint, |
499 | 508 | videoId, |
500 | 509 | status: readPixVerseStatus(completed), |
501 | | -seed: asFiniteNumber(completed.seed), |
| 510 | +seed: readPixVerseSeed(completed.seed), |
502 | 511 | size: asFiniteNumber(completed.size), |
503 | 512 | }, |
504 | 513 | }; |
|