(text: string)
| 189 | * @returns Array of references with position info |
| 190 | */ |
| 191 | export function extractAgentReferencesWithPositions(text: string): Array<{ |
| 192 | reference: AgentReference; |
| 193 | start: number; |
| 194 | end: number; |
| 195 | fullMatch: string; |
| 196 | }> { |
| 197 | const regex = /@(\w+)(?:#(\d+))?/g; |
| 198 | const references: Array<{ |
| 199 | reference: AgentReference; |
| 200 | start: number; |
| 201 | end: number; |
| 202 | fullMatch: string; |
| 203 | }> = []; |
| 204 | let match; |
| 205 | |
| 206 | while ((match = regex.exec(text)) !== null) { |
| 207 | references.push({ |
| 208 | reference: { |
| 209 | agentId: match[1], |
| 210 | runCount: match[2] ? parseInt(match[2]) : 3 |
| 211 | }, |
| 212 | start: match.index, |
| 213 | end: match.index + match[0].length, |
| 214 | fullMatch: match[0] |
| 215 | }); |
| 216 | } |
| 217 | |
| 218 | return references; |
| 219 | } |
| 220 | |
| 221 | /** |
| 222 | * Removes @references from text, leaving clean user message |
no test coverage detected