Skip to content

RegistryAgent

Base classes

Name Children Inherits
BaseModel
pydantic.main
!!! abstract "Usage Documentation"

⋔ Inheritance diagram

graph TD
  95970868409488["model.RegistryAgent"]
  95970851503232["main.BaseModel"]
  125067848591872["builtins.object"]
  95970851503232 --> 95970868409488
  125067848591872 --> 95970851503232

🛈 DocStrings

Bases: BaseModel

A single agent entry in the ACP registry.

Source code in src/aclientp/registry/model.py
class RegistryAgent(BaseModel):
    """A single agent entry in the ACP registry."""

    id: str
    name: str
    version: str
    description: str
    repository: str | None = None
    authors: list[str] = Field(default_factory=list)
    license: str
    icon: str | None = None
    distribution: DistributionUnion

    def __str__(self) -> str:
        return f"{self.name} ({self.id})"

    @cached_property
    def dist(self) -> Distribution:
        """Resolve the best distribution for the current platform."""
        match self.distribution:
            case DistributionUnion(npx=NpxDistribution() as npx):
                return npx
            case DistributionUnion(uvx=UvxDistribution() as uvx):
                return uvx
            case DistributionUnion(binary=dict() as binaries):
                platform_key = get_platform_key()
                binary_distro: BinaryDistribution | None = binaries.get(platform_key)
                if binary_distro is not None:
                    return binary_distro
                raise ValueError(f"No binary distribution found for platform {platform_key!r}")
            case _:
                raise ValueError("Unsupported distribution type.")

    async def prepare(
        self,
        extra_args: list[str] | None = None,
        *,
        bin_dir: Path = DEFAULT_BIN_DIR,
    ) -> list[str]:
        """Resolve this agent to a runnable command list."""
        args = extra_args or []
        match self.dist:
            case NpxDistribution() as dist:
                return prepare_npx(dist, args)
            case UvxDistribution() as dist:
                return prepare_uvx(dist, args)
            case BinaryDistribution() as dist:
                return await prepare_binary(dist, args, bin_dir)
            case _:
                raise ValueError("Unsupported distribution type.")

dist cached property

dist: Distribution

Resolve the best distribution for the current platform.

prepare async

prepare(extra_args: list[str] | None = None, *, bin_dir: Path = DEFAULT_BIN_DIR) -> list[str]

Resolve this agent to a runnable command list.

Source code in src/aclientp/registry/model.py
async def prepare(
    self,
    extra_args: list[str] | None = None,
    *,
    bin_dir: Path = DEFAULT_BIN_DIR,
) -> list[str]:
    """Resolve this agent to a runnable command list."""
    args = extra_args or []
    match self.dist:
        case NpxDistribution() as dist:
            return prepare_npx(dist, args)
        case UvxDistribution() as dist:
            return prepare_uvx(dist, args)
        case BinaryDistribution() as dist:
            return await prepare_binary(dist, args, bin_dir)
        case _:
            raise ValueError("Unsupported distribution type.")

:fa-brands-github: Show source on GitHub