| 4 | * Parse `@agent-name message` syntax for direct team member messaging. |
| 5 | */ |
| 6 | export function parseDirectMemberMessage(input: string): { |
| 7 | recipientName: string |
| 8 | message: string |
| 9 | } | null { |
| 10 | const match = input.match(/^@([\w-]+)\s+(.+)$/s) |
| 11 | if (!match) return null |
| 12 | |
| 13 | const [, recipientName, message] = match |
| 14 | if (!recipientName || !message) return null |
| 15 | |
| 16 | const trimmedMessage = message.trim() |
| 17 | if (!trimmedMessage) return null |
| 18 | |
| 19 | return { recipientName, message: trimmedMessage } |
| 20 | } |
| 21 | |
| 22 | export type DirectMessageResult = |
| 23 | | { success: true; recipientName: string } |