AFM Core
Core library for Agent-Flavored Markdown (AFM) - providing parsing, validation, and interface implementations.
Features
- AFM File Parser: Extracts YAML frontmatter and Markdown content (Role, Instructions sections)
- Pydantic Models: Type-safe validation of AFM schema for agents, interfaces, and tools
- Interface Implementations: Console chat, web chat, and webhook interfaces
- AgentRunner Protocol: Pluggable backend system for different execution frameworks
- CLI Framework: Entry point for the
afmcommand with validation and run commands
Installation
This package is typically installed as part of afm-cli. For development or custom integrations:
pip install afm-core
Usage
from afm.parser import parse_afm_file
# Parse an AFM file (returns an AFMRecord)
record = parse_afm_file("agent.afm.md")
# Access parsed data
print(f"Agent: {record.metadata.name}")
print(f"Model: {record.metadata.model.provider}/{record.metadata.model.name}")
print(f"Interfaces: {[i.type for i in record.metadata.interfaces]}")
print(f"Role: {record.role}")
print(f"Instructions: {record.instructions}")
Development
Setup
This project uses uv for dependency management.
# Clone the repository
git clone https://github.com/wso2/reference-implementations-afm.git
cd python-interpreter
# Install dependencies
uv sync
Running Tests
# Run all tests
uv run pytest packages/afm-core/tests/
# Run with coverage
uv run pytest packages/afm-core/tests/ --cov=afm
Code Quality
# Format code
uv run ruff format
# Lint code
uv run ruff check
Project Structure
packages/afm-core/src/afm/
├── __init__.py
├── cli.py # CLI entry point
├── exceptions.py # Custom exceptions
├── models.py # Pydantic models
├── parser.py # AFM file parsing
├── runner.py # AgentRunner protocol and runner utilities
├── schema_validator.py # Schema validation
├── templates.py # Prompt templates
├── update.py # Update checker
├── variables.py # Variable substitution
└── interfaces/ # Interface implementations
├── __init__.py
├── base.py # Interface utilities (get_interfaces, get_http_path)
├── console_chat.py
├── web_chat.py
└── webhook.py
Documentation
For comprehensive documentation, see the project README.
License
Apache-2.0
Metadata
Release files for afm-core 0.3.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| afm_core-0.3.0.tar.gz | 34.2 kB | Without provenance | Details for afm_core-0.3.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| afm_core-0.3.0-py3-none-any.whl | Python 3 | none | any | Details for afm_core-0.3.0-py3-none-any.whl |
Total release size: 80.8 kB
Release files / afm_core-0.3.0.tar.gz
| Download URL | afm_core-0.3.0.tar.gz |
|---|---|
| Size | 34.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
d15826d68766da900bb697cc7bf5f19e0142933006f98e7877f90e58db4ca7e7
|
|
BLAKE2b-256 checksum How to use checksums |
c5562f76d3fa9f3848bb34149a00521f5b0b08fc9db54f1fd37dbfad3ae50a55
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.11.6 {"installer":{"name":"uv","version":"0.11.6","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Release files / afm_core-0.3.0-py3-none-any.whl
| Download URL | afm_core-0.3.0-py3-none-any.whl |
|---|---|
| Size | 46.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
c9983fbce969e58ef8e3330773aaeee27bfd53281901f6a22ec0c4dd5596892a
|
|
BLAKE2b-256 checksum How to use checksums |
134e615f8f7c6aa48ebda6ca36c691e29edc150a18d6e320d903487b9c349a47
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.11.6 {"installer":{"name":"uv","version":"0.11.6","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Security for afm-core 0.3.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.