TypeScript SDK for secure registration, policy definition, and execution of AI agent intents
npm install @shiunex/sdkGet started with the Shiunex SDK in minutes
import { ShiunexClient } from "@shiunex/sdk";
// Initialize client
const client = new ShiunexClient({
rpcUrl: "https://api.mainnet-beta.solana.com",
wallet: yourWallet
});
// Register a new agent
await client.registerAgent({
agentId: "agent-alpha",
permissions: ["swap", "stake"]
});
// Define execution policy
await client.definePolicy({
agentId: "agent-alpha",
maxValue: 5000,
allowedPrograms: ["JUP", "ORCA"]
});
// Execute agent intent
await client.executeIntent({
agentId: "agent-alpha",
intent: {
type: "swap",
pair: "SOL/USDC",
amount: 100
}
});Core SDK methods and interfaces
Register a new AI agent with permissions
{ agentId: string, permissions: string[] }Promise<{ success: boolean, agentId: string }>Define execution policy for an agent
{ agentId: string, maxValue: number, allowedPrograms: string[] }Promise<{ success: boolean, policyHash: string }>Submit agent intent for execution
{ agentId: string, intent: Intent }Promise<{ success: boolean, txHash: string }>Get current status of an agent
{ agentId: string }Promise<AgentStatus>const result = await client.registerAgent({
agentId: "trading-agent-01",
permissions: ["swap", "stake", "lend"]
});
console.log("Agent registered:", result.agentId);await client.definePolicy({
agentId: "trading-agent-01",
constraints: {
maxValue: 10000,
allowedPrograms: ["JUP", "ORCA", "MARINADE"],
rateLimit: {
maxExecutions: 20,
windowSeconds: 3600
},
timeRestrictions: {
allowedHours: [9, 17] // Trading hours only
}
}
});const execution = await client.executeIntent({
agentId: "trading-agent-01",
intent: {
type: "swap",
params: {
tokenIn: "SOL",
tokenOut: "USDC",
amountIn: 500,
slippage: 0.01,
program: "JUP"
}
}
});
console.log("Transaction hash:", execution.txHash);