aixxai 1.6.8 → 1.7.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.
@@ -1,7 +1,7 @@
1
1
  /**
2
- * AIXX CLI - market 命令(1030 产品版)
2
+ * AIXX CLI - market 命令(1104 公开端点版)
3
3
  *
4
- * 算力行情数据订阅($998/月):
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 的 marketToken(兼容读 aciBetaToken)。
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 w = d.weights || {};
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(` 版本: ${d.formula || '-'}`);
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/aci/tickers${usd ? '?currency=USD' : ''}`);
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/aci/ticker/${encodeURIComponent(sym)}${usd ? '?currency=USD' : ''}`);
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/aci/scorecard/${encodeURIComponent(sym)}`);
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/aci/history/${encodeURIComponent(sym)}?days=${days}`);
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/detail/${encodeURIComponent(sym)}${usd ? '?currency=USD' : ''}`);
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;
@@ -1,96 +1,84 @@
1
- /**
2
- * AIXX CLI - search 命令
3
- *
4
- * 搜索AIXX能力库(数据/技能)。免key接口,未注册也能搜——
5
- * 目的:让用户先看到"有什么、多少钱",再决定要不要装。
6
- *
7
- * 接口:POST {DEFAULT_BASE_URL}/capability body: {need: 关键词}
8
- * 响应:{matched, capabilities:[{id,name,description,pricing:{per_use,weekly,monthly,free_quota},
9
- * match_score,estimated_time}]},可能带 compliance_blocked(合规拦截,服务端会给message)
10
- *
11
- * 注意:搜到的能力不是装到本地的,装好AIXX技能后AI直接说需求即可调用。
12
- */
13
-
14
- import { DEFAULT_BASE_URL } from '../../bin/aixx.js';
15
- import { detectAixxSkillDirs } from './install.js';
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
- // 描述压成一句话并截断(≤60字)
26
- function oneLine(text, max = 60) {
27
- const line = String(text || '').replace(/\s+/g, ' ').trim();
28
- return line.length > max ? line.slice(0, max) + '…' : line;
29
- }
30
-
31
- export async function search(subArgs) {
32
- const keyword = subArgs.filter(a => a && !a.startsWith('-')).join(' ').trim();
33
-
34
- // 无关键词:给用法示例,别让用户干瞪眼
35
- if (!keyword) {
36
- console.log('用法: aixx search <关键词>\n');
37
- console.log('示例:');
38
- console.log(' aixx search 抖音数据 查抖音相关的数据能力');
39
- console.log(' aixx search UI设计 查设计相关的技能');
40
- return;
41
- }
42
-
43
- console.log(`🔍 搜索AIXX能力: ${keyword}\n`);
44
-
45
- // 免key接口,不加任何认证头
46
- const baseUrl = process.env.AIXX_BASE_URL || DEFAULT_BASE_URL;
47
- let data;
48
- try {
49
- const resp = await fetch(`${baseUrl}/capability`, {
50
- method: 'POST',
51
- headers: { 'Content-Type': 'application/json' },
52
- body: JSON.stringify({ need: keyword }),
53
- signal: AbortSignal.timeout(FETCH_TIMEOUT),
54
- });
55
- if (!resp.ok) throw new Error(`HTTP ${resp.status}`);
56
- data = await resp.json();
57
- } catch (err) {
58
- console.error(`❌ 搜索失败: ${friendlyNetErr(err)}`);
59
- console.error(' 也可以直接到官网浏览全部能力: https://www.aixx.vip/cloud.html');
60
- process.exit(1);
61
- }
62
-
63
- // 合规拦截:如实转达服务端说法
64
- if (data?.compliance_blocked) {
65
- console.log(`⛔ ${data.message || '该关键词被合规策略拦截,换个说法试试'}`);
66
- return;
67
- }
68
-
69
- const caps = Array.isArray(data?.capabilities) ? data.capabilities : [];
70
- if (!data?.matched || caps.length === 0) {
71
- console.log(`没有找到与"${keyword}"相关的能力。`);
72
- console.log('建议换个关键词再试试,比如:抖音数据、小红书、UI设计、视频脚本。');
73
- return;
74
- }
75
-
76
- caps.forEach((cap, i) => {
77
- // data-*前缀的id是数据接口,其余是技能
78
- const type = cap.id?.startsWith('data-') ? '数据' : '技能';
79
- console.log(`${i + 1}. ${cap.name || '未命名'} [${type}]`);
80
- console.log(` ${oneLine(cap.description)}`);
81
- const tags = [];
82
- if (cap.pricing?.per_use !== undefined && cap.pricing?.per_use !== null) {
83
- tags.push("$1.99 一次买断·永久使用");
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
+ }
@@ -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
+ }