diff --git a/agent-node/src/agent_node/core/regex_patterns.py b/agent-node/src/agent_node/core/regex_patterns.py index 2ae6d3a..3186aa1 100644 --- a/agent-node/src/agent_node/core/regex_patterns.py +++ b/agent-node/src/agent_node/core/regex_patterns.py @@ -31,3 +31,11 @@ PROTOCOL_HINT_PATTERN = re.compile(r"1337;Task|`e]|\\033]") STRIP_START_FENCE = re.compile(r'\x1b]1337;Task(Start|End);id=.*?\x07') STRIP_BRACKET_FENCE = re.compile(r'\[\[1337;Task(Start|End);id=.*?\]\]') + +# 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) diff --git a/agent-node/src/agent_node/skills/shell_bridge.py b/agent-node/src/agent_node/skills/shell_bridge.py index 2ed353a..8bb9fbf 100644 --- a/agent-node/src/agent_node/skills/shell_bridge.py +++ b/agent-node/src/agent_node/skills/shell_bridge.py @@ -16,7 +16,10 @@ STRIP_BRACKET_FENCE, ECHO_START_PATTERN, ECHO_END_PATTERN, - PROTOCOL_HINT_PATTERN + PROTOCOL_HINT_PATTERN, + WIN_TITLE_RE, + BAT_CALL_RE, + DEL_RE, ) class ShellSkill(BaseSkill): @@ -166,12 +169,6 @@ print(f" [🐚⚠️] Protocol parsing failed: {e}") if sess.get("event"): sess["event"].set() - # Matches Windows ConHost title-set sequences: "0;...<title>..." lines - _WIN_TITLE_RE = re.compile(r'^\s*0;.*$', re.MULTILINE) - # Matches the 'call "...bat"' invocation line echoed by cmd - _BAT_CALL_RE = re.compile(r'^\s*call\s+".+\.bat".*$', re.MULTILINE | re.IGNORECASE) - # Matches the 'del /Q ...' cleanup echo - _DEL_RE = re.compile(r'^\s*del\s+/Q\s+".+\.bat".*$', re.MULTILINE | re.IGNORECASE) def _handle_ui_streaming(self, sess, session_id, active_tid, decoded, on_event): """Internal helper to filter plumbing and stream terminal output to the client.""" @@ -183,9 +180,9 @@ # Strip Windows internals: title-set escape sequences, bat call/del lines clean_no_ansi = ANSI_ESCAPE.sub('', decoded) - clean_no_ansi = self._WIN_TITLE_RE.sub('', clean_no_ansi) - clean_no_ansi = self._BAT_CALL_RE.sub('', clean_no_ansi) - clean_no_ansi = self._DEL_RE.sub('', clean_no_ansi) + clean_no_ansi = WIN_TITLE_RE.sub('', clean_no_ansi) + clean_no_ansi = BAT_CALL_RE.sub('', clean_no_ansi) + clean_no_ansi = DEL_RE.sub('', clean_no_ansi) # Line-Aware Stealthing for extra safety (protocol fence markers) lines = clean_no_ansi.splitlines(keepends=True) diff --git a/scripts/start_agent.bat b/scripts/start_agent.bat deleted file mode 100644 index 05d84ad..0000000 --- a/scripts/start_agent.bat +++ /dev/null @@ -1,4 +0,0 @@ -@echo off -cd /d C:\Users\axiey\.cortex\agent-node -set PYTHONPATH=src -python src\agent_node\main.py > out.log 2>&1