diff --git a/agent-node/src/agent_node/core/regex_patterns.py b/agent-node/src/agent_node/core/regex_patterns.py index 3186aa1..5756ce7 100644 --- a/agent-node/src/agent_node/core/regex_patterns.py +++ b/agent-node/src/agent_node/core/regex_patterns.py @@ -19,11 +19,12 @@ # Protocol Extraction (OSC 1337 / Bracketed) TASK_PROTOCOL_FENCE = re.compile(r'1337;Task(Start|End);id=([a-zA-Z0-9-]*)') -EXIT_CODE_PATTERN = re.compile(r'exit=(\d+)') +# This matches digits optionally followed by brackets (for split-processing resilience) +EXIT_CODE_PATTERN = re.compile(r'^(\d+)') # Echo Suppression Patterns (M9/M7) ECHO_START_PATTERN = re.compile(r'echo \s*\[\[1337;Task\^Start;id=[a-zA-Z0-9-]*\]\]\s*&\s*') -ECHO_END_PATTERN = re.compile(r'\s*&\s*echo \s*\[\[1337;Task\^End;id=[a-zA-Z0-9-]*;exit=%errorlevel%\]\]') +ECHO_END_PATTERN = re.compile(r'\s*&\s*echo \s*\[\[1337;Task\^End;id=[a-zA-Z0-9-]*;exit=%(__ctx_err|errorlevel)%\]\]') ECHO_CLEANUP_ANSI = re.compile(r'echo \x1b]1337;TaskEnd;.*') ECHO_CLEANUP_BRACKET = re.compile(r'echo \[\[1337;TaskEnd;.*') @@ -35,7 +36,7 @@ # Windows ConPTY stream noise filters # Matches Windows ConHost title-set sequences: "0;......" lines WIN_TITLE_RE = re.compile(r'^\s*0;.*$', re.MULTILINE) -# Matches the 'call "...bat"' invocation line echoed by cmd.exe -BAT_CALL_RE = re.compile(r'^\s*call\s+".+\.bat".*$', re.MULTILINE | re.IGNORECASE) -# Matches the 'del /Q ...' cleanup echo (fallback; @call suppresses this in practice) -DEL_RE = re.compile(r'^\s*del\s+/Q\s+".+\.bat".*$', re.MULTILINE | re.IGNORECASE) +# Matches the '@call "...bat"' invocation line echoed by cmd.exe (accounting for optional @) +BAT_CALL_RE = re.compile(r'^\s*@?call\s+".+\.bat".*$', re.MULTILINE | re.IGNORECASE) +# Matches the '@del /Q ...' cleanup echo (accounting for optional @) +DEL_RE = re.compile(r'^\s*@?del\s+/Q\s+".+\.bat".*$', re.MULTILINE | re.IGNORECASE)