@quantish/agent 0.1.5 → 0.1.7

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.
Files changed (3) hide show
  1. package/README.md +152 -140
  2. package/dist/index.js +48 -21
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -1,45 +1,19 @@
1
- # @quantish/cli
1
+ # @quantish/agent
2
2
 
3
- AI-powered CLI agent for building trading bots on Polymarket.
3
+ AI-powered CLI agent for building trading bots and applications on Polymarket.
4
4
 
5
5
  Combines **coding tools** (file system, shell, git) with **trading tools** (Polymarket orders, positions, wallet) powered by Claude AI.
6
6
 
7
- ## How It Works
8
-
9
- Quantish CLI connects to the **Quantish Signing Server** to execute trades on Polymarket. Here's why:
10
-
11
- ### Why We Use a Signing Server
12
-
13
- Polymarket uses a **gasless relayer system** - this means:
14
- - ✅ **Free wallet creation** - No MATIC needed to set up
15
- - ✅ **Free trading** - Polymarket covers gas fees on all transactions
16
- - ✅ **Simplified signing** - Our server handles the complex signature formats
17
-
18
- To make this work reliably, the Quantish Signing Server:
19
- 1. **Handles wallet creation** - Your wallet is created and managed through our server
20
- 2. **Signs transactions** - Orders are signed using Polymarket's required format
21
- 3. **Relays to Polymarket** - Transactions go through Polymarket's official relayer
22
- 4. **Bypasses geo-restrictions** - Our server is hosted in a compatible region
23
-
24
- ### What This Means for You
25
-
26
- - **Your funds are secure** - Only you can authorize transactions via your API key
27
- - **Wallets are non-custodial** - You can export your private key anytime with `export_private_key`
28
- - **Trading is free** - No gas fees, ever
29
- - **It just works** - No VPN or complex setup needed
30
-
31
- > 🔒 **Security Note**: Your private keys are stored encrypted. You can export them and migrate to a self-hosted solution in the future if needed.
32
-
33
7
  ## Installation
34
8
 
35
9
  ```bash
36
- npm install -g @quantish/cli
10
+ npm install -g @quantish/agent
37
11
  ```
38
12
 
39
13
  Or run directly with npx:
40
14
 
41
15
  ```bash
42
- npx @quantish/cli
16
+ npx @quantish/agent
43
17
  ```
44
18
 
45
19
  ## Quick Start
@@ -67,15 +41,15 @@ quantish
67
41
  Example conversations:
68
42
 
69
43
  ```
70
- You: Create a trading bot that monitors my positions and sells when profit > 20%
71
- Assistant: I'll create that for you. Let me first check your current positions...
72
- [Calling get_positions...]
73
- [Writing bot.ts...]
44
+ You: Create a trading bot that monitors Bitcoin markets and alerts on price changes
45
+ Assistant: I'll create that for you. Let me first search for Bitcoin markets...
46
+ [Calling search_markets...]
47
+ [Writing bitcoin-monitor.js...]
74
48
 
75
49
  You: What's my current balance?
76
- Assistant: Your Safe wallet has 0.68 USDC available for trading.
50
+ Assistant: Your Safe wallet has 125.50 USDC available for trading.
77
51
 
78
- You: Place a $5 YES order on Trump winning at 55 cents
52
+ You: Place a $10 YES order on Trump winning at 55 cents
79
53
  Assistant: Order placed! Order ID: abc123...
80
54
  ```
81
55
 
@@ -85,12 +59,6 @@ Assistant: Order placed! Order ID: abc123...
85
59
  quantish -p "check my open orders"
