@vincentai/cli 0.1.1
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/dist/commands/brave/news.js +25 -0
- package/dist/commands/brave/web.js +33 -0
- package/dist/commands/polymarket/balance.js +13 -0
- package/dist/commands/polymarket/bet.js +27 -0
- package/dist/commands/polymarket/cancel-all.js +13 -0
- package/dist/commands/polymarket/cancel-order.js +17 -0
- package/dist/commands/polymarket/holdings.js +13 -0
- package/dist/commands/polymarket/market.js +17 -0
- package/dist/commands/polymarket/markets.js +31 -0
- package/dist/commands/polymarket/open-orders.js +20 -0
- package/dist/commands/polymarket/orderbook.js +17 -0
- package/dist/commands/polymarket/redeem.js +20 -0
- package/dist/commands/polymarket/trades.js +13 -0
- package/dist/commands/raw-signer/addresses.js +13 -0
- package/dist/commands/raw-signer/sign.js +20 -0
- package/dist/commands/secret/create.js +41 -0
- package/dist/commands/secret/list.js +17 -0
- package/dist/commands/secret/relink.js +35 -0
- package/dist/commands/trade-manager/create-rule.js +34 -0
- package/dist/commands/trade-manager/delete-rule.js +19 -0
- package/dist/commands/trade-manager/events.js +30 -0
- package/dist/commands/trade-manager/health.js +11 -0
- package/dist/commands/trade-manager/list-rules.js +20 -0
- package/dist/commands/trade-manager/positions.js +15 -0
- package/dist/commands/trade-manager/status.js +13 -0
- package/dist/commands/trade-manager/update-rule.js +20 -0
- package/dist/commands/twitter/search.js +29 -0
- package/dist/commands/twitter/tweet.js +17 -0
- package/dist/commands/twitter/user-tweets.js +22 -0
- package/dist/commands/twitter/user.js +17 -0
- package/dist/commands/wallet/address.js +18 -0
- package/dist/commands/wallet/balances.js +20 -0
- package/dist/commands/wallet/send-tx.js +25 -0
- package/dist/commands/wallet/swap.js +36 -0
- package/dist/commands/wallet/transfer-between.js +57 -0
- package/dist/commands/wallet/transfer.js +25 -0
- package/dist/index.js +111 -0
- package/dist/lib/args.js +71 -0
- package/dist/lib/client.js +61 -0
- package/dist/lib/keystore.js +99 -0
- package/dist/lib/types.js +1 -0
- package/package.json +32 -0
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { parseArgs, getRequired, getOptional, hasFlag, showHelp } from '../../lib/args.js';
|
|
2
|
+
import { resolveApiKey } from '../../lib/keystore.js';
|
|
3
|
+
import { vincentGet } from '../../lib/client.js';
|
|
4
|
+
export async function run(argv) {
|
|
5
|
+
const { flags } = parseArgs(argv);
|
|
6
|
+
if (hasFlag(flags, 'help')) {
|
|
7
|
+
showHelp('brave news', [
|
|
8
|
+
{ name: 'key-id', description: 'API key ID' },
|
|
9
|
+
{ name: 'q', description: 'Search query', required: true },
|
|
10
|
+
{ name: 'count', description: 'Number of results (1-20)' },
|
|
11
|
+
{ name: 'freshness', description: 'Time filter: pd, pw, pm, py' },
|
|
12
|
+
]);
|
|
13
|
+
return;
|
|
14
|
+
}
|
|
15
|
+
const apiKey = resolveApiKey(flags, 'DATA_SOURCES');
|
|
16
|
+
const params = { q: getRequired(flags, 'q') };
|
|
17
|
+
const count = getOptional(flags, 'count');
|
|
18
|
+
if (count)
|
|
19
|
+
params.count = count;
|
|
20
|
+
const freshness = getOptional(flags, 'freshness');
|
|
21
|
+
if (freshness)
|
|
22
|
+
params.freshness = freshness;
|
|
23
|
+
const res = await vincentGet('/api/data-sources/brave/news', apiKey, params);
|
|
24
|
+
console.log(JSON.stringify(res, null, 2));
|
|
25
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { parseArgs, getRequired, getOptional, hasFlag, showHelp } from '../../lib/args.js';
|
|
2
|
+
import { resolveApiKey } from '../../lib/keystore.js';
|
|
3
|
+
import { vincentGet } from '../../lib/client.js';
|
|
4
|
+
export async function run(argv) {
|
|
5
|
+
const { flags } = parseArgs(argv);
|
|
6
|
+
if (hasFlag(flags, 'help')) {
|
|
7
|
+
showHelp('brave web', [
|
|
8
|
+
{ name: 'key-id', description: 'API key ID' },
|
|
9
|
+
{ name: 'q', description: 'Search query', required: true },
|
|
10
|
+
{ name: 'count', description: 'Number of results (1-20)' },
|
|
11
|
+
{ name: 'offset', description: 'Pagination offset (0-9)' },
|
|
12
|
+
{ name: 'freshness', description: 'Time filter: pd, pw, pm, py' },
|
|
13
|
+
{ name: 'country', description: '2-letter country code' },
|
|
14
|
+
]);
|
|
15
|
+
return;
|
|
16
|
+
}
|
|
17
|
+
const apiKey = resolveApiKey(flags, 'DATA_SOURCES');
|
|
18
|
+
const params = { q: getRequired(flags, 'q') };
|
|
19
|
+
const count = getOptional(flags, 'count');
|
|
20
|
+
if (count)
|
|
21
|
+
params.count = count;
|
|
22
|
+
const offset = getOptional(flags, 'offset');
|
|
23
|
+
if (offset)
|
|
24
|
+
params.offset = offset;
|
|
25
|
+
const freshness = getOptional(flags, 'freshness');
|
|
26
|
+
if (freshness)
|
|
27
|
+
params.freshness = freshness;
|
|
28
|
+
const country = getOptional(flags, 'country');
|
|
29
|
+
if (country)
|
|
30
|
+
params.country = country;
|
|
31
|
+
const res = await vincentGet('/api/data-sources/brave/web', apiKey, params);
|
|
32
|
+
console.log(JSON.stringify(res, null, 2));
|
|
33
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { parseArgs, hasFlag, showHelp } from '../../lib/args.js';
|
|
2
|
+
import { resolveApiKey } from '../../lib/keystore.js';
|
|
3
|
+
import { vincentGet } from '../../lib/client.js';
|
|
4
|
+
export async function run(argv) {
|
|
5
|
+
const { flags } = parseArgs(argv);
|
|
6
|
+
if (hasFlag(flags, 'help')) {
|
|
7
|
+
showHelp('polymarket balance', [{ name: 'key-id', description: 'API key ID' }]);
|
|
8
|
+
return;
|
|
9
|
+
}
|
|
10
|
+
const apiKey = resolveApiKey(flags, 'POLYMARKET_WALLET');
|
|
11
|
+
const res = await vincentGet('/api/skills/polymarket/balance', apiKey);
|
|
12
|
+
console.log(JSON.stringify(res, null, 2));
|
|
13
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { parseArgs, getRequired, getOptional, hasFlag, showHelp } from '../../lib/args.js';
|
|
2
|
+
import { resolveApiKey } from '../../lib/keystore.js';
|
|
3
|
+
import { vincentPost } from '../../lib/client.js';
|
|
4
|
+
export async function run(argv) {
|
|
5
|
+
const { flags } = parseArgs(argv);
|
|
6
|
+
if (hasFlag(flags, 'help')) {
|
|
7
|
+
showHelp('polymarket bet', [
|
|
8
|
+
{ name: 'key-id', description: 'API key ID' },
|
|
9
|
+
{ name: 'token-id', description: 'Outcome token ID', required: true },
|
|
10
|
+
{ name: 'side', description: 'BUY or SELL', required: true },
|
|
11
|
+
{ name: 'amount', description: 'USD amount (BUY) or shares (SELL)', required: true },
|
|
12
|
+
{ name: 'price', description: 'Limit price 0.01-0.99 (omit for market order)' },
|
|
13
|
+
]);
|
|
14
|
+
return;
|
|
15
|
+
}
|
|
16
|
+
const apiKey = resolveApiKey(flags, 'POLYMARKET_WALLET');
|
|
17
|
+
const body = {
|
|
18
|
+
tokenId: getRequired(flags, 'token-id'),
|
|
19
|
+
side: getRequired(flags, 'side'),
|
|
20
|
+
amount: Number(getRequired(flags, 'amount')),
|
|
21
|
+
};
|
|
22
|
+
const price = getOptional(flags, 'price');
|
|
23
|
+
if (price)
|
|
24
|
+
body.price = Number(price);
|
|
25
|
+
const res = await vincentPost('/api/skills/polymarket/bet', apiKey, body);
|
|
26
|
+
console.log(JSON.stringify(res, null, 2));
|
|
27
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { parseArgs, hasFlag, showHelp } from '../../lib/args.js';
|
|
2
|
+
import { resolveApiKey } from '../../lib/keystore.js';
|
|
3
|
+
import { vincentDelete } from '../../lib/client.js';
|
|
4
|
+
export async function run(argv) {
|
|
5
|
+
const { flags } = parseArgs(argv);
|
|
6
|
+
if (hasFlag(flags, 'help')) {
|
|
7
|
+
showHelp('polymarket cancel-all', [{ name: 'key-id', description: 'API key ID' }]);
|
|
8
|
+
return;
|
|
9
|
+
}
|
|
10
|
+
const apiKey = resolveApiKey(flags, 'POLYMARKET_WALLET');
|
|
11
|
+
const res = await vincentDelete('/api/skills/polymarket/orders', apiKey);
|
|
12
|
+
console.log(JSON.stringify(res, null, 2));
|
|
13
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { parseArgs, getRequired, hasFlag, showHelp } from '../../lib/args.js';
|
|
2
|
+
import { resolveApiKey } from '../../lib/keystore.js';
|
|
3
|
+
import { vincentDelete } from '../../lib/client.js';
|
|
4
|
+
export async function run(argv) {
|
|
5
|
+
const { flags } = parseArgs(argv);
|
|
6
|
+
if (hasFlag(flags, 'help')) {
|
|
7
|
+
showHelp('polymarket cancel-order', [
|
|
8
|
+
{ name: 'key-id', description: 'API key ID' },
|
|
9
|
+
{ name: 'order-id', description: 'Order ID to cancel', required: true },
|
|
10
|
+
]);
|
|
11
|
+
return;
|
|
12
|
+
}
|
|
13
|
+
const apiKey = resolveApiKey(flags, 'POLYMARKET_WALLET');
|
|
14
|
+
const orderId = getRequired(flags, 'order-id');
|
|
15
|
+
const res = await vincentDelete(`/api/skills/polymarket/orders/${orderId}`, apiKey);
|
|
16
|
+
console.log(JSON.stringify(res, null, 2));
|
|
17
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { parseArgs, hasFlag, showHelp } from '../../lib/args.js';
|
|
2
|
+
import { resolveApiKey } from '../../lib/keystore.js';
|
|
3
|
+
import { vincentGet } from '../../lib/client.js';
|
|
4
|
+
export async function run(argv) {
|
|
5
|
+
const { flags } = parseArgs(argv);
|
|
6
|
+
if (hasFlag(flags, 'help')) {
|
|
7
|
+
showHelp('polymarket holdings', [{ name: 'key-id', description: 'API key ID' }]);
|
|
8
|
+
return;
|
|
9
|
+
}
|
|
10
|
+
const apiKey = resolveApiKey(flags, 'POLYMARKET_WALLET');
|
|
11
|
+
const res = await vincentGet('/api/skills/polymarket/holdings', apiKey);
|
|
12
|
+
console.log(JSON.stringify(res, null, 2));
|
|
13
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { parseArgs, getRequired, hasFlag, showHelp } from '../../lib/args.js';
|
|
2
|
+
import { resolveApiKey } from '../../lib/keystore.js';
|
|
3
|
+
import { vincentGet } from '../../lib/client.js';
|
|
4
|
+
export async function run(argv) {
|
|
5
|
+
const { flags } = parseArgs(argv);
|
|
6
|
+
if (hasFlag(flags, 'help')) {
|
|
7
|
+
showHelp('polymarket market', [
|
|
8
|
+
{ name: 'key-id', description: 'API key ID' },
|
|
9
|
+
{ name: 'condition-id', description: 'Market condition ID', required: true },
|
|
10
|
+
]);
|
|
11
|
+
return;
|
|
12
|
+
}
|
|
13
|
+
const apiKey = resolveApiKey(flags, 'POLYMARKET_WALLET');
|
|
14
|
+
const conditionId = getRequired(flags, 'condition-id');
|
|
15
|
+
const res = await vincentGet(`/api/skills/polymarket/market/${conditionId}`, apiKey);
|
|
16
|
+
console.log(JSON.stringify(res, null, 2));
|
|
17
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { parseArgs, getOptional, hasFlag, showHelp } from '../../lib/args.js';
|
|
2
|
+
import { resolveApiKey } from '../../lib/keystore.js';
|
|
3
|
+
import { vincentGet } from '../../lib/client.js';
|
|
4
|
+
export async function run(argv) {
|
|
5
|
+
const { flags } = parseArgs(argv);
|
|
6
|
+
if (hasFlag(flags, 'help')) {
|
|
7
|
+
showHelp('polymarket markets', [
|
|
8
|
+
{ name: 'key-id', description: 'API key ID' },
|
|
9
|
+
{ name: 'query', description: 'Search query' },
|
|
10
|
+
{ name: 'slug', description: 'Market slug or Polymarket URL' },
|
|
11
|
+
{ name: 'active', description: 'Only active markets (flag)' },
|
|
12
|
+
{ name: 'limit', description: 'Max results (default: 20)' },
|
|
13
|
+
]);
|
|
14
|
+
return;
|
|
15
|
+
}
|
|
16
|
+
const apiKey = resolveApiKey(flags, 'POLYMARKET_WALLET');
|
|
17
|
+
const params = {};
|
|
18
|
+
const query = getOptional(flags, 'query');
|
|
19
|
+
if (query)
|
|
20
|
+
params.query = query;
|
|
21
|
+
const slug = getOptional(flags, 'slug');
|
|
22
|
+
if (slug)
|
|
23
|
+
params.slug = slug;
|
|
24
|
+
if (flags['active'] === true || flags['active'] === 'true')
|
|
25
|
+
params.active = 'true';
|
|
26
|
+
const limit = getOptional(flags, 'limit');
|
|
27
|
+
if (limit)
|
|
28
|
+
params.limit = limit;
|
|
29
|
+
const res = await vincentGet('/api/skills/polymarket/markets', apiKey, params);
|
|
30
|
+
console.log(JSON.stringify(res, null, 2));
|
|
31
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { parseArgs, getOptional, hasFlag, showHelp } from '../../lib/args.js';
|
|
2
|
+
import { resolveApiKey } from '../../lib/keystore.js';
|
|
3
|
+
import { vincentGet } from '../../lib/client.js';
|
|
4
|
+
export async function run(argv) {
|
|
5
|
+
const { flags } = parseArgs(argv);
|
|
6
|
+
if (hasFlag(flags, 'help')) {
|
|
7
|
+
showHelp('polymarket open-orders', [
|
|
8
|
+
{ name: 'key-id', description: 'API key ID' },
|
|
9
|
+
{ name: 'market', description: 'Filter by market condition ID' },
|
|
10
|
+
]);
|
|
11
|
+
return;
|
|
12
|
+
}
|
|
13
|
+
const apiKey = resolveApiKey(flags, 'POLYMARKET_WALLET');
|
|
14
|
+
const params = {};
|
|
15
|
+
const market = getOptional(flags, 'market');
|
|
16
|
+
if (market)
|
|
17
|
+
params.market = market;
|
|
18
|
+
const res = await vincentGet('/api/skills/polymarket/open-orders', apiKey, params);
|
|
19
|
+
console.log(JSON.stringify(res, null, 2));
|
|
20
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { parseArgs, getRequired, hasFlag, showHelp } from '../../lib/args.js';
|
|
2
|
+
import { resolveApiKey } from '../../lib/keystore.js';
|
|
3
|
+
import { vincentGet } from '../../lib/client.js';
|
|
4
|
+
export async function run(argv) {
|
|
5
|
+
const { flags } = parseArgs(argv);
|
|
6
|
+
if (hasFlag(flags, 'help')) {
|
|
7
|
+
showHelp('polymarket orderbook', [
|
|
8
|
+
{ name: 'key-id', description: 'API key ID' },
|
|
9
|
+
{ name: 'token-id', description: 'Outcome token ID', required: true },
|
|
10
|
+
]);
|
|
11
|
+
return;
|
|
12
|
+
}
|
|
13
|
+
const apiKey = resolveApiKey(flags, 'POLYMARKET_WALLET');
|
|
14
|
+
const tokenId = getRequired(flags, 'token-id');
|
|
15
|
+
const res = await vincentGet(`/api/skills/polymarket/orderbook/${tokenId}`, apiKey);
|
|
16
|
+
console.log(JSON.stringify(res, null, 2));
|
|
17
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { parseArgs, getOptional, hasFlag, showHelp } from '../../lib/args.js';
|
|
2
|
+
import { resolveApiKey } from '../../lib/keystore.js';
|
|
3
|
+
import { vincentPost } from '../../lib/client.js';
|
|
4
|
+
export async function run(argv) {
|
|
5
|
+
const { flags } = parseArgs(argv);
|
|
6
|
+
if (hasFlag(flags, 'help')) {
|
|
7
|
+
showHelp('polymarket redeem', [
|
|
8
|
+
{ name: 'key-id', description: 'API key ID' },
|
|
9
|
+
{ name: 'condition-ids', description: 'Comma-separated condition IDs (omit to redeem all)' },
|
|
10
|
+
]);
|
|
11
|
+
return;
|
|
12
|
+
}
|
|
13
|
+
const apiKey = resolveApiKey(flags, 'POLYMARKET_WALLET');
|
|
14
|
+
const body = {};
|
|
15
|
+
const conditionIds = getOptional(flags, 'condition-ids');
|
|
16
|
+
if (conditionIds)
|
|
17
|
+
body.conditionIds = conditionIds.split(',');
|
|
18
|
+
const res = await vincentPost('/api/skills/polymarket/redeem', apiKey, body);
|
|
19
|
+
console.log(JSON.stringify(res, null, 2));
|
|
20
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { parseArgs, hasFlag, showHelp } from '../../lib/args.js';
|
|
2
|
+
import { resolveApiKey } from '../../lib/keystore.js';
|
|
3
|
+
import { vincentGet } from '../../lib/client.js';
|
|
4
|
+
export async function run(argv) {
|
|
5
|
+
const { flags } = parseArgs(argv);
|
|
6
|
+
if (hasFlag(flags, 'help')) {
|
|
7
|
+
showHelp('polymarket trades', [{ name: 'key-id', description: 'API key ID' }]);
|
|
8
|
+
return;
|
|
9
|
+
}
|
|
10
|
+
const apiKey = resolveApiKey(flags, 'POLYMARKET_WALLET');
|
|
11
|
+
const res = await vincentGet('/api/skills/polymarket/trades', apiKey);
|
|
12
|
+
console.log(JSON.stringify(res, null, 2));
|
|
13
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { parseArgs, hasFlag, showHelp } from '../../lib/args.js';
|
|
2
|
+
import { resolveApiKey } from '../../lib/keystore.js';
|
|
3
|
+
import { vincentGet } from '../../lib/client.js';
|
|
4
|
+
export async function run(argv) {
|
|
5
|
+
const { flags } = parseArgs(argv);
|
|
6
|
+
if (hasFlag(flags, 'help')) {
|
|
7
|
+
showHelp('raw-signer addresses', [{ name: 'key-id', description: 'API key ID' }]);
|
|
8
|
+
return;
|
|
9
|
+
}
|
|
10
|
+
const apiKey = resolveApiKey(flags, 'RAW_SIGNER');
|
|
11
|
+
const res = await vincentGet('/api/skills/raw-signer/addresses', apiKey);
|
|
12
|
+
console.log(JSON.stringify(res, null, 2));
|
|
13
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { parseArgs, getRequired, hasFlag, showHelp } from '../../lib/args.js';
|
|
2
|
+
import { resolveApiKey } from '../../lib/keystore.js';
|
|
3
|
+
import { vincentPost } from '../../lib/client.js';
|
|
4
|
+
export async function run(argv) {
|
|
5
|
+
const { flags } = parseArgs(argv);
|
|
6
|
+
if (hasFlag(flags, 'help')) {
|
|
7
|
+
showHelp('raw-signer sign', [
|
|
8
|
+
{ name: 'key-id', description: 'API key ID' },
|
|
9
|
+
{ name: 'message', description: 'Hex-encoded message to sign (0x...)', required: true },
|
|
10
|
+
{ name: 'curve', description: 'Signing curve: ethereum or solana', required: true },
|
|
11
|
+
]);
|
|
12
|
+
return;
|
|
13
|
+
}
|
|
14
|
+
const apiKey = resolveApiKey(flags, 'RAW_SIGNER');
|
|
15
|
+
const res = await vincentPost('/api/skills/raw-signer/sign', apiKey, {
|
|
16
|
+
message: getRequired(flags, 'message'),
|
|
17
|
+
curve: getRequired(flags, 'curve'),
|
|
18
|
+
});
|
|
19
|
+
console.log(JSON.stringify(res, null, 2));
|
|
20
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { parseArgs, getRequired, getOptional, hasFlag, showHelp } from '../../lib/args.js';
|
|
2
|
+
import { vincentPost } from '../../lib/client.js';
|
|
3
|
+
import { storeKey } from '../../lib/keystore.js';
|
|
4
|
+
export async function run(argv) {
|
|
5
|
+
const { flags } = parseArgs(argv);
|
|
6
|
+
if (hasFlag(flags, 'help')) {
|
|
7
|
+
showHelp('secret create', [
|
|
8
|
+
{
|
|
9
|
+
name: 'type',
|
|
10
|
+
description: 'Secret type (EVM_WALLET, RAW_SIGNER, POLYMARKET_WALLET, DATA_SOURCES)',
|
|
11
|
+
required: true,
|
|
12
|
+
},
|
|
13
|
+
{ name: 'memo', description: 'Description for this secret', required: true },
|
|
14
|
+
{ name: 'chain-id', description: 'Chain ID (for EVM_WALLET)' },
|
|
15
|
+
]);
|
|
16
|
+
return;
|
|
17
|
+
}
|
|
18
|
+
const type = getRequired(flags, 'type');
|
|
19
|
+
const memo = getRequired(flags, 'memo');
|
|
20
|
+
const chainId = getOptional(flags, 'chain-id');
|
|
21
|
+
const body = { type, memo };
|
|
22
|
+
if (chainId)
|
|
23
|
+
body.chainId = Number(chainId);
|
|
24
|
+
const res = (await vincentPost('/api/secrets', null, body));
|
|
25
|
+
const apiKey = res.apiKey;
|
|
26
|
+
const keyId = res.apiKeyId || res.id;
|
|
27
|
+
storeKey({
|
|
28
|
+
id: keyId,
|
|
29
|
+
apiKey,
|
|
30
|
+
type,
|
|
31
|
+
memo,
|
|
32
|
+
secretId: res.secretId || res.id,
|
|
33
|
+
createdAt: new Date().toISOString(),
|
|
34
|
+
});
|
|
35
|
+
console.log(JSON.stringify({
|
|
36
|
+
keyId,
|
|
37
|
+
claimUrl: res.claimUrl,
|
|
38
|
+
address: res.address,
|
|
39
|
+
secretId: res.secretId || res.id,
|
|
40
|
+
}, null, 2));
|
|
41
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { parseArgs, getOptional, hasFlag, showHelp } from '../../lib/args.js';
|
|
2
|
+
import { listKeys } from '../../lib/keystore.js';
|
|
3
|
+
export async function run(argv) {
|
|
4
|
+
const { flags } = parseArgs(argv);
|
|
5
|
+
if (hasFlag(flags, 'help')) {
|
|
6
|
+
showHelp('secret list', [
|
|
7
|
+
{
|
|
8
|
+
name: 'type',
|
|
9
|
+
description: 'Filter by type (EVM_WALLET, RAW_SIGNER, POLYMARKET_WALLET, DATA_SOURCES)',
|
|
10
|
+
},
|
|
11
|
+
]);
|
|
12
|
+
return;
|
|
13
|
+
}
|
|
14
|
+
const type = getOptional(flags, 'type');
|
|
15
|
+
const keys = listKeys(type);
|
|
16
|
+
console.log(JSON.stringify(keys.map((k) => ({ id: k.id, type: k.type, memo: k.memo, createdAt: k.createdAt })), null, 2));
|
|
17
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { parseArgs, getRequired, hasFlag, showHelp } from '../../lib/args.js';
|
|
2
|
+
import { vincentPost } from '../../lib/client.js';
|
|
3
|
+
import { storeKey } from '../../lib/keystore.js';
|
|
4
|
+
export async function run(argv) {
|
|
5
|
+
const { flags } = parseArgs(argv);
|
|
6
|
+
if (hasFlag(flags, 'help')) {
|
|
7
|
+
showHelp('secret relink', [
|
|
8
|
+
{ name: 'token', description: 'Re-link token from the wallet owner', required: true },
|
|
9
|
+
]);
|
|
10
|
+
return;
|
|
11
|
+
}
|
|
12
|
+
const token = getRequired(flags, 'token');
|
|
13
|
+
const res = (await vincentPost('/api/secrets/relink', null, {
|
|
14
|
+
relinkToken: token,
|
|
15
|
+
apiKeyName: 'Re-linked API Key',
|
|
16
|
+
}));
|
|
17
|
+
const secret = res.secret;
|
|
18
|
+
const apiKeyObj = res.apiKey;
|
|
19
|
+
const apiKey = apiKeyObj.key;
|
|
20
|
+
const keyId = apiKeyObj.id;
|
|
21
|
+
const type = secret.type;
|
|
22
|
+
storeKey({
|
|
23
|
+
id: keyId,
|
|
24
|
+
apiKey,
|
|
25
|
+
type,
|
|
26
|
+
memo: `Re-linked ${type}`,
|
|
27
|
+
secretId: secret.id,
|
|
28
|
+
createdAt: new Date().toISOString(),
|
|
29
|
+
});
|
|
30
|
+
console.log(JSON.stringify({
|
|
31
|
+
keyId,
|
|
32
|
+
secretId: secret.id,
|
|
33
|
+
type,
|
|
34
|
+
}, null, 2));
|
|
35
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { parseArgs, getRequired, getOptional, hasFlag, showHelp } from '../../lib/args.js';
|
|
2
|
+
import { resolveApiKey } from '../../lib/keystore.js';
|
|
3
|
+
import { vincentPost, getTradeManagerBaseUrl } from '../../lib/client.js';
|
|
4
|
+
export async function run(argv) {
|
|
5
|
+
const { flags } = parseArgs(argv);
|
|
6
|
+
if (hasFlag(flags, 'help')) {
|
|
7
|
+
showHelp('trade-manager create-rule', [
|
|
8
|
+
{ name: 'key-id', description: 'Polymarket API key ID' },
|
|
9
|
+
{ name: 'market-id', description: 'Market condition ID', required: true },
|
|
10
|
+
{ name: 'token-id', description: 'Outcome token ID', required: true },
|
|
11
|
+
{
|
|
12
|
+
name: 'rule-type',
|
|
13
|
+
description: 'STOP_LOSS, TAKE_PROFIT, or TRAILING_STOP',
|
|
14
|
+
required: true,
|
|
15
|
+
},
|
|
16
|
+
{ name: 'trigger-price', description: 'Trigger price (0-1)', required: true },
|
|
17
|
+
{ name: 'trailing-percent', description: 'Trailing percent (TRAILING_STOP only)' },
|
|
18
|
+
]);
|
|
19
|
+
return;
|
|
20
|
+
}
|
|
21
|
+
const apiKey = resolveApiKey(flags, 'POLYMARKET_WALLET');
|
|
22
|
+
const body = {
|
|
23
|
+
marketId: getRequired(flags, 'market-id'),
|
|
24
|
+
tokenId: getRequired(flags, 'token-id'),
|
|
25
|
+
ruleType: getRequired(flags, 'rule-type'),
|
|
26
|
+
triggerPrice: Number(getRequired(flags, 'trigger-price')),
|
|
27
|
+
action: { type: 'SELL_ALL' },
|
|
28
|
+
};
|
|
29
|
+
const trailingPercent = getOptional(flags, 'trailing-percent');
|
|
30
|
+
if (trailingPercent)
|
|
31
|
+
body.trailingPercent = Number(trailingPercent);
|
|
32
|
+
const res = await vincentPost('/api/rules', apiKey, body, { baseUrl: getTradeManagerBaseUrl() });
|
|
33
|
+
console.log(JSON.stringify(res, null, 2));
|
|
34
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { parseArgs, getRequired, hasFlag, showHelp } from '../../lib/args.js';
|
|
2
|
+
import { resolveApiKey } from '../../lib/keystore.js';
|
|
3
|
+
import { vincentDelete, getTradeManagerBaseUrl } from '../../lib/client.js';
|
|
4
|
+
export async function run(argv) {
|
|
5
|
+
const { flags } = parseArgs(argv);
|
|
6
|
+
if (hasFlag(flags, 'help')) {
|
|
7
|
+
showHelp('trade-manager delete-rule', [
|
|
8
|
+
{ name: 'key-id', description: 'Polymarket API key ID' },
|
|
9
|
+
{ name: 'rule-id', description: 'Rule ID to delete', required: true },
|
|
10
|
+
]);
|
|
11
|
+
return;
|
|
12
|
+
}
|
|
13
|
+
const apiKey = resolveApiKey(flags, 'POLYMARKET_WALLET');
|
|
14
|
+
const ruleId = getRequired(flags, 'rule-id');
|
|
15
|
+
const res = await vincentDelete(`/api/rules/${ruleId}`, apiKey, {
|
|
16
|
+
baseUrl: getTradeManagerBaseUrl(),
|
|
17
|
+
});
|
|
18
|
+
console.log(JSON.stringify(res, null, 2));
|
|
19
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { parseArgs, getOptional, hasFlag, showHelp } from '../../lib/args.js';
|
|
2
|
+
import { resolveApiKey } from '../../lib/keystore.js';
|
|
3
|
+
import { vincentGet, getTradeManagerBaseUrl } from '../../lib/client.js';
|
|
4
|
+
export async function run(argv) {
|
|
5
|
+
const { flags } = parseArgs(argv);
|
|
6
|
+
if (hasFlag(flags, 'help')) {
|
|
7
|
+
showHelp('trade-manager events', [
|
|
8
|
+
{ name: 'key-id', description: 'Polymarket API key ID' },
|
|
9
|
+
{ name: 'rule-id', description: 'Filter by rule ID' },
|
|
10
|
+
{ name: 'limit', description: 'Max results (1-1000, default: 100)' },
|
|
11
|
+
{ name: 'offset', description: 'Pagination offset' },
|
|
12
|
+
]);
|
|
13
|
+
return;
|
|
14
|
+
}
|
|
15
|
+
const apiKey = resolveApiKey(flags, 'POLYMARKET_WALLET');
|
|
16
|
+
const params = {};
|
|
17
|
+
const ruleId = getOptional(flags, 'rule-id');
|
|
18
|
+
if (ruleId)
|
|
19
|
+
params.ruleId = ruleId;
|
|
20
|
+
const limit = getOptional(flags, 'limit');
|
|
21
|
+
if (limit)
|
|
22
|
+
params.limit = limit;
|
|
23
|
+
const offset = getOptional(flags, 'offset');
|
|
24
|
+
if (offset)
|
|
25
|
+
params.offset = offset;
|
|
26
|
+
const res = await vincentGet('/api/events', apiKey, params, {
|
|
27
|
+
baseUrl: getTradeManagerBaseUrl(),
|
|
28
|
+
});
|
|
29
|
+
console.log(JSON.stringify(res, null, 2));
|
|
30
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { parseArgs, hasFlag, showHelp } from '../../lib/args.js';
|
|
2
|
+
import { vincentGet, getTradeManagerBaseUrl } from '../../lib/client.js';
|
|
3
|
+
export async function run(argv) {
|
|
4
|
+
const { flags } = parseArgs(argv);
|
|
5
|
+
if (hasFlag(flags, 'help')) {
|
|
6
|
+
showHelp('trade-manager health', []);
|
|
7
|
+
return;
|
|
8
|
+
}
|
|
9
|
+
const res = await vincentGet('/health', null, undefined, { baseUrl: getTradeManagerBaseUrl() });
|
|
10
|
+
console.log(JSON.stringify(res, null, 2));
|
|
11
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { parseArgs, getOptional, hasFlag, showHelp } from '../../lib/args.js';
|
|
2
|
+
import { resolveApiKey } from '../../lib/keystore.js';
|
|
3
|
+
import { vincentGet, getTradeManagerBaseUrl } from '../../lib/client.js';
|
|
4
|
+
export async function run(argv) {
|
|
5
|
+
const { flags } = parseArgs(argv);
|
|
6
|
+
if (hasFlag(flags, 'help')) {
|
|
7
|
+
showHelp('trade-manager list-rules', [
|
|
8
|
+
{ name: 'key-id', description: 'Polymarket API key ID' },
|
|
9
|
+
{ name: 'status', description: 'Filter by status (ACTIVE, TRIGGERED, CANCELED, FAILED)' },
|
|
10
|
+
]);
|
|
11
|
+
return;
|
|
12
|
+
}
|
|
13
|
+
const apiKey = resolveApiKey(flags, 'POLYMARKET_WALLET');
|
|
14
|
+
const params = {};
|
|
15
|
+
const status = getOptional(flags, 'status');
|
|
16
|
+
if (status)
|
|
17
|
+
params.status = status;
|
|
18
|
+
const res = await vincentGet('/api/rules', apiKey, params, { baseUrl: getTradeManagerBaseUrl() });
|
|
19
|
+
console.log(JSON.stringify(res, null, 2));
|
|
20
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { parseArgs, hasFlag, showHelp } from '../../lib/args.js';
|
|
2
|
+
import { resolveApiKey } from '../../lib/keystore.js';
|
|
3
|
+
import { vincentGet, getTradeManagerBaseUrl } from '../../lib/client.js';
|
|
4
|
+
export async function run(argv) {
|
|
5
|
+
const { flags } = parseArgs(argv);
|
|
6
|
+
if (hasFlag(flags, 'help')) {
|
|
7
|
+
showHelp('trade-manager positions', [{ name: 'key-id', description: 'Polymarket API key ID' }]);
|
|
8
|
+
return;
|
|
9
|
+
}
|
|
10
|
+
const apiKey = resolveApiKey(flags, 'POLYMARKET_WALLET');
|
|
11
|
+
const res = await vincentGet('/api/positions', apiKey, undefined, {
|
|
12
|
+
baseUrl: getTradeManagerBaseUrl(),
|
|
13
|
+
});
|
|
14
|
+
console.log(JSON.stringify(res, null, 2));
|
|
15
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { parseArgs, hasFlag, showHelp } from '../../lib/args.js';
|
|
2
|
+
import { resolveApiKey } from '../../lib/keystore.js';
|
|
3
|
+
import { vincentGet, getTradeManagerBaseUrl } from '../../lib/client.js';
|
|
4
|
+
export async function run(argv) {
|
|
5
|
+
const { flags } = parseArgs(argv);
|
|
6
|
+
if (hasFlag(flags, 'help')) {
|
|
7
|
+
showHelp('trade-manager status', [{ name: 'key-id', description: 'Polymarket API key ID' }]);
|
|
8
|
+
return;
|
|
9
|
+
}
|
|
10
|
+
const apiKey = resolveApiKey(flags, 'POLYMARKET_WALLET');
|
|
11
|
+
const res = await vincentGet('/status', apiKey, undefined, { baseUrl: getTradeManagerBaseUrl() });
|
|
12
|
+
console.log(JSON.stringify(res, null, 2));
|
|
13
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { parseArgs, getRequired, hasFlag, showHelp } from '../../lib/args.js';
|
|
2
|
+
import { resolveApiKey } from '../../lib/keystore.js';
|
|
3
|
+
import { vincentPatch, getTradeManagerBaseUrl } from '../../lib/client.js';
|
|
4
|
+
export async function run(argv) {
|
|
5
|
+
const { flags } = parseArgs(argv);
|
|
6
|
+
if (hasFlag(flags, 'help')) {
|
|
7
|
+
showHelp('trade-manager update-rule', [
|
|
8
|
+
{ name: 'key-id', description: 'Polymarket API key ID' },
|
|
9
|
+
{ name: 'rule-id', description: 'Rule ID to update', required: true },
|
|
10
|
+
{ name: 'trigger-price', description: 'New trigger price', required: true },
|
|
11
|
+
]);
|
|
12
|
+
return;
|
|
13
|
+
}
|
|
14
|
+
const apiKey = resolveApiKey(flags, 'POLYMARKET_WALLET');
|
|
15
|
+
const ruleId = getRequired(flags, 'rule-id');
|
|
16
|
+
const res = await vincentPatch(`/api/rules/${ruleId}`, apiKey, {
|
|
17
|
+
triggerPrice: Number(getRequired(flags, 'trigger-price')),
|
|
18
|
+
}, { baseUrl: getTradeManagerBaseUrl() });
|
|
19
|
+
console.log(JSON.stringify(res, null, 2));
|
|
20
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { parseArgs, getRequired, getOptional, hasFlag, showHelp } from '../../lib/args.js';
|
|
2
|
+
import { resolveApiKey } from '../../lib/keystore.js';
|
|
3
|
+
import { vincentGet } from '../../lib/client.js';
|
|
4
|
+
export async function run(argv) {
|
|
5
|
+
const { flags } = parseArgs(argv);
|
|
6
|
+
if (hasFlag(flags, 'help')) {
|
|
7
|
+
showHelp('twitter search', [
|
|
8
|
+
{ name: 'key-id', description: 'API key ID' },
|
|
9
|
+
{ name: 'q', description: 'Search query', required: true },
|
|
10
|
+
{ name: 'max-results', description: 'Max results (default: 10)' },
|
|
11
|
+
{ name: 'start-time', description: 'Start time (ISO 8601)' },
|
|
12
|
+
{ name: 'end-time', description: 'End time (ISO 8601)' },
|
|
13
|
+
]);
|
|
14
|
+
return;
|
|
15
|
+
}
|
|
16
|
+
const apiKey = resolveApiKey(flags, 'DATA_SOURCES');
|
|
17
|
+
const params = { q: getRequired(flags, 'q') };
|
|
18
|
+
const maxResults = getOptional(flags, 'max-results');
|
|
19
|
+
if (maxResults)
|
|
20
|
+
params.max_results = maxResults;
|
|
21
|
+
const startTime = getOptional(flags, 'start-time');
|
|
22
|
+
if (startTime)
|
|
23
|
+
params.start_time = startTime;
|
|
24
|
+
const endTime = getOptional(flags, 'end-time');
|
|
25
|
+
if (endTime)
|
|
26
|
+
params.end_time = endTime;
|
|
27
|
+
const res = await vincentGet('/api/data-sources/twitter/search', apiKey, params);
|
|
28
|
+
console.log(JSON.stringify(res, null, 2));
|
|
29
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { parseArgs, getRequired, hasFlag, showHelp } from '../../lib/args.js';
|
|
2
|
+
import { resolveApiKey } from '../../lib/keystore.js';
|
|
3
|
+
import { vincentGet } from '../../lib/client.js';
|
|
4
|
+
export async function run(argv) {
|
|
5
|
+
const { flags } = parseArgs(argv);
|
|
6
|
+
if (hasFlag(flags, 'help')) {
|
|
7
|
+
showHelp('twitter tweet', [
|
|
8
|
+
{ name: 'key-id', description: 'API key ID' },
|
|
9
|
+
{ name: 'tweet-id', description: 'Tweet ID', required: true },
|
|
10
|
+
]);
|
|
11
|
+
return;
|
|
12
|
+
}
|
|
13
|
+
const apiKey = resolveApiKey(flags, 'DATA_SOURCES');
|
|
14
|
+
const tweetId = getRequired(flags, 'tweet-id');
|
|
15
|
+
const res = await vincentGet(`/api/data-sources/twitter/tweets/${tweetId}`, apiKey);
|
|
16
|
+
console.log(JSON.stringify(res, null, 2));
|
|
17
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { parseArgs, getRequired, getOptional, hasFlag, showHelp } from '../../lib/args.js';
|
|
2
|
+
import { resolveApiKey } from '../../lib/keystore.js';
|
|
3
|
+
import { vincentGet } from '../../lib/client.js';
|
|
4
|
+
export async function run(argv) {
|
|
5
|
+
const { flags } = parseArgs(argv);
|
|
6
|
+
if (hasFlag(flags, 'help')) {
|
|
7
|
+
showHelp('twitter user-tweets', [
|
|
8
|
+
{ name: 'key-id', description: 'API key ID' },
|
|
9
|
+
{ name: 'user-id', description: 'Twitter user ID', required: true },
|
|
10
|
+
{ name: 'max-results', description: 'Max results' },
|
|
11
|
+
]);
|
|
12
|
+
return;
|
|
13
|
+
}
|
|
14
|
+
const apiKey = resolveApiKey(flags, 'DATA_SOURCES');
|
|
15
|
+
const userId = getRequired(flags, 'user-id');
|
|
16
|
+
const params = {};
|
|
17
|
+
const maxResults = getOptional(flags, 'max-results');
|
|
18
|
+
if (maxResults)
|
|
19
|
+
params.max_results = maxResults;
|
|
20
|
+
const res = await vincentGet(`/api/data-sources/twitter/users/${userId}/tweets`, apiKey, params);
|
|
21
|
+
console.log(JSON.stringify(res, null, 2));
|
|
22
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { parseArgs, getRequired, hasFlag, showHelp } from '../../lib/args.js';
|
|
2
|
+
import { resolveApiKey } from '../../lib/keystore.js';
|
|
3
|
+
import { vincentGet } from '../../lib/client.js';
|
|
4
|
+
export async function run(argv) {
|
|
5
|
+
const { flags } = parseArgs(argv);
|
|
6
|
+
if (hasFlag(flags, 'help')) {
|
|
7
|
+
showHelp('twitter user', [
|
|
8
|
+
{ name: 'key-id', description: 'API key ID' },
|
|
9
|
+
{ name: 'username', description: 'Twitter username', required: true },
|
|
10
|
+
]);
|
|
11
|
+
return;
|
|
12
|
+
}
|
|
13
|
+
const apiKey = resolveApiKey(flags, 'DATA_SOURCES');
|
|
14
|
+
const username = getRequired(flags, 'username');
|
|
15
|
+
const res = await vincentGet(`/api/data-sources/twitter/users/${username}`, apiKey);
|
|
16
|
+
console.log(JSON.stringify(res, null, 2));
|
|
17
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { parseArgs, hasFlag, showHelp } from '../../lib/args.js';
|
|
2
|
+
import { resolveApiKey } from '../../lib/keystore.js';
|
|
3
|
+
import { vincentGet } from '../../lib/client.js';
|
|
4
|
+
export async function run(argv) {
|
|
5
|
+
const { flags } = parseArgs(argv);
|
|
6
|
+
if (hasFlag(flags, 'help')) {
|
|
7
|
+
showHelp('wallet address', [
|
|
8
|
+
{
|
|
9
|
+
name: 'key-id',
|
|
10
|
+
description: 'API key ID (auto-discovered if only one EVM_WALLET key exists)',
|
|
11
|
+
},
|
|
12
|
+
]);
|
|
13
|
+
return;
|
|
14
|
+
}
|
|
15
|
+
const apiKey = resolveApiKey(flags, 'EVM_WALLET');
|
|
16
|
+
const res = await vincentGet('/api/skills/evm-wallet/address', apiKey);
|
|
17
|
+
console.log(JSON.stringify(res, null, 2));
|
|
18
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { parseArgs, getOptional, hasFlag, showHelp } from '../../lib/args.js';
|
|
2
|
+
import { resolveApiKey } from '../../lib/keystore.js';
|
|
3
|
+
import { vincentGet } from '../../lib/client.js';
|
|
4
|
+
export async function run(argv) {
|
|
5
|
+
const { flags } = parseArgs(argv);
|
|
6
|
+
if (hasFlag(flags, 'help')) {
|
|
7
|
+
showHelp('wallet balances', [
|
|
8
|
+
{ name: 'key-id', description: 'API key ID' },
|
|
9
|
+
{ name: 'chain-ids', description: 'Comma-separated chain IDs to filter' },
|
|
10
|
+
]);
|
|
11
|
+
return;
|
|
12
|
+
}
|
|
13
|
+
const apiKey = resolveApiKey(flags, 'EVM_WALLET');
|
|
14
|
+
const params = {};
|
|
15
|
+
const chainIds = getOptional(flags, 'chain-ids');
|
|
16
|
+
if (chainIds)
|
|
17
|
+
params.chainIds = chainIds;
|
|
18
|
+
const res = await vincentGet('/api/skills/evm-wallet/balances', apiKey, params);
|
|
19
|
+
console.log(JSON.stringify(res, null, 2));
|
|
20
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { parseArgs, getRequired, getOptional, hasFlag, showHelp } from '../../lib/args.js';
|
|
2
|
+
import { resolveApiKey } from '../../lib/keystore.js';
|
|
3
|
+
import { vincentPost } from '../../lib/client.js';
|
|
4
|
+
export async function run(argv) {
|
|
5
|
+
const { flags } = parseArgs(argv);
|
|
6
|
+
if (hasFlag(flags, 'help')) {
|
|
7
|
+
showHelp('wallet send-tx', [
|
|
8
|
+
{ name: 'key-id', description: 'API key ID' },
|
|
9
|
+
{ name: 'to', description: 'Contract address', required: true },
|
|
10
|
+
{ name: 'data', description: 'Hex-encoded calldata', required: true },
|
|
11
|
+
{ name: 'value', description: 'ETH value to send (default: 0)' },
|
|
12
|
+
]);
|
|
13
|
+
return;
|
|
14
|
+
}
|
|
15
|
+
const apiKey = resolveApiKey(flags, 'EVM_WALLET');
|
|
16
|
+
const body = {
|
|
17
|
+
to: getRequired(flags, 'to'),
|
|
18
|
+
data: getRequired(flags, 'data'),
|
|
19
|
+
};
|
|
20
|
+
const value = getOptional(flags, 'value');
|
|
21
|
+
if (value)
|
|
22
|
+
body.value = value;
|
|
23
|
+
const res = await vincentPost('/api/skills/evm-wallet/send-transaction', apiKey, body);
|
|
24
|
+
console.log(JSON.stringify(res, null, 2));
|
|
25
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { parseArgs, getRequired, getOptional, hasFlag, showHelp } from '../../lib/args.js';
|
|
2
|
+
import { resolveApiKey } from '../../lib/keystore.js';
|
|
3
|
+
import { vincentPost } from '../../lib/client.js';
|
|
4
|
+
export async function run(argv) {
|
|
5
|
+
const { flags, positional } = parseArgs(argv);
|
|
6
|
+
const subcommand = positional[0];
|
|
7
|
+
if (hasFlag(flags, 'help') || !subcommand) {
|
|
8
|
+
showHelp('wallet swap <preview|execute>', [
|
|
9
|
+
{ name: 'key-id', description: 'API key ID' },
|
|
10
|
+
{ name: 'sell-token', description: 'Token address to sell', required: true },
|
|
11
|
+
{ name: 'buy-token', description: 'Token address to buy', required: true },
|
|
12
|
+
{ name: 'sell-amount', description: 'Amount to sell', required: true },
|
|
13
|
+
{ name: 'chain-id', description: 'Chain ID', required: true },
|
|
14
|
+
{ name: 'slippage', description: 'Slippage tolerance in basis points (execute only)' },
|
|
15
|
+
]);
|
|
16
|
+
return;
|
|
17
|
+
}
|
|
18
|
+
if (subcommand !== 'preview' && subcommand !== 'execute') {
|
|
19
|
+
console.error(`Unknown subcommand: ${subcommand}. Use "preview" or "execute".`);
|
|
20
|
+
process.exit(1);
|
|
21
|
+
}
|
|
22
|
+
const apiKey = resolveApiKey(flags, 'EVM_WALLET');
|
|
23
|
+
const body = {
|
|
24
|
+
sellToken: getRequired(flags, 'sell-token'),
|
|
25
|
+
buyToken: getRequired(flags, 'buy-token'),
|
|
26
|
+
sellAmount: getRequired(flags, 'sell-amount'),
|
|
27
|
+
chainId: Number(getRequired(flags, 'chain-id')),
|
|
28
|
+
};
|
|
29
|
+
if (subcommand === 'execute') {
|
|
30
|
+
const slippage = getOptional(flags, 'slippage');
|
|
31
|
+
if (slippage)
|
|
32
|
+
body.slippageBps = Number(slippage);
|
|
33
|
+
}
|
|
34
|
+
const res = await vincentPost(`/api/skills/evm-wallet/swap/${subcommand}`, apiKey, body);
|
|
35
|
+
console.log(JSON.stringify(res, null, 2));
|
|
36
|
+
}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { parseArgs, getRequired, getOptional, hasFlag, showHelp } from '../../lib/args.js';
|
|
2
|
+
import { resolveApiKey } from '../../lib/keystore.js';
|
|
3
|
+
import { vincentPost, vincentGet } from '../../lib/client.js';
|
|
4
|
+
export async function run(argv) {
|
|
5
|
+
const { flags, positional } = parseArgs(argv);
|
|
6
|
+
const subcommand = positional[0];
|
|
7
|
+
if (hasFlag(flags, 'help') || !subcommand) {
|
|
8
|
+
showHelp('wallet transfer-between <preview|execute|status>', [
|
|
9
|
+
{ name: 'key-id', description: 'API key ID' },
|
|
10
|
+
{
|
|
11
|
+
name: 'to-secret-id',
|
|
12
|
+
description: 'Destination secret ID (preview/execute)',
|
|
13
|
+
required: true,
|
|
14
|
+
},
|
|
15
|
+
{ name: 'from-chain', description: 'Source chain ID (preview/execute)', required: true },
|
|
16
|
+
{ name: 'to-chain', description: 'Destination chain ID (preview/execute)', required: true },
|
|
17
|
+
{
|
|
18
|
+
name: 'token-in',
|
|
19
|
+
description: 'Input token address or ETH (preview/execute)',
|
|
20
|
+
required: true,
|
|
21
|
+
},
|
|
22
|
+
{ name: 'amount', description: 'Amount to transfer (preview/execute)', required: true },
|
|
23
|
+
{
|
|
24
|
+
name: 'token-out',
|
|
25
|
+
description: 'Output token address or ETH (preview/execute)',
|
|
26
|
+
required: true,
|
|
27
|
+
},
|
|
28
|
+
{ name: 'slippage', description: 'Slippage in basis points' },
|
|
29
|
+
{ name: 'relay-id', description: 'Relay request ID (status only)' },
|
|
30
|
+
]);
|
|
31
|
+
return;
|
|
32
|
+
}
|
|
33
|
+
if (subcommand !== 'preview' && subcommand !== 'execute' && subcommand !== 'status') {
|
|
34
|
+
console.error(`Unknown subcommand: ${subcommand}. Use "preview", "execute", or "status".`);
|
|
35
|
+
process.exit(1);
|
|
36
|
+
}
|
|
37
|
+
const apiKey = resolveApiKey(flags, 'EVM_WALLET');
|
|
38
|
+
if (subcommand === 'status') {
|
|
39
|
+
const relayId = getRequired(flags, 'relay-id');
|
|
40
|
+
const res = await vincentGet(`/api/skills/evm-wallet/transfer-between-secrets/status/${relayId}`, apiKey);
|
|
41
|
+
console.log(JSON.stringify(res, null, 2));
|
|
42
|
+
return;
|
|
43
|
+
}
|
|
44
|
+
const body = {
|
|
45
|
+
toSecretId: getRequired(flags, 'to-secret-id'),
|
|
46
|
+
fromChainId: Number(getRequired(flags, 'from-chain')),
|
|
47
|
+
toChainId: Number(getRequired(flags, 'to-chain')),
|
|
48
|
+
tokenIn: getRequired(flags, 'token-in'),
|
|
49
|
+
tokenInAmount: getRequired(flags, 'amount'),
|
|
50
|
+
tokenOut: getRequired(flags, 'token-out'),
|
|
51
|
+
};
|
|
52
|
+
const slippage = getOptional(flags, 'slippage');
|
|
53
|
+
if (slippage)
|
|
54
|
+
body.slippage = Number(slippage);
|
|
55
|
+
const res = await vincentPost(`/api/skills/evm-wallet/transfer-between-secrets/${subcommand}`, apiKey, body);
|
|
56
|
+
console.log(JSON.stringify(res, null, 2));
|
|
57
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { parseArgs, getRequired, getOptional, hasFlag, showHelp } from '../../lib/args.js';
|
|
2
|
+
import { resolveApiKey } from '../../lib/keystore.js';
|
|
3
|
+
import { vincentPost } from '../../lib/client.js';
|
|
4
|
+
export async function run(argv) {
|
|
5
|
+
const { flags } = parseArgs(argv);
|
|
6
|
+
if (hasFlag(flags, 'help')) {
|
|
7
|
+
showHelp('wallet transfer', [
|
|
8
|
+
{ name: 'key-id', description: 'API key ID' },
|
|
9
|
+
{ name: 'to', description: 'Recipient address', required: true },
|
|
10
|
+
{ name: 'amount', description: 'Amount to transfer', required: true },
|
|
11
|
+
{ name: 'token', description: 'ERC-20 token contract address (omit for native ETH)' },
|
|
12
|
+
]);
|
|
13
|
+
return;
|
|
14
|
+
}
|
|
15
|
+
const apiKey = resolveApiKey(flags, 'EVM_WALLET');
|
|
16
|
+
const body = {
|
|
17
|
+
to: getRequired(flags, 'to'),
|
|
18
|
+
amount: getRequired(flags, 'amount'),
|
|
19
|
+
};
|
|
20
|
+
const token = getOptional(flags, 'token');
|
|
21
|
+
if (token)
|
|
22
|
+
body.token = token;
|
|
23
|
+
const res = await vincentPost('/api/skills/evm-wallet/transfer', apiKey, body);
|
|
24
|
+
console.log(JSON.stringify(res, null, 2));
|
|
25
|
+
}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
const COMMANDS = {
|
|
3
|
+
secret: {
|
|
4
|
+
create: () => import('./commands/secret/create.js'),
|
|
5
|
+
relink: () => import('./commands/secret/relink.js'),
|
|
6
|
+
list: () => import('./commands/secret/list.js'),
|
|
7
|
+
},
|
|
8
|
+
wallet: {
|
|
9
|
+
address: () => import('./commands/wallet/address.js'),
|
|
10
|
+
balances: () => import('./commands/wallet/balances.js'),
|
|
11
|
+
transfer: () => import('./commands/wallet/transfer.js'),
|
|
12
|
+
swap: () => import('./commands/wallet/swap.js'),
|
|
13
|
+
'send-tx': () => import('./commands/wallet/send-tx.js'),
|
|
14
|
+
'transfer-between': () => import('./commands/wallet/transfer-between.js'),
|
|
15
|
+
},
|
|
16
|
+
'raw-signer': {
|
|
17
|
+
addresses: () => import('./commands/raw-signer/addresses.js'),
|
|
18
|
+
sign: () => import('./commands/raw-signer/sign.js'),
|
|
19
|
+
},
|
|
20
|
+
polymarket: {
|
|
21
|
+
balance: () => import('./commands/polymarket/balance.js'),
|
|
22
|
+
markets: () => import('./commands/polymarket/markets.js'),
|
|
23
|
+
market: () => import('./commands/polymarket/market.js'),
|
|
24
|
+
orderbook: () => import('./commands/polymarket/orderbook.js'),
|
|
25
|
+
bet: () => import('./commands/polymarket/bet.js'),
|
|
26
|
+
holdings: () => import('./commands/polymarket/holdings.js'),
|
|
27
|
+
'open-orders': () => import('./commands/polymarket/open-orders.js'),
|
|
28
|
+
trades: () => import('./commands/polymarket/trades.js'),
|
|
29
|
+
'cancel-order': () => import('./commands/polymarket/cancel-order.js'),
|
|
30
|
+
'cancel-all': () => import('./commands/polymarket/cancel-all.js'),
|
|
31
|
+
redeem: () => import('./commands/polymarket/redeem.js'),
|
|
32
|
+
},
|
|
33
|
+
twitter: {
|
|
34
|
+
search: () => import('./commands/twitter/search.js'),
|
|
35
|
+
tweet: () => import('./commands/twitter/tweet.js'),
|
|
36
|
+
user: () => import('./commands/twitter/user.js'),
|
|
37
|
+
'user-tweets': () => import('./commands/twitter/user-tweets.js'),
|
|
38
|
+
},
|
|
39
|
+
brave: {
|
|
40
|
+
web: () => import('./commands/brave/web.js'),
|
|
41
|
+
news: () => import('./commands/brave/news.js'),
|
|
42
|
+
},
|
|
43
|
+
'trade-manager': {
|
|
44
|
+
health: () => import('./commands/trade-manager/health.js'),
|
|
45
|
+
status: () => import('./commands/trade-manager/status.js'),
|
|
46
|
+
'create-rule': () => import('./commands/trade-manager/create-rule.js'),
|
|
47
|
+
'list-rules': () => import('./commands/trade-manager/list-rules.js'),
|
|
48
|
+
'update-rule': () => import('./commands/trade-manager/update-rule.js'),
|
|
49
|
+
'delete-rule': () => import('./commands/trade-manager/delete-rule.js'),
|
|
50
|
+
positions: () => import('./commands/trade-manager/positions.js'),
|
|
51
|
+
events: () => import('./commands/trade-manager/events.js'),
|
|
52
|
+
},
|
|
53
|
+
};
|
|
54
|
+
function printHelp() {
|
|
55
|
+
console.log(`Usage: vincent <group> <command> [options]
|
|
56
|
+
|
|
57
|
+
Groups and commands:
|
|
58
|
+
`);
|
|
59
|
+
for (const [group, commands] of Object.entries(COMMANDS)) {
|
|
60
|
+
console.log(` ${group}`);
|
|
61
|
+
for (const cmd of Object.keys(commands)) {
|
|
62
|
+
console.log(` ${cmd}`);
|
|
63
|
+
}
|
|
64
|
+
console.log();
|
|
65
|
+
}
|
|
66
|
+
console.log('Options:');
|
|
67
|
+
console.log(' --help Show help for a command');
|
|
68
|
+
console.log(' --version Show version');
|
|
69
|
+
}
|
|
70
|
+
async function main() {
|
|
71
|
+
const argv = process.argv.slice(2);
|
|
72
|
+
if (argv.length === 0 || argv[0] === '--help' || argv[0] === '-h') {
|
|
73
|
+
printHelp();
|
|
74
|
+
process.exit(0);
|
|
75
|
+
}
|
|
76
|
+
if (argv[0] === '--version' || argv[0] === '-v') {
|
|
77
|
+
console.log('0.1.0');
|
|
78
|
+
process.exit(0);
|
|
79
|
+
}
|
|
80
|
+
const group = argv[0];
|
|
81
|
+
const command = argv[1];
|
|
82
|
+
const rest = argv.slice(2);
|
|
83
|
+
const groupCommands = COMMANDS[group];
|
|
84
|
+
if (!groupCommands) {
|
|
85
|
+
console.error(`Unknown group: ${group}`);
|
|
86
|
+
console.error(`Run "vincent --help" for available groups.`);
|
|
87
|
+
process.exit(1);
|
|
88
|
+
}
|
|
89
|
+
if (!command || command === '--help' || command === '-h') {
|
|
90
|
+
console.log(`Available commands for "${group}":\n`);
|
|
91
|
+
for (const cmd of Object.keys(groupCommands)) {
|
|
92
|
+
console.log(` vincent ${group} ${cmd}`);
|
|
93
|
+
}
|
|
94
|
+
console.log(`\nRun "vincent ${group} <command> --help" for command-specific help.`);
|
|
95
|
+
process.exit(0);
|
|
96
|
+
}
|
|
97
|
+
const loader = groupCommands[command];
|
|
98
|
+
if (!loader) {
|
|
99
|
+
console.error(`Unknown command: ${group} ${command}`);
|
|
100
|
+
console.error(`Run "vincent ${group} --help" for available commands.`);
|
|
101
|
+
process.exit(1);
|
|
102
|
+
}
|
|
103
|
+
const mod = await loader();
|
|
104
|
+
await mod.run(rest);
|
|
105
|
+
}
|
|
106
|
+
main().catch((err) => {
|
|
107
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
108
|
+
console.error(`Error: ${message}`);
|
|
109
|
+
process.exit(1);
|
|
110
|
+
});
|
|
111
|
+
export {};
|
package/dist/lib/args.js
ADDED
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
export function parseArgs(argv) {
|
|
2
|
+
const flags = {};
|
|
3
|
+
const positional = [];
|
|
4
|
+
let i = 0;
|
|
5
|
+
while (i < argv.length) {
|
|
6
|
+
const arg = argv[i];
|
|
7
|
+
if (arg.startsWith('--')) {
|
|
8
|
+
const key = arg.slice(2);
|
|
9
|
+
const next = argv[i + 1];
|
|
10
|
+
if (next === undefined || next.startsWith('--')) {
|
|
11
|
+
flags[key] = true;
|
|
12
|
+
i++;
|
|
13
|
+
}
|
|
14
|
+
else {
|
|
15
|
+
flags[key] = next;
|
|
16
|
+
i += 2;
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
else {
|
|
20
|
+
positional.push(arg);
|
|
21
|
+
i++;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
return { flags, positional };
|
|
25
|
+
}
|
|
26
|
+
export function getRequired(flags, name) {
|
|
27
|
+
const val = flags[name];
|
|
28
|
+
if (typeof val !== 'string') {
|
|
29
|
+
console.error(`Missing required option: --${name}`);
|
|
30
|
+
process.exit(1);
|
|
31
|
+
}
|
|
32
|
+
return val;
|
|
33
|
+
}
|
|
34
|
+
export function getOptional(flags, name) {
|
|
35
|
+
const val = flags[name];
|
|
36
|
+
if (typeof val !== 'string')
|
|
37
|
+
return undefined;
|
|
38
|
+
return val;
|
|
39
|
+
}
|
|
40
|
+
export function getNumber(flags, name) {
|
|
41
|
+
const val = getOptional(flags, name);
|
|
42
|
+
if (val === undefined)
|
|
43
|
+
return undefined;
|
|
44
|
+
const n = Number(val);
|
|
45
|
+
if (isNaN(n)) {
|
|
46
|
+
console.error(`Invalid number for --${name}: ${val}`);
|
|
47
|
+
process.exit(1);
|
|
48
|
+
}
|
|
49
|
+
return n;
|
|
50
|
+
}
|
|
51
|
+
export function getRequiredNumber(flags, name) {
|
|
52
|
+
const val = getRequired(flags, name);
|
|
53
|
+
const n = Number(val);
|
|
54
|
+
if (isNaN(n)) {
|
|
55
|
+
console.error(`Invalid number for --${name}: ${val}`);
|
|
56
|
+
process.exit(1);
|
|
57
|
+
}
|
|
58
|
+
return n;
|
|
59
|
+
}
|
|
60
|
+
export function hasFlag(flags, name) {
|
|
61
|
+
return flags[name] === true || flags[name] !== undefined;
|
|
62
|
+
}
|
|
63
|
+
export function showHelp(command, args) {
|
|
64
|
+
console.log(`Usage: vincent ${command} [options]\n`);
|
|
65
|
+
console.log('Options:');
|
|
66
|
+
for (const arg of args) {
|
|
67
|
+
const req = arg.required ? ' (required)' : '';
|
|
68
|
+
console.log(` --${arg.name.padEnd(20)} ${arg.description}${req}`);
|
|
69
|
+
}
|
|
70
|
+
console.log(` --${'help'.padEnd(20)} Show this help message`);
|
|
71
|
+
}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
const DEFAULT_BASE_URL = 'https://heyvincent.ai';
|
|
2
|
+
const TRADE_MANAGER_BASE_URL = 'http://localhost:19000';
|
|
3
|
+
function getBaseUrl() {
|
|
4
|
+
return process.env.VINCENT_BASE_URL || DEFAULT_BASE_URL;
|
|
5
|
+
}
|
|
6
|
+
export function getTradeManagerBaseUrl() {
|
|
7
|
+
return process.env.VINCENT_TRADE_MANAGER_URL || TRADE_MANAGER_BASE_URL;
|
|
8
|
+
}
|
|
9
|
+
async function request(method, path, apiKey, body, opts) {
|
|
10
|
+
const base = opts?.baseUrl || getBaseUrl();
|
|
11
|
+
const url = `${base}${path}`;
|
|
12
|
+
const headers = {};
|
|
13
|
+
if (apiKey) {
|
|
14
|
+
headers['Authorization'] = `Bearer ${apiKey}`;
|
|
15
|
+
}
|
|
16
|
+
if (body !== undefined) {
|
|
17
|
+
headers['Content-Type'] = 'application/json';
|
|
18
|
+
}
|
|
19
|
+
const res = await fetch(url, {
|
|
20
|
+
method,
|
|
21
|
+
headers,
|
|
22
|
+
body: body !== undefined ? JSON.stringify(body) : undefined,
|
|
23
|
+
});
|
|
24
|
+
const text = await res.text();
|
|
25
|
+
let data;
|
|
26
|
+
try {
|
|
27
|
+
data = JSON.parse(text);
|
|
28
|
+
}
|
|
29
|
+
catch {
|
|
30
|
+
data = text;
|
|
31
|
+
}
|
|
32
|
+
if (!res.ok) {
|
|
33
|
+
const msg = typeof data === 'object' && data !== null
|
|
34
|
+
? data.message ||
|
|
35
|
+
data.error ||
|
|
36
|
+
text
|
|
37
|
+
: text;
|
|
38
|
+
console.error(`API error (${res.status}): ${msg}`);
|
|
39
|
+
process.exit(1);
|
|
40
|
+
}
|
|
41
|
+
return data;
|
|
42
|
+
}
|
|
43
|
+
export function vincentGet(path, apiKey, params, opts) {
|
|
44
|
+
let fullPath = path;
|
|
45
|
+
if (params) {
|
|
46
|
+
const entries = Object.entries(params).filter(([, v]) => v !== undefined && v !== '');
|
|
47
|
+
if (entries.length > 0) {
|
|
48
|
+
fullPath += '?' + new URLSearchParams(entries).toString();
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
return request('GET', fullPath, apiKey, undefined, opts);
|
|
52
|
+
}
|
|
53
|
+
export function vincentPost(path, apiKey, body, opts) {
|
|
54
|
+
return request('POST', path, apiKey, body, opts);
|
|
55
|
+
}
|
|
56
|
+
export function vincentDelete(path, apiKey, opts) {
|
|
57
|
+
return request('DELETE', path, apiKey, undefined, opts);
|
|
58
|
+
}
|
|
59
|
+
export function vincentPatch(path, apiKey, body, opts) {
|
|
60
|
+
return request('PATCH', path, apiKey, body, opts);
|
|
61
|
+
}
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
import { readFileSync, writeFileSync, mkdirSync, readdirSync, existsSync } from 'node:fs';
|
|
2
|
+
import { join } from 'node:path';
|
|
3
|
+
import { homedir } from 'node:os';
|
|
4
|
+
const TYPE_DIRS = {
|
|
5
|
+
EVM_WALLET: 'agentwallet',
|
|
6
|
+
POLYMARKET_WALLET: 'agentwallet',
|
|
7
|
+
RAW_SIGNER: 'agentwallet',
|
|
8
|
+
DATA_SOURCES: 'datasources',
|
|
9
|
+
};
|
|
10
|
+
function getCredentialsRoot() {
|
|
11
|
+
const stateDir = process.env.OPENCLAW_STATE_DIR || join(homedir(), '.openclaw');
|
|
12
|
+
return join(stateDir, 'credentials');
|
|
13
|
+
}
|
|
14
|
+
function getDirForType(type) {
|
|
15
|
+
const subdir = TYPE_DIRS[type];
|
|
16
|
+
if (!subdir) {
|
|
17
|
+
throw new Error(`Unknown secret type: ${type}`);
|
|
18
|
+
}
|
|
19
|
+
return join(getCredentialsRoot(), subdir);
|
|
20
|
+
}
|
|
21
|
+
export function storeKey(keyData) {
|
|
22
|
+
const dir = getDirForType(keyData.type);
|
|
23
|
+
mkdirSync(dir, { recursive: true });
|
|
24
|
+
const filePath = join(dir, `${keyData.id}.json`);
|
|
25
|
+
writeFileSync(filePath, JSON.stringify(keyData, null, 2) + '\n');
|
|
26
|
+
}
|
|
27
|
+
export function getKey(keyId) {
|
|
28
|
+
const root = getCredentialsRoot();
|
|
29
|
+
for (const subdir of ['agentwallet', 'datasources']) {
|
|
30
|
+
const filePath = join(root, subdir, `${keyId}.json`);
|
|
31
|
+
if (existsSync(filePath)) {
|
|
32
|
+
const data = JSON.parse(readFileSync(filePath, 'utf-8'));
|
|
33
|
+
return data.apiKey;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
console.error(`Key not found: ${keyId}`);
|
|
37
|
+
console.error(`Searched in: ${root}/agentwallet/ and ${root}/datasources/`);
|
|
38
|
+
process.exit(1);
|
|
39
|
+
}
|
|
40
|
+
export function getKeyData(keyId) {
|
|
41
|
+
const root = getCredentialsRoot();
|
|
42
|
+
for (const subdir of ['agentwallet', 'datasources']) {
|
|
43
|
+
const filePath = join(root, subdir, `${keyId}.json`);
|
|
44
|
+
if (existsSync(filePath)) {
|
|
45
|
+
return JSON.parse(readFileSync(filePath, 'utf-8'));
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
console.error(`Key not found: ${keyId}`);
|
|
49
|
+
console.error(`Searched in: ${root}/agentwallet/ and ${root}/datasources/`);
|
|
50
|
+
process.exit(1);
|
|
51
|
+
}
|
|
52
|
+
export function listKeys(type) {
|
|
53
|
+
const root = getCredentialsRoot();
|
|
54
|
+
const keys = [];
|
|
55
|
+
const subdirs = type ? [TYPE_DIRS[type]] : ['agentwallet', 'datasources'];
|
|
56
|
+
for (const subdir of subdirs) {
|
|
57
|
+
if (!subdir)
|
|
58
|
+
continue;
|
|
59
|
+
const dir = join(root, subdir);
|
|
60
|
+
if (!existsSync(dir))
|
|
61
|
+
continue;
|
|
62
|
+
for (const file of readdirSync(dir)) {
|
|
63
|
+
if (!file.endsWith('.json'))
|
|
64
|
+
continue;
|
|
65
|
+
try {
|
|
66
|
+
const data = JSON.parse(readFileSync(join(dir, file), 'utf-8'));
|
|
67
|
+
if (!type || data.type === type) {
|
|
68
|
+
keys.push(data);
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
catch {
|
|
72
|
+
// skip malformed files
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
return keys;
|
|
77
|
+
}
|
|
78
|
+
export function findKey(type) {
|
|
79
|
+
const keys = listKeys(type);
|
|
80
|
+
if (keys.length === 0) {
|
|
81
|
+
console.error(`No ${type} key found. Create one with: vincent secret create --type ${type}`);
|
|
82
|
+
process.exit(1);
|
|
83
|
+
}
|
|
84
|
+
if (keys.length > 1) {
|
|
85
|
+
console.error(`Multiple ${type} keys found. Specify one with --key-id:`);
|
|
86
|
+
for (const k of keys) {
|
|
87
|
+
console.error(` ${k.id} — ${k.memo}`);
|
|
88
|
+
}
|
|
89
|
+
process.exit(1);
|
|
90
|
+
}
|
|
91
|
+
return keys[0].apiKey;
|
|
92
|
+
}
|
|
93
|
+
export function resolveApiKey(flags, type) {
|
|
94
|
+
const keyId = flags['key-id'];
|
|
95
|
+
if (typeof keyId === 'string') {
|
|
96
|
+
return getKey(keyId);
|
|
97
|
+
}
|
|
98
|
+
return findKey(type);
|
|
99
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/package.json
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@vincentai/cli",
|
|
3
|
+
"version": "0.1.1",
|
|
4
|
+
"description": "CLI for Vincent AI agent skills",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"bin": {
|
|
7
|
+
"vincent": "./dist/index.js"
|
|
8
|
+
},
|
|
9
|
+
"files": [
|
|
10
|
+
"dist"
|
|
11
|
+
],
|
|
12
|
+
"scripts": {
|
|
13
|
+
"build": "tsc && chmod +x dist/index.js",
|
|
14
|
+
"dev": "tsx src/index.ts",
|
|
15
|
+
"typecheck": "tsc --noEmit",
|
|
16
|
+
"lint": "eslint src",
|
|
17
|
+
"prepublishOnly": "npm run build"
|
|
18
|
+
},
|
|
19
|
+
"engines": {
|
|
20
|
+
"node": ">=20.0.0"
|
|
21
|
+
},
|
|
22
|
+
"keywords": [
|
|
23
|
+
"vincent",
|
|
24
|
+
"ai-agent",
|
|
25
|
+
"wallet",
|
|
26
|
+
"cli"
|
|
27
|
+
],
|
|
28
|
+
"license": "ISC",
|
|
29
|
+
"publishConfig": {
|
|
30
|
+
"access": "public"
|
|
31
|
+
}
|
|
32
|
+
}
|