iamai
A compact Python + Rust runtime for cross-platform messaging, plugins, and auditable AI agents.
English · 中文
What Is iamai
iamai is an open-source runtime for chatbots, event-driven applications, and lightweight AI agents. It keeps platform protocols at the edge and lets business logic stay in ordinary async Python plugins.
Adapters normalize terminal, WebSocket, HTTP, Telegram, and OneBot payloads into stable Event, Message, and Context objects. The runtime then handles discovery, lifecycle, dispatch, rules, permissions, dependency injection, middleware, state, sessions, and observability. Selected message and normalization primitives run in a Rust extension through PyO3.
iamai is deliberately a runtime, not an all-in-one agent platform. You can use the built-in agent primitives, replace them, or run without an LLM at all.
How It Works
external platform
-> Adapter validates and normalizes a payload
-> Runtime matches handlers and evaluates Rule + Permission + DI
-> Plugin executes inside event-scoped Context
-> Context.reply() delegates the response back to the Adapter
| Layer | Responsibility | Source |
|---|---|---|
| Adapter | Networking, authentication, signatures, protocol conversion, outbound APIs | python/iamai/adapters |
| Runtime | Configuration, extension discovery, lifecycle, dispatch, DI, middleware, state, sessions, hot reload | python/iamai |
| Plugin | Commands, message/event handlers, rules, permissions, and application behavior | examples |
| Rust core | Message-chain operations, OneBot normalization, JSON merge helpers | src |
The complete lifecycle, including admission, middleware, reload, and shutdown semantics, is documented in the architecture guide.
Features
- Protocol-neutral plugins: write against
Event,Message, andContext, not platform payloads. - Explicit extension model: load plugins and adapters by import path or standard Python entry points.
- Structured dispatch: commands, message handlers, event handlers, composable rules, permissions, DI, and middleware.
- Stateful workflows: memory, JSON, and SQLite state stores plus event-scoped session waiters.
- Operational controls: configuration validation, versioned JSON Schema, health and metrics views, audit events, and management commands.
- Safe development loop: plugin/config hot reload with rollback when the replacement fails.
- Agent building blocks: OpenAI-compatible model calls, tool metadata, approval hooks, traces, and output guardrails.
- Stable contracts: versioned serialization, lifecycle, configuration, deprecation, and extension conformance rules.
Quick Start
Install the latest stable package
python -m pip install iamai
The dev branch may be ahead of the latest PyPI release. To run the repository examples against the current source:
git clone https://github.com/retrofor/iamai.git
cd iamai
uv sync --locked --all-packages --group dev
# Validate the complete runtime configuration before starting it.
uv run --package echo-runtime iamai \
--config examples/echo-runtime/config.terminal.toml config-check
# Start the local TerminalAdapter example.
uv run --package echo-runtime iamai \
--config examples/echo-runtime/config.terminal.toml
At the prompt, enter:
/echo hello iamai
Write a plugin
from iamai import Context, Plugin, command
class HelloPlugin(Plugin):
name = "hello"
@command("hello")
async def hello(self, ctx: Context) -> None:
await ctx.reply("Hello from iamai.")
Add the plugin import path to [runtime].plugins, run config-check, and restart the runtime. The quickstart follows this path from configuration to the first reply.
Adapters
| Adapter | Transport | Typical use |
|---|---|---|
TerminalAdapter |
stdin / stdout | Local development and deterministic testing |
OneBot11Adapter |
HTTP, WebSocket, reverse WebSocket | QQ ecosystems such as Lagrange and LLOneBot |
TelegramAdapter |
Long polling | Telegram bots |
WebhookAdapter |
HTTP POST with optional signature checks | Generic webhooks and service integrations |
| Custom adapter | Any protocol | Subclass Adapter; implement start() and send_message(), then override close() when cleanup is required |
Adapters own the network and trust boundary. The adapter guide covers authentication, payload normalization, outbound calls, and production constraints.
Agent Building Blocks
iamai includes small, composable primitives for agent-style plugins. They are optional and do not change the core runtime model.
| Component | Purpose |
|---|---|
LLMClient |
Async OpenAI-compatible text and JSON calls; live calls require the optional openai package |
ToolRegistry |
Named tools with input schema, permission name, approval requirement, and audit fields |
AgentTrace |
Append-only model/tool/observation records with JSON serialization |
Guardrail |
Case-normalized substring checks for blocked output |
LLMConfig |
TOML/environment configuration for endpoint, model, credentials, temperature, token limit, and timeout |
Runnable patterns live in the repository:
| Pattern | What it demonstrates | Example |
|---|---|---|
| ReAct | Tool selection, observations, memory, and trace inspection | react-runtime |
| Planner-Executor | Structured planning followed by staged execution | planner-executor-runtime |
| Supervisor-Team | Role-specialized workers coordinated by a supervisor | supervisor-team-runtime |
| Skill Chat | Tool/skill routing in a conversational runtime | skill-chat-runtime |
See the agent runtime guide for dependency and security boundaries.
Extensions and Contracts
Third-party packages can publish iamai.plugins and iamai.adapters entry points. The runtime provides deterministic discovery errors, versioned configuration schemas, secret annotations, and conformance helpers for independently distributed extensions.
The 1.x compatibility surface is documented rather than implied:
- Extension packaging and discovery
- Serialization contract
- Lifecycle contract
- Public API conformance matrix
- 0.3 to 1.0 migration guide
Examples and Documentation
| Resource | Start here when you want to... |
|---|---|
| Quickstart | Validate a config and run the terminal example |
| Tutorials | Build a runtime step by step |
| Guides | Design plugins, adapters, state, operations, and agents |
| API reference | Inspect public Python classes and functions |
examples/ |
Run complete local projects and agent patterns |
| Ecosystem comparison | Understand where iamai fits and what it intentionally does not replace |
Development
uv sync --locked --all-packages --group dev --group docs
uv run ruff check .
uv run python -m mypy
uv run pytest
cargo test --no-default-features
bash scripts/check_example_configs.sh
uv run sphinx-build -W --keep-going -b html docs docs/_build/html
Open pull requests against dev. Keep runtime behavior covered by tests and update the relevant contract documentation when changing a public boundary. See GitHub Issues and Discussions for active work.
License
MIT © iamai contributors
Acknowledgments
iamai draws lessons from NoneBot, Koishi, and AliceBot. Its agent examples are informed by the ReAct paper and the wider agent-runtime community.
Release files for iamai 1.0.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 | |
|---|---|---|---|
| iamai-1.0.0.tar.gz | 482.8 kB | Details |
Built distributions (wheels)
Total release size: 8.0 MB
Release files / iamai-1.0.0.tar.gz
| Download URL | iamai-1.0.0.tar.gz |
|---|---|
| Size | 482.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
a43ff8ca1735b735d09f9edd82df16383bd7a69127a93125ef037236a0c54cdf
|
|
BLAKE2b-256 checksum How to use checksums |
e4faf71eff0aa7e9bb1dda1264f9f01f19dd500ee87b01a7f64ea981c8303c49
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.12.7 {"installer":{"name":"uv","version":"0.12.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}
|
Release files / iamai-1.0.0-cp311-abi3-win_arm64.whl
| Download URL | iamai-1.0.0-cp311-abi3-win_arm64.whl |
|---|---|
| Size | 309.6 kB |
| Tags | CPython 3.11 Windows ARM64 abi3 |
|
SHA-256 checksum How to use checksums |
7a22066a134accb45636e89d5c26dbe4aff15c029cd433f30a9485730847ee0b
|
|
BLAKE2b-256 checksum How to use checksums |
cf39d3eb086a6bd11fca4acfcdd2738ae1d3f64777ae2ff06390d6a5832d8a68
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.12.7 {"installer":{"name":"uv","version":"0.12.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}
|
Release files / iamai-1.0.0-cp311-abi3-win_amd64.whl
| Download URL | iamai-1.0.0-cp311-abi3-win_amd64.whl |
|---|---|
| Size | 319.5 kB |
| Tags | CPython 3.11 Windows x86-64 abi3 |
|
SHA-256 checksum How to use checksums |
63168baeab1c154c19a4ef3a46c993996e7a9291bead051e929cc351699e5929
|
|
BLAKE2b-256 checksum How to use checksums |
49c0553f4a216394a97121eb244e024c97863c2dbc0a981c8f205a5a82e49ea7
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.12.7 {"installer":{"name":"uv","version":"0.12.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}
|
Release files / iamai-1.0.0-cp311-abi3-win32.whl
| Download URL | iamai-1.0.0-cp311-abi3-win32.whl |
|---|---|
| Size | 306.1 kB |
| Tags | CPython 3.11 Windows x86-32 abi3 |
|
SHA-256 checksum How to use checksums |
7d1f178ef7668ce368981c367d0f1eeffc2e85ba245fb9fb29e77477b8ab95d4
|
|
BLAKE2b-256 checksum How to use checksums |
8c0c7f642271ab2e137dc0f072afd0fee4741571888e3021bcec43ae922f960c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.12.7 {"installer":{"name":"uv","version":"0.12.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}
|
Release files / iamai-1.0.0-cp311-abi3-musllinux_1_2_x86_64.whl
| Download URL | iamai-1.0.0-cp311-abi3-musllinux_1_2_x86_64.whl |
|---|---|
| Size | 676.2 kB |
| Tags | CPython 3.11 Linux musl 1.2+ x86-64 abi3 |
|
SHA-256 checksum How to use checksums |
fef97435638548bce8a6b0a8f69a0ac309e39933d53c24c8ba44b30dcbe7d63f
|
|
BLAKE2b-256 checksum How to use checksums |
bc0b7d9656939282e15a7737beac49f055bc5c2f276eb7c509df56da40517efd
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.12.7 {"installer":{"name":"uv","version":"0.12.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}
|
Release files / iamai-1.0.0-cp311-abi3-musllinux_1_2_i686.whl
| Download URL | iamai-1.0.0-cp311-abi3-musllinux_1_2_i686.whl |
|---|---|
| Size | 705.7 kB |
| Tags | CPython 3.11 Linux musl 1.2+ x86-32 abi3 |
|
SHA-256 checksum How to use checksums |
1bbd9066ccb87e0dc9e6f84e58b37c78e0b9df8c55e9491fadc7707d8c635896
|
|
BLAKE2b-256 checksum How to use checksums |
e15297f765bc9413d831648873f658c6a921b8c58ababc58b1aeca968f93611e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.12.7 {"installer":{"name":"uv","version":"0.12.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}
|
Release files / iamai-1.0.0-cp311-abi3-musllinux_1_2_armv7l.whl
| Download URL | iamai-1.0.0-cp311-abi3-musllinux_1_2_armv7l.whl |
|---|---|
| Size | 740.5 kB |
| Tags | CPython 3.11 Linux musl 1.2+ ARMv7l abi3 |
|
SHA-256 checksum How to use checksums |
2359e2ebd1f96f7e689a20d0aa0633919f1531e005e1aac2cdb2875fa2f77ec6
|
|
BLAKE2b-256 checksum How to use checksums |
9e5edb00f22b0f36589bc5dcc8a51ce8a4102943e81d98a6a1b7f19c9de0d917
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.12.7 {"installer":{"name":"uv","version":"0.12.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}
|
Release files / iamai-1.0.0-cp311-abi3-musllinux_1_2_aarch64.whl
| Download URL | iamai-1.0.0-cp311-abi3-musllinux_1_2_aarch64.whl |
|---|---|
| Size | 637.2 kB |
| Tags | CPython 3.11 Linux musl 1.2+ ARM64 abi3 |
|
SHA-256 checksum How to use checksums |
d659524b89571be744b8536cfaefeeccb42efa0ddfe1bd0892f9c356a169056d
|
|
BLAKE2b-256 checksum How to use checksums |
3682a3ff6dff9e7581f36ec3c7168e2f00269caac0e4d07f0b84468c8ef147e6
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.12.7 {"installer":{"name":"uv","version":"0.12.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}
|
Release files / iamai-1.0.0-cp311-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
| Download URL | iamai-1.0.0-cp311-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl |
|---|---|
| Size | 473.9 kB |
| Tags | CPython 3.11 Linux glibc 2.17+ x86-64 abi3 |
|
SHA-256 checksum How to use checksums |
3bceac697d7941e39a3f7c53ca7471c61c3455cb6c0000b2272742f4f3cc8f8d
|
|
BLAKE2b-256 checksum How to use checksums |
4d22e7947956d105d82dc5f936412824b54c02665ad6d2d54c4b6d8e0804f84b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.12.7 {"installer":{"name":"uv","version":"0.12.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}
|
Release files / iamai-1.0.0-cp311-abi3-manylinux_2_17_s390x.manylinux2014_s390x.whl
| Download URL | iamai-1.0.0-cp311-abi3-manylinux_2_17_s390x.manylinux2014_s390x.whl |
|---|---|
| Size | 492.7 kB |
| Tags | CPython 3.11 Linux glibc 2.17+ IBM System/390x abi3 |
|
SHA-256 checksum How to use checksums |
76abc77f1ac758ef4c17e9fc53910bcc1838bbfbba6a702035e90da378fed94e
|
|
BLAKE2b-256 checksum How to use checksums |
d28a3a4ca7bb0f61230be77844e4a6b0dcb998a152758237198e0fac6159f111
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.12.7 {"installer":{"name":"uv","version":"0.12.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}
|
Release files / iamai-1.0.0-cp311-abi3-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl
| Download URL | iamai-1.0.0-cp311-abi3-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl |
|---|---|
| Size | 584.1 kB |
| Tags | CPython 3.11 Linux glibc 2.17+ PowerPC 64-le abi3 |
|
SHA-256 checksum How to use checksums |
fc67f6897ac243d67fca61e0b7001bda288bc8eab21756e5442723211dbaf2a2
|
|
BLAKE2b-256 checksum How to use checksums |
66d1585cffc074d97a06a59c1fbda2d44bc4a891955b69a2f791ab1395174d98
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.12.7 {"installer":{"name":"uv","version":"0.12.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}
|
Release files / iamai-1.0.0-cp311-abi3-manylinux_2_17_armv7l.manylinux2014_armv7l.whl
| Download URL | iamai-1.0.0-cp311-abi3-manylinux_2_17_armv7l.manylinux2014_armv7l.whl |
|---|---|
| Size | 465.4 kB |
| Tags | CPython 3.11 Linux glibc 2.17+ ARMv7l abi3 |
|
SHA-256 checksum How to use checksums |
7c26fb03ea29cd2e68714cf6e6fae7583c14509135b971dd0b7d81643c6b127d
|
|
BLAKE2b-256 checksum How to use checksums |
f566de9a399f9e21e98d1fda59c646e03c631ba891de89b974ee9937a88c34bf
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.12.7 {"installer":{"name":"uv","version":"0.12.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}
|
Release files / iamai-1.0.0-cp311-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
| Download URL | iamai-1.0.0-cp311-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl |
|---|---|
| Size | 460.7 kB |
| Tags | CPython 3.11 Linux glibc 2.17+ ARM64 abi3 |
|
SHA-256 checksum How to use checksums |
aaab6e3f193bc3f2a5390d5323797ba8c14e3e639dba7ee779423d97f21c5d61
|
|
BLAKE2b-256 checksum How to use checksums |
f39e891e323bddee1c4b5a78d1d9dea9c6d0b73fd8dd42dc0041616cce303086
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.12.7 {"installer":{"name":"uv","version":"0.12.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}
|
Release files / iamai-1.0.0-cp311-abi3-manylinux_2_5_i686.manylinux1_i686.whl
| Download URL | iamai-1.0.0-cp311-abi3-manylinux_2_5_i686.manylinux1_i686.whl |
|---|---|
| Size | 492.5 kB |
| Tags | CPython 3.11 Linux glibc 2.5+ x86-32 abi3 |
|
SHA-256 checksum How to use checksums |
1ea28d0ee75cff1d7334e97c337fa433a762a2eafb38160f5682344cb25c5453
|
|
BLAKE2b-256 checksum How to use checksums |
c7213d69fcff3fd918cc32d9dcf1ba8f7a91b047cacae643f5aa2e86942210bc
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.12.7 {"installer":{"name":"uv","version":"0.12.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}
|
Release files / iamai-1.0.0-cp311-abi3-macosx_11_0_arm64.whl
| Download URL | iamai-1.0.0-cp311-abi3-macosx_11_0_arm64.whl |
|---|---|
| Size | 422.9 kB |
| Tags | CPython 3.11 abi3 macOS 11.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
1a325dec46f52ab5b11f74b44c25116fc780d15cad36444f95167874ce069714
|
|
BLAKE2b-256 checksum How to use checksums |
173c9973d201bd63fc7da66e034aee178c1087e8c4fc80b8c0e7c2fcf112c7c7
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.12.7 {"installer":{"name":"uv","version":"0.12.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}
|
Release files / iamai-1.0.0-cp311-abi3-macosx_10_12_x86_64.whl
| Download URL | iamai-1.0.0-cp311-abi3-macosx_10_12_x86_64.whl |
|---|---|
| Size | 430.4 kB |
| Tags | CPython 3.11 abi3 macOS 10.12+ x86-64 |
|
SHA-256 checksum How to use checksums |
2dca38f1fd14b2e07e18973f985f97b514690598736ac29141f4ea11f16d6400
|
|
BLAKE2b-256 checksum How to use checksums |
a73a2cd406fb234550b39de3b7b7db6e8366cb4229dca9ecc1bb2d07685343f4
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.12.7 {"installer":{"name":"uv","version":"0.12.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}
|