Skip to content

ccproxy.models.detection

ccproxy.models.detection

Shared helper dataclasses for plugin detection caches.

DetectedHeaders dataclass

DetectedHeaders(values=dict())

Normalized, lowercase HTTP headers captured during CLI detection.

as_dict

as_dict()

Return a copy of the detected headers as a plain dict.

Source code in ccproxy/models/detection.py
def as_dict(self) -> dict[str, str]:
    """Return a copy of the detected headers as a plain dict."""

    return dict(self.values)

filtered

filtered(ignores=None, redacted=None)

Return headers filtered for safe forwarding.

Source code in ccproxy/models/detection.py
def filtered(
    self,
    ignores: Iterable[str] | None = None,
    redacted: Iterable[str] | None = None,
) -> dict[str, str]:
    """Return headers filtered for safe forwarding."""

    ignore_set = {item.lower() for item in ignores or ()}
    redacted_set = {item.lower() for item in redacted or ()}
    return {
        key: value
        for key, value in self.values.items()
        if value and key not in ignore_set and key not in redacted_set
    }

get

get(key, default=None)

Lookup a header by key (case-insensitive).

Source code in ccproxy/models/detection.py
def get(self, key: str, default: str | None = None) -> str | None:
    """Lookup a header by key (case-insensitive)."""

    return self.values.get(key.lower(), default)

items

items()

Iterate over header key/value pairs.

Source code in ccproxy/models/detection.py
def items(self) -> ItemsView[str, str]:
    """Iterate over header key/value pairs."""

    return self.values.items()

DetectedPrompts dataclass

DetectedPrompts(instructions=None, system=None, raw=dict())

Structured prompt metadata extracted from CLI detection payloads.

from_body classmethod

from_body(body)

Build a DetectedPrompts instance from a captured request body.

Source code in ccproxy/models/detection.py
@classmethod
def from_body(cls, body: Any | None) -> DetectedPrompts:
    """Build a DetectedPrompts instance from a captured request body."""

    if not isinstance(body, dict):
        return cls(raw={} if body is None else {"__raw__": body})

    body_copy = deepcopy(body)

    instructions = body_copy.get("instructions")
    if not isinstance(instructions, str) or not instructions.strip():
        instructions = None

    system_value = body_copy.get("system")

    return cls(instructions=instructions, system=system_value, raw=body_copy)

instructions_payload

instructions_payload()

Return a payload suitable for injecting Codex-style instructions.

Source code in ccproxy/models/detection.py
def instructions_payload(self) -> dict[str, Any]:
    """Return a payload suitable for injecting Codex-style instructions."""

    if self.instructions:
        return {"instructions": self.instructions}
    return {}

system_payload

system_payload(mode='full')

Return anthropic-style system data respecting the requested mode.

Source code in ccproxy/models/detection.py
def system_payload(self, mode: str = "full") -> dict[str, Any]:
    """Return anthropic-style system data respecting the requested mode."""

    if self.system is None or mode == "none":
        return {}

    if mode == "minimal" and isinstance(self.system, list):
        return {"system": self.system[:1]} if self.system else {}

    return {"system": self.system}