86
60
  ```
87
61
 
88
- **Piped input:**
89
-
90
- ```bash
91
- echo "show my positions" | quantish
92
- ```
93
-
94
62
  ## Commands
95
63
 
96
64
  | Command | Description |
@@ -98,6 +66,8 @@ echo "show my positions" | quantish
98
66
  | `quantish` | Start interactive chat |
99
67
  | `quantish init` | Configure API keys |
100
68
  | `quantish config` | View configuration |
69
+ | `quantish config --server <url>` | Set custom MCP server URL |
70
+ | `quantish config --export` | Export keys for standalone apps |
101
71
  | `quantish tools` | List available tools |
102
72
  | `quantish -p "..."` | Run one-shot prompt |
103
73
 
@@ -112,124 +82,173 @@ echo "show my positions" | quantish
112
82
  | `--version` | Show version |
113
83
  | `--help` | Show help |
114
84
 
115
- ## Available Tools
85
+ ## Building Standalone Applications
116
86
 
117
- ### Local Tools (Coding)
87
+ The real power of Quantish is building standalone applications that interact with prediction markets. The agent can create trading bots, web dashboards, notification systems, and more.
118
88
 
119
- | Tool | Description |
120
- |------|-------------|
121
- | `read_file` | Read file contents |
122
- | `write_file` | Write/create files |
123
- | `list_dir` | List directory contents |
124
- | `delete_file` | Delete files |
125
- | `file_exists` | Check if file exists |
126
- | `run_command` | Execute shell commands |
127
- | `grep` | Search file contents |
128
- | `find_files` | Find files by pattern |
129
- | `git_status` | Get git status |
130
- | `git_diff` | Show git diff |
131
- | `git_add` | Stage files |
132
- | `git_commit` | Create commits |
133
- | `git_log` | Show commit history |
134
- | `git_checkout` | Switch branches |
135
- | `web_search` | Search the web (Exa/DuckDuckGo) |
136
- | `web_answer` | AI-powered Q&A (Exa) |
137
- | `fetch_url` | Fetch URL content |
89
+ ### MCP API Overview
138
90
 
139
- ### MCP Tools (Trading)
91
+ There are two MCP endpoints:
140
92
 
141
- | Tool | Description |
142
- |------|-------------|
143
- | `get_balances` | Check wallet balances |
144
- | `get_positions` | View current positions |
145
- | `place_order` | Place buy/sell orders |
146
- | `cancel_order` | Cancel open orders |
147
- | `get_orders` | List orders |
148
- | `get_orderbook` | Get market orderbook |
149
- | `get_price` | Get current price |
150
- | `transfer_usdc` | Transfer USDC |
151
- | `swap_tokens` | Swap tokens |
152
- | `claim_winnings` | Claim from resolved markets |
93
+ | Endpoint | Purpose | Auth Required |
94
+ |----------|---------|---------------|
95
+ | Trading API | Wallet, orders, positions | Yes (QUANTISH_API_KEY) |
96
+ | Discovery API | Search markets, prices | No (public key) |
153
97
 
154
- ## Configuration
98
+ ### Trading API (Requires Your API Key)
155
99
 
156
- Configuration is stored in `~/.quantish/config.json`:
100
+ ```javascript
101
+ const response = await fetch('https://quantish-sdk-production.up.railway.app/mcp/execute', {
102
+ method: 'POST',
103
+ headers: {
104
+ 'Content-Type': 'application/json',
105
+ 'x-api-key': process.env.QUANTISH_API_KEY
106
+ },
107
+ body: JSON.stringify({
108
+ jsonrpc: '2.0',
109
+ method: 'tools/call',
110
+ params: { name: 'get_balances', arguments: {} },
111
+ id: Date.now()
112
+ })
113
+ });
157
114
 
158
- ```json
159
- {
160
- "anthropicApiKey": "sk-ant-...",
161
- "quantishApiKey": "pk_live_...",
162
- "mcpServerUrl": "https://quantish-sdk-production.up.railway.app/mcp"
163
- }
115
+ const data = await response.json();
116
+ const result = JSON.parse(data.result.content[0].text);
164
117
  ```
165
118
 
