Run a read tool on the pool. Always resolves (never rejects).
(toolName: string, args: Record<string, unknown>)
| 273 | |
| 274 | /** Run a read tool on the pool. Always resolves (never rejects). */ |
| 275 | run(toolName: string, args: Record<string, unknown>): Promise<ToolResult> { |
| 276 | return new Promise<ToolResult>((resolve) => { |
| 277 | const job: Job = { |
| 278 | id: this.nextId++, toolName, args, resolve, |
| 279 | retries: 0, settled: false, enqueuedAt: Date.now(), |
| 280 | }; |
| 281 | // Don't let the caller wait past softTimeoutMs. The worker may still be |
| 282 | // busy (we can't cancel synchronous CPU), but the CLIENT gets a prompt, |
| 283 | // success-shaped "retry" instead of a hard timeout. |
| 284 | job.softTimer = setTimeout(() => { |
| 285 | if (!job.settled) this.settle(job, busyGuidance(Date.now() - job.enqueuedAt)); |
| 286 | }, this.softTimeoutMs); |
| 287 | job.softTimer.unref?.(); |
| 288 | this.queue.push(job); |
| 289 | this.drain(); |
| 290 | }); |
| 291 | } |
| 292 | |
| 293 | /** Terminate all workers and answer any outstanding calls gracefully. */ |
| 294 | async destroy(): Promise<void> { |
nothing calls this directly
no test coverage detected