* Records a tool_use ID as resolved so that late/duplicate control_response * messages for the same tool are ignored by the orphan handler.
(request: SDKControlRequest)
| 175 | * messages for the same tool are ignored by the orphan handler. |
| 176 | */ |
| 177 | private trackResolvedToolUseId(request: SDKControlRequest): void { |
| 178 | const inner = request.request as { subtype?: string; tool_use_id?: string } |
| 179 | if (inner.subtype === 'can_use_tool') { |
| 180 | this.resolvedToolUseIds.add(inner.tool_use_id as string) |
| 181 | if (this.resolvedToolUseIds.size > MAX_RESOLVED_TOOL_USE_IDS) { |
| 182 | // Evict the oldest entry (Sets iterate in insertion order) |
| 183 | const first = this.resolvedToolUseIds.values().next().value |
| 184 | if (first !== undefined) { |
| 185 | this.resolvedToolUseIds.delete(first) |
| 186 | } |
| 187 | } |
| 188 | } |
| 189 | } |
| 190 | |
| 191 | /** Flush pending internal events. No-op for non-remote IO. Overridden by RemoteIO. */ |
| 192 | flushInternalEvents(): Promise<void> { |
no test coverage detected