Skip to content

API Reference parrot_tools.browsing.catalog

github-actions[bot] edited this page Dec 2, 2026 · 4 revisions

parrot_tools.browsing.catalog

View source

ActionCatalog — disk-backed store of sites and their catalogued actions.

Layout (one folder per site, one JSON file per action)::

{catalog_dir}/
    hooba-es/
        _site.json          <- SiteInfo
        login.json          <- SiteAction
        goto-dashboard.json
        create-invoice-draft.json

All I/O is async: file contents go through aiofiles and filesystem metadata operations run in a worker thread (asyncio.to_thread), so the event loop is never blocked. Mutating operations are serialized by a write lock, so concurrent tool calls cannot interleave a check-then-write (e.g. two save_action(overwrite=False) for the same action).

Site and action names are slugified before touching the filesystem, so catalog entries can never escape the catalog directory.

Class ActionCatalog

Disk-backed catalog of sites and their deterministic actions.

Parameter Type Default Description
catalog_dir Union[str, Path] Root directory of the catalog. Created lazily on the first write.

Attributes:

Attribute Type Description
catalog_dir Path Root directory of the catalog.

Method ActionCatalog.load

Scan the catalog directory and load every site's metadata.

load(*, force: bool = False) -> None

Parameter Type Default Description
force bool False Re-scan even when already loaded.

Method ActionCatalog.register_site

Create or update a site's metadata file.

register_site(info: SiteInfo, *, overwrite: bool = True) -> SiteInfo

Parameter Type Default Description
info SiteInfo Site metadata (slug auto-derived from its base URL).
overwrite bool True Replace existing metadata. When False and the site exists, raises ValueError.

Returns: SiteInfo — The stored :class:SiteInfo.

Method ActionCatalog.list_sites

Return every registered site's metadata.

list_sites() -> List[SiteInfo]

Returns: List[SiteInfo]

Method ActionCatalog.resolve_site

Resolve a natural reference ("hooba", "hooba.es") to a site.

resolve_site(query: str) -> SiteInfo

Parameter Type Default Description
query str Site slug, alias, domain, base URL, or title.

Returns: SiteInfo — The matching :class:SiteInfo.

Raises:

  • KeyError — No registered site matches query.
  • ValueError — More than one site matches query.

Method ActionCatalog.delete_site

Remove a site and every action file inside its folder.

delete_site(query: str) -> bool

Parameter Type Default Description
query str Site reference (see :meth:resolve_site).

Returns: bool — True when the site existed and was removed.

Method ActionCatalog.save_action

Validate and persist an action script for a site.

Steps are type-checked against the BrowserAction DSL before anything touches disk, so an invalid script never enters the catalog.

save_action(site_query: str, action: SiteAction, *, overwrite: bool = False) -> Path

Parameter Type Default Description
site_query str Site reference (see :meth:resolve_site).
action SiteAction The action to store (site is overwritten with the resolved slug).
overwrite bool False Replace an existing action file.

Returns: Path — Path of the stored JSON file.

Raises:

  • FileExistsError — The action exists and overwrite is False.
  • ValueError — The action's steps fail DSL validation.

Method ActionCatalog.get_action

Load one action script.

get_action(site_query: str, name: str) -> SiteAction

Parameter Type Default Description
site_query str Site reference (see :meth:resolve_site).
name str Action name (slugified before lookup).

Returns: SiteAction — The stored :class:SiteAction.

Raises:

  • KeyError — The action does not exist for that site.

Method ActionCatalog.list_actions

Load every action of a site, sorted by name.

list_actions(site_query: str) -> List[SiteAction]

Parameter Type Default Description
site_query str Site reference (see :meth:resolve_site).

Returns: List[SiteAction] — All parseable actions of the site.

Method ActionCatalog.delete_action

Remove one action script from disk.

delete_action(site_query: str, name: str) -> bool

Parameter Type Default Description
site_query str Site reference (see :meth:resolve_site).
name str Action name.

Returns: bool — True when the file existed and was removed.

Alias SiteAction

Re-exported from parrot_tools.browsing.models.SiteAction.

Alias SiteInfo

Re-exported from parrot_tools.browsing.models.SiteInfo.

Attribute logger

Alias slugify

Re-exported from parrot_tools.browsing.models.slugify.

Architecture

Clients

Bots & Agents

Memory

Knowledge

Tools & Toolkits

Flows

Experts

Skills

Stores & Loaders

MCP & A2A

Server & APIs

Integrations

Outputs & A2UI

Prompts

Security

Operations

Migration

SDD Tooling

LLM Wiki

Deployment

Decisions

API Reference

Clone this wiki locally