Expand description
§Loop Agent SDK
Trustless agent infrastructure for the Loop Protocol.
§Architecture
┌─────────────────────────────────────────────────────────┐
│ LOOP AGENT SDK │
├─────────────────┬─────────────────┬─────────────────────┤
│ STATE │ ACTION │ PERCEPTION │
│ │ │ │
│ context_fetch │ capture_value │ on_transaction │
│ context_push │ stake_cred │ on_location_hit │
│ agent_memory │ claim_yield │ on_proof_submitted │
│ │ optimize_yield │ on_position_unlock │
└─────────────────┴─────────────────┴─────────────────────┘§Security Model
- Intent-Based Execution: Agents request actions, smart contracts execute
- Session Keys: Scoped permissions with TTL (read/capture/stake)
- Trustless Distribution: 80/14/6 split enforced by contract, not agent
- No Key Access: Agents never hold private keys or move funds directly
§MCP Compliance
This SDK is designed to be MCP (Model Context Protocol) compliant.
See mcp/loop-vault-manifest.json for the tool/resource definitions
that allow any MCP-compatible AI to interact with Loop vaults.
§Quick Start
ⓘ
use loop_agent_sdk::{
action::{VaultAction, SessionKey, ZkProof},
perception::{PerceptionEvent, PerceptionHandler},
state::{StateStore, UserContext},
};
// In your Lambda handler:
async fn handler(event: PerceptionEvent) -> Result<(), Error> {
// 1. Load user context (<100ms)
let ctx = state_store.context_fetch(&event.user_pubkey())?;
// 2. Get session key for this user
let session = get_session_key(&ctx.pubkey).await?;
// 3. Execute action based on event
match event {
PerceptionEvent::TransactionDetected(tx) => {
let proof = build_proof_from_pos(&tx)?;
let result = vault.capture_value(&session, tx.merchant_id, proof)?;
// 4. Update context
state_store.push_event(&ctx.pubkey, ContextEvent {
event_type: "capture".into(),
amount: Some(result.cred_minted),
..
})?;
}
// ... handle other events
}
Ok(())
}Re-exports§
pub use action::VaultAction;pub use action::SessionKey;pub use action::PermissionScope;pub use action::ZkProof;pub use action::ProofType;pub use action::CaptureResult;pub use action::StakingPosition;pub use action::YieldRecommendation;pub use action::ActionError;pub use action::DISTRIBUTION;pub use action::YIELD_RATES_BPS;pub use perception::PerceptionEvent;pub use perception::PerceptionHandler;pub use perception::PerceptionError;pub use perception::TransactionEvent;pub use perception::LocationEvent;pub use perception::ProofEvent;pub use perception::UnlockEvent;pub use perception::Processor;pub use perception::GeoEventType;pub use state::StateStore;pub use state::StateError;pub use state::UserContext;pub use state::VaultState;pub use state::UserPreferences;pub use state::ContextEvent;pub use state::init_user_context;pub use vault_action::SolanaVaultAction;pub use dynamo::DynamoStateStore;pub use dynamo::DynamoConfig;pub use dynamo::CardMapping;pub use dynamo::PendingCapture;pub use dynamo::SessionKeyData;pub use dynamo::create_table;pub use privacy::PrivacyLayer;pub use privacy::PrivacyConfig;pub use privacy::LoopFingerprint;pub use privacy::PrivacyError;pub use privacy::generate_pepper;pub use privacy::create_pepper_secret;pub use webhook::WebhookHandler;pub use webhook::WebhookSecrets;pub use webhook::FidelSecrets;pub use webhook::WebhookContext;pub use webhook::WebhookSource;pub use webhook::WebhookError;pub use webhook::NormalizedTransaction;pub use webhook::TransactionType;pub use webhook::verify_fidel_signature;pub use webhook::verify_square_signature;pub use webhook::verify_stripe_signature;pub use webhook::parse_fidel_webhook;pub use webhook::parse_square_webhook;pub use notifications::NotificationService;pub use notifications::NotificationConfig;pub use notifications::NotificationError;pub use notifications::PushNotification;pub use notifications::NotificationData;pub use notifications::NotificationPriority;pub use notifications::NotificationResult;pub use supabase::SupabaseClient;pub use supabase::SupabaseConfig;pub use supabase::SupabaseAttestation;pub use supabase::SupabaseReputationScore;pub use constants::Network;pub use constants::ProgramIds;pub use constants::TokenMints;pub use constants::MainnetState;pub use constants::CaptureType;pub use constants::PermissionLevel;pub use constants::EscrowStatus;pub use constants::AgentType;pub use constants::AgentStatus;pub use constants::CRED_DECIMALS;pub use constants::OXO_DECIMALS;pub use constants::LAMPORTS_PER_CRED;pub use constants::LAMPORTS_PER_OXO;pub use constants::USER_SHARE_BPS;pub use constants::TREASURY_SHARE_BPS;pub use constants::STAKER_SHARE_BPS;pub use constants::STAKING_APY;pub use constants::MIN_STAKE_DAYS;pub use constants::MAX_STAKE_DAYS;pub use constants::rpc_endpoint;pub use constants::DEVNET_RPC;pub use constants::MAINNET_RPC;pub use constants::STAKE_30D_APY_BPS;pub use constants::STAKE_90D_APY_BPS;pub use constants::STAKE_180D_APY_BPS;pub use constants::STAKE_365D_APY_BPS;pub use constants::SESSION_KEY_TTL_HOURS;pub use constants::SESSION_KEY_MAX_ACTIONS;pub use constants::CONTEXT_RELOAD_TARGET_MS;pub use reputation_engine::ReputationEngine;pub use reputation_engine::TrustScore;pub use reputation_engine::TrustTier;pub use reputation_engine::CaptureLayer;pub use reputation_engine::LayerGroup;pub use reputation_engine::Attestation;pub use reputation_engine::AttestationRecord;pub use reputation_engine::AttestationMetadata;pub use reputation_engine::VaultAttestation;pub use reputation_engine::VaultAction as VaultAttestAction;pub use reputation_engine::ReputationDimension;pub use reputation_engine::ReputationResponse;pub use reputation_engine::ReputationCapabilities;pub use reputation_engine::LayerActivity;pub use reputation_engine::ProfessionalAttestation;pub use reputation_engine::CredentialCategory;pub use reputation_engine::DifficultyTier;pub use reputation_engine::VerificationLevel;pub use reputation_engine::SWARM_COORDINATOR_THRESHOLD;pub use reputation_engine::COLLATERAL_THRESHOLD;pub use reputation_engine::MAX_SCORE;pub use gateway::Gateway;pub use gateway::GatewayError;pub use gateway::A2ARequest;pub use gateway::A2AResponse;pub use gateway::SwarmAction;pub use gateway::PermissionCheck;pub use aws_lambda_runtime as lambda_runtime;
Modules§
- action
- Loop Agent SDK - Action Interface
- constants
- Loop Protocol Constants
- dynamo
- Loop Agent SDK - DynamoDB State Store Implementation
- gateway
- A2A Gateway - Agent-to-Agent Communication Gateway
- notifications
- Loop Agent SDK - Push Notifications
- perception
- Loop Agent SDK - Perception Interface
- privacy
- Loop Agent SDK - Privacy Layer
- reputation_
engine - Reputation Engine for Loop Protocol
- state
- Loop Agent SDK - State Interface
- supabase
- Supabase Integration for Reputation Engine
- utils
- Utility functions
- vault_
action - Loop Agent SDK - Vault Action Implementation
- webhook
- Loop Agent SDK - Webhook Handler
Constants§
- VERSION
- SDK version