Agent-first Python CLI library — Typer-compatible, built on argparse + pydantic
Project description
agentyper
Agent-first Python CLI library — built on argparse + pydantic, Typer-compatible.
Typer was built for the era when type hints changed Python.
agentyper is built for the era when AI agents changed how software is operated.
Install
pip install agentyper
Quick Start
Single function (like typer.run()):
import agentyper
def search(ticker: str, limit: int = 10):
"""Search securities by ticker."""
results = service.search(ticker, limit)
agentyper.output(results) # routes via --format automatically
agentyper.run(search)
Multi-command app:
import agentyper
app = agentyper.Agentyper(name="my-tool", version="1.0.0")
@app.command()
def search(ticker: str, limit: int = agentyper.Option(10, help="Max results")):
"""Search securities."""
agentyper.output(service.search(ticker, limit))
@app.command()
def delete(name: str):
"""Delete a record."""
if agentyper.confirm(f"Delete '{name}'?"):
service.delete(name)
app()
Typer migration — one line:
# import typer ← before
import agentyper as typer # ← after; everything else stays identical
What Agents Get for Free
Every command automatically gains:
my-tool --schema # full JSON Schema of the entire app
my-tool search --schema # JSON Schema for this command's params
my-tool search AAPL --format csv # 4× cheaper output than table
my-tool search AAPL --format json # structured JSON output
my-tool delete alice --yes # skip confirm() in agent mode
my-tool wizard --answers '{"confirms":[true],"prompts":["Alice","admin"]}'
Agent Ergonomics
| Feature | agentyper | Typer |
|---|---|---|
--schema on every command |
✅ automatic | ❌ manual |
--format json/csv/table |
✅ automatic | ❌ manual |
| Structured JSON errors | ✅ automatic | ❌ free text |
| Exit code taxonomy (0/1/2) | ✅ | ❌ 0 or 1 |
| Interactive features in agent mode | ✅ --yes/--answers bypass |
❌ blocks |
isatty() auto-format detection |
✅ | ❌ |
| Dependencies | argparse + pydantic | Click + Typer |
Exit Codes
agentyper.EXIT_SUCCESS = 0 # success
agentyper.EXIT_VALIDATION = 1 # bad input — agent should retry with correction
agentyper.EXIT_SYSTEM = 2 # system error — agent should abort
Interactive Features
All interactive features from Typer work identically in a terminal. In agent/non-TTY mode, they resolve without blocking:
# Human terminal: asks interactively
my-tool delete alice
# Agent: auto-confirm via flag
my-tool delete alice --yes
# Agent: pre-supply all answers
my-tool wizard --answers '{"confirms":[true,false],"prompts":["Alice","admin"]}'
# Agent: pipe answers from stdin
echo '{"confirms":[true]}' | my-tool delete alice --answers -
License
MIT
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file agentyper-0.1.3.tar.gz.
File metadata
- Download URL: agentyper-0.1.3.tar.gz
- Upload date:
- Size: 24.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: uv/0.10.7 {"installer":{"name":"uv","version":"0.10.7","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}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
14519ade330e82a393dd5ebc50a732b440db5ea2a51f352c490bf3e4383d6715
|
|
| MD5 |
c1c1769e5f494ad9174e54bf6f491c95
|
|
| BLAKE2b-256 |
c14edc0ad914ee2db88541808eea3c74bc875a46e62b09ea38fd3e0c928b60af
|
File details
Details for the file agentyper-0.1.3-py3-none-any.whl.
File metadata
- Download URL: agentyper-0.1.3-py3-none-any.whl
- Upload date:
- Size: 25.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: uv/0.10.7 {"installer":{"name":"uv","version":"0.10.7","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}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2bfb7c95b85c38c3eb5f1d5515a4e16d8a0bc5bdc715d0c41ffbf230c7068c0d
|
|
| MD5 |
c8915a5302b741029f0b9383ee2d1210
|
|
| BLAKE2b-256 |
a1e14ee4eaaed62e04dac5c15f610ac5d75cb68b0621df5281ba2bed516b90c5
|