@quantish/agent 0.1.25 → 0.1.27
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 +137 -17
- package/README.md +181 -253
- package/dist/index.js +213 -29
- package/package.json +7 -3
package/LICENSE
CHANGED
|
@@ -1,24 +1,144 @@
|
|
|
1
|
-
|
|
1
|
+
# PolyForm Noncommercial License 1.0.0
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
<https://polyformproject.org/licenses/noncommercial/1.0.0>
|
|
4
4
|
|
|
5
|
-
|
|
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:
|
|
5
|
+
Required Notice: Copyright 2025 Quantish Inc. (https://quantish.live)
|
|
11
6
|
|
|
12
|
-
|
|
13
|
-
copies or substantial portions of the Software.
|
|
7
|
+
## Acceptance
|
|
14
8
|
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
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.
|
|
9
|
+
In order to get any license under these terms, you must agree
|
|
10
|
+
to them as both strict obligations and conditions to all
|
|
11
|
+
your licenses.
|
|
22
12
|
|
|
13
|
+
## Copyright License
|
|
23
14
|
|
|
15
|
+
The licensor grants you a copyright license for the software
|
|
16
|
+
to do everything you might do with the software that would
|
|
17
|
+
otherwise infringe the licensor's copyright in it for any
|
|
18
|
+
permitted purpose. However, you may only distribute the
|
|
19
|
+
software according to [Distribution License](#distribution-license)
|
|
20
|
+
and make changes or new works based on the software according
|
|
21
|
+
to [Changes and New Works License](#changes-and-new-works-license).
|
|
24
22
|
|
|
23
|
+
## Distribution License
|
|
24
|
+
|
|
25
|
+
The licensor grants you an additional copyright license to
|
|
26
|
+
distribute copies of the software. Your license to distribute
|
|
27
|
+
covers distributing the software with changes and new works
|
|
28
|
+
permitted by [Changes and New Works License](#changes-and-new-works-license).
|
|
29
|
+
|
|
30
|
+
## Notices
|
|
31
|
+
|
|
32
|
+
You must ensure that anyone who gets a copy of any part of
|
|
33
|
+
the software from you also gets a copy of these terms or the
|
|
34
|
+
URL for them above, as well as copies of any plain-text lines
|
|
35
|
+
beginning with `Required Notice:` that the licensor provided
|
|
36
|
+
with the software. For example:
|
|
37
|
+
|
|
38
|
+
> Required Notice: Copyright Yoyodyne, Inc. (http://example.com)
|
|
39
|
+
|
|
40
|
+
## Changes and New Works License
|
|
41
|
+
|
|
42
|
+
The licensor grants you an additional copyright license to
|
|
43
|
+
make changes and new works based on the software for any
|
|
44
|
+
permitted purpose.
|
|
45
|
+
|
|
46
|
+
## Patent License
|
|
47
|
+
|
|
48
|
+
The licensor grants you a patent license for the software that
|
|
49
|
+
covers patent claims the licensor can license, or becomes able
|
|
50
|
+
to license, that you would infringe by using the software.
|
|
51
|
+
|
|
52
|
+
## Noncommercial Purposes
|
|
53
|
+
|
|
54
|
+
Any noncommercial purpose is a permitted purpose.
|
|
55
|
+
|
|
56
|
+
## Personal Uses
|
|
57
|
+
|
|
58
|
+
Personal use for research, experiment, and testing for
|
|
59
|
+
the benefit of public knowledge, personal study, private
|
|
60
|
+
entertainment, hobby projects, amateur pursuits, or religious
|
|
61
|
+
observance, without any anticipated commercial application,
|
|
62
|
+
is use for a permitted purpose.
|
|
63
|
+
|
|
64
|
+
## Noncommercial Organizations
|
|
65
|
+
|
|
66
|
+
Use by any charitable organization, educational institution,
|
|
67
|
+
public research organization, public safety or health
|
|
68
|
+
organization, environmental protection organization, or
|
|
69
|
+
government institution is use for a permitted purpose
|
|
70
|
+
regardless of the source of funding or obligations resulting
|
|
71
|
+
from the funding.
|
|
72
|
+
|
|
73
|
+
## Fair Use
|
|
74
|
+
|
|
75
|
+
You may have "fair use" rights for the software under the
|
|
76
|
+
law. These terms do not limit them.
|
|
77
|
+
|
|
78
|
+
## No Other Rights
|
|
79
|
+
|
|
80
|
+
These terms do not allow you to sublicense or transfer any
|
|
81
|
+
of your licenses to anyone else, or prevent the licensor
|
|
82
|
+
from granting licenses to anyone else. These terms do not
|
|
83
|
+
imply any other licenses.
|
|
84
|
+
|
|
85
|
+
## Patent Defense
|
|
86
|
+
|
|
87
|
+
If you make any written claim that the software infringes
|
|
88
|
+
or contributes to infringement of any patent, your patent
|
|
89
|
+
license for the software granted under these terms ends
|
|
90
|
+
immediately. If your company makes such a claim, your
|
|
91
|
+
patent license ends immediately for work on behalf of your
|
|
92
|
+
company.
|
|
93
|
+
|
|
94
|
+
## Violations
|
|
95
|
+
|
|
96
|
+
The first time you are notified in writing that you have
|
|
97
|
+
violated any of these terms, or done anything with the
|
|
98
|
+
software not covered by your licenses, your licenses can
|
|
99
|
+
nonetheless continue if you come into full compliance with
|
|
100
|
+
these terms, and take practical steps to correct past
|
|
101
|
+
violations, within 32 days of receiving notice. Otherwise,
|
|
102
|
+
all your licenses end immediately.
|
|
103
|
+
|
|
104
|
+
## No Liability
|
|
105
|
+
|
|
106
|
+
***As far as the law allows, the software comes as is,
|
|
107
|
+
without any warranty or condition, and the licensor will
|
|
108
|
+
not be liable to you for any damages arising out of these
|
|
109
|
+
terms or the use or nature of the software, under any kind
|
|
110
|
+
of legal claim.***
|
|
111
|
+
|
|
112
|
+
## Definitions
|
|
113
|
+
|
|
114
|
+
The **licensor** is the individual or entity offering these
|
|
115
|
+
terms, and the **software** is the software the licensor
|
|
116
|
+
makes available under these terms.
|
|
117
|
+
|
|
118
|
+
**You** refers to the individual or entity agreeing to these
|
|
119
|
+
terms.
|
|
120
|
+
|
|
121
|
+
**Your company** is any legal entity, sole proprietorship,
|
|
122
|
+
or other kind of organization that you work for, plus all
|
|
123
|
+
organizations that have control over, are under the control
|
|
124
|
+
of, or are under common control with that organization.
|
|
125
|
+
**Control** means ownership of substantially all the assets
|
|
126
|
+
of an entity, or the power to direct its management and
|
|
127
|
+
policies by vote, contract, or otherwise. Control can be
|
|
128
|
+
direct or indirect.
|
|
129
|
+
|
|
130
|
+
**Your licenses** are all the licenses granted to you for
|
|
131
|
+
the software under these terms.
|
|
132
|
+
|
|
133
|
+
**Use** means anything you do with the software requiring
|
|
134
|
+
one of your licenses.
|
|
135
|
+
|
|
136
|
+
---
|
|
137
|
+
|
|
138
|
+
## Commercial Licensing
|
|
139
|
+
|
|
140
|
+
For commercial use or to monetize this software as a product,
|
|
141
|
+
please contact Quantish Inc. for a commercial license:
|
|
142
|
+
|
|
143
|
+
Email: hello@quantish.live
|
|
144
|
+
Website: https://quantish.live
|
package/README.md
CHANGED
|
@@ -1,16 +1,8 @@
|
|
|
1
1
|
# @quantish/agent
|
|
2
2
|
|
|
3
|
-
AI-powered
|
|
3
|
+
AI-powered CLI agent for building trading bots and applications on Polymarket.
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
- **🤖 Multi-Provider AI** - Use Anthropic Claude or 100+ OpenRouter models (GLM-4.7, MiniMax, DeepSeek, etc.)
|
|
8
|
-
- **💹 Live Trading** - Place orders, manage positions, check balances on Polymarket
|
|
9
|
-
- **🔧 Full Coding Tools** - Read/write files, run commands, git operations
|
|
10
|
-
- **🌐 Web Search** - Search the web with Exa AI or DuckDuckGo fallback
|
|
11
|
-
- **💾 Session Persistence** - Save and resume conversations across sessions
|
|
12
|
-
- **⚡ Queued Input** - Type while the agent is working, queue messages
|
|
13
|
-
- **📊 Cost Tracking** - Real-time token usage and cost display
|
|
5
|
+
Combines **coding tools** (file system, shell, git) with **trading tools** (Polymarket orders, positions, wallet) powered by Claude AI.
|
|
14
6
|
|
|
15
7
|
## Installation
|
|
16
8
|
|
|
@@ -18,329 +10,265 @@ AI-powered coding & trading agent for Polymarket. Build trading bots, analyze ma
|
|
|
18
10
|
npm install -g @quantish/agent
|
|
19
11
|
```
|
|
20
12
|
|
|
21
|
-
|
|
13
|
+
Or run directly with npx:
|
|
22
14
|
|
|
23
15
|
```bash
|
|
24
|
-
|
|
25
|
-
quantish init
|
|
26
|
-
|
|
27
|
-
# Start interactive chat
|
|
28
|
-
quantish
|
|
16
|
+
npx @quantish/agent
|
|
29
17
|
```
|
|
30
18
|
|
|
31
|
-
##
|
|
32
|
-
|
|
33
|
-
The agent connects to two MCP (Model Context Protocol) servers:
|
|
34
|
-
|
|
35
|
-
1. **Discovery MCP** (Public) - Market search, trending markets, market details
|
|
36
|
-
2. **Trading MCP** (Your API Key) - Wallet, orders, positions, trades
|
|
37
|
-
|
|
38
|
-
Your wallet is created and managed through our signing server, which:
|
|
39
|
-
- ✅ Handles gasless transactions (Polymarket covers fees)
|
|
40
|
-
- ✅ Signs orders using Polymarket's required format
|
|
41
|
-
- ✅ Works globally (no geo-restrictions)
|
|
42
|
-
- 🔒 Non-custodial - export your private key anytime
|
|
43
|
-
|
|
44
|
-
## Interactive Commands
|
|
45
|
-
|
|
46
|
-
### Chat Commands
|
|
47
|
-
|
|
48
|
-
| Command | Description |
|
|
49
|
-
|---------|-------------|
|
|
50
|
-
| `/help` | Show all commands |
|
|
51
|
-
| `/clear` | Clear conversation history |
|
|
52
|
-
| `/compact` | Summarize conversation to save tokens |
|
|
53
|
-
| `/model <name>` | Switch model (opus, sonnet, haiku, glm, minimax, etc.) |
|
|
54
|
-
| `/provider <name>` | Switch LLM provider (anthropic, openrouter) |
|
|
55
|
-
| `/cost` | Show session cost breakdown |
|
|
56
|
-
| `/tools` | List available tools |
|
|
57
|
-
| `/config` | Show configuration info |
|
|
58
|
-
|
|
59
|
-
### Session Commands
|
|
60
|
-
|
|
61
|
-
| Command | Description |
|
|
62
|
-
|---------|-------------|
|
|
63
|
-
| `/save [name]` | Save current session |
|
|
64
|
-
| `/resume` | Resume last session |
|
|
65
|
-
| `/sessions` | List all saved sessions |
|
|
66
|
-
| `/load <id>` | Load a session by ID |
|
|
67
|
-
| `/forget` | Delete all saved sessions |
|
|
68
|
-
|
|
69
|
-
### Process Commands
|
|
70
|
-
|
|
71
|
-
| Command | Description |
|
|
72
|
-
|---------|-------------|
|
|
73
|
-
| `/processes` | List running background processes |
|
|
74
|
-
| `/stop <id>` | Stop a background process |
|
|
75
|
-
| `/stopall` | Stop all background processes |
|
|
76
|
-
|
|
77
|
-
### Keyboard Shortcuts
|
|
19
|
+
## Quick Start
|
|
78
20
|
|
|
79
|
-
|
|
80
|
-
|-----|--------|
|
|
81
|
-
| `Enter` | Send message (or queue if agent is working) |
|
|
82
|
-
| `Esc` | Interrupt current generation |
|
|
83
|
-
| `Ctrl+C` | Exit CLI |
|
|
21
|
+
### 1. Initialize
|
|
84
22
|
|
|
85
|
-
|
|
23
|
+
Set up your API keys:
|
|
86
24
|
|
|
87
25
|
```bash
|
|
88
|
-
quantish
|
|
89
|
-
quantish init # First-time setup wizard
|
|
90
|
-
quantish config # View configuration
|
|
91
|
-
quantish config --export # Export as .env format
|
|
92
|
-
quantish tools # List all available tools
|
|
93
|
-
quantish -p "message" # One-shot mode
|
|
94
|
-
quantish --version # Show version
|
|
26
|
+
quantish init
|
|
95
27
|
```
|
|
96
28
|
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
| `-v, --verbose` | Show detailed tool calls |
|
|
101
|
-
| `--no-mcp` | Disable trading tools |
|
|
102
|
-
| `--no-local` | Disable coding tools |
|
|
103
|
-
|
|
104
|
-
## Available Tools
|
|
105
|
-
|
|
106
|
-
### Local Tools (Coding)
|
|
107
|
-
|
|
108
|
-
| Tool | Description |
|
|
109
|
-
|------|-------------|
|
|
110
|
-
| `read_file` | Read file contents with line numbers |
|
|
111
|
-
| `write_file` | Create or overwrite files |
|
|
112
|
-
| `edit_file` | Search and replace in files |
|
|
113
|
-
| `edit_lines` | Edit specific line ranges (efficient) |
|
|
114
|
-
| `list_dir` | List directory contents |
|
|
115
|
-
| `delete_file` | Delete files |
|
|
116
|
-
| `file_exists` | Check if file exists |
|
|
117
|
-
| `run_command` | Execute shell commands (blocking) |
|
|
118
|
-
| `start_background_process` | Run long-running processes |
|
|
119
|
-
| `get_process_output` | Get output from background process |
|
|
120
|
-
| `stop_process` | Stop a background process |
|
|
121
|
-
| `grep` | Search file contents |
|
|
122
|
-
| `find_files` | Find files by pattern |
|
|
123
|
-
| `setup_env` | Create/update .env files |
|
|
124
|
-
|
|
125
|
-
### Git Tools
|
|
126
|
-
|
|
127
|
-
| Tool | Description |
|
|
128
|
-
|------|-------------|
|
|
129
|
-
| `git_status` | Get repository status |
|
|
130
|
-
| `git_diff` | Show changes |
|
|
131
|
-
| `git_add` | Stage files |
|
|
132
|
-
| `git_commit` | Create commits |
|
|
133
|
-
| `git_log` | Show commit history |
|
|
134
|
-
| `git_checkout` | Switch branches |
|
|
135
|
-
|
|
136
|
-
### Web Tools
|
|
137
|
-
|
|
138
|
-
| Tool | Description |
|
|
139
|
-
|------|-------------|
|
|
140
|
-
| `web_search` | Search the web (Exa/DuckDuckGo) |
|
|
141
|
-
| `web_answer` | AI-powered Q&A (requires Exa API key) |
|
|
142
|
-
| `fetch_url` | Fetch URL content |
|
|
143
|
-
|
|
144
|
-
### MCP Tools (Trading)
|
|
145
|
-
|
|
146
|
-
| Tool | Server | Description |
|
|
147
|
-
|------|--------|-------------|
|
|
148
|
-
| `search_markets` | Discovery | Search markets by query |
|
|
149
|
-
| `get_trending_markets` | Discovery | Get trending/popular markets |
|
|
150
|
-
| `get_market_details` | Discovery | Get market info and prices |
|
|
151
|
-
| `get_balances` | Trading | Check wallet balances |
|
|
152
|
-
| `get_positions` | Trading | View current positions |
|
|
153
|
-
| `place_order` | Trading | Place buy/sell orders |
|
|
154
|
-
| `cancel_order` | Trading | Cancel open orders |
|
|
155
|
-
| `get_orders` | Trading | List orders |
|
|
156
|
-
| `get_orderbook` | Trading | Get market orderbook |
|
|
157
|
-
| `get_price` | Trading | Get current price |
|
|
158
|
-
| `transfer_usdc` | Trading | Transfer USDC |
|
|
159
|
-
| `claim_winnings` | Trading | Claim from resolved markets |
|
|
160
|
-
| `export_private_key` | Trading | Export wallet private key |
|
|
29
|
+
You'll need:
|
|
30
|
+
- **Anthropic API Key** - Get one at https://console.anthropic.com/
|
|
31
|
+
- **Quantish API Key** - Created automatically during setup
|
|
161
32
|
|
|
162
|
-
|
|
33
|
+
### 2. Start Building
|
|
163
34
|
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
Uses Claude models directly via Anthropic API.
|
|
35
|
+
**Interactive mode:**
|
|
167
36
|
|
|
168
37
|
```bash
|
|
169
|
-
|
|
170
|
-
/model sonnet # Claude Sonnet 4.5 - Balanced (default)
|
|
171
|
-
/model haiku # Claude Haiku 4.5 - Fastest/cheapest
|
|
38
|
+
quantish
|
|
172
39
|
```
|
|
173
40
|
|
|
174
|
-
|
|
41
|
+
Example conversations:
|
|
175
42
|
|
|
176
|
-
|
|
43
|
+
```
|
|
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...]
|
|
177
48
|
|
|
178
|
-
|
|
179
|
-
|
|
49
|
+
You: What's my current balance?
|
|
50
|
+
Assistant: Your Safe wallet has 125.50 USDC available for trading.
|
|
180
51
|
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
/model deepseek # DeepSeek V3.2 - Great reasoning
|
|
184
|
-
/model gemini # Gemini 2.0 Flash - Google's latest
|
|
185
|
-
/model grok # Grok 3 Mini Beta - xAI
|
|
52
|
+
You: Place a $10 YES order on Trump winning at 55 cents
|
|
53
|
+
Assistant: Order placed! Order ID: abc123...
|
|
186
54
|
```
|
|
187
55
|
|
|
188
|
-
|
|
56
|
+
**One-shot mode:**
|
|
57
|
+
|
|
189
58
|
```bash
|
|
190
|
-
|
|
191
|
-
/model meta-llama/llama-3.3-70b-instruct
|
|
59
|
+
quantish -p "check my open orders"
|
|
192
60
|
```
|
|
193
61
|
|
|
194
|
-
##
|
|
62
|
+
## Commands
|
|
195
63
|
|
|
196
|
-
|
|
64
|
+
| Command | Description |
|
|
65
|
+
|---------|-------------|
|
|
66
|
+
| `quantish` | Start interactive chat |
|
|
67
|
+
| `quantish init` | Configure API keys |
|
|
68
|
+
| `quantish config` | View configuration |
|
|
69
|
+
| `quantish config --server <url>` | Set custom MCP server URL |
|
|
70
|
+
| `quantish config --export` | Export keys for standalone apps |
|
|
71
|
+
| `quantish tools` | List available tools |
|
|
72
|
+
| `quantish -p "..."` | Run one-shot prompt |
|
|
197
73
|
|
|
198
|
-
|
|
74
|
+
## Options
|
|
199
75
|
|
|
200
|
-
|
|
|
201
|
-
|
|
202
|
-
|
|
|
203
|
-
| `
|
|
204
|
-
| `
|
|
205
|
-
| `
|
|
206
|
-
| `
|
|
76
|
+
| Option | Description |
|
|
77
|
+
|--------|-------------|
|
|
78
|
+
| `-p, --prompt <message>` | Run a single prompt |
|
|
79
|
+
| `-v, --verbose` | Show tool calls |
|
|
80
|
+
| `--no-mcp` | Disable trading tools |
|
|
81
|
+
| `--no-local` | Disable coding tools |
|
|
82
|
+
| `--version` | Show version |
|
|
83
|
+
| `--help` | Show help |
|
|
207
84
|
|
|
208
|
-
|
|
85
|
+
## Building Standalone Applications
|
|
209
86
|
|
|
210
|
-
|
|
211
|
-
quantish config --export > .env
|
|
212
|
-
```
|
|
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.
|
|
213
88
|
|
|
214
|
-
|
|
89
|
+
### MCP API Overview
|
|
215
90
|
|
|
216
|
-
|
|
91
|
+
There are two MCP endpoints:
|
|
217
92
|
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
- Trading: `https://quantish-sdk-production.up.railway.app/mcp/execute` (requires API key)
|
|
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) |
|
|
223
97
|
|
|
224
|
-
|
|
98
|
+
### Trading API (Requires Your API Key)
|
|
225
99
|
|
|
226
100
|
```javascript
|
|
227
|
-
|
|
228
|
-
const response = await fetch('https://quantish.live/mcp/execute', {
|
|
101
|
+
const response = await fetch('https://quantish-sdk-production.up.railway.app/mcp/execute', {
|
|
229
102
|
method: 'POST',
|
|
230
103
|
headers: {
|
|
231
104
|
'Content-Type': 'application/json',
|
|
232
|
-
'
|
|
105
|
+
'x-api-key': process.env.QUANTISH_API_KEY
|
|
233
106
|
},
|
|
234
107
|
body: JSON.stringify({
|
|
235
|
-
|
|
236
|
-
|
|
108
|
+
jsonrpc: '2.0',
|
|
109
|
+
method: 'tools/call',
|
|
110
|
+
params: { name: 'get_balances', arguments: {} },
|
|
111
|
+
id: Date.now()
|
|
237
112
|
})
|
|
238
113
|
});
|
|
239
114
|
|
|
240
|
-
|
|
241
|
-
const
|
|
115
|
+
const data = await response.json();
|
|
116
|
+
const result = JSON.parse(data.result.content[0].text);
|
|
117
|
+
```
|
|
118
|
+
|
|
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', {
|
|
242
125
|
method: 'POST',
|
|
243
126
|
headers: {
|
|
244
127
|
'Content-Type': 'application/json',
|
|
245
|
-
'X-API-Key':
|
|
128
|
+
'X-API-Key': 'qm_ueQeqrmvZyHtR1zuVbLYkhx0fKyVAuV8' // Public key
|
|
246
129
|
},
|
|
247
130
|
body: JSON.stringify({
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
method: 'tools/call',
|
|
251
|
-
params: {
|
|
252
|
-
name: 'get_positions',
|
|
253
|
-
arguments: {}
|
|
254
|
-
}
|
|
131
|
+
name: 'search_markets', // Simple format for Discovery
|
|
132
|
+
arguments: { query: 'bitcoin', limit: 5 }
|
|
255
133
|
})
|
|
256
134
|
});
|
|
135
|
+
|
|
136
|
+
const data = await response.json();
|
|
137
|
+
const result = JSON.parse(data.result.content[0].text);
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
**Discovery Tools:** `search_markets`, `get_market_details`, `get_trending_markets`, `find_arbitrage`
|
|
141
|
+
|
|
142
|
+
### Example: Ask the Agent to Build an App
|
|
143
|
+
|
|
144
|
+
```bash
|
|
145
|
+
quantish
|
|
146
|
+
> Create a Node.js script that monitors Bitcoin markets and sends a Discord notification when prices move more than 10%
|
|
147
|
+
```
|
|
148
|
+
|
|
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
|
|
156
|
+
|
|
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
|
|
257
169
|
```
|
|
258
170
|
|
|
259
171
|
## Self-Hosting
|
|
260
172
|
|
|
261
|
-
You can
|
|
173
|
+
You can run your own Trading MCP server for full control over your wallet keys.
|
|
174
|
+
|
|
175
|
+
### Configure Custom Server
|
|
262
176
|
|
|
263
177
|
```bash
|
|
264
|
-
# Set
|
|
178
|
+
# Set via CLI
|
|
265
179
|
quantish config --server https://your-server.com/mcp
|
|
266
180
|
|
|
267
|
-
# Or
|
|
181
|
+
# Or via environment variable
|
|
268
182
|
export MCP_SERVER_URL=https://your-server.com/mcp
|
|
269
183
|
```
|
|
270
184
|
|
|
271
|
-
|
|
185
|
+
### What You Need
|
|
272
186
|
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
| Linux | ✅ Full support |
|
|
277
|
-
| Windows | ⚠️ Requires WSL |
|
|
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
|
|
278
190
|
|
|
279
|
-
|
|
191
|
+
See [Self-Hosting Guide](https://quantish.live/docs/self-hosting.html) for full instructions.
|
|
280
192
|
|
|
281
|
-
|
|
282
|
-
# Search for markets
|
|
283
|
-
quantish -p "find markets about bitcoin"
|
|
193
|
+
## Configuration
|
|
284
194
|
|
|
285
|
-
|
|
286
|
-
quantish -p "show my positions with P&L"
|
|
195
|
+
Configuration is stored in `~/.quantish/config.json`:
|
|
287
196
|
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
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
|
+
}
|
|
204
|
+
```
|
|
291
205
|
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
206
|
+
Environment variables take precedence:
|
|
207
|
+
- `ANTHROPIC_API_KEY`
|
|
208
|
+
- `QUANTISH_API_KEY`
|
|
209
|
+
- `MCP_SERVER_URL`
|
|
295
210
|
|
|
296
|
-
|
|
297
|
-
quantish
|
|
298
|
-
> Review my trading bot code and suggest improvements
|
|
299
|
-
```
|
|
211
|
+
## Available Tools
|
|
300
212
|
|
|
301
|
-
|
|
213
|
+
### Local Tools (Coding)
|
|
302
214
|
|
|
303
|
-
|
|
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 |
|
|
304
230
|
|
|
305
|
-
|
|
231
|
+
### MCP Tools (Trading)
|
|
306
232
|
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
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 |
|
|
310
243
|
|
|
311
|
-
###
|
|
244
|
+
### MCP Tools (Discovery)
|
|
312
245
|
|
|
313
|
-
|
|
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 |
|
|
314
252
|
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
253
|
+
## Platform Support
|
|
254
|
+
|
|
255
|
+
| Platform | Support |
|
|
256
|
+
|----------|---------|
|
|
257
|
+
| macOS | ✅ Full support |
|
|
258
|
+
| Linux | ✅ Full support |
|
|
259
|
+
| Windows | ⚠️ Requires WSL |
|
|
318
260
|
|
|
319
|
-
|
|
261
|
+
**Windows users:** Install [WSL](https://learn.microsoft.com/en-us/windows/wsl/install) and run Quantish from within WSL.
|
|
320
262
|
|
|
321
|
-
|
|
322
|
-
/compact # Summarize conversation
|
|
323
|
-
/model haiku # Switch to cheaper model
|
|
324
|
-
/clear # Start fresh
|
|
325
|
-
```
|
|
263
|
+
## How It Works
|
|
326
264
|
|
|
327
|
-
|
|
265
|
+
Quantish CLI connects to the **Quantish Signing Server** to execute trades on Polymarket:
|
|
328
266
|
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
npm run build
|
|
334
|
-
npm link # Install locally
|
|
335
|
-
```
|
|
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
|
|
336
271
|
|
|
337
272
|
## License
|
|
338
273
|
|
|
339
274
|
MIT
|
|
340
|
-
|
|
341
|
-
## Links
|
|
342
|
-
|
|
343
|
-
- [GitHub](https://github.com/joinQuantish/quantish-agent)
|
|
344
|
-
- [NPM](https://www.npmjs.com/package/@quantish/agent)
|
|
345
|
-
- [Documentation](https://docs.quantish.live)
|
|
346
|
-
- [Quantish Platform](https://quantish.live)
|
package/dist/index.js
CHANGED
|
@@ -13,6 +13,7 @@ import { join } from "path";
|
|
|
13
13
|
var DEFAULT_TRADING_MCP_URL = "https://quantish-sdk-production.up.railway.app/mcp";
|
|
14
14
|
var DISCOVERY_MCP_URL = "https://quantish.live/mcp";
|
|
15
15
|
var DISCOVERY_MCP_PUBLIC_KEY = "qm_ueQeqrmvZyHtR1zuVbLYkhx0fKyVAuV8";
|
|
16
|
+
var KALSHI_MCP_URL = "https://kalshi-mcp-production-7c2c.up.railway.app/mcp";
|
|
16
17
|
var DEFAULT_MCP_URL = DEFAULT_TRADING_MCP_URL;
|
|
17
18
|
var DEFAULT_ANTHROPIC_MODEL = "claude-sonnet-4-5-20250929";
|
|
18
19
|
var DEFAULT_OPENROUTER_MODEL = "z-ai/glm-4.7";
|
|
@@ -26,6 +27,9 @@ var schema = {
|
|
|
26
27
|
quantishApiKey: {
|
|
27
28
|
type: "string"
|
|
28
29
|
},
|
|
30
|
+
kalshiApiKey: {
|
|
31
|
+
type: "string"
|
|
32
|
+
},
|
|
29
33
|
mcpServerUrl: {
|
|
30
34
|
type: "string",
|
|
31
35
|
default: DEFAULT_MCP_URL
|
|
@@ -91,6 +95,20 @@ var ConfigManager = class {
|
|
|
91
95
|
setQuantishApiKey(key) {
|
|
92
96
|
this.conf.set("quantishApiKey", key);
|
|
93
97
|
}
|
|
98
|
+
/**
|
|
99
|
+
* Get the Kalshi API key
|
|
100
|
+
*/
|
|
101
|
+
getKalshiApiKey() {
|
|
102
|
+
const envKey = process.env.KALSHI_API_KEY;
|
|
103
|
+
if (envKey) return envKey;
|
|
104
|
+
return this.conf.get("kalshiApiKey");
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* Set the Kalshi API key
|
|
108
|
+
*/
|
|
109
|
+
setKalshiApiKey(key) {
|
|
110
|
+
this.conf.set("kalshiApiKey", key);
|
|
111
|
+
}
|
|
94
112
|
/**
|
|
95
113
|
* Get the current LLM provider
|
|
96
114
|
*/
|
|
@@ -382,18 +400,26 @@ function createMCPClient(baseUrl, apiKey, source = "trading") {
|
|
|
382
400
|
var MCPClientManager = class {
|
|
383
401
|
discoveryClient;
|
|
384
402
|
tradingClient;
|
|
403
|
+
kalshiClient;
|
|
385
404
|
toolSourceMap = /* @__PURE__ */ new Map();
|
|
386
405
|
allToolsCache = null;
|
|
387
|
-
constructor(discoveryUrl, discoveryApiKey, tradingUrl, tradingApiKey) {
|
|
406
|
+
constructor(discoveryUrl, discoveryApiKey, tradingUrl, tradingApiKey, kalshiUrl, kalshiApiKey) {
|
|
388
407
|
this.discoveryClient = new MCPClient(discoveryUrl, discoveryApiKey, "discovery");
|
|
389
408
|
this.tradingClient = tradingUrl && tradingApiKey ? new MCPClient(tradingUrl, tradingApiKey, "trading") : null;
|
|
409
|
+
this.kalshiClient = kalshiUrl && kalshiApiKey ? new MCPClient(kalshiUrl, kalshiApiKey, "kalshi") : null;
|
|
390
410
|
}
|
|
391
411
|
/**
|
|
392
|
-
* Check if trading is enabled
|
|
412
|
+
* Check if trading is enabled (Polymarket)
|
|
393
413
|
*/
|
|
394
414
|
isTradingEnabled() {
|
|
395
415
|
return this.tradingClient !== null;
|
|
396
416
|
}
|
|
417
|
+
/**
|
|
418
|
+
* Check if Kalshi trading is enabled
|
|
419
|
+
*/
|
|
420
|
+
isKalshiEnabled() {
|
|
421
|
+
return this.kalshiClient !== null;
|
|
422
|
+
}
|
|
397
423
|
/**
|
|
398
424
|
* Get the discovery client
|
|
399
425
|
*/
|
|
@@ -406,6 +432,12 @@ var MCPClientManager = class {
|
|
|
406
432
|
getTradingClient() {
|
|
407
433
|
return this.tradingClient;
|
|
408
434
|
}
|
|
435
|
+
/**
|
|
436
|
+
* Get the Kalshi client (may be null)
|
|
437
|
+
*/
|
|
438
|
+
getKalshiClient() {
|
|
439
|
+
return this.kalshiClient;
|
|
440
|
+
}
|
|
409
441
|
/**
|
|
410
442
|
* List all tools from both servers
|
|
411
443
|
*/
|
|
@@ -435,6 +467,17 @@ var MCPClientManager = class {
|
|
|
435
467
|
console.warn("Failed to fetch Trading MCP tools:", error2);
|
|
436
468
|
}
|
|
437
469
|
}
|
|
470
|
+
if (this.kalshiClient) {
|
|
471
|
+
try {
|
|
472
|
+
const kalshiTools = await this.kalshiClient.listTools();
|
|
473
|
+
for (const tool of kalshiTools) {
|
|
474
|
+
allTools.push({ ...tool, source: "kalshi" });
|
|
475
|
+
this.toolSourceMap.set(tool.name, "kalshi");
|
|
476
|
+
}
|
|
477
|
+
} catch (error2) {
|
|
478
|
+
console.warn("Failed to fetch Kalshi MCP tools:", error2);
|
|
479
|
+
}
|
|
480
|
+
}
|
|
438
481
|
this.allToolsCache = allTools;
|
|
439
482
|
return allTools;
|
|
440
483
|
}
|
|
@@ -466,12 +509,22 @@ var MCPClientManager = class {
|
|
|
466
509
|
if (!this.tradingClient) {
|
|
467
510
|
return {
|
|
468
511
|
success: false,
|
|
469
|
-
error: `
|
|
512
|
+
error: `Polymarket trading not enabled. Run 'quantish init' to set up trading.`
|
|
470
513
|
};
|
|
471
514
|
}
|
|
472
515
|
const result = await this.tradingClient.callTool(name, args);
|
|
473
516
|
return { ...result, source: "trading" };
|
|
474
517
|
}
|
|
518
|
+
if (source === "kalshi") {
|
|
519
|
+
if (!this.kalshiClient) {
|
|
520
|
+
return {
|
|
521
|
+
success: false,
|
|
522
|
+
error: `Kalshi trading not enabled. Run 'quantish init' to set up your Kalshi API key.`
|
|
523
|
+
};
|
|
524
|
+
}
|
|
525
|
+
const result = await this.kalshiClient.callTool(name, args);
|
|
526
|
+
return { ...result, source: "kalshi" };
|
|
527
|
+
}
|
|
475
528
|
return {
|
|
476
529
|
success: false,
|
|
477
530
|
error: `Unknown tool source: ${source}`
|
|
@@ -495,8 +548,8 @@ var MCPClientManager = class {
|
|
|
495
548
|
return { discovery, trading };
|
|
496
549
|
}
|
|
497
550
|
};
|
|
498
|
-
function createMCPClientManager(discoveryUrl, discoveryApiKey, tradingUrl, tradingApiKey) {
|
|
499
|
-
return new MCPClientManager(discoveryUrl, discoveryApiKey, tradingUrl, tradingApiKey);
|
|
551
|
+
function createMCPClientManager(discoveryUrl, discoveryApiKey, tradingUrl, tradingApiKey, kalshiUrl, kalshiApiKey) {
|
|
552
|
+
return new MCPClientManager(discoveryUrl, discoveryApiKey, tradingUrl, tradingApiKey, kalshiUrl, kalshiApiKey);
|
|
500
553
|
}
|
|
501
554
|
|
|
502
555
|
// src/mcp/tools.ts
|
|
@@ -528,25 +581,28 @@ function printArchitectureInfo() {
|
|
|
528
581
|
console.log(chalk.bold.yellow("\n\u{1F4CB} How Quantish Works\n"));
|
|
529
582
|
console.log(chalk.dim("\u2500".repeat(60)));
|
|
530
583
|
console.log();
|
|
531
|
-
console.log(chalk.bold("
|
|
584
|
+
console.log(chalk.bold("Three Capabilities:"));
|
|
532
585
|
console.log();
|
|
533
586
|
console.log(chalk.cyan("\u{1F50D} Market Discovery") + chalk.dim(" (Free, always available)"));
|
|
534
587
|
console.log(chalk.dim(" Search markets across Polymarket, Kalshi, and more"));
|
|
535
588
|
console.log(chalk.dim(" Uses our Discovery MCP with embedded public key"));
|
|
536
589
|
console.log();
|
|
537
590
|
console.log(chalk.magenta("\u{1F4B0} Polymarket Trading") + chalk.dim(" (Optional, your own wallet)"));
|
|
538
|
-
console.log(chalk.dim(" Trade on Polymarket with a managed wallet"));
|
|
591
|
+
console.log(chalk.dim(" Trade on Polymarket with a managed Polygon wallet"));
|
|
539
592
|
console.log(chalk.dim(" Uses the Quantish Signing Server"));
|
|
540
593
|
console.log();
|
|
594
|
+
console.log(chalk.blue("\u{1F5F3}\uFE0F Kalshi Trading") + chalk.dim(" (Optional, via DFlow on Solana)"));
|
|
595
|
+
console.log(chalk.dim(" Trade on Kalshi markets via DFlow protocol"));
|
|
596
|
+
console.log(chalk.dim(" Uses a Solana wallet managed by the Kalshi MCP"));
|
|
597
|
+
console.log();
|
|
541
598
|
console.log(chalk.bold("How Trading Works:"));
|
|
542
|
-
console.log(chalk.dim("
|
|
543
|
-
console.log(chalk.dim("
|
|
544
|
-
console.log(chalk.dim("
|
|
545
|
-
console.log(chalk.dim(" 4. You control your wallet via your personal API key\n"));
|
|
599
|
+
console.log(chalk.dim(" Polymarket: Gasless transactions on Polygon, fees covered"));
|
|
600
|
+
console.log(chalk.dim(" Kalshi: Trade on Solana via DFlow, small SOL fees"));
|
|
601
|
+
console.log(chalk.dim(" Both: Non-custodial wallets, export keys anytime\n"));
|
|
546
602
|
console.log(chalk.bold("Security:"));
|
|
547
|
-
console.log(chalk.dim(" \u2022 Your
|
|
603
|
+
console.log(chalk.dim(" \u2022 Your wallets are non-custodial - only you can authorize trades"));
|
|
548
604
|
console.log(chalk.dim(" \u2022 Export your private key anytime with: ") + chalk.cyan("export_private_key"));
|
|
549
|
-
console.log(chalk.dim(" \u2022 Discovery is read-only - it can't access your
|
|
605
|
+
console.log(chalk.dim(" \u2022 Discovery is read-only - it can't access your wallets"));
|
|
550
606
|
console.log();
|
|
551
607
|
console.log(chalk.dim("\u2500".repeat(60)));
|
|
552
608
|
console.log();
|
|
@@ -693,7 +749,73 @@ async function runSetup() {
|
|
|
693
749
|
} else {
|
|
694
750
|
console.log(chalk.dim("\u2713 No trading key - you can still search markets via Discovery\n"));
|
|
695
751
|
}
|
|
696
|
-
console.log(chalk.bold("Step 3:
|
|
752
|
+
console.log(chalk.bold("Step 3: Kalshi Trading (Optional)"));
|
|
753
|
+
console.log(chalk.dim("Trade on Kalshi markets via DFlow on Solana."));
|
|
754
|
+
console.log(chalk.dim("Skip this if you only want Polymarket or market discovery.\n"));
|
|
755
|
+
let kalshiKey = config.getKalshiApiKey();
|
|
756
|
+
let skipKalshi = false;
|
|
757
|
+
if (kalshiKey) {
|
|
758
|
+
console.log(chalk.dim(`Current Kalshi key: ${kalshiKey.slice(0, 12)}...`));
|
|
759
|
+
const action = await prompt("Keep current key (Enter), enter new key (n), or disable Kalshi (d): ");
|
|
760
|
+
if (action.toLowerCase() === "n") {
|
|
761
|
+
kalshiKey = await prompt("Enter your Kalshi API key: ", true);
|
|
762
|
+
} else if (action.toLowerCase() === "d") {
|
|
763
|
+
kalshiKey = void 0;
|
|
764
|
+
skipKalshi = true;
|
|
765
|
+
}
|
|
766
|
+
} else {
|
|
767
|
+
console.log("Options:");
|
|
768
|
+
console.log(chalk.dim(" 1. Create a new Kalshi wallet (recommended for new users)"));
|
|
769
|
+
console.log(chalk.dim(" 2. Enter an existing Kalshi API key"));
|
|
770
|
+
console.log(chalk.dim(" 3. Skip Kalshi for now\n"));
|
|
771
|
+
const choice = await prompt("Choose (1/2/3): ");
|
|
772
|
+
if (choice === "1") {
|
|
773
|
+
console.log(chalk.dim("\nCreating a new Solana wallet on Kalshi MCP..."));
|
|
774
|
+
const externalId = await prompt("Enter a unique identifier (e.g., email or username): ");
|
|
775
|
+
if (!externalId) {
|
|
776
|
+
console.log(chalk.red("Identifier is required to create an account."));
|
|
777
|
+
skipKalshi = true;
|
|
778
|
+
} else {
|
|
779
|
+
try {
|
|
780
|
+
const kalshiClient = createMCPClient(KALSHI_MCP_URL, "", "kalshi");
|
|
781
|
+
const result = await kalshiClient.callTool("kalshi_signup", { externalId });
|
|
782
|
+
if (result.success && typeof result.data === "object" && result.data !== null) {
|
|
783
|
+
const data = result.data;
|
|
784
|
+
kalshiKey = data.apiKey;
|
|
785
|
+
console.log(chalk.green("\n\u2713 Kalshi wallet created!"));
|
|
786
|
+
console.log(chalk.dim(` Solana Address: ${data.walletAddress}`));
|
|
787
|
+
if (data.apiSecret) {
|
|
788
|
+
console.log(chalk.yellow("\n\u26A0\uFE0F Save your API secret (shown only once):"));
|
|
789
|
+
console.log(chalk.bold.yellow(` ${String(data.apiSecret)}`));
|
|
790
|
+
console.log();
|
|
791
|
+
}
|
|
792
|
+
} else {
|
|
793
|
+
console.log(chalk.red("Failed to create Kalshi account: " + (result.error || "Unknown error")));
|
|
794
|
+
console.log(chalk.dim("You can try again later via the agent."));
|
|
795
|
+
skipKalshi = true;
|
|
796
|
+
}
|
|
797
|
+
} catch (error2) {
|
|
798
|
+
console.log(chalk.red("Failed to connect to Kalshi MCP."));
|
|
799
|
+
console.log(chalk.dim(String(error2)));
|
|
800
|
+
console.log(chalk.dim("You can try again later via the agent."));
|
|
801
|
+
skipKalshi = true;
|
|
802
|
+
}
|
|
803
|
+
}
|
|
804
|
+
} else if (choice === "2") {
|
|
805
|
+
kalshiKey = await prompt("Enter your Kalshi API key: ", true);
|
|
806
|
+
} else {
|
|
807
|
+
skipKalshi = true;
|
|
808
|
+
}
|
|
809
|
+
}
|
|
810
|
+
if (kalshiKey) {
|
|
811
|
+
config.setKalshiApiKey(kalshiKey);
|
|
812
|
+
console.log(chalk.green("\u2713 Kalshi API key saved\n"));
|
|
813
|
+
} else if (skipKalshi) {
|
|
814
|
+
console.log(chalk.dim("\u2713 Kalshi disabled - you can set it up later via the agent\n"));
|
|
815
|
+
} else {
|
|
816
|
+
console.log(chalk.dim("\u2713 No Kalshi key - you can set it up later\n"));
|
|
817
|
+
}
|
|
818
|
+
console.log(chalk.bold("Step 4: Exa API Key (Optional)"));
|
|
697
819
|
console.log(chalk.dim("Powers web search. Get one free at https://dashboard.exa.ai"));
|
|
698
820
|
console.log(chalk.dim("Without this, web search will use DuckDuckGo as fallback.\n"));
|
|
699
821
|
const exaKey = await prompt("Enter your Exa API key (or press Enter to skip): ", true);
|
|
@@ -704,7 +826,7 @@ async function runSetup() {
|
|
|
704
826
|
} else {
|
|
705
827
|
console.log(chalk.dim("Skipped. Web search will use DuckDuckGo.\n"));
|
|
706
828
|
}
|
|
707
|
-
console.log(chalk.bold("Step
|
|
829
|
+
console.log(chalk.bold("Step 5: Verifying connections..."));
|
|
708
830
|
try {
|
|
709
831
|
const discoveryClient = createMCPClient(DISCOVERY_MCP_URL, DISCOVERY_MCP_PUBLIC_KEY, "discovery");
|
|
710
832
|
const discoveryResult = await discoveryClient.callTool("get_market_stats", {});
|
|
@@ -723,19 +845,37 @@ async function runSetup() {
|
|
|
723
845
|
const result = await tradingClient.callTool("get_wallet_status", {});
|
|
724
846
|
if (result.success && typeof result.data === "object" && result.data !== null) {
|
|
725
847
|
const data = result.data;
|
|
726
|
-
console.log(chalk.green("\u2713
|
|
848
|
+
console.log(chalk.green("\u2713 Polymarket MCP connected"));
|
|
727
849
|
console.log(chalk.dim(` Safe Address: ${data.safeAddress || "Not yet deployed"}`));
|
|
728
850
|
console.log(chalk.dim(` Status: ${data.status}`));
|
|
729
851
|
console.log(chalk.dim(` Ready to trade: ${data.isReady ? "Yes" : "Run setup_wallet first"}`));
|
|
730
852
|
} else {
|
|
731
|
-
console.log(chalk.yellow("\u26A0
|
|
853
|
+
console.log(chalk.yellow("\u26A0 Polymarket MCP: " + (result.error || "Unknown error")));
|
|
732
854
|
}
|
|
733
855
|
} catch (error2) {
|
|
734
|
-
console.log(chalk.yellow("\u26A0 Could not verify
|
|
856
|
+
console.log(chalk.yellow("\u26A0 Could not verify Polymarket MCP connection."));
|
|
735
857
|
console.log(chalk.dim(String(error2)));
|
|
736
858
|
}
|
|
737
859
|
} else {
|
|
738
|
-
console.log(chalk.dim("\u23ED
|
|
860
|
+
console.log(chalk.dim("\u23ED Polymarket MCP skipped (no API key)"));
|
|
861
|
+
}
|
|
862
|
+
if (kalshiKey) {
|
|
863
|
+
try {
|
|
864
|
+
const kalshiClient = createMCPClient(KALSHI_MCP_URL, kalshiKey, "kalshi");
|
|
865
|
+
const result = await kalshiClient.callTool("kalshi_get_wallet_info", {});
|
|
866
|
+
if (result.success && typeof result.data === "object" && result.data !== null) {
|
|
867
|
+
const data = result.data;
|
|
868
|
+
console.log(chalk.green("\u2713 Kalshi MCP connected"));
|
|
869
|
+
console.log(chalk.dim(` Solana Address: ${data.publicKey || "Unknown"}`));
|
|
870
|
+
} else {
|
|
871
|
+
console.log(chalk.yellow("\u26A0 Kalshi MCP: " + (result.error || "Unknown error")));
|
|
872
|
+
}
|
|
873
|
+
} catch (error2) {
|
|
874
|
+
console.log(chalk.yellow("\u26A0 Could not verify Kalshi MCP connection."));
|
|
875
|
+
console.log(chalk.dim(String(error2)));
|
|
876
|
+
}
|
|
877
|
+
} else {
|
|
878
|
+
console.log(chalk.dim("\u23ED Kalshi MCP skipped (no API key)"));
|
|
739
879
|
}
|
|
740
880
|
console.log();
|
|
741
881
|
console.log(chalk.bold.green("\u{1F389} Setup complete!"));
|
|
@@ -5071,8 +5211,11 @@ Use /load <id> to load a session.`
|
|
|
5071
5211
|
abortController.current = null;
|
|
5072
5212
|
}
|
|
5073
5213
|
}, [agent, isProcessing, isInterrupted, exit, onExit, handleSlashCommand]);
|
|
5214
|
+
const wasProcessing = useRef(false);
|
|
5074
5215
|
useEffect(() => {
|
|
5075
|
-
|
|
5216
|
+
const justFinished = wasProcessing.current && !isProcessing;
|
|
5217
|
+
wasProcessing.current = isProcessing;
|
|
5218
|
+
if (justFinished && hasQueuedMessage && queuedInput) {
|
|
5076
5219
|
const nextMessage = queuedInput;
|
|
5077
5220
|
setQueuedInput("");
|
|
5078
5221
|
setHasQueuedMessage(false);
|
|
@@ -5151,10 +5294,22 @@ Stopped ${count} background process${count > 1 ? "es" : ""}.`);
|
|
|
5151
5294
|
setIsInterrupted(true);
|
|
5152
5295
|
abortController.current?.abort();
|
|
5153
5296
|
if (hasQueuedMessage && queuedInput) {
|
|
5154
|
-
|
|
5155
|
-
|
|
5156
|
-
|
|
5157
|
-
|
|
5297
|
+
const messageToSend = queuedInput;
|
|
5298
|
+
setQueuedInput("");
|
|
5299
|
+
setHasQueuedMessage(false);
|
|
5300
|
+
setIsProcessing(false);
|
|
5301
|
+
setMessages((prev) => {
|
|
5302
|
+
const filtered = prev.filter(
|
|
5303
|
+
(m) => !(m.role === "system" && m.content.startsWith("\u{1F4E5} Queued:"))
|
|
5304
|
+
);
|
|
5305
|
+
return [...filtered, {
|
|
5306
|
+
role: "system",
|
|
5307
|
+
content: "\u26A1 Interrupted. Sending queued message..."
|
|
5308
|
+
}];
|
|
5309
|
+
});
|
|
5310
|
+
setTimeout(() => {
|
|
5311
|
+
handleSubmit(messageToSend);
|
|
5312
|
+
}, 200);
|
|
5158
5313
|
} else {
|
|
5159
5314
|
setMessages((prev) => [...prev, {
|
|
5160
5315
|
role: "system",
|
|
@@ -5377,9 +5532,9 @@ program.command("config").description("View or edit configuration").option("-s,
|
|
|
5377
5532
|
}
|
|
5378
5533
|
console.log();
|
|
5379
5534
|
});
|
|
5380
|
-
program.command("tools").description("List available tools").option("-l, --local", "Show only local tools").option("-d, --discovery", "Show only Discovery MCP tools").option("-t, --trading", "Show only Trading MCP tools").action(async (options) => {
|
|
5535
|
+
program.command("tools").description("List available tools").option("-l, --local", "Show only local tools").option("-d, --discovery", "Show only Discovery MCP tools").option("-t, --trading", "Show only Trading MCP tools").option("-k, --kalshi", "Show only Kalshi MCP tools").action(async (options) => {
|
|
5381
5536
|
console.log();
|
|
5382
|
-
const showAll = !options.local && !options.discovery && !options.trading;
|
|
5537
|
+
const showAll = !options.local && !options.discovery && !options.trading && !options.kalshi;
|
|
5383
5538
|
if (showAll || options.local) {
|
|
5384
5539
|
console.log(chalk3.bold.blue("\u{1F4C1} Local Tools (coding)"));
|
|
5385
5540
|
printDivider();
|
|
@@ -5413,7 +5568,7 @@ program.command("tools").description("List available tools").option("-l, --local
|
|
|
5413
5568
|
if (showAll || options.trading) {
|
|
5414
5569
|
const config = getConfigManager();
|
|
5415
5570
|
if (config.isTradingEnabled()) {
|
|
5416
|
-
console.log(chalk3.bold.magenta("\u{1F4B0} Trading MCP Tools (wallet & orders)"));
|
|
5571
|
+
console.log(chalk3.bold.magenta("\u{1F4B0} Polymarket Trading MCP Tools (wallet & orders)"));
|
|
5417
5572
|
printDivider();
|
|
5418
5573
|
try {
|
|
5419
5574
|
const tradingClient = createMCPClient(
|
|
@@ -5432,7 +5587,34 @@ program.command("tools").description("List available tools").option("-l, --local
|
|
|
5432
5587
|
}
|
|
5433
5588
|
console.log();
|
|
5434
5589
|
} else {
|
|
5435
|
-
console.log(chalk3.dim('\u{1F4B0} Trading MCP: Not configured. Run "quantish init" to enable trading.'));
|
|
5590
|
+
console.log(chalk3.dim('\u{1F4B0} Polymarket Trading MCP: Not configured. Run "quantish init" to enable trading.'));
|
|
5591
|
+
console.log();
|
|
5592
|
+
}
|
|
5593
|
+
}
|
|
5594
|
+
if (showAll || options.kalshi) {
|
|
5595
|
+
const config = getConfigManager();
|
|
5596
|
+
const kalshiKey = config.getKalshiApiKey();
|
|
5597
|
+
if (kalshiKey) {
|
|
5598
|
+
console.log(chalk3.bold.yellow("\u{1F3AF} Kalshi MCP Tools (DFlow on Solana)"));
|
|
5599
|
+
printDivider();
|
|
5600
|
+
try {
|
|
5601
|
+
const kalshiClient = createMCPClient(
|
|
5602
|
+
KALSHI_MCP_URL,
|
|
5603
|
+
kalshiKey,
|
|
5604
|
+
"kalshi"
|
|
5605
|
+
);
|
|
5606
|
+
const kalshiTools = await kalshiClient.listTools();
|
|
5607
|
+
for (const tool of kalshiTools) {
|
|
5608
|
+
console.log(chalk3.yellow(` ${tool.name}`));
|
|
5609
|
+
const desc = tool.description || "";
|
|
5610
|
+
console.log(chalk3.dim(` ${desc.slice(0, 80)}${desc.length > 80 ? "..." : ""}`));
|
|
5611
|
+
}
|
|
5612
|
+
} catch (error2) {
|
|
5613
|
+
warn("Could not fetch Kalshi tools. Check your API key.");
|
|
5614
|
+
}
|
|
5615
|
+
console.log();
|
|
5616
|
+
} else {
|
|
5617
|
+
console.log(chalk3.dim("\u{1F3AF} Kalshi MCP: Not configured. Set your Kalshi API key to enable."));
|
|
5436
5618
|
console.log();
|
|
5437
5619
|
}
|
|
5438
5620
|
}
|
|
@@ -5489,7 +5671,9 @@ function createMCPManager(options) {
|
|
|
5489
5671
|
DISCOVERY_MCP_URL,
|
|
5490
5672
|
DISCOVERY_MCP_PUBLIC_KEY,
|
|
5491
5673
|
config.isTradingEnabled() ? config.getTradingMcpUrl() : void 0,
|
|
5492
|
-
config.getQuantishApiKey()
|
|
5674
|
+
config.getQuantishApiKey(),
|
|
5675
|
+
config.getKalshiApiKey() ? KALSHI_MCP_URL : void 0,
|
|
5676
|
+
config.getKalshiApiKey()
|
|
5493
5677
|
);
|
|
5494
5678
|
}
|
|
5495
5679
|
async function runInteractiveChat(options = {}) {
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@quantish/agent",
|
|
3
|
-
"version": "0.1.
|
|
4
|
-
"description": "AI-powered agent for
|
|
3
|
+
"version": "0.1.27",
|
|
4
|
+
"description": "AI-powered agent for trading on Polymarket and Kalshi",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
7
7
|
"quantish": "./dist/index.js"
|
|
@@ -20,6 +20,7 @@
|
|
|
20
20
|
},
|
|
21
21
|
"keywords": [
|
|
22
22
|
"polymarket",
|
|
23
|
+
"kalshi",
|
|
23
24
|
"trading",
|
|
24
25
|
"cli",
|
|
25
26
|
"ai",
|
|
@@ -28,11 +29,14 @@
|
|
|
28
29
|
"mcp",
|
|
29
30
|
"prediction-markets",
|
|
30
31
|
"polymarket-trading",
|
|
32
|
+
"kalshi-trading",
|
|
33
|
+
"solana",
|
|
34
|
+
"dflow",
|
|
31
35
|
"ai-agent",
|
|
32
36
|
"trading-bot"
|
|
33
37
|
],
|
|
34
38
|
"author": "Quantish <hello@quantish.live>",
|
|
35
|
-
"license": "
|
|
39
|
+
"license": "PolyForm-Noncommercial-1.0.0",
|
|
36
40
|
"publishConfig": {
|
|
37
41
|
"access": "public"
|
|
38
42
|
},
|