@trading-boy/cli 1.11.0 → 2.0.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.
Files changed (83) hide show
  1. package/README.md +50 -22
  2. package/dist/api-client.d.ts +4 -7
  3. package/dist/api-client.js +8 -13
  4. package/dist/cli.bundle.js +1977 -33976
  5. package/dist/credentials.js +1 -1
  6. package/dist/index.d.ts +0 -28
  7. package/dist/index.js +0 -24
  8. package/dist/logger.d.ts +8 -0
  9. package/dist/logger.js +12 -0
  10. package/dist/utils.js +3 -3
  11. package/package.json +20 -5
  12. package/dist/cli.d.ts +0 -5
  13. package/dist/cli.js +0 -157
  14. package/dist/commands/agent-cmd.d.ts +0 -9
  15. package/dist/commands/agent-cmd.js +0 -572
  16. package/dist/commands/audit.d.ts +0 -18
  17. package/dist/commands/audit.js +0 -73
  18. package/dist/commands/behavioral.d.ts +0 -73
  19. package/dist/commands/behavioral.js +0 -349
  20. package/dist/commands/benchmark-cmd.d.ts +0 -3
  21. package/dist/commands/benchmark-cmd.js +0 -191
  22. package/dist/commands/billing.d.ts +0 -12
  23. package/dist/commands/billing.js +0 -142
  24. package/dist/commands/catalysts.d.ts +0 -17
  25. package/dist/commands/catalysts.js +0 -151
  26. package/dist/commands/coaching-cmd.d.ts +0 -16
  27. package/dist/commands/coaching-cmd.js +0 -222
  28. package/dist/commands/config-cmd.d.ts +0 -30
  29. package/dist/commands/config-cmd.js +0 -515
  30. package/dist/commands/connect-chatgpt.d.ts +0 -5
  31. package/dist/commands/connect-chatgpt.js +0 -293
  32. package/dist/commands/connect-claude.d.ts +0 -5
  33. package/dist/commands/connect-claude.js +0 -280
  34. package/dist/commands/context.d.ts +0 -41
  35. package/dist/commands/context.js +0 -405
  36. package/dist/commands/cron-cmd.d.ts +0 -3
  37. package/dist/commands/cron-cmd.js +0 -305
  38. package/dist/commands/decisions.d.ts +0 -57
  39. package/dist/commands/decisions.js +0 -364
  40. package/dist/commands/edge-cmd.d.ts +0 -78
  41. package/dist/commands/edge-cmd.js +0 -183
  42. package/dist/commands/edge-guard-cmd.d.ts +0 -36
  43. package/dist/commands/edge-guard-cmd.js +0 -169
  44. package/dist/commands/events.d.ts +0 -3
  45. package/dist/commands/events.js +0 -117
  46. package/dist/commands/infra.d.ts +0 -24
  47. package/dist/commands/infra.js +0 -137
  48. package/dist/commands/journal.d.ts +0 -3
  49. package/dist/commands/journal.js +0 -302
  50. package/dist/commands/login.d.ts +0 -18
  51. package/dist/commands/login.js +0 -127
  52. package/dist/commands/logout.d.ts +0 -8
  53. package/dist/commands/logout.js +0 -108
  54. package/dist/commands/narratives.d.ts +0 -3
  55. package/dist/commands/narratives.js +0 -259
  56. package/dist/commands/onboarding.d.ts +0 -7
  57. package/dist/commands/onboarding.js +0 -298
  58. package/dist/commands/query.d.ts +0 -32
  59. package/dist/commands/query.js +0 -135
  60. package/dist/commands/replay-cmd.d.ts +0 -43
  61. package/dist/commands/replay-cmd.js +0 -184
  62. package/dist/commands/review.d.ts +0 -3
  63. package/dist/commands/review.js +0 -443
  64. package/dist/commands/risk.d.ts +0 -47
  65. package/dist/commands/risk.js +0 -158
  66. package/dist/commands/social.d.ts +0 -43
  67. package/dist/commands/social.js +0 -318
  68. package/dist/commands/soul-wizard.d.ts +0 -29
  69. package/dist/commands/soul-wizard.js +0 -155
  70. package/dist/commands/strategy-cmd.d.ts +0 -44
  71. package/dist/commands/strategy-cmd.js +0 -340
  72. package/dist/commands/subscribe.d.ts +0 -78
  73. package/dist/commands/subscribe.js +0 -552
  74. package/dist/commands/suggestions-cmd.d.ts +0 -24
  75. package/dist/commands/suggestions-cmd.js +0 -148
  76. package/dist/commands/thesis-cmd.d.ts +0 -3
  77. package/dist/commands/thesis-cmd.js +0 -129
  78. package/dist/commands/trader.d.ts +0 -30
  79. package/dist/commands/trader.js +0 -971
  80. package/dist/commands/watch.d.ts +0 -16
  81. package/dist/commands/watch.js +0 -104
  82. package/dist/commands/whoami.d.ts +0 -14
  83. package/dist/commands/whoami.js +0 -105
