AgentMesh API Reference

April 26, 2026 · View on GitHub

Auto-generated reference for the AgentMesh public API. All classes use Pydantic BaseModel unless noted.


Layer 1 — Identity (agentmesh.identity)

Cryptographic agent identity, credentials, delegation, and key management.

AgentDID

Decentralized Identifier for an agent. Format: did:mesh:<unique-id>.

MethodSignatureDescription
generate(name: str, org: str | None = None) → AgentDIDGenerate a new DID for an agent.
from_string(did_string: str) → AgentDIDParse a did:mesh:… string.

AgentIdentity

First-class identity for an AI agent with Ed25519 cryptographic binding.

MethodSignatureDescription
create(name, sponsor, capabilities?, organization?, description?) → AgentIdentityFactory method — generates keypair, DID, and identity.
sign(data: bytes) → strSign data with the agent's private key (base64 result).
verify_signature(data: bytes, signature: str) → boolVerify a base64 Ed25519 signature.
delegate(name, capabilities, description?) → AgentIdentityCreate a child agent with narrowed capabilities.
revoke(reason: str) → NonePermanently revoke this identity.
suspend(reason: str) → NoneTemporarily suspend this identity.
reactivate() → NoneReactivate a suspended identity.
is_active() → boolCheck active status and expiration.
has_capability(capability: str) → boolCheck capability (supports wildcards).
to_jwk(include_private: bool = False) → dictExport as JWK (RFC 7517).
from_jwk(jwk: dict) → AgentIdentityImport from JWK.
to_jwks(include_private: bool = False) → dictExport as JWK Set.
from_jwks(jwks: dict, kid?: str) → AgentIdentityImport from JWK Set.
to_did_document() → dictExport as W3C DID Document.

IdentityRegistry

In-memory registry for agent identities.

MethodSignatureDescription
register(identity: AgentIdentity) → NoneRegister an identity.
get(did: str | AgentDID) → AgentIdentity | NoneLook up by DID.
revoke(did: str | AgentDID, reason: str) → boolRevoke identity and all delegates.
get_by_sponsor(sponsor_email: str) → list[AgentIdentity]Get all identities for a sponsor.
list_active() → list[AgentIdentity]List all active identities.

Credential

Ephemeral credential with configurable TTL (default 15 min).

MethodSignatureDescription
issue(agent_did, capabilities?, resources?, ttl_seconds?, issued_for?) → CredentialIssue a new credential.
is_valid() → boolCheck validity (not expired, not revoked).
is_expiring_soon(threshold_seconds: int = 300) → boolCheck if nearing expiration.
verify_token(token: str) → boolVerify a bearer token.
revoke(reason: str) → NoneRevoke this credential.
rotate() → CredentialCreate a replacement credential.
has_capability(capability: str) → boolCheck if credential grants a capability.
can_access_resource(resource: str) → boolCheck resource access.
time_remaining() → timedeltaTime until expiration.
to_bearer_token() → strSerialize as a bearer token string.

CredentialManager

Manages credential lifecycle — issuance, validation, rotation, revocation.

MethodSignatureDescription
issue(agent_did, capabilities?, resources?, ttl_seconds?, issued_for?) → CredentialIssue a managed credential.
validate(token: str) → Credential | NoneValidate a bearer token.
rotate(credential_id: str) → Credential | NoneRotate a credential.
rotate_if_needed(credential_id: str) → CredentialRotate only if expiring soon.
revoke(credential_id: str, reason: str) → boolRevoke by ID.
revoke_all_for_agent(agent_did: str, reason: str) → intRevoke all credentials for an agent.
get_active_for_agent(agent_did: str) → list[Credential]Get active credentials.
cleanup_expired() → intRemove expired credentials.
on_revocation(callback: Callable) → NoneRegister a revocation callback.

Cryptographic scope chains that can only narrow capabilities.

MethodSignatureDescription
ScopeChain.create_root(sponsor_email, root_agent_did, capabilities, sponsor_verified?) → tupleCreate the root of a chain.
ScopeChain.add_link(link: DelegationLink) → NoneAppend a delegation link.
ScopeChain.verify() → tuple[bool, str | None]Verify entire chain integrity.
ScopeChain.get_effective_capabilities() → list[str]Compute narrowed capabilities.
ScopeChain.trace_capability(capability: str) → list[dict]Trace a capability through the chain.
DelegationLink.verify_capability_narrowing() → boolVerify child caps ⊆ parent caps.
DelegationLink.is_valid() → boolCheck link validity.

UserContext

Represents the human user context attached to a delegation.

MethodSignatureDescription
create(user_id, user_email?, roles?, permissions?, ttl_seconds?) → UserContextFactory method.
is_valid() → boolCheck expiration.
has_permission(permission: str) → boolCheck permission.
has_role(role: str) → boolCheck role membership.

