Run a read tool on the pool. Always resolves (never rejects).
(toolName: string, args: Record<string, unknown>)
| 491 | |
| 492 | /** Run a read tool on the pool. Always resolves (never rejects). */ |
| 493 | run(toolName: string, args: Record<string, unknown>): Promise<ToolResult> { |
| 494 | this.clearIdleShrink(); |
| 495 | return new Promise<ToolResult>((resolve) => { |
| 496 | const job: Job = { |
| 497 | id: this.nextId++, toolName, args, resolve, |
| 498 | retries: 0, settled: false, enqueuedAt: Date.now(), |
| 499 | }; |
| 500 | // Don't let the caller wait past softTimeoutMs. The worker may still be |
| 501 | // busy (we can't cancel synchronous CPU), but the CLIENT gets a prompt, |
| 502 | // success-shaped "retry" instead of a hard timeout. |
| 503 | job.softTimer = setTimeout(() => { |
| 504 | if (!job.settled) this.answerBusy(job); |
| 505 | }, this.softTimeoutMs); |
| 506 | job.softTimer.unref?.(); |
| 507 | this.queue.push(job); |
| 508 | this.drain(); |
| 509 | }); |
| 510 | } |
| 511 | |
| 512 | /** |
| 513 | * The backstop: answer a caller whose call is not done, and say in the log |
no test coverage detected