166
- Environment variables take precedence:
167
- - `ANTHROPIC_API_KEY`
168
- - `QUANTISH_API_KEY`
119
+ **Trading Tools:** `get_balances`, `get_positions`, `place_order`, `cancel_order`, `get_orders`, `get_orderbook`, `get_price`, `transfer_usdc`
120
+
121
+ ### Discovery API (Free, No Auth)
122
+
123
+ ```javascript
124
+ const response = await fetch('https://quantish.live/mcp/execute', {
125
+ method: 'POST',
126
+ headers: {
127
+ 'Content-Type': 'application/json',
128
+ 'X-API-Key': 'qm_ueQeqrmvZyHtR1zuVbLYkhx0fKyVAuV8' // Public key
129
+ },
130
+ body: JSON.stringify({
131
+ name: 'search_markets', // Simple format for Discovery
132
+ arguments: { query: 'bitcoin', limit: 5 }
133
+ })
134
+ });
135
+
136
+ const data = await response.json();
137
+ const result = JSON.parse(data.result.content[0].text);
138
+ ```
169
139
 
170
- ## Examples
140
+ **Discovery Tools:** `search_markets`, `get_market_details`, `get_trending_markets`, `find_arbitrage`
171
141
 
172
- ### Build a Trading Bot
142
+ ### Example: Ask the Agent to Build an App
173
143
 
174
144
  ```bash
175
145
  quantish
176
- > Create a Python script that monitors the Trump market and alerts me when price drops below 40 cents
146
+ > Create a Node.js script that monitors Bitcoin markets and sends a Discord notification when prices move more than 10%
177
147
  ```
178
148
 
179
- ### Manage Positions
149
+ The agent will create all necessary files:
150
+ - Main application code with MCP helper functions
151
+ - `package.json` with dependencies
152
+ - `.env.example` with required environment variables
153
+ - `README.md` with setup instructions
154
+
155
+ ## Architecture
180
156
 
181
- ```bash
182
- quantish -p "show me my positions with unrealized P&L"
157
+ ```
158
+ quantish (CLI)
159
+
160
+ ├── Local Tools (filesystem, shell, git)
161
+ │ └── Runs directly on your machine
162
+
163
+ └── MCP Tools (trading + discovery)
164
+ ├── Trading MCP (your wallet, orders)
165
+ │ └── https://quantish-sdk-production.up.railway.app/mcp
166
+
167
+ └── Discovery MCP (public market data)
168
+ └── https://quantish.live/mcp
183
169
  ```
184
170
 
185
- ### Market Making
171
+ ## Self-Hosting
186
172
 
187
- ```bash
188
- quantish
189
- > Help me set up a basic market making strategy. I want to place both bid and ask orders around the current mid price.
190
- ```
173
+ You can run your own Trading MCP server for full control over your wallet keys.
191
174
 
192
- ### Code Review
175
+ ### Configure Custom Server
193
176
 
194
177
  ```bash
195
- quantish
196
- > Read my trading bot code in bot.ts and suggest improvements
178
+ # Set via CLI
179
+ quantish config --server https://your-server.com/mcp
180
+
181
+ # Or via environment variable
182
+ export MCP_SERVER_URL=https://your-server.com/mcp
197
183
  ```
198
184
 
199
- ## Development
185
+ ### What You Need
200
186
 
201
- ```bash
202
- # Clone the repo
203
- git clone https://github.com/quantish/cli
187
+ 1. **Server**: Deploy the `quantish-server` to Railway, Render, or your own VPS
188
+ 2. **Database**: PostgreSQL for user data and encrypted keys
189
+ 3. **Polymarket Builder Credentials**: Apply at https://polymarket.com/builder
204
190
 