HumanSponsor

Human accountability link for agent identities.

MethodSignatureDescription
create(email, name?, organization?, allowed_capabilities?) → HumanSponsorFactory method.
verify(method: str = "email") → NoneMark sponsor as verified.
can_sponsor_agent() → boolCheck if sponsor can create agents.
can_grant_capability(capability: str) → boolCheck if capability is allowed.
add_agent / remove_agent(agent_did: str) → NoneManage sponsored agents.
suspend / reactivate(reason?: str) → NoneSuspend or reactivate.

KeyStore (abstract), SoftwareKeyStore, PKCS11KeyStore

Pluggable cryptographic key storage backends.

MethodSignatureDescription
generate_keypair(agent_id: str) → bytesGenerate Ed25519 keypair; return raw public key.
sign(agent_id: str, data: bytes) → bytesSign data with agent's private key.
verify(public_key: bytes, data: bytes, signature: bytes) → boolVerify an Ed25519 signature.
get_public_key(agent_id: str) → bytesRetrieve raw public key bytes.
delete_key(agent_id: str) → NoneDelete keypair.

SoftwareKeyStore — In-memory Ed25519 keys (default). PKCS11KeyStore(library_path, slot=0, pin=None) — HSM-backed via PKCS#11.

RiskScorer / RiskScore

Continuous risk scoring for agent behavior.

MethodSignatureDescription
RiskScorer.get_score(agent_did: str) → RiskScoreGet current risk score.
RiskScorer.add_signal(agent_did: str, signal: RiskSignal) → NoneAdd a risk signal.
RiskScorer.recalculate(agent_did: str) → RiskScoreRecalculate from signals.
RiskScorer.get_high_risk_agents(threshold?: int) → list[RiskScore]Find high-risk agents.
RiskScore.get_risk_level(score: int) → strMap score to level string.

SPIFFEIdentity / SVID

SPIFFE/SVID workload identity integration.

MethodSignatureDescription
SPIFFEIdentity.create(agent_did, agent_name, trust_domain?, organization?) → SPIFFEIdentityCreate SPIFFE identity.
SPIFFEIdentity.issue_svid(ttl_hours?, svid_type?) → SVIDIssue a new SVID.
SPIFFEIdentity.get_valid_svid() → SVID | NoneGet current valid SVID.
SVID.is_valid() → boolCheck SVID validity.

RevocationList

Manages revoked agent identities.

MethodSignatureDescription
revoke(agent_did, reason, revoked_by?, ttl_seconds?) → RevocationEntryRevoke an agent.
unrevoke(agent_did: str) → boolRemove from revocation list.
is_revoked(agent_did: str) → boolCheck revocation status.
save / load(path: str) → NonePersist to / load from file.

KeyRotationManager

Ed25519 key rotation with cryptographic continuity proofs.

MethodSignatureDescription
rotate() → AgentIdentityRotate keys and return updated identity.
needs_rotation() → boolCheck if rotation is due.
get_rotation_proof() → dictGet proof linking old → new key.
verify_rotation(old_pk, new_pk, proof) → boolVerify a rotation proof (static).

NamespaceManager

Manages agent communication namespaces and cross-namespace rules.

MethodSignatureDescription
create_namespace(name, description, parent?) → AgentNamespaceCreate a namespace.
add_member / remove_member(namespace_name, agent_did) → NoneManage members.
can_communicate(from_did, to_did) → boolCheck if two agents can communicate.
can_delegate(from_did, to_did) → boolCheck cross-namespace delegation.

MTLSIdentityVerifier

Mutual TLS identity verification for agent connections.

MethodSignatureDescription
create_self_signed_cert() → tuple[bytes, bytes]Generate self-signed cert + key.
create_ssl_context(server_side: bool = False) → ssl.SSLContextCreate configured SSL context.
verify_peer_certificate(cert_pem: bytes) → dictVerify and extract peer cert info.
extract_did_from_cert(cert_pem: bytes) → str | NoneExtract DID from certificate SAN.

JWK Functions

FunctionSignatureDescription
to_jwk(identity, include_private?) → dictExport identity as JWK.
from_jwk(jwk: dict) → AgentIdentityImport identity from JWK.
to_jwks(identity, include_private?) → dictExport as JWK Set.
from_jwks(jwks: dict, kid?: str) → AgentIdentityImport from JWK Set.

Layer 2 — Trust (agentmesh.trust)

Trust scoring, protocol bridges, capabilities, and agent cards.

TrustBridge

Manages peer trust relationships and handshake verification.

