Run a read tool on the pool. Always resolves (never rejects).
(toolName: string, args: Record<string, unknown>)
| 459 | |
| 460 | /** Run a read tool on the pool. Always resolves (never rejects). */ |
| 461 | run(toolName: string, args: Record<string, unknown>): Promise<ToolResult> { |
| 462 | this.clearIdleShrink(); |
| 463 | return new Promise<ToolResult>((resolve) => { |
| 464 | const job: Job = { |
| 465 | id: this.nextId++, toolName, args, resolve, |
| 466 | retries: 0, settled: false, enqueuedAt: Date.now(), |
| 467 | }; |
| 468 | // Don't let the caller wait past softTimeoutMs. The worker may still be |
| 469 | // busy (we can't cancel synchronous CPU), but the CLIENT gets a prompt, |
| 470 | // success-shaped "retry" instead of a hard timeout. |
| 471 | job.softTimer = setTimeout(() => { |
| 472 | if (!job.settled) this.settle(job, busyGuidance(Date.now() - job.enqueuedAt)); |
| 473 | }, this.softTimeoutMs); |
| 474 | job.softTimer.unref?.(); |
| 475 | this.queue.push(job); |
| 476 | this.drain(); |
| 477 | }); |
| 478 | } |
| 479 | |
| 480 | private startSettled(w: PoolWorker): void { |
| 481 | const start = this.starts.get(w); |
nothing calls this directly
no test coverage detected