@@ -1,340 +0,0 @@
1
- import { Option } from 'commander';
2
- import chalk from 'chalk';
3
- import { createLogger } from '@trading-boy/core';
4
- import { apiRequest } from '../api-client.js';
5
- import { padRight, handleApiError, ensureRemote } from '../utils.js';
6
- // ─── Logger ───
7
- const logger = createLogger('cli-strategy');
8
- // ─── Helpers ───
9
- function formatShortDate(isoString) {
10
- try {
11
- return new Date(isoString).toISOString().slice(0, 16).replace('T', ' ');
12
- }
13
- catch {
14
- return isoString;
15
- }
16
- }
17
- // ─── Formatters ───
18
- export function formatStrategyDetail(s) {
19
- const lines = [];
20
- lines.push('');
21
- lines.push(chalk.bold.cyan(` Strategy — ${s.name}`));
22
- lines.push(chalk.gray(' ' + '─'.repeat(56)));
23
- lines.push('');
24
- lines.push(` ${chalk.gray('ID:')} ${chalk.white(s.id)}`);
25
- lines.push(` ${chalk.gray('Version:')} ${chalk.white(String(s.version))}`);
26
- lines.push(` ${chalk.gray('Agent ID:')} ${chalk.white(s.agentId)}`);
27
- lines.push(` ${chalk.gray('Trader ID:')} ${chalk.white(s.traderId)}`);
28
- lines.push(` ${chalk.gray('Tenant ID:')} ${chalk.dim(s.tenantId)}`);
29
- lines.push(` ${chalk.gray('Active:')} ${s.active ? chalk.green('YES') : chalk.red('NO')}`);
30
- lines.push('');
31
- lines.push(` ${chalk.gray('Tokens:')} ${chalk.white(s.tokens.join(', ') || chalk.dim('none'))}`);
32
- lines.push(` ${chalk.gray('Setup Types:')} ${chalk.white(s.setupTypes.join(', ') || chalk.dim('none'))}`);
33
- if (s.narrativePreferences.length > 0) {
34
- lines.push(` ${chalk.gray('Narratives:')} ${chalk.white(s.narrativePreferences.join(', '))}`);
35
- }
36
- if (Object.keys(s.signalWeights).length > 0) {
37
- lines.push('');
38
- lines.push(chalk.bold(' Signal Weights'));
39
- for (const [signal, weight] of Object.entries(s.signalWeights)) {
40
- lines.push(` ${chalk.gray(signal + ':')} ${chalk.white(weight.toFixed(3))}`);
41
- }
42
- }
43
- if (Object.keys(s.riskLimits).length > 0) {
44
- lines.push('');
45
- lines.push(chalk.bold(' Risk Limits'));
46
- for (const [key, val] of Object.entries(s.riskLimits)) {
47
- lines.push(` ${chalk.gray(key + ':')} ${chalk.white(JSON.stringify(val))}`);
48
- }
49
- }
50
- if (Object.keys(s.regimeBehavior).length > 0) {
51
- lines.push('');
52
- lines.push(chalk.bold(' Regime Behavior'));
53
- for (const [regime, behavior] of Object.entries(s.regimeBehavior)) {
54
- lines.push(` ${chalk.gray(regime + ':')} ${chalk.white(JSON.stringify(behavior))}`);
55
- }
56
- }
57
- lines.push('');
58
- lines.push(` ${chalk.gray('Created:')} ${chalk.dim(formatShortDate(s.createdAt))}`);
59
- lines.push(` ${chalk.gray('Updated:')} ${chalk.dim(formatShortDate(s.updatedAt))}`);
60
- lines.push('');
61
- return lines.join('\n');
62
- }
63
- export function formatStrategyList(response) {
64
- const lines = [];
65
- lines.push('');
66
- lines.push(chalk.bold.cyan(' Agent Strategies'));
67
- lines.push(chalk.gray(' ' + '─'.repeat(96)));
68
- lines.push('');
69
- if (response.strategies.length === 0) {
70
- lines.push(` ${chalk.dim('No strategies found.')}`);
71
- lines.push('');
72
- return lines.join('\n');
73
- }
74
- // Header
75
- lines.push(' ' +
76
- padRight('Name', 24) +
77
- padRight('ID', 30) +
78
- padRight('Tokens', 20) +
79
- padRight('v', 4) +
80
- padRight('Active', 8) +
81
- 'Updated');
82
- lines.push(' ' + '─'.repeat(96));
83
- for (const s of response.strategies) {
84
- const activeStr = s.active ? chalk.green('YES') : chalk.red('NO');
85
- const tokensStr = s.tokens.slice(0, 3).join(',') + (s.tokens.length > 3 ? '…' : '');
86
- lines.push(' ' +
87
- padRight(s.name, 24) +
88
- padRight(chalk.dim(s.id), 30) +
89
- padRight(tokensStr || chalk.dim('-'), 20) +
90
- padRight(String(s.version), 4) +
91
- padRight(activeStr, 8) +
92
- chalk.dim(formatShortDate(s.updatedAt)));
93
- }
94
- lines.push('');
95
- lines.push(` ${chalk.gray(`Showing ${response.strategies.length} of ${response.total} (offset: ${response.offset})`)}`);
96
- lines.push('');
97
- return lines.join('\n');
98
- }
99
- export function formatHistoryList(response) {
100
- const lines = [];
101
- lines.push('');
102
- lines.push(chalk.bold.cyan(` Strategy History — ${response.strategyId}`));
103
- lines.push(chalk.gray(' ' + '─'.repeat(80)));
104
- lines.push('');
105
- if (response.history.length === 0) {
106
- lines.push(` ${chalk.dim('No history entries found.')}`);
107
- lines.push('');
108
- return lines.join('\n');
109
- }
110
- lines.push(' ' +
111
- padRight('v', 4) +
112
- padRight('Name', 28) +
113
- padRight('Tokens', 24) +
114
- padRight('Setups', 20) +
115
- 'Changed At');
116
- lines.push(' ' + '─'.repeat(80));
117
- for (const entry of response.history) {
118
- const tokensStr = entry.tokens.slice(0, 3).join(',') + (entry.tokens.length > 3 ? '…' : '');
119
- const setupsStr = entry.setupTypes.slice(0, 2).join(',') + (entry.setupTypes.length > 2 ? '…' : '');
120
- lines.push(' ' +
121
- padRight(String(entry.version), 4) +
122
- padRight(entry.name, 28) +
123
- padRight(tokensStr || chalk.dim('-'), 24) +
124
- padRight(setupsStr || chalk.dim('-'), 20) +
125
- chalk.dim(formatShortDate(entry.changedAt)));
126
- }
127
- lines.push('');
128
- return lines.join('\n');
129
- }
130
- // ─── Command Registration ───
131
- export function registerStrategyCommand(program) {
132
- const strategy = program
133
- .command('strategy')
134
- .description('Manage agent strategies (token watch-lists, setup types, signal weights)');
135
- // ─── strategy create ───
136
- strategy
137
- .command('create')
138
- .description('Create a new agent strategy')
139
- .requiredOption('--name <name>', 'Strategy name')
140
- .requiredOption('--trader-id <id>', 'Trader ID')
141
- .requiredOption('--agent-id <id>', 'Agent ID')
142
- .requiredOption('--tokens <tokens>', 'Comma-separated token symbols')
143
- .option('--setups <types>', 'Comma-separated setup types')
144
- .addOption(new Option('--format <format>', 'Output format').choices(['text', 'json']).default('text'))
145
- .action(async (options) => {
146
- if (!(await ensureRemote()))
147
- return;
148
- const tokens = options.tokens.split(',').map((t) => t.trim().toUpperCase()).filter(Boolean);
149
- const setupTypes = options.setups
150
- ? options.setups.split(',').map((s) => s.trim().toUpperCase()).filter(Boolean)
151
- : ['BREAKOUT'];
152
- const body = {
153
- name: options.name,
154
- traderId: options.traderId,
155
- agentId: options.agentId,
156
- tokens,
157
- setupTypes,
158
- regimeBehavior: {
159
- ACCUMULATION: { enabled: true, maxPositionSize: 0.25, confidenceThreshold: 0.6, preferredSetups: setupTypes },
160
- MARKUP: { enabled: true, maxPositionSize: 0.5, confidenceThreshold: 0.5, preferredSetups: setupTypes },
161
- DISTRIBUTION: { enabled: true, maxPositionSize: 0.15, confidenceThreshold: 0.7, preferredSetups: setupTypes },
162
- MARKDOWN: { enabled: false, maxPositionSize: 0.1, confidenceThreshold: 0.8, preferredSetups: setupTypes },
163
- },
164
- riskLimits: {
165
- maxDrawdown: 0.2,
166
- maxConcurrentPositions: 5,
167
- maxExposurePerToken: 0.3,
168
- maxCorrelatedExposure: 0.5,
169
- },
170
- signalWeights: { price: 0.3, volume: 0.2, momentum: 0.2, sentiment: 0.15, onchain: 0.15 },
171
- narrativePreferences: [],
172
- };
173
- try {
174
- const result = await apiRequest('/api/v1/strategies', {
175
- method: 'POST',
176
- body,
177
- });
178
- if (options.format === 'json') {
179
- console.log(JSON.stringify(result, null, 2));
180
- }
181
- else {
182
- console.log(formatStrategyDetail(result));
183
- }
184
- }
185
- catch (error) {
186
- handleApiError(error, 'Strategy create failed', logger);
187
- }
188
- });
189
- // ─── strategy list ───
190
- strategy
191
- .command('list')
192
- .description('List strategies for a trader')
193
- .requiredOption('--trader-id <id>', 'Trader ID')
194
- .option('--agent-id <id>', 'Filter by agent ID')
195
- .option('--limit <n>', 'Maximum results', '20')
196
- .option('--offset <n>', 'Pagination offset', '0')
197
- .addOption(new Option('--format <format>', 'Output format').choices(['text', 'json']).default('text'))
198
- .action(async (options) => {
199
- if (!(await ensureRemote()))
200
- return;
201
- const params = new URLSearchParams();
202
- params.set('traderId', options.traderId);
203
- if (options.agentId)
204
- params.set('agentId', options.agentId);
205
- params.set('limit', options.limit);
206
- params.set('offset', options.offset);
207
- try {
208
- const result = await apiRequest(`/api/v1/strategies?${params.toString()}`);
209
- if (options.format === 'json') {
210
- console.log(JSON.stringify(result, null, 2));
211
- }
212
- else {
213
- console.log(formatStrategyList(result));
214
- }
215
- }
216
- catch (error) {
217
- handleApiError(error, 'Strategy list failed', logger);
218
- }
219
- });
220
- // ─── strategy show <id> ───
221
- strategy
222
- .command('show <id>')
223
- .description('Show full details for a strategy')
224
- .addOption(new Option('--format <format>', 'Output format').choices(['text', 'json']).default('text'))
225
- .action(async (id, options) => {
226
- if (!(await ensureRemote()))
227
- return;
228
- try {
229
- const result = await apiRequest(`/api/v1/strategies/${encodeURIComponent(id)}`);
230
- if (options.format === 'json') {
231
- console.log(JSON.stringify(result, null, 2));
232
- }
233
- else {
234
- console.log(formatStrategyDetail(result));
235
- }
236
- }
237
- catch (error) {
238
- handleApiError(error, 'Strategy show failed', logger);
239
- }
240
- });
241
- // ─── strategy update <id> ───
242
- strategy
243
- .command('update <id>')
244
- .description('Update a strategy')
245
- .option('--name <name>', 'New strategy name')
246
- .option('--tokens <tokens>', 'New comma-separated token symbols (replaces existing)')
247
- .option('--setups <types>', 'New comma-separated setup types (replaces existing)')
248
- .addOption(new Option('--format <format>', 'Output format').choices(['text', 'json']).default('text'))
249
- .action(async (id, options) => {
250
- if (!(await ensureRemote()))
251
- return;
252
- const body = {};
253
- if (options.name) {
254
- body.name = options.name;
255
- }
256
- if (options.tokens) {
257
- body.tokens = options.tokens.split(',').map((t) => t.trim().toUpperCase()).filter(Boolean);
258
- }
259
- if (options.setups) {
260
- body.setupTypes = options.setups.split(',').map((s) => s.trim().toUpperCase()).filter(Boolean);
261
- }
262
- if (Object.keys(body).length === 0) {
263
- console.error(chalk.red('Error: Provide at least one of --name, --tokens, or --setups to update.'));
264
- process.exitCode = 1;
265
- return;
266
- }
267
- try {
268
- const result = await apiRequest(`/api/v1/strategies/${encodeURIComponent(id)}`, { method: 'PUT', body });
269
- if (options.format === 'json') {
270
- console.log(JSON.stringify(result, null, 2));
271
- }
272
- else {
273
- console.log(formatStrategyDetail(result));
274
- }
275
- }
276
- catch (error) {
277
- handleApiError(error, 'Strategy update failed', logger);
278
- }
279
- });
280
- // ─── strategy history <id> ───
281
- strategy
282
- .command('history <id>')
283
- .description('Show version history for a strategy')
284
- .addOption(new Option('--format <format>', 'Output format').choices(['text', 'json']).default('text'))
285
- .action(async (id, options) => {
286
- if (!(await ensureRemote()))
287
- return;
288
- try {
289
- const result = await apiRequest(`/api/v1/strategies/${encodeURIComponent(id)}/history`);
290
- if (options.format === 'json') {
291
- console.log(JSON.stringify(result, null, 2));
292
- }
293
- else {
294
- console.log(formatHistoryList(result));
295
- }
296
- }
297
- catch (error) {
298
- handleApiError(error, 'Strategy history failed', logger);
299
- }
300
- });
301
- // ─── strategy export ───
302
- strategy
303
- .command('export')
304
- .description('Export a strategy in json, elizaos, or freqtrade format')
305
- .requiredOption('--id <id>', 'Strategy ID to export')
306
- .addOption(new Option('--format <format>', 'Export format')
307
- .choices(['json', 'elizaos', 'freqtrade'])
308
- .default('json'))
309
- .option('--output <file>', 'Write output to a file instead of stdout')
310
- .action(async (options) => {
311
- if (!(await ensureRemote()))
312
- return;
313
- try {
314
- const result = await apiRequest(`/api/v1/strategies/${encodeURIComponent(options.id)}/export?format=${encodeURIComponent(options.format)}`);
315
- const output = JSON.stringify(result, null, 2);
316
- if (options.output) {
317
- const { writeFile } = await import('node:fs/promises');
318
- const { resolve } = await import('node:path');
319
- const resolved = resolve(options.output);
320
- // Block writes to system directories
321
- const blocked = ['/etc', '/usr', '/bin', '/sbin', '/var', '/lib', '/boot', '/sys', '/proc', '/dev'];
322
- if (blocked.some((dir) => resolved.startsWith(dir + '/'))) {
323
- console.error(chalk.red(`Error: --output must not write to system directories.`));
324
- console.error(chalk.dim(` Resolved: ${resolved}`));
325
- process.exitCode = 1;
326
- return;
327
- }
328
- await writeFile(resolved, output + '\n', 'utf-8');
329
- console.log(chalk.green(`Strategy exported to ${resolved}`));
330
- }
331
- else {
332
- console.log(output);
333
- }
334
- }
335
- catch (error) {
336
- handleApiError(error, 'Strategy export failed', logger);
337
- }
338
- });
339
- }
340
- //# sourceMappingURL=strategy-cmd.js.map
@@ -1,78 +0,0 @@
1
- import { Command } from 'commander';
2
- export interface CheckoutResponse {
3
- checkoutUrl: string;
4
- provisioningToken: string;
5
- }
6
- export interface ProvisionResponse {
7
- status: 'pending' | 'ready' | 'expired' | 'already_retrieved' | 'not_found';
8
- apiKey?: string;
9
- keyPrefix?: string;
10
- email?: string;
11
- plan?: string;
12
- }
13
- export interface PollResult {
14
- success: boolean;
15
- apiKey?: string;
16
- keyPrefix?: string;
17
- email?: string;
18
- plan?: string;
19
- error?: string;
20
- }
21
- export interface CryptoCheckoutResponse {
22
- reference: string;
23
- provisioningToken: string;
24
- merchantWallet: string;
25
- amountUsdc: number;
26
- tokenSymbol: string;
27
- network: string;
28
- plan: string;
29
- solanaPayUrl: string;
30
- solanaReference: string;
31
- }
32
- export interface CryptoVerifyResponse {
33
- status: 'pending' | 'confirmed' | 'not_found' | 'expired';
34
- }
35
- /**
36
- * Create a Stripe Checkout session via the API.
37
- * This is a public endpoint — no auth needed.
38
- */
39
- export declare function createCheckoutSession(email: string, plan?: string): Promise<CheckoutResponse>;
40
- /**
41
- * Poll the provisioning endpoint for the API key.
42
- * Returns normalized ProvisionResponse regardless of HTTP status.
43
- */
44
- export declare function pollProvisioningToken(token: string): Promise<ProvisionResponse>;
45
- /**
46
- * Create a crypto (USDC) checkout session via the API.
47
- * Public endpoint — no auth needed.
48
- */
49
- export declare function createCryptoCheckout(email: string, plan?: string): Promise<CryptoCheckoutResponse>;
50
- /**
51
- * Check if a USDC payment has been confirmed on Solana.
52
- */
53
- export declare function checkCryptoPayment(reference: string): Promise<CryptoVerifyResponse>;
54
- /**
55
- * Poll until USDC payment is confirmed on Solana, then poll for provisioned API key.
56
- */
57
- export declare function pollCryptoPayment(reference: string, provisioningToken: string, onTick?: (elapsed: number, phase: 'payment' | 'provisioning') => void): Promise<PollResult>;
58
- /**
59
- * Poll the provisioning endpoint until a key is ready or timeout.
60
- */
61
- export declare function pollForApiKey(token: string, onTick?: (elapsed: number) => void): Promise<PollResult>;
62
- /**
63
- * Save API credentials using the credential storage module.
64
- */
65
- export declare function saveApiKey(apiKey: string, metadata: {
66
- keyPrefix?: string;
67
- email?: string;
68
- plan?: string;
69
- }): Promise<void>;
70
- export declare function formatSubscribeSuccess(result: PollResult): string;
71
- export declare function registerSubscribeCommand(program: Command): void;
72
- export interface RegisterResponse {
73
- apiKey: string;
74
- keyPrefix: string;
75
- email: string;
76
- plan: string;
77
- }
78
- //# sourceMappingURL=subscribe.d.ts.map