@polkadot-agent-kit/cli
v2.1.5
Published
CLI for Polkadot Agent Kit - AI Agent Management
Downloads
210
Readme
Installation
Global Installation
npm install -g @polkadot-agent-kit/cliLocal Development
# Clone the repository
git clone https://github.com/elasticlabs-org/polkadot-agent-kit.git
cd polkadot-agent-kit
# Install dependencies
pnpm install
# Build the CLI
pnpm build
# Link for local development
cd packages/cli
npm linkQuick Start
1. Create Your First Agent
pak agent create my-agent --interactive2. Chat with Your Agent
pak agent chat my-agentCommands
Configuration Management
pak config
Manage CLI configuration.
Subcommands:
get [key]- Get configuration valueset <key> <value>- Set configuration valuelist- List all configuration valuesreset- Reset configuration to defaultsvalidate- Validate current configurationedit- Interactive configuration editorexport <file>- Export configuration to fileimport <file>- Import configuration from filepaths- Show configuration file paths
Examples:
pak config get llm.defaultProvider
pak config set llm.defaultProvider ollama
pak config list --format json
pak config edit --global
pak config validateAgent Management
pak agent create <name>
Create a new AI agent.
Options:
-p, --provider <provider>- LLM provider (ollama, openai)-m, --model <model>- LLM model name-t, --tools <tools>- Comma-separated list of tools-d, --description <description>- Agent description-i, --interactive- Interactive setup
Examples:
pak agent create trading-bot --provider openai --model gpt-4
pak agent create staking-helper --tools balance,staking,xcm
pak agent create my-agent --interactivepak agent list
List all AI agents.
Options:
-p, --provider <provider>- Filter by provider-f, --format <format>- Output format (table, json)--filter <filter>- Filter agents by name pattern
Examples:
pak agent list
pak agent list --provider ollama
pak agent list --format json
pak agent list --filter tradingpak agent chat <name>
Start an interactive chat session with an agent.
Options:
--history- Show chat history--save- Save chat history (default: true)--timeout <timeout>- Request timeout in seconds
Examples:
pak agent chat my-agent
pak agent chat trading-bot --historypak agent run <name> <command>
Execute a command with an agent.
Options:
-f, --format <format>- Output format (json, table, raw)-t, --timeout <timeout>- Request timeout in seconds-v, --verbose- Verbose output
Examples:
pak agent run my-agent "check my DOT balance"
pak agent run trading-bot "swap 10 DOT for USDC" --format json
pak agent run staking-helper "show my staking rewards" --verbosepak agent delete <name>
Delete an AI agent.
Options:
-y, --yes- Skip confirmation
Examples:
pak agent delete old-agent
pak agent delete temp-agent --yespak agent model
Manage agent model settings.
Subcommands:
set <name> <provider> [model]- Set the model for an agentget <name>- Get the current model for an agentlist <provider>- List available models for a provider
Examples:
pak agent model set my-agent ollama llama2
pak agent model get my-agent
pak agent model list openaiDocumentation
pak docs
Open Polkadot Agent Kit documentation.
Options:
-s, --section <section>- Open specific documentation section
Examples:
pak docs
pak docs --section getting-started
pak docs --section apiConfiguration
The CLI uses a hierarchical configuration system:
- Global Configuration (
~/.pak/config.json) - Project Configuration (
./pak.config.json)
Configuration Structure
{
"version": "1.0.0",
"llm": {
"defaultProvider": "ollama",
"ollama": {
"baseUrl": "http://localhost:11434",
"defaultModel": "llama2",
"timeout": 30000
},
"openai": {
"defaultModel": "gpt-3.5-turbo",
"timeout": 30000
}
},
"agents": {
"defaultTools": ["balance", "transfer", "xcm"],
"storageLocation": "~/.pak/agents",
"maxHistory": 100
},
"ui": {
"colorOutput": true,
"verboseLogging": false,
"progressIndicators": true,
"theme": "auto"
},
"polkadot": {
"defaultChain": "polkadot",
"rpcEndpoints": {
"polkadot": "wss://rpc.polkadot.io",
"kusama": "wss://kusama-rpc.polkadot.io"
}
}
}Available Tools
Agents can be equipped with various tools:
- balance - Check token balances on various chains
- transfer - Transfer tokens between accounts
- xcm - Cross-chain transfers using XCM
- staking - Staking operations (nominate, bond, unbond)
- swap - Token swapping via DEX protocols
LLM Providers
Ollama (Local)
- Install Ollama: https://ollama.ai/
- Pull a model:
ollama pull qwen3:latest - Configure the CLI:
pak config set llm.defaultProvider ollama pak config set llm.ollama.baseUrl http://localhost:11434
OpenAI (Cloud)
- Get an API key from OpenAI
- Configure the CLI:
pak config set llm.defaultProvider openai pak config set llm.openai.apiKey your-api-key
Examples
Trading Bot Example
# Create a trading-focused agent
pak agent create trading-bot \
--provider openai \
--model gpt-4 \
--tools balance,transfer,swap,xcm \
--description "AI trading assistant for DeFi operations"
# Chat with the trading bot
pak agent chat trading-bot
# Execute trading commands
pak agent run trading-bot "What's my DOT balance?"
pak agent run trading-bot "Swap 10 DOT for USDC on HydraDX"Troubleshooting
Common Issues
Command not found: pak
# Make sure the CLI is installed globally npm install -g @polkadot-agent-kit/cli # Or use npx npx @polkadot-agent-kit/cli --helpOllama connection failed
# Check if Ollama is running curl http://localhost:11434/api/tags # Update the base URL if needed pak config set llm.ollama.baseUrl http://localhost:11434OpenAI API errors
# Verify your API key pak config get llm.openai.apiKey # Set a new API key pak config set llm.openai.apiKey your-new-api-keyAgent not found
# List all agents pak agent list # Check agents storage location pak config get agents.storageLocation
Debug Mode
Enable verbose logging for debugging:
pak --verbose agent chat my-agent
pak config set ui.verboseLogging trueDevelopment
Building from Source
# Clone the repository
git clone https://github.com/elasticlabs-org/polkadot-agent-kit.git
cd polkadot-agent-kit
# Install dependencies
pnpm install
# Build the CLI package
pnpm build --filter @polkadot-agent-kit/cli
### Contributing
1. Fork the repository
2. Create a feature branch
3. Make your changes
4. Add tests
5. Submit a pull request
## License
MIT License - see [LICENSE](../../LICENSE) for details.
## Support
- [GitHub Issues](https://github.com/elasticlabs-org/polkadot-agent-kit/issues)
- [Documentation](https://github.com/elasticlabs-org/polkadot-agent-kit)
- [Discord Community](https://discord.gg/polkadot)