ArmorIQ SDK for intent-based agent development with CSRG-IAP integration
Project description
ArmorIQ SDK (Python)
Intent-based Agent Development with CSRG-IAP Integration
The ArmorIQ SDK provides a simple, powerful interface for building AI agents that use the Canonical Structured Reasoning Graph (CSRG) Intent Assurance Plane (IAP) for secure, auditable action execution.
Architecture
┌─────────┐ capture_plan() ┌──────────┐
│ Agent │ ──────────────────────> │ IAP │
│ │ │ (CSRG) │
└─────────┘ └──────────┘
│ │
│ get_intent_token() │
│ <──────────────────────────────────┘
│
│ invoke(mcp, action, token)
├──────────────────────> ┌──────────────┐
│ │ AIQ Proxy A │──> MCP A
│ └──────────────┘
│ │
│ verify_token(IAP)
│
└──────────────────────> ┌──────────────┐
│ AIQ Proxy B │──> MCP B
└──────────────┘
Features
✅ Simple API - 4 core methods: capture_plan(), get_intent_token(), invoke(), delegate()
✅ Intent Verification - Every action verified against the original plan
✅ Multi-MCP Support - Seamlessly route actions across multiple MCPs
✅ IAM Context Injection - Automatic IAM context passing to MCP tools
✅ Public Key Delegation - Ed25519-based secure delegation between agents
✅ Token Management - Automatic token caching and refresh
✅ Type-Safe - Full Pydantic models and type hints
✅ Async-First - Built on modern async/await patterns
✅ Error Handling - Clear exceptions for token and intent issues
Installation
pip install armoriq-sdk
For development:
# Clone the repo
git clone https://github.com/armoriq/armoriq-sdk-python
cd armoriq-sdk-python
# Install with uv
uv sync
# Or with pip
pip install -e ".[dev]"
Configuration
Production Endpoints (Default)
The SDK automatically connects to ArmorIQ production services:
- IAP (Intent Assurance Plane):
https://iap.armoriq.io - Proxy Server:
https://cloud-run-proxy.armoriq.io - ConMap API:
https://api.armoriq.io
Environment Variables
Create a .env file or set environment variables:
# Required
AGENT_ID=your-agent-id
USER_ID=your-user-id
# Optional - Override production endpoints
# IAP_ENDPOINT=https://iap.armoriq.io
# PROXY_ENDPOINT=https://cloud-run-proxy.armoriq.io
# For local development
# ARMORIQ_ENV=development # Uses localhost endpoints
Local Development
For local testing with services running on localhost:
export ARMORIQ_ENV=development
export AGENT_ID=test-agent
export USER_ID=test-user
This automatically uses:
- IAP:
http://localhost:8082 - Proxy:
http://localhost:3001
Quick Start
Production Usage
from armoriq_sdk import ArmorIQClient
# Production (uses default endpoints)
client = ArmorIQClient(
user_id="user123",
agent_id="my-agent"
)
# 1. Capture a plan from LLM output
plan = client.capture_plan(
llm="gpt-4",
prompt="Book a flight to Paris and reserve a hotel"
)
# 2. Get an intent token from IAP
token = client.get_intent_token(plan)
# 3. Execute actions through MCP proxies
try:
result = client.invoke(
mcp="travel-mcp",
action="book_flight",
intent_token=token,
params={"destination": "CDG", "date": "2026-02-15"}
)
print(f"Flight booked: {result}")
except InvalidTokenException as e:
print(f"Token validation failed: {e}")
Core API
capture_plan(llm: str, prompt: str) -> Dict
Captures an execution plan from an LLM response and converts it to canonical CSRG format.
Parameters:
llm: LLM identifier (e.g., "gpt-4", "claude-3")prompt: User prompt or instruction
Returns: Canonical plan dictionary ready for token issuance
get_intent_token(plan: Dict) -> IntentToken
Requests a signed intent token from the IAP for the given plan.
Parameters:
plan: Canonical plan fromcapture_plan()
Returns: IntentToken object containing the signed token and metadata
invoke(mcp: str, action: str, intent_token: IntentToken, params: Dict = None, user_email: str = None) -> MCPInvocationResult
Executes an MCP action through the ArmorIQ proxy with token verification and IAM context injection.
Parameters:
mcp: MCP identifier (e.g., "travel-mcp", "finance-mcp")action: Action name to invoke (tool name)intent_token: Token fromget_intent_token()params: Optional action parametersuser_email: Optional user email (injected into IAM context)
Returns: MCPInvocationResult with action result and metadata
Raises:
InvalidTokenException: Token signature/expiry invalidIntentMismatchException: Action not in original planMCPInvocationException: MCP invocation failed
IAM Context: The SDK automatically injects _iam_context parameter with:
email: User emailuser_id: User identifieragent_id: Agent identifierallowed_tools: List of allowed tools from policy validation
delegate(intent_token: IntentToken, delegate_public_key: str, validity_seconds: int = 3600, allowed_actions: List[str] = None) -> DelegationResult
Delegates authority to another agent using public key-based CSRG delegation.
Parameters:
intent_token: Token to delegatedelegate_public_key: Public key of delegate agent (Ed25519 hex format)validity_seconds: Delegation validity in seconds (default: 3600)allowed_actions: Optional list of allowed actions (defaults to all)
Returns: DelegationResult with delegated token and metadata
Raises:
DelegationException: Delegation creation failedInvalidTokenException: Original token is invalid
Example:
from cryptography.hazmat.primitives.asymmetric import ed25519
from cryptography.hazmat.primitives import serialization
# Generate delegate keypair
delegate_private_key = ed25519.Ed25519PrivateKey.generate()
delegate_public_key = delegate_private_key.public_key()
pub_key_bytes = delegate_public_key.public_bytes(
encoding=serialization.Encoding.Raw,
format=serialization.PublicFormat.Raw
)
pub_key_hex = pub_key_bytes.hex()
# Create delegation
result = client.delegate(
intent_token=token,
delegate_public_key=pub_key_hex,
validity_seconds=1800,
allowed_actions=["approve_loan", "process_payment"]
)
# Delegate uses new token
delegate_agent = ArmorIQClient(...)
delegate_agent.invoke(
"loan-mcp",
"approve_loan",
result.delegated_token,
params={"loan_id": "L123"}
)
Configuration
The SDK can be configured via constructor or environment variables:
client = ArmorIQClient(
iap_endpoint="https://iap.armoriq.example.com", # or IAP_ENDPOINT env var
proxy_endpoints={
"travel-mcp": "https://proxy-a.armoriq.example.com",
"finance-mcp": "https://proxy-b.armoriq.example.com"
},
user_id="user123",
agent_id="my-agent",
timeout=30.0,
max_retries=3
)
Examples
See the examples/ directory for complete examples:
basic_agent.py- Simple agent with plan capture and executionmulti_mcp_agent.py- Agent coordinating multiple MCPsdelegation_example.py- Agent-to-agent delegationerror_handling.py- Comprehensive error handling patterns
Development
# Install dev dependencies
uv sync
# Run tests
uv run pytest
# Run tests with coverage
uv run pytest --cov=armoriq_sdk
# Format code
uv run black armoriq_sdk tests
# Type checking
uv run mypy armoriq_sdk
Architecture Details
The SDK integrates with three key components:
- CSRG-IAP - Issues intent tokens after plan canonicalization
- ArmorIQ Proxy - Verifies tokens and routes MCP calls
- MCPs - Execute actual actions (travel, finance, etc.)
Security Model
- Every plan is converted to a canonical hash (CSRG)
- Intent tokens are Ed25519-signed by IAP
- Proxies verify tokens before executing actions
- Actions are checked against Merkle proofs of the plan
- All operations are append-only audited
Contributing
Contributions welcome! Please see CONTRIBUTING.md for guidelines.
License
MIT License - see LICENSE file for details.
Support
- Documentation: https://docs.armoriq.example.com
- Issues: https://github.com/armoriq/armoriq-sdk-python/issues
- Discord: https://discord.gg/armoriq
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 armoriq_sdk-0.1.1.tar.gz.
File metadata
- Download URL: armoriq_sdk-0.1.1.tar.gz
- Upload date:
- Size: 63.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
afd9ce450ad127e7ae6997265d976a65390302d2a370cdd783584b557bb0f691
|
|
| MD5 |
a6b73045ba9787d4a1fe13262cd62d69
|
|
| BLAKE2b-256 |
1b86fe56b452ec7d691e8361e694441f2899f1aff9f6d05a823df74380934d1a
|
File details
Details for the file armoriq_sdk-0.1.1-py3-none-any.whl.
File metadata
- Download URL: armoriq_sdk-0.1.1-py3-none-any.whl
- Upload date:
- Size: 15.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e244eb6970383523658aadedac0783d60e839aaa03a35dda3555811147c3ac72
|
|
| MD5 |
6437f696ffe3e9478867e7a65955d3e2
|
|
| BLAKE2b-256 |
8b41c333878023e4242f9f5c42139be4cb276582a764fae753b13f657798a8b8
|