aixxai 1.6.8 → 1.6.9
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/aixxai-1.6.9.tgz +0 -0
- package/bin/aixx.js +139 -137
- package/package.json +1 -1
- package/src/commands/balance.js +170 -168
- package/src/commands/config.js +68 -68
- package/src/commands/help.js +46 -45
- package/src/commands/install.js +636 -636
- package/src/commands/market.js +16 -14
- package/src/commands/status.js +120 -0
package/src/commands/market.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* AIXX CLI - market 命令(
|
|
2
|
+
* AIXX CLI - market 命令(1104 公开端点版)
|
|
3
3
|
*
|
|
4
|
-
*
|
|
4
|
+
* 算力行情数据订阅(三档:consumer/bulk/all · 7天全功能试用):
|
|
5
5
|
* aixx market login --token <T> 保存访问令牌
|
|
6
6
|
* aixx market tickers [--usd] 全标的快照
|
|
7
7
|
* aixx market ticker <SYMBOL> 单标的快照
|
|
@@ -12,8 +12,9 @@
|
|
|
12
12
|
* 所有命令支持 --json(脚本管道用)
|
|
13
13
|
*
|
|
14
14
|
* 本命令组为纯数据输出,零 AI 参与;错误一律人话提示。
|
|
15
|
+
* 端点:/api/v1/* 公开命名契约(机读契约见 /api/v1/api-docs.json)。
|
|
15
16
|
*
|
|
16
|
-
* 令牌来源:环境变量 AIXX_MARKET_TOKEN → ~/.aixx/config.json
|
|
17
|
+
* 令牌来源:环境变量 AIXX_MARKET_TOKEN → ~/.aixx/config.json marketToken(兼容读 aciBetaToken)。
|
|
17
18
|
*/
|
|
18
19
|
|
|
19
20
|
import { existsSync, readFileSync, writeFileSync, mkdirSync } from 'fs';
|
|
@@ -107,11 +108,12 @@ function printScore(d) {
|
|
|
107
108
|
console.log(` ${d.symbol} 记分卡`);
|
|
108
109
|
console.log(` 总分: ${s.raw ?? '-'} 等级: ${s.grade ?? '-'}`);
|
|
109
110
|
const dims = s.dims || {};
|
|
110
|
-
const
|
|
111
|
+
const f = s.formula || {};
|
|
112
|
+
const w = f.weights || {};
|
|
111
113
|
console.log(` 回本维度: ${dims.payback ?? '-'} (权重 ${w.payback ?? 40})`);
|
|
112
114
|
console.log(` 涨价维度: ${dims.appreciation ?? '-'} (权重 ${w.appreciation ?? 30})`);
|
|
113
115
|
console.log(` 流通维度: ${dims.liquidity ?? '-'} (权重 ${w.liquidity ?? 30})`);
|
|
114
|
-
console.log(` 版本: ${
|
|
116
|
+
console.log(` 版本: ${f.version || '-'}`);
|
|
115
117
|
}
|
|
116
118
|
|
|
117
119
|
async function market(subArgs) {
|
|
@@ -140,7 +142,7 @@ async function market(subArgs) {
|
|
|
140
142
|
}
|
|
141
143
|
|
|
142
144
|
if (sub === 'tickers') {
|
|
143
|
-
const d = await mFetch(`/v1/
|
|
145
|
+
const d = await mFetch(`/api/v1/market/overview${usd ? '?currency=USD' : ''}`);
|
|
144
146
|
if (asJson) { console.log(JSON.stringify(d, null, 2)); return; }
|
|
145
147
|
console.log(`AIXX 算力行情 更新: ${d.generated} 标的: ${d.count} 币种: ${d.currency}\n`);
|
|
146
148
|
for (const c of d.cards || []) printTicker(c, usd);
|
|
@@ -150,7 +152,7 @@ async function market(subArgs) {
|
|
|
150
152
|
if (sub === 'ticker') {
|
|
151
153
|
const sym = (args[0] || '').toUpperCase();
|
|
152
154
|
if (!sym) { console.error('用法: aixx market ticker <SYMBOL>'); process.exit(1); }
|
|
153
|
-
const d = await mFetch(`/v1/
|
|
155
|
+
const d = await mFetch(`/api/v1/assets/${encodeURIComponent(sym)}${usd ? '?currency=USD' : ''}`);
|
|
154
156
|
if (asJson) { console.log(JSON.stringify(d, null, 2)); return; }
|
|
155
157
|
console.log(`AIXX 算力行情 更新: ${d.generated}`);
|
|
156
158
|
printTicker(d.ticker, d.currency === 'USD');
|
|
@@ -160,7 +162,7 @@ async function market(subArgs) {
|
|
|
160
162
|
if (sub === 'score') {
|
|
161
163
|
const sym = (args[0] || '').toUpperCase();
|
|
162
164
|
if (!sym) { console.error('用法: aixx market score <SYMBOL>'); process.exit(1); }
|
|
163
|
-
const d = await mFetch(`/v1/
|
|
165
|
+
const d = await mFetch(`/api/v1/assets/${encodeURIComponent(sym)}/aci`);
|
|
164
166
|
if (asJson) { console.log(JSON.stringify(d, null, 2)); return; }
|
|
165
167
|
printScore(d);
|
|
166
168
|
return;
|
|
@@ -170,11 +172,11 @@ async function market(subArgs) {
|
|
|
170
172
|
const sym = (args[0] || '').toUpperCase();
|
|
171
173
|
const days = parseInt(args[1] || '30', 10) || 30;
|
|
172
174
|
if (!sym) { console.error('用法: aixx market history <SYMBOL> [天数]'); process.exit(1); }
|
|
173
|
-
const d = await mFetch(`/v1/
|
|
175
|
+
const d = await mFetch(`/api/v1/assets/${encodeURIComponent(sym)}/history?days=${days}`);
|
|
174
176
|
if (asJson) { console.log(JSON.stringify(d, null, 2)); return; }
|
|
175
177
|
console.log(`AIXX 行情历史 ${d.symbol} 近 ${d.days} 天\n`);
|
|
176
178
|
for (const p of d.points || []) {
|
|
177
|
-
console.log(` ${p.generated} ${money(p.listing?.lo, false)} ~ ${money(p.listing?.hi, false)} 评分 ${p.score_raw ?? '-'}`);
|
|
179
|
+
console.log(` ${p.as_of ?? p.generated} ${money(p.listing?.lo, false)} ~ ${money(p.listing?.hi, false)} 评分 ${p.score_raw ?? '-'}`);
|
|
178
180
|
}
|
|
179
181
|
return;
|
|
180
182
|
}
|
|
@@ -182,14 +184,14 @@ async function market(subArgs) {
|
|
|
182
184
|
if (sub === 'detail') {
|
|
183
185
|
const sym = (args[0] || '').toUpperCase();
|
|
184
186
|
if (!sym) { console.error('用法: aixx market detail <SYMBOL> [--usd]'); process.exit(1); }
|
|
185
|
-
const d = await mFetch(`/v1/market/
|
|
187
|
+
const d = await mFetch(`/api/v1/market/bulk/${encodeURIComponent(sym)}${usd ? '?currency=USD' : ''}`);
|
|
186
188
|
if (asJson) { console.log(JSON.stringify(d, null, 2)); return; }
|
|
187
189
|
console.log(`AIXX 行情详情 ${d.symbol} 更新: ${d.generated} 币种: ${d.currency}\n`);
|
|
188
190
|
printTicker(d.ticker, d.currency === 'USD');
|
|
189
191
|
const pts = d.history?.points || [];
|
|
190
192
|
console.log(` 近 ${d.history?.days ?? 0} 天走势${d.history?.truncated ? '(截断)' : ''}:`);
|
|
191
193
|
for (const p of pts.slice(-10)) {
|
|
192
|
-
console.log(` ${p.generated} 评分 ${p.score_raw ?? '-'}`);
|
|
194
|
+
console.log(` ${p.as_of ?? p.generated} 评分 ${p.score_raw ?? '-'}`);
|
|
193
195
|
}
|
|
194
196
|
const rr = d.rent_regions || [];
|
|
195
197
|
if (rr.length) {
|
|
@@ -202,9 +204,9 @@ async function market(subArgs) {
|
|
|
202
204
|
if (sub === 'consumer') {
|
|
203
205
|
const sym = (args[0] || '').toLowerCase();
|
|
204
206
|
if (!sym) { console.error('用法: aixx market consumer <型号,如 rtx5090>'); process.exit(1); }
|
|
205
|
-
const d = await mFetch(`/v1/market/consumer/${encodeURIComponent(sym)}`);
|
|
207
|
+
const d = await mFetch(`/api/v1/market/consumer/${encodeURIComponent(sym)}`);
|
|
206
208
|
if (asJson) { console.log(JSON.stringify(d, null, 2)); return; }
|
|
207
|
-
console.log(`AIXX 消费级行情 ${d.symbol} 更新: ${d.updated_at || '-'}\n`);
|
|
209
|
+
console.log(`AIXX 消费级行情 ${d.symbol} 更新: ${d.as_of || d.updated_at || '-'}\n`);
|
|
208
210
|
const retail = d.retail || {};
|
|
209
211
|
for (const [ch, v] of Object.entries(retail)) {
|
|
210
212
|
if (!v || typeof v !== 'object') continue;
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* AIXX CLI - status 命令(1120 K哥令:身份编号必须给到用户的agent)
|
|
3
|
+
*
|
|
4
|
+
* 一条命令打出自家全貌:
|
|
5
|
+
* aixx status
|
|
6
|
+
* - 安装身份(萬安云编号 + sk key掩码)
|
|
7
|
+
* - 模型余额(cloudpay/balance 官方端点)
|
|
8
|
+
* - 行情数据 API 额度(X-Quota 或 /api/v1/account/usage)
|
|
9
|
+
*
|
|
10
|
+
* 设计给两种读者:人(终端输出)和 agent(同一输出可直接转述)。
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
import { existsSync, readFileSync } from 'fs';
|
|
14
|
+
import { homedir } from 'os';
|
|
15
|
+
import { join } from 'path';
|
|
16
|
+
|
|
17
|
+
const DEFAULT_BASE_URL = 'https://baodan.run/v1';
|
|
18
|
+
const CLOUD_BASE = 'https://console.aixx.ai';
|
|
19
|
+
const DATA_BASE = 'https://www.aixx.vip';
|
|
20
|
+
const FETCH_TIMEOUT = 12000;
|
|
21
|
+
|
|
22
|
+
function loadApiKey() {
|
|
23
|
+
if (process.env.AIXX_API_KEY) return process.env.AIXX_API_KEY;
|
|
24
|
+
try {
|
|
25
|
+
const cfg = JSON.parse(readFileSync(join(homedir(), '.aixx', 'config.json'), 'utf8'));
|
|
26
|
+
if (cfg.AIXX_API_KEY) return cfg.AIXX_API_KEY;
|
|
27
|
+
} catch {}
|
|
28
|
+
try {
|
|
29
|
+
const acc = JSON.parse(readFileSync(join(homedir(), '.aixx', 'account.json'), 'utf8'));
|
|
30
|
+
if (acc.apiKey) return acc.apiKey;
|
|
31
|
+
} catch {}
|
|
32
|
+
return '';
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
function loadIdentity() {
|
|
36
|
+
// 优先 account.json(正式账号),其次 config.json 的裸注册身份(1010方案)
|
|
37
|
+
try {
|
|
38
|
+
const acc = JSON.parse(readFileSync(join(homedir(), '.aixx', 'account.json'), 'utf8'));
|
|
39
|
+
if (acc.username) return { id: acc.username, kind: 'account' };
|
|
40
|
+
} catch {}
|
|
41
|
+
try {
|
|
42
|
+
const cfg = JSON.parse(readFileSync(join(homedir(), '.aixx', 'config.json'), 'utf8'));
|
|
43
|
+
if (cfg.AIXX_USER_ID) return { id: cfg.AIXX_USER_ID, kind: 'naked' };
|
|
44
|
+
} catch {}
|
|
45
|
+
return null;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
function maskKey(k) {
|
|
49
|
+
if (!k) return '(未找到)';
|
|
50
|
+
return k.slice(0, 8) + '…' + k.slice(-4);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
async function fetchJson(url, headers) {
|
|
54
|
+
const ctrl = new AbortController();
|
|
55
|
+
const t = setTimeout(() => ctrl.abort(), FETCH_TIMEOUT);
|
|
56
|
+
try {
|
|
57
|
+
const r = await fetch(url, { headers: headers || {}, signal: ctrl.signal });
|
|
58
|
+
return await r.json();
|
|
59
|
+
} finally { clearTimeout(t); }
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
export async function status() {
|
|
63
|
+
console.log('╔══════════════════════════════════════════╗');
|
|
64
|
+
console.log('║ AIXX 账户全景(aixx status) ║');
|
|
65
|
+
console.log('╚══════════════════════════════════════════╝\n');
|
|
66
|
+
|
|
67
|
+
// 1. 身份
|
|
68
|
+
const id = loadIdentity();
|
|
69
|
+
const apiKey = loadApiKey();
|
|
70
|
+
console.log('── 安装身份 ──');
|
|
71
|
+
if (id) {
|
|
72
|
+
console.log(`🪪 萬安云身份编号:${id.id}${id.kind === 'naked' ? '(裸注册身份)' : ''}`);
|
|
73
|
+
console.log(' 可在个人中心「账号设置 → 绑定安装身份」并入你的账户');
|
|
74
|
+
} else {
|
|
75
|
+
console.log('🪪 未找到本地身份(尚未安装?运行 npx aixxai install)');
|
|
76
|
+
}
|
|
77
|
+
console.log(`🔑 API Key:${maskKey(apiKey)}\n`);
|
|
78
|
+
|
|
79
|
+
// 2. 模型余额(cloudpay/balance 官方端点)
|
|
80
|
+
console.log('── 模型 API 余额 ──');
|
|
81
|
+
if (apiKey) {
|
|
82
|
+
try {
|
|
83
|
+
const b = await fetchJson(`${CLOUD_BASE}/cloudpay/balance?api_key=${encodeURIComponent(apiKey)}`);
|
|
84
|
+
if (b && b.ok) {
|
|
85
|
+
console.log(`💰 余额:$${Number(b.balance_usd).toFixed(2)}(账户 ${b.username})`);
|
|
86
|
+
} else {
|
|
87
|
+
console.log('⚠️ 查询失败:' + ((b && (b.detail || b.message)) || '未知错误'));
|
|
88
|
+
}
|
|
89
|
+
} catch (e) {
|
|
90
|
+
console.log('⚠️ 网络异常:' + e.message);
|
|
91
|
+
}
|
|
92
|
+
} else {
|
|
93
|
+
console.log('(无 key,跳过)');
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
// 3. 行情数据 API 额度(usage 端点,sk key 桥接可查)
|
|
97
|
+
console.log('\n── GPU 行情数据 API ──');
|
|
98
|
+
if (apiKey) {
|
|
99
|
+
try {
|
|
100
|
+
const u = await fetchJson(`${DATA_BASE}/api/v1/account/usage`,
|
|
101
|
+
{ Authorization: `Bearer ${apiKey}` });
|
|
102
|
+
if (u && u.ok) {
|
|
103
|
+
const left = u.free_quota - u.free_used;
|
|
104
|
+
console.log(`📊 档位:${u.tier === 'sub' ? '订阅中' : '免费档'}${u.sub_expires_at ? `(至 ${String(u.sub_expires_at).slice(0, 10)})` : ''}`);
|
|
105
|
+
console.log(`📊 免费额度:剩 ${left} / ${u.free_quota} 次(今日已用 ${u.today_counted})`);
|
|
106
|
+
} else {
|
|
107
|
+
console.log('⚠️ ' + ((u && (u.error || u.message)) || '查询失败'));
|
|
108
|
+
}
|
|
109
|
+
} catch (e) {
|
|
110
|
+
console.log('⚠️ 网络异常:' + e.message);
|
|
111
|
+
}
|
|
112
|
+
} else {
|
|
113
|
+
console.log('(无 key,跳过)');
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
console.log('\n── 入口 ──');
|
|
117
|
+
console.log('👤 个人中心:https://console.aixx.ai/console-app.html');
|
|
118
|
+
console.log('📈 行情数据:https://aixx.ai/data-api.html');
|
|
119
|
+
console.log('\n(对 AI 说「跑一下 aixx status」即可随时查看本全景)');
|
|
120
|
+
}
|