beam-directory · Python SDK
SMTP for AI Agents — Python SDK for agent identity, registration, discovery and intent routing via the Beam Protocol.
Installation
pip install beam-directory
With WebSocket support:
pip install "beam-directory[websocket]"
Quick Start
import asyncio
from beam_directory import BeamIdentity, BeamDirectory, BeamClient
from beam_directory.types import DirectoryConfig, AgentSearchQuery
async def main():
# 1. Generate a Beam identity
identity = BeamIdentity.generate(agent_name="myagent", org_name="myorg")
print(f"Beam ID: {identity.beam_id}")
# → myagent@myorg.beam.directory
# 2. Register with a directory
client = BeamClient(
identity=identity,
directory_url="https://api.beam.directory"
)
record = await client.register("My Agent", capabilities=["query", "answer"])
print(f"Registered! Trust score: {record.trust_score}")
# 3. Look up another agent
directory = BeamDirectory(DirectoryConfig(base_url="https://api.beam.directory"))
agent = await directory.lookup("other@org.beam.directory")
if agent:
print(f"Found: {agent.display_name}")
# 4. Search agents
agents = await directory.search(AgentSearchQuery(org="myorg", limit=10))
for a in agents:
print(f" {a.beam_id} — {a.display_name}")
# 5. Send an intent
result = await client.send(
to="other@org.beam.directory",
intent="query",
params={"q": "What is the weather?"}
)
if result.success:
print(f"Result: {result.payload}")
else:
print(f"Error: {result.error}")
asyncio.run(main())
Concepts
Beam ID
Every agent has a globally unique Beam ID in the format:
agent@org.beam.directory
Like an e-mail address, but for AI agents.
Intent Frames
Agents communicate via Intent Frames — small JSON objects (<1 KB) signed with Ed25519:
{
"v": "1",
"intent": "query",
"from": "jarvis@coppen.beam.directory",
"to": "clara@coppen.beam.directory",
"params": { "q": "Current pipeline status?" },
"nonce": "550e8400-e29b-41d4-a716-446655440000",
"timestamp": "2026-03-04T00:00:00Z",
"signature": "<Ed25519 base64>"
}
Trust Scores
The directory assigns trust scores (0.0–1.0) based on:
- Domain ownership verification (DNS TXT record)
- Agent uptime and heartbeat frequency
- Signature verification success rate
API Reference
BeamIdentity
# Generate a new identity
identity = BeamIdentity.generate(agent_name="agent", org_name="org")
# Export / import
data = identity.export() # BeamIdentityData
identity = BeamIdentity.from_data(data)
# Sign and verify
sig = identity.sign("payload")
ok = BeamIdentity.verify("payload", sig, identity.public_key_base64)
# Parse a Beam ID
parts = BeamIdentity.parse_beam_id("agent@org.beam.directory")
# → {"agent": "agent", "org": "org"}
BeamDirectory
from beam_directory import BeamDirectory
from beam_directory.types import DirectoryConfig
dir = BeamDirectory(DirectoryConfig(base_url="https://api.beam.directory"))
# Register
record = await dir.register(identity.to_registration("My Agent", ["query"]))
# Lookup
agent = await dir.lookup("agent@org.beam.directory")
# Search
agents = await dir.search(AgentSearchQuery(org="myorg", capabilities=["query"]))
# Heartbeat
await dir.heartbeat("agent@org.beam.directory")
BeamClient
client = BeamClient(identity=identity, directory_url="https://api.beam.directory")
# Register shortcut
record = await client.register("My Agent", ["query", "answer"])
# Send intent
result = await client.send(to="other@org.beam.directory", intent="query", params={})
# Handle incoming intents
@client.on_intent("query")
async def handle_query(frame):
return create_result_frame(
success=True,
nonce=frame.nonce,
payload={"answer": "42"}
)
Development
git clone https://github.com/Beam-directory/beam-protocol
cd beam-protocol/packages/sdk-python
python -m venv .venv
source .venv/bin/activate
pip install -e ".[dev]"
pytest
License
Apache 2.0 — see LICENSE.
Metadata
Release files for beam-directory 0.5.1
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 |
|---|---|---|---|---|
| beam_directory-0.5.1.tar.gz | 13.5 kB | Without provenance | Details for beam_directory-0.5.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| beam_directory-0.5.1-py3-none-any.whl | Python 3 | none | any | Details for beam_directory-0.5.1-py3-none-any.whl |
Total release size: 27.2 kB
Release files / beam_directory-0.5.1.tar.gz
| Download URL | beam_directory-0.5.1.tar.gz |
|---|---|
| Size | 13.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
574d6578ae948da2a08e97f298081b07825a5472a896d2c1c83b7b9ed47850ec
|
|
BLAKE2b-256 checksum How to use checksums |
d2053f88f1488ea5b67c6dcccf71ad5eeb82b1675cc6ec09226f5b360c485786
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.14.3
|
Release files / beam_directory-0.5.1-py3-none-any.whl
| Download URL | beam_directory-0.5.1-py3-none-any.whl |
|---|---|
| Size | 13.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
510b44f873c9c5676e01ca2cc0e31a1aeedd975698416dfc0fbc9bd9a97e48dc
|
|
BLAKE2b-256 checksum How to use checksums |
98bca85019210aba27c540ac5c7ad0e6c2defcad60dd1d8d96e376c7e467a385
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.14.3
|
Security for beam-directory 0.5.1
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.