* Parse XML block response: yes/no * Strips thinking content first to avoid matching tags inside reasoning. * Returns true for "yes" (should block), false for "no", null if unparseable.
(text: string)
| 576 | * Returns true for "yes" (should block), false for "no", null if unparseable. |
| 577 | */ |
| 578 | function parseXmlBlock(text: string): boolean | null { |
| 579 | const matches = [ |
| 580 | ...stripThinking(text).matchAll(/<block>(yes|no)\b(<\/block>)?/gi), |
| 581 | ] |
| 582 | if (matches.length === 0) return null |
| 583 | return matches[0]![1]!.toLowerCase() === 'yes' |
| 584 | } |
| 585 | |
| 586 | /** |
| 587 | * Parse XML reason: <reason>...</reason> |
no test coverage detected