File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ // Header wait and body progress are separate failure modes. Keep both Tlon
2+ // media directions on one policy so attachment and upload fallbacks stay aligned.
3+ export const TLON_MEDIA_FETCH_TIMEOUTS = {
4+ responseHeaderTimeoutMs : 120_000 ,
5+ readIdleTimeoutMs : 30_000 ,
6+ } as const ;
Original file line number Diff line number Diff line change @@ -10,10 +10,9 @@ import {
1010 saveRemoteMedia ,
1111} from "openclaw/plugin-sdk/media-runtime" ;
1212import { normalizeLowercaseStringOrEmpty } from "openclaw/plugin-sdk/string-coerce-runtime" ;
13+ import { TLON_MEDIA_FETCH_TIMEOUTS } from "../media-fetch-timeouts.js" ;
1314
1415const MAX_IMAGES_PER_MESSAGE = 8 ;
15- const TLON_MEDIA_DOWNLOAD_IDLE_TIMEOUT_MS = 30_000 ;
16- const TLON_MEDIA_RESPONSE_HEADER_TIMEOUT_MS = 120_000 ;
1716
1817interface ExtractedImage {
1918 url : string ;
@@ -71,8 +70,7 @@ export async function downloadMedia(
7170 const fetchOptions = {
7271 url,
7372 maxBytes : MAX_IMAGE_BYTES ,
74- responseHeaderTimeoutMs : TLON_MEDIA_RESPONSE_HEADER_TIMEOUT_MS ,
75- readIdleTimeoutMs : TLON_MEDIA_DOWNLOAD_IDLE_TIMEOUT_MS ,
73+ ...TLON_MEDIA_FETCH_TIMEOUTS ,
7674 ssrfPolicy : undefined ,
7775 requestInit : { method : "GET" } ,
7876 } ;
Original file line number Diff line number Diff line change 22 * Upload an image from a URL to Tlon storage.
33 */
44import { MAX_IMAGE_BYTES , readRemoteMediaBuffer } from "openclaw/plugin-sdk/media-runtime" ;
5+ import { TLON_MEDIA_FETCH_TIMEOUTS } from "../media-fetch-timeouts.js" ;
56import { uploadFile } from "../tlon-api.js" ;
67
7- const TLON_UPLOAD_IMAGE_IDLE_TIMEOUT_MS = 30_000 ;
8- const TLON_UPLOAD_IMAGE_RESPONSE_HEADER_TIMEOUT_MS = 120_000 ;
9-
108/**
119 * Fetch an image from a URL and upload it to Tlon storage.
1210 * Returns the uploaded URL, or falls back to the original URL on error.
@@ -25,8 +23,7 @@ export async function uploadImageFromUrl(imageUrl: string): Promise<string> {
2523 const fetched = await readRemoteMediaBuffer ( {
2624 url : imageUrl ,
2725 maxBytes : MAX_IMAGE_BYTES ,
28- responseHeaderTimeoutMs : TLON_UPLOAD_IMAGE_RESPONSE_HEADER_TIMEOUT_MS ,
29- readIdleTimeoutMs : TLON_UPLOAD_IMAGE_IDLE_TIMEOUT_MS ,
26+ ...TLON_MEDIA_FETCH_TIMEOUTS ,
3027 ssrfPolicy : undefined ,
3128 requestInit : { method : "GET" } ,
3229 } ) ;
You can’t perform that action at this time.
0 commit comments