@wenrwa/marketplace-cli 0.1.0 → 0.3.0
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 +18 -1
- package/dist/__tests__/agent.test.d.ts +1 -0
- package/dist/__tests__/agent.test.js +138 -0
- package/dist/__tests__/apps.test.d.ts +1 -0
- package/dist/__tests__/apps.test.js +160 -0
- package/dist/__tests__/auth.test.d.ts +1 -0
- package/dist/__tests__/auth.test.js +94 -0
- package/dist/__tests__/bounty.test.d.ts +1 -0
- package/dist/__tests__/bounty.test.js +185 -0
- package/dist/__tests__/client.test.d.ts +1 -0
- package/dist/__tests__/client.test.js +106 -0
- package/dist/__tests__/config.test.d.ts +1 -0
- package/dist/__tests__/config.test.js +99 -0
- package/dist/__tests__/dashboard-helpers.test.d.ts +1 -0
- package/dist/__tests__/dashboard-helpers.test.js +123 -0
- package/dist/__tests__/format.test.d.ts +1 -0
- package/dist/__tests__/format.test.js +144 -0
- package/dist/__tests__/helpers.d.ts +7 -0
- package/dist/__tests__/helpers.js +12 -0
- package/dist/__tests__/treasury.test.d.ts +1 -0
- package/dist/__tests__/treasury.test.js +122 -0
- package/dist/__tests__/websocket.test.d.ts +1 -0
- package/dist/__tests__/websocket.test.js +61 -0
- package/dist/__tests__/workspace.test.d.ts +1 -0
- package/dist/__tests__/workspace.test.js +105 -0
- package/dist/commands/agent.d.ts +0 -0
- package/dist/commands/agent.js +0 -0
- package/dist/commands/apps.d.ts +2 -0
- package/dist/commands/apps.js +200 -0
- package/dist/commands/auth.d.ts +0 -0
- package/dist/commands/auth.js +0 -0
- package/dist/commands/bounty.d.ts +0 -0
- package/dist/commands/bounty.js +128 -7
- package/dist/commands/dashboard.d.ts +31 -0
- package/dist/commands/dashboard.js +5 -0
- package/dist/commands/keys.d.ts +2 -0
- package/dist/commands/keys.js +72 -0
- package/dist/commands/treasury.d.ts +0 -0
- package/dist/commands/treasury.js +2 -2
- package/dist/commands/webhook.d.ts +2 -0
- package/dist/commands/webhook.js +131 -0
- package/dist/commands/workspace.d.ts +1 -0
- package/dist/commands/workspace.js +293 -14
- package/dist/index.d.ts +0 -0
- package/dist/index.js +8 -1
- package/dist/utils/client.d.ts +1 -0
- package/dist/utils/client.js +3 -0
- package/dist/utils/config.d.ts +0 -0
- package/dist/utils/config.js +0 -0
- package/dist/utils/format.d.ts +0 -1
- package/dist/utils/format.js +2 -11
- package/dist/utils/websocket.d.ts +0 -0
- package/dist/utils/websocket.js +0 -0
- package/package.json +5 -2
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.keysCommand = void 0;
|
|
7
|
+
const commander_1 = require("commander");
|
|
8
|
+
const chalk_1 = __importDefault(require("chalk"));
|
|
9
|
+
const client_1 = require("../utils/client");
|
|
10
|
+
const format_1 = require("../utils/format");
|
|
11
|
+
exports.keysCommand = new commander_1.Command('keys').description('API key management');
|
|
12
|
+
exports.keysCommand
|
|
13
|
+
.command('generate')
|
|
14
|
+
.option('--name <name>', 'Human-readable name for the key')
|
|
15
|
+
.description('Generate a new API key')
|
|
16
|
+
.action(async (opts) => {
|
|
17
|
+
try {
|
|
18
|
+
const client = (0, client_1.getClient)();
|
|
19
|
+
const data = await client.post('/keys/generate', { name: opts.name });
|
|
20
|
+
const rec = data.keyRecord;
|
|
21
|
+
(0, format_1.success)('API key generated');
|
|
22
|
+
console.log(` ID: ${rec.id}`);
|
|
23
|
+
console.log(` Name: ${rec.name || chalk_1.default.dim('(none)')}`);
|
|
24
|
+
console.log(` Prefix: ${rec.keyPrefix}`);
|
|
25
|
+
console.log();
|
|
26
|
+
console.log(chalk_1.default.yellow.bold(' Full key (shown once — save it now):'));
|
|
27
|
+
console.log(chalk_1.default.yellow(` ${data.key}`));
|
|
28
|
+
}
|
|
29
|
+
catch (err) {
|
|
30
|
+
(0, format_1.error)(err.message);
|
|
31
|
+
}
|
|
32
|
+
});
|
|
33
|
+
exports.keysCommand
|
|
34
|
+
.command('list')
|
|
35
|
+
.description('List your API keys')
|
|
36
|
+
.action(async () => {
|
|
37
|
+
try {
|
|
38
|
+
const client = (0, client_1.getClient)();
|
|
39
|
+
const data = await client.get('/keys');
|
|
40
|
+
const keys = data.keys || [];
|
|
41
|
+
if (keys.length === 0) {
|
|
42
|
+
console.log(chalk_1.default.dim(' No API keys'));
|
|
43
|
+
return;
|
|
44
|
+
}
|
|
45
|
+
(0, format_1.heading)('API Keys');
|
|
46
|
+
console.log((0, format_1.makeTable)(['ID', 'Name', 'Prefix', 'Permissions', 'Last Used', 'Active'], keys.map((k) => [
|
|
47
|
+
(0, format_1.shorten)(k.id),
|
|
48
|
+
k.name || chalk_1.default.dim('—'),
|
|
49
|
+
k.keyPrefix,
|
|
50
|
+
k.permissions?.length ? k.permissions.join(', ') : chalk_1.default.dim('all'),
|
|
51
|
+
k.lastUsedAt ? (0, format_1.formatTimeAgo)(k.lastUsedAt) : chalk_1.default.dim('never'),
|
|
52
|
+
k.isActive ? chalk_1.default.green('yes') : chalk_1.default.red('no'),
|
|
53
|
+
])));
|
|
54
|
+
}
|
|
55
|
+
catch (err) {
|
|
56
|
+
(0, format_1.error)(err.message);
|
|
57
|
+
}
|
|
58
|
+
});
|
|
59
|
+
exports.keysCommand
|
|
60
|
+
.command('revoke')
|
|
61
|
+
.argument('<key-id>', 'API key ID to revoke')
|
|
62
|
+
.description('Revoke an API key')
|
|
63
|
+
.action(async (keyId) => {
|
|
64
|
+
try {
|
|
65
|
+
const client = (0, client_1.getClient)();
|
|
66
|
+
await client.del(`/keys/${keyId}`);
|
|
67
|
+
(0, format_1.success)(`API key ${(0, format_1.shorten)(keyId)} revoked`);
|
|
68
|
+
}
|
|
69
|
+
catch (err) {
|
|
70
|
+
(0, format_1.error)(err.message);
|
|
71
|
+
}
|
|
72
|
+
});
|
|
File without changes
|
|
@@ -57,7 +57,7 @@ exports.treasuryCommand
|
|
|
57
57
|
exports.treasuryCommand
|
|
58
58
|
.command('fund')
|
|
59
59
|
.argument('<workspace-id>', 'Workspace ID')
|
|
60
|
-
.requiredOption('--amount <amount>', 'Amount in
|
|
60
|
+
.requiredOption('--amount <amount>', 'Amount in USDC micro-units')
|
|
61
61
|
.option('--tx-signature <sig>', 'On-chain transaction signature')
|
|
62
62
|
.description('Fund workspace treasury')
|
|
63
63
|
.action(async (workspaceId, opts) => {
|
|
@@ -76,7 +76,7 @@ exports.treasuryCommand
|
|
|
76
76
|
exports.treasuryCommand
|
|
77
77
|
.command('distribute')
|
|
78
78
|
.argument('<workspace-id>', 'Workspace ID')
|
|
79
|
-
.requiredOption('--per-agent <amount>', 'Amount per agent in
|
|
79
|
+
.requiredOption('--per-agent <amount>', 'Amount per agent in USDC micro-units')
|
|
80
80
|
.description('Distribute funds to workspace agents')
|
|
81
81
|
.action(async (workspaceId, opts) => {
|
|
82
82
|
try {
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.webhookCommand = void 0;
|
|
7
|
+
const commander_1 = require("commander");
|
|
8
|
+
const chalk_1 = __importDefault(require("chalk"));
|
|
9
|
+
const client_1 = require("../utils/client");
|
|
10
|
+
const format_1 = require("../utils/format");
|
|
11
|
+
exports.webhookCommand = new commander_1.Command('webhook').description('Webhook subscription management');
|
|
12
|
+
exports.webhookCommand
|
|
13
|
+
.command('create')
|
|
14
|
+
.requiredOption('--url <url>', 'Webhook callback URL (HTTPS)')
|
|
15
|
+
.requiredOption('--events <types...>', 'Event types to subscribe to (e.g. bounty:created bounty:completed)')
|
|
16
|
+
.option('--workspace <id>', 'Filter to a specific workspace')
|
|
17
|
+
.option('--bounty <id>', 'Filter to a specific bounty')
|
|
18
|
+
.description('Create a new webhook subscription')
|
|
19
|
+
.action(async (opts) => {
|
|
20
|
+
try {
|
|
21
|
+
const client = (0, client_1.getClient)();
|
|
22
|
+
const data = await client.post('/webhooks', {
|
|
23
|
+
url: opts.url,
|
|
24
|
+
eventTypes: opts.events,
|
|
25
|
+
filterWorkspaceId: opts.workspace,
|
|
26
|
+
filterBountyId: opts.bounty,
|
|
27
|
+
});
|
|
28
|
+
const sub = data.subscription;
|
|
29
|
+
(0, format_1.success)('Webhook created');
|
|
30
|
+
console.log(` ID: ${sub.id}`);
|
|
31
|
+
console.log(` URL: ${sub.url}`);
|
|
32
|
+
console.log(` Events: ${sub.eventTypes.join(', ')}`);
|
|
33
|
+
console.log();
|
|
34
|
+
console.log(chalk_1.default.yellow.bold(' Secret (shown once — save it now):'));
|
|
35
|
+
console.log(chalk_1.default.yellow(` ${sub.secret}`));
|
|
36
|
+
}
|
|
37
|
+
catch (err) {
|
|
38
|
+
(0, format_1.error)(err.message);
|
|
39
|
+
}
|
|
40
|
+
});
|
|
41
|
+
exports.webhookCommand
|
|
42
|
+
.command('list')
|
|
43
|
+
.description('List your webhook subscriptions')
|
|
44
|
+
.action(async () => {
|
|
45
|
+
try {
|
|
46
|
+
const client = (0, client_1.getClient)();
|
|
47
|
+
const data = await client.get('/webhooks');
|
|
48
|
+
const subs = data.subscriptions || [];
|
|
49
|
+
if (subs.length === 0) {
|
|
50
|
+
console.log(chalk_1.default.dim(' No webhook subscriptions'));
|
|
51
|
+
return;
|
|
52
|
+
}
|
|
53
|
+
(0, format_1.heading)('Webhook Subscriptions');
|
|
54
|
+
console.log((0, format_1.makeTable)(['ID', 'URL', 'Events', 'Active', 'Failures', 'Last Delivery'], subs.map((s) => [
|
|
55
|
+
(0, format_1.shorten)(s.id),
|
|
56
|
+
s.url.length > 40 ? s.url.slice(0, 37) + '...' : s.url,
|
|
57
|
+
s.eventTypes.length > 2
|
|
58
|
+
? `${s.eventTypes.slice(0, 2).join(', ')} +${s.eventTypes.length - 2}`
|
|
59
|
+
: s.eventTypes.join(', '),
|
|
60
|
+
s.isActive ? chalk_1.default.green('yes') : chalk_1.default.red('no'),
|
|
61
|
+
s.consecutiveFailures > 0 ? chalk_1.default.red(String(s.consecutiveFailures)) : '0',
|
|
62
|
+
s.lastDeliveryAt ? (0, format_1.formatTimeAgo)(s.lastDeliveryAt) : chalk_1.default.dim('never'),
|
|
63
|
+
])));
|
|
64
|
+
}
|
|
65
|
+
catch (err) {
|
|
66
|
+
(0, format_1.error)(err.message);
|
|
67
|
+
}
|
|
68
|
+
});
|
|
69
|
+
exports.webhookCommand
|
|
70
|
+
.command('delete')
|
|
71
|
+
.argument('<id>', 'Webhook subscription ID')
|
|
72
|
+
.description('Delete a webhook subscription')
|
|
73
|
+
.action(async (id) => {
|
|
74
|
+
try {
|
|
75
|
+
const client = (0, client_1.getClient)();
|
|
76
|
+
await client.del(`/webhooks/${id}`);
|
|
77
|
+
(0, format_1.success)(`Webhook ${(0, format_1.shorten)(id)} deleted`);
|
|
78
|
+
}
|
|
79
|
+
catch (err) {
|
|
80
|
+
(0, format_1.error)(err.message);
|
|
81
|
+
}
|
|
82
|
+
});
|
|
83
|
+
exports.webhookCommand
|
|
84
|
+
.command('deliveries')
|
|
85
|
+
.argument('<id>', 'Webhook subscription ID')
|
|
86
|
+
.option('--limit <n>', 'Number of deliveries to show', '10')
|
|
87
|
+
.description('Show recent delivery attempts for a webhook')
|
|
88
|
+
.action(async (id, opts) => {
|
|
89
|
+
try {
|
|
90
|
+
const client = (0, client_1.getClient)();
|
|
91
|
+
const data = await client.get(`/webhooks/${id}/deliveries?limit=${opts.limit}`);
|
|
92
|
+
const deliveries = data.deliveries || [];
|
|
93
|
+
if (deliveries.length === 0) {
|
|
94
|
+
console.log(chalk_1.default.dim(' No deliveries yet'));
|
|
95
|
+
return;
|
|
96
|
+
}
|
|
97
|
+
(0, format_1.heading)('Webhook Deliveries');
|
|
98
|
+
console.log((0, format_1.makeTable)(['Event', 'Type', 'Attempt', 'Status', 'HTTP', 'Time'], deliveries.map((d) => [
|
|
99
|
+
(0, format_1.shorten)(d.eventId),
|
|
100
|
+
d.eventType,
|
|
101
|
+
String(d.attempt),
|
|
102
|
+
(0, format_1.statusColor)(d.status),
|
|
103
|
+
d.httpStatus ? String(d.httpStatus) : chalk_1.default.dim('—'),
|
|
104
|
+
d.createdAt ? (0, format_1.formatTimeAgo)(d.createdAt) : '',
|
|
105
|
+
])));
|
|
106
|
+
}
|
|
107
|
+
catch (err) {
|
|
108
|
+
(0, format_1.error)(err.message);
|
|
109
|
+
}
|
|
110
|
+
});
|
|
111
|
+
exports.webhookCommand
|
|
112
|
+
.command('test')
|
|
113
|
+
.argument('<id>', 'Webhook subscription ID')
|
|
114
|
+
.description('Send a synthetic test event to a webhook')
|
|
115
|
+
.action(async (id) => {
|
|
116
|
+
try {
|
|
117
|
+
const client = (0, client_1.getClient)();
|
|
118
|
+
console.log(`Sending test event to webhook ${(0, format_1.shorten)(id)}...`);
|
|
119
|
+
const data = await client.post(`/webhooks/${id}/test`, {});
|
|
120
|
+
const delivery = data.delivery;
|
|
121
|
+
if (delivery.status === 'success') {
|
|
122
|
+
(0, format_1.success)(`Test delivered successfully (HTTP ${delivery.httpStatus})`);
|
|
123
|
+
}
|
|
124
|
+
else {
|
|
125
|
+
(0, format_1.error)(`Test delivery failed: ${delivery.errorMessage || `HTTP ${delivery.httpStatus}`}`);
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
catch (err) {
|
|
129
|
+
(0, format_1.error)(err.message);
|
|
130
|
+
}
|
|
131
|
+
});
|
|
@@ -3,16 +3,16 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.workspaceCommand = void 0;
|
|
6
|
+
exports.invitesCommand = exports.workspaceCommand = void 0;
|
|
7
7
|
const commander_1 = require("commander");
|
|
8
8
|
const chalk_1 = __importDefault(require("chalk"));
|
|
9
9
|
const client_1 = require("../utils/client");
|
|
10
10
|
const format_1 = require("../utils/format");
|
|
11
11
|
const websocket_1 = require("../utils/websocket");
|
|
12
|
-
exports.workspaceCommand = new commander_1.Command('workspace').description('Workspace
|
|
12
|
+
exports.workspaceCommand = new commander_1.Command('workspace').description('Workspace management');
|
|
13
13
|
exports.workspaceCommand
|
|
14
14
|
.command('list')
|
|
15
|
-
.description('List
|
|
15
|
+
.description('List workspaces you own or belong to')
|
|
16
16
|
.action(async () => {
|
|
17
17
|
try {
|
|
18
18
|
const client = (0, client_1.getClient)();
|
|
@@ -22,19 +22,265 @@ exports.workspaceCommand
|
|
|
22
22
|
console.log('No workspaces found.');
|
|
23
23
|
return;
|
|
24
24
|
}
|
|
25
|
-
console.log((0, format_1.makeTable)(['ID', 'Name', '
|
|
25
|
+
console.log((0, format_1.makeTable)(['ID', 'Name', 'Visibility', 'Mode', 'Agents', 'Tags', 'Created'], workspaces.map((ws) => [
|
|
26
26
|
(0, format_1.shorten)(ws.id),
|
|
27
27
|
ws.name,
|
|
28
|
+
ws.visibility || 'private',
|
|
28
29
|
ws.mode || 'open',
|
|
29
|
-
String(ws.
|
|
30
|
-
|
|
31
|
-
ws.
|
|
30
|
+
String((ws.agentWallets || ws.agents || []).length),
|
|
31
|
+
(ws.tags || []).join(', ') || '—',
|
|
32
|
+
ws.createdAt ? new Date(ws.createdAt).toLocaleDateString() : '',
|
|
32
33
|
])));
|
|
33
34
|
}
|
|
34
35
|
catch (err) {
|
|
35
36
|
(0, format_1.error)(err.message);
|
|
36
37
|
}
|
|
37
38
|
});
|
|
39
|
+
exports.workspaceCommand
|
|
40
|
+
.command('create')
|
|
41
|
+
.description('Create a new workspace')
|
|
42
|
+
.requiredOption('--name <name>', 'Workspace name')
|
|
43
|
+
.option('--description <description>', 'Workspace description')
|
|
44
|
+
.option('--visibility <visibility>', 'Visibility: public or private', 'private')
|
|
45
|
+
.option('--tags <tags>', 'Comma-separated tags')
|
|
46
|
+
.action(async (opts) => {
|
|
47
|
+
try {
|
|
48
|
+
const client = (0, client_1.getClient)();
|
|
49
|
+
const body = { name: opts.name };
|
|
50
|
+
if (opts.description)
|
|
51
|
+
body.description = opts.description;
|
|
52
|
+
if (opts.visibility)
|
|
53
|
+
body.visibility = opts.visibility;
|
|
54
|
+
if (opts.tags)
|
|
55
|
+
body.tags = opts.tags.split(',').map((t) => t.trim());
|
|
56
|
+
const data = await client.post('/workspaces', body);
|
|
57
|
+
const ws = data.workspace;
|
|
58
|
+
(0, format_1.heading)('Workspace Created');
|
|
59
|
+
console.log(` ID: ${ws.id}`);
|
|
60
|
+
console.log(` Name: ${ws.name}`);
|
|
61
|
+
console.log(` Visibility: ${ws.visibility}`);
|
|
62
|
+
if (ws.description)
|
|
63
|
+
console.log(` Description: ${ws.description}`);
|
|
64
|
+
if (ws.tags?.length)
|
|
65
|
+
console.log(` Tags: ${ws.tags.join(', ')}`);
|
|
66
|
+
}
|
|
67
|
+
catch (err) {
|
|
68
|
+
(0, format_1.error)(err.message);
|
|
69
|
+
}
|
|
70
|
+
});
|
|
71
|
+
exports.workspaceCommand
|
|
72
|
+
.command('explore')
|
|
73
|
+
.description('Browse public workspaces')
|
|
74
|
+
.option('--search <query>', 'Search by name or description')
|
|
75
|
+
.option('--tags <tags>', 'Filter by comma-separated tags')
|
|
76
|
+
.option('--limit <n>', 'Max results', '20')
|
|
77
|
+
.action(async (opts) => {
|
|
78
|
+
try {
|
|
79
|
+
const client = (0, client_1.getClient)();
|
|
80
|
+
const params = new URLSearchParams();
|
|
81
|
+
if (opts.search)
|
|
82
|
+
params.set('search', opts.search);
|
|
83
|
+
if (opts.tags)
|
|
84
|
+
params.set('tags', opts.tags);
|
|
85
|
+
params.set('limit', opts.limit);
|
|
86
|
+
const query = params.toString();
|
|
87
|
+
const data = await client.get(`/workspaces/explore${query ? `?${query}` : ''}`);
|
|
88
|
+
const workspaces = data.workspaces || [];
|
|
89
|
+
if (workspaces.length === 0) {
|
|
90
|
+
console.log('No public workspaces found.');
|
|
91
|
+
return;
|
|
92
|
+
}
|
|
93
|
+
(0, format_1.heading)(`Public Workspaces (${data.total} total)`);
|
|
94
|
+
console.log((0, format_1.makeTable)(['ID', 'Name', 'Description', 'Tags', 'Agents'], workspaces.map((ws) => [
|
|
95
|
+
(0, format_1.shorten)(ws.id),
|
|
96
|
+
ws.name,
|
|
97
|
+
(ws.description || '').slice(0, 40) || '—',
|
|
98
|
+
(ws.tags || []).join(', ') || '—',
|
|
99
|
+
String((ws.agentWallets || ws.agents || []).length),
|
|
100
|
+
])));
|
|
101
|
+
}
|
|
102
|
+
catch (err) {
|
|
103
|
+
(0, format_1.error)(err.message);
|
|
104
|
+
}
|
|
105
|
+
});
|
|
106
|
+
exports.workspaceCommand
|
|
107
|
+
.command('join')
|
|
108
|
+
.argument('<target>', 'Workspace ID or invite token')
|
|
109
|
+
.option('--invite', 'Treat target as an invite token')
|
|
110
|
+
.description('Join a public workspace or redeem an invite')
|
|
111
|
+
.action(async (target, opts) => {
|
|
112
|
+
try {
|
|
113
|
+
const client = (0, client_1.getClient)();
|
|
114
|
+
if (opts.invite) {
|
|
115
|
+
const data = await client.post(`/workspaces/invites/${target}/redeem`, {});
|
|
116
|
+
console.log(chalk_1.default.green(`Joined workspace: ${data.workspace.name} (${data.workspace.id})`));
|
|
117
|
+
}
|
|
118
|
+
else {
|
|
119
|
+
const data = await client.post(`/workspaces/${target}/join`, {});
|
|
120
|
+
console.log(chalk_1.default.green(`Joined workspace: ${data.workspace.name} (${data.workspace.id})`));
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
catch (err) {
|
|
124
|
+
(0, format_1.error)(err.message);
|
|
125
|
+
}
|
|
126
|
+
});
|
|
127
|
+
exports.workspaceCommand
|
|
128
|
+
.command('invite-create')
|
|
129
|
+
.argument('<workspace-id>', 'Workspace ID')
|
|
130
|
+
.option('--max-uses <n>', 'Maximum number of uses')
|
|
131
|
+
.option('--expires <date>', 'Expiration date (ISO 8601)')
|
|
132
|
+
.option('--target <wallet>', 'Target wallet for the invite')
|
|
133
|
+
.option('--role <role>', 'Role to assign: manager, reviewer, or member', 'member')
|
|
134
|
+
.description('Create an invite link for a workspace')
|
|
135
|
+
.action(async (workspaceId, opts) => {
|
|
136
|
+
try {
|
|
137
|
+
const client = (0, client_1.getClient)();
|
|
138
|
+
const body = {};
|
|
139
|
+
if (opts.maxUses)
|
|
140
|
+
body.maxUses = parseInt(opts.maxUses, 10);
|
|
141
|
+
if (opts.expires)
|
|
142
|
+
body.expiresAt = opts.expires;
|
|
143
|
+
if (opts.target)
|
|
144
|
+
body.targetWallet = opts.target;
|
|
145
|
+
if (opts.role && opts.role !== 'member')
|
|
146
|
+
body.role = opts.role;
|
|
147
|
+
const data = await client.post(`/workspaces/${workspaceId}/invites`, body);
|
|
148
|
+
const invite = data.invite;
|
|
149
|
+
(0, format_1.heading)('Invite Created');
|
|
150
|
+
console.log(` Token: ${invite.token}`);
|
|
151
|
+
console.log(` Max Uses: ${invite.maxUses ?? 'unlimited'}`);
|
|
152
|
+
console.log(` Expires: ${invite.expiresAt ?? 'never'}`);
|
|
153
|
+
console.log('');
|
|
154
|
+
console.log(chalk_1.default.cyan(` Share: wenrwa workspace join ${invite.token} --invite`));
|
|
155
|
+
}
|
|
156
|
+
catch (err) {
|
|
157
|
+
(0, format_1.error)(err.message);
|
|
158
|
+
}
|
|
159
|
+
});
|
|
160
|
+
exports.workspaceCommand
|
|
161
|
+
.command('invite-list')
|
|
162
|
+
.argument('<workspace-id>', 'Workspace ID')
|
|
163
|
+
.description('List invites for a workspace')
|
|
164
|
+
.action(async (workspaceId) => {
|
|
165
|
+
try {
|
|
166
|
+
const client = (0, client_1.getClient)();
|
|
167
|
+
const data = await client.get(`/workspaces/${workspaceId}/invites`);
|
|
168
|
+
const invites = data.invites || [];
|
|
169
|
+
if (invites.length === 0) {
|
|
170
|
+
console.log('No invites found.');
|
|
171
|
+
return;
|
|
172
|
+
}
|
|
173
|
+
console.log((0, format_1.makeTable)(['ID', 'Token', 'Uses', 'Max Uses', 'Expires', 'Created'], invites.map((inv) => [
|
|
174
|
+
(0, format_1.shorten)(inv.id),
|
|
175
|
+
inv.token.slice(0, 12) + '...',
|
|
176
|
+
String(inv.useCount),
|
|
177
|
+
inv.maxUses != null ? String(inv.maxUses) : 'unlimited',
|
|
178
|
+
inv.expiresAt ? new Date(inv.expiresAt).toLocaleDateString() : 'never',
|
|
179
|
+
new Date(inv.createdAt).toLocaleDateString(),
|
|
180
|
+
])));
|
|
181
|
+
}
|
|
182
|
+
catch (err) {
|
|
183
|
+
(0, format_1.error)(err.message);
|
|
184
|
+
}
|
|
185
|
+
});
|
|
186
|
+
exports.workspaceCommand
|
|
187
|
+
.command('invite-revoke')
|
|
188
|
+
.argument('<workspace-id>', 'Workspace ID')
|
|
189
|
+
.argument('<invite-id>', 'Invite ID to revoke')
|
|
190
|
+
.description('Revoke an invite for a workspace')
|
|
191
|
+
.action(async (workspaceId, inviteId) => {
|
|
192
|
+
try {
|
|
193
|
+
const client = (0, client_1.getClient)();
|
|
194
|
+
await client.del(`/workspaces/${workspaceId}/invites/${inviteId}`);
|
|
195
|
+
console.log(chalk_1.default.green('Invite revoked.'));
|
|
196
|
+
}
|
|
197
|
+
catch (err) {
|
|
198
|
+
(0, format_1.error)(err.message);
|
|
199
|
+
}
|
|
200
|
+
});
|
|
201
|
+
exports.workspaceCommand
|
|
202
|
+
.command('members')
|
|
203
|
+
.argument('<workspace-id>', 'Workspace ID')
|
|
204
|
+
.description('List members and their roles')
|
|
205
|
+
.action(async (workspaceId) => {
|
|
206
|
+
try {
|
|
207
|
+
const client = (0, client_1.getClient)();
|
|
208
|
+
const data = await client.get(`/workspaces/${workspaceId}/members`);
|
|
209
|
+
const members = data.members || [];
|
|
210
|
+
if (members.length === 0) {
|
|
211
|
+
console.log('No members found.');
|
|
212
|
+
return;
|
|
213
|
+
}
|
|
214
|
+
console.log((0, format_1.makeTable)(['Wallet', 'Role', 'Joined'], members.map((m) => [
|
|
215
|
+
(0, format_1.shorten)(m.walletPubkey),
|
|
216
|
+
m.role,
|
|
217
|
+
m.joinedAt ? new Date(m.joinedAt).toLocaleDateString() : '',
|
|
218
|
+
])));
|
|
219
|
+
}
|
|
220
|
+
catch (err) {
|
|
221
|
+
(0, format_1.error)(err.message);
|
|
222
|
+
}
|
|
223
|
+
});
|
|
224
|
+
exports.workspaceCommand
|
|
225
|
+
.command('kick')
|
|
226
|
+
.argument('<workspace-id>', 'Workspace ID')
|
|
227
|
+
.argument('<wallet>', 'Wallet to kick')
|
|
228
|
+
.description('Remove a member from the workspace')
|
|
229
|
+
.action(async (workspaceId, wallet) => {
|
|
230
|
+
try {
|
|
231
|
+
const client = (0, client_1.getClient)();
|
|
232
|
+
await client.del(`/workspaces/${workspaceId}/members/${wallet}`);
|
|
233
|
+
console.log(chalk_1.default.green(`Kicked ${(0, format_1.shorten)(wallet)} from workspace.`));
|
|
234
|
+
}
|
|
235
|
+
catch (err) {
|
|
236
|
+
(0, format_1.error)(err.message);
|
|
237
|
+
}
|
|
238
|
+
});
|
|
239
|
+
exports.workspaceCommand
|
|
240
|
+
.command('leave')
|
|
241
|
+
.argument('<workspace-id>', 'Workspace ID')
|
|
242
|
+
.description('Leave a workspace')
|
|
243
|
+
.action(async (workspaceId) => {
|
|
244
|
+
try {
|
|
245
|
+
const client = (0, client_1.getClient)();
|
|
246
|
+
await client.post(`/workspaces/${workspaceId}/leave`, {});
|
|
247
|
+
console.log(chalk_1.default.green('Left workspace.'));
|
|
248
|
+
}
|
|
249
|
+
catch (err) {
|
|
250
|
+
(0, format_1.error)(err.message);
|
|
251
|
+
}
|
|
252
|
+
});
|
|
253
|
+
exports.workspaceCommand
|
|
254
|
+
.command('set-role')
|
|
255
|
+
.argument('<workspace-id>', 'Workspace ID')
|
|
256
|
+
.argument('<wallet>', 'Member wallet')
|
|
257
|
+
.argument('<role>', 'New role: manager, reviewer, or member')
|
|
258
|
+
.description('Set a member\'s role (owner only)')
|
|
259
|
+
.action(async (workspaceId, wallet, role) => {
|
|
260
|
+
try {
|
|
261
|
+
const client = (0, client_1.getClient)();
|
|
262
|
+
await client.put(`/workspaces/${workspaceId}/members/${wallet}/role`, { role });
|
|
263
|
+
console.log(chalk_1.default.green(`Set ${(0, format_1.shorten)(wallet)} role to ${role}.`));
|
|
264
|
+
}
|
|
265
|
+
catch (err) {
|
|
266
|
+
(0, format_1.error)(err.message);
|
|
267
|
+
}
|
|
268
|
+
});
|
|
269
|
+
exports.workspaceCommand
|
|
270
|
+
.command('transfer')
|
|
271
|
+
.argument('<workspace-id>', 'Workspace ID')
|
|
272
|
+
.argument('<wallet>', 'New owner wallet')
|
|
273
|
+
.description('Transfer workspace ownership')
|
|
274
|
+
.action(async (workspaceId, wallet) => {
|
|
275
|
+
try {
|
|
276
|
+
const client = (0, client_1.getClient)();
|
|
277
|
+
await client.post(`/workspaces/${workspaceId}/transfer`, { targetWallet: wallet });
|
|
278
|
+
console.log(chalk_1.default.green(`Ownership transferred to ${(0, format_1.shorten)(wallet)}.`));
|
|
279
|
+
}
|
|
280
|
+
catch (err) {
|
|
281
|
+
(0, format_1.error)(err.message);
|
|
282
|
+
}
|
|
283
|
+
});
|
|
38
284
|
exports.workspaceCommand
|
|
39
285
|
.command('status')
|
|
40
286
|
.argument('<workspace-id>', 'Workspace ID')
|
|
@@ -45,10 +291,15 @@ exports.workspaceCommand
|
|
|
45
291
|
const data = await client.get(`/workspaces/${workspaceId}`);
|
|
46
292
|
const ws = data.workspace;
|
|
47
293
|
(0, format_1.heading)(`Workspace: ${ws.name}`);
|
|
48
|
-
console.log(` ID:
|
|
49
|
-
console.log(` Mode:
|
|
50
|
-
console.log(`
|
|
51
|
-
console.log(`
|
|
294
|
+
console.log(` ID: ${ws.id}`);
|
|
295
|
+
console.log(` Mode: ${ws.mode}`);
|
|
296
|
+
console.log(` Visibility: ${ws.visibility || 'private'}`);
|
|
297
|
+
console.log(` Escrow: ${ws.use_escrow || ws.useEscrow ? 'Yes' : 'No'}`);
|
|
298
|
+
if (ws.description)
|
|
299
|
+
console.log(` Description: ${ws.description}`);
|
|
300
|
+
if (ws.tags?.length)
|
|
301
|
+
console.log(` Tags: ${ws.tags.join(', ')}`);
|
|
302
|
+
console.log(` Created: ${ws.createdAt || ws.created_at}`);
|
|
52
303
|
// Fetch bounties for this workspace
|
|
53
304
|
const bountyData = await client.get(`/bounties?workspaceId=${workspaceId}`);
|
|
54
305
|
const bounties = bountyData.bounties || [];
|
|
@@ -57,9 +308,9 @@ exports.workspaceCommand
|
|
|
57
308
|
console.log((0, format_1.makeTable)(['Title', 'Status', 'Assignee', 'Reward', 'Blocked By'], bounties.map((b) => [
|
|
58
309
|
b.title.slice(0, 30),
|
|
59
310
|
(0, format_1.statusColor)(b.status),
|
|
60
|
-
b.assignee_wallet ? (0, format_1.shorten)(b.assignee_wallet) : '—',
|
|
61
|
-
(0, format_1.formatReward)(b.reward_amount, b.reward_symbol),
|
|
62
|
-
b.blocked_by?.length ? b.blocked_by.map((id) => (0, format_1.shorten)(id)).join(', ') : '—',
|
|
311
|
+
b.assignee_wallet || b.assigneeWallet ? (0, format_1.shorten)(b.assignee_wallet || b.assigneeWallet) : '—',
|
|
312
|
+
(0, format_1.formatReward)(b.reward_amount || b.rewardAmount, b.reward_symbol || b.rewardSymbol),
|
|
313
|
+
(b.blocked_by || b.blockedBy)?.length ? (b.blocked_by || b.blockedBy).map((id) => (0, format_1.shorten)(id)).join(', ') : '—',
|
|
63
314
|
])));
|
|
64
315
|
}
|
|
65
316
|
// Fetch treasury
|
|
@@ -94,3 +345,31 @@ exports.workspaceCommand
|
|
|
94
345
|
process.exit(0);
|
|
95
346
|
});
|
|
96
347
|
});
|
|
348
|
+
exports.invitesCommand = new commander_1.Command('invites')
|
|
349
|
+
.description('List pending invites for your wallet')
|
|
350
|
+
.action(async () => {
|
|
351
|
+
try {
|
|
352
|
+
const client = (0, client_1.getClient)();
|
|
353
|
+
const data = await client.get('/me/invites');
|
|
354
|
+
const invites = data.invites || [];
|
|
355
|
+
if (invites.length === 0) {
|
|
356
|
+
console.log('No pending invites.');
|
|
357
|
+
return;
|
|
358
|
+
}
|
|
359
|
+
(0, format_1.heading)('Pending Invites');
|
|
360
|
+
for (const item of invites) {
|
|
361
|
+
const inv = item.invite;
|
|
362
|
+
const ws = item.workspace;
|
|
363
|
+
console.log(` ${chalk_1.default.cyan(ws.name)} (${(0, format_1.shorten)(ws.id)})`);
|
|
364
|
+
if (ws.description)
|
|
365
|
+
console.log(` ${ws.description.slice(0, 60)}`);
|
|
366
|
+
console.log(` Role: ${chalk_1.default.yellow(inv.role || 'member')} Members: ${ws.memberCount ?? '?'} Visibility: ${ws.visibility}`);
|
|
367
|
+
console.log(` Token: ${inv.token.slice(0, 12)}...`);
|
|
368
|
+
console.log(` Accept: ${chalk_1.default.dim('wenrwa workspace join ' + inv.token + ' --invite')}`);
|
|
369
|
+
console.log('');
|
|
370
|
+
}
|
|
371
|
+
}
|
|
372
|
+
catch (err) {
|
|
373
|
+
(0, format_1.error)(err.message);
|
|
374
|
+
}
|
|
375
|
+
});
|
package/dist/index.d.ts
CHANGED
|
File without changes
|
package/dist/index.js
CHANGED
|
@@ -8,15 +8,22 @@ const bounty_1 = require("./commands/bounty");
|
|
|
8
8
|
const agent_1 = require("./commands/agent");
|
|
9
9
|
const treasury_1 = require("./commands/treasury");
|
|
10
10
|
const dashboard_1 = require("./commands/dashboard");
|
|
11
|
+
const webhook_1 = require("./commands/webhook");
|
|
12
|
+
const apps_1 = require("./commands/apps");
|
|
13
|
+
const keys_1 = require("./commands/keys");
|
|
11
14
|
const program = new commander_1.Command();
|
|
12
15
|
program
|
|
13
16
|
.name('wen-market')
|
|
14
17
|
.description('Wenrwa Agent Marketplace CLI')
|
|
15
|
-
.version('0.
|
|
18
|
+
.version('0.3.0');
|
|
16
19
|
program.addCommand(auth_1.authCommand);
|
|
17
20
|
program.addCommand(workspace_1.workspaceCommand);
|
|
18
21
|
program.addCommand(bounty_1.bountyCommand);
|
|
19
22
|
program.addCommand(agent_1.agentCommand);
|
|
20
23
|
program.addCommand(treasury_1.treasuryCommand);
|
|
21
24
|
program.addCommand(dashboard_1.dashboardCommand);
|
|
25
|
+
program.addCommand(webhook_1.webhookCommand);
|
|
26
|
+
program.addCommand(apps_1.appsCommand);
|
|
27
|
+
program.addCommand(keys_1.keysCommand);
|
|
28
|
+
program.addCommand(workspace_1.invitesCommand);
|
|
22
29
|
program.parse();
|
package/dist/utils/client.d.ts
CHANGED
package/dist/utils/client.js
CHANGED
package/dist/utils/config.d.ts
CHANGED
|
File without changes
|
package/dist/utils/config.js
CHANGED
|
File without changes
|
package/dist/utils/format.d.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
export declare function statusColor(status: string): string;
|
|
2
2
|
export declare function shorten(s: string, len?: number): string;
|
|
3
|
-
export declare function formatSol(lamports: string | number): string;
|
|
4
3
|
export declare function formatUsdc(amount: string | number): string;
|
|
5
4
|
export declare function formatReward(amount: string | number, symbol?: string): string;
|
|
6
5
|
export declare function formatTimestamp(ts: string): string;
|