MethodSignatureDescription
verify_peer(peer_did, protocol?, required_trust_score?, required_capabilities?) → HandshakeResultVerify and establish trust with a peer.
is_peer_trusted(peer_did, required_score?) → boolCheck if a peer is trusted.
get_peer(peer_did: str) → PeerInfo | NoneGet peer information.
get_trusted_peers(min_score?: int) → list[PeerInfo]List trusted peers.
revoke_peer_trust(peer_did, reason) → boolRevoke trust for a peer.

ProtocolBridge

Translates messages between A2A, MCP, and IATP protocols.

MethodSignatureDescription
send_message(peer_did, message, source_protocol, target_protocol?) → AnySend cross-protocol message.
add_verification_footer(content, trust_score, agent_did, metadata?) → strAppend trust verification footer.
get_protocol_for_peer(peer_did: str) → str | NoneGet preferred protocol for a peer.

TrustHandshake

Implements the IATP trust handshake protocol.

MethodSignatureDescription
initiate(peer_did, protocol?, required_trust_score?, required_capabilities?, use_cache?) → HandshakeResultInitiate async handshake.
respond(challenge, my_capabilities, my_trust_score, private_key?, identity?, user_context?) → HandshakeResponseRespond to a challenge.
create_challenge() → HandshakeChallengeCreate a new challenge.
validate_challenge(challenge_id: str) → boolValidate a pending challenge.
clear_cache() → NoneClear handshake result cache.

HandshakeResult

Result of a trust handshake.

MethodSignatureDescription
success(peer_did, trust_score, capabilities, …) → HandshakeResultCreate a successful result.
failure(peer_did, reason, …) → HandshakeResultCreate a failure result.

CapabilityScope / CapabilityGrant

Fine-grained capability management with action:resource:instance format.

MethodSignatureDescription
CapabilityGrant.create(capability, granted_to, granted_by, resource_ids?, expires_at?) → CapabilityGrantCreate a grant.
CapabilityGrant.is_valid() → boolCheck validity.
CapabilityGrant.matches(requested, resource_id?) → boolCheck if grant covers a request.
CapabilityScope.add_grant(grant: CapabilityGrant) → NoneAdd a grant to scope.
CapabilityScope.has_capability(capability, resource_id?) → boolCheck capability in scope.
CapabilityScope.filter_capabilities(requested: list[str]) → list[str]Filter to granted capabilities.
CapabilityScope.revoke_all() → intRevoke all grants.

CapabilityRegistry

Global registry for capability grants across agents.

MethodSignatureDescription
grant(capability, to_agent, from_agent, resource_ids?) → CapabilityGrantGrant a capability.
check(agent_did, capability, resource_id?) → boolCheck if agent has capability.
revoke_all_from(grantor_did: str) → intRevoke all grants from a grantor.

TrustedAgentCard / CardRegistry

Signed agent cards for discovery and verification.

MethodSignatureDescription
TrustedAgentCard.from_identity(identity: AgentIdentity) → TrustedAgentCardCreate card from identity.
TrustedAgentCard.sign(identity: AgentIdentity) → NoneSign the card.
TrustedAgentCard.verify_signature(identity?: AgentIdentity) → boolVerify card signature.
CardRegistry.register(card: TrustedAgentCard) → boolRegister a card.
CardRegistry.get(agent_did: str) → TrustedAgentCard | NoneLook up a card.
CardRegistry.find_by_capability(capability: str) → list[TrustedAgentCard]Find cards by capability.

Layer 3 — Governance (agentmesh.governance)

Policy enforcement, compliance mapping, and tamper-evident audit.

PolicyEngine

Declarative policy engine supporting YAML, JSON, and Rego policies.

MethodSignatureDescription
load_policy(policy: Policy) → NoneLoad a policy into the engine.
load_yaml(yaml_content: str) → PolicyLoad from YAML string.
load_json(json_content: str) → PolicyLoad from JSON string.
load_rego(rego_path?, rego_content?, package?) → OPAEvaluatorLoad OPA Rego policy.
evaluate(agent_did: str, context: dict) → PolicyDecisionEvaluate all policies.
get_policy(name: str) → Policy | NoneGet policy by name.
list_policies() → list[str]List loaded policy names.
remove_policy(name: str) → boolRemove a policy.

Policy / PolicyRule

Individual policy definitions with YAML/JSON serialization.

MethodSignatureDescription
Policy.from_yaml(yaml_content: str) → PolicyParse from YAML.
Policy.from_json(json_content: str) → PolicyParse from JSON.
Policy.applies_to(agent_did: str) → boolCheck if policy applies.
Policy.to_yaml() → strSerialize to YAML.
PolicyRule.evaluate(context: dict) → boolEvaluate a single rule.

ComplianceEngine

Automated compliance mapping for SOC 2, HIPAA, EU AI Act, and NIST.

