jaspervault_cli 1.0.27 → 1.0.29

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (57) hide show
  1. package/README.md +25 -24
  2. package/dist/bin/jv.js +6 -2
  3. package/dist/bin/jv.js.map +1 -1
  4. package/dist/src/client.js +28 -1
  5. package/dist/src/client.js.map +1 -1
  6. package/dist/src/commands/deposit.js +129 -125
  7. package/dist/src/commands/deposit.js.map +1 -1
  8. package/dist/src/commands/install.d.ts +2 -0
  9. package/dist/src/commands/install.js +184 -0
  10. package/dist/src/commands/install.js.map +1 -0
  11. package/dist/src/commands/limit-order.js +7 -0
  12. package/dist/src/commands/limit-order.js.map +1 -1
  13. package/dist/src/commands/mcp.d.ts +2 -0
  14. package/dist/src/commands/mcp.js +10 -0
  15. package/dist/src/commands/mcp.js.map +1 -0
  16. package/dist/src/commands/sl.js +12 -2
  17. package/dist/src/commands/sl.js.map +1 -1
  18. package/dist/src/commands/tp.js +12 -2
  19. package/dist/src/commands/tp.js.map +1 -1
  20. package/dist/src/commands/vault.js +111 -87
  21. package/dist/src/commands/vault.js.map +1 -1
  22. package/dist/src/commands/withdraw.d.ts +2 -0
  23. package/dist/src/commands/withdraw.js +114 -0
  24. package/dist/src/commands/withdraw.js.map +1 -0
  25. package/dist/src/mcp/executor.d.ts +23 -0
  26. package/dist/src/mcp/executor.js +75 -0
  27. package/dist/src/mcp/executor.js.map +1 -0
  28. package/dist/src/mcp/index.d.ts +1 -0
  29. package/dist/src/mcp/index.js +58 -0
  30. package/dist/src/mcp/index.js.map +1 -0
  31. package/dist/src/mcp/installer.d.ts +9 -0
  32. package/dist/src/mcp/installer.js +66 -0
  33. package/dist/src/mcp/installer.js.map +1 -0
  34. package/dist/src/mcp/tools.d.ts +15 -0
  35. package/dist/src/mcp/tools.js +250 -0
  36. package/dist/src/mcp/tools.js.map +1 -0
  37. package/dist/src/services/order-signer.js +1 -1
  38. package/dist/src/services/order-signer.js.map +1 -1
  39. package/dist/src/services/session-poller.d.ts +12 -0
  40. package/dist/src/services/session-poller.js +57 -0
  41. package/dist/src/services/session-poller.js.map +1 -0
  42. package/dist/src/templates/skill-body.d.ts +1 -1
  43. package/dist/src/templates/skill-body.js +1 -1
  44. package/dist/src/templates/skill-content/SKILL.core.md +52 -45
  45. package/dist/src/templates/skill-content/frontmatter/claude.md +1 -1
  46. package/dist/src/templates/skill-content/frontmatter/openclaw.md +2 -2
  47. package/dist/src/templates/skill-content/references/onboarding.md +68 -87
  48. package/dist/src/templates/skill-content/references/queries.md +58 -188
  49. package/dist/src/templates/skill-content/references/trading.md +128 -178
  50. package/dist/src/types.d.ts +13 -6
  51. package/dist/src/utils/config.d.ts +1 -1
  52. package/dist/src/utils/config.js +1 -1
  53. package/dist/src/utils/config.js.map +1 -1
  54. package/dist/src/utils/endpoints.d.ts +3 -0
  55. package/dist/src/utils/endpoints.js +5 -0
  56. package/dist/src/utils/endpoints.js.map +1 -1
  57. 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,IAAI,EAAE,SAAS,EAAE,WAAW,EAAE,oCAAoC,EAAE;gBAC3E,UAAU,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC,KAAK,EAAE,IAAI,CAAC,EAAE,WAAW,EAAE,qBAAqB,EAAE;gBACvF,YAAY,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC,KAAK,EAAE,KAAK,CAAC,EAAE,WAAW,EAAE,qBAAqB,EAAE;gBAC1F,QAAQ,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,WAAW,EAA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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,CAAC;AAQF;;GAEG;AACH,MAAM,CAAC,KAAK,UAAU,aAAa,CACjC,MAA4C,EAC5C,OAAqB,EACrB,OAAe;IAEf,MAAM,GAAG,GAAG,gBAAgB,CAAC,OAAO,CAAC,CAAC;IACtC,MAAM,MAAM,GAAG,SAAS,IAAI,MAAM,IAAI,MAAM,CAAC,OAAO,IAAI,OAAO,IAAI,MAAM,CAAC;IAC1E,MAAM,UAAU,GAAG,MAAoC,CAAC;IAExD,MAAM,aAAa,GAAG,OAAO,CAAC,aAAa,IAAI,UAAU,CAAC,aAAa,CAAC;IACxE,IAAI,CAAC,aAAa,IAAI,CAAC,MAAM,EAAE,CAAC;QAC9B,MAAM,IAAI,KAAK,CAAC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essionStatusResponse } 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;IAC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,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,IAAI,CAAC,GAAG,EAAE,GAAG,KAAK,CAAC,GAAG,IAAI,CAAC,CAAC;QACxD,IAAI,IAAI,CAAC,GAAG,EAAE,GAAG,aAAa,IAAI,qBAAqB,EAAE,CAAC;YACxD,OAAO,CAAC,MAAM,CAAC,KAAK,CAClB,IAAI,CAAC,SAAS,CAAC;gBACb,MAAM,EAAE,SAAS;gBACjB,KAAK,EAAE,cAAc;gBACrB,OAAO;gBACP,OAAO,EAAE,oDAAoD;aAC9D,CAAC,GAAG,IAAI,CACV,CAAC;YACF,aAAa,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;QAC7B,CAAC;QAED,MAAM,IAAI,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 skill install command.
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 skill install command.
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,51 +1,58 @@
1
1
  # JasperVault Trading Skill
