惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

Google DeepMind News
Google DeepMind News
B
Blog RSS Feed
量子位
aimingoo的专栏
aimingoo的专栏
V
Visual Studio Blog
Y
Y Combinator Blog
Vercel News
Vercel News
云风的 BLOG
云风的 BLOG
宝玉的分享
宝玉的分享
Engineering at Meta
Engineering at Meta
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
GbyAI
GbyAI
人人都是产品经理
人人都是产品经理
博客园 - 叶小钗
Stack Overflow Blog
Stack Overflow Blog
大猫的无限游戏
大猫的无限游戏
Microsoft Security Blog
Microsoft Security Blog
B
Blog
Last Week in AI
Last Week in AI
有赞技术团队
有赞技术团队
博客园 - 聂微东
腾讯CDC
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
J
Java Code Geeks

Recent Commits to openclaw:main

test: merge chat side-result checks · openclaw/openclaw@ddd2c2a test: merge cron history checks · openclaw/openclaw@f7eb746 test: merge responsive navigation shell checks · openclaw/openclaw@c2e4b47 docs(changelog): add codex oauth fixes · openclaw/openclaw@628e6cd test: merge navigation routing cases · openclaw/openclaw@5d8cecb Tests: mock channel registry bundled fallback · openclaw/openclaw@2b08233 Secrets: avoid broad web search discovery for single plugin config · openclaw/openclaw@a464f59 test: merge config view browser checks · openclaw/openclaw@20cf511 fix(status): align oauth health with runtime · openclaw/openclaw@eed7116 feat: add macOS screen snapshots for monitor preview (#67954) thanks … · openclaw/openclaw@f377db1 fix: report shared auth scopes in hello-ok (#67810) thanks @BunsDev · openclaw/openclaw@0b6c39b Auto-reply: avoid eager bundled route fallback · openclaw/openclaw@3ea1bf4 Tests: narrow session binding contract setup · openclaw/openclaw@54e4e16 fix(macOS): enable undo/redo in webchat composer text input (#34962) · openclaw/openclaw@00951dc Tests: speed up channel setup promotion · openclaw/openclaw@82b529a Docs: refresh agent instructions · openclaw/openclaw@5775fe2 fix(auth): serialize OAuth refresh across agents to fix #26322 (#67876) · openclaw/openclaw@8e79080 test: allow ollama public surface boundary test · openclaw/openclaw@7d4f1a6 Docs: add test performance guardrails · openclaw/openclaw@89706d3 Tests: restore context-engine usage proof · openclaw/openclaw@e4c4f95 Tests: slim context engine runtime coverage · openclaw/openclaw@74c198f ci: retry failed custom checkouts · openclaw/openclaw@0ee5baf test: trim duplicate provider auth onboarding cases · openclaw/openclaw@1ffc02e matrix: fix sessions_spawn --thread subagent session spawning (#67643) · openclaw/openclaw@1ce2596 test: reduce auth choice fixture churn · openclaw/openclaw@857b9cd test: mock health status config boundaries · openclaw/openclaw@9d5ab4a test: mock onboard config io boundary · openclaw/openclaw@299694d test: mock legacy state plugin boundaries · openclaw/openclaw@2713089 test: mock channel install boundaries · openclaw/openclaw@b945248 test: mock doctor preview channel boundaries · openclaw/openclaw@b1a3ad4
fix: thread openai video request policy · openclaw/opencl...
shakkernerd · 2026-05-23 · via Recent Commits to openclaw:main

@@ -6,6 +6,7 @@ import {

66

createProviderOperationDeadline,

77

createProviderOperationTimeoutResolver,

88

fetchProviderDownloadResponse,

9+

fetchWithTimeoutGuarded,

910

pollProviderOperationJson,

1011

postJsonRequest,

1112

postMultipartRequest,

@@ -30,6 +31,11 @@ const MAX_POLL_ATTEMPTS = 120;

3031

const OPENAI_VIDEO_SECONDS = [4, 8, 12] as const;

3132

const OPENAI_VIDEO_SIZES = ["720x1280", "1280x720", "1024x1792", "1792x1024"] as const;

323334+

type OpenAIVideoRequestPolicy = {

35+

allowPrivateNetwork: boolean;

36+

dispatcherPolicy?: Parameters<typeof postJsonRequest>[0]["dispatcherPolicy"];

37+

};

38+3339

type OpenAIVideoStatus = "queued" | "in_progress" | "completed" | "failed";

34403541

type OpenAIVideoResponse = {

@@ -117,13 +123,15 @@ function resolveReferenceAsset(req: VideoGenerationRequest) {

117123

return new File([toBlobBytes(asset.buffer)], fileName, { type: mimeType });

118124

}

119125120-

async function pollOpenAIVideo(params: {

121-

videoId: string;

122-

headers: Headers;

123-

timeoutMs?: number;

124-

baseUrl: string;

125-

fetchFn: typeof fetch;

126-

}): Promise<OpenAIVideoResponse> {

126+

async function pollOpenAIVideo(

127+

params: {

128+

videoId: string;

129+

headers: Headers;

130+

timeoutMs?: number;

131+

baseUrl: string;

132+

fetchFn: typeof fetch;

133+

} & OpenAIVideoRequestPolicy,

134+

): Promise<OpenAIVideoResponse> {

127135

const deadline = createProviderOperationDeadline({

128136

timeoutMs: params.timeoutMs,

129137

label: `OpenAI video generation task ${params.videoId}`,

@@ -138,6 +146,9 @@ async function pollOpenAIVideo(params: {

138146

pollIntervalMs: POLL_INTERVAL_MS,

139147

requestFailedMessage: "OpenAI video status request failed",

140148

timeoutMessage: `OpenAI video generation task ${params.videoId} did not finish in time`,

149+

allowPrivateNetwork: params.allowPrivateNetwork,

150+

dispatcherPolicy: params.dispatcherPolicy,

151+

auditContext: "openai-video-status",

141152

isComplete: (payload) => payload.status === "completed",

142153

getFailureMessage: (payload) =>

143154

payload.status === "failed"

@@ -146,16 +157,63 @@ async function pollOpenAIVideo(params: {

146157

});

147158

}

148159149-

async function downloadOpenAIVideo(params: {

150-

videoId: string;

151-

headers: Headers;

152-

timeoutMs?: ProviderOperationTimeoutMs;

153-

baseUrl: string;

154-

fetchFn: typeof fetch;

155-

}): Promise<GeneratedVideoAsset> {

160+

function resolveOpenAIVideoDownloadTimeoutMs(timeoutMs: ProviderOperationTimeoutMs | undefined) {

161+

const resolved = typeof timeoutMs === "function" ? timeoutMs() : timeoutMs;

162+

return typeof resolved === "number" && Number.isFinite(resolved) && resolved > 0

163+

? resolved

164+

: DEFAULT_TIMEOUT_MS;

165+

}

166+167+

async function fetchOpenAIVideoDownload(

168+

params: {

169+

url: string;

170+

init: RequestInit;

171+

timeoutMs?: ProviderOperationTimeoutMs;

172+

fetchFn: typeof fetch;

173+

} & OpenAIVideoRequestPolicy,

174+

) {

175+

if (!params.allowPrivateNetwork && !params.dispatcherPolicy) {

176+

const response = await fetchProviderDownloadResponse({

177+

url: params.url,

178+

init: params.init,

179+

timeoutMs: params.timeoutMs ?? DEFAULT_TIMEOUT_MS,

180+

fetchFn: params.fetchFn,

181+

provider: "openai",

182+

requestFailedMessage: "OpenAI video download failed",

183+

});

184+

return {

185+

response,

186+

release: async () => {},

187+

};

188+

}

189+190+

const result = await fetchWithTimeoutGuarded(

191+

params.url,

192+

params.init,

193+

resolveOpenAIVideoDownloadTimeoutMs(params.timeoutMs),

194+

params.fetchFn,

195+

{

196+

...(params.allowPrivateNetwork ? { ssrfPolicy: { allowPrivateNetwork: true } } : {}),

197+

...(params.dispatcherPolicy ? { dispatcherPolicy: params.dispatcherPolicy } : {}),

198+

auditContext: "openai-video-download",

199+

},

200+

);

201+

await assertOkOrThrowHttpError(result.response, "OpenAI video download failed");

202+

return result;

203+

}

204+205+

async function downloadOpenAIVideo(

206+

params: {

207+

videoId: string;

208+

headers: Headers;

209+

timeoutMs?: ProviderOperationTimeoutMs;

210+

baseUrl: string;

211+

fetchFn: typeof fetch;

212+

} & OpenAIVideoRequestPolicy,

213+

): Promise<GeneratedVideoAsset> {

156214

const url = new URL(`${params.baseUrl}/videos/${params.videoId}/content`);

157215

url.searchParams.set("variant", "video");

158-

const response = await fetchProviderDownloadResponse({

216+

const { response, release } = await fetchOpenAIVideoDownload({

159217

url: url.toString(),

160218

init: {

161219

method: "GET",

@@ -164,18 +222,22 @@ async function downloadOpenAIVideo(params: {

164222

Accept: "application/binary",

165223

}),

166224

},

167-

timeoutMs: params.timeoutMs ?? DEFAULT_TIMEOUT_MS,

225+

timeoutMs: params.timeoutMs,

168226

fetchFn: params.fetchFn,

169-

provider: "openai",

170-

requestFailedMessage: "OpenAI video download failed",

227+

allowPrivateNetwork: params.allowPrivateNetwork,

228+

dispatcherPolicy: params.dispatcherPolicy,

171229

});

172-

const mimeType = normalizeOptionalString(response.headers.get("content-type")) ?? "video/mp4";

173-

const arrayBuffer = await response.arrayBuffer();

174-

return {

175-

buffer: Buffer.from(arrayBuffer),

176-

mimeType,

177-

fileName: `video-1.${extensionForMime(mimeType)?.slice(1) ?? "mp4"}`,

178-

};

230+

try {

231+

const mimeType = normalizeOptionalString(response.headers.get("content-type")) ?? "video/mp4";

232+

const arrayBuffer = await response.arrayBuffer();

233+

return {

234+

buffer: Buffer.from(arrayBuffer),

235+

mimeType,

236+

fileName: `video-1.${extensionForMime(mimeType)?.slice(1) ?? "mp4"}`,

237+

};

238+

} finally {

239+

await release();

240+

}

179241

}

180242181243

export function buildOpenAIVideoGenerationProvider(): VideoGenerationProvider {

@@ -351,6 +413,8 @@ export function buildOpenAIVideoGenerationProvider(): VideoGenerationProvider {

351413

}),

352414

baseUrl,

353415

fetchFn,

416+

allowPrivateNetwork,

417+

dispatcherPolicy,

354418

});

355419

const video = await downloadOpenAIVideo({

356420

videoId,

@@ -361,6 +425,8 @@ export function buildOpenAIVideoGenerationProvider(): VideoGenerationProvider {

361425

}),

362426

baseUrl,

363427

fetchFn,

428+

allowPrivateNetwork,

429+

dispatcherPolicy,

364430

});

365431

return {

366432

videos: [video],