Function
runWithTimeout
(
promise: Promise<T>,
timeoutMs: number,
)
Source from the content-addressed store, hash-verified
| 296 | } |
| 297 | |
| 298 | async function runWithTimeout<T>( |
| 299 | promise: Promise<T>, |
| 300 | timeoutMs: number, |
| 301 | ): Promise<T> { |
| 302 | return await new Promise<T>((resolve, reject) => { |
| 303 | const timeout = setTimeout(() => { |
| 304 | reject(new Error(`JavaScript REPL execution timed out after ${timeoutMs}ms`)) |
| 305 | }, timeoutMs) |
| 306 | promise.then( |
| 307 | value => { |
| 308 | clearTimeout(timeout) |
| 309 | resolve(value) |
| 310 | }, |
| 311 | error => { |
| 312 | clearTimeout(timeout) |
| 313 | reject(error) |
| 314 | }, |
| 315 | ) |
| 316 | }) |
| 317 | } |
| 318 | |
| 319 | function formatToolCallSummary(call: ReplToolCallSummary): string { |
| 320 | const input = preview(stringifyUnknown(call.toolInput)) |
Tested by
no test coverage detected