MethodSignatureDescription
map_action(action_type: str) → ComplianceMapping | NoneMap action to controls.
check_compliance(agent_did, action_type, context) → list[ComplianceViolation]Check for violations.
generate_report(framework, period_start, period_end, agent_ids?) → ComplianceReportGenerate compliance report.
remediate_violation(violation_id, notes) → boolMark violation as remediated.
get_violations(framework?, agent_did?, remediated?) → list[ComplianceViolation]Query violations.

AuditLog / HashChainAuditLog

Tamper-evident audit logging with hash-chain integrity.

MethodSignatureDescription
AuditLog.log(event_type, agent_did, action, resource?, data?, outcome?, …) → AuditEntryLog an audit entry.
AuditLog.query(agent_did?, event_type?, start_time?, end_time?, outcome?, limit?) → list[AuditEntry]Query entries.
AuditLog.verify_integrity() → tuple[bool, str | None]Verify hash chain integrity.
AuditLog.export_cloudevents(start_time?, end_time?) → list[dict]Export as CloudEvents.
HashChainAuditLog.add_entry(entry: AuditEntry) → NoneAdd entry to chain.
HashChainAuditLog.get_proof(entry_id: str) → list[tuple] | NoneGet hash chain proof.
HashChainAuditLog.verify_chain() → tuple[bool, str | None]Verify full chain.

PersistentAuditLog

Async file-backed audit log with hash chain integrity.

MethodSignatureDescription
append(event_type, agent_did, action, …) → AuditEntryAppend entry (async).
load() → intLoad entries from storage (async).
verify_integrity() → tuple[bool, str | None]Verify in-memory chain (async).
verify_against_storage() → tuple[bool, str | None]Verify against persisted data (async).

ShadowMode

Shadow/dry-run policy evaluation for safe policy rollout.

MethodSignatureDescription
start_session(agent_dids?, policy_names?) → ShadowSessionStart a shadow session.
evaluate(action, production_decision?) → ShadowResultEvaluate action in shadow mode.
replay_batch(actions, production_decisions?) → list[ShadowResult]Batch replay.
end_session(session_id?) → ShadowSessionEnd a session.
get_divergence_report(session_id?) → dictGet divergence statistics.
is_ready_for_production(session_id?) → boolCheck if policy is production-ready.

OPAEvaluator

Open Policy Agent (Rego) evaluator.

MethodSignatureDescription
evaluate(query: str, input_data: dict) → OPADecisionEvaluate a Rego query.

TrustPolicy / TrustRule / PolicyEvaluator

Trust-specific policy definitions and evaluation.

MethodSignatureDescription
TrustPolicy.from_yaml(path: str | Path) → TrustPolicyLoad from YAML file.
TrustPolicy.to_yaml(path: str | Path) → NoneSave to YAML file.
TrustCondition.evaluate(context: dict) → boolEvaluate a condition.
PolicyEvaluator.evaluate(context: dict) → TrustPolicyDecisionEvaluate trust policies.
load_policies(directory: str | Path) → list[TrustPolicy]Load all policies from directory.

Enumerations

EnumModuleValues
ComplianceFrameworkgovernance.complianceSOC2, HIPAA, EU_AI_ACT, NIST_AI_RMF
ConditionOperatorgovernance.trust_policyEQUALS, NOT_EQUALS, GREATER_THAN, LESS_THAN, IN, NOT_IN, CONTAINS, MATCHES

Data Models (fields only)

ModelModuleKey Fields
PeerInfotrust.bridgedid, name, protocol, trust_score, capabilities, verified_at
HandshakeChallengetrust.handshakechallenge_id, nonce, timestamp, expires_at, protocol
HandshakeResponsetrust.handshakechallenge_id, responder_did, signature, capabilities, trust_score
PolicyDecisiongovernance.policyallowed, policy_name, matched_rules, reason, timestamp
ComplianceViolationgovernance.complianceviolation_id, framework, control_id, agent_did, severity
ComplianceReportgovernance.complianceframework, period_start, period_end, total_controls, violations
AuditEntrygovernance.auditentry_id, event_type, agent_did, action, resource, outcome, hash
ShadowResultgovernance.shadowaction_id, shadow_decision, production_decision, diverged
OPADecisiongovernance.oparesult, allowed, reason
TrustPolicyDecisiongovernance.policy_evaluatorallowed, trust_score_required, matched_rules
AgentNamespaceidentity.namespacename, description, parent, members, created_at
NamespaceRuleidentity.namespacesource_namespace, target_namespace, allow_communication, allow_delegation
RevocationEntryidentity.revocationagent_did, reason, revoked_by, revoked_at, expires_at
RiskSignalidentity.risksignal_type, severity, source, description
RiskScoreidentity.riskagent_did, overall, identity, behavior, network, compliance
MTLSConfigidentity.mtlscert_path, key_path, ca_path, verify_client