jaspervault_cli 1.0.27 → 1.0.28
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 +25 -24
- package/dist/bin/jv.js +6 -2
- package/dist/bin/jv.js.map +1 -1
- package/dist/src/client.js +28 -1
- package/dist/src/client.js.map +1 -1
- package/dist/src/commands/deposit.js +129 -125
- package/dist/src/commands/deposit.js.map +1 -1
- package/dist/src/commands/install.d.ts +2 -0
- package/dist/src/commands/install.js +184 -0
- package/dist/src/commands/install.js.map +1 -0
- package/dist/src/commands/limit-order.js +7 -0
- package/dist/src/commands/limit-order.js.map +1 -1
- package/dist/src/commands/mcp.d.ts +2 -0
- package/dist/src/commands/mcp.js +10 -0
- package/dist/src/commands/mcp.js.map +1 -0
- package/dist/src/commands/sl.js +12 -2
- package/dist/src/commands/sl.js.map +1 -1
- package/dist/src/commands/tp.js +12 -2
- package/dist/src/commands/tp.js.map +1 -1
- package/dist/src/commands/vault.js +111 -87
- package/dist/src/commands/vault.js.map +1 -1
- package/dist/src/commands/withdraw.d.ts +2 -0
- package/dist/src/commands/withdraw.js +114 -0
- package/dist/src/commands/withdraw.js.map +1 -0
- package/dist/src/mcp/executor.d.ts +23 -0
- package/dist/src/mcp/executor.js +75 -0
- package/dist/src/mcp/executor.js.map +1 -0
- package/dist/src/mcp/index.d.ts +1 -0
- package/dist/src/mcp/index.js +58 -0
- package/dist/src/mcp/index.js.map +1 -0
- package/dist/src/mcp/installer.d.ts +9 -0
- package/dist/src/mcp/installer.js +66 -0
- package/dist/src/mcp/installer.js.map +1 -0
- package/dist/src/mcp/tools.d.ts +15 -0
- package/dist/src/mcp/tools.js +250 -0
- package/dist/src/mcp/tools.js.map +1 -0
- package/dist/src/services/order-signer.js +1 -1
- package/dist/src/services/order-signer.js.map +1 -1
- package/dist/src/services/session-poller.d.ts +12 -0
- package/dist/src/services/session-poller.js +57 -0
- package/dist/src/services/session-poller.js.map +1 -0
- package/dist/src/templates/skill-body.d.ts +1 -1
- package/dist/src/templates/skill-body.js +1 -1
- package/dist/src/templates/skill-content/SKILL.core.md +7 -7
- package/dist/src/templates/skill-content/frontmatter/claude.md +1 -1
- package/dist/src/templates/skill-content/frontmatter/openclaw.md +1 -1
- package/dist/src/templates/skill-content/references/onboarding.md +33 -33
- package/dist/src/types.d.ts +13 -6
- package/dist/src/utils/config.d.ts +1 -1
- package/dist/src/utils/config.js +1 -1
- package/dist/src/utils/config.js.map +1 -1
- package/dist/src/utils/endpoints.d.ts +3 -0
- package/dist/src/utils/endpoints.js +5 -0
- package/dist/src/utils/endpoints.js.map +1 -1
- package/package.json +3 -5
|
@@ -0,0 +1,250 @@
|
|
|
1
|
+
export const TOOLS = [
|
|
2
|
+
// ── Trading ──
|
|
3
|
+
{
|
|
4
|
+
name: 'create_order',
|
|
5
|
+
description: 'Create a market or limit order. For market orders, omit limit_price. ' +
|
|
6
|
+
'To close a position, create an opposite-side order. ' +
|
|
7
|
+
'Returns jobId (market) or limitOrderId (limit).',
|
|
8
|
+
inputSchema: {
|
|
9
|
+
type: 'object',
|
|
10
|
+
properties: {
|
|
11
|
+
side: { type: 'string', enum: ['long', 'short'], description: 'Order direction' },
|
|
12
|
+
symbol: { type: 'string', description: 'Trading symbol, e.g. JBTC, JETH' },
|
|
13
|
+
margin: { type: 'number', description: 'Margin (collateral) in USDC' },
|
|
14
|
+
leverage: { type: 'number', description: 'Leverage multiplier (default: 50)' },
|
|
15
|
+
limit_price: { type: 'number', description: 'Limit price in USDC. Omit for market order.' },
|
|
16
|
+
ppo: { type: 'boolean', description: 'Enable PPO hedge option protection' },
|
|
17
|
+
ppo_expire: { type: 'string', enum: ['30m', '8h'], description: 'PPO expiry duration' },
|
|
18
|
+
ppo_category: { type: 'string', enum: ['ATM', 'OTM'], description: 'PPO option category' },
|
|
19
|
+
ppo_tier: { type: 'number', description: 'OTM strike offset tier 1-5 (0.1%-0.5%)' },
|
|
20
|
+
ttl: { type: 'number', description: 'Order TTL in seconds (default: 3600)' },
|
|
21
|
+
},
|
|
22
|
+
required: ['side', 'symbol', 'margin'],
|
|
23
|
+
},
|
|
24
|
+
cliCommand: ['order', 'create'],
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
name: 'protect_order',
|
|
28
|
+
description: 'Add PPO hedge option protection to an existing position without changing position size.',
|
|
29
|
+
inputSchema: {
|
|
30
|
+
type: 'object',
|
|
31
|
+
properties: {
|
|
32
|
+
order_id: { type: 'string', description: 'Existing perps order ID to protect' },
|
|
33
|
+
symbol: { type: 'string', description: 'Asset symbol, e.g. JBTC' },
|
|
34
|
+
ppo_expire: { type: 'string', enum: ['30m', '8h'], description: 'Option expiry (default: 30m)' },
|
|
35
|
+
ppo_category: { type: 'string', enum: ['ATM', 'OTM'], description: 'Option category (default: ATM)' },
|
|
36
|
+
ppo_tier: { type: 'number', description: 'OTM strike offset tier 1-5' },
|
|
37
|
+
},
|
|
38
|
+
required: ['order_id', 'symbol'],
|
|
39
|
+
},
|
|
40
|
+
cliCommand: ['order', 'protect'],
|
|
41
|
+
},
|
|
42
|
+
{
|
|
43
|
+
name: 'set_take_profit',
|
|
44
|
+
description: 'Set a take-profit limit order for an existing position.',
|
|
45
|
+
inputSchema: {
|
|
46
|
+
type: 'object',
|
|
47
|
+
properties: {
|
|
48
|
+
order_id: { type: 'string', description: 'Existing order ID' },
|
|
49
|
+
price: { type: 'number', description: 'Take-profit price in USDC' },
|
|
50
|
+
symbol: { type: 'string', description: 'Asset symbol, e.g. JBTC' },
|
|
51
|
+
side: { type: 'string', enum: ['long', 'short'], description: 'Position side (default: long)' },
|
|
52
|
+
ppo: { type: 'boolean', description: 'Enable PPO hedge option' },
|
|
53
|
+
ppo_expire: { type: 'string', enum: ['30m', '8h'] },
|
|
54
|
+
ppo_category: { type: 'string', enum: ['ATM', 'OTM'] },
|
|
55
|
+
ppo_tier: { type: 'number' },
|
|
56
|
+
ttl: { type: 'number', description: 'Order TTL in seconds (default: 86400)' },
|
|
57
|
+
},
|
|
58
|
+
required: ['order_id', 'price', 'symbol'],
|
|
59
|
+
},
|
|
60
|
+
cliCommand: ['tp', 'set'],
|
|
61
|
+
},
|
|
62
|
+
{
|
|
63
|
+
name: 'set_stop_loss',
|
|
64
|
+
description: 'Set a stop-loss limit order for an existing position.',
|
|
65
|
+
inputSchema: {
|
|
66
|
+
type: 'object',
|
|
67
|
+
properties: {
|
|
68
|
+
order_id: { type: 'string', description: 'Existing order ID' },
|
|
69
|
+
price: { type: 'number', description: 'Stop-loss price in USDC' },
|
|
70
|
+
symbol: { type: 'string', description: 'Asset symbol, e.g. JBTC' },
|
|
71
|
+
side: { type: 'string', enum: ['long', 'short'], description: 'Position side (default: long)' },
|
|
72
|
+
ppo: { type: 'boolean', description: 'Enable PPO hedge option' },
|
|
73
|
+
ppo_expire: { type: 'string', enum: ['30m', '8h'] },
|
|
74
|
+
ppo_category: { type: 'string', enum: ['ATM', 'OTM'] },
|
|
75
|
+
ppo_tier: { type: 'number' },
|
|
76
|
+
ttl: { type: 'number', description: 'Order TTL in seconds (default: 86400)' },
|
|
77
|
+
},
|
|
78
|
+
required: ['order_id', 'price', 'symbol'],
|
|
79
|
+
},
|
|
80
|
+
cliCommand: ['sl', 'set'],
|
|
81
|
+
},
|
|
82
|
+
// ── Queries ──
|
|
83
|
+
{
|
|
84
|
+
name: 'list_orders',
|
|
85
|
+
description: 'List positions/orders. Defaults to active positions only. Use all=true to include closed.',
|
|
86
|
+
inputSchema: {
|
|
87
|
+
type: 'object',
|
|
88
|
+
properties: {
|
|
89
|
+
position_side: { type: 'string', enum: ['LONG', 'SHORT'], description: 'Filter by side' },
|
|
90
|
+
all: { type: 'boolean', description: 'Include closed orders (default: active only)' },
|
|
91
|
+
since: { type: 'string', description: 'Filter orders after this time (e.g. "7d", "2025-01-01")' },
|
|
92
|
+
until: { type: 'string', description: 'Filter orders before this time' },
|
|
93
|
+
page: { type: 'number', description: 'Page number (default: 1)' },
|
|
94
|
+
limit: { type: 'number', description: 'Items per page (default: 20)' },
|
|
95
|
+
},
|
|
96
|
+
required: [],
|
|
97
|
+
},
|
|
98
|
+
cliCommand: ['orders', 'list', '--pretty'],
|
|
99
|
+
},
|
|
100
|
+
{
|
|
101
|
+
name: 'get_order',
|
|
102
|
+
description: 'Get a single order/position by ID.',
|
|
103
|
+
inputSchema: {
|
|
104
|
+
type: 'object',
|
|
105
|
+
properties: {
|
|
106
|
+
order_id: { type: 'string', description: 'Order ID' },
|
|
107
|
+
},
|
|
108
|
+
required: ['order_id'],
|
|
109
|
+
},
|
|
110
|
+
cliCommand: ['orders', 'get'],
|
|
111
|
+
},
|
|
112
|
+
{
|
|
113
|
+
name: 'get_order_stats',
|
|
114
|
+
description: 'Get order statistics for the configured vault.',
|
|
115
|
+
inputSchema: {
|
|
116
|
+
type: 'object',
|
|
117
|
+
properties: {},
|
|
118
|
+
required: [],
|
|
119
|
+
},
|
|
120
|
+
cliCommand: ['orders', 'stats', '--pretty'],
|
|
121
|
+
},
|
|
122
|
+
{
|
|
123
|
+
name: 'get_price',
|
|
124
|
+
description: 'Get real-time market price for an asset.',
|
|
125
|
+
inputSchema: {
|
|
126
|
+
type: 'object',
|
|
127
|
+
properties: {
|
|
128
|
+
symbol: { type: 'string', description: 'Asset symbol, e.g. JBTC, JETH' },
|
|
129
|
+
},
|
|
130
|
+
required: ['symbol'],
|
|
131
|
+
},
|
|
132
|
+
cliCommand: ['price'],
|
|
133
|
+
},
|
|
134
|
+
{
|
|
135
|
+
name: 'get_job_status',
|
|
136
|
+
description: 'Get execution status/result of a market order job.',
|
|
137
|
+
inputSchema: {
|
|
138
|
+
type: 'object',
|
|
139
|
+
properties: {
|
|
140
|
+
job_id: { type: 'string', description: 'Job ID returned from market order creation' },
|
|
141
|
+
},
|
|
142
|
+
required: ['job_id'],
|
|
143
|
+
},
|
|
144
|
+
cliCommand: ['job', 'status'],
|
|
145
|
+
},
|
|
146
|
+
// ── Limit Orders ──
|
|
147
|
+
{
|
|
148
|
+
name: 'list_limit_orders',
|
|
149
|
+
description: 'List limit orders by wallet address.',
|
|
150
|
+
inputSchema: {
|
|
151
|
+
type: 'object',
|
|
152
|
+
properties: {
|
|
153
|
+
wallet: { type: 'string', description: 'Wallet address' },
|
|
154
|
+
status: {
|
|
155
|
+
type: 'string',
|
|
156
|
+
enum: ['PENDING', 'TRIGGERED', 'EXECUTING', 'COMPLETED', 'FAILED', 'EXPIRED', 'CANCELLED'],
|
|
157
|
+
description: 'Filter by status',
|
|
158
|
+
},
|
|
159
|
+
},
|
|
160
|
+
required: ['wallet'],
|
|
161
|
+
},
|
|
162
|
+
cliCommand: ['limit-order', 'list'],
|
|
163
|
+
},
|
|
164
|
+
{
|
|
165
|
+
name: 'get_limit_order_status',
|
|
166
|
+
description: 'Get status of a specific limit order.',
|
|
167
|
+
inputSchema: {
|
|
168
|
+
type: 'object',
|
|
169
|
+
properties: {
|
|
170
|
+
limit_order_id: { type: 'string', description: 'Limit order ID' },
|
|
171
|
+
},
|
|
172
|
+
required: ['limit_order_id'],
|
|
173
|
+
},
|
|
174
|
+
cliCommand: ['limit-order', 'status'],
|
|
175
|
+
},
|
|
176
|
+
{
|
|
177
|
+
name: 'cancel_limit_order',
|
|
178
|
+
description: 'Cancel a pending limit order.',
|
|
179
|
+
inputSchema: {
|
|
180
|
+
type: 'object',
|
|
181
|
+
properties: {
|
|
182
|
+
limit_order_id: { type: 'string', description: 'Limit order ID to cancel' },
|
|
183
|
+
},
|
|
184
|
+
required: ['limit_order_id'],
|
|
185
|
+
},
|
|
186
|
+
cliCommand: ['limit-order', 'cancel'],
|
|
187
|
+
},
|
|
188
|
+
// ── Wallet Setup & Deposit (hosted web page) ──
|
|
189
|
+
{
|
|
190
|
+
name: 'wallet_setup',
|
|
191
|
+
description: 'Set up a new JasperVault wallet via hosted web page. ' +
|
|
192
|
+
'Returns a URL that the user must open in their browser to connect their wallet ' +
|
|
193
|
+
'and sign the delegation authorization. Polls automatically until complete.',
|
|
194
|
+
inputSchema: {
|
|
195
|
+
type: 'object',
|
|
196
|
+
properties: {
|
|
197
|
+
network: { type: 'string', description: 'Network name (default: jaspervault)' },
|
|
198
|
+
vault_types: { type: 'string', description: 'Comma-separated vault types (default: 33,37)' },
|
|
199
|
+
},
|
|
200
|
+
required: [],
|
|
201
|
+
},
|
|
202
|
+
cliCommand: ['vault', 'setup'],
|
|
203
|
+
timeoutMs: 960_000, // 16 minutes
|
|
204
|
+
},
|
|
205
|
+
{
|
|
206
|
+
name: 'deposit_via_browser',
|
|
207
|
+
description: 'Deposit tokens from Base to JasperVault via hosted web page. ' +
|
|
208
|
+
'Returns a URL for the user to open in their browser to approve and send the deposit transaction. ' +
|
|
209
|
+
'Use when the user cannot sign transactions locally (e.g. WhatsApp, Telegram agents).',
|
|
210
|
+
inputSchema: {
|
|
211
|
+
type: 'object',
|
|
212
|
+
properties: {
|
|
213
|
+
token: { type: 'string', description: 'Token: jbtc | jusdc | cbbtc | usdc' },
|
|
214
|
+
amount: { type: 'number', description: 'Amount in human-readable units, e.g. 1000 for USDC' },
|
|
215
|
+
network: { type: 'string', description: 'Network name (default: jaspervault)' },
|
|
216
|
+
},
|
|
217
|
+
required: ['token', 'amount'],
|
|
218
|
+
},
|
|
219
|
+
cliCommand: ['deposit'],
|
|
220
|
+
timeoutMs: 960_000,
|
|
221
|
+
},
|
|
222
|
+
{
|
|
223
|
+
name: 'withdraw_via_browser',
|
|
224
|
+
description: 'Withdraw tokens from JasperVault to Base via hosted web page. ' +
|
|
225
|
+
'Returns a URL for the user to open in their browser to sign the withdrawal, bridge, and redeem. ' +
|
|
226
|
+
'Use when the user cannot sign transactions locally (e.g. WhatsApp, Telegram agents).',
|
|
227
|
+
inputSchema: {
|
|
228
|
+
type: 'object',
|
|
229
|
+
properties: {
|
|
230
|
+
token: { type: 'string', description: 'Token: jbtc | jusdc | cbbtc | usdc' },
|
|
231
|
+
amount: { type: 'number', description: 'Amount in human-readable units, e.g. 100 for USDC' },
|
|
232
|
+
network: { type: 'string', description: 'Network name (default: base_uat)' },
|
|
233
|
+
},
|
|
234
|
+
required: ['token', 'amount'],
|
|
235
|
+
},
|
|
236
|
+
cliCommand: ['withdraw'],
|
|
237
|
+
timeoutMs: 960_000,
|
|
238
|
+
},
|
|
239
|
+
];
|
|
240
|
+
/**
|
|
241
|
+
* Parameters that are positional arguments (not flags) in CLI.
|
|
242
|
+
* Key: tool name, Value: param name that should be passed as positional arg.
|
|
243
|
+
*/
|
|
244
|
+
export const POSITIONAL_ARGS = {
|
|
245
|
+
get_order: 'order_id',
|
|
246
|
+
get_job_status: 'job_id',
|
|
247
|
+
get_limit_order_status: 'limit_order_id',
|
|
248
|
+
cancel_limit_order: 'limit_order_id',
|
|
249
|
+
};
|
|
250
|
+
//# sourceMappingURL=tools.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tools.js","sourceRoot":"","sources":["../../../src/mcp/tools.ts"],"names":[],"mappings":"AAUA,MAAM,CAAC,MAAM,KAAK,GAAc;IAC9B,gBAAgB;IAChB;QACE,IAAI,EAAE,cAAc;QACpB,WAAW,EACT,uEAAuE;YACvE,sDAAsD;YACtD,iDAAiD;QACnD,WAAW,EAAE;YACX,IAAI,EAAE,QAAQ;YACd,UAAU,EAAE;gBACV,IAAI,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,WAAW,EAAE,iBAAiB,EAAE;gBACjF,MAAM,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,WAAW,EAAE,iCAAiC,EAAE;gBAC1E,MAAM,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,WAAW,EAAE,6BAA6B,EAAE;gBACtE,QAAQ,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,WAAW,EAAE,mCAAmC,EAAE;gBAC9E,WAAW,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,WAAW,EAAE,6CAA6C,EAAE;gBAC3F,GAAG,EAAE,EAAE,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gBAC5E,MAAM,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,WAAW,EAAE,mDAAmD,EAAE;gBAC5F,OAAO,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,WAAW,EAAE,kCAAkC,EAAE;aAC7E;YACD,QAAQ,EAAE,CAAC,OAAO,EAAE,QAAQ,CAAC;SAC9B;QACD,UAAU,EAAE,CAAC,UAAU,CAAC;QACxB,SAAS,EAAE,OAAO;KACnB;CACF,CAAC;AAEF;;;GAGG;AACH,MAAM,CAAC,MAAM,eAAe,GAA2B;IACrD,SAAS,EAAE,UAAU;IACrB,cAAc,EAAE,QAAQ;IACxB,sBAAsB,EAAE,gBAAgB;IACxC,kBAAkB,EAAE,gBAAgB;CACrC,CAAC"}
|
|
@@ -38,7 +38,7 @@ export async function buildSignData(intent, profile, network) {
|
|
|
38
38
|
const tpSlIntent = intent;
|
|
39
39
|
orderID = Number(tpSlIntent.orderID);
|
|
40
40
|
targetPrice = ethers.parseUnits(tpSlIntent.price, 18).toString();
|
|
41
|
-
marginAmount = '0';
|
|
41
|
+
marginAmount = tpSlIntent.marginAmount ?? '0';
|
|
42
42
|
productType = (100 * 10 ** 12).toString();
|
|
43
43
|
writerSide = tpSlIntent.side === 'short' ? 'long' : 'short';
|
|
44
44
|
signOrderType = 1;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"order-signer.js","sourceRoot":"","sources":["../../../src/services/order-signer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAIhC,OAAO,EAAE,gBAAgB,EAAE,cAAc,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AACvF,OAAO,EAAE,6BAA6B,EAAE,MAAM,oBAAoB,CAAC;AAEnE,MAAM,WAAW,GAAG,gFAAgF,CAAC;AACrG,MAAM,eAAe,GAAG,GAAG,IAAI,GAAG,CAAC;AAEnC,MAAM,gCAAgC,GAAG;IACvC,qfAAqf;CACtf,CA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EAC1B,CAAC,MAAM,CAAC,CACT,CAAC;IACF,MAAM,WAAW,GAAG,MAAM,CAAC,SAAS,CAAC,WAAW,CAAC,CAAC;IAClD,OAAO,MAAM,CAAC,WAAW,CAAC,MAAM,CAAC,QAAQ,CAAC,WAAW,CAAC,CAAC,CAAC;AAC1D,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { ApiClient } from '../client.js';
|
|
2
|
+
import type { CliSessionStatusResponse } from '../types.js';
|
|
3
|
+
export interface PollSessionOptions {
|
|
4
|
+
intervalMs?: number;
|
|
5
|
+
timeoutMs?: number;
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* Poll a CLI session until it reaches a terminal status (completed / failed / expired).
|
|
9
|
+
* Uses raw fetch to avoid process.exit on transient HTTP errors (e.g. 429 rate limit).
|
|
10
|
+
* Outputs periodic heartbeat JSON to stderr so MCP can relay progress.
|
|
11
|
+
*/
|
|
12
|
+
export declare function pollSession(apiClient: ApiClient, sessionId: string, opts?: PollSessionOptions): Promise<CliSessionStatusResponse>;
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { ENDPOINTS } from '../utils/endpoints.js';
|
|
2
|
+
import { loadConfig } from '../utils/config.js';
|
|
3
|
+
const DEFAULT_INTERVAL_MS = 3_000;
|
|
4
|
+
const DEFAULT_TIMEOUT_MS = 15 * 60 * 1000; // 15 minutes
|
|
5
|
+
const HEARTBEAT_INTERVAL_MS = 10_000;
|
|
6
|
+
/**
|
|
7
|
+
* Poll a CLI session until it reaches a terminal status (completed / failed / expired).
|
|
8
|
+
* Uses raw fetch to avoid process.exit on transient HTTP errors (e.g. 429 rate limit).
|
|
9
|
+
* Outputs periodic heartbeat JSON to stderr so MCP can relay progress.
|
|
10
|
+
*/
|
|
11
|
+
export async function pollSession(apiClient, sessionId, opts) {
|
|
12
|
+
const intervalMs = opts?.intervalMs ?? DEFAULT_INTERVAL_MS;
|
|
13
|
+
const timeoutMs = opts?.timeoutMs ?? DEFAULT_TIMEOUT_MS;
|
|
14
|
+
const start = Date.now();
|
|
15
|
+
let lastHeartbeat = 0;
|
|
16
|
+
const config = loadConfig();
|
|
17
|
+
const baseUrl = config.apiUrl.endsWith('/') ? config.apiUrl.slice(0, -1) : config.apiUrl;
|
|
18
|
+
const headers = { 'Content-Type': 'application/json' };
|
|
19
|
+
if (config.apiKey) {
|
|
20
|
+
headers['Authorization'] = `Bearer ${config.apiKey}`;
|
|
21
|
+
}
|
|
22
|
+
while (Date.now() - start < timeoutMs) {
|
|
23
|
+
try {
|
|
24
|
+
const url = `${baseUrl}${ENDPOINTS.CLI_SESSION_STATUS}/${sessionId}/status`;
|
|
25
|
+
const response = await fetch(url, { method: 'GET', headers });
|
|
26
|
+
if (response.ok) {
|
|
27
|
+
const body = await response.json();
|
|
28
|
+
let data = body.data;
|
|
29
|
+
// Unwrap marketplace double-envelope
|
|
30
|
+
if (data && typeof data === 'object' && 'code' in data && 'data' in data) {
|
|
31
|
+
data = data.data;
|
|
32
|
+
}
|
|
33
|
+
if (data && data.status !== 'pending') {
|
|
34
|
+
return data;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
// On non-ok (429, 500, etc.), just retry next tick
|
|
38
|
+
}
|
|
39
|
+
catch {
|
|
40
|
+
// Swallow network errors during polling — retry on next tick
|
|
41
|
+
}
|
|
42
|
+
// Emit heartbeat on stderr for MCP/agent consumption
|
|
43
|
+
const elapsed = Math.round((Date.now() - start) / 1000);
|
|
44
|
+
if (Date.now() - lastHeartbeat >= HEARTBEAT_INTERVAL_MS) {
|
|
45
|
+
process.stderr.write(JSON.stringify({
|
|
46
|
+
status: 'waiting',
|
|
47
|
+
phase: 'user_signing',
|
|
48
|
+
elapsed,
|
|
49
|
+
message: 'Waiting for user to complete signing in browser...',
|
|
50
|
+
}) + '\n');
|
|
51
|
+
lastHeartbeat = Date.now();
|
|
52
|
+
}
|
|
53
|
+
await new Promise((r) => setTimeout(r, intervalMs));
|
|
54
|
+
}
|
|
55
|
+
return { status: 'expired' };
|
|
56
|
+
}
|
|
57
|
+
//# sourceMappingURL=session-poller.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"session-poller.js","sourceRoot":"","sources":["../../../src/services/session-poller.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAClD,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAGhD,MAAM,mBAAmB,GAAG,KAAK,CAAC;AAClC,MAAM,kBAAkB,GAAG,EAAE,GAAG,EAAE,GAAG,IAAI,CAAC,CAAC,aAAa;AACxD,MAAM,qBAAqB,GAAG,MAAM,CAAC;AAOrC;;;;GAIG;AACH,MAAM,CAAC,KAAK,UAAU,WAAW,CAC/B,SAAoB,EACpB,SAAiB,EACjB,IAAyB;IAEzB,MAAM,UAAU,GAAG,IAAI,EAAE,UAAU,IAAI,mBAAmB,CAAC;IAC3D,MAAM,SAAS,GAAG,IAAI,EAAE,SAAS,IAAI,kBAAkB,CAAC;IACxD,MAAM,KAAK,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;IACzB,IAAI,aAAa,GAAG,CAAC,CAAC;IAEtB,MAAM,MAAM,GAAG,UAAU,EAAE,CAAC;IAC5B,MAAM,OAAO,GAAG,MAAM,CAAC,MAAM,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC;IACzF,MAAM,OAAO,GAA2B,EAAE,cAAc,EAAE,kBAAkB,EAAE,CAAC;IAC/E,IAAI,MAAM,CAAC,MAAM,EAAE,CAAC;QAClB,OAAO,CAAC,eAAe,CAAC,GAAG,UAAU,MAAM,CAAC,MAAM,EAAE,CAAC;IACvD,CAAC;IAED,OAAO,IAAI,CAAC,GAAG,EAAE,GAAG,KAAK,GAAG,SAA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,OAAO,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,UAAU,CAAC,CAAC,EAAE,UAAU,CAAC,CAAC,CAAC;IACtD,CAAC;IAED,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,CAAC;AAC/B,CAAC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Skill template content and banner for jv
|
|
2
|
+
* Skill template content and banner for jv install command.
|
|
3
3
|
* Generates a multi-file skill structure:
|
|
4
4
|
* SKILL.md — compact core rules + activation + intent table
|
|
5
5
|
* references/ — detailed docs loaded on demand by the agent
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Skill template content and banner for jv
|
|
2
|
+
* Skill template content and banner for jv install command.
|
|
3
3
|
* Generates a multi-file skill structure:
|
|
4
4
|
* SKILL.md — compact core rules + activation + intent table
|
|
5
5
|
* references/ — detailed docs loaded on demand by the agent
|
|
@@ -4,22 +4,22 @@ Trade perpetual contracts on JasperVault via the `jv` CLI (v{{CLI_VERSION}}). No
|
|
|
4
4
|
|
|
5
5
|
## CRITICAL RULES (MUST FOLLOW — violations cause broken UX)
|
|
6
6
|
|
|
7
|
-
1. **
|
|
8
|
-
2. **
|
|
9
|
-
3. **Long-running Commands**: `jv vault setup` is a long-running command (up to
|
|
7
|
+
1. **Browser Signing ONLY**: ALWAYS use `jv vault setup`. NEVER suggest `jv vault init` (private-key mode). NEVER ask the user to set `PRIVATE_KEY`.
|
|
8
|
+
2. **URL Display**: When `jv vault setup` outputs JSON with a `url` field, you MUST display the `url` value as a clickable link to the user. The user opens this URL in their browser to connect their wallet and sign.
|
|
9
|
+
3. **Long-running Commands**: `jv vault setup` is a long-running command (up to 15 min) that creates a web session. After it outputs the session URL, it polls automatically until the user completes signing in the browser. Show the URL to the user and wait for completion.
|
|
10
10
|
4. **Real-time Prices**: NEVER guess or estimate prices. ALWAYS run `jv price --symbol JBTC --pretty` before any price-dependent operation (opening a position by asset quantity, calculating PnL).
|
|
11
11
|
5. **PPO Auto-Cancellation**: When performing any position operation (reduce, close, add size) WITHOUT `--ppo`, the smart contract automatically cancels existing PPO hedge options. There is NO separate "cancel PPO" command. NEVER attempt a separate cancellation — it risks unintended position closures.
|
|
12
12
|
6. **Standalone PPO Protection**: To add hedge protection to an **existing position**, use `jv order protect --order-id <id> --symbol <symbol>`. Do NOT use `jv order create --ppo` for this — that command ADDS POSITION SIZE. `jv order create --ppo` is ONLY for opening new positions or adding size with protection. See [references/trading.md](references/trading.md) for details.
|
|
13
13
|
7. **Market Order Output**: `jv order create` (market) prints TWO JSON lines — first the submission, then the execution result (auto-waits up to 60s). If `status === "completed"`, the order IS executed. Do NOT retry or place another order. See [references/trading.md](references/trading.md).
|
|
14
|
-
8. **Deposit via
|
|
14
|
+
8. **Deposit via Browser**: `jv deposit` auto-detects signing mode. Without `PRIVATE_KEY`, it creates a hosted web session — the user opens the URL in their browser to approve the deposit. See [references/onboarding.md](references/onboarding.md).
|
|
15
15
|
|
|
16
16
|
## Activation Behavior
|
|
17
17
|
|
|
18
18
|
1. Check if vault is initialized: `jv orders list --pretty`
|
|
19
19
|
2. If the command fails (exit code 1, or errors like "delegation key not found" / "vault not initialized" / "no profile"):
|
|
20
|
-
- Tell the user: "Your vault is not initialized yet. Let me set it up
|
|
21
|
-
- Immediately run `jv vault setup
|
|
22
|
-
- Follow the
|
|
20
|
+
- Tell the user: "Your vault is not initialized yet. Let me set it up — you'll sign in your browser, no private key needed."
|
|
21
|
+
- Immediately run `jv vault setup`.
|
|
22
|
+
- Follow the URL display instructions in [references/onboarding.md](references/onboarding.md).
|
|
23
23
|
3. If the command succeeds → vault is ready. Proceed with the user's request.
|
|
24
24
|
|
|
25
25
|
## Intent → Command Reference
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: jasper-vault-cli
|
|
3
|
-
description: "Trade perpetual contracts (perps) on JasperVault — open/close positions, set TP/SL, manage limit orders, deposit, and query portfolio via the `jv` CLI. Initialize wallet via
|
|
3
|
+
description: "Trade perpetual contracts (perps) on JasperVault — open/close positions, set TP/SL, manage limit orders, deposit, and query portfolio via the `jv` CLI. Initialize wallet via hosted web page (no private key needed)."
|
|
4
4
|
---
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: jasper-vault-cli
|
|
3
|
-
description: "Trade perpetual contracts (perps) on JasperVault — open/close positions, set TP/SL, manage limit orders, deposit, and query portfolio via the `jv` CLI. Initialize wallet via
|
|
3
|
+
description: "Trade perpetual contracts (perps) on JasperVault — open/close positions, set TP/SL, manage limit orders, deposit, and query portfolio via the `jv` CLI. Initialize wallet via hosted web page (no private key needed)."
|
|
4
4
|
trigger: "jaspervault|jasper vault|jasper trading|jv|jv trade|jv order|在jasper交易|jasper 交易|初始化钱包|连接钱包|开仓|平仓|做多|做空|止盈|止损|查看持仓|永续合约"
|
|
5
5
|
tools: [shell, process]
|
|
6
6
|
metadata:
|
|
@@ -2,65 +2,64 @@
|
|
|
2
2
|
|
|
3
3
|
## 1. Wallet Initialization (`jv vault setup`)
|
|
4
4
|
|
|
5
|
-
Initialize the JasperVault delegation wallet via
|
|
5
|
+
Initialize the JasperVault delegation wallet via hosted web page. The user signs in their browser — no private key needed.
|
|
6
6
|
|
|
7
7
|
### Syntax
|
|
8
8
|
|
|
9
9
|
```
|
|
10
|
-
jv vault setup --network <name> [--
|
|
10
|
+
jv vault setup [--network <name>] [--vault-types <types>] [--timeout <seconds>] [--pretty]
|
|
11
11
|
```
|
|
12
12
|
|
|
13
13
|
### Options
|
|
14
14
|
|
|
15
15
|
| Option | Required | Default | Description |
|
|
16
16
|
|--------|----------|---------|-------------|
|
|
17
|
-
| `--network <name>` |
|
|
18
|
-
| `--
|
|
19
|
-
| `--
|
|
17
|
+
| `--network <name>` | No | `base_uat` | Network name |
|
|
18
|
+
| `--vault-types <types>` | No | `33,37` | Comma-separated vault types |
|
|
19
|
+
| `--timeout <seconds>` | No | `900` | Polling timeout |
|
|
20
20
|
| `--pretty` | No | — | Pretty-print JSON output |
|
|
21
21
|
|
|
22
22
|
### Step-by-Step Flow
|
|
23
23
|
|
|
24
24
|
1. Run the command:
|
|
25
25
|
```
|
|
26
|
-
jv vault setup --
|
|
26
|
+
jv vault setup --pretty
|
|
27
27
|
```
|
|
28
28
|
|
|
29
|
-
2. The
|
|
30
|
-
|
|
31
|
-
3. The **first JSON output** contains the QR code URL:
|
|
29
|
+
2. The **first JSON output** contains the session URL:
|
|
32
30
|
```json
|
|
33
|
-
{
|
|
31
|
+
{
|
|
32
|
+
"status": "session_created",
|
|
33
|
+
"sessionId": "abc123",
|
|
34
|
+
"url": "https://trading.jaspervault.pro/cli-session/abc123",
|
|
35
|
+
"message": "Open this URL in your browser to connect wallet and complete setup"
|
|
36
|
+
}
|
|
34
37
|
```
|
|
35
|
-
**You MUST display this `
|
|
38
|
+
**You MUST display this `url` as a clickable link** so the user can open it in their browser to connect their wallet (e.g., MetaMask, Rabby) and sign the delegation authorization.
|
|
36
39
|
|
|
37
|
-
|
|
38
|
-
- While waiting, you'll see heartbeat lines: `{"status":"waiting","phase":"wallet_scan","elapsed":10,"message":"Waiting for wallet connection..."}`
|
|
39
|
-
- Continue polling until you see the **second JSON line** with `"success":true` or the process exits.
|
|
40
|
+
3. The CLI **automatically polls** for completion. While waiting, heartbeat lines appear on stderr.
|
|
40
41
|
|
|
41
|
-
|
|
42
|
+
4. On success, the output includes:
|
|
42
43
|
```json
|
|
43
44
|
{
|
|
44
45
|
"success": true,
|
|
45
46
|
"walletAddress": "0x...",
|
|
46
47
|
"delegationAddress": "0x...",
|
|
47
|
-
"
|
|
48
|
-
"
|
|
48
|
+
"marginAccount": "0x...",
|
|
49
|
+
"vaults": [{"type": 33, "address": "0x..."}, {"type": 37, "address": "0x..."}]
|
|
49
50
|
}
|
|
50
51
|
```
|
|
51
52
|
|
|
52
|
-
|
|
53
|
+
5. The CLI automatically:
|
|
53
54
|
- Generates and saves a delegation key to `~/.jaspervault/keys.json`
|
|
54
55
|
- Saves the vault profile to `~/.jaspervault/profile.json`
|
|
55
|
-
- Registers the delegation key on-chain via WalletConnect signing
|
|
56
56
|
|
|
57
57
|
### Error Handling
|
|
58
58
|
|
|
59
59
|
| Error | Cause | Action |
|
|
60
60
|
|-------|-------|--------|
|
|
61
|
-
| `
|
|
62
|
-
| `
|
|
63
|
-
| `Failed to initialize WalletConnect` | Network issue | Check internet connection, retry |
|
|
61
|
+
| `Session expired/failed` | User didn't complete signing in time | Re-run `jv vault setup` |
|
|
62
|
+
| `Failed to create session` | Network/API issue | Check internet connection, retry |
|
|
64
63
|
|
|
65
64
|
### Important Notes
|
|
66
65
|
|
|
@@ -72,12 +71,12 @@ jv vault setup --network <name> [--timeout <seconds>] [--vault-index <n>] [--pre
|
|
|
72
71
|
|
|
73
72
|
## 2. Deposit Tokens (`jv deposit`)
|
|
74
73
|
|
|
75
|
-
Deposit tokens from Base network to JasperVault via Hyperlane warp routes.
|
|
74
|
+
Deposit tokens from Base network to JasperVault via Hyperlane warp routes.
|
|
76
75
|
|
|
77
76
|
### Syntax
|
|
78
77
|
|
|
79
78
|
```
|
|
80
|
-
jv deposit --token <token> --amount <amount> [--
|
|
79
|
+
jv deposit --token <token> --amount <amount> [--vault-index <n>] [--network <name>] [--timeout <seconds>] [--no-wait] [--pretty]
|
|
81
80
|
```
|
|
82
81
|
|
|
83
82
|
### Options
|
|
@@ -86,20 +85,21 @@ jv deposit --token <token> --amount <amount> [--wallet <address>] [--vault-index
|
|
|
86
85
|
|--------|----------|---------|-------------|
|
|
87
86
|
| `--token <token>` | Yes | — | Token to deposit: `jbtc`, `jusdc`, `cbbtc`, or `usdc` |
|
|
88
87
|
| `--amount <amount>` | Yes | — | Amount in human-readable units (e.g., `0.01` for BTC, `1000` for USDC) |
|
|
89
|
-
| `--wallet <address>` | No | from profile | Override wallet address (default: from vault profile) |
|
|
90
88
|
| `--vault-index <n>` | No | `1` | Vault index for recipient address derivation |
|
|
91
89
|
| `--network <name>` | No | `jaspervault` | Network name |
|
|
92
|
-
| `--timeout <seconds>` | No | `
|
|
90
|
+
| `--timeout <seconds>` | No | `900` | Polling timeout |
|
|
93
91
|
| `--no-wait` | No | — | Skip polling for arrival on JasperVault |
|
|
94
92
|
| `--pretty` | No | — | Pretty-print JSON output |
|
|
95
93
|
|
|
96
94
|
### Flow
|
|
97
95
|
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
96
|
+
Without `PRIVATE_KEY`, the CLI creates a hosted web session:
|
|
97
|
+
1. It outputs a session URL — display it to the user.
|
|
98
|
+
2. The user opens the URL in their browser to approve the deposit.
|
|
99
|
+
3. The CLI polls until the transaction is confirmed.
|
|
100
|
+
4. Unless `--no-wait`, it then polls for token arrival on JasperVault (up to 60s).
|
|
101
|
+
|
|
102
|
+
With `PRIVATE_KEY` set, it signs and sends directly (no browser needed).
|
|
103
103
|
|
|
104
104
|
### Output
|
|
105
105
|
|
|
@@ -108,7 +108,7 @@ jv deposit --token <token> --amount <amount> [--wallet <address>] [--vault-index
|
|
|
108
108
|
"success": true,
|
|
109
109
|
"token": "jbtc",
|
|
110
110
|
"amount": "0.01",
|
|
111
|
-
"
|
|
111
|
+
"transactionHash": "0x...",
|
|
112
112
|
"arrived": true,
|
|
113
113
|
"arrivalTimeMs": 12345,
|
|
114
114
|
"message": "Deposit confirmed"
|
|
@@ -117,7 +117,7 @@ jv deposit --token <token> --amount <amount> [--wallet <address>] [--vault-index
|
|
|
117
117
|
|
|
118
118
|
### Important Notes
|
|
119
119
|
|
|
120
|
-
- **
|
|
120
|
+
- **Browser signing**: Without `PRIVATE_KEY`, the deposit command creates a hosted web session. When you see the `url` output, display it as a clickable link.
|
|
121
121
|
- **Token names**: Use lowercase: `jbtc`, `jusdc`, `cbbtc`, `usdc`.
|
|
122
122
|
- **Amount format**: Human-readable (e.g., `0.01` BTC, `1000` USDC). The CLI handles decimal conversion.
|
|
123
123
|
- **Cross-chain**: Tokens are bridged from Base (chain 8453) to JasperVault (chain 55531) via Hyperlane.
|