trenchfeed-cli 0.1.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/dist/api.d.ts ADDED
@@ -0,0 +1,110 @@
1
+ /**
2
+ * CLI API Client — REST client for TrenchFeed backend
3
+ */
4
+ export interface PlatformConfig {
5
+ burnRequired: boolean;
6
+ burnMint: string | null;
7
+ burnAmount: number;
8
+ burnTokenSymbol: string;
9
+ }
10
+ export interface AgentSummary {
11
+ id: string;
12
+ userId: string;
13
+ status: string;
14
+ strategy: string;
15
+ name: string;
16
+ dryRun?: boolean;
17
+ positions: number;
18
+ openPnlSol: number;
19
+ closedPnlSol: number;
20
+ totalTrades: number;
21
+ wallet: {
22
+ publicKey: string;
23
+ };
24
+ createdAt: number;
25
+ startedAt: number | null;
26
+ }
27
+ export interface AgentDetail {
28
+ id: string;
29
+ userId: string;
30
+ status: string;
31
+ config: Record<string, unknown>;
32
+ openPnlSol: number;
33
+ closedPnlSol: number;
34
+ totalTrades: number;
35
+ wallet: {
36
+ publicKey: string;
37
+ };
38
+ positions: Array<{
39
+ mint: string;
40
+ symbol?: string;
41
+ amountSol: number;
42
+ entryPrice: number;
43
+ currentPrice?: number;
44
+ unrealizedPnl?: number;
45
+ unrealizedPnlPct?: number;
46
+ }>;
47
+ createdAt: number;
48
+ startedAt: number | null;
49
+ stoppedAt: number | null;
50
+ }
51
+ export interface TradeRecord {
52
+ id: number;
53
+ action: string;
54
+ mint: string;
55
+ symbol: string | null;
56
+ amountSol: number | null;
57
+ price: number | null;
58
+ pnlSol: number | null;
59
+ pnlPct: number | null;
60
+ reason: string | null;
61
+ createdAt: number;
62
+ }
63
+ export interface WalletInfo {
64
+ publicKey: string;
65
+ balance: number;
66
+ lamports: number;
67
+ }
68
+ export declare const api: {
69
+ health: () => Promise<{
70
+ status: string;
71
+ agents: number;
72
+ running: number;
73
+ }>;
74
+ getCliConfig: () => Promise<PlatformConfig>;
75
+ register: (walletToken: string, body: {
76
+ config?: Record<string, unknown>;
77
+ burnTxSignature?: string;
78
+ }) => Promise<{
79
+ apiKey: string;
80
+ agentId: string;
81
+ wallet: string;
82
+ status: string;
83
+ message: string;
84
+ }>;
85
+ getMyAgent: () => Promise<AgentSummary[]>;
86
+ getAgent: (id: string) => Promise<AgentDetail>;
87
+ startAgent: (id: string) => Promise<{
88
+ status: string;
89
+ }>;
90
+ stopAgent: (id: string) => Promise<{
91
+ status: string;
92
+ }>;
93
+ pauseAgent: (id: string) => Promise<{
94
+ status: string;
95
+ }>;
96
+ resumeAgent: (id: string) => Promise<{
97
+ status: string;
98
+ }>;
99
+ emergencyStop: (id: string) => Promise<{
100
+ status: string;
101
+ }>;
102
+ updateConfig: (id: string, config: Record<string, unknown>) => Promise<{
103
+ config: Record<string, unknown>;
104
+ }>;
105
+ getWallet: (id: string) => Promise<WalletInfo>;
106
+ getTrades: (id: string, limit?: number) => Promise<TradeRecord[]>;
107
+ withdraw: (id: string, toAddress: string, amountSol: number) => Promise<{
108
+ signature: string;
109
+ }>;
110
+ };
package/dist/api.js ADDED
@@ -0,0 +1,52 @@
1
+ "use strict";
2
+ /**
3
+ * CLI API Client — REST client for TrenchFeed backend
4
+ */
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.api = void 0;
7
+ const config_1 = require("./config");
8
+ async function request(path, opts = {}) {
9
+ const config = (0, config_1.loadConfig)();
10
+ const url = `${config.apiUrl}${path}`;
11
+ const token = opts.token ?? config.apiKey;
12
+ const headers = {
13
+ 'Content-Type': 'application/json',
14
+ };
15
+ if (token) {
16
+ headers['Authorization'] = `Bearer ${token}`;
17
+ }
18
+ const res = await fetch(url, {
19
+ method: opts.method ?? 'GET',
20
+ headers,
21
+ body: opts.body ? JSON.stringify(opts.body) : undefined,
22
+ });
23
+ if (!res.ok) {
24
+ const err = await res.json().catch(() => ({ error: res.statusText }));
25
+ throw new Error(err.error ?? `API error ${res.status}`);
26
+ }
27
+ return res.json();
28
+ }
29
+ // ─── API Methods ──────────────────────────────────────────────────────────────
30
+ exports.api = {
31
+ // Health
32
+ health: () => request('/health'),
33
+ // Platform config (burn gate info)
34
+ getCliConfig: () => request('/api/cli/config'),
35
+ // CLI auth
36
+ register: (walletToken, body) => request('/api/cli/register', { method: 'POST', body, token: walletToken }),
37
+ // Agent
38
+ getMyAgent: () => request('/api/agents/me'),
39
+ getAgent: (id) => request(`/api/agents/${id}`),
40
+ startAgent: (id) => request(`/api/agents/${id}/start`, { method: 'POST' }),
41
+ stopAgent: (id) => request(`/api/agents/${id}/stop`, { method: 'POST' }),
42
+ pauseAgent: (id) => request(`/api/agents/${id}/pause`, { method: 'POST' }),
43
+ resumeAgent: (id) => request(`/api/agents/${id}/resume`, { method: 'POST' }),
44
+ emergencyStop: (id) => request(`/api/agents/${id}/emergency`, { method: 'POST' }),
45
+ updateConfig: (id, config) => request(`/api/agents/${id}/config`, { method: 'PATCH', body: config }),
46
+ getWallet: (id) => request(`/api/agents/${id}/wallet`),
47
+ getTrades: (id, limit = 20) => request(`/api/agents/${id}/trades?limit=${limit}`),
48
+ withdraw: (id, toAddress, amountSol) => request(`/api/agents/${id}/wallet/withdraw`, {
49
+ method: 'POST', body: { toAddress, amountSol },
50
+ }),
51
+ };
52
+ //# sourceMappingURL=api.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"api.js","sourceRoot":"","sources":["../src/api.ts"],"names":[],"mappings":";AAAA;;GAEG;;;AAEH,qCAAsC;AAEtC,KAAK,UAAU,OAAO,CAAI,IAAY,EAAE,OAA4D,EAAE;IACpG,MAAM,MAAM,GAAG,IAAA,mBAAU,GAAE,CAAC;IAC5B,MAAM,GAAG,GAAG,GAAG,MAAM,CAAC,MAAM,GAAG,IAAI,EAAE,CAAC;IACtC,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,IAAI,MAAM,CAAC,MAAM,CAAC;IAE1C,MAAM,OAAO,GAA2B;QACtC,cAAc,EAAE,kBAAkB;KACnC,CAAC;IACF,IAAI,KAAK,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
+ /**
2
+ * CLI Config — Stores API key and settings in ~/.trenchfeed/cli.json
3
+ */
4
+ export interface CliConfig {
5
+ apiUrl: string;
6
+ apiKey: string | null;
7
+ agentId: string | null;
8
+ wallet: string | null;
9
+ }
10
+ export declare function loadConfig(): CliConfig;
11
+ export declare function saveConfig(config: Partial<CliConfig>): void;
12
+ export declare function clearConfig(): void;
13
+ export declare function getConfigPath(): string;
package/dist/config.js ADDED
@@ -0,0 +1,48 @@
1
+ "use strict";
2
+ /**
3
+ * CLI Config — Stores API key and settings in ~/.trenchfeed/cli.json
4
+ */
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.loadConfig = loadConfig;
7
+ exports.saveConfig = saveConfig;
8
+ exports.clearConfig = clearConfig;
9
+ exports.getConfigPath = getConfigPath;
10
+ const path_1 = require("path");
11
+ const os_1 = require("os");
12
+ const fs_1 = require("fs");
13
+ const CONFIG_DIR = (0, path_1.join)((0, os_1.homedir)(), '.trenchfeed');
14
+ const CONFIG_FILE = (0, path_1.join)(CONFIG_DIR, 'cli.json');
15
+ const DEFAULTS = {
16
+ apiUrl: 'https://trenchfeed-production.up.railway.app',
17
+ apiKey: null,
18
+ agentId: null,
19
+ wallet: null,
20
+ };
21
+ function loadConfig() {
22
+ if (!(0, fs_1.existsSync)(CONFIG_FILE))
23
+ return { ...DEFAULTS };
24
+ try {
25
+ const raw = (0, fs_1.readFileSync)(CONFIG_FILE, 'utf-8');
26
+ return { ...DEFAULTS, ...JSON.parse(raw) };
27
+ }
28
+ catch {
29
+ return { ...DEFAULTS };
30
+ }
31
+ }
32
+ function saveConfig(config) {
33
+ if (!(0, fs_1.existsSync)(CONFIG_DIR)) {
34
+ (0, fs_1.mkdirSync)(CONFIG_DIR, { recursive: true });
35
+ }
36
+ const current = loadConfig();
37
+ const merged = { ...current, ...config };
38
+ (0, fs_1.writeFileSync)(CONFIG_FILE, JSON.stringify(merged, null, 2), 'utf-8');
39
+ }
40
+ function clearConfig() {
41
+ if ((0, fs_1.existsSync)(CONFIG_FILE)) {
42
+ (0, fs_1.writeFileSync)(CONFIG_FILE, JSON.stringify(DEFAULTS, null, 2), 'utf-8');
43
+ }
44
+ }
45
+ function getConfigPath() {
46
+ return CONFIG_FILE;
47
+ }
48
+ //# sourceMappingURL=config.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config.js","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":";AAAA;;GAEG;;AAuBH,gCAQC;AAED,gCAOC;AAED,kCAIC;AAED,sCAEC;AAhDD,+BAA4B;AAC5B,2BAA6B;AAC7B,2BAAwE;AAExE,MAAM,UAAU,GAAG,IAAA,WAAI,EAAC,IAAA,YAAO,GAAE,EAAE,aAAa,CAAC,CAAC;AAClD,MAAM,WAAW,GAAG,IAAA,WAAI,EAAC,UAAU,EAAE,UAAU,CAAC,CAAC;AASjD,MAAM,QAAQ,GAAc;IAC1B,MAAM,EAAE,8CAA8C;IACtD,MAAM,EAAE,IAAI;IACZ,OAAO,EAAE,IAAI;IACb,MAAM,EAAE,IAAI;CACb,CAAC;AAEF,SAAgB,UAAU;IACxB,IAAI,CAAC,IAAA,eAAU,EAAC,WAAW,CAAC;QAAE,OAAO,EAAE,GAAG,QAAQ,EAAE,CAAC;IACrD,IAAI,CAAC;QACH,MAAM,GAAG,GAAG,IAAA,iBAAY,EAAC,WAAW,EAAE,OAAO,CAAC,CAAC;QAC/C,OAAO,EAAE,GAAG,QAAQ,EAAE,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,EAAE,CAAC;IAC7C,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,EAAE,GAAG,QAAQ,EAAE,CAAC;IACzB,CAAC;AACH,CAAC;AAED,SAAgB,UAAU,CAAC,MAA0B;IACnD,IAAI,CAAC,IAAA,eAAU,EAAC,UAAU,CAAC,EAAE,CAAC;QAC5B,IAAA,cAAS,EAAC,UAAU,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;IAC7C,CAAC;IACD,MAAM,OAAO,GAAG,UAAU,EAAE,CAAC;IAC7B,MAAM,MAAM,GAAG,EAAE,GAAG,OAAO,EAAE,GAAG,MAAM,EAAE,CAAC;IACzC,IAAA,kBAAa,EAAC,WAAW,EAAE,IAAI,CAAC,SAAS,CAAC,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC,EAAE,OAAO,CAAC,CAAC;AACvE,CAAC;AAED,SAAgB,WAAW;IACzB,IAAI,IAAA,eAAU,EAAC,WAAW,CAAC,EAAE,CAAC;QAC5B,IAAA,kBAAa,EAAC,WAAW,EAAE,IAAI,CAAC,SAAS,CAAC,QAAQ,EAAE,IAAI,EAAE,CAAC,CAAC,EAAE,OAAO,CAAC,CAAC;IACzE,CAAC;AACH,CAAC;AAED,SAAgB,aAAa;IAC3B,OAAO,WAAW,CAAC;AACrB,CAAC"}
@@ -0,0 +1,20 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * TrenchFeed CLI — Deploy and manage AI trading agents from your terminal.
4
+ *
5
+ * Commands:
6
+ * trenchfeed setup — Interactive agent setup wizard
7
+ * trenchfeed status — Show agent status + PnL
8
+ * trenchfeed start — Start trading
9
+ * trenchfeed stop — Stop trading
10
+ * trenchfeed pause — Pause trading
11
+ * trenchfeed resume — Resume trading
12
+ * trenchfeed emergency — Emergency stop + sell all
13
+ * trenchfeed config — View/update agent config
14
+ * trenchfeed wallet — Show wallet address + balance
15
+ * trenchfeed trades — Show recent trade history
16
+ * trenchfeed stream — Live stream agent events
17
+ * trenchfeed chat <msg> — Send a message to your agent
18
+ * trenchfeed logout — Clear stored credentials
19
+ */
20
+ export {};