suzi-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/commands/agents.d.ts +3 -0
- package/dist/commands/agents.d.ts.map +1 -0
- package/dist/commands/agents.js +274 -0
- package/dist/commands/agents.js.map +1 -0
- package/dist/commands/deploy.d.ts +3 -0
- package/dist/commands/deploy.d.ts.map +1 -0
- package/dist/commands/deploy.js +149 -0
- package/dist/commands/deploy.js.map +1 -0
- package/dist/commands/import.d.ts +3 -0
- package/dist/commands/import.d.ts.map +1 -0
- package/dist/commands/import.js +70 -0
- package/dist/commands/import.js.map +1 -0
- package/dist/commands/list-tools.d.ts +3 -0
- package/dist/commands/list-tools.d.ts.map +1 -0
- package/dist/commands/list-tools.js +163 -0
- package/dist/commands/list-tools.js.map +1 -0
- package/dist/commands/login.d.ts +13 -0
- package/dist/commands/login.d.ts.map +1 -0
- package/dist/commands/login.js +311 -0
- package/dist/commands/login.js.map +1 -0
- package/dist/commands/portfolio.d.ts +3 -0
- package/dist/commands/portfolio.d.ts.map +1 -0
- package/dist/commands/portfolio.js +170 -0
- package/dist/commands/portfolio.js.map +1 -0
- package/dist/commands/preferences.d.ts +3 -0
- package/dist/commands/preferences.d.ts.map +1 -0
- package/dist/commands/preferences.js +121 -0
- package/dist/commands/preferences.js.map +1 -0
- package/dist/commands/prompt-suggestions.d.ts +3 -0
- package/dist/commands/prompt-suggestions.d.ts.map +1 -0
- package/dist/commands/prompt-suggestions.js +148 -0
- package/dist/commands/prompt-suggestions.js.map +1 -0
- package/dist/commands/skills.d.ts +3 -0
- package/dist/commands/skills.d.ts.map +1 -0
- package/dist/commands/skills.js +571 -0
- package/dist/commands/skills.js.map +1 -0
- package/dist/commands/subagents.d.ts +3 -0
- package/dist/commands/subagents.d.ts.map +1 -0
- package/dist/commands/subagents.js +194 -0
- package/dist/commands/subagents.js.map +1 -0
- package/dist/commands/transactions.d.ts +3 -0
- package/dist/commands/transactions.d.ts.map +1 -0
- package/dist/commands/transactions.js +153 -0
- package/dist/commands/transactions.js.map +1 -0
- package/dist/commands/wallet.d.ts +3 -0
- package/dist/commands/wallet.d.ts.map +1 -0
- package/dist/commands/wallet.js +183 -0
- package/dist/commands/wallet.js.map +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +95 -0
- package/dist/index.js.map +1 -0
- package/dist/lib/api.d.ts +12 -0
- package/dist/lib/api.d.ts.map +1 -0
- package/dist/lib/api.js +82 -0
- package/dist/lib/api.js.map +1 -0
- package/dist/lib/config.d.ts +42 -0
- package/dist/lib/config.d.ts.map +1 -0
- package/dist/lib/config.js +85 -0
- package/dist/lib/config.js.map +1 -0
- package/dist/utils/ui.d.ts +26 -0
- package/dist/utils/ui.d.ts.map +1 -0
- package/dist/utils/ui.js +111 -0
- package/dist/utils/ui.js.map +1 -0
- package/package.json +46 -0
package/dist/index.js
ADDED
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
"use strict";
|
|
3
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
4
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
5
|
+
};
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
const commander_1 = require("commander");
|
|
8
|
+
const chalk_1 = __importDefault(require("chalk"));
|
|
9
|
+
const login_1 = require("./commands/login");
|
|
10
|
+
const wallet_1 = require("./commands/wallet");
|
|
11
|
+
const portfolio_1 = require("./commands/portfolio");
|
|
12
|
+
const preferences_1 = require("./commands/preferences");
|
|
13
|
+
const list_tools_1 = require("./commands/list-tools");
|
|
14
|
+
const agents_1 = require("./commands/agents");
|
|
15
|
+
const deploy_1 = require("./commands/deploy");
|
|
16
|
+
const import_1 = require("./commands/import");
|
|
17
|
+
const subagents_1 = require("./commands/subagents");
|
|
18
|
+
const transactions_1 = require("./commands/transactions");
|
|
19
|
+
const prompt_suggestions_1 = require("./commands/prompt-suggestions");
|
|
20
|
+
const skills_1 = require("./commands/skills");
|
|
21
|
+
const ui_1 = require("./utils/ui");
|
|
22
|
+
const config_1 = require("./lib/config");
|
|
23
|
+
const program = new commander_1.Command();
|
|
24
|
+
program
|
|
25
|
+
.name('suzi')
|
|
26
|
+
.description('Suzi CLI — Autonomous agent platform for blockchain protocols')
|
|
27
|
+
.version('0.1.0')
|
|
28
|
+
.addHelpText('beforeAll', (0, ui_1.logo)())
|
|
29
|
+
.addHelpText('after', () => {
|
|
30
|
+
const config = (0, config_1.getConfig)();
|
|
31
|
+
const loggedIn = (0, config_1.isLoggedIn)();
|
|
32
|
+
let statusLine = '';
|
|
33
|
+
if (loggedIn) {
|
|
34
|
+
const account = (0, config_1.getActiveAccount)();
|
|
35
|
+
statusLine = `\n ${chalk_1.default.green('●')} Logged in as ${chalk_1.default.bold(config.user?.email || config.user?.id || 'unknown')}`;
|
|
36
|
+
if (account) {
|
|
37
|
+
statusLine += ` | Account: ${chalk_1.default.bold(account.name)}`;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
else {
|
|
41
|
+
statusLine = `\n ${chalk_1.default.gray('○')} Not logged in. Run ${chalk_1.default.cyan('suzi login')} to get started.`;
|
|
42
|
+
}
|
|
43
|
+
return statusLine + '\n';
|
|
44
|
+
});
|
|
45
|
+
// Register all commands
|
|
46
|
+
(0, login_1.registerLoginCommand)(program); // login, logout, whoami
|
|
47
|
+
(0, wallet_1.registerWalletCommand)(program); // wallet, wallet address, wallet balance, wallet fund
|
|
48
|
+
(0, portfolio_1.registerPortfolioCommand)(program); // portfolio
|
|
49
|
+
(0, preferences_1.registerPreferencesCommand)(program); // preferences, preferences set-username, preferences telegram
|
|
50
|
+
(0, list_tools_1.registerListToolsCommand)(program); // list-tools / tools
|
|
51
|
+
(0, agents_1.registerAgentsCommand)(program); // agents, agents view, agents activate, agents deactivate, agents execute, agents logs, agents delete
|
|
52
|
+
(0, deploy_1.registerDeployCommand)(program); // deploy
|
|
53
|
+
(0, import_1.registerImportCommand)(program); // import
|
|
54
|
+
(0, subagents_1.registerSubagentsCommand)(program); // subagents, subagents init, subagents validate
|
|
55
|
+
(0, transactions_1.registerTransactionsCommand)(program); // transactions / txns, tx-confirm
|
|
56
|
+
(0, prompt_suggestions_1.registerPromptSuggestions)(program); // suggest / help-me
|
|
57
|
+
(0, skills_1.registerSkillsCommand)(program); // skills, skills add
|
|
58
|
+
// Default action: show quick status + suggestions
|
|
59
|
+
program.action(() => {
|
|
60
|
+
console.log((0, ui_1.logo)());
|
|
61
|
+
const loggedIn = (0, config_1.isLoggedIn)();
|
|
62
|
+
if (loggedIn) {
|
|
63
|
+
const config = (0, config_1.getConfig)();
|
|
64
|
+
const account = (0, config_1.getActiveAccount)();
|
|
65
|
+
console.log(` ${chalk_1.default.green('●')} Logged in as ${chalk_1.default.bold(config.user?.email || 'unknown')}`);
|
|
66
|
+
if (account) {
|
|
67
|
+
console.log(` ${ui_1.colors.muted('Account:')} ${account.name}`);
|
|
68
|
+
if (account.svmWalletAddress) {
|
|
69
|
+
console.log(` ${ui_1.colors.sol('SOL:')} ${account.svmWalletAddress}`);
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
else {
|
|
74
|
+
console.log(` ${chalk_1.default.gray('○')} Not logged in`);
|
|
75
|
+
}
|
|
76
|
+
console.log();
|
|
77
|
+
(0, ui_1.divider)();
|
|
78
|
+
console.log();
|
|
79
|
+
console.log(chalk_1.default.bold(' Quick Start:'));
|
|
80
|
+
console.log();
|
|
81
|
+
if (!loggedIn) {
|
|
82
|
+
console.log(` ${ui_1.colors.primary('$')} ${chalk_1.default.white('suzi login')} ${ui_1.colors.muted('Sign in with Google')}`);
|
|
83
|
+
}
|
|
84
|
+
console.log(` ${ui_1.colors.primary('$')} ${chalk_1.default.white('suzi portfolio')} ${ui_1.colors.muted('View your assets')}`);
|
|
85
|
+
console.log(` ${ui_1.colors.primary('$')} ${chalk_1.default.white('suzi wallet balance')} ${ui_1.colors.muted('Check balances')}`);
|
|
86
|
+
console.log(` ${ui_1.colors.primary('$')} ${chalk_1.default.white('suzi agents')} ${ui_1.colors.muted('List your agents')}`);
|
|
87
|
+
console.log(` ${ui_1.colors.primary('$')} ${chalk_1.default.white('suzi deploy')} ${ui_1.colors.muted('Deploy an agent')}`);
|
|
88
|
+
console.log(` ${ui_1.colors.primary('$')} ${chalk_1.default.white('suzi list-tools')} ${ui_1.colors.muted('Browse available tools')}`);
|
|
89
|
+
console.log(` ${ui_1.colors.primary('$')} ${chalk_1.default.white('suzi suggest')} ${ui_1.colors.muted('Get command suggestions')}`);
|
|
90
|
+
console.log();
|
|
91
|
+
(0, ui_1.info)('Run `suzi --help` for all commands.');
|
|
92
|
+
console.log();
|
|
93
|
+
});
|
|
94
|
+
program.parse(process.argv);
|
|
95
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;AAEA,yCAAoC;AACpC,kDAA0B;AAC1B,4CAAwD;AACxD,8CAA0D;AAC1D,oDAAgE;AAChE,wDAAoE;AACpE,sDAAiE;AACjE,8CAA0D;AAC1D,8CAA0D;AAC1D,8CAA0D;AAC1D,oDAAgE;AAChE,0DAAsE;AACtE,sEAA0E;AAC1E,8CAA0D;AAC1D,mCAAyD;AACzD,yCAAuE;AAEvE,MAAM,OAAO,GAAG,IAAI,mBAAO,EAAE,CAAC;AAE9B,OAAO;KACJ,IAAI,CAAC,MAAM,CAAC;KACZ,WAAW,CAAC,+DAA+D,CAAC;KAC5E,OAAO,CAAC,OAAO,CAAC;KAChB,WAAW,CAAC,WAAW,EAAE,IAAA,SAAI,GAAE,CAAC;KAChC,WAAW,CAAC,OAAO,EAAE,GAAG,EAAE;IACzB,MAAM,MAAM,GAAG,IAAA,kBAAS,GAAE,CAAC;IAC3B,MAAM,QAAQ,GAAG,IAAA,mBAAU,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O,CAAC,GAAG,CAAC,IAAI,eAAK,CAAC,KAAK,CAAC,cAAc,CAAC,YAAY,WAAM,CAAC,KAAK,CAAC,yBAAyB,CAAC,EAAE,CAAC,CAAC;IAC5H,OAAO,CAAC,GAAG,EAAE,CAAC;IAEd,IAAA,SAAI,EAAC,qCAAqC,CAAC,CAAC;IAC5C,OAAO,CAAC,GAAG,EAAE,CAAC;AAChB,CAAC,CAAC,CAAC;AAEH,OAAO,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
interface ApiResponse<T = any> {
|
|
2
|
+
ok: boolean;
|
|
3
|
+
status: number;
|
|
4
|
+
data: T;
|
|
5
|
+
}
|
|
6
|
+
export declare function get<T = any>(path: string): Promise<ApiResponse<T>>;
|
|
7
|
+
export declare function post<T = any>(path: string, body?: any): Promise<ApiResponse<T>>;
|
|
8
|
+
export declare function put<T = any>(path: string, body?: any): Promise<ApiResponse<T>>;
|
|
9
|
+
export declare function patch<T = any>(path: string, body?: any): Promise<ApiResponse<T>>;
|
|
10
|
+
export declare function del<T = any>(path: string): Promise<ApiResponse<T>>;
|
|
11
|
+
export {};
|
|
12
|
+
//# sourceMappingURL=api.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"api.d.ts","sourceRoot":"","sources":["../../src/lib/api.ts"],"names":[],"mappings":"AAKA,UAAU,WAAW,CAAC,CAAC,GAAG,GAAG;IAC3B,EAAE,EAAE,OAAO,CAAC;IACZ,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,CAAC,CAAC;CACT;AAoED,wBAAgB,GAAG,CAAC,CAAC,GAAG,GAAG,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,CAElE;AAED,wBAAgB,IAAI,CAAC,CAAC,GAAG,GAAG,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,GAAG,GAAG,OAAO,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,CAE/E;AAED,wBAAgB,GAAG,CAAC,CAAC,GAAG,GAAG,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,GAAG,GAAG,OAAO,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,CAE9E;AAED,wBAAgB,KAAK,CAAC,CAAC,GAAG,GAAG,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,GAAG,GAAG,OAAO,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,CAEhF;AAED,wBAAgB,GAAG,CAAC,CAAC,GAAG,GAAG,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,CAElE"}
|
package/dist/lib/api.js
ADDED
|
@@ -0,0 +1,82 @@
|
|
|
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.get = get;
|
|
7
|
+
exports.post = post;
|
|
8
|
+
exports.put = put;
|
|
9
|
+
exports.patch = patch;
|
|
10
|
+
exports.del = del;
|
|
11
|
+
const http_1 = __importDefault(require("http"));
|
|
12
|
+
const https_1 = __importDefault(require("https"));
|
|
13
|
+
const url_1 = require("url");
|
|
14
|
+
const config_1 = require("./config");
|
|
15
|
+
function request(method, path, body, customHeaders) {
|
|
16
|
+
return new Promise((resolve, reject) => {
|
|
17
|
+
const { apiUrl } = (0, config_1.getConfig)();
|
|
18
|
+
const url = new url_1.URL(path, apiUrl);
|
|
19
|
+
const isHttps = url.protocol === 'https:';
|
|
20
|
+
const transport = isHttps ? https_1.default : http_1.default;
|
|
21
|
+
const headers = {
|
|
22
|
+
'Content-Type': 'application/json',
|
|
23
|
+
...customHeaders,
|
|
24
|
+
};
|
|
25
|
+
const token = (0, config_1.getToken)();
|
|
26
|
+
if (token) {
|
|
27
|
+
headers['Authorization'] = `Bearer ${token}`;
|
|
28
|
+
}
|
|
29
|
+
const bodyStr = body ? JSON.stringify(body) : undefined;
|
|
30
|
+
if (bodyStr) {
|
|
31
|
+
headers['Content-Length'] = Buffer.byteLength(bodyStr).toString();
|
|
32
|
+
}
|
|
33
|
+
const req = transport.request({
|
|
34
|
+
hostname: url.hostname,
|
|
35
|
+
port: url.port || (isHttps ? 443 : 80),
|
|
36
|
+
path: url.pathname + url.search,
|
|
37
|
+
method,
|
|
38
|
+
headers,
|
|
39
|
+
}, (res) => {
|
|
40
|
+
let data = '';
|
|
41
|
+
res.on('data', (chunk) => (data += chunk));
|
|
42
|
+
res.on('end', () => {
|
|
43
|
+
try {
|
|
44
|
+
const parsed = data ? JSON.parse(data) : {};
|
|
45
|
+
resolve({
|
|
46
|
+
ok: res.statusCode >= 200 && res.statusCode < 300,
|
|
47
|
+
status: res.statusCode,
|
|
48
|
+
data: parsed,
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
catch {
|
|
52
|
+
resolve({
|
|
53
|
+
ok: res.statusCode >= 200 && res.statusCode < 300,
|
|
54
|
+
status: res.statusCode,
|
|
55
|
+
data: data,
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
});
|
|
59
|
+
});
|
|
60
|
+
req.on('error', reject);
|
|
61
|
+
if (bodyStr) {
|
|
62
|
+
req.write(bodyStr);
|
|
63
|
+
}
|
|
64
|
+
req.end();
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
function get(path) {
|
|
68
|
+
return request('GET', path);
|
|
69
|
+
}
|
|
70
|
+
function post(path, body) {
|
|
71
|
+
return request('POST', path, body);
|
|
72
|
+
}
|
|
73
|
+
function put(path, body) {
|
|
74
|
+
return request('PUT', path, body);
|
|
75
|
+
}
|
|
76
|
+
function patch(path, body) {
|
|
77
|
+
return request('PATCH', path, body);
|
|
78
|
+
}
|
|
79
|
+
function del(path) {
|
|
80
|
+
return request('DELETE', path);
|
|
81
|
+
}
|
|
82
|
+
//# sourceMappingURL=api.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"api.js","sourceRoot":"","sources":["../../src/lib/api.ts"],"names":[],"mappings":";;;;;AA6EA,kBAEC;AAED,oBAEC;AAED,kBAEC;AAED,sBAEC;AAED,kBAEC;AA/FD,gDAAwB;AACxB,kDAA0B;AAC1B,6BAA0B;AAC1B,qCAA+C;AAQ/C,SAAS,OAAO,CACd,MAAc,EACd,IAAY,EACZ,IAAU,EACV,aAAsC;IAEtC,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;QACrC,MAAM,EAAE,MAAM,EAAE,GAAG,IAAA,kBAAS,GAAE,CAAC;QAC/B,MAAM,GAAG,GAAG,IAAI,SAAG,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;QAClC,MAAM,OAAO,GAAG,GAAG,CAAC,QAAQ,KAAK,QAAQ,CAAC;QAC1C,MAAM,SAAS,GAAG,OAAO,CAAC,CAAC,CAAC,eAAK,CAAC,CAAC,CAAC,cAAI,CAAC;QAEzC,MAAM,OAAO,GAA2B;YACtC,cAAc,EAAE,kBAAkB;YAClC,GAAG,aAAa;SACjB,CAAC;QAEF,MAAM,KAAK,GAAG,IAAA,iBAAQ,GAAE,CAAC;QACzB,IAAI,KAAK,EAAE,CAAC;YACV,OAAO,CAAC,eAAe,CAAC,GAAG,UAAU,KAAK,EAAE,CAAC;QAC/C,CAAC;QAED,MAAM,OAAO,GAAG,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;QACxD,IAAI,OAAO,EAAE,CAAC;YACZ,OAAO,CAAC,gBAAgB,CAAC,GAAG,MAAM,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC,QAAQ,EAAE,CAAC;QACpE,CAAC;QAED,MAAM,GA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QACrB,CAAC;QACD,GAAG,CAAC,GAAG,EAAE,CAAC;IACZ,CAAC,CAAC,CAAC;AACL,CAAC;AAED,SAAgB,GAAG,CAAU,IAAY;IACvC,OAAO,OAAO,CAAI,KAAK,EAAE,IAAI,CAAC,CAAC;AACjC,CAAC;AAED,SAAgB,IAAI,CAAU,IAAY,EAAE,IAAU;IACpD,OAAO,OAAO,CAAI,MAAM,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC;AACxC,CAAC;AAED,SAAgB,GAAG,CAAU,IAAY,EAAE,IAAU;IACnD,OAAO,OAAO,CAAI,KAAK,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC;AACvC,CAAC;AAED,SAAgB,KAAK,CAAU,IAAY,EAAE,IAAU;IACrD,OAAO,OAAO,CAAI,OAAO,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC;AACzC,CAAC;AAED,SAAgB,GAAG,CAAU,IAAY;IACvC,OAAO,OAAO,CAAI,QAAQ,EAAE,IAAI,CAAC,CAAC;AACpC,CAAC"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import Conf from 'conf';
|
|
2
|
+
export interface SuziConfig {
|
|
3
|
+
accessToken?: string;
|
|
4
|
+
apiUrl: string;
|
|
5
|
+
webUrl: string;
|
|
6
|
+
user?: {
|
|
7
|
+
id: string;
|
|
8
|
+
email: string | null;
|
|
9
|
+
privyUserId: string;
|
|
10
|
+
};
|
|
11
|
+
activeAccountId?: string;
|
|
12
|
+
accounts?: Array<{
|
|
13
|
+
id: string;
|
|
14
|
+
name: string;
|
|
15
|
+
svmWalletAddress: string;
|
|
16
|
+
evmWalletAddress: string;
|
|
17
|
+
}>;
|
|
18
|
+
preferences?: {
|
|
19
|
+
username?: string;
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
declare const config: Conf<SuziConfig>;
|
|
23
|
+
export declare function getConfig(): SuziConfig;
|
|
24
|
+
export declare function setToken(token: string): void;
|
|
25
|
+
export declare function setUser(user: SuziConfig['user']): void;
|
|
26
|
+
export declare function setAccounts(accounts: SuziConfig['accounts']): void;
|
|
27
|
+
export declare function setActiveAccountId(accountId: string): void;
|
|
28
|
+
export declare function setApiUrl(url: string): void;
|
|
29
|
+
export declare function setWebUrl(url: string): void;
|
|
30
|
+
export declare function getWebUrl(): string;
|
|
31
|
+
export declare function setPreference(key: string, value: string): void;
|
|
32
|
+
export declare function clearAuth(): void;
|
|
33
|
+
export declare function isLoggedIn(): boolean;
|
|
34
|
+
export declare function getToken(): string | undefined;
|
|
35
|
+
export declare function getActiveAccount(): {
|
|
36
|
+
id: string;
|
|
37
|
+
name: string;
|
|
38
|
+
svmWalletAddress: string;
|
|
39
|
+
evmWalletAddress: string;
|
|
40
|
+
} | undefined;
|
|
41
|
+
export { config };
|
|
42
|
+
//# sourceMappingURL=config.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/lib/config.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,MAAM,CAAC;AAExB,MAAM,WAAW,UAAU;IACzB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,CAAC,EAAE;QACL,EAAE,EAAE,MAAM,CAAC;QACX,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;QACrB,WAAW,EAAE,MAAM,CAAC;KACrB,CAAC;IACF,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,EAAE,KAAK,CAAC;QACf,EAAE,EAAE,MAAM,CAAC;QACX,IAAI,EAAE,MAAM,CAAC;QACb,gBAAgB,EAAE,MAAM,CAAC;QACzB,gBAAgB,EAAE,MAAM,CAAC;KAC1B,CAAC,CAAC;IACH,WAAW,CAAC,EAAE;QACZ,QAAQ,CAAC,EAAE,MAAM,CAAC;KACnB,CAAC;CACH;AAED,QAAA,MAAM,MAAM,kBAMV,CAAC;AAEH,wBAAgB,SAAS,IAAI,UAAU,CAUtC;AAED,wBAAgB,QAAQ,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,CAE5C;AAED,wBAAgB,OAAO,CAAC,IAAI,EAAE,UAAU,CAAC,MAAM,CAAC,GAAG,IAAI,CAEtD;AAED,wBAAgB,WAAW,CAAC,QAAQ,EAAE,UAAU,CAAC,UAAU,CAAC,GAAG,IAAI,CAElE;AAED,wBAAgB,kBAAkB,CAAC,SAAS,EAAE,MAAM,GAAG,IAAI,CAE1D;AAED,wBAAgB,SAAS,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,CAE3C;AAED,wBAAgB,SAAS,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,CAE3C;AAED,wBAAgB,SAAS,IAAI,MAAM,CAElC;AAED,wBAAgB,aAAa,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,IAAI,CAI9D;AAED,wBAAgB,SAAS,IAAI,IAAI,CAKhC;AAED,wBAAgB,UAAU,IAAI,OAAO,CAEpC;AAED,wBAAgB,QAAQ,IAAI,MAAM,GAAG,SAAS,CAE7C;AAED,wBAAgB,gBAAgB;QA/ExB,MAAM;UACJ,MAAM;sBACM,MAAM;sBACN,MAAM;cAiF3B;AAED,OAAO,EAAE,MAAM,EAAE,CAAC"}
|
|
@@ -0,0 +1,85 @@
|
|
|
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.config = void 0;
|
|
7
|
+
exports.getConfig = getConfig;
|
|
8
|
+
exports.setToken = setToken;
|
|
9
|
+
exports.setUser = setUser;
|
|
10
|
+
exports.setAccounts = setAccounts;
|
|
11
|
+
exports.setActiveAccountId = setActiveAccountId;
|
|
12
|
+
exports.setApiUrl = setApiUrl;
|
|
13
|
+
exports.setWebUrl = setWebUrl;
|
|
14
|
+
exports.getWebUrl = getWebUrl;
|
|
15
|
+
exports.setPreference = setPreference;
|
|
16
|
+
exports.clearAuth = clearAuth;
|
|
17
|
+
exports.isLoggedIn = isLoggedIn;
|
|
18
|
+
exports.getToken = getToken;
|
|
19
|
+
exports.getActiveAccount = getActiveAccount;
|
|
20
|
+
const conf_1 = __importDefault(require("conf"));
|
|
21
|
+
const config = new conf_1.default({
|
|
22
|
+
projectName: 'suzi-cli',
|
|
23
|
+
defaults: {
|
|
24
|
+
apiUrl: 'http://localhost:4000',
|
|
25
|
+
webUrl: 'http://localhost:3000',
|
|
26
|
+
},
|
|
27
|
+
});
|
|
28
|
+
exports.config = config;
|
|
29
|
+
function getConfig() {
|
|
30
|
+
return {
|
|
31
|
+
accessToken: config.get('accessToken'),
|
|
32
|
+
apiUrl: config.get('apiUrl'),
|
|
33
|
+
webUrl: config.get('webUrl'),
|
|
34
|
+
user: config.get('user'),
|
|
35
|
+
activeAccountId: config.get('activeAccountId'),
|
|
36
|
+
accounts: config.get('accounts'),
|
|
37
|
+
preferences: config.get('preferences'),
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
function setToken(token) {
|
|
41
|
+
config.set('accessToken', token);
|
|
42
|
+
}
|
|
43
|
+
function setUser(user) {
|
|
44
|
+
config.set('user', user);
|
|
45
|
+
}
|
|
46
|
+
function setAccounts(accounts) {
|
|
47
|
+
config.set('accounts', accounts);
|
|
48
|
+
}
|
|
49
|
+
function setActiveAccountId(accountId) {
|
|
50
|
+
config.set('activeAccountId', accountId);
|
|
51
|
+
}
|
|
52
|
+
function setApiUrl(url) {
|
|
53
|
+
config.set('apiUrl', url);
|
|
54
|
+
}
|
|
55
|
+
function setWebUrl(url) {
|
|
56
|
+
config.set('webUrl', url);
|
|
57
|
+
}
|
|
58
|
+
function getWebUrl() {
|
|
59
|
+
return config.get('webUrl');
|
|
60
|
+
}
|
|
61
|
+
function setPreference(key, value) {
|
|
62
|
+
const prefs = config.get('preferences') || {};
|
|
63
|
+
prefs[key] = value;
|
|
64
|
+
config.set('preferences', prefs);
|
|
65
|
+
}
|
|
66
|
+
function clearAuth() {
|
|
67
|
+
config.delete('accessToken');
|
|
68
|
+
config.delete('user');
|
|
69
|
+
config.delete('accounts');
|
|
70
|
+
config.delete('activeAccountId');
|
|
71
|
+
}
|
|
72
|
+
function isLoggedIn() {
|
|
73
|
+
return !!config.get('accessToken');
|
|
74
|
+
}
|
|
75
|
+
function getToken() {
|
|
76
|
+
return config.get('accessToken');
|
|
77
|
+
}
|
|
78
|
+
function getActiveAccount() {
|
|
79
|
+
const accounts = config.get('accounts');
|
|
80
|
+
const activeId = config.get('activeAccountId');
|
|
81
|
+
if (!accounts || !activeId)
|
|
82
|
+
return undefined;
|
|
83
|
+
return accounts.find((a) => a.id === activeId);
|
|
84
|
+
}
|
|
85
|
+
//# sourceMappingURL=config.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.js","sourceRoot":"","sources":["../../src/lib/config.ts"],"names":[],"mappings":";;;;;;AA+BA,8BAUC;AAED,4BAEC;AAED,0BAEC;AAED,kCAEC;AAED,gDAEC;AAED,8BAEC;AAED,8BAEC;AAED,8BAEC;AAED,sCAIC;AAED,8BAKC;AAED,gCAEC;AAED,4BAEC;AAED,4CAKC;AAjGD,gDAAwB;AAuBxB,MAAM,MAAM,GAAG,IAAI,cAAI,CAAa;IAClC,WAAW,EAAE,UAAU;IACvB,QAAQ,EAAE;QACR,MAAM,EAAE,uBAAuB;QAC/B,MAAM,EAAE,uBAAuB;KAChC;CACF,CAAC,CAAC;AAsEM,wBAAM;AApEf,SAAgB,SAAS;IACvB,OAAO;QACL,WAAW,EAAE,MAAM,CAAC,GAAG,CAAC,aAAa,CAAC;QACtC,MAAM,EAAE,MAAM,CAAC,GAAG,CAAC,QAAQ,CAAC;QAC5B,MAAM,EAAE,MAAM,CAAC,GAAG,CAAC,QAAQ,CAAC;QAC5B,IAAI,EA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AAM,CAAC,aAAa,CAAC,CAAC;IAC7B,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;IACtB,MAAM,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC;IAC1B,MAAM,CAAC,MAAM,CAAC,iBAAiB,CAAC,CAAC;AACnC,CAAC;AAED,SAAgB,UAAU;IACxB,OAAO,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,aAAa,CAAC,CAAC;AACrC,CAAC;AAED,SAAgB,QAAQ;IACtB,OAAO,MAAM,CAAC,GAAG,CAAC,aAAa,CAAC,CAAC;AACnC,CAAC;AAED,SAAgB,gBAAgB;IAC9B,MAAM,QAAQ,GAAG,MAAM,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC;IACxC,MAAM,QAAQ,GAAG,MAAM,CAAC,GAAG,CAAC,iBAAiB,CAAC,CAAC;IAC/C,IAAI,CAAC,QAAQ,IAAI,CAAC,QAAQ;QAAE,OAAO,SAAS,CAAC;IAC7C,OAAO,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,KAAK,QAAQ,CAAC,CAAC;AACjD,CAAC"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import chalk from 'chalk';
|
|
2
|
+
export declare const colors: {
|
|
3
|
+
primary: chalk.Chalk;
|
|
4
|
+
secondary: chalk.Chalk;
|
|
5
|
+
success: chalk.Chalk;
|
|
6
|
+
error: chalk.Chalk;
|
|
7
|
+
warning: chalk.Chalk;
|
|
8
|
+
muted: chalk.Chalk;
|
|
9
|
+
highlight: chalk.Chalk;
|
|
10
|
+
sol: chalk.Chalk;
|
|
11
|
+
evm: chalk.Chalk;
|
|
12
|
+
};
|
|
13
|
+
export declare function logo(): string;
|
|
14
|
+
export declare function header(text: string): void;
|
|
15
|
+
export declare function success(msg: string): void;
|
|
16
|
+
export declare function error(msg: string): void;
|
|
17
|
+
export declare function warn(msg: string): void;
|
|
18
|
+
export declare function info(msg: string): void;
|
|
19
|
+
export declare function label(key: string, value: string): void;
|
|
20
|
+
export declare function divider(): void;
|
|
21
|
+
export declare function requireAuth(): boolean;
|
|
22
|
+
export declare function formatSol(amount: number): string;
|
|
23
|
+
export declare function formatUsd(amount: number): string;
|
|
24
|
+
export declare function truncateAddress(addr: string, chars?: number): string;
|
|
25
|
+
export declare function statusBadge(status: string): string;
|
|
26
|
+
//# sourceMappingURL=ui.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ui.d.ts","sourceRoot":"","sources":["../../src/utils/ui.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAI1B,eAAO,MAAM,MAAM;;;;;;;;;;CAUlB,CAAC;AAEF,wBAAgB,IAAI,IAAI,MAAM,CAW7B;AAED,wBAAgB,MAAM,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAQzC;AAED,wBAAgB,OAAO,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,CAEzC;AAED,wBAAgB,KAAK,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,CAEvC;AAED,wBAAgB,IAAI,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,CAEtC;AAED,wBAAgB,IAAI,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,CAEtC;AAED,wBAAgB,KAAK,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,IAAI,CAEtD;AAED,wBAAgB,OAAO,IAAI,IAAI,CAE9B;AAED,wBAAgB,WAAW,IAAI,OAAO,CAOrC;AAED,wBAAgB,SAAS,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAEhD;AAED,wBAAgB,SAAS,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAEhD;AAED,wBAAgB,eAAe,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,SAAI,GAAG,MAAM,CAI/D;AAED,wBAAgB,WAAW,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAkBlD"}
|
package/dist/utils/ui.js
ADDED
|
@@ -0,0 +1,111 @@
|
|
|
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.colors = void 0;
|
|
7
|
+
exports.logo = logo;
|
|
8
|
+
exports.header = header;
|
|
9
|
+
exports.success = success;
|
|
10
|
+
exports.error = error;
|
|
11
|
+
exports.warn = warn;
|
|
12
|
+
exports.info = info;
|
|
13
|
+
exports.label = label;
|
|
14
|
+
exports.divider = divider;
|
|
15
|
+
exports.requireAuth = requireAuth;
|
|
16
|
+
exports.formatSol = formatSol;
|
|
17
|
+
exports.formatUsd = formatUsd;
|
|
18
|
+
exports.truncateAddress = truncateAddress;
|
|
19
|
+
exports.statusBadge = statusBadge;
|
|
20
|
+
const chalk_1 = __importDefault(require("chalk"));
|
|
21
|
+
const boxen_1 = __importDefault(require("boxen"));
|
|
22
|
+
const figures_1 = __importDefault(require("figures"));
|
|
23
|
+
exports.colors = {
|
|
24
|
+
primary: chalk_1.default.hex('#FF4DA9'),
|
|
25
|
+
secondary: chalk_1.default.hex('#06B6D4'),
|
|
26
|
+
success: chalk_1.default.green,
|
|
27
|
+
error: chalk_1.default.red,
|
|
28
|
+
warning: chalk_1.default.yellow,
|
|
29
|
+
muted: chalk_1.default.gray,
|
|
30
|
+
highlight: chalk_1.default.bold.white,
|
|
31
|
+
sol: chalk_1.default.hex('#9945FF'),
|
|
32
|
+
evm: chalk_1.default.hex('#627EEA'),
|
|
33
|
+
};
|
|
34
|
+
function logo() {
|
|
35
|
+
const light = chalk_1.default.hex('#FF80C4'); // lighter tint (top of gradient)
|
|
36
|
+
const base = chalk_1.default.hex('#FF4DA9'); // primary base
|
|
37
|
+
return `
|
|
38
|
+
${light.bold('███████╗██╗ ██╗███████╗██╗')}
|
|
39
|
+
${light.bold('██╔════╝██║ ██║╚══███╔╝██║')}
|
|
40
|
+
${base.bold('███████╗██║ ██║ ███╔╝ ██║')}
|
|
41
|
+
${base.bold('╚════██║██║ ██║ ███╔╝ ██║')}
|
|
42
|
+
${base.bold('███████║╚██████╔╝███████╗██║')}
|
|
43
|
+
${base.bold('╚══════╝ ╚═════╝ ╚══════╝╚═╝')}
|
|
44
|
+
`;
|
|
45
|
+
}
|
|
46
|
+
function header(text) {
|
|
47
|
+
console.log((0, boxen_1.default)(exports.colors.primary.bold(text), {
|
|
48
|
+
padding: { top: 0, bottom: 0, left: 1, right: 1 },
|
|
49
|
+
borderStyle: 'round',
|
|
50
|
+
borderColor: '#FF4DA9',
|
|
51
|
+
}));
|
|
52
|
+
}
|
|
53
|
+
function success(msg) {
|
|
54
|
+
console.log(`${exports.colors.success(figures_1.default.tick)} ${msg}`);
|
|
55
|
+
}
|
|
56
|
+
function error(msg) {
|
|
57
|
+
console.log(`${exports.colors.error(figures_1.default.cross)} ${msg}`);
|
|
58
|
+
}
|
|
59
|
+
function warn(msg) {
|
|
60
|
+
console.log(`${exports.colors.warning(figures_1.default.warning)} ${msg}`);
|
|
61
|
+
}
|
|
62
|
+
function info(msg) {
|
|
63
|
+
console.log(`${exports.colors.muted(figures_1.default.info)} ${msg}`);
|
|
64
|
+
}
|
|
65
|
+
function label(key, value) {
|
|
66
|
+
console.log(` ${exports.colors.muted(key + ':')} ${value}`);
|
|
67
|
+
}
|
|
68
|
+
function divider() {
|
|
69
|
+
console.log(exports.colors.muted('─'.repeat(50)));
|
|
70
|
+
}
|
|
71
|
+
function requireAuth() {
|
|
72
|
+
const { isLoggedIn } = require('../lib/config');
|
|
73
|
+
if (!isLoggedIn()) {
|
|
74
|
+
error('Not logged in. Run `suzi login` first.');
|
|
75
|
+
return false;
|
|
76
|
+
}
|
|
77
|
+
return true;
|
|
78
|
+
}
|
|
79
|
+
function formatSol(amount) {
|
|
80
|
+
return `${exports.colors.sol(amount.toFixed(4))} SOL`;
|
|
81
|
+
}
|
|
82
|
+
function formatUsd(amount) {
|
|
83
|
+
return `$${amount.toFixed(2)}`;
|
|
84
|
+
}
|
|
85
|
+
function truncateAddress(addr, chars = 6) {
|
|
86
|
+
if (!addr)
|
|
87
|
+
return 'N/A';
|
|
88
|
+
if (addr.length <= chars * 2 + 3)
|
|
89
|
+
return addr;
|
|
90
|
+
return `${addr.slice(0, chars)}...${addr.slice(-chars)}`;
|
|
91
|
+
}
|
|
92
|
+
function statusBadge(status) {
|
|
93
|
+
switch (status) {
|
|
94
|
+
case 'active':
|
|
95
|
+
return exports.colors.success(`● ${status}`);
|
|
96
|
+
case 'inactive':
|
|
97
|
+
case 'draft':
|
|
98
|
+
return exports.colors.muted(`○ ${status}`);
|
|
99
|
+
case 'deleted':
|
|
100
|
+
return exports.colors.error(`✕ ${status}`);
|
|
101
|
+
case 'completed':
|
|
102
|
+
return exports.colors.success(`✓ ${status}`);
|
|
103
|
+
case 'running':
|
|
104
|
+
return exports.colors.secondary(`◉ ${status}`);
|
|
105
|
+
case 'failed':
|
|
106
|
+
return exports.colors.error(`✕ ${status}`);
|
|
107
|
+
default:
|
|
108
|
+
return status;
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
//# sourceMappingURL=ui.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ui.js","sourceRoot":"","sources":["../../src/utils/ui.ts"],"names":[],"mappings":";;;;;;AAgBA,oBAWC;AAED,wBAQC;AAED,0BAEC;AAED,sBAEC;AAED,oBAEC;AAED,oBAEC;AAED,sBAEC;AAED,0BAEC;AAED,kCAOC;AAED,8BAEC;AAED,8BAEC;AAED,0CAIC;AAED,kCAkBC;AAxGD,kDAA0B;AAC1B,kDAA0B;AAC1B,sDAA8B;AAEjB,QAAA,MAAM,GAAG;IACpB,OAAO,EAAE,eAAK,CAAC,GAAG,CAAC,SAAS,CAAC;IAC7B,SAAS,EAAE,eAAK,CAAC,GAAG,CAAC,SA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main": "dist/index.js",
|
|
6
|
+
"bin": {
|
|
7
|
+
"suzi": "./dist/index.js"
|
|
8
|
+
},
|
|
9
|
+
"repository": {
|
|
10
|
+
"type": "git",
|
|
11
|
+
"url": "https://github.com/sendaifun"
|
|
12
|
+
},
|
|
13
|
+
"homepage": "https://github.com/sendaifun",
|
|
14
|
+
"keywords": ["suzi", "sendai", "cli", "blockchain", "agents", "autonomous"],
|
|
15
|
+
"license": "MIT",
|
|
16
|
+
"author": "SendAI",
|
|
17
|
+
"scripts": {
|
|
18
|
+
"dev": "tsx src/index.ts",
|
|
19
|
+
"build": "tsc",
|
|
20
|
+
"start": "node dist/index.js",
|
|
21
|
+
"lint": "eslint src",
|
|
22
|
+
"clean": "rm -rf dist .turbo node_modules"
|
|
23
|
+
},
|
|
24
|
+
"dependencies": {
|
|
25
|
+
"boxen": "^5.1.2",
|
|
26
|
+
"chalk": "^4.1.2",
|
|
27
|
+
"cli-table3": "^0.6.5",
|
|
28
|
+
"commander": "^12.1.0",
|
|
29
|
+
"conf": "^10.2.0",
|
|
30
|
+
"express": "^4.21.2",
|
|
31
|
+
"figures": "^3.2.0",
|
|
32
|
+
"inquirer": "^8.2.6",
|
|
33
|
+
"open": "^8.4.2",
|
|
34
|
+
"ora": "^5.4.1",
|
|
35
|
+
"qrcode-terminal": "^0.12.0"
|
|
36
|
+
},
|
|
37
|
+
"devDependencies": {
|
|
38
|
+
"@types/express": "^5.0.0",
|
|
39
|
+
"@types/inquirer": "^8.2.10",
|
|
40
|
+
"@types/node": "^22.10.5",
|
|
41
|
+
"@types/qrcode-terminal": "^0.12.2",
|
|
42
|
+
"eslint": "^9.18.0",
|
|
43
|
+
"tsx": "^4.19.2",
|
|
44
|
+
"typescript": "^5.7.3"
|
|
45
|
+
}
|
|
46
|
+
}
|