( messages: (UserMessage | AttachmentMessage | SystemMessage)[], toolUseID: string | undefined, )
| 10 | * This prevents the "is running" message from being duplicated in the UI. |
| 11 | */ |
| 12 | export function tagMessagesWithToolUseID( |
| 13 | messages: (UserMessage | AttachmentMessage | SystemMessage)[], |
| 14 | toolUseID: string | undefined, |
| 15 | ): (UserMessage | AttachmentMessage | SystemMessage)[] { |
| 16 | if (!toolUseID) { |
| 17 | return messages |
| 18 | } |
| 19 | return messages.map(m => { |
| 20 | if (m.type === 'user') { |
| 21 | return { ...m, sourceToolUseID: toolUseID } |
| 22 | } |
| 23 | return m |
| 24 | }) |
| 25 | } |
| 26 | |
| 27 | /** |
| 28 | * Extracts the tool use ID from a parent message for a given tool name. |
no outgoing calls
no test coverage detected