Skip to content

Scanner

Agent discovery and scanning functionality.

Agent scanner utility to discover PlanExecute subclasses.

DiscoveredAgent

Bases: BaseModel

Information about a discovered agent.

Source code in src/opensymbolicai_cli/scanner.py
class DiscoveredAgent(BaseModel):
    """Information about a discovered agent."""

    name: str = Field(description="Human-readable name of the agent")
    class_name: str = Field(description="Python class name")
    file_path: Path = Field(description="Path to the Python file containing the agent")
    description: str = Field(default="", description="Agent description")
    version: str = Field(default="", description="Agent version")
    base_class: str = Field(
        default="PlanExecute",
        description="Base class: 'PlanExecute' or 'Planner'",
    )
    methods: list[DiscoveredMethod] = Field(
        default_factory=list, description="List of primitive and decomposition methods"
    )

DiscoveredMethod

Bases: BaseModel

Information about a discovered method.

Source code in src/opensymbolicai_cli/scanner.py
class DiscoveredMethod(BaseModel):
    """Information about a discovered method."""

    name: str = Field(description="Method name")
    method_type: str = Field(description="Type: 'primitive' or 'decomposition'")
    docstring: str = Field(default="", description="Method docstring")
    signature: str = Field(default="", description="Method signature")
    source: str = Field(default="", description="Full source code of the method")
    line_number: int = Field(default=0, description="Line number in source file")
    read_only: bool = Field(default=False, description="Whether primitive is read-only")
    intent: str = Field(default="", description="Decomposition intent")
    expanded_intent: str = Field(default="", description="Decomposition expanded intent")

ManifestMetadata

Bases: BaseModel

Metadata extracted from a manifest file.

Source code in src/opensymbolicai_cli/scanner.py
class ManifestMetadata(BaseModel):
    """Metadata extracted from a manifest file."""

    name: str = Field(default="", description="Agent name from manifest")
    description: str = Field(default="", description="Agent description from manifest")
    version: str = Field(default="", description="Agent version from manifest")

scan_directory_for_agents(directory)

Scan a directory for Python files containing PlanExecute/Planner subclasses.

Parameters:

Name Type Description Default
directory Path

The directory to scan.

required

Returns:

Type Description
list[DiscoveredAgent]

List of discovered agents.

Source code in src/opensymbolicai_cli/scanner.py
def scan_directory_for_agents(directory: Path) -> list[DiscoveredAgent]:
    """Scan a directory for Python files containing PlanExecute/Planner subclasses.

    Args:
        directory: The directory to scan.

    Returns:
        List of discovered agents.
    """
    if not directory.exists() or not directory.is_dir():
        return []

    agents = []

    for py_file in directory.rglob("*.py"):
        # Skip __pycache__ directories
        if "__pycache__" in py_file.parts:
            continue

        discovered = _extract_agent_info_from_ast(py_file)
        agents.extend(discovered)

    return agents

scan_file_for_agents(file_path)

Scan a single Python file for PlanExecute/Planner subclasses.

Parameters:

Name Type Description Default
file_path Path

Path to the Python file to scan.

required

Returns:

Type Description
list[DiscoveredAgent]

List of discovered agents in the file.

Source code in src/opensymbolicai_cli/scanner.py
def scan_file_for_agents(file_path: Path) -> list[DiscoveredAgent]:
    """Scan a single Python file for PlanExecute/Planner subclasses.

    Args:
        file_path: Path to the Python file to scan.

    Returns:
        List of discovered agents in the file.
    """
    if not file_path.exists() or not file_path.is_file():
        return []

    return _extract_agent_info_from_ast(file_path)