(
{ url, prompt },
{ abortController, options: { isNonInteractiveSession } },
)
| 206 | renderToolUseProgressMessage, |
| 207 | renderToolResultMessage, |
| 208 | async call( |
| 209 | { url, prompt }, |
| 210 | { abortController, options: { isNonInteractiveSession } }, |
| 211 | ) { |
| 212 | const start = Date.now() |
| 213 | |
| 214 | const response = await getURLMarkdownContent(url, abortController) |
| 215 | |
| 216 | // Check if we got a redirect to a different host |
| 217 | if ('type' in response && response.type === 'redirect') { |
| 218 | const statusText = |
| 219 | response.statusCode === 301 |
| 220 | ? 'Moved Permanently' |
| 221 | : response.statusCode === 308 |
| 222 | ? 'Permanent Redirect' |
| 223 | : response.statusCode === 307 |
| 224 | ? 'Temporary Redirect' |
| 225 | : 'Found' |
| 226 | |
| 227 | const message = `REDIRECT DETECTED: The URL redirects to a different host. |
| 228 | |
| 229 | Original URL: ${response.originalUrl} |
| 230 | Redirect URL: ${response.redirectUrl} |
| 231 | Status: ${response.statusCode} ${statusText} |
| 232 | |
| 233 | To complete your request, I need to fetch content from the redirected URL. Please use WebFetch again with these parameters: |
| 234 | - url: "${response.redirectUrl}" |
| 235 | - prompt: "${prompt}"` |
| 236 | |
| 237 | const output: Output = { |
| 238 | bytes: Buffer.byteLength(message), |
| 239 | code: response.statusCode, |
| 240 | codeText: statusText, |
| 241 | result: message, |
| 242 | durationMs: Date.now() - start, |
| 243 | url, |
| 244 | } |
| 245 | |
| 246 | return { |
| 247 | data: output, |
| 248 | } |
| 249 | } |
| 250 | |
| 251 | const { |
| 252 | content, |
| 253 | bytes, |
| 254 | code, |
| 255 | codeText, |
| 256 | contentType, |
| 257 | persistedPath, |
| 258 | persistedSize, |
| 259 | } = response as FetchedContent |
| 260 | |
| 261 | const isPreapproved = isPreapprovedUrl(url) |
| 262 | |
| 263 | let result: string |
| 264 | if ( |
| 265 | isPreapproved && |
nothing calls this directly
no test coverage detected