@dexterai/clawdexter 1.0.0

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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Dexter AI
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,425 @@
1
+ # Dexter x402 Plugin for Moltbot
2
+
3
+ The most comprehensive x402 payment plugin for Moltbot. Provides:
4
+
5
+ 1. **Generic x402 Payments** (`x402_pay`) - Call ANY x402-enabled paid API with automatic USDC payment
6
+ 2. **x402 Directory Search** (`x402_search`) - Discover paid APIs across multiple networks
7
+ 3. **59+ Dexter DeFi Tools** (`dexter_x402`) - Authenticated access to Dexter's MCP tools
8
+
9
+ ## Overview
10
+
11
+ ### Generic x402 Tools (No Auth Required)
12
+
13
+ Configure your wallet keys and start making paid API calls immediately:
14
+
15
+ - **`x402_pay`** - Make paid requests to any x402 endpoint (Solana, Base, Polygon, Arbitrum, Optimism, Avalanche)
16
+ - **`x402_search`** - Search the aggregated directory of 2600+ paid APIs
17
+
18
+ ### Dexter MCP Tools (OAuth Required)
19
+
20
+ Connect to Dexter's 59+ Solana DeFi tools via OAuth:
21
+
22
+ - **`dexter_x402`** - Gateway to wallet management, trading, analytics, games, and more
23
+
24
+ ## Quick Start
25
+
26
+ ### Option A: Generic x402 (No Auth - Config Only)
27
+
28
+ Add your wallet keys to `~/.moltbot/moltbot.json`:
29
+
30
+ ```json
31
+ {
32
+ "plugins": {
33
+ "dexter-x402": {
34
+ "svmPrivateKey": "YOUR_SOLANA_PRIVATE_KEY",
35
+ "evmPrivateKey": "0xYOUR_EVM_PRIVATE_KEY",
36
+ "maxPaymentUSDC": "0.50"
37
+ }
38
+ }
39
+ }
40
+ ```
41
+
42
+ Then use:
43
+ ```bash
44
+ # Search for paid APIs
45
+ moltbot agent -m "Use x402_search to find weather APIs"
46
+
47
+ # Call a paid endpoint
48
+ moltbot agent -m "Use x402_pay to call https://example.com/api/data"
49
+ ```
50
+
51
+ ### Option B: Dexter Tools (OAuth Required)
52
+
53
+ #### 1. Authenticate
54
+
55
+ ```bash
56
+ moltbot models auth login --provider dexter-x402
57
+ ```
58
+
59
+ This opens OAuth flow in your browser. Sign in with your Dexter account and authorize Moltbot.
60
+
61
+ ### 2. Use Tools
62
+
63
+ The plugin exposes a single gateway tool `dexter_x402` that provides access to all 59+ Dexter capabilities:
64
+
65
+ ```bash
66
+ # List available tools
67
+ moltbot agent --local --session-id demo -m "Use dexter_x402 with action='list'"
68
+
69
+ # Call a specific tool
70
+ moltbot agent --local --session-id demo -m "Use dexter_x402 to check trending Solana tokens"
71
+ ```
72
+
73
+ Or simply ask naturally:
74
+
75
+ ```bash
76
+ moltbot agent --local --session-id demo -m "What's trending on Solana right now?"
77
+ ```
78
+
79
+ ## Available Tools (59+)
80
+
81
+ ### 💼 Wallet Management
82
+ | Tool | Description |
83
+ |------|-------------|
84
+ | `resolve_wallet` | Resolve the effective managed wallet for this session |
85
+ | `list_my_wallets` | List all wallets linked to your Dexter account |
86
+ | `set_session_wallet_override` | Override wallet for the current session |
87
+ | `auth_info` | Diagnostics for wallet resolution and token state |
88
+
89
+ ### 💱 Solana Trading
90
+ | Tool | Description |
91
+ |------|-------------|
92
+ | `solana_resolve_token` | Resolve token metadata by name, ticker, or address |
93
+ | `solana_send` | Transfer SOL, USDC, DEXTER, PAYAI, or any SPL token |
94
+ | `solana_swap_preview` | Preview a token swap before execution |
95
+ | `solana_swap_execute` | Execute a previewed swap |
96
+ | `jupiter_quote_preview` | Get Jupiter DEX swap quote |
97
+ | `jupiter_quote_pro` | Jupiter quote with pro-tier features |
98
+
99
+ ### 📊 Analytics & Research
100
+ | Tool | Description |
101
+ |------|-------------|
102
+ | `search` | Web search with real-time results |
103
+ | `fetch` | Retrieve and summarize web pages |
104
+ | `pumpstream_live_summary` | Live pump.fun stream analytics |
105
+ | `markets_fetch_ohlcv` | Birdeye OHLCV candle data |
106
+ | `onchain_activity_overview` | On-chain analytics for tokens/wallets |
107
+ | `onchain_entity_insight` | Deep analysis of wallets, tokens, or signatures |
108
+ | `solscan_trending_tokens` | Solscan trending tokens snapshot |
109
+ | `slippage_sentinel` | Volatility analysis & optimal slippage calculation |
110
+ | `twitter_topic_analysis` | Twitter sentiment and conversation analysis |
111
+
112
+ ### 🎬 Creative & Media (x402 Paid)
113
+ | Tool | Description |
114
+ |------|-------------|
115
+ | `sora_video_job` | Generate video clips with OpenAI Sora |
116
+ | `meme_generator_job` | AI-powered meme and image generation |
117
+ | `studio_breaking_news` | Create newscast videos and infographics |
118
+ | `studio_news_status` | Check breaking news job status |
119
+
120
+ ### 🎮 Games
121
+ | Tool | Description |
122
+ |------|-------------|
123
+ | `pokedexter_create_challenge` | Create wagered Pokémon battle ($1-$25) |
124
+ | `pokedexter_accept_challenge` | Accept a battle challenge |
125
+ | `pokedexter_make_move` | Submit battle action |
126
+ | `pokedexter_get_battle_state` | Get current battle state |
127
+ | `pokedexter_join_queue` | Join quick match queue |
128
+ | `games_king_usurp` | Become King of Dexter ($0.01) |
129
+ | `games_king_state` | View current King state |
130
+ | `games_story_append` | Add to the Infinite Story ($0.01) |
131
+ | `games_story_read` | Read the Infinite Story |
132
+
133
+ ### 🚀 Hyperliquid (Perpetuals)
134
+ | Tool | Description |
135
+ |------|-------------|
136
+ | `hyperliquid_markets` | List tradable perp symbols |
137
+ | `hyperliquid_opt_in` | Provision agent wallet for perp trading |
138
+ | `hyperliquid_fund` | Bridge SOL → USDC → Hyperliquid |
139
+ | `hyperliquid_bridge_deposit` | Deposit from Arbitrum |
140
+ | `hyperliquid_perp_trade` | Submit perpetual orders |
141
+
142
+ ### 🔧 Codex Sessions
143
+ | Tool | Description |
144
+ |------|-------------|
145
+ | `codex_start` | Begin a new Codex conversation |
146
+ | `codex_reply` | Follow-up to existing Codex session |
147
+ | `codex_exec` | Run Codex with optional JSON schema |
148
+
149
+ ### 🏭 Studio (Superadmin)
150
+ | Tool | Description |
151
+ |------|-------------|
152
+ | `studio_create` | Start a Studio agent task |
153
+ | `studio_status` | Check job status |
154
+ | `studio_cancel` | Cancel running job |
155
+ | `studio_inspect` | Full job details |
156
+ | `studio_list` | List recent jobs |
157
+
158
+ ### 📺 Stream Engagement
159
+ | Tool | Description |
160
+ |------|-------------|
161
+ | `stream_public_shout` | Submit shout-out for live stream |
162
+ | `stream_shout_feed` | Get latest public shouts |
163
+
164
+ ## Architecture
165
+
166
+ ```
167
+ ┌─────────────────┐ OAuth 2.0 + PKCE ┌──────────────────┐
168
+ │ Moltbot │◄─────────────────────────►│ Dexter OAuth │
169
+ │ (dexter-x402 │ │ (dexter-api) │
170
+ │ plugin) │ └──────────────────┘
171
+ └────────┬────────┘
172
+
173
+ │ MCP Protocol (JSON-RPC over HTTP)
174
+ │ - tools/list
175
+ │ - tools/call
176
+
177
+ ┌─────────────────┐ Internal ┌──────────────────┐
178
+ │ Dexter x402 │◄─────────────────►│ Dexter Backend │
179
+ │ Server │ │ (59+ tools) │
180
+ │ mcp.dexter.cash │ │ │
181
+ └─────────────────┘ └──────────────────┘
182
+ ```
183
+
184
+ ### Authentication Flow
185
+
186
+ **Primary (Desktop/CLI):**
187
+ 1. **Link Request**: Plugin creates a tracking code via `api.dexter.cash/api/moltbot/link/create`
188
+ 2. **DCR**: Plugin registers with Dexter's OAuth server using remote callback (`dexter.cash/moltbot/link/callback`)
189
+ 3. **PKCE Authorization**: Browser-based OAuth with S256 code challenge
190
+ 4. **Remote Callback**: OAuth redirects to `dexter.cash`, backend stores tokens
191
+ 5. **Poll Completion**: Plugin polls for tokens, retrieves them when ready
192
+ 6. **Automatic Refresh**: Tokens refreshed automatically before expiry
193
+
194
+ **Fallback (Telegram/Remote):**
195
+ 1. **Device Code**: Plugin creates link code, displays to user
196
+ 2. **Manual Auth**: User visits `dexter.cash/moltbot/link?code=XXXX`, signs in
197
+ 3. **Poll Completion**: Plugin polls until user completes auth
198
+
199
+ ### MCP Integration
200
+
201
+ The plugin uses the official `@modelcontextprotocol/sdk` to:
202
+
203
+ 1. Establish `StreamableHTTPClientTransport` connection to `mcp.dexter.cash/mcp`
204
+ 2. Send `tools/list` JSON-RPC requests to discover available tools
205
+ 3. Execute `tools/call` JSON-RPC requests for tool invocation
206
+ 4. Handle response content (text, JSON, images)
207
+
208
+ ## Configuration
209
+
210
+ Full configuration in `~/.moltbot/moltbot.json`:
211
+
212
+ ```json
213
+ {
214
+ "plugins": {
215
+ "dexter-x402": {
216
+ "svmPrivateKey": "base58_solana_private_key",
217
+ "evmPrivateKey": "0x_hex_evm_private_key",
218
+ "defaultNetwork": "solana",
219
+ "maxPaymentUSDC": "0.50",
220
+ "baseUrl": "https://mcp.dexter.cash/mcp",
221
+ "directoryUrl": "https://api.dexter.cash/api/x402/directory",
222
+ "autoRefreshTools": true,
223
+ "disableTelemetry": false
224
+ }
225
+ }
226
+ }
227
+ ```
228
+
229
+ ### Config Options
230
+
231
+ | Option | Type | Default | Description |
232
+ |--------|------|---------|-------------|
233
+ | `svmPrivateKey` | string | - | Solana private key (base58) for x402 payments |
234
+ | `evmPrivateKey` | string | - | EVM private key (hex) for Base/Polygon/etc payments |
235
+ | `defaultNetwork` | string | `"solana"` | Preferred network: solana, base, polygon, arbitrum, optimism, avalanche |
236
+ | `maxPaymentUSDC` | string | `"0.50"` | Maximum payment per request (e.g., "0.50" = $0.50) |
237
+ | `baseUrl` | string | `https://mcp.dexter.cash/mcp` | Dexter MCP server (for authenticated tools) |
238
+ | `directoryUrl` | string | `https://x402.dexter.cash/api/x402/directory` | x402 directory API |
239
+ | `autoRefreshTools` | boolean | `true` | Refresh Dexter tool list on connection |
240
+ | `disableTelemetry` | boolean | `false` | Disable anonymous usage telemetry |
241
+
242
+ ## Tools Reference
243
+
244
+ ### x402_pay (Generic Payments)
245
+
246
+ Call ANY x402-enabled paid API with automatic USDC payment. No authentication required - just configure wallet keys.
247
+
248
+ **Supported Networks:** Solana, Base, Polygon, Arbitrum, Optimism, Avalanche
249
+
250
+ **Parameters:**
251
+ | Param | Type | Required | Description |
252
+ |-------|------|----------|-------------|
253
+ | `url` | string | Yes | The x402-enabled endpoint URL |
254
+ | `method` | string | No | HTTP method (default: GET) |
255
+ | `params` | object | No | Query params (GET) or JSON body (POST) |
256
+ | `headers` | object | No | Custom HTTP headers |
257
+
258
+ **Example:**
259
+ ```bash
260
+ moltbot agent -m "Use x402_pay to call https://x402.dexter.cash/api/onchain/activity/overview with params {\"entityId\": \"SOL\"}"
261
+ ```
262
+
263
+ **How it works:**
264
+ 1. Makes request to the URL
265
+ 2. If 402 returned, SDK automatically signs USDC payment
266
+ 3. Retries request with payment proof
267
+ 4. Returns response data
268
+
269
+ ### x402_search (Directory Search)
270
+
271
+ Search the aggregated directory of x402-enabled paid APIs. Combines Dexter's catalog with external sources.
272
+
273
+ **Parameters:**
274
+ | Param | Type | Required | Description |
275
+ |-------|------|----------|-------------|
276
+ | `query` | string | No | Search term (searches url, description) |
277
+ | `network` | string | No | Filter: solana, base, polygon, arbitrum, optimism, avalanche |
278
+ | `verified` | boolean | No | Only show verified endpoints |
279
+ | `limit` | number | No | Max results (default: 10, max: 50) |
280
+
281
+ **Example:**
282
+ ```bash
283
+ moltbot agent -m "Use x402_search to find Solana analytics APIs"
284
+ ```
285
+
286
+ **Response includes:**
287
+ - Endpoint URL and method
288
+ - Network and pricing
289
+ - Description and verification status
290
+ - Success rate (when available)
291
+
292
+ ### dexter_x402 (Authenticated Dexter Tools)
293
+
294
+ ## How It Works
295
+
296
+ ### The `dexter_x402` Gateway
297
+
298
+ Rather than registering 59+ individual tools (which would overwhelm the agent's context), this plugin exposes a single `dexter_x402` gateway with two actions:
299
+
300
+ ```typescript
301
+ {
302
+ action: "list" | "call",
303
+ tool?: string, // Tool name (required for "call")
304
+ args?: string // JSON arguments for the tool
305
+ }
306
+ ```
307
+
308
+ **List tools:**
309
+ ```json
310
+ { "action": "list" }
311
+ ```
312
+
313
+ **Call a tool:**
314
+ ```json
315
+ {
316
+ "action": "call",
317
+ "tool": "solscan_trending_tokens",
318
+ "args": "{\"limit\": 10}"
319
+ }
320
+ ```
321
+
322
+ ### Credential Storage
323
+
324
+ OAuth credentials are stored in:
325
+ ```
326
+ ~/.moltbot/auth-profiles.json
327
+ # or legacy location:
328
+ ~/.clawdbot/agents/main/agent/auth-profiles.json
329
+ ```
330
+
331
+ Format:
332
+ ```json
333
+ {
334
+ "version": 1,
335
+ "profiles": {
336
+ "dexter-x402:default": {
337
+ "type": "oauth",
338
+ "provider": "dexter-x402",
339
+ "access": "eyJ...",
340
+ "refresh": "...",
341
+ "expires": 1769639417118,
342
+ "baseUrl": "https://mcp.dexter.cash/mcp"
343
+ }
344
+ }
345
+ }
346
+ ```
347
+
348
+ ## Troubleshooting
349
+
350
+ ### "Not connected to Dexter"
351
+
352
+ The tool couldn't find valid credentials. Run:
353
+ ```bash
354
+ moltbot models auth login --provider dexter-x402
355
+ ```
356
+
357
+ ### OAuth on Telegram or remote server
358
+
359
+ The plugin automatically uses device code flow for Telegram and remote environments:
360
+
361
+ 1. Plugin displays a link code (e.g., `ABC12345`)
362
+ 2. Visit `dexter.cash/moltbot/link?code=ABC12345` in any browser
363
+ 3. Sign in to Dexter and click "Connect"
364
+ 4. Return to Moltbot - it will detect the auth automatically
365
+
366
+ No localhost or port forwarding needed.
367
+
368
+ ### Token expired
369
+
370
+ Tokens auto-refresh. If refresh fails, re-authenticate:
371
+ ```bash
372
+ moltbot models auth login --provider dexter-x402
373
+ ```
374
+
375
+ ### MCP connection errors
376
+
377
+ Check that `mcp.dexter.cash` is accessible:
378
+ ```bash
379
+ curl https://mcp.dexter.cash/mcp/health
380
+ ```
381
+
382
+ ### Tools not appearing
383
+
384
+ Ensure the plugin is enabled:
385
+ ```bash
386
+ cat ~/.moltbot/moltbot.json | jq '.plugins'
387
+ ```
388
+
389
+ ## Development
390
+
391
+ ### Building
392
+
393
+ ```bash
394
+ cd /path/to/moltbot-research
395
+ pnpm build
396
+ ```
397
+
398
+ ### Testing OAuth Flow
399
+
400
+ ```bash
401
+ ./moltbot.mjs models auth login --provider dexter-x402
402
+ ```
403
+
404
+ ### Testing Tool Execution
405
+
406
+ ```bash
407
+ export ANTHROPIC_API_KEY="sk-ant-..."
408
+ ./moltbot.mjs agent --local --session-id test -m "Use dexter_x402 with action='list'"
409
+ ```
410
+
411
+ ## Dependencies
412
+
413
+ - `@modelcontextprotocol/sdk` - Official MCP client SDK
414
+ - `@sinclair/typebox` - Runtime type validation
415
+
416
+ ## Links
417
+
418
+ - [Dexter](https://dexter.cash) - Main website
419
+ - [Dexter x402](https://mcp.dexter.cash) - MCP server
420
+ - [MCP Specification](https://modelcontextprotocol.io) - Protocol documentation
421
+ - [Discord](https://discord.gg/dexter) - Community support
422
+
423
+ ## License
424
+
425
+ MIT