aixxai 1.6.9 → 1.7.1
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/package.json +38 -38
- package/src/commands/balance.js +24 -1
- package/src/commands/market.js +206 -232
- package/src/commands/search.js +84 -96
package/package.json
CHANGED
|
@@ -1,38 +1,38 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "aixxai",
|
|
3
|
-
"version": "1.
|
|
4
|
-
"description": "AIXX CLI - 让你的AI调用万物。One command, every AI model. By AIXX (Wanan Exchange), the verification-first compute exchange. 安装:npx aixxai",
|
|
5
|
-
"type": "module",
|
|
6
|
-
"bin": {
|
|
7
|
-
"aixx": "./bin/aixx.js"
|
|
8
|
-
},
|
|
9
|
-
"scripts": {
|
|
10
|
-
"test": "node bin/aixx.js --version"
|
|
11
|
-
},
|
|
12
|
-
"keywords": [
|
|
13
|
-
"aixx",
|
|
14
|
-
"aixxai",
|
|
15
|
-
"ai",
|
|
16
|
-
"llm",
|
|
17
|
-
"gateway",
|
|
18
|
-
"openai",
|
|
19
|
-
"glm",
|
|
20
|
-
"kimi",
|
|
21
|
-
"skill",
|
|
22
|
-
"agent",
|
|
23
|
-
"mcp",
|
|
24
|
-
"claude",
|
|
25
|
-
"cursor",
|
|
26
|
-
"api-gateway",
|
|
27
|
-
"compute",
|
|
28
|
-
"gpu",
|
|
29
|
-
"marketplace",
|
|
30
|
-
"exchange",
|
|
31
|
-
"wanan"
|
|
32
|
-
],
|
|
33
|
-
"author": "AIXX (Wanan Exchange)",
|
|
34
|
-
"license": "ISC",
|
|
35
|
-
"engines": {
|
|
36
|
-
"node": ">=18"
|
|
37
|
-
}
|
|
38
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "aixxai",
|
|
3
|
+
"version": "1.7.1",
|
|
4
|
+
"description": "AIXX CLI - 让你的AI调用万物。One command, every AI model. By AIXX (Wanan Exchange), the verification-first compute exchange. 安装:npx aixxai",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"bin": {
|
|
7
|
+
"aixx": "./bin/aixx.js"
|
|
8
|
+
},
|
|
9
|
+
"scripts": {
|
|
10
|
+
"test": "node bin/aixx.js --version"
|
|
11
|
+
},
|
|
12
|
+
"keywords": [
|
|
13
|
+
"aixx",
|
|
14
|
+
"aixxai",
|
|
15
|
+
"ai",
|
|
16
|
+
"llm",
|
|
17
|
+
"gateway",
|
|
18
|
+
"openai",
|
|
19
|
+
"glm",
|
|
20
|
+
"kimi",
|
|
21
|
+
"skill",
|
|
22
|
+
"agent",
|
|
23
|
+
"mcp",
|
|
24
|
+
"claude",
|
|
25
|
+
"cursor",
|
|
26
|
+
"api-gateway",
|
|
27
|
+
"compute",
|
|
28
|
+
"gpu",
|
|
29
|
+
"marketplace",
|
|
30
|
+
"exchange",
|
|
31
|
+
"wanan"
|
|
32
|
+
],
|
|
33
|
+
"author": "AIXX (Wanan Exchange)",
|
|
34
|
+
"license": "ISC",
|
|
35
|
+
"engines": {
|
|
36
|
+
"node": ">=18"
|
|
37
|
+
}
|
|
38
|
+
}
|
package/src/commands/balance.js
CHANGED
|
@@ -163,8 +163,31 @@ export async function balance(subArgs) {
|
|
|
163
163
|
console.log(`💳 账户总额度:¥${totalCny.toFixed(2)}($${hardLimitUsd.toFixed(2)})`);
|
|
164
164
|
}
|
|
165
165
|
console.log('────────────────────────────────────');
|
|
166
|
+
|
|
167
|
+
// 4. GPU行情数据API额度(1121千问终检③"最后一跳":/api/v1/account/usage @ www.aixx.vip)
|
|
168
|
+
if (apiKey) {
|
|
169
|
+
try {
|
|
170
|
+
const ctrl = new AbortController();
|
|
171
|
+
const t4 = setTimeout(() => ctrl.abort(), 12000);
|
|
172
|
+
const u = await fetch('https://www.aixx.vip/api/v1/account/usage', {
|
|
173
|
+
headers: { Authorization: `Bearer ${apiKey}` },
|
|
174
|
+
signal: ctrl.signal,
|
|
175
|
+
});
|
|
176
|
+
clearTimeout(t4);
|
|
177
|
+
const j = await u.json();
|
|
178
|
+
if (j && j.ok) {
|
|
179
|
+
const left = j.free_quota - j.free_used;
|
|
180
|
+
console.log('\n── GPU 行情数据 API ──');
|
|
181
|
+
console.log(`📊 档位:${j.tier === 'sub' ? '订阅中' : '免费档'}${j.sub_expires_at ? `(至 ${String(j.sub_expires_at).slice(0, 10)})` : ''}`);
|
|
182
|
+
console.log(`📊 免费额度:剩 ${left} / ${j.free_quota} 次(今日已用 ${j.today_counted})`);
|
|
183
|
+
console.log('────────────────────────────────────');
|
|
184
|
+
}
|
|
185
|
+
} catch { /* 数据API额度查询失败不影响主流程 */ }
|
|
186
|
+
}
|
|
187
|
+
|
|
166
188
|
console.log('\n💡 提示:');
|
|
167
189
|
console.log(' - 新用户注册送 $0.5 试用额度');
|
|
168
190
|
console.log(' - glm-4-air 便宜,省着用能聊很久');
|
|
169
|
-
console.log(' - 余额不足时运行 aixx recharge
|
|
191
|
+
console.log(' - 余额不足时运行 aixx recharge 查看充值方式');
|
|
192
|
+
console.log(' - 一条命令看全貌:aixx status\n');
|
|
170
193
|
}
|
package/src/commands/market.js
CHANGED
|
@@ -1,232 +1,206 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* AIXX CLI - market 命令(
|
|
3
|
-
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
}
|
|
61
|
-
if (res.status ===
|
|
62
|
-
console.error('
|
|
63
|
-
process.exit(1);
|
|
64
|
-
}
|
|
65
|
-
if (res.status ===
|
|
66
|
-
console.error('
|
|
67
|
-
process.exit(1);
|
|
68
|
-
}
|
|
69
|
-
if (
|
|
70
|
-
console.error(
|
|
71
|
-
process.exit(1);
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
console.log(`
|
|
100
|
-
console.log(`
|
|
101
|
-
|
|
102
|
-
console.log(`
|
|
103
|
-
console.log('');
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
function
|
|
107
|
-
const
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
const
|
|
129
|
-
|
|
130
|
-
if (
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
return;
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
const d = await mFetch(`/api/v1/market/consumer/${encodeURIComponent(sym)}`);
|
|
208
|
-
if (asJson) { console.log(JSON.stringify(d, null, 2)); return; }
|
|
209
|
-
console.log(`AIXX 消费级行情 ${d.symbol} 更新: ${d.as_of || d.updated_at || '-'}\n`);
|
|
210
|
-
const retail = d.retail || {};
|
|
211
|
-
for (const [ch, v] of Object.entries(retail)) {
|
|
212
|
-
if (!v || typeof v !== 'object') continue;
|
|
213
|
-
console.log(` ${ch}: 中位 ${money(v.median, false)} 区间 ${money(v.min, false)} ~ ${money(v.max, false)} (${v.n || 0} 条)`);
|
|
214
|
-
}
|
|
215
|
-
const rr = d.rent_regions || [];
|
|
216
|
-
if (rr.length) {
|
|
217
|
-
console.log(`\n 地区租金: ${rr.map((r) => `${r.region || r[0]} ${r.usd_hr || r[1]}`).join(' · ')}`);
|
|
218
|
-
}
|
|
219
|
-
return;
|
|
220
|
-
}
|
|
221
|
-
|
|
222
|
-
console.log('用法: aixx market <子命令>');
|
|
223
|
-
console.log(' login --token <T> 保存访问令牌');
|
|
224
|
-
console.log(' tickers [--usd] [--json] 全标的快照');
|
|
225
|
-
console.log(' ticker <SYMBOL> 单标的快照');
|
|
226
|
-
console.log(' score <SYMBOL> 标的记分卡');
|
|
227
|
-
console.log(' history <SYMBOL> [天数] 历史点位');
|
|
228
|
-
console.log(' detail <SYMBOL> [--usd] 大宗详情数据包');
|
|
229
|
-
console.log(' consumer <型号> 消费级详情数据包');
|
|
230
|
-
}
|
|
231
|
-
|
|
232
|
-
export { market };
|
|
1
|
+
/**
|
|
2
|
+
* AIXX CLI - market 命令(GPU 算力行情)
|
|
3
|
+
*
|
|
4
|
+
* 1121 行情首页窗拍B:六命令重映射到生产端点(bulk/consumer族·四轮找茬淬炼)。
|
|
5
|
+
* tickers → GET /api/v1/market/bulk 全标的快照(40SKU锚价)
|
|
6
|
+
* ticker → bulk + 客户端过滤 单标的
|
|
7
|
+
* detail → bulk 过滤全字段 大宗详情
|
|
8
|
+
* consumer→ GET /api/v1/market/consumer 消费级租金带
|
|
9
|
+
* score/history → ACI记分卡/历史点位=卡194内测端点候上生产(行情首页窗拍B流程)——如实报未上生产
|
|
10
|
+
*
|
|
11
|
+
* 凭证兼容序: AIXX_MARKET_TOKEN → config marketToken/aciBetaToken → AIXX_API_KEY → config AIXX_API_KEY → account.json apiKey
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
import { existsSync, readFileSync, mkdirSync, writeFileSync } from 'fs';
|
|
15
|
+
import { join } from 'path';
|
|
16
|
+
import { homedir } from 'os';
|
|
17
|
+
|
|
18
|
+
const BASE = process.env.AIXX_MARKET_BASE_URL || 'https://aixx.ai';
|
|
19
|
+
const FETCH_TIMEOUT = 15000;
|
|
20
|
+
|
|
21
|
+
function configFile() {
|
|
22
|
+
return join(homedir(), '.aixx', 'config.json');
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
function loadToken() {
|
|
26
|
+
if (process.env.AIXX_MARKET_TOKEN) return process.env.AIXX_MARKET_TOKEN;
|
|
27
|
+
try {
|
|
28
|
+
const f = configFile();
|
|
29
|
+
if (existsSync(f)) {
|
|
30
|
+
const conf = JSON.parse(readFileSync(f, 'utf-8'));
|
|
31
|
+
if (conf.marketToken) return conf.marketToken;
|
|
32
|
+
if (conf.aciBetaToken) return conf.aciBetaToken;
|
|
33
|
+
if (conf.AIXX_API_KEY) return conf.AIXX_API_KEY;
|
|
34
|
+
}
|
|
35
|
+
} catch (e) { /* 走未配置路径 */ }
|
|
36
|
+
if (process.env.AIXX_API_KEY) return process.env.AIXX_API_KEY;
|
|
37
|
+
try {
|
|
38
|
+
const acc = join(homedir(), '.aixx', 'account.json');
|
|
39
|
+
if (existsSync(acc)) {
|
|
40
|
+
const a = JSON.parse(readFileSync(acc, 'utf-8'));
|
|
41
|
+
if (a.apiKey) return a.apiKey;
|
|
42
|
+
}
|
|
43
|
+
} catch (e) { /* 走未配置路径 */ }
|
|
44
|
+
return null;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
async function mFetch(path) {
|
|
48
|
+
const token = loadToken();
|
|
49
|
+
if (!token) {
|
|
50
|
+
console.error('尚未配置访问令牌。');
|
|
51
|
+
console.error('开通: https://www.aixx.vip | 或设置环境变量 AIXX_API_KEY');
|
|
52
|
+
process.exit(1);
|
|
53
|
+
}
|
|
54
|
+
const ctrl = new AbortController();
|
|
55
|
+
const timer = setTimeout(() => ctrl.abort(), FETCH_TIMEOUT);
|
|
56
|
+
try {
|
|
57
|
+
const res = await fetch(`${BASE}${path}`, {
|
|
58
|
+
headers: { Authorization: `Bearer ${token}` },
|
|
59
|
+
signal: ctrl.signal,
|
|
60
|
+
});
|
|
61
|
+
if (res.status === 403) {
|
|
62
|
+
console.error('当前订阅档位不包含该数据 —— 如需升级请访问 aixx.ai 或联系客服');
|
|
63
|
+
process.exit(1);
|
|
64
|
+
}
|
|
65
|
+
if (res.status === 404) {
|
|
66
|
+
console.error('未查询到该数据(请核对标的代码)');
|
|
67
|
+
process.exit(1);
|
|
68
|
+
}
|
|
69
|
+
if (res.status === 401) {
|
|
70
|
+
console.error('令牌无效或已过期,请重新登录: aixx market login --token <T>');
|
|
71
|
+
process.exit(1);
|
|
72
|
+
}
|
|
73
|
+
if (!res.ok) {
|
|
74
|
+
console.error(`服务暂不可用 (${res.status}),请稍后重试`);
|
|
75
|
+
process.exit(1);
|
|
76
|
+
}
|
|
77
|
+
return await res.json();
|
|
78
|
+
} catch (err) {
|
|
79
|
+
console.error(err?.name === 'AbortError' || err?.name === 'TimeoutError'
|
|
80
|
+
? '连接超时,请检查网络后重试' : '网络异常,请稍后重试');
|
|
81
|
+
process.exit(1);
|
|
82
|
+
} finally {
|
|
83
|
+
clearTimeout(timer);
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
function fmtCnyWan(v) {
|
|
88
|
+
if (typeof v !== 'number') return '-';
|
|
89
|
+
return v >= 10000 ? `¥${(v / 10000).toFixed(1)}万` : `¥${v.toLocaleString()}`;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
function fmtUsd(v) {
|
|
93
|
+
if (typeof v !== 'number') return '-';
|
|
94
|
+
return v >= 10000 ? `$${(v / 10000).toFixed(1)}万` : `$${v.toLocaleString()}`;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
function printBulkItem(it, usd) {
|
|
98
|
+
const price = usd ? fmtUsd(it.price_usd) : fmtCnyWan(it.price_cny);
|
|
99
|
+
console.log(` ${it.subject || it.sku} (${it.sku})`);
|
|
100
|
+
console.log(` 锚价: ${price}${usd ? '' : ' | ' + fmtUsd(it.price_usd)}`);
|
|
101
|
+
console.log(` 在售: ${it.units_on_sale ?? '-'} 台 采购热度: ${it.buyer_heat ?? '-'} 售出中位: ${it.sold_median_days ?? '-'} 天`);
|
|
102
|
+
if (it.premium_note) console.log(` 口径: ${it.premium_note}`);
|
|
103
|
+
console.log('');
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
function filterItems(items, kw) {
|
|
107
|
+
const k = String(kw || '').toLowerCase();
|
|
108
|
+
return items.filter((it) =>
|
|
109
|
+
String(it.sku || '').toLowerCase().includes(k) ||
|
|
110
|
+
String(it.subject || '').toLowerCase().includes(k) ||
|
|
111
|
+
String(it.subject_en || '').toLowerCase().includes(k));
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
async function market(subArgs) {
|
|
115
|
+
const sub = subArgs[0] || 'help';
|
|
116
|
+
const rest = subArgs.slice(1);
|
|
117
|
+
const asJson = rest.includes('--json');
|
|
118
|
+
const usd = rest.includes('--usd');
|
|
119
|
+
const args = rest.filter((a) => !a.startsWith('--'));
|
|
120
|
+
|
|
121
|
+
if (sub === 'login') {
|
|
122
|
+
const i = rest.indexOf('--token');
|
|
123
|
+
const tok = i >= 0 ? rest[i + 1] : null;
|
|
124
|
+
if (!tok) {
|
|
125
|
+
console.error('用法: aixx market login --token <令牌>');
|
|
126
|
+
process.exit(1);
|
|
127
|
+
}
|
|
128
|
+
const f = configFile();
|
|
129
|
+
let conf = {};
|
|
130
|
+
try { if (existsSync(f)) conf = JSON.parse(readFileSync(f, 'utf-8')); } catch (e) { conf = {}; }
|
|
131
|
+
conf.marketToken = tok;
|
|
132
|
+
mkdirSync(join(homedir(), '.aixx'), { recursive: true });
|
|
133
|
+
writeFileSync(f, JSON.stringify(conf, null, 2));
|
|
134
|
+
console.log('✓ 令牌已保存');
|
|
135
|
+
return;
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
if (sub === 'tickers') {
|
|
139
|
+
const d = await mFetch('/api/v1/market/bulk');
|
|
140
|
+
const items = d?.data?.items || [];
|
|
141
|
+
if (asJson) { console.log(JSON.stringify(d, null, 2)); return; }
|
|
142
|
+
console.log(`AIXX 大宗算力行情 更新: ${d?.data?.generated_at || '-'} 标的: ${items.length}\n`);
|
|
143
|
+
for (const it of items) printBulkItem(it, usd);
|
|
144
|
+
return;
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
if (sub === 'ticker' || sub === 'detail') {
|
|
148
|
+
const sym = (args[0] || '').trim();
|
|
149
|
+
if (!sym) { console.error(`用法: aixx market ${sub} <标的,如 b300>`); process.exit(1); }
|
|
150
|
+
const d = await mFetch('/api/v1/market/bulk');
|
|
151
|
+
const items = filterItems(d?.data?.items || [], sym);
|
|
152
|
+
if (asJson) { console.log(JSON.stringify(sub === 'detail' ? items : items[0] || {}, null, 2)); return; }
|
|
153
|
+
if (items.length === 0) {
|
|
154
|
+
console.log(`未找到与"${sym}"匹配的标的。`);
|
|
155
|
+
console.log('用 aixx market tickers 看全部标的代码。');
|
|
156
|
+
return;
|
|
157
|
+
}
|
|
158
|
+
console.log(`AIXX 大宗行情 · ${sym} 匹配 ${items.length} 条 更新: ${d?.data?.generated_at || '-'}\n`);
|
|
159
|
+
for (const it of items) printBulkItem(it, usd);
|
|
160
|
+
return;
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
if (sub === 'score' || sub === 'history') {
|
|
164
|
+
const nameZh = sub === 'score' ? 'ACI记分卡' : '历史点位(K线)';
|
|
165
|
+
console.log(`📊 ${nameZh}端点为ACI内测版(卡194),候行情首页窗质检上生产后开放。`);
|
|
166
|
+
console.log(' 现在可用的替代:');
|
|
167
|
+
console.log(' - aixx market ticker <标的> 锚价/在售/热度/售出中位');
|
|
168
|
+
console.log(' - aixx market consumer <型号> 消费级全球租金带');
|
|
169
|
+
console.log(' - aixx status 账户与数据API额度全貌');
|
|
170
|
+
return;
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
if (sub === 'consumer') {
|
|
174
|
+
const sym = (args[0] || '').toLowerCase();
|
|
175
|
+
if (!sym) { console.error('用法: aixx market consumer <型号,如 4090>'); process.exit(1); }
|
|
176
|
+
const d = await mFetch(`/api/v1/market/consumer?symbol=${encodeURIComponent(sym)}`);
|
|
177
|
+
const syms = d?.data?.symbols || [];
|
|
178
|
+
if (asJson) { console.log(JSON.stringify(d, null, 2)); return; }
|
|
179
|
+
if (syms.length === 0) {
|
|
180
|
+
console.log(`未找到与"${sym}"匹配的消费级型号。`);
|
|
181
|
+
return;
|
|
182
|
+
}
|
|
183
|
+
console.log(`AIXX 消费级行情 更新: ${d?.data?.updated_at || '-'} 单位: ${d?.data?.unit || '-'}\n`);
|
|
184
|
+
for (const s of syms) {
|
|
185
|
+
console.log(` ${s.symbol}:`);
|
|
186
|
+
for (const r of s.rows || []) {
|
|
187
|
+
const band = Array.isArray(r.band) ? ` 区间 $${r.band[0]}~$${r.band[1]}` : '';
|
|
188
|
+
console.log(` ${r.region || r.region_en}: $${r.usd_per_hr}/台·时${band}${r.samples ? ` (${r.samples} 采样)` : ''}`);
|
|
189
|
+
}
|
|
190
|
+
console.log('');
|
|
191
|
+
}
|
|
192
|
+
return;
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
// help / 未知子命令
|
|
196
|
+
console.log('用法: aixx market <子命令>');
|
|
197
|
+
console.log(' tickers [--usd] [--json] 全标的快照(40SKU锚价)');
|
|
198
|
+
console.log(' ticker <标的> [--usd] 单标的(如 b300 / h200)');
|
|
199
|
+
console.log(' detail <标的> [--usd] 大宗详情(含口径注)');
|
|
200
|
+
console.log(' consumer <型号> 消费级全球租金带(如 4090)');
|
|
201
|
+
console.log(' score <标的> ACI记分卡(内测候上生产)');
|
|
202
|
+
console.log(' history <标的> [天数] 历史点位(内测候上生产)');
|
|
203
|
+
console.log(' login --token <T> 保存访问令牌(兼容项,标准key即可用)');
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
export { market };
|
package/src/commands/search.js
CHANGED
|
@@ -1,96 +1,84 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* AIXX CLI - search 命令
|
|
3
|
-
*
|
|
4
|
-
* 搜索AIXX
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
import {
|
|
15
|
-
import {
|
|
16
|
-
|
|
17
|
-
// 与 install/balance 同款:统一 15 秒超时 + 网络/超时异常转友好提示
|
|
18
|
-
const FETCH_TIMEOUT = 15000;
|
|
19
|
-
function friendlyNetErr(err) {
|
|
20
|
-
return err?.name === 'TimeoutError' || err?.name === 'AbortError'
|
|
21
|
-
? '连接超时,请检查网络'
|
|
22
|
-
: err?.message || String(err);
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
console.log('
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
if (
|
|
71
|
-
console.log(`没有找到与"${keyword}"
|
|
72
|
-
console.log('
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
console.log(`${i + 1}. ${
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
if ((cap.pricing?.free_quota || 0) > 0) {
|
|
86
|
-
|
|
87
|
-
}
|
|
88
|
-
tags.push(`ID: ${cap.id}`);
|
|
89
|
-
console.log(` ${tags.join(' · ')}`);
|
|
90
|
-
});
|
|
91
|
-
|
|
92
|
-
console.log('\n以上能力无需单独安装——安装AIXX技能后,你的AI直接说需求即可调用(能力ID给AI看就行)');
|
|
93
|
-
if (detectAixxSkillDirs().length === 0) {
|
|
94
|
-
console.log('还没安装AIXX技能?运行 npx aixxai install 一键开通');
|
|
95
|
-
}
|
|
96
|
-
}
|
|
1
|
+
/**
|
|
2
|
+
* AIXX CLI - search 命令
|
|
3
|
+
*
|
|
4
|
+
* 搜索AIXX可用AI模型。GET {DEFAULT_BASE_URL}/models(OpenAI兼容·装机key可查),
|
|
5
|
+
* 客户端按关键词过滤——1121千问终检③:旧 /capability 端点已退役404,换本端点。
|
|
6
|
+
*
|
|
7
|
+
* 响应:{data:[{id,object,created,owned_by}]}(159+模型)
|
|
8
|
+
*
|
|
9
|
+
* 注意:模型列表只读展示;调用走你自己的agent(key已在本地)。
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
import { DEFAULT_BASE_URL } from '../../bin/aixx.js';
|
|
13
|
+
import { existsSync, readFileSync } from 'fs';
|
|
14
|
+
import { join } from 'path';
|
|
15
|
+
import { homedir } from 'os';
|
|
16
|
+
|
|
17
|
+
// 与 install/balance 同款:统一 15 秒超时 + 网络/超时异常转友好提示
|
|
18
|
+
const FETCH_TIMEOUT = 15000;
|
|
19
|
+
function friendlyNetErr(err) {
|
|
20
|
+
return err?.name === 'TimeoutError' || err?.name === 'AbortError'
|
|
21
|
+
? '连接超时,请检查网络'
|
|
22
|
+
: err?.message || String(err);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
function loadKey() {
|
|
26
|
+
if (process.env.AIXX_API_KEY) return process.env.AIXX_API_KEY;
|
|
27
|
+
try {
|
|
28
|
+
const f = join(homedir(), '.aixx', 'config.json');
|
|
29
|
+
if (existsSync(f)) return JSON.parse(readFileSync(f, 'utf-8')).AIXX_API_KEY || '';
|
|
30
|
+
} catch { /* 无key走未登录路径 */ }
|
|
31
|
+
return '';
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export async function search(subArgs) {
|
|
35
|
+
const keyword = subArgs.filter(a => a && !a.startsWith('-')).join(' ').trim();
|
|
36
|
+
|
|
37
|
+
// 无关键词:给用法示例,别让用户干瞪眼
|
|
38
|
+
if (!keyword) {
|
|
39
|
+
console.log('用法: aixx search <关键词>\n');
|
|
40
|
+
console.log('示例:');
|
|
41
|
+
console.log(' aixx search glm 查GLM系模型');
|
|
42
|
+
console.log(' aixx search deepseek 查DeepSeek系模型');
|
|
43
|
+
console.log(' aixx market tickers 查GPU行情标的');
|
|
44
|
+
return;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
console.log(`🔍 搜索AIXX模型: ${keyword}\n`);
|
|
48
|
+
|
|
49
|
+
// /v1/models(OpenAI兼容)——装机key即身份,与对话同源
|
|
50
|
+
const baseUrl = process.env.AIXX_BASE_URL || DEFAULT_BASE_URL;
|
|
51
|
+
const apiKey = loadKey();
|
|
52
|
+
|
|
53
|
+
let data;
|
|
54
|
+
try {
|
|
55
|
+
const resp = await fetch(`${baseUrl}/models`, {
|
|
56
|
+
headers: apiKey ? { Authorization: `Bearer ${apiKey}` } : {},
|
|
57
|
+
signal: AbortSignal.timeout(FETCH_TIMEOUT),
|
|
58
|
+
});
|
|
59
|
+
if (!resp.ok) throw new Error(`HTTP ${resp.status}`);
|
|
60
|
+
data = await resp.json();
|
|
61
|
+
} catch (err) {
|
|
62
|
+
console.error(`❌ 搜索失败: ${friendlyNetErr(err)}`);
|
|
63
|
+
console.error(' 也可以直接到官网浏览全部模型: https://console.aixx.ai');
|
|
64
|
+
process.exit(1);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
const caps = (Array.isArray(data?.data) ? data.data : [])
|
|
68
|
+
.filter((m) => String(m.id || '').toLowerCase().includes(keyword.toLowerCase()));
|
|
69
|
+
|
|
70
|
+
if (caps.length === 0) {
|
|
71
|
+
console.log(`没有找到与"${keyword}"相关的模型。`);
|
|
72
|
+
console.log('建议换个关键词再试试,比如:glm、deepseek、kimi、qwen、llama。');
|
|
73
|
+
console.log('找GPU行情数据?用 aixx market tickers 或 aixx market consumer <型号>。');
|
|
74
|
+
return;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
console.log(`共 ${caps.length} 个匹配:\n`);
|
|
78
|
+
caps.slice(0, 10).forEach((m, i) => {
|
|
79
|
+
console.log(`${i + 1}. ${m.id} (${m.owned_by || 'aixx'})`);
|
|
80
|
+
});
|
|
81
|
+
if (caps.length > 10) console.log(`… 其余 ${caps.length - 10} 个略(调 aixx search <更精确关键词>)`);
|
|
82
|
+
|
|
83
|
+
console.log('\n以上模型你的AI已可直接调用(key在本地);行情数据用 aixx market / aixx status 查看。');
|
|
84
|
+
}
|