aixxai 1.7.6 → 1.7.7

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/bin/aixx.js CHANGED
@@ -32,6 +32,7 @@ import { aci } from '../src/commands/aci.js';
32
32
  import { market } from '../src/commands/market.js';
33
33
  import { servers } from '../src/commands/servers.js';
34
34
  import { status } from '../src/commands/status.js';
35
+ import { subscribe } from '../src/commands/subscribe.js';
35
36
  import { showHelp, showVersion } from '../src/commands/help.js';
36
37
 
37
38
  // 版本号从 package.json 读(单一来源,别再硬编码)
@@ -56,7 +57,8 @@ const COMMANDS = [
56
57
  { name: 'market', run: market }, /* 1030产品版: 行情数据订阅(docs/PLAN_MARKET_API_1030.md), 不进help带外态 */
57
58
  { name: 'aci', run: aci }, /* 已并入market, 保留指路 */
58
59
  { name: 'servers', run: servers }, /* 1022版: 萬安云服务器货架 */
59
- { name: 'status', aliases: ['st'], run: status }, /* 1120 K哥令: 身份编号给到agent·一条命令看全貌 */
60
+ { name: 'status', aliases: ['st'], run: status },
61
+ { name: 'subscribe', aliases: ['sub'], run: subscribe }, /* 1121 K哥令: 一步收银台·对话直达 */ /* 1120 K哥令: 身份编号给到agent·一条命令看全貌 */
60
62
  ];
61
63
 
62
64
  // help/version 不吃子参数(走 flag/无参分支),但命令名仍参与下面的近似匹配
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "aixxai",
3
- "version": "1.7.6",
3
+ "version": "1.7.7",
4
4
  "description": "AIXX CLI - 让你的AI调用万物。One command, every AI model. By AIXX (Wanan Exchange), the verification-first compute exchange. 安装:npx aixxai",
5
5
  "type": "module",
