@aegis-ai/sdk
v0.1.0
Published
TypeScript SDK for the Aegis node API — structured intents for autonomous agents on Solana
Maintainers
Readme
@aegis-ai/sdk
TypeScript SDK for the Aegis node API. Send structured intents to autonomous Solana agents — transfers, swaps, staking, lending, flash loans, and raw CPI calls — with full type safety and no raw fetch calls.
install
npm install @aegis-ai/sdkquick start
import { AegisClient, transfer, swap, stake } from "@aegis-ai/sdk";
const client = new AegisClient({
baseUrl: "https://aegis-ycdm.onrender.com",
apiKey: "your-api-key",
});
// create an agent
const { agentId, apiKey } = await client.createAgent({
policy: { maxTxAmountSOL: 0.5, dailySpendLimitSOL: 2 },
});
// fund it on devnet
await client.airdrop(agentId, 2);
// execute intents
await client.execute(agentId, transfer({ to: "<address>", amount: 0.1 }), "rebalancing");
await client.execute(agentId, swap({ fromMint: "SOL", toMint: "USDC", amount: 0.5 }), "spread detected");
await client.execute(agentId, stake({ amount: 1, voteAccount: "<vote_account>" }), "earning yield");
// read state
const agent = await client.getAgent(agentId); // reputationScore, lastActivityAt, policy
const balance = await client.getBalance(agentId);
const txs = await client.getTransactions(agentId, 20);
// pause the agent
await client.updateStatus(agentId, "paused");intent types
| intent | params |
|---|---|
| transfer | to, amount, mint? (default SOL), decimals? (default 6) |
| swap | fromMint, toMint, amount, slippageBps? (default 50) |
| stake | amount, voteAccount |
| lend | protocol (marginfi|solend), mint, amount, decimals? |
| flash | mint, amount, instructions[] |
| cpi | programId, data (base64), accounts[] |
client methods
client.health()
client.createAgent(options?)
client.getAgents()
client.getAgent(agentId)
client.updateStatus(agentId, "active" | "paused" | "suspended")
client.getBalance(agentId)
client.getTransactions(agentId, limit?)
client.airdrop(agentId, amount?)
client.execute(agentId, intent, reasoning?)error handling
policy violations throw AegisError with a typed violations array:
import { AegisError } from "@aegis-ai/sdk";
try {
await client.execute(agentId, transfer({ to: "...", amount: 999 }));
} catch (e) {
if (e instanceof AegisError) {
console.log(e.status); // 403
console.log(e.violations); // [{ code: "AMOUNT_EXCEEDS_TX_CAP", message: "..." }]
}
}policy
agents enforce policy on every intent before touching the chain:
await client.createAgent({
policy: {
allowedIntents: ["transfer", "swap"],
allowedMints: ["SOL", "USDC"],
maxTxAmountSOL: 1,
dailySpendLimitSOL: 5,
maxSlippageBps: 100,
requireSimulation: true,
cooldownMs: 5000,
maxRiskScore: 50,
},
});license
MIT