2
2
 
3
- Trade perpetual contracts on JasperVault via the `jv` CLI (v{{CLI_VERSION}}). No private key is ever required.
4
-
5
- ## CRITICAL RULES (MUST FOLLOW — violations cause broken UX)
6
-
7
- 1. **WalletConnect ONLY**: ALWAYS use `jv vault setup`. NEVER suggest `jv vault init` (private-key mode). NEVER ask the user to set `PRIVATE_KEY`.
8
- 2. **QR Code Display**: When `jv vault setup` outputs JSON with a `qrCodeUrl` field, you MUST display the `qrCodeUrl` value as a clickable link to the user. This is the only QR code field in the output — there are no other QR representations.
9
- 3. **Long-running Commands**: `jv vault setup` is a long-running command (up to 2 min) that will be auto-backgrounded. After it backgrounds you receive a `sessionId` and the first JSON output (QR code). Show the QR link to the user, then poll every 15 seconds with `process poll` using that `sessionId` until you see the second JSON line containing `"success":true` or the process exits. See [references/onboarding.md](references/onboarding.md) for the full step-by-step flow.
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
- 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
- 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
- 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 WalletConnect**: `jv deposit` auto-detects signing mode. Without `PRIVATE_KEY`, it uses WalletConnect (QR scan). Follow the same QR display rules as `jv vault setup`. See [references/onboarding.md](references/onboarding.md).
15
-
16
- ## Activation Behavior
17
-
18
- 1. Check if vault is initialized: `jv orders list --pretty`
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 via WalletConnect — no private key needed."
21
- - Immediately run `jv vault setup --network jaspervault --timeout 120`.
22
- - Follow the QR code display instructions in [references/onboarding.md](references/onboarding.md).
23
- 3. If the command succeeds → vault is ready. Proceed with the user's request.
24
-
25
- ## Intent Command Reference
26
-
27
- | User Intent | Command | Details |
28
- |-------------|---------|---------|
29
- | Initialize / connect wallet | `jv vault setup` | [references/onboarding.md](references/onboarding.md) |
30
- | Deposit tokens from Base | `jv deposit --token <T> --amount <N>` | [references/onboarding.md](references/onboarding.md) |
31
- | Get current price | `jv price --symbol JBTC --pretty` | [references/queries.md](references/queries.md) |
32
- | Open position (market) | `jv order create --side long/short -m <usdc> --symbol JBTC` | [references/trading.md](references/trading.md) |
33
- | Open position (limit) | `jv order create ... --limit-price <N>` | [references/trading.md](references/trading.md) |
34
- | Reduce / close position | opposite-side `jv order create` | [references/trading.md](references/trading.md) |
35
- | Add size to position | same-side `jv order create` | [references/trading.md](references/trading.md) |
36
- | Set take-profit | `jv tp set --order-id <ID> --price <P> --symbol <S>` | [references/trading.md](references/trading.md) |
37
- | Set stop-loss | `jv sl set --order-id <ID> --price <P> --symbol <S>` | [references/trading.md](references/trading.md) |
38
- | Add PPO to existing position | `jv order protect --order-id <id> --symbol <S>` | [references/trading.md](references/trading.md) |
39
- | Open/add-size with PPO | add `--ppo` to `jv order create` | [references/trading.md](references/trading.md) |
40
- | Cancel PPO / remove hedge | order without `--ppo` (auto-cancels) | [references/trading.md](references/trading.md) |
41
- | Query positions / portfolio | `jv orders list --pretty` | [references/queries.md](references/queries.md) |
42
- | Get specific position | `jv orders get <orderId> --pretty` | [references/queries.md](references/queries.md) |
43
- | Portfolio statistics | `jv orders stats --pretty` | [references/queries.md](references/queries.md) |
44
- | Job execution status | `jv job status <jobId> --pretty` | [references/queries.md](references/queries.md) |
45
- | Manage limit orders | `jv limit-order list/status/cancel` | [references/queries.md](references/queries.md) |
3
+ Trade perpetual contracts on JasperVault using the `jasper-vault` MCP tools. No private key is ever required — the user signs in their browser.
4
+
5
+ ## How It Works
6
+
7
+ JasperVault provides MCP tools (via `jasper-vault` MCP server) for all trading operations. These tools handle timeouts, polling, and error recovery automatically. Always use MCP tools never run `jv` shell commands directly, because long-running operations like wallet setup will be killed by shell timeouts.
8
+
9
+ ## Important Behaviors
10
+
11
+ 1. **Browser signing**: `wallet_setup` and `deposit_via_browser` return a URL. Display it as a clickable link — the user opens it in their browser to connect their wallet and sign. The tool polls automatically and returns the result when done (up to 16 minutes).
12
+
13
+ 2. **Real-time prices**: Always call `get_price` before any price-dependent operation. Never guess prices they change every second.
14
+
15
+ 3. **PPO auto-cancellation**: The smart contract automatically cancels existing PPO hedge options when you execute any position operation (reduce, close, add size) without `ppo: true`. There is no separate "cancel PPO" tool. Attempting a separate cancellation risks unintended position closures.
16
+
17
+ 4. **Standalone PPO**: To add hedge protection to an existing position, use `protect_order`. Don't use `create_order` with `ppo: true` for this — that adds position size. `create_order` with `ppo` is only for opening new positions or adding size with protection.
18
+
19
+ 5. **Market order result**: `create_order` (without `limit_price`) auto-waits up to 60s for the on-chain result. If `status === "completed"`, the order is executed don't retry or place another order. The `operation` field contains raw on-chain data in wei — don't interpret it. Use `list_orders` to verify the actual position with human-readable fields.
20
+
21
+ 6. **Deposit flow**: `deposit_via_browser` returns a URL for the user to open in their browser. The tool polls automatically. If `arrived` is false after completion, tokens may still be in transit — tell the user to wait a few minutes.
22
+
23
+ ## Getting Started
24
+
25
+ Check if vault is initialized by calling `list_orders`. If it fails with errors like "delegation key not found" or "vault not initialized" or "no profile":
26
+ - Tell the user their vault needs initialization — they'll sign in their browser, no private key needed.
27
+ - Call `wallet_setup` and display the returned URL as a clickable link.
28
+ - Wait for the tool to return success, then proceed.
29
+
30
+ ## Intent MCP Tool Reference
31
+
32
+ | User Intent | MCP Tool | Key Parameters | Details |
33
+ |-------------|----------|----------------|---------|
34
+ | Initialize wallet | `wallet_setup` | | [onboarding](references/onboarding.md) |
35
+ | Deposit tokens | `deposit_via_browser` | `token`, `amount` | [onboarding](references/onboarding.md) |
36
+ | Withdraw tokens | `withdraw_via_browser` | `token`, `amount` | [onboarding](references/onboarding.md) |
37
+ | Get current price | `get_price` | `symbol` | [queries](references/queries.md) |
38
+ | Open position (market) | `create_order` | `side`, `symbol`, `margin` | [trading](references/trading.md) |
39
+ | Open position (limit) | `create_order` | + `limit_price` | [trading](references/trading.md) |
40
+ | Close position | `create_order` | opposite `side` | [trading](references/trading.md) |
41
+ | Add size | `create_order` | same `side` | [trading](references/trading.md) |
42
+ | Set take-profit | `set_take_profit` | `order_id`, `price`, `symbol` | [trading](references/trading.md) |
43
+ | Set stop-loss | `set_stop_loss` | `order_id`, `price`, `symbol` | [trading](references/trading.md) |
44
+ | Add PPO to existing | `protect_order` | `order_id`, `symbol` | [trading](references/trading.md) |
45
+ | Open with PPO | `create_order` | + `ppo: true` | [trading](references/trading.md) |
46
+ | Remove hedge | `create_order` | without `ppo` | [trading](references/trading.md) |
47
+ | List positions | `list_orders` | — | [queries](references/queries.md) |
48
+ | Get position detail | `get_order` | `order_id` | [queries](references/queries.md) |
49
+ | Portfolio stats | `get_order_stats` | — | [queries](references/queries.md) |
50
+ | Job status | `get_job_status` | `job_id` | [queries](references/queries.md) |
51
+ | List limit orders | `list_limit_orders` | `wallet` | [queries](references/queries.md) |
52
+ | Cancel limit order | `cancel_limit_order` | `limit_order_id` | [queries](references/queries.md) |
46
53
 
