guardmesh-cli
v1.1.0
Published
CLI framework for building governed AI agents on 0G with GuardMesh
Maintainers
Readme
GuardMesh CLI
CLI framework for building governed AI agents on 0G with GuardMesh
GuardMesh CLI is a developer tool for creating, testing, and deploying AI agents with built-in governance, TEE-verified decisions, and immutable audit trails on the 0G network.
Features
- 🚀 Quick Start: Initialize agent projects with templates
- 🔐 Policy Management: Define and enforce agent permissions
- 🧪 Testing Framework: Test actions against guardian mesh before deployment
- 📊 Audit Trail: Query and verify decisions on 0G Storage
- 🌐 Guardian Management: Monitor and manage guardian nodes
- 🛠️ Developer-Friendly: Simple CLI commands for complex operations
Installation
npm install -g @guardmesh/cliOr use directly with npx:
npx @guardmesh/cli init my-agentQuick Start
1. Initialize a New Agent
guardmesh init my-agent --template code-analyzer
cd my-agent
npm install2. Configure Environment
cp .env.example .env
# Edit .env with your configuration3. Configure GuardMesh
guardmesh config --rpc https://evmrpc-testnet.0g.ai
guardmesh config --registry 0xYourRegistryAddress
guardmesh config --audit 0xYourAuditAddress4. Register Your Agent
guardmesh agent register \
-i my-agent-01 \
-r code_analysis_only \
-a "read_file,code_analysis" \
-d "write_file,change_permissions"5. Test Actions
guardmesh test action \
-a my-agent-01 \
--action read_file \
--target auth.py6. Deploy
guardmesh deploy --config agent.yamlCommands
guardmesh init
Initialize a new agent project with templates.
guardmesh init [name] [options]
Options:
-t, --template <type> Agent template (code-analyzer, data-bot, custom)
-d, --dir <path> Target directoryguardmesh agent
Manage agents and policies.
# Register a new agent
guardmesh agent register -i <agentId> -r <role> [-a <allowed>] [-d <denied>]
# List all agents
guardmesh agent list
# Get agent details
guardmesh agent info <agentId>guardmesh test
Test agent actions against guardians.
# Test a single action
guardmesh test action -a <agentId> --action <type> --target <resource>
# Test policy configuration
guardmesh test policy -a <agentId>guardmesh deploy
Deploy agent with governance.
guardmesh deploy [options]
Options:
-c, --config <path> Agent config file (default: agent.yaml)
--dry-run Simulate deploymentguardmesh audit
Query audit trail and decisions.
# Watch live audit feed
guardmesh audit watch [-a <agentId>] [-o <outcome>]
# Query audit history
guardmesh audit history [-a <agentId>] [-l <limit>]
# Verify decision on 0G Storage
guardmesh audit verify <merkleRoot>guardmesh guardians
Manage guardian nodes.
# Show guardian status
guardmesh guardians status
# Add a guardian
guardmesh guardians add -p <pubkey> -e <ens> [--endpoint <url>]
# Remove a guardian
guardmesh guardians remove <pubkey>guardmesh config
Configure GuardMesh CLI.
guardmesh config [options]
Options:
--rpc <url> Set RPC endpoint
--registry <address> Set registry contract address
--audit <address> Set audit contract address
--show Show current configurationAgent Templates
Code Analyzer
An agent restricted to code analysis tasks.
guardmesh init my-analyzer --template code-analyzerAllowed: read_file, code_analysis, query_db
Denied: write_file, change_permissions, forum_post
Data Bot
An agent for read-only analytics.
guardmesh init my-databot --template data-botAllowed: query_db, read_file
Denied: change_permissions, export_pii, write_file
Custom
A blank template for custom agents.
guardmesh init my-agent --template customArchitecture
GuardMesh CLI integrates with:
- GuardMesh Registry: On-chain agent policy management
- GuardMesh Audit: Immutable decision log
- AXL Mesh: P2P guardian communication layer
- 0G Storage: Decentralized audit trail storage
- 0G Compute: TEE-verified guardian inference
┌─────────────┐
│ Your │
│ Agent │
└──────┬──────┘
│ Intent
▼
┌─────────────────────────────────┐
│ Guardian Mesh (AXL) │
│ ┌─────┐ ┌─────┐ ┌─────┐ │
│ │ G1 │ │ G2 │ │ G3 │ │ ◄── TEE Inference (0G Compute)
│ └─────┘ └─────┘ └─────┘ │
└──────┬──────────────────────────┘
│ Consensus
▼
┌─────────────────────────────────┐
│ GuardMesh Contracts │
│ • Registry (Policy) │
│ • Audit (Decisions) │
└──────┬──────────────────────────┘
│ Merkle Root
▼
┌─────────────────────────────────┐
│ 0G Storage │
│ • Intent Bundle │
│ • Guardian Verdicts │
│ • Verification Proof │
└─────────────────────────────────┘Configuration
GuardMesh CLI uses two configuration sources:
- Local
.env(project-specific) - Global config (
~/.guardmesh/config.json)
Local configuration takes precedence.
Environment Variables
# Agent Configuration
AGENT_ID=my-agent-01
GUARDIAN_ENDPOINT=http://127.0.0.1:9002
# Blockchain Configuration
RPC_URL=https://evmrpc-testnet.0g.ai
REGISTRY_ADDRESS=0x...
AUDIT_ADDRESS=0x...
# Optional: Private key for signing
PRIVATE_KEY=0x...Examples
Example 1: Code Review Agent
# Initialize
guardmesh init code-reviewer --template code-analyzer
# Register
guardmesh agent register \
-i code-reviewer-01 \
-r code_analysis_only \
-a "read_file,code_analysis"
# Test
guardmesh test action \
-a code-reviewer-01 \
--action read_file \
--target src/auth.ts
# Deploy
guardmesh deployExample 2: Analytics Bot
# Initialize
guardmesh init analytics-bot --template data-bot
# Register with strict permissions
guardmesh agent register \
-i analytics-bot-01 \
-r analytics_readonly \
-a "query_db" \
-d "change_permissions,export_pii"
# Test policy
guardmesh test policy -a analytics-bot-01
# Watch audit feed
guardmesh audit watch -a analytics-bot-01Development
Build from source:
git clone https://github.com/yourusername/guardmesh-cli
cd guardmesh-cli
npm install
npm run build
npm linkContributing
Contributions welcome! Please read our Contributing Guide.
License
MIT
Links
Built with ❤️ for the 0G Hackathon - Best Agent Framework Track
