"""
This type stub file was generated by pyright.
"""
import pathlib
from typing import List, Optional, Union
from .c4a_result import CompilationResult, ValidationResult
from ..async_configs import LLMConfig
"""
Clean C4A-Script API with Result pattern
No exceptions - always returns results
"""
class C4ACompiler:
"""Main compiler with result-based API"""
ERROR_CODES = ...
@classmethod
def compile(cls, script: Union[str, List[str]], root: Optional[pathlib.Path] = ...) -> CompilationResult:
"""
Compile C4A-Script to JavaScript
Args:
script: C4A-Script as string or list of lines
root: Root directory for includes
Returns:
CompilationResult with success status and JS code or errors
"""
...
@classmethod
def validate(cls, script: Union[str, List[str]]) -> ValidationResult:
"""
Validate script syntax without generating code
Args:
script: C4A-Script to validate
Returns:
ValidationResult with validity status and any errors
"""
...
@classmethod
def compile_file(cls, path: Union[str, pathlib.Path]) -> CompilationResult:
"""
Compile a C4A-Script file
Args:
path: Path to the file
Returns:
CompilationResult
"""
...
@staticmethod
def generate_script(html: str, query: str | None = ..., mode: str = ..., llm_config: LLMConfig | None = ..., **completion_kwargs) -> str:
"""
One-shot helper that calls the LLM exactly once to convert a
natural-language goal + HTML snippet into either:
1. raw JavaScript (`mode="js"`)
2. Crawl4ai DSL (`mode="c4a"`)
The returned string is guaranteed to be free of markdown wrappers
or explanatory text, ready for direct execution.
"""
...
def compile(script: Union[str, List[str]], root: Optional[pathlib.Path] = ...) -> CompilationResult:
"""Compile C4A-Script to JavaScript"""
...
def validate(script: Union[str, List[str]]) -> ValidationResult:
"""Validate C4A-Script syntax"""
...
def compile_file(path: Union[str, pathlib.Path]) -> CompilationResult:
"""Compile C4A-Script file"""
...