@itzannetos/x402-tools 1.0.0 → 1.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.opencode/plugins/x402-tools.ts +22 -6
- package/README.md +271 -31
- package/package.json +8 -1
|
@@ -69,9 +69,17 @@ export const X402ToolsPlugin: Plugin = async () => {
|
|
|
69
69
|
const privateKey = await getPrivateKey()
|
|
70
70
|
const client = createPaymentClient(privateKey)
|
|
71
71
|
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
72
|
+
let response
|
|
73
|
+
try {
|
|
74
|
+
response = await client.post(X_SEARCHER_PATH, {
|
|
75
|
+
message: args.query,
|
|
76
|
+
})
|
|
77
|
+
} catch (error) {
|
|
78
|
+
if (axios.isAxiosError(error) && error.response?.status === 402) {
|
|
79
|
+
throw new Error("Not enough USDC in your wallet, please top up")
|
|
80
|
+
}
|
|
81
|
+
throw error
|
|
82
|
+
}
|
|
75
83
|
|
|
76
84
|
if (!response.data?.data?.response) {
|
|
77
85
|
throw new Error("Unexpected response from X Searcher")
|
|
@@ -90,9 +98,17 @@ export const X402ToolsPlugin: Plugin = async () => {
|
|
|
90
98
|
const privateKey = await getPrivateKey()
|
|
91
99
|
const client = createPaymentClient(privateKey)
|
|
92
100
|
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
101
|
+
let response
|
|
102
|
+
try {
|
|
103
|
+
response = await client.post(FIND_PEOPLE_PATH, {
|
|
104
|
+
message: args.query,
|
|
105
|
+
})
|
|
106
|
+
} catch (error) {
|
|
107
|
+
if (axios.isAxiosError(error) && error.response?.status === 402) {
|
|
108
|
+
throw new Error("Not enough USDC in your wallet, please top up")
|
|
109
|
+
}
|
|
110
|
+
throw error
|
|
111
|
+
}
|
|
96
112
|
|
|
97
113
|
if (!response.data?.data?.response) {
|
|
98
114
|
throw new Error("Unexpected response from Find People")
|
package/README.md
CHANGED
|
@@ -1,15 +1,77 @@
|
|
|
1
|
-
#
|
|
1
|
+
# X402 Tools Plugin
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Developed and managed by [402box.io](https://402box.io) | Contact: george@402box.io
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
An OpenCode AI plugin that provides payment-gated AI tools via the X402 payment protocol. This plugin enables real-time access to specialized AI agents for Twitter/X search and OSINT (Open Source Intelligence) research, with payments handled automatically through blockchain microtransactions.
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
- `find_people` - OSINT agent for researching individuals and professional entities.
|
|
7
|
+
## Overview
|
|
9
8
|
|
|
10
|
-
|
|
9
|
+
X402 Tools integrates premium AI capabilities into OpenCode through a pay-per-use model. Each tool invocation triggers a micropayment on the Base blockchain, enabling access to advanced AI services without requiring subscriptions or API keys for the underlying services.
|
|
11
10
|
|
|
12
|
-
|
|
11
|
+
### What is X402?
|
|
12
|
+
|
|
13
|
+
X402 is a payment protocol that enables micropayments for API calls using blockchain technology. When you use this plugin, each API request is automatically paid for using your Ethereum wallet on the Base network. This allows service providers to monetize their AI tools on a per-request basis.
|
|
14
|
+
|
|
15
|
+
## Available Tools
|
|
16
|
+
|
|
17
|
+
### 🔍 `x_searcher`
|
|
18
|
+
|
|
19
|
+
**Price: 0.05 USDC per request**
|
|
20
|
+
|
|
21
|
+
AI-powered X/Twitter search agent that provides real-time trends, news, and social media insights.
|
|
22
|
+
|
|
23
|
+
**Use cases:**
|
|
24
|
+
- Monitor trending topics and conversations
|
|
25
|
+
- Research public sentiment on specific topics
|
|
26
|
+
- Track breaking news and viral content
|
|
27
|
+
- Analyze social media discussions
|
|
28
|
+
- Discover influencer opinions and threads
|
|
29
|
+
|
|
30
|
+
**Example queries:**
|
|
31
|
+
- "Latest discussions about AI regulation"
|
|
32
|
+
- "Trending topics in cryptocurrency today"
|
|
33
|
+
- "What are people saying about the new iPhone?"
|
|
34
|
+
|
|
35
|
+
### 👤 `find_people`
|
|
36
|
+
|
|
37
|
+
**Price: 0.15 USDC per request**
|
|
38
|
+
|
|
39
|
+
Real-time Open Source Intelligence (OSINT) agent specialized in researching individuals and professional entities.
|
|
40
|
+
|
|
41
|
+
**What it does:**
|
|
42
|
+
- Identifies people by name, role, or company affiliation
|
|
43
|
+
- Retrieves verified career timelines and professional backgrounds
|
|
44
|
+
- Finds similar professionals in any industry or domain
|
|
45
|
+
- Synthesizes biographical information with source citations
|
|
46
|
+
- Validates identities across LinkedIn, company sites, and public records
|
|
47
|
+
|
|
48
|
+
**Best for:**
|
|
49
|
+
- Due diligence research on potential hires or partners
|
|
50
|
+
- Competitive intelligence on industry leaders
|
|
51
|
+
- Journalist & researcher background verification
|
|
52
|
+
- Sales prospecting and lead enrichment
|
|
53
|
+
- Investor research on startup founders and executives
|
|
54
|
+
|
|
55
|
+
**Powered by:**
|
|
56
|
+
Neural and deep search capabilities that go beyond standard search engines to find hard-to-reach biographical details, executive profiles, and professional networks.
|
|
57
|
+
|
|
58
|
+
**Output format:**
|
|
59
|
+
Returns structured summaries with key details (career, education, notable works) and numbered source citations for verification.
|
|
60
|
+
|
|
61
|
+
## Prerequisites
|
|
62
|
+
|
|
63
|
+
Before installing this plugin, ensure you have:
|
|
64
|
+
|
|
65
|
+
1. **OpenCode** - The AI coding assistant (https://opencode.ai)
|
|
66
|
+
2. **Bun** - JavaScript runtime (https://bun.sh) - Required for local plugin development
|
|
67
|
+
3. **Ethereum Wallet** - A private key with funds on the Base network
|
|
68
|
+
4. **Base Network ETH** - Small amount of USDC on Base for payment transactions (NO gas needed)
|
|
69
|
+
|
|
70
|
+
## Installation
|
|
71
|
+
|
|
72
|
+
### Option 1: Install from npm (Recommended)
|
|
73
|
+
|
|
74
|
+
1. Add the plugin to your `opencode.json` configuration file:
|
|
13
75
|
|
|
14
76
|
```json
|
|
15
77
|
{
|
|
@@ -18,7 +80,7 @@ Local OpenCode plugin that provides payment-gated tools via X402.
|
|
|
18
80
|
}
|
|
19
81
|
```
|
|
20
82
|
|
|
21
|
-
2. Create `.opencode/x402-tools.json` with your key:
|
|
83
|
+
2. Create a configuration file at `.opencode/x402-tools.json` with your private key:
|
|
22
84
|
|
|
23
85
|
```json
|
|
24
86
|
{
|
|
@@ -26,25 +88,26 @@ Local OpenCode plugin that provides payment-gated tools via X402.
|
|
|
26
88
|
}
|
|
27
89
|
```
|
|
28
90
|
|
|
29
|
-
|
|
91
|
+
**OR** set it in `.env` at the project root (necessary on Windows):
|
|
30
92
|
|
|
31
|
-
```
|
|
93
|
+
```env
|
|
32
94
|
X402_PRIVATE_KEY=0x...
|
|
33
95
|
```
|
|
34
96
|
|
|
35
|
-
|
|
97
|
+
3. Restart OpenCode to load the plugin.
|
|
98
|
+
|
|
99
|
+
### Option 2: Local Development Installation
|
|
36
100
|
|
|
37
|
-
|
|
101
|
+
1. Clone or download this repository
|
|
38
102
|
|
|
39
|
-
1. Ensure Bun is installed.
|
|
40
103
|
2. Install dependencies for local plugins:
|
|
41
104
|
|
|
42
105
|
```bash
|
|
43
|
-
cd
|
|
106
|
+
cd .opencode
|
|
44
107
|
bun install
|
|
45
108
|
```
|
|
46
109
|
|
|
47
|
-
3. Create `.opencode/x402-tools.json` with your key:
|
|
110
|
+
3. Create `.opencode/x402-tools.json` with your private key:
|
|
48
111
|
|
|
49
112
|
```json
|
|
50
113
|
{
|
|
@@ -52,42 +115,219 @@ bun install
|
|
|
52
115
|
}
|
|
53
116
|
```
|
|
54
117
|
|
|
55
|
-
|
|
118
|
+
**OR** set it in `.env` at the project root (necessary on Windows):
|
|
56
119
|
|
|
57
|
-
```
|
|
120
|
+
```env
|
|
58
121
|
X402_PRIVATE_KEY=0x...
|
|
59
122
|
```
|
|
60
123
|
|
|
61
|
-
|
|
124
|
+
4. Restart OpenCode so the plugin is loaded from `.opencode/plugins/x402-tools.ts`
|
|
125
|
+
|
|
126
|
+
## Configuration
|
|
127
|
+
|
|
128
|
+
### Private Key Setup
|
|
129
|
+
|
|
130
|
+
The plugin needs your Ethereum private key to sign payment transactions. The key is read in this order:
|
|
131
|
+
|
|
132
|
+
1. **First**: `.opencode/x402-tools.json` file (preferred, keeps config local)
|
|
133
|
+
2. **Fallback**: `X402_PRIVATE_KEY` environment variable in `.env` file
|
|
134
|
+
|
|
135
|
+
**Security Notes:**
|
|
136
|
+
- Never commit your private key to version control
|
|
137
|
+
- The `.gitignore` is configured to exclude `.opencode/x402-tools.json` and `.env`
|
|
138
|
+
- Only use wallets with small amounts of ETH for testing
|
|
139
|
+
- The private key must be for the Base network
|
|
140
|
+
|
|
141
|
+
### Configuration File Format
|
|
142
|
+
|
|
143
|
+
`.opencode/x402-tools.json`:
|
|
144
|
+
```json
|
|
145
|
+
{
|
|
146
|
+
"private_key": "0x1234567890abcdef..."
|
|
147
|
+
}
|
|
148
|
+
```
|
|
149
|
+
|
|
150
|
+
The `0x` prefix is optional - the plugin will add it automatically if missing.
|
|
62
151
|
|
|
63
152
|
## Usage
|
|
64
153
|
|
|
65
|
-
|
|
154
|
+
Once installed, you can invoke the tools directly in OpenCode conversations:
|
|
155
|
+
|
|
156
|
+
### Using X Searcher
|
|
66
157
|
|
|
67
158
|
```
|
|
68
|
-
Use the x_searcher tool to search for "AI breakthroughs in 2026"
|
|
159
|
+
Use the x_searcher tool to search for "AI breakthroughs in 2026"
|
|
69
160
|
```
|
|
70
161
|
|
|
71
162
|
```
|
|
72
|
-
|
|
163
|
+
Search X for discussions about "climate change policy"
|
|
164
|
+
```
|
|
165
|
+
|
|
166
|
+
### Using Find People
|
|
167
|
+
|
|
73
168
|
```
|
|
169
|
+
Use the find_people tool to research "Jane Doe, head of AI at ExampleCorp"
|
|
170
|
+
```
|
|
171
|
+
|
|
172
|
+
```
|
|
173
|
+
Find information about "Elon Musk, CEO of Tesla"
|
|
174
|
+
```
|
|
175
|
+
|
|
176
|
+
The AI will automatically use the appropriate tool, handle the payment, and return the results.
|
|
74
177
|
|
|
75
|
-
##
|
|
178
|
+
## How It Works
|
|
76
179
|
|
|
77
|
-
|
|
180
|
+
### Architecture
|
|
78
181
|
|
|
79
182
|
```
|
|
80
|
-
|
|
183
|
+
OpenCode → Plugin → X402 Payment Client → AI Service API
|
|
184
|
+
↓
|
|
185
|
+
Wallet (Base Chain)
|
|
81
186
|
```
|
|
82
187
|
|
|
188
|
+
1. **Plugin Registration**: When OpenCode starts, it loads the plugin and registers the tools
|
|
189
|
+
2. **Tool Invocation**: When you request a tool, OpenCode calls the plugin's execute function
|
|
190
|
+
3. **Private Key Loading**: The plugin reads your private key from config or environment
|
|
191
|
+
4. **Payment Client Setup**: Creates a wallet client using viem on the Base blockchain
|
|
192
|
+
5. **Payment Interceptor**: x402-axios wraps Axios to handle payment headers automatically
|
|
193
|
+
6. **API Request**: Makes HTTP POST to the AI service endpoint with your query
|
|
194
|
+
7. **Payment Processing**: The interceptor signs the payment transaction and includes it in the request
|
|
195
|
+
8. **Response**: The service validates payment and returns the AI-generated response
|
|
196
|
+
|
|
197
|
+
### Technical Details
|
|
198
|
+
|
|
199
|
+
- **Base URL**: `https://agents.402box.io`
|
|
200
|
+
- **Endpoints**:
|
|
201
|
+
- `/x_searcher` - X/Twitter search agent
|
|
202
|
+
- `/find_people` - OSINT research agent
|
|
203
|
+
- **Timeout**: 300 seconds (5 minutes) per request
|
|
204
|
+
- **Blockchain**: Base (Ethereum L2)
|
|
205
|
+
- **Payment Protocol**: X402 (blockchain-based micropayments)
|
|
206
|
+
|
|
207
|
+
### Dependencies
|
|
208
|
+
|
|
209
|
+
- `@opencode-ai/plugin` - OpenCode plugin SDK
|
|
210
|
+
- `axios` - HTTP client
|
|
211
|
+
- `x402-axios` - X402 payment interceptor for Axios
|
|
212
|
+
- `viem` - Ethereum library for wallet and transaction signing
|
|
213
|
+
- `dotenv` - Environment variable management
|
|
214
|
+
|
|
83
215
|
## Publishing and Updates
|
|
84
216
|
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
217
|
+
### Publishing to npm
|
|
218
|
+
|
|
219
|
+
The package is published as `@itzannetos/x402-tools` on npm. To publish updates:
|
|
220
|
+
|
|
221
|
+
```bash
|
|
222
|
+
npm version patch # or minor, or major
|
|
223
|
+
npm publish
|
|
224
|
+
```
|
|
225
|
+
|
|
226
|
+
### Version Management
|
|
227
|
+
|
|
228
|
+
- Use semantic versioning (semver) for releases
|
|
229
|
+
- Reference the package in `opencode.json` using a version range: `"@itzannetos/x402-tools": "^1.0.0"`
|
|
230
|
+
- OpenCode installs npm plugins at startup and picks up compatible updates automatically
|
|
231
|
+
- Pin an exact version if you want to control upgrades manually
|
|
232
|
+
|
|
233
|
+
## Troubleshooting
|
|
234
|
+
|
|
235
|
+
### "X402 private key missing" Error
|
|
236
|
+
|
|
237
|
+
**Problem**: The plugin can't find your private key.
|
|
238
|
+
|
|
239
|
+
**Solution**:
|
|
240
|
+
- Ensure either `.opencode/x402-tools.json` exists with a valid `private_key` field
|
|
241
|
+
- OR set `X402_PRIVATE_KEY` in your `.env` file
|
|
242
|
+
- Verify the private key starts with `0x` or let the plugin add it automatically
|
|
243
|
+
|
|
244
|
+
### Payment Failures
|
|
245
|
+
|
|
246
|
+
**Problem**: Transactions are failing or timing out.
|
|
247
|
+
|
|
248
|
+
**Solution**:
|
|
249
|
+
- Ensure your wallet has sufficient USDC on the Base network
|
|
250
|
+
- Check Base network status (https://status.base.org)
|
|
251
|
+
- Verify your private key is valid
|
|
252
|
+
- Try with a smaller query first to test connectivity
|
|
253
|
+
|
|
254
|
+
### "Unexpected response" Errors
|
|
255
|
+
|
|
256
|
+
**Problem**: API returns unexpected data format.
|
|
257
|
+
|
|
258
|
+
**Solution**:
|
|
259
|
+
- Check your internet connection
|
|
260
|
+
- Verify the API service is operational
|
|
261
|
+
- Ensure you're using the latest plugin version
|
|
262
|
+
- Check if the query format is valid
|
|
263
|
+
|
|
264
|
+
### Plugin Not Loading
|
|
265
|
+
|
|
266
|
+
**Problem**: Tools don't appear in OpenCode.
|
|
267
|
+
|
|
268
|
+
**Solution**:
|
|
269
|
+
- Restart OpenCode after installation
|
|
270
|
+
- Check `opencode.json` syntax is valid JSON
|
|
271
|
+
- For local development, verify `.opencode/plugins/x402-tools.ts` exists
|
|
272
|
+
- Check OpenCode logs for error messages
|
|
273
|
+
|
|
274
|
+
## Development
|
|
275
|
+
|
|
276
|
+
### Project Structure
|
|
277
|
+
|
|
278
|
+
```
|
|
279
|
+
x402-tools/
|
|
280
|
+
├── .opencode/
|
|
281
|
+
│ ├── plugins/
|
|
282
|
+
│ │ └── x402-tools.ts # Main plugin implementation
|
|
283
|
+
│ ├── package.json # Local plugin dependencies
|
|
284
|
+
│ └── x402-tools.json # Config file (gitignored)
|
|
285
|
+
├── index.ts # Package entry point
|
|
286
|
+
├── package.json # npm package metadata
|
|
287
|
+
├── README.md # This file
|
|
288
|
+
└── .gitignore # Git ignore rules
|
|
289
|
+
```
|
|
290
|
+
|
|
291
|
+
### Local Development Workflow
|
|
292
|
+
|
|
293
|
+
1. Make changes to `.opencode/plugins/x402-tools.ts`
|
|
294
|
+
2. Restart OpenCode to reload the plugin
|
|
295
|
+
3. Test the tools in OpenCode conversations
|
|
296
|
+
4. Commit changes (config files are gitignored automatically)
|
|
297
|
+
|
|
298
|
+
|
|
299
|
+
|
|
300
|
+
## Security Considerations
|
|
301
|
+
|
|
302
|
+
- **Private Keys**: Never commit private keys to version control
|
|
303
|
+
- **Wallet Security**: Use a dedicated wallet with limited funds for API payments
|
|
304
|
+
- **Network**: Transactions occur on Base mainnet - be aware of gas costs
|
|
305
|
+
- **API Trust**: You're trusting the API provider (402box.io) to deliver services
|
|
306
|
+
- **Code Review**: Review the plugin code before using to understand what it does with your private key
|
|
307
|
+
|
|
308
|
+
## License
|
|
309
|
+
|
|
310
|
+
Check the package repository for license information.
|
|
311
|
+
|
|
312
|
+
## Coming Soon
|
|
313
|
+
|
|
314
|
+
We are actively adding more agents and tools in the coming days. Stay tuned for updates!
|
|
315
|
+
|
|
316
|
+
## Add Your Own Agent
|
|
317
|
+
|
|
318
|
+
Want to add your own x402 agent to this package? Contact us at george@402box.io to discuss integration.
|
|
319
|
+
|
|
320
|
+
## Support
|
|
321
|
+
|
|
322
|
+
For issues, questions, or contributions:
|
|
323
|
+
- GitHub Issues: [Report an issue](https://github.com/itzannetos/x402-tools/issues)
|
|
324
|
+
- Package: [@itzannetos/x402-tools](https://www.npmjs.com/package/@itzannetos/x402-tools)
|
|
88
325
|
|
|
89
|
-
##
|
|
326
|
+
## Changelog
|
|
90
327
|
|
|
91
|
-
|
|
92
|
-
-
|
|
93
|
-
-
|
|
328
|
+
### v1.0.0
|
|
329
|
+
- Initial release
|
|
330
|
+
- X Searcher tool for X/Twitter search
|
|
331
|
+
- Find People tool for OSINT research
|
|
332
|
+
- X402 payment integration
|
|
333
|
+
- Base network support
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@itzannetos/x402-tools",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.2",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "index.ts",
|
|
6
6
|
"files": [
|
|
@@ -8,6 +8,13 @@
|
|
|
8
8
|
".opencode/plugins/x402-tools.ts",
|
|
9
9
|
"README.md"
|
|
10
10
|
],
|
|
11
|
+
"keywords": [
|
|
12
|
+
"opencode",
|
|
13
|
+
"plugin",
|
|
14
|
+
"agents",
|
|
15
|
+
"llm",
|
|
16
|
+
"x402"
|
|
17
|
+
],
|
|
11
18
|
"dependencies": {
|
|
12
19
|
"@opencode-ai/plugin": "^1.1.25",
|
|
13
20
|
"axios": "^1.7.9",
|