(task: ToolCallTask<Result>)
| 30 | private queuedTasks: Array<ScheduledToolCallTask<Result>> = []; |
| 31 | |
| 32 | add(task: ToolCallTask<Result>): Promise<Result> { |
| 33 | const result = createControlledPromise<Result>(); |
| 34 | void result.catch(() => undefined); |
| 35 | |
| 36 | const scheduledTask: ScheduledToolCallTask<Result> = { ...task, result }; |
| 37 | if (this.isBlocked(task, this.queuedTasks)) { |
| 38 | this.queuedTasks.push(scheduledTask); |
| 39 | } else { |
| 40 | this.start(scheduledTask); |
| 41 | } |
| 42 | |
| 43 | return result; |
| 44 | } |
| 45 | |
| 46 | private isBlocked( |
| 47 | task: ToolCallTask<Result>, |