205
- # Install dependencies
206
- cd packages/quantish-cli
207
- npm install
191
+ See [Self-Hosting Guide](https://quantish.live/docs/self-hosting.html) for full instructions.
208
192
 
209
- # Build
210
- npm run build
193
+ ## Configuration
211
194
 
212
- # Run locally
213
- npm start
195
+ Configuration is stored in `~/.quantish/config.json`:
214
196
 
215
- # Development mode (watch)
216
- npm run dev
197
+ ```json
198
+ {
199
+ "anthropicApiKey": "sk-ant-...",
200
+ "quantishApiKey": "qtsh_...",
201
+ "mcpServerUrl": "https://quantish-sdk-production.up.railway.app/mcp",
202
+ "model": "claude-sonnet-4-5-20250929"
203
+ }
217
204
  ```
218
205
 
219
- ## Architecture
206
+ Environment variables take precedence:
207
+ - `ANTHROPIC_API_KEY`
208
+ - `QUANTISH_API_KEY`
209
+ - `MCP_SERVER_URL`
220
210
 
221
- ```
222
- quantish (CLI)
223
-
224
- ├── Local Tools (filesystem, shell, git)
225
- │ └── Runs directly on your machine
226
-
227
- └── MCP Tools (trading)
228
- └── Calls Quantish MCP Server
229
- └── Executes on Polymarket
230
- ```
211
+ ## Available Tools
212
+
213
+ ### Local Tools (Coding)
214
+
215
+ | Tool | Description |
216
+ |------|-------------|
217
+ | `read_file` | Read file contents |
218
+ | `write_file` | Write/create files |
219
+ | `edit_file` | Search and replace in files |
220
+ | `list_dir` | List directory contents |
221
+ | `delete_file` | Delete files |
222
+ | `setup_env` | Create/update .env files |
223
+ | `run_command` | Execute shell commands |
224
+ | `grep` | Search file contents |
225
+ | `find_files` | Find files by pattern |
226
+ | `git_status` | Get git status |
227
+ | `git_diff` | Show git diff |
228
+ | `git_add` | Stage files |
229
+ | `git_commit` | Create commits |
230
+
231
+ ### MCP Tools (Trading)
232
+
233
+ | Tool | Description |
234
+ |------|-------------|
235
+ | `get_balances` | Check wallet balances |
236
+ | `get_positions` | View current positions |
237
+ | `place_order` | Place buy/sell orders |
238
+ | `cancel_order` | Cancel open orders |
239
+ | `get_orders` | List orders |
240
+ | `get_orderbook` | Get market orderbook |
241
+ | `get_price` | Get current price |
242
+ | `transfer_usdc` | Transfer USDC |
231
243
 
232
- The agent uses Claude to understand your requests and decide which tools to use. It can combine coding and trading tools in a single conversation.
244
+ ### MCP Tools (Discovery)
245
+
246
+ | Tool | Description |
247
+ |------|-------------|
248
+ | `search_markets` | Search markets by keyword |
249
+ | `get_market_details` | Get full market info |
250
+ | `get_trending_markets` | Popular markets |
251
+ | `find_arbitrage` | Find price discrepancies |
233
252
 
234
253
  ## Platform Support
235
254
 
@@ -239,23 +258,16 @@ The agent uses Claude to understand your requests and decide which tools to use.
239
258
  | Linux | ✅ Full support |
240
259
  | Windows | ⚠️ Requires WSL |
241
260
 
242
- **Windows users:** Install [WSL (Windows Subsystem for Linux)](https://learn.microsoft.com/en-us/windows/wsl/install) and run Quantish from within WSL. Native Windows (PowerShell/cmd.exe) is not supported.
243
-
244
- ## Environment Variables
245
-
246
- | Variable | Description |
247
- |----------|-------------|
248
- | `ANTHROPIC_API_KEY` | Your Anthropic API key (required) |
249
- | `QUANTISH_API_KEY` | Your Quantish trading API key |
250
- | `EXA_API_KEY` | Optional: Exa AI search key for powerful web search |
261
+ **Windows users:** Install [WSL](https://learn.microsoft.com/en-us/windows/wsl/install) and run Quantish from within WSL.
251
262
 
252
- ### Web Search
253
-
254
- Web search works without API keys (using DuckDuckGo fallback), but **Exa is strongly recommended** for AI-quality search results.
263
+ ## How It Works
255
264
 
256
- Get your Exa API key at: https://dashboard.exa.ai
265
+ Quantish CLI connects to the **Quantish Signing Server** to execute trades on Polymarket:
257
266
 
258
- Exa is the same search engine used by Cursor, Notion, Vercel, and other leading AI products.
267
+ - **Your funds are secure** - Only you can authorize transactions via your API key
268
+ - **Wallets are non-custodial** - Export your private key anytime with `export_private_key`
269
+ - **Trading is free** - No gas fees (Polymarket covers them)
270
+ - **Self-hosting available** - Run your own server for full control
259
271
 
260
272
  ## License
261
273
 
package/dist/index.js CHANGED
@@ -70,8 +70,11 @@ var ConfigManager = class {
70
70
  }
71
71
  /**
72
72
  * Get the Trading MCP server URL (user's wallet/orders)
73
+ * Priority: MCP_SERVER_URL env var > config file > default
73
74
  */
74
75
  getMcpServerUrl() {
76
+ const envUrl = process.env.MCP_SERVER_URL;
77
+ if (envUrl) return envUrl;
75
78
  return this.conf.get("mcpServerUrl") ?? DEFAULT_MCP_URL;
76
79
  }
77
80
  /**
@@ -98,6 +101,12 @@ var ConfigManager = class {
98
101
  setMcpServerUrl(url) {
99
102
  this.conf.set("mcpServerUrl", url);
100
103
  }
104
+ /**
105
+ * Generic setter for any config key
106
+ */
107
+ set(key, value) {
108
+ this.conf.set(key, value);
109
+ }
101
110
  /**
102
111
  * Get the model to use
103
112
  */
@@ -2754,12 +2763,27 @@ const result = JSON.parse(data.result.content[0].text);
2754
2763
  - \`transfer_usdc\`: Send USDC. Args: { toAddress, amount }
2755
2764
 
2756
2765
  ### Key Discovery Tools (free, no auth required)
2757
- Discovery uses a different endpoint with an embedded public key:
2758
- \`\`\`
2759
- POST https://quantish.live/mcp/execute
2760
- Header: X-API-Key: qm_ueQeqrmvZyHtR1zuVbLYkhx0fKyVAuV8
2766
+ Discovery uses a SIMPLER request format (not full JSON-RPC):
2767
+ \`\`\`javascript
2768
+ // Discovery API - uses simple { name, arguments } format
2769
+ const response = await fetch('https://quantish.live/mcp/execute', {
2770
+ method: 'POST',
2771
+ headers: {
2772
+ 'Content-Type': 'application/json',
2773
+ 'X-API-Key': 'qm_ueQeqrmvZyHtR1zuVbLYkhx0fKyVAuV8'
2774
+ },
2775
+ body: JSON.stringify({
2776
+ name: 'search_markets', // Tool name at top level
2777
+ arguments: { query: 'bitcoin', limit: 5 } // Arguments at top level
2778
+ })
2779
+ });
2780
+
2781
+ // Response is still JSON-RPC wrapped:
2782
+ const data = await response.json();
2783
+ const result = JSON.parse(data.result.content[0].text);
2761
2784
  \`\`\`
2762
2785
 
2786
+ Available Discovery Tools:
2763
2787
  - \`search_markets\`: Find markets. Args: { query, limit?, platform?: "polymarket"|"kalshi"|"all" }
2764
2788
  - \`get_market_details\`: Get market info. Args: { platform, marketId }
2765
2789
  - \`get_trending_markets\`: Popular markets. Args: { limit?, platform? }
@@ -2886,29 +2910,25 @@ console.log('Order placed:', orderResult.orderId);
2886
2910
  ### SIMPLE EXAMPLE - Copy This Pattern Exactly
2887
2911
 
2888
2912
  \`\`\`javascript
2889
- // Simple bot that searches markets - CORRECT PATTERN
2913
+ // Simple bot that searches markets using Discovery API (free, no auth)
2890
2914
  require('dotenv').config();
2891
2915
 
2892
- async function callTool(name, args = {}) {
2916
+ // Discovery API uses SIMPLE format: { name, arguments }
2917
+ async function callDiscovery(name, args = {}) {
2893
2918
  const res = await fetch('https://quantish.live/mcp/execute', {
2894
2919
  method: 'POST',
2895
2920
  headers: {
2896
2921
  'Content-Type': 'application/json',
2897
- 'X-API-Key': 'qm_ueQeqrmvZyHtR1zuVbLYkhx0fKyVAuV8'
2922
+ 'X-API-Key': 'qm_ueQeqrmvZyHtR1zuVbLYkhx0fKyVAuV8' // Public key
2898
2923
  },
2899
- body: JSON.stringify({
2900
- jsonrpc: '2.0',
2901
- method: 'tools/call',
2902
- params: { name, arguments: args },
2903
- id: 1
2904
- })
2924
+ body: JSON.stringify({ name, arguments: args }) // Simple format!
2905
2925
  });
2906
2926
  const data = await res.json();
2907
2927
  return JSON.parse(data.result.content[0].text);
2908
2928
  }
2909
2929
 
2910
2930
  // Use it!
2911
- const markets = await callTool('search_markets', { query: 'bitcoin', limit: 5 });
2931
+ const markets = await callDiscovery('search_markets', { query: 'bitcoin', limit: 5 });
2912
2932
  console.log(markets);
2913
2933
  \`\`\`
2914
2934
 
@@ -2976,6 +2996,7 @@ async function callTradingTool(name, args = {}) {
2976
2996
 
2977
2997
  /**
2978
2998
  * Call a discovery tool (no auth required)
2999
+ * Uses SIMPLE format: { name, arguments } - NOT full JSON-RPC
2979
3000
  * Tools: search_markets, get_market_details, get_trending_markets, find_arbitrage
2980
3001
  */
2981
3002
  async function callDiscoveryTool(name, args = {}) {
@@ -2985,12 +3006,7 @@ async function callDiscoveryTool(name, args = {}) {
2985
3006
  'Content-Type': 'application/json',
2986
3007
  'X-API-Key': DISCOVERY_API_KEY
2987
3008
  },
2988
- body: JSON.stringify({
2989
- jsonrpc: '2.0',
2990
- method: 'tools/call',
2991
- params: { name, arguments: args },
2992
- id: Date.now()
2993
- })
3009
+ body: JSON.stringify({ name, arguments: args }) // Simple format for Discovery!
2994
3010
  });
2995
3011
 
2996
3012
  const data = await response.json();
@@ -4199,8 +4215,19 @@ program.name("quantish").description("AI coding & trading agent for Polymarket")
4199
4215
  program.command("init").description("Configure Quantish CLI with your API keys").action(async () => {
4200
4216
  await runSetup();
4201
4217
  });
4202
- program.command("config").description("View or edit configuration").option("-s, --show", "Show current configuration").option("-c, --clear", "Clear all configuration").option("--path", "Show config file path").option("--export", "Export configuration as .env format").option("--show-keys", "Show full API keys (use with caution)").action(async (options) => {
4218
+ program.command("config").description("View or edit configuration").option("-s, --show", "Show current configuration").option("-c, --clear", "Clear all configuration").option("--path", "Show config file path").option("--export", "Export configuration as .env format").option("--show-keys", "Show full API keys (use with caution)").option("--server <url>", "Set custom Trading MCP server URL").action(async (options) => {
4203
4219
  const config = getConfigManager();
4220
+ if (options.server) {
4221
+ try {
4222
+ new URL(options.server);
4223
+ } catch {
4224
+ error("Invalid URL format. Please provide a valid URL (e.g., https://your-server.com/mcp)");
4225
+ return;
4226
+ }
4227
+ config.set("mcpServerUrl", options.server);
4228
+ success(`Trading MCP server URL set to: ${options.server}`);
4229
+ return;
4230
+ }
4204
4231
  if (options.path) {
4205
4232
  console.log(config.getConfigPath());
4206
4233
  return;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@quantish/agent",
3
- "version": "0.1.5",
3
+ "version": "0.1.7",
4
4
  "description": "AI-powered agent for building trading bots on Polymarket",
5
5
  "type": "module",
6
6
  "bin": {