Plugin Development Guide
Relevant source files
The following files were used as context for generating this wiki page:
This guide provides technical specifications for developing plugins within the abx-dl ecosystem. abx-dl uses a language-agnostic plugin architecture shared with ArchiveBox, where plugins are composed of a configuration schema and executable hook scripts that react to specific lifecycle events.
Plugins are responsible for downloading, extracting, and processing web content. They are loaded from the abx-plugins package or a directory specified by the ABX_PLUGINS_DIR environment variable. Sources: README.md:50-55, abx_dl/models.py:270-280
Plugin Architecture and Structure
An abx-dl plugin is a directory containing a metadata file and one or more executable hooks. The system treats these hooks as black-box executables, allowing developers to implement logic in any language as long as the file is executable and follows naming conventions. Sources: abx_dl/models.py:40-50, abx_dl/models.py:300-310
Directory Layout
A typical plugin directory includes:
config.json: Defines plugin metadata, configuration properties, and dependencies.on_{Event}__*: Executable scripts (Python, JS, Shell, etc.) that handle specific events.
The diagram shows the relationship between plugin files and the execution phases they influence. Sources: README.md:55-65, abx_dl/models.py:75-85
Plugin Configuration (config.json)
The config.json file defines the plugin's identity, its requirements, and the configuration options it exposes to users. Sources: abx_dl/models.py:75-90
Key Configuration Fields
| Field | Type | Description |
|---|---|---|
title | String | Human-readable name of the plugin. |
description | String | Brief explanation of what the plugin downloads or extracts. |
output_mimetypes | List[String] | Mimetypes of files produced by the plugin (e.g., text/html, image/png). |
properties | Object | JSONSchema describing configuration properties (e.g., {PLUGIN}_ENABLED). |
required_binaries | List[Object] | External binaries needed (e.g., wget, chrome) and their providers. |
required_plugins | List[String] | Other abx plugins that must be active for this plugin to work. |
Sources: abx_dl/models.py:78-87, abx_dl/cli.py:910-925
Execution Lifecycle and Hooks
abx-dl executes plugins in distinct phases. Each phase corresponds to a specific hook prefix. Sources: README.md:55-65, TODOs.md:15-30
Hook Naming Convention
Hooks must follow the format: on_{Event}__[{order}_]{description}[.finite][.daemon][.bg].{ext}.
- Event: The lifecycle stage (e.g.,
Snapshot). - Order: Two-digit integer (e.g.,
01) determining execution sequence. - Type:
.bgindicates a background process;.daemonindicates a long-running service.
Sources: abx_dl/models.py:42-55, abx_dl/models.py:328-335
Lifecycle Phases
- BinaryRequest Phase: Resolves or installs required external tools. Hooks emit
Binaryrecords. - CrawlSetup Phase: Configures runtime state or launches daemons (like headless Chrome). Hooks emit
Processrecords but noArchiveResultrecords. - Snapshot Phase: The primary extraction phase per URL. Hooks emit
ArchiveResult,Snapshot, andTagrecords.
The sequence shows the standard execution flow from dependency resolution to final extraction. Sources: README.md:155-165, TODOs.md:15-25
Data Models and Output
Plugins communicate with the abx-dl orchestrator by emitting structured JSONL records to stdout. Sources: README.md:145-155, abx_dl/models.py:255-265
Common Output Records
- Binary: Contains
abspath,version, andnameof a resolved tool. - ArchiveResult: Details the outcome of a snapshot attempt. Includes
status(succeeded,failed,skipped),output_str(file path), andoutput_files(list of produced files). - Snapshot: Metadata about the URL being processed.
- Process: Metadata about subprocess execution, including
exit_code,stdout, andstderr.
Sources: abx_dl/models.py:195-250, abx_dl/cli.py:65-75
Output File Structure
By default, plugins write results into a subdirectory named after the plugin within the output directory. Metadata is recorded in index.jsonl. Sources: README.md:180-195, skills/abx-dl/SKILL.md:45-55
./output_dir/
├── index.jsonl # Master manifest
├── {plugin_name}/ # Plugin-specific directory
│ └── output.ext # Extraction results
└── {plugin_name}.stdout.log # Execution logs
Sources: README.md:185-200, CLAUDE.md:65-70
Environment and Configuration Propagation
Plugins receive configuration via environment variables. abx-dl hydrates these variables from three layers:
- Default Config: Hardcoded defaults in the plugin and core.
- User Config: Stored in
~/.config/abx/config.env. - Derived Config: Runtime-detected values (like binary paths) stored in
~/.config/abx/derived.env.
Variable names follow the convention {PLUGIN}_{PROPERTY} (e.g., WGET_TIMEOUT, CHROME_BINARY). Sources: README.md:85-110, abx_dl/models.py:145-165
Runtime Environment (PluginEnv)
The PluginEnv model ensures that PATH is updated to include abx-managed binary directories (LIB_DIR, PIP_BIN_DIR, NPM_BIN_DIR) before the system PATH, ensuring hooks use the correctly resolved dependencies. Sources: abx_dl/models.py:140-190
Best Practices for Plugin Developers
- Idempotency: Hooks should handle existing files gracefully, especially in the
CrawlSetupphase. Sources: CLAUDE.md:65-70 - Log Management: Hooks should write to
{hook_name}.stdout.logto avoid conflicts when multiple hooks run concurrently. Sources: CLAUDE.md:65-70 - Binary Discovery: Use
on_BinaryRequest__*hooks to register binary paths by emitting{"type": "Binary", "name": "...", "abspath": "..."}. Sources: CLAUDE.md:60-65 - Timeouts: Respect the
TIMEOUTenvironment variable provided by the orchestrator. Sources: README.md:100-105
Conclusion
Developing plugins for abx-dl involves creating modular, event-driven scripts that adhere to a strict naming and output contract. By leveraging the multi-phase lifecycle—from binary installation to snapshot extraction—plugins can integrate complex tools like headless browsers and media downloaders into a unified archival workflow. Reusing the abx-plugins ecosystem ensures compatibility between abx-dl and the full ArchiveBox suite. Sources: README.md:10-25, TODOs.md:5-10