File size: 1,526 Bytes
a5784e9
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
"""
FC Debug Module Definitions.

Defines the FCModule enum representing different function calling components
that can be independently logged and configured.
"""

from enum import Enum


class FCModule(Enum):
    """Function Calling debug logging modules."""

    ORCHESTRATOR = "fc_orchestrator"  # Mode selection, fallback logic, high-level flow
    UI = "fc_ui"  # Browser UI automation (toggle, dialog, paste)
    CACHE = "fc_cache"  # Cache hits/misses/invalidation
    WIRE = "fc_wire"  # Wire format parsing from network
    DOM = "fc_dom"  # DOM-based function call extraction
    SCHEMA = "fc_schema"  # Schema conversion and validation
    RESPONSE = "fc_response"  # Response formatting for OpenAI compatibility

    @property
    def prefix(self) -> str:
        """Get the log prefix for this module."""
        # Use shorter prefixes for some modules
        prefix_map = {
            "ORCHESTRATOR": "ORCH",
            "RESPONSE": "RESP",
        }
        name = prefix_map.get(self.name, self.name)
        return f"[FC:{name}]"

    @property
    def env_enabled_key(self) -> str:
        """Get the environment variable key for enabling this module."""
        return f"FC_DEBUG_{self.name.upper()}"

    @property
    def env_level_key(self) -> str:
        """Get the environment variable key for log level."""
        return f"FC_DEBUG_LEVEL_{self.name.upper()}"

    @property
    def log_filename(self) -> str:
        """Get the log filename for this module."""
        return f"{self.value}.log"