(
toolCall: OpenAIStreamToolCallDelta,
position: number,
)
| 1203 | } |
| 1204 | |
| 1205 | const resolveToolKey = ( |
| 1206 | toolCall: OpenAIStreamToolCallDelta, |
| 1207 | position: number, |
| 1208 | ): string => { |
| 1209 | if (toolCall.index !== undefined && toolCall.index !== null) { |
| 1210 | const existing = toolKeyByIndex.get(toolCall.index) |
| 1211 | if (existing) { |
| 1212 | if (toolCall.id) { |
| 1213 | toolKeyById.set(toolCall.id, existing) |
| 1214 | } |
| 1215 | return existing |
| 1216 | } |
| 1217 | const key = `index:${toolCall.index}` |
| 1218 | toolKeyByIndex.set(toolCall.index, key) |
| 1219 | if (toolCall.id) { |
| 1220 | toolKeyById.set(toolCall.id, key) |
| 1221 | } |
| 1222 | return key |
| 1223 | } |
| 1224 | |
| 1225 | if (toolCall.id) { |
| 1226 | const existing = toolKeyById.get(toolCall.id) |
| 1227 | if (existing) { |
| 1228 | return existing |
| 1229 | } |
| 1230 | const key = `id:${toolCall.id}` |
| 1231 | toolKeyById.set(toolCall.id, key) |
| 1232 | return key |
| 1233 | } |
| 1234 | |
| 1235 | const existing = syntheticToolKeyByPosition.get(position) |
| 1236 | if (existing) { |
| 1237 | return existing |
| 1238 | } |
| 1239 | const key = `synthetic:${nextSyntheticToolKey++}` |
| 1240 | syntheticToolKeyByPosition.set(position, key) |
| 1241 | return key |
| 1242 | } |
| 1243 | |
| 1244 | const ensureToolState = ( |
| 1245 | toolKey: string, |
no test coverage detected