@quantish/agent 0.1.6 → 0.1.8
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/README.md +152 -140
- package/dist/index.js +57 -37
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,45 +1,19 @@
|
|
|
1
|
-
# @quantish/
|
|
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/
|
|
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/
|
|
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
|
|
71
|
-
Assistant: I'll create that for you. Let me first
|
|
72
|
-
[Calling
|
|
73
|
-
[Writing
|
|
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
|
|
50
|
+
Assistant: Your Safe wallet has 125.50 USDC available for trading.
|
|
77
51
|
|
|
78
|
-
You: Place a $
|
|
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
|
-
##
|
|
85
|
+
## Building Standalone Applications
|
|
116
86
|
|
|
117
|
-
|
|
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
|
-
|
|
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
|
-
|
|
91
|
+
There are two MCP endpoints:
|
|
140
92
|
|
|
141
|
-
|
|
|
142
|
-
|
|
143
|
-
|
|
|
144
|
-
|
|
|
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
|
-
|
|
98
|
+
### Trading API (Requires Your API Key)
|
|
155
99
|
|
|
156
|
-
|
|
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
|
-
|
|
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
|
-
|
|
167
|
-
|
|
168
|
-
|
|
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
|
-
|
|
140
|
+
**Discovery Tools:** `search_markets`, `get_market_details`, `get_trending_markets`, `find_arbitrage`
|
|
171
141
|
|
|
172
|
-
### Build
|
|
142
|
+
### Example: Ask the Agent to Build an App
|
|
173
143
|
|
|
174
144
|
```bash
|
|
175
145
|
quantish
|
|
176
|
-
> Create a
|
|
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
|
-
|
|
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
|
-
```
|
|
182
|
-
quantish
|
|
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
|
-
|
|
171
|
+
## Self-Hosting
|
|
186
172
|
|
|
187
|
-
|
|
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
|
-
###
|
|
175
|
+
### Configure Custom Server
|
|
193
176
|
|
|
194
177
|
```bash
|
|
195
|
-
|
|
196
|
-
|
|
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
|
-
|
|
185
|
+
### What You Need
|
|
200
186
|
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
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
|
-
|
|
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
|
-
|
|
210
|
-
npm run build
|
|
193
|
+
## Configuration
|
|
211
194
|
|
|
212
|
-
|
|
213
|
-
npm start
|
|
195
|
+
Configuration is stored in `~/.quantish/config.json`:
|
|
214
196
|
|
|
215
|
-
|
|
216
|
-
|
|
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
|
-
|
|
206
|
+
Environment variables take precedence:
|
|
207
|
+
- `ANTHROPIC_API_KEY`
|
|
208
|
+
- `QUANTISH_API_KEY`
|
|
209
|
+
- `MCP_SERVER_URL`
|
|
220
210
|
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
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
|
-
|
|
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
|
|
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
|
-
|
|
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
|
-
|
|
265
|
+
Quantish CLI connects to the **Quantish Signing Server** to execute trades on Polymarket:
|
|
257
266
|
|
|
258
|
-
|
|
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
|
@@ -27,7 +27,7 @@ var schema = {
|
|
|
27
27
|
},
|
|
28
28
|
model: {
|
|
29
29
|
type: "string",
|
|
30
|
-
default: "claude-sonnet-4-
|
|
30
|
+
default: "claude-sonnet-4-20250514"
|
|
31
31
|
}
|
|
32
32
|
};
|
|
33
33
|
var ConfigManager = class {
|
|
@@ -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,11 +101,17 @@ 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
|
*/
|
|
104
113
|
getModel() {
|
|
105
|
-
return this.conf.get("model") ?? "claude-sonnet-4-
|
|
114
|
+
return this.conf.get("model") ?? "claude-sonnet-4-20250514";
|
|
106
115
|
}
|
|
107
116
|
/**
|
|
108
117
|
* Set the model to use
|
|
@@ -2278,7 +2287,7 @@ function parseCompactedSummary(response) {
|
|
|
2278
2287
|
}
|
|
2279
2288
|
return response.trim() || null;
|
|
2280
2289
|
}
|
|
2281
|
-
async function createCompactedSummary(anthropic, history, model = "claude-sonnet-4-
|
|
2290
|
+
async function createCompactedSummary(anthropic, history, model = "claude-sonnet-4-20250514", customPrompt) {
|
|
2282
2291
|
const prompt2 = customPrompt || COMPACTION_PROMPT;
|
|
2283
2292
|
const compactionMessages = [
|
|
2284
2293
|
...history,
|
|
@@ -2322,7 +2331,7 @@ async function compactConversation(anthropic, history, model, systemPrompt, tool
|
|
|
2322
2331
|
const contentLength = JSON.stringify(history).length;
|
|
2323
2332
|
originalTokens = Math.ceil(contentLength / 4);
|
|
2324
2333
|
}
|
|
2325
|
-
const summaryModel = "claude-sonnet-4-
|
|
2334
|
+
const summaryModel = "claude-sonnet-4-20250514";
|
|
2326
2335
|
const summary = await createCompactedSummary(anthropic, history, summaryModel);
|
|
2327
2336
|
const newHistory = historyFromSummary(summary);
|
|
2328
2337
|
let newTokens = 0;
|
|
@@ -2348,25 +2357,25 @@ async function compactConversation(anthropic, history, model, systemPrompt, tool
|
|
|
2348
2357
|
|
|
2349
2358
|
// src/agent/pricing.ts
|
|
2350
2359
|
var MODELS = {
|
|
2351
|
-
"claude-opus-4-
|
|
2352
|
-
id: "claude-opus-4-
|
|
2353
|
-
name: "opus-4
|
|
2354
|
-
displayName: "Claude Opus 4
|
|
2360
|
+
"claude-opus-4-20250514": {
|
|
2361
|
+
id: "claude-opus-4-20250514",
|
|
2362
|
+
name: "opus-4",
|
|
2363
|
+
displayName: "Claude Opus 4",
|
|
2355
2364
|
pricing: {
|
|
2356
|
-
inputPerMTok:
|
|
2357
|
-
outputPerMTok:
|
|
2358
|
-
cacheWritePerMTok:
|
|
2365
|
+
inputPerMTok: 15,
|
|
2366
|
+
outputPerMTok: 75,
|
|
2367
|
+
cacheWritePerMTok: 18.75,
|
|
2359
2368
|
// 1.25x input
|
|
2360
|
-
cacheReadPerMTok:
|
|
2369
|
+
cacheReadPerMTok: 1.5
|
|
2361
2370
|
// 0.1x input
|
|
2362
2371
|
},
|
|
2363
2372
|
contextWindow: 2e5,
|
|
2364
2373
|
description: "Most capable model. Best for complex reasoning and creative tasks."
|
|
2365
2374
|
},
|
|
2366
|
-
"claude-sonnet-4-
|
|
2367
|
-
id: "claude-sonnet-4-
|
|
2368
|
-
name: "sonnet-4
|
|
2369
|
-
displayName: "Claude Sonnet 4
|
|
2375
|
+
"claude-sonnet-4-20250514": {
|
|
2376
|
+
id: "claude-sonnet-4-20250514",
|
|
2377
|
+
name: "sonnet-4",
|
|
2378
|
+
displayName: "Claude Sonnet 4",
|
|
2370
2379
|
pricing: {
|
|
2371
2380
|
inputPerMTok: 3,
|
|
2372
2381
|
outputPerMTok: 15,
|
|
@@ -2378,30 +2387,30 @@ var MODELS = {
|
|
|
2378
2387
|
contextWindow: 2e5,
|
|
2379
2388
|
description: "Balanced performance and cost. Great for most coding and trading tasks."
|
|
2380
2389
|
},
|
|
2381
|
-
"claude-
|
|
2382
|
-
id: "claude-
|
|
2383
|
-
name: "haiku-
|
|
2384
|
-
displayName: "Claude Haiku
|
|
2390
|
+
"claude-3-5-haiku-20241022": {
|
|
2391
|
+
id: "claude-3-5-haiku-20241022",
|
|
2392
|
+
name: "haiku-3.5",
|
|
2393
|
+
displayName: "Claude Haiku 3.5",
|
|
2385
2394
|
pricing: {
|
|
2386
|
-
inputPerMTok:
|
|
2387
|
-
outputPerMTok:
|
|
2388
|
-
cacheWritePerMTok: 1
|
|
2395
|
+
inputPerMTok: 0.8,
|
|
2396
|
+
outputPerMTok: 4,
|
|
2397
|
+
cacheWritePerMTok: 1,
|
|
2389
2398
|
// 1.25x input
|
|
2390
|
-
cacheReadPerMTok: 0.
|
|
2399
|
+
cacheReadPerMTok: 0.08
|
|
2391
2400
|
// 0.1x input
|
|
2392
2401
|
},
|
|
2393
2402
|
contextWindow: 2e5,
|
|
2394
2403
|
description: "Fastest and most economical. Good for simple tasks and high volume."
|
|
2395
2404
|
}
|
|
2396
2405
|
};
|
|
2397
|
-
var DEFAULT_MODEL = "claude-sonnet-4-
|
|
2406
|
+
var DEFAULT_MODEL = "claude-sonnet-4-20250514";
|
|
2398
2407
|
var MODEL_ALIASES = {
|
|
2399
|
-
"opus": "claude-opus-4-
|
|
2400
|
-
"opus-4
|
|
2401
|
-
"sonnet": "claude-sonnet-4-
|
|
2402
|
-
"sonnet-4
|
|
2403
|
-
"haiku": "claude-
|
|
2404
|
-
"haiku-
|
|
2408
|
+
"opus": "claude-opus-4-20250514",
|
|
2409
|
+
"opus-4": "claude-opus-4-20250514",
|
|
2410
|
+
"sonnet": "claude-sonnet-4-20250514",
|
|
2411
|
+
"sonnet-4": "claude-sonnet-4-20250514",
|
|
2412
|
+
"haiku": "claude-3-5-haiku-20241022",
|
|
2413
|
+
"haiku-3.5": "claude-3-5-haiku-20241022"
|
|
2405
2414
|
};
|
|
2406
2415
|
function resolveModelId(nameOrAlias) {
|
|
2407
2416
|
const lower = nameOrAlias.toLowerCase();
|
|
@@ -3174,7 +3183,7 @@ var Agent = class {
|
|
|
3174
3183
|
*/
|
|
3175
3184
|
async run(userMessage, options) {
|
|
3176
3185
|
const maxIterations = this.config.maxIterations ?? 15;
|
|
3177
|
-
const model = this.config.model ?? "claude-sonnet-4-
|
|
3186
|
+
const model = this.config.model ?? "claude-sonnet-4-20250514";
|
|
3178
3187
|
const maxTokens = this.config.maxTokens ?? 8192;
|
|
3179
3188
|
const systemPrompt = this.config.systemPrompt ?? DEFAULT_SYSTEM_PROMPT;
|
|
3180
3189
|
const useStreaming = this.config.streaming ?? true;
|
|
@@ -3434,7 +3443,7 @@ ${userMessage}`;
|
|
|
3434
3443
|
* Count tokens in current conversation (uses Anthropic's token counting API)
|
|
3435
3444
|
*/
|
|
3436
3445
|
async countTokens() {
|
|
3437
|
-
const model = this.config.model ?? "claude-sonnet-4-
|
|
3446
|
+
const model = this.config.model ?? "claude-sonnet-4-20250514";
|
|
3438
3447
|
const systemPrompt = this.config.systemPrompt ?? DEFAULT_SYSTEM_PROMPT;
|
|
3439
3448
|
const allTools = await this.getAllTools();
|
|
3440
3449
|
try {
|
|
@@ -3505,7 +3514,7 @@ ${userMessage}`;
|
|
|
3505
3514
|
* @returns Object with original/new token counts and the summary
|
|
3506
3515
|
*/
|
|
3507
3516
|
async compactHistory() {
|
|
3508
|
-
const model = this.config.model ?? "claude-sonnet-4-
|
|
3517
|
+
const model = this.config.model ?? "claude-sonnet-4-20250514";
|
|
3509
3518
|
const systemPrompt = this.config.systemPrompt ?? DEFAULT_SYSTEM_PROMPT;
|
|
3510
3519
|
const allTools = await this.getAllTools();
|
|
3511
3520
|
if (this.conversationHistory.length < 2) {
|
|
@@ -4206,8 +4215,19 @@ program.name("quantish").description("AI coding & trading agent for Polymarket")
|
|
|
4206
4215
|
program.command("init").description("Configure Quantish CLI with your API keys").action(async () => {
|
|
4207
4216
|
await runSetup();
|
|
4208
4217
|
});
|
|
4209
|
-
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) => {
|
|
4210
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
|
+
}
|
|
4211
4231
|
if (options.path) {
|
|
4212
4232
|
console.log(config.getConfigPath());
|
|
4213
4233
|
return;
|
|
@@ -4230,7 +4250,7 @@ program.command("config").description("View or edit configuration").option("-s,
|
|
|
4230
4250
|
console.log(`QUANTISH_API_KEY=${all2.quantishApiKey}`);
|
|
4231
4251
|
}
|
|
4232
4252
|
console.log(`QUANTISH_MCP_URL=${all2.mcpServerUrl}`);
|
|
4233
|
-
console.log(`QUANTISH_MODEL=${all2.model || "claude-sonnet-4-
|
|
4253
|
+
console.log(`QUANTISH_MODEL=${all2.model || "claude-sonnet-4-20250514"}`);
|
|
4234
4254
|
console.log();
|
|
4235
4255
|
console.log(chalk3.dim("# Discovery MCP (public, read-only market data)"));
|
|
4236
4256
|
console.log(`QUANTISH_DISCOVERY_URL=https://quantish.live/mcp`);
|
|
@@ -4251,7 +4271,7 @@ program.command("config").description("View or edit configuration").option("-s,
|
|
|
4251
4271
|
tableRow("Quantish API Key", all.quantishApiKey ? `${all.quantishApiKey.slice(0, 12)}...` : chalk3.dim("Not set"));
|
|
4252
4272
|
}
|
|
4253
4273
|
tableRow("MCP Server URL", all.mcpServerUrl);
|
|
4254
|
-
tableRow("Model", all.model || "claude-sonnet-4-
|
|
4274
|
+
tableRow("Model", all.model || "claude-sonnet-4-20250514");
|
|
4255
4275
|
printDivider();
|
|
4256
4276
|
console.log(chalk3.dim(`Config file: ${config.getConfigPath()}`));
|
|
4257
4277
|
console.log();
|