47
54
  ## Security
48
55
 
49
56
  - Never log or display private keys, signatures, or API keys.
50
- - The CLI signs orders via the delegation wallet in `~/.jaspervault/keys.json`.
51
- - Do NOT ask the user to set `PRIVATE_KEY`.
57
+ - The system signs orders via a delegation wallet stored in `~/.jaspervault/keys.json`.
58
+ - Never ask the user to set `PRIVATE_KEY` — that's for CI/automation only.
@@ -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 WalletConnect QR scan (no private key needed)."
3
+ description: "Trade perpetual contracts (perps) on JasperVault using the jasper-vault MCP tools — open/close positions, set TP/SL, manage limit orders, deposit/withdraw, and query portfolio. Initialize wallet via browser signing (no private key needed). Use this skill whenever the user mentions JasperVault, perps trading, opening positions, setting stop-loss or take-profit, depositing crypto, or checking their portfolio."
4
4
  ---
@@ -1,8 +1,8 @@
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 WalletConnect QR scan (no private key needed). JasperVault 上交易永续合约 做多做空、开仓平仓、止盈止损、限价单、持仓查询、充值,使用 WalletConnect 扫码初始化(无需私钥)。"
3
+ description: "Trade perpetual contracts (perps) on JasperVault using the jasper-vault MCP tools — open/close positions, set TP/SL, manage limit orders, deposit/withdraw, and query portfolio. Initialize wallet via browser signing (no private key needed). Use this skill whenever the user mentions JasperVault, perps trading, opening positions, setting stop-loss or take-profit, depositing crypto, or checking their portfolio."
4
4
  trigger: "jaspervault|jasper vault|jasper trading|jv|jv trade|jv order|在jasper交易|jasper 交易|初始化钱包|连接钱包|开仓|平仓|做多|做空|止盈|止损|查看持仓|永续合约"
5
- tools: [shell, process]
5
+ tools: [mcp]
6
6
  metadata:
7
7
  openclaw:
8
8
  requires: