Building Agents
An Assegai agent is essentially a Dockerized Node.js application that uses the @assegailabs/sdk to interact with the world.
Directory Structure
Section titled “Directory Structure”A valid agent requires a specific directory structure:
my-agent/├── assegai.json # The Agent Manifest├── package.json # Standard Node.js dependencies├── index.js # Entry point (your code)└── Dockerfile # (Optional) Custom build instructionsThe Manifest (assegai.json)
Section titled “The Manifest (assegai.json)”This file defines your agent’s identity, permissions, and resource requirements.
{ "name": "DeFi Sniper", "version": "1.0.0", "runtime": "node", "entrypoint": "index.js", "permissions": { "chains": ["eip155:1", "eip155:8453"], "rpcs": { "eip155:1": "https://eth.llamarpc.com", "eip155:8453": "https://mainnet.base.org" }, "apis": ["openai", "anthropic"], "contracts": ["0x..."] }, "resources": { "memory": "512MB", "cpu": "1.0" }, "spending_limits": { "per_transaction": "0.1", "daily": "1.0", "weekly": "5.0", "monthly": "20.0" }}Configuration Fields
Section titled “Configuration Fields”| Field | Description |
|---|---|
runtime | Currently supports node. |
permissions.chains | Array of CAIP-2 chain identifiers the agent can access (e.g., eip155:1 for Ethereum). |
permissions.apis | Array of AI services required (e.g., ["openai", "anthropic"]). |
spending_limits | Limits defined in the native currency (e.g., ETH). |
Agent Code (index.js)
Section titled “Agent Code (index.js)”Your agent must import the SDK to perform sensitive actions.
import { AssegaiSDK } from '@assegailabs/sdk';
const sdk = new AssegaiSDK();
async function start() { await sdk.info('Agent initializing...');
// 1. Get the user's connected wallet address const address = await sdk.getWalletAddress('eip155:1');
// 2. Read data (No approval needed) const balance = await sdk.getBalance('eip155:1', address); await sdk.info(`Balance: ${BigInt(balance)} wei`);
// 3. Execute Action (Triggers User Approval Popup) try { const txHash = await sdk.requestTransaction({ chain: 'eip155:1', to: '0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045', value: '1000000000000000', // Wei data: '0x' }); await sdk.success(`Transaction mined: ${txHash}`); } catch (error) { await sdk.error('Transaction failed or was rejected'); }}
start();Installing Your Agent
Section titled “Installing Your Agent”- Open the Assegai Sandbox App.
- Click “Install Agent”.
- Select the folder containing your
assegai.json. - The Sandbox will build the Docker image locally.
- Click “Start” on the new Agent Card.