mcpower-proxy 0.0.58__py3-none-any.whl → 0.0.73__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (36) hide show
  1. ide_tools/__init__.py +12 -0
  2. ide_tools/common/__init__.py +6 -0
  3. ide_tools/common/hooks/__init__.py +6 -0
  4. ide_tools/common/hooks/init.py +125 -0
  5. ide_tools/common/hooks/output.py +64 -0
  6. ide_tools/common/hooks/prompt_submit.py +186 -0
  7. ide_tools/common/hooks/read_file.py +170 -0
  8. ide_tools/common/hooks/shell_execution.py +196 -0
  9. ide_tools/common/hooks/types.py +35 -0
  10. ide_tools/common/hooks/utils.py +276 -0
  11. ide_tools/cursor/__init__.py +11 -0
  12. ide_tools/cursor/constants.py +58 -0
  13. ide_tools/cursor/format.py +35 -0
  14. ide_tools/cursor/router.py +100 -0
  15. ide_tools/router.py +48 -0
  16. main.py +11 -4
  17. {mcpower_proxy-0.0.58.dist-info → mcpower_proxy-0.0.73.dist-info}/METADATA +15 -3
  18. mcpower_proxy-0.0.73.dist-info/RECORD +59 -0
  19. {mcpower_proxy-0.0.58.dist-info → mcpower_proxy-0.0.73.dist-info}/top_level.txt +1 -0
  20. modules/apis/security_policy.py +11 -6
  21. modules/decision_handler.py +219 -0
  22. modules/logs/audit_trail.py +22 -17
  23. modules/logs/logger.py +14 -18
  24. modules/redaction/redactor.py +112 -107
  25. modules/ui/__init__.py +1 -1
  26. modules/ui/confirmation.py +0 -1
  27. modules/utils/cli.py +36 -6
  28. modules/utils/ids.py +55 -10
  29. modules/utils/json.py +3 -3
  30. wrapper/__version__.py +1 -1
  31. wrapper/middleware.py +121 -210
  32. wrapper/server.py +19 -11
  33. mcpower_proxy-0.0.58.dist-info/RECORD +0 -43
  34. {mcpower_proxy-0.0.58.dist-info → mcpower_proxy-0.0.73.dist-info}/WHEEL +0 -0
  35. {mcpower_proxy-0.0.58.dist-info → mcpower_proxy-0.0.73.dist-info}/entry_points.txt +0 -0
  36. {mcpower_proxy-0.0.58.dist-info → mcpower_proxy-0.0.73.dist-info}/licenses/LICENSE +0 -0
modules/logs/logger.py CHANGED
@@ -13,7 +13,7 @@ from modules.utils.ids import get_session_id
13
13
 
14
14
  class UTF8StreamHandler(logging.StreamHandler):
15
15
  """StreamHandler that forces UTF-8 encoding on Windows to prevent UnicodeEncodeError"""
16
-
16
+
17
17
  def __init__(self, stream=None):
18
18
  # On Windows, wrap the stream with UTF-8 encoding BEFORE passing to parent
19
19
  if sys.platform == 'win32' and stream is not None:
@@ -25,13 +25,13 @@ class UTF8StreamHandler(logging.StreamHandler):
25
25
  errors='replace',
26
26
  line_buffering=True
27
27
  )
28
-
28
+
29
29
  super().__init__(stream)
30
30
 
31
31
 
32
32
  class SessionFormatter(logging.Formatter):
33
33
  """Custom formatter that includes session ID in log messages"""
34
-
34
+
35
35
  # Single character mapping for perfect alignment and compactness
36
36
  LEVEL_MAPPING = {
37
37
  'DEBUG': 'D',
@@ -40,11 +40,11 @@ class SessionFormatter(logging.Formatter):
40
40
  'ERROR': 'E',
41
41
  'CRITICAL': 'C'
42
42
  }
43
-
43
+
44
44
  def __init__(self, *args, **kwargs):
45
45
  super().__init__(*args, **kwargs)
46
46
  self._session_id = get_session_id()[:8]
47
-
47
+
48
48
  def format(self, record):
49
49
  # Use the cached session ID
50
50
  record.session_id = self._session_id
@@ -58,52 +58,51 @@ class SessionFormatter(logging.Formatter):
58
58
 
59
59
  class MCPLogger:
60
60
  """Simple line-based logger for MCP traffic"""
61
-
61
+
62
62
  def __init__(self, log_file: Optional[str] = None, level: int = logging.INFO):
63
63
  self.log_file = log_file
64
64
  self.file_handle: Optional[TextIO] = None
65
-
65
+
66
66
  # Setup file handle if log file specified (for MCP traffic logging)
67
67
  if log_file:
68
68
  log_path = Path(log_file)
69
69
  log_path.parent.mkdir(parents=True, exist_ok=True)
70
70
  self.file_handle = open(log_path, 'a', encoding='utf-8')
71
-
71
+
72
72
  # Setup standard logger for non-MCP messages
73
73
  self.logger = logging.getLogger('mcpower')
74
74
  self.logger.setLevel(level)
75
-
75
+
76
76
  # Create console handler with UTF-8 support
77
77
  console_handler = UTF8StreamHandler(sys.stderr)
78
78
  console_handler.setLevel(level)
79
79
  formatter = SessionFormatter('%(asctime)s [%(session_id)s] (%(levelname)s) %(message)s')
80
80
  console_handler.setFormatter(formatter)
81
81
  self.logger.addHandler(console_handler)
82
-
82
+
83
83
  # Add file handler if log file specified
84
84
  if log_file:
85
85
  file_handler = logging.FileHandler(log_file, encoding='utf-8')
86
86
  file_handler.setLevel(level)
87
87
  file_handler.setFormatter(formatter)
88
88
  self.logger.addHandler(file_handler)
89
-
90
89
 
91
90
  def info(self, message: str) -> None:
92
91
  """Log info message"""
93
92
  self.logger.info(message)
94
-
93
+
95
94
  def error(self, message: str, exc_info: bool = False) -> None:
96
95
  """Log error message"""
97
96
  self.logger.error(message, exc_info=exc_info)
98
-
97
+
99
98
  def warning(self, message: str) -> None:
100
99
  """Log warning message"""
101
100
  self.logger.warning(message)
102
-
101
+
103
102
  def debug(self, message: str) -> None:
104
103
  """Log debug message"""
105
104
  self.logger.debug(message)
106
-
105
+
107
106
  def close(self) -> None:
108
107
  """Close log file handle"""
109
108
  if self.file_handle:
@@ -123,6 +122,3 @@ def setup_logger(log_file: Optional[str] = None, level: int = logging.INFO) -> M
123
122
  Configured MCPLogger instance
124
123
  """
125
124
  return MCPLogger(log_file, level)
126
-
127
-
128
-