Skip to content

Commit 09ea0e9

Browse files
authored
Merge pull request #40 from aporthq/dev
Update test passport IDs
2 parents e9d94b3 + 0565776 commit 09ea0e9

8 files changed

Lines changed: 1605 additions & 11 deletions

File tree

Lines changed: 239 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,239 @@
1+
# APort CLI Tool
2+
3+
A simple command-line tool for testing APort agent verification and passport management. Perfect for developers who want to quickly test APort functionality without building a full integration.
4+
5+
## 🚀 Quick Start
6+
7+
### Prerequisites
8+
9+
- Node.js 18+
10+
- APort API key (optional for verification commands, required for passport management)
11+
12+
### Installation
13+
14+
```bash
15+
# Clone the repository
16+
git clone https://github.com/aporthq/aport-integrations.git
17+
cd aport-integrations/examples/developer-tools/cli
18+
19+
# Install dependencies
20+
npm install
21+
22+
# Optional: Set up environment for passport management
23+
cp env.example .env
24+
# Edit .env with your APort API key (only needed for create-passport, get-passport)
25+
```
26+
27+
### Basic Usage
28+
29+
```bash
30+
# Run the demo (uses sample agent IDs) - NO API KEY NEEDED!
31+
npm start demo
32+
33+
# Interactive verification - NO API KEY NEEDED!
34+
npm start verify -- --interactive
35+
36+
# Direct verification with real agent IDs - NO API KEY NEEDED!
37+
npm start verify ap_a2d10232c6534523812423eec8a1425c payments.refund.v1 '{"amount":50}'
38+
39+
# Or using options
40+
npm start verify -a ap_a2d10232c6534523812423eec8a1425c -p payments.refund.v1 -c '{"amount":50}'
41+
42+
# Get passport information - NO API KEY NEEDED!
43+
npm start get-passport -- --interactive
44+
45+
# Create a new passport (requires API key)
46+
npm start create-passport -- --interactive
47+
```
48+
49+
## 📋 Available Commands
50+
51+
### `verify` - Verify an agent against a policy
52+
53+
```bash
54+
# Interactive mode
55+
aport verify --interactive
56+
57+
# Direct mode (positional arguments)
58+
aport verify agt_inst_refund_bot_123 payments.refund.v1 '{"amount":50}'
59+
60+
# Direct mode (options)
61+
aport verify -a agt_inst_refund_bot_123 -p payments.refund.v1 -c '{"amount":50}'
62+
```
63+
64+
### `policy` - Verify against specific policy pack
65+
66+
```bash
67+
aport policy -a agt_inst_data_exporter_456 -p data.export.v1 -c '{"rows":1000}'
68+
```
69+
70+
### `create-passport` - Create a new agent passport
71+
72+
```bash
73+
# Interactive mode
74+
aport create-passport --interactive
75+
76+
# Default mode (creates test passport)
77+
aport create-passport
78+
```
79+
80+
### `get-passport` - Get passport information
81+
82+
```bash
83+
# Interactive mode (no API key needed!)
84+
aport get-passport --interactive
85+
86+
# Direct mode (no API key needed!)
87+
aport get-passport -a ap_a2d10232c6534523812423eec8a1425c
88+
```
89+
90+
### `demo` - Run complete demo
91+
92+
```bash
93+
aport demo
94+
```
95+
96+
### `help` - Show help and examples
97+
98+
```bash
99+
aport help
100+
```
101+
102+
## 🎯 Sample Agent IDs
103+
104+
The CLI includes pre-configured sample agent IDs for testing:
105+
106+
| Agent | ID | Description |
107+
|-------|----|-----------|
108+
| `refund-bot` | `agt_inst_refund_bot_123` | Handles refund processing |
109+
| `data-exporter` | `agt_inst_data_exporter_456` | Exports data with limits |
110+
| `pr-merger` | `agt_inst_pr_merger_789` | Merges pull requests |
111+
112+
## 📦 Policy Packs
113+
114+
Test against these policy packs:
115+
116+
- `payments.refund.v1` - Refund processing policies
117+
- `data.export.v1` - Data export policies
118+
- `repo.v1` - Repository operation policies
119+
- `admin.access.v1` - Admin access policies
120+
121+
## 🔧 Configuration
122+
123+
### Environment Variables
124+
125+
```bash
126+
# Optional - Only needed for create-passport command
127+
APORT_API_KEY=your_api_key_here
128+
129+
# Optional - Override default API endpoint
130+
APORT_BASE_URL=https://aport.io
131+
```
132+
133+
**Note:** Most commands (`verify`, `policy`, `get-passport`, `demo`) work without an API key! Only `create-passport` requires authentication.
134+
135+
### API Client
136+
137+
The CLI uses a simple API client that handles:
138+
139+
- ✅ Agent verification (`/api/verify`)
140+
- ✅ Policy verification (`/api/verify/policy/{policy}`)
141+
- ✅ Passport creation (`/api/issue`)
142+
- ✅ Passport retrieval (`/api/passports/{id}`)
143+
- ✅ Passport suspension (`/api/suspend`)
144+
- ✅ Policy pack listing (`/api/policies`)
145+
146+
## 🧪 Testing
147+
148+
```bash
149+
# Run tests
150+
npm test
151+
152+
# Run demo
153+
npm start demo
154+
```
155+
156+
## 📝 Examples
157+
158+
### Example 1: Verify Refund Bot
159+
160+
```bash
161+
aport verify -a agt_inst_refund_bot_123 -p payments.refund.v1 -c '{"amount":50,"currency":"USD"}'
162+
```
163+
164+
### Example 2: Create Test Passport
165+
166+
```bash
167+
aport create-passport --interactive
168+
```
169+
170+
### Example 3: Check Data Export Limits
171+
172+
```bash
173+
aport policy -a agt_inst_data_exporter_456 -p data.export.v1 -c '{"rows":5000,"dataset":"users"}'
174+
```
175+
176+
### Example 4: Get Admin Bot Passport
177+
178+
```bash
179+
aport get-passport -a agt_inst_admin_bot_101
180+
```
181+
182+
## 🎨 Features
183+
184+
- **Interactive Mode**: Easy-to-use prompts for all operations
185+
- **Sample Data**: Pre-configured agent IDs for quick testing
186+
- **Error Handling**: Clear error messages and validation
187+
- **Colored Output**: Beautiful terminal output with chalk
188+
- **Spinner**: Loading indicators for API calls
189+
- **Demo Mode**: Complete walkthrough of all features
190+
191+
## 🛠️ Development
192+
193+
### Project Structure
194+
195+
```
196+
src/
197+
├── index.js # CLI commands and interface
198+
├── client.js # APort API client
199+
└── ...
200+
201+
package.json # Dependencies and scripts
202+
env.example # Environment variables template
203+
README.md # This file
204+
```
205+
206+
### Adding New Commands
207+
208+
1. Add command to `program.command()` in `src/index.js`
209+
2. Implement the command logic
210+
3. Add corresponding API method to `src/client.js` if needed
211+
4. Update this README
212+
213+
### API Client Methods
214+
215+
- `verify(policy, agentId, context)` - Verify agent
216+
- `verifyPolicy(policy, agentId, context)` - Verify specific policy
217+
- `createPassport(passportData)` - Create passport
218+
- `getPassport(agentId)` - Get passport
219+
- `suspendPassport(agentId, reason)` - Suspend passport
220+
- `getPolicyPack(policyId)` - Get policy pack
221+
- `listPolicyPacks()` - List all policy packs
222+
223+
## 🤝 Contributing
224+
225+
1. Fork the repository
226+
2. Create a feature branch
227+
3. Make your changes
228+
4. Add tests if applicable
229+
5. Submit a pull request
230+
231+
## 📄 License
232+
233+
MIT
234+
235+
---
236+
237+
**🛡️ Secure your AI agents. Trust but verify.**
238+
239+
Made with ❤️ by the APort community

0 commit comments

Comments
 (0)