Skip to main content

Zero-dependency parser for agents.txt v1.0. The reference Python implementation.

Project description

agentpress-core

Zero-dependency reference parser for agents.txt v1.0. Python.

Mirror of @agent_press/core (TypeScript). Use this from Python agent runtimes, CI scripts, and analysis tools.

Install

pip install agentpress-core

Quick start

from pathlib import Path
from agentpress_core import parse, validate, is_action_allowed, check_rate_limit, fetch_and_parse

# Parse a local file
text = Path("agents.txt").read_text(encoding="utf-8")
data = parse(text)

# Validate against the spec
result = validate(data)
if not result.ok:
    for issue in result.issues:
        print(issue.severity, issue.message)

# Decide what an agent may do
decision = is_action_allowed(data, "merge_to_main")
#   "allow" | "deny" | "requires_approval" | "unknown"

# Respect rate limits
if not check_rate_limit(data, "pr", current_daily_pr_count):
    raise RuntimeError("agents.txt rate limit reached for this repo")

# Or fetch directly
remote = fetch_and_parse("https://github.com/barneywohl/agentpress/raw/main/agents.txt")

API

Function Description
parse(text) Parse a raw agents.txt string into a typed AgentsTxt object. Tolerant — never raises.
validate(data) Returns ValidationResult(ok, issues). Errors fail validation; warnings don't.
is_action_allowed(data, action) Returns "allow" | "deny" | "requires_approval" | "unknown".
check_rate_limit(data, kind, count) kind in {"pr", "issue", "comment", "branch"}.
fetch_and_parse(url, timeout=10.0) Fetch + parse. Standard library only (urllib).
load(url, timeout=10.0) fetch_and_parse + validate — convenience.

Why stdlib only

  • Auditable in 30 minutes.
  • Zero supply-chain risk.
  • Pinnable in any Python project from 3.10 onwards.

License

MIT.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

agentpress_core-1.0.0rc2.tar.gz (8.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

agentpress_core-1.0.0rc2-py3-none-any.whl (6.1 kB view details)

Uploaded Python 3

File details

Details for the file agentpress_core-1.0.0rc2.tar.gz.

File metadata

  • Download URL: agentpress_core-1.0.0rc2.tar.gz
  • Upload date:
  • Size: 8.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.3

File hashes

Hashes for agentpress_core-1.0.0rc2.tar.gz
Algorithm Hash digest
SHA256 4eb2f7a8255ce63775edc4a48bc8650b6dcd67fc44965d37cce8607906f8fd33
MD5 61b4d472e9227586ac9ef219527b7029
BLAKE2b-256 d40701ebfd660507028b5a7d5b26cc663d896c2976d7e49006d1d5260017343d

See more details on using hashes here.

File details

Details for the file agentpress_core-1.0.0rc2-py3-none-any.whl.

File metadata

File hashes

Hashes for agentpress_core-1.0.0rc2-py3-none-any.whl
Algorithm Hash digest
SHA256 b8f50f4b32b6080f28e4c75a3b5f2d04ff57f4e15d4aa7db7a13d68e0b71e5de
MD5 d0d439e056774b4790b46eccc8f18197
BLAKE2b-256 684a7283a726a450bd44f5973013c2bd63241276ebc7015cafd8551903f7992a

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page