MCPcopy Create free account
hub / github.com/Noumena-Network/code / parseXmlBlock

Function parseXmlBlock

src/utils/permissions/yoloClassifier.ts:580–586  ·  view source on GitHub ↗

* 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)

Source from the content-addressed store, hash-verified

578 * Returns true for "yes" (should block), false for "no", null if unparseable.
579 */
580function parseXmlBlock(text: string): boolean | null {
581 const matches = [
582 ...stripThinking(text).matchAll(/<block>(yes|no)\b(<\/block>)?/gi),
583 ]
584 if (matches.length === 0) return null
585 return matches[0]![1]!.toLowerCase() === 'yes'
586}
587
588/**
589 * Parse XML reason: <reason>...</reason>

Callers 1

classifyYoloActionXmlFunction · 0.85

Calls 1

stripThinkingFunction · 0.85

Tested by

no test coverage detected