| 353 | * @returns Object with suggestion info or null |
| 354 | */ |
| 355 | export function detectPartialAgentTyping(text: string, cursorPosition: number): { |
| 356 | partialMatch: string; |
| 357 | start: number; |
| 358 | end: number; |
| 359 | } | null { |
| 360 | // Look for @word pattern before cursor |
| 361 | const beforeCursor = text.substring(0, cursorPosition); |
| 362 | const match = beforeCursor.match(/@(\w*)$/); |
| 363 | |
| 364 | if (match) { |
| 365 | return { |
| 366 | partialMatch: match[1], // The part after @ |
| 367 | start: match.index! + 1, // Position after @ |
| 368 | end: cursorPosition |
| 369 | }; |
| 370 | } |
| 371 | |
| 372 | return null; |
| 373 | } |
| 374 | |
| 375 | /** |
| 376 | * Formats agent reference context for appending to a message |