6
6
  "bin": {
@@ -1,131 +1,157 @@
1
- /**
2
- * AIXX CLI - recharge 命令
3
- *
4
- * 显示充值方式。优先尝试调后端 creem/pay 接口生成在线充值链接;
5
- * 如果后端不支持或失败,则给出通用引导(联系客服/后台充值)。
6
- */
7
-
8
- import { DEFAULT_BASE_URL } from '../../bin/aixx.js';
9
- import { loadApiKey, maskKey } from '../utils/env.js';
10
-
11
- // 所有对外请求统一 15 秒超时
12
- const FETCH_TIMEOUT = 15000;
13
-
14
- /**
15
- * apiKey 读取统一走 src/utils/env.js 的 loadApiKey:
16
- * 环境变量 AIXX_API_KEY → ~/.aixx/config.json → ~/.aixx/account.json
17
- */
18
-
19
- /**
20
- * 尝试调后端的 creem 支付接口生成充值链接。
21
- * New-API 的在线充值常见接口:
22
- * POST /api/user/creem/pay { amount, ... }
23
- * 不同版本字段不一,失败就回退到手动引导。
24
- */
25
- async function tryGetCreemLink(apiKey, baseUrl, amount) {
26
- const apiBase = baseUrl.replace(/\/v1$/, '');
27
- const candidates = [
28
- {
29
- url: `${apiBase}/api/user/creem/pay`,
30
- body: { amount, currency: 'USD', gateway: 'creem' },
31
- },
32
- {
33
- url: `${apiBase}/api/user/topup`,
34
- body: { amount, top_up_code: '', payment_method: 'creem' },
35
- },
36
- ];
37
-
38
- for (const c of candidates) {
39
- try {
40
- const resp = await fetch(c.url, {
41
- method: 'POST',
42
- headers: {
43
- Authorization: `Bearer ${apiKey}`,
44
- 'Content-Type': 'application/json',
45
- },
46
- body: JSON.stringify(c.body),
47
- signal: AbortSignal.timeout(FETCH_TIMEOUT),
48
- });
49
- if (!resp.ok) continue;
50
- const data = await resp.json().catch(() => null);
51
- if (!data) continue;
52
- // 多种可能的字段名兜底
53
- const link =
54
- data.data?.url ||
55
- data.data?.payment_url ||
56
- data.data?.checkout_url ||
57
- data.url ||
58
- data.payment_url;
59
- if (link) return link;
60
- } catch (e) {
61
- // 超时单独提示一次(其余错误静默试下一个候选接口)
62
- if (e?.name === 'TimeoutError' || e?.name === 'AbortError') {
63
- console.log(' ⚠️ 连接超时,请检查网络');
64
- }
65
- }
66
- }
67
- return null;
68
- }
69
-
70
- export async function recharge(subArgs) {
71
- console.log('╔══════════════════════════════════════════╗');
72
- console.log('║ AIXX 充值 ║');
73
- console.log('╚══════════════════════════════════════════╝\n');
74
-
75
- const apiKey = loadApiKey();
76
- const baseUrl = process.env.AIXX_BASE_URL || DEFAULT_BASE_URL;
77
-
78
- // 从参数取金额,默认 $5(最低)
79
- let amount = 5;
80
- if (subArgs[0]) {
81
- const n = Number(subArgs[0]);
82
- if (!Number.isNaN(n) && n > 0) amount = n;
83
- }
84
-
85
- if (!apiKey) {
86
- console.log('⚠️ 未检测到AIXX API Key,以下为通用充值方式:\n');
87
- console.log('充值方式:');
88
- console.log(' 信用卡 / ApplePay:登录 AIXX 后台 → 充值 → Creem');
89
- console.log(' USDT 加密货币:联系客服或后台提交');
90
- console.log(`\n 最低充值 $5`);
91
- console.log(`\n🌐 后台地址:${baseUrl.replace(/\/v1$/, '')}`);
92
- return;
93
- }
94
-
95
- console.log(`使用Key: ${maskKey(apiKey)}`);
96
- console.log(`充值金额:$${amount}\n`);
97
-
98
- // 尝试生成在线支付链接
99
- console.log('🔄 正在生成在线充值链接...');
100
- const link = await tryGetCreemLink(apiKey, baseUrl, amount);
101
-
102
- console.log('\n────────────────────────────────────');
103
- console.log('💳 充值方式:');
104
- console.log('────────────────────────────────────');
105
-
106
- if (link) {
107
- console.log('\n ① 信用卡 / ApplePay(推荐,即时到账):');
108
- console.log(` ${link}`);
109
- console.log('\n 复制链接到浏览器打开即可支付。');
110
- } else {
111
- console.log('\n ① 信用卡 / ApplePay:');
112
- console.log(' 自动生成链接失败,请直接登录后台充值:');
113
- console.log(` ${baseUrl.replace(/\/v1$/, '')}/console/topup`);
114
- }
115
-
116
- console.log('\n ② USDT 加密货币:');
117
- console.log(' 联系 AIXX 客服,或后台提交 USDT 充值订单');
118
- console.log(' (后续会支持自动生成钱包地址)');
119
-
120
- console.log('\n ③ 微信/支付宝:');
121
- console.log(' 联系 AIXX 客服走人工充值');
122
-
123
- console.log('\n────────────────────────────────────');
124
- console.log(`最低充值 $5(约 ¥${(amount * 7).toFixed(0)})`);
125
- console.log(`充值后额度即时到账,可直接使用。\n`);
126
-
127
- console.log('💡 充值提示:');
128
- console.log(' - 充 $5 用 glm-4-air 能聊 5 万次以上');
129
- console.log(' - 充 $20 够用 Claude/GPT 跑一个月');
130
- console.log(' - 推荐码注册的用户充值后推荐人有分润\n');
131
- }
1
+ /**
2
+ * AIXX CLI - recharge 命令
3
+ *
4
+ * 显示充值方式。优先尝试调后端 creem/pay 接口生成在线充值链接;
5
+ * 如果后端不支持或失败,则给出通用引导(联系客服/后台充值)。
6
+ */
7
+
8
+ import { DEFAULT_BASE_URL } from '../../bin/aixx.js';
9
+ import { loadApiKey, maskKey } from '../utils/env.js';
10
+
11
+ // 所有对外请求统一 15 秒超时
12
+ const FETCH_TIMEOUT = 15000;
13
+
14
+ /**
15
+ * apiKey 读取统一走 src/utils/env.js 的 loadApiKey:
16
+ * 环境变量 AIXX_API_KEY → ~/.aixx/config.json → ~/.aixx/account.json
17
+ */
18
+
19
+ /**
20
+ * 尝试调后端的 creem 支付接口生成充值链接。
21
+ * New-API 的在线充值常见接口:
22
+ * POST /api/user/creem/pay { amount, ... }
23
+ * 不同版本字段不一,失败就回退到手动引导。
24
+ */
25
+ async function tryGetCreemLink(apiKey, baseUrl, amount) {
26
+ const apiBase = baseUrl.replace(/\/v1$/, '');
27
+ const candidates = [
28
+ {
29
+ url: `${apiBase}/api/user/creem/pay`,
30
+ body: { amount, currency: 'USD', gateway: 'creem' },
31
+ },
32
+ {
33
+ url: `${apiBase}/api/user/topup`,
34
+ body: { amount, top_up_code: '', payment_method: 'creem' },
35
+ },
36
+ ];
37
+
38
+ for (const c of candidates) {
39
+ try {
40
+ const resp = await fetch(c.url, {
41
+ method: 'POST',
42
+ headers: {
43
+ Authorization: `Bearer ${apiKey}`,
44
+ 'Content-Type': 'application/json',
45
+ },
46
+ body: JSON.stringify(c.body),
47
+ signal: AbortSignal.timeout(FETCH_TIMEOUT),
48
+ });
49
+ if (!resp.ok) continue;
50
+ const data = await resp.json().catch(() => null);
51
+ if (!data) continue;
52
+ // 多种可能的字段名兜底
53
+ const link =
54
+ data.data?.url ||
55
+ data.data?.payment_url ||
56
+ data.data?.checkout_url ||
57
+ data.url ||
58
+ data.payment_url;
59
+ if (link) return link;
60
+ } catch (e) {
61
+ // 超时单独提示一次(其余错误静默试下一个候选接口)
62
+ if (e?.name === 'TimeoutError' || e?.name === 'AbortError') {
63
+ console.log(' ⚠️ 连接超时,请检查网络');
64
+ }
65
+ }
66
+ }
67
+ return null;
68
+ }
69
+
70
+ export async function recharge(subArgs) {
71
+ // 1121 K哥令一步收银台: aixx recharge 10 --channel alipay → checkout-intent直接开单(零登录)
72
+ const _num = (subArgs || []).find(a => /^\d+(\.\d+)?$/.test(a));
73
+ const _ch = (subArgs || []).find(a => a.startsWith('--channel'));
74
+ if (_num) {
75
+ const apiKey = loadApiKey ? loadApiKey() : '';
76
+ try {
77
+ const r = await fetch('https://console.aixx.ai/cloudpay/checkout/intent', {
78
+ method: 'POST',
79
+ headers: { Authorization: `Bearer ${apiKey}`, 'Content-Type': 'application/json' },
80
+ body: JSON.stringify({ item: 'balance', amount_usd: parseFloat(_num), channel: (_ch ? _ch.split('=')[1] || 'alipay' : 'alipay') }),
81
+ signal: AbortSignal.timeout(20000),
82
+ });
83
+ const j = await r.json().catch(() => ({}));
84
+ if (r.ok && j.ok) {
85
+ console.log(`✅ 收银台已开(订单 ${j.order_no})`);
86
+ console.log(` 金额:$${Number(j.amount_usd).toFixed(2)} ≈ ¥${Number(j.amount_cny).toFixed(2)} · 通道 ${j.channel}`);
87
+ console.log(`
88
+ 💳 收银台链接(点开或发到手机打开):
89
+ ${j.pay_url}`);
90
+ console.log(`
91
+ 付款到账自动入余额——aixx balance 随时看。`);
92
+ return;
93
+ }
94
+ console.log(`(一步收银台开单失败: ${(j && (j.detail || j.message)) || 'HTTP ' + r.status}——回退传统方式)`);
95
+ } catch { console.log('(一步收银台网络异常——回退传统方式)'); }
96
+ }
97
+ console.log('╔══════════════════════════════════════════╗');
98
+ console.log('║ AIXX 充值 ║');
99
+ console.log('╚══════════════════════════════════════════╝\n');
100
+
101
+ const apiKey = loadApiKey();
102
+ const baseUrl = process.env.AIXX_BASE_URL || DEFAULT_BASE_URL;
103
+
104
+ // 从参数取金额,默认 $5(最低)
105
+ let amount = 5;
106
+ if (subArgs[0]) {
107
+ const n = Number(subArgs[0]);
108
+ if (!Number.isNaN(n) && n > 0) amount = n;
109
+ }
110
+
111
+ if (!apiKey) {
112
+ console.log('⚠️ 未检测到AIXX API Key,以下为通用充值方式:\n');
113
+ console.log('充值方式:');
114
+ console.log(' 信用卡 / ApplePay:登录 AIXX 后台 → 充值 → Creem');
115
+ console.log(' USDT 加密货币:联系客服或后台提交');
116
+ console.log(`\n 最低充值 $5`);
117
+ console.log(`\n🌐 后台地址:${baseUrl.replace(/\/v1$/, '')}`);
118
+ return;
119
+ }
120
+
121
+ console.log(`使用Key: ${maskKey(apiKey)}`);
122
+ console.log(`充值金额:$${amount}\n`);
123
+
124
+ // 尝试生成在线支付链接
125
+ console.log('🔄 正在生成在线充值链接...');
126
+ const link = await tryGetCreemLink(apiKey, baseUrl, amount);
127
+
128
+ console.log('\n────────────────────────────────────');
129
+ console.log('💳 充值方式:');
130
+ console.log('────────────────────────────────────');
131
+
132
+ if (link) {
133
+ console.log('\n ① 信用卡 / ApplePay(推荐,即时到账):');
134
+ console.log(` ${link}`);
135
+ console.log('\n 复制链接到浏览器打开即可支付。');
136
+ } else {
137
+ console.log('\n ① 信用卡 / ApplePay:');
138
+ console.log(' 自动生成链接失败,请直接登录后台充值:');
139
+ console.log(` ${baseUrl.replace(/\/v1$/, '')}/console/topup`);
140
+ }
141
+
142
+ console.log('\n ② USDT 加密货币:');
143
+ console.log(' 联系 AIXX 客服,或后台提交 USDT 充值订单');
144
+ console.log(' (后续会支持自动生成钱包地址)');
145
+
146
+ console.log('\n ③ 微信/支付宝:');
147
+ console.log(' 联系 AIXX 客服走人工充值');
148
+
149
+ console.log('\n────────────────────────────────────');
150
+ console.log(`最低充值 $5(约 ¥${(amount * 7).toFixed(0)})`);
151
+ console.log(`充值后额度即时到账,可直接使用。\n`);
152
+
153
+ console.log('💡 充值提示:');
154
+ console.log(' - 充 $5 用 glm-4-air 能聊 5 万次以上');
155
+ console.log(' - 充 $20 够用 Claude/GPT 跑一个月');
156
+ console.log(' - 推荐码注册的用户充值后推荐人有分润\n');
157
+ }
@@ -0,0 +1,72 @@
1
+ /**
2
+ * AIXX CLI - subscribe 命令(1121 K哥令:一步收银台·零登录·对话直达)
3
+ *
4
+ * aixx subscribe 1m → 数据API月档收银链接+二维码(支付宝默认)
5
+ * aixx subscribe 3m --channel wxpay
6
+ * aixx subscribe 12m --channel usdt(USDT需整数美元·测试期档价为1/2/3/4分)
7
+ *
8
+ * 凭证 = 本机 sk- 数据key(装机自带)——POST /cloudpay/checkout/intent
9
+ * 返回 pay_url + qr_url,打印给用户/agent:链接打开即真实收银台,付款自动升档。
10
+ * 金额/档位/收款地址全部服务端生成——agent拿不到也改不了。
11
+ */
12
+
13
+ import { loadApiKey } from '../utils/env.js';
14
+
15
+ const CHECKOUT = 'https://console.aixx.ai/cloudpay/checkout/intent';
16
+ const FETCH_TIMEOUT = 20000;
17
+
18
+ const PLANS = {
19
+ '1m': '1个月档', '3m': '3个月档', '6m': '6个月档', '12m': '12个月档',
20
+ };
21
+
22
+ export async function subscribe(subArgs) {
23
+ const rest = (subArgs || []).filter((a) => a && !a.startsWith('--'));
24
+ const plan = (rest[0] || '').toLowerCase();
25
+ const chArg = (subArgs || []).find((a) => a.startsWith('--channel'));
26
+ const channel = chArg ? chArg.split('=')[1] || subArgs[(subArgs.indexOf(chArg) + 1)] || '' : 'alipay';
27
+
28
+ if (!plan || !PLANS[plan]) {
29
+ console.log('用法: aixx subscribe <1m|3m|6m|12m> [--channel alipay|wxpay|usdt]\n');
30
+ console.log('示例:');
31
+ console.log(' aixx subscribe 1m 一个月档(支付宝扫码/打开)');
32
+ console.log(' aixx subscribe 12m --channel usdt 年档USDT付款');
33
+ console.log('\n订阅=行情数据API六域全开(80次免费额度之外的不限量档)。');
34
+ return;
35
+ }
36
+
37
+ const apiKey = loadApiKey();
38
+ if (!apiKey) {
39
+ console.error('❌ 未找到AIXX API Key——请先 npx aixxai install');
40
+ process.exit(1);
41
+ }
42
+
43
+ console.log(`🧾 正在开单:${PLANS[plan]} · 通道 ${channel}…\n`);
44
+ try {
45
+ const r = await fetch(CHECKOUT, {
46
+ method: 'POST',
47
+ headers: { Authorization: `Bearer ${apiKey}`, 'Content-Type': 'application/json' },
48
+ body: JSON.stringify({ item: `sub:${plan}`, channel }),
49
+ signal: AbortSignal.timeout(FETCH_TIMEOUT),
50
+ });
51
+ const j = await r.json().catch(() => ({}));
52
+ if (!r.ok || !j.ok) {
53
+ console.error(`❌ 开单失败: ${(j && (j.detail || j.message)) || 'HTTP ' + r.status}`);
54
+ if (j && j.detail && String(j.detail).includes('测试价')) {
55
+ console.error(' (订阅测试价当前仅限内部验证账号)');
56
+ }
57
+ process.exit(1);
58
+ }
59
+ console.log(`✅ 收银台已开(订单 ${j.order_no})`);
60
+ console.log(` 档位:${PLANS[plan]} 金额:$${Number(j.amount_usd).toFixed(2)} ≈ ¥${Number(j.amount_cny).toFixed(2)}`);
61
+ console.log(` 通道:${j.channel}`);
62
+ console.log(`\n💳 收银台链接(点开或发到手机打开):\n${j.pay_url}`);
63
+ if (j.qr_url && j.qr_url !== j.pay_url) {
64
+ console.log(`\n📱 二维码图片(可贴进对话):\n${j.qr_url}`);
65
+ }
66
+ console.log('\n付款到账后自动升级订阅档——aixx status 可随时看档位与到期日。');
67
+ } catch (err) {
68
+ console.error('❌ ' + (err?.name === 'TimeoutError' || err?.name === 'AbortError'
69
+ ? '连接超时,请检查网络' : err?.message || String(err)));
70
+ process.exit(1);
71
+ }
72
+ }