aixxai 1.6.6 → 1.6.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/README.md +52 -52
- package/bin/aixx.js +4 -0
- package/package.json +2 -3
- package/src/commands/aci.js +150 -0
- package/src/commands/config.js +68 -68
- package/src/commands/install.js +636 -636
- package/src/commands/models.js +120 -120
- package/src/commands/recharge.js +131 -131
- package/src/commands/servers.js +122 -0
- package/src/commands/test.js +91 -91
- package/templates/QUICKSTART.md +100 -100
- package/templates/SKILL.md +137 -137
- package/templates/references/account.md +85 -85
- package/templates/references/apps.md +201 -201
- package/templates/references/chat.md +138 -138
- package/templates/references/data.md +152 -152
- package/templates/references/notify.md +53 -53
- package/templates/references/search.md +96 -96
package/src/commands/test.js
CHANGED
|
@@ -1,91 +1,91 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* AIXX CLI - test 命令
|
|
3
|
-
* 测试AIXX是否可用
|
|
4
|
-
*/
|
|
5
|
-
|
|
6
|
-
import { DEFAULT_BASE_URL } from '../../bin/aixx.js';
|
|
7
|
-
import { loadApiKey, maskKey } from '../utils/env.js';
|
|
8
|
-
|
|
9
|
-
export async function test(subArgs) {
|
|
10
|
-
console.log('╔══════════════════════════════════════════╗');
|
|
11
|
-
console.log('║ AIXX 连通性测试 ║');
|
|
12
|
-
console.log('╚══════════════════════════════════════════╝\n');
|
|
13
|
-
|
|
14
|
-
// 统一配置链:环境变量 → ~/.aixx/config.json → ~/.aixx/account.json
|
|
15
|
-
const apiKey = loadApiKey();
|
|
16
|
-
const baseUrl = process.env.AIXX_BASE_URL || DEFAULT_BASE_URL;
|
|
17
|
-
|
|
18
|
-
if (!apiKey) {
|
|
19
|
-
console.error('❌ 未找到AIXX API Key');
|
|
20
|
-
console.error(' 运行 npx aixxai install 配置,或设置环境变量 AIXX_API_KEY');
|
|
21
|
-
process.exit(1);
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
console.log(`测试地址: ${baseUrl}`);
|
|
25
|
-
console.log(`使用Key: ${maskKey(apiKey)}\n`);
|
|
26
|
-
|
|
27
|
-
// 1. 测试模型列表(带key调 /v1/models,这才是真实的可用性验证)
|
|
28
|
-
let modelCount = 0;
|
|
29
|
-
console.log('1️⃣ 获取可用模型列表...');
|
|
30
|
-
try {
|
|
31
|
-
const resp = await fetch(`${baseUrl}/models`, {
|
|
32
|
-
headers: { 'Authorization': `Bearer ${apiKey}` }
|
|
33
|
-
});
|
|
34
|
-
if (resp.ok) {
|
|
35
|
-
const data = await resp.json();
|
|
36
|
-
const models = data.data || data.models || [];
|
|
37
|
-
modelCount = models.length;
|
|
38
|
-
console.log(` ✅ 可用模型 (${models.length}个):`);
|
|
39
|
-
models.slice(0, 10).forEach(m => {
|
|
40
|
-
const id = typeof m === 'string' ? m : m.id;
|
|
41
|
-
console.log(` • ${id}`);
|
|
42
|
-
});
|
|
43
|
-
if (models.length > 10) console.log(` ... 还有 ${models.length - 10} 个`);
|
|
44
|
-
} else if (resp.status === 401) {
|
|
45
|
-
console.error(' ❌ API Key 无效(401)');
|
|
46
|
-
process.exit(1);
|
|
47
|
-
} else if (resp.status === 404) {
|
|
48
|
-
console.error(` ❌ 接口404,检查 AIXX_BASE_URL 是否正确(当前: ${baseUrl})`);
|
|
49
|
-
process.exit(1);
|
|
50
|
-
} else {
|
|
51
|
-
console.error(` ❌ 返回 ${resp.status}`);
|
|
52
|
-
process.exit(1);
|
|
53
|
-
}
|
|
54
|
-
} catch (err) {
|
|
55
|
-
console.error(` ❌ 失败: ${err.message}`);
|
|
56
|
-
process.exit(1);
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
// 2. 测试实际调用
|
|
60
|
-
console.log('\n2️⃣ 测试调用 deepseek-chat...');
|
|
61
|
-
try {
|
|
62
|
-
const resp = await fetch(`${baseUrl}/chat/completions`, {
|
|
63
|
-
method: 'POST',
|
|
64
|
-
headers: {
|
|
65
|
-
'Authorization': `Bearer ${apiKey}`,
|
|
66
|
-
'Content-Type': 'application/json'
|
|
67
|
-
},
|
|
68
|
-
body: JSON.stringify({
|
|
69
|
-
model: 'deepseek-chat',
|
|
70
|
-
messages: [{ role: 'user', content: '说"测试成功"三个字' }],
|
|
71
|
-
max_tokens: 20
|
|
72
|
-
})
|
|
73
|
-
});
|
|
74
|
-
if (resp.ok) {
|
|
75
|
-
const data = await resp.json();
|
|
76
|
-
const reply = data.choices?.[0]?.message?.content || '(空回复)';
|
|
77
|
-
const usage = data.usage || {};
|
|
78
|
-
console.log(` ✅ 调用成功!`);
|
|
79
|
-
console.log(` 模型回复: ${reply}`);
|
|
80
|
-
console.log(` Token用量: ${usage.total_tokens || '?'}`);
|
|
81
|
-
} else {
|
|
82
|
-
const errData = await resp.json().catch(() => ({}));
|
|
83
|
-
console.error(` ❌ 调用失败 (${resp.status}): ${errData.error?.message || resp.statusText}`);
|
|
84
|
-
if (resp.status === 402) console.error(' 提示: 额度不足,请充值');
|
|
85
|
-
}
|
|
86
|
-
} catch (err) {
|
|
87
|
-
console.error(` ❌ 网络错误: ${err.message}`);
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
console.log('\n测试完成。\n');
|
|
91
|
-
}
|
|
1
|
+
/**
|
|
2
|
+
* AIXX CLI - test 命令
|
|
3
|
+
* 测试AIXX是否可用
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import { DEFAULT_BASE_URL } from '../../bin/aixx.js';
|
|
7
|
+
import { loadApiKey, maskKey } from '../utils/env.js';
|
|
8
|
+
|
|
9
|
+
export async function test(subArgs) {
|
|
10
|
+
console.log('╔══════════════════════════════════════════╗');
|
|
11
|
+
console.log('║ AIXX 连通性测试 ║');
|
|
12
|
+
console.log('╚══════════════════════════════════════════╝\n');
|
|
13
|
+
|
|
14
|
+
// 统一配置链:环境变量 → ~/.aixx/config.json → ~/.aixx/account.json
|
|
15
|
+
const apiKey = loadApiKey();
|
|
16
|
+
const baseUrl = process.env.AIXX_BASE_URL || DEFAULT_BASE_URL;
|
|
17
|
+
|
|
18
|
+
if (!apiKey) {
|
|
19
|
+
console.error('❌ 未找到AIXX API Key');
|
|
20
|
+
console.error(' 运行 npx aixxai install 配置,或设置环境变量 AIXX_API_KEY');
|
|
21
|
+
process.exit(1);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
console.log(`测试地址: ${baseUrl}`);
|
|
25
|
+
console.log(`使用Key: ${maskKey(apiKey)}\n`);
|
|
26
|
+
|
|
27
|
+
// 1. 测试模型列表(带key调 /v1/models,这才是真实的可用性验证)
|
|
28
|
+
let modelCount = 0;
|
|
29
|
+
console.log('1️⃣ 获取可用模型列表...');
|
|
30
|
+
try {
|
|
31
|
+
const resp = await fetch(`${baseUrl}/models`, {
|
|
32
|
+
headers: { 'Authorization': `Bearer ${apiKey}` }
|
|
33
|
+
});
|
|
34
|
+
if (resp.ok) {
|
|
35
|
+
const data = await resp.json();
|
|
36
|
+
const models = data.data || data.models || [];
|
|
37
|
+
modelCount = models.length;
|
|
38
|
+
console.log(` ✅ 可用模型 (${models.length}个):`);
|
|
39
|
+
models.slice(0, 10).forEach(m => {
|
|
40
|
+
const id = typeof m === 'string' ? m : m.id;
|
|
41
|
+
console.log(` • ${id}`);
|
|
42
|
+
});
|
|
43
|
+
if (models.length > 10) console.log(` ... 还有 ${models.length - 10} 个`);
|
|
44
|
+
} else if (resp.status === 401) {
|
|
45
|
+
console.error(' ❌ API Key 无效(401)');
|
|
46
|
+
process.exit(1);
|
|
47
|
+
} else if (resp.status === 404) {
|
|
48
|
+
console.error(` ❌ 接口404,检查 AIXX_BASE_URL 是否正确(当前: ${baseUrl})`);
|
|
49
|
+
process.exit(1);
|
|
50
|
+
} else {
|
|
51
|
+
console.error(` ❌ 返回 ${resp.status}`);
|
|
52
|
+
process.exit(1);
|
|
53
|
+
}
|
|
54
|
+
} catch (err) {
|
|
55
|
+
console.error(` ❌ 失败: ${err.message}`);
|
|
56
|
+
process.exit(1);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
// 2. 测试实际调用
|
|
60
|
+
console.log('\n2️⃣ 测试调用 deepseek-chat...');
|
|
61
|
+
try {
|
|
62
|
+
const resp = await fetch(`${baseUrl}/chat/completions`, {
|
|
63
|
+
method: 'POST',
|
|
64
|
+
headers: {
|
|
65
|
+
'Authorization': `Bearer ${apiKey}`,
|
|
66
|
+
'Content-Type': 'application/json'
|
|
67
|
+
},
|
|
68
|
+
body: JSON.stringify({
|
|
69
|
+
model: 'deepseek-chat',
|
|
70
|
+
messages: [{ role: 'user', content: '说"测试成功"三个字' }],
|
|
71
|
+
max_tokens: 20
|
|
72
|
+
})
|
|
73
|
+
});
|
|
74
|
+
if (resp.ok) {
|
|
75
|
+
const data = await resp.json();
|
|
76
|
+
const reply = data.choices?.[0]?.message?.content || '(空回复)';
|
|
77
|
+
const usage = data.usage || {};
|
|
78
|
+
console.log(` ✅ 调用成功!`);
|
|
79
|
+
console.log(` 模型回复: ${reply}`);
|
|
80
|
+
console.log(` Token用量: ${usage.total_tokens || '?'}`);
|
|
81
|
+
} else {
|
|
82
|
+
const errData = await resp.json().catch(() => ({}));
|
|
83
|
+
console.error(` ❌ 调用失败 (${resp.status}): ${errData.error?.message || resp.statusText}`);
|
|
84
|
+
if (resp.status === 402) console.error(' 提示: 额度不足,请充值');
|
|
85
|
+
}
|
|
86
|
+
} catch (err) {
|
|
87
|
+
console.error(` ❌ 网络错误: ${err.message}`);
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
console.log('\n测试完成。\n');
|
|
91
|
+
}
|
package/templates/QUICKSTART.md
CHANGED
|
@@ -1,100 +1,100 @@
|
|
|
1
|
-
# AIXX 快速开始
|
|
2
|
-
|
|
3
|
-
**一条命令装完即用,30秒开始让AI调用万物。**
|
|
4
|
-
|
|
5
|
-
---
|
|
6
|
-
|
|
7
|
-
## 安装(唯一需要做的一步)
|
|
8
|
-
|
|
9
|
-
```bash
|
|
10
|
-
npx aixxai install
|
|
11
|
-
```
|
|
12
|
-
|
|
13
|
-
装完自动完成:
|
|
14
|
-
1. **自动注册AIXX账号**(免费,送$0.5试用额度)并创建你的专属API Key
|
|
15
|
-
2. **自动写入本地配置**(~/.aixx/config.json)
|
|
16
|
-
3. **自动配置本地agent**(ZCode / Claude Code 检测到就自动配好,装完重启agent即可用)
|
|
17
|
-
4. **自动测试连通性**
|
|
18
|
-
|
|
19
|
-
带推荐码安装(推荐人获消费分润):`npx aixxai install zhangsan`
|
|
20
|
-
|
|
21
|
-
脚本/CI等非交互环境:`npx aixxai install --yes`
|
|
22
|
-
|
|
23
|
-
**不需要手动export任何环境变量。**
|
|
24
|
-
|
|
25
|
-
## 配置读取顺序(了解即可)
|
|
26
|
-
|
|
27
|
-
所有AIXX功能(CLI命令、skill)按这个顺序找key,装完即用:
|
|
28
|
-
1. 环境变量 `AIXX_API_KEY`
|
|
29
|
-
2. `~/.aixx/config.json`(install自动写入,兜底主力)
|
|
30
|
-
3. `~/.aixx/account.json`(install自动注册时保存)
|
|
31
|
-
|
|
32
|
-
忘了key在哪?运行 `npx aixxai config` 查看(key脱敏显示),或直接看 `~/.aixx/` 目录。
|
|
33
|
-
|
|
34
|
-
## 验证
|
|
35
|
-
|
|
36
|
-
装完后,让你的 agent 说一句:
|
|
37
|
-
> "帮我用 glm-4-flash 翻译:Hello World"
|
|
38
|
-
|
|
39
|
-
或运行 `npx aixxai test` 测连通性。
|
|
40
|
-
|
|
41
|
-
## 进阶:在代码里直接用(OpenAI兼容)
|
|
42
|
-
|
|
43
|
-
AIXX 兼容 OpenAI 接口。base_url 和 key 在 `~/.aixx/config.json` 里能找到:
|
|
44
|
-
|
|
45
|
-
```python
|
|
46
|
-
from openai import OpenAI
|
|
47
|
-
|
|
48
|
-
client = OpenAI(
|
|
49
|
-
api_key="sk-你的key",
|
|
50
|
-
base_url="https://console.aixx.ai/v1"
|
|
51
|
-
)
|
|
52
|
-
|
|
53
|
-
response = client.chat.completions.create(
|
|
54
|
-
model="glm-4-flash",
|
|
55
|
-
messages=[{"role": "user", "content": "你好"}]
|
|
56
|
-
)
|
|
57
|
-
print(response.choices[0].message.content)
|
|
58
|
-
```
|
|
59
|
-
|
|
60
|
-
```javascript
|
|
61
|
-
import OpenAI from "openai";
|
|
62
|
-
|
|
63
|
-
const client = new OpenAI({
|
|
64
|
-
apiKey: "sk-你的key",
|
|
65
|
-
baseURL: "https://console.aixx.ai/v1",
|
|
66
|
-
});
|
|
67
|
-
|
|
68
|
-
const response = await client.chat.completions.create({
|
|
69
|
-
model: "glm-4-flash",
|
|
70
|
-
messages: [{ role: "user", content: "你好" }],
|
|
71
|
-
});
|
|
72
|
-
console.log(response.choices[0].message.content);
|
|
73
|
-
```
|
|
74
|
-
|
|
75
|
-
> ⚠️ **安全提示**:当前后端用 HTTP 明文传输,存在凭据被嗅探风险,HTTPS 上线后请换用 https 地址。
|
|
76
|
-
|
|
77
|
-
## 常见问题
|
|
78
|
-
|
|
79
|
-
**Q: 报错 "Unauthorized"**
|
|
80
|
-
A: API Key 不对,重新运行 `npx aixxai install`,或检查 `~/.aixx/config.json` 里的key是否完整(含 `sk-` 前缀)。
|
|
81
|
-
|
|
82
|
-
**Q: 报错 "insufficient quota"**
|
|
83
|
-
A: 额度不足,运行 `npx aixxai recharge` 查看充值方式。
|
|
84
|
-
|
|
85
|
-
**Q: 报错 "model price not configured"**
|
|
86
|
-
A: 该模型未配置价格,联系管理员或换用 glm-4-flash。
|
|
87
|
-
|
|
88
|
-
**Q: Windows下环境变量没生效?**
|
|
89
|
-
A: 不影响使用——所有命令都会兜底读 `~/.aixx/config.json`。想配环境变量的话重开终端(setx写入的变量对新终端生效)。
|
|
90
|
-
|
|
91
|
-
## 下一步
|
|
92
|
-
|
|
93
|
-
- 查看 [`./SKILL.md`](./SKILL.md) 了解完整能力
|
|
94
|
-
- 查看 [`./references/chat.md`](./references/chat.md) 了解LLM调用细节
|
|
95
|
-
- 查看 [`./references/data.md`](./references/data.md) 查社媒/电商数据
|
|
96
|
-
- 查看 [`./references/apps.md`](./references/apps.md) 发通知/推送/邮件
|
|
97
|
-
- 查看 [`./references/account.md`](./references/account.md) 查询用量
|
|
98
|
-
|
|
99
|
-
---
|
|
100
|
-
维护者:龙龙(AIXX PM)| 2026-08-08 建立 | 2026-08-14 更新:装完即用,删手动export(任务书A)
|
|
1
|
+
# AIXX 快速开始
|
|
2
|
+
|
|
3
|
+
**一条命令装完即用,30秒开始让AI调用万物。**
|
|
4
|
+
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
## 安装(唯一需要做的一步)
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
npx aixxai install
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
装完自动完成:
|
|
14
|
+
1. **自动注册AIXX账号**(免费,送$0.5试用额度)并创建你的专属API Key
|
|
15
|
+
2. **自动写入本地配置**(~/.aixx/config.json)
|
|
16
|
+
3. **自动配置本地agent**(ZCode / Claude Code 检测到就自动配好,装完重启agent即可用)
|
|
17
|
+
4. **自动测试连通性**
|
|
18
|
+
|
|
19
|
+
带推荐码安装(推荐人获消费分润):`npx aixxai install zhangsan`
|
|
20
|
+
|
|
21
|
+
脚本/CI等非交互环境:`npx aixxai install --yes`
|
|
22
|
+
|
|
23
|
+
**不需要手动export任何环境变量。**
|
|
24
|
+
|
|
25
|
+
## 配置读取顺序(了解即可)
|
|
26
|
+
|
|
27
|
+
所有AIXX功能(CLI命令、skill)按这个顺序找key,装完即用:
|
|
28
|
+
1. 环境变量 `AIXX_API_KEY`
|
|
29
|
+
2. `~/.aixx/config.json`(install自动写入,兜底主力)
|
|
30
|
+
3. `~/.aixx/account.json`(install自动注册时保存)
|
|
31
|
+
|
|
32
|
+
忘了key在哪?运行 `npx aixxai config` 查看(key脱敏显示),或直接看 `~/.aixx/` 目录。
|
|
33
|
+
|
|
34
|
+
## 验证
|
|
35
|
+
|
|
36
|
+
装完后,让你的 agent 说一句:
|
|
37
|
+
> "帮我用 glm-4-flash 翻译:Hello World"
|
|
38
|
+
|
|
39
|
+
或运行 `npx aixxai test` 测连通性。
|
|
40
|
+
|
|
41
|
+
## 进阶:在代码里直接用(OpenAI兼容)
|
|
42
|
+
|
|
43
|
+
AIXX 兼容 OpenAI 接口。base_url 和 key 在 `~/.aixx/config.json` 里能找到:
|
|
44
|
+
|
|
45
|
+
```python
|
|
46
|
+
from openai import OpenAI
|
|
47
|
+
|
|
48
|
+
client = OpenAI(
|
|
49
|
+
api_key="sk-你的key",
|
|
50
|
+
base_url="https://console.aixx.ai/v1"
|
|
51
|
+
)
|
|
52
|
+
|
|
53
|
+
response = client.chat.completions.create(
|
|
54
|
+
model="glm-4-flash",
|
|
55
|
+
messages=[{"role": "user", "content": "你好"}]
|
|
56
|
+
)
|
|
57
|
+
print(response.choices[0].message.content)
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
```javascript
|
|
61
|
+
import OpenAI from "openai";
|
|
62
|
+
|
|
63
|
+
const client = new OpenAI({
|
|
64
|
+
apiKey: "sk-你的key",
|
|
65
|
+
baseURL: "https://console.aixx.ai/v1",
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
const response = await client.chat.completions.create({
|
|
69
|
+
model: "glm-4-flash",
|
|
70
|
+
messages: [{ role: "user", content: "你好" }],
|
|
71
|
+
});
|
|
72
|
+
console.log(response.choices[0].message.content);
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
> ⚠️ **安全提示**:当前后端用 HTTP 明文传输,存在凭据被嗅探风险,HTTPS 上线后请换用 https 地址。
|
|
76
|
+
|
|
77
|
+
## 常见问题
|
|
78
|
+
|
|
79
|
+
**Q: 报错 "Unauthorized"**
|
|
80
|
+
A: API Key 不对,重新运行 `npx aixxai install`,或检查 `~/.aixx/config.json` 里的key是否完整(含 `sk-` 前缀)。
|
|
81
|
+
|
|
82
|
+
**Q: 报错 "insufficient quota"**
|
|
83
|
+
A: 额度不足,运行 `npx aixxai recharge` 查看充值方式。
|
|
84
|
+
|
|
85
|
+
**Q: 报错 "model price not configured"**
|
|
86
|
+
A: 该模型未配置价格,联系管理员或换用 glm-4-flash。
|
|
87
|
+
|
|
88
|
+
**Q: Windows下环境变量没生效?**
|
|
89
|
+
A: 不影响使用——所有命令都会兜底读 `~/.aixx/config.json`。想配环境变量的话重开终端(setx写入的变量对新终端生效)。
|
|
90
|
+
|
|
91
|
+
## 下一步
|
|
92
|
+
|
|
93
|
+
- 查看 [`./SKILL.md`](./SKILL.md) 了解完整能力
|
|
94
|
+
- 查看 [`./references/chat.md`](./references/chat.md) 了解LLM调用细节
|
|
95
|
+
- 查看 [`./references/data.md`](./references/data.md) 查社媒/电商数据
|
|
96
|
+
- 查看 [`./references/apps.md`](./references/apps.md) 发通知/推送/邮件
|
|
97
|
+
- 查看 [`./references/account.md`](./references/account.md) 查询用量
|
|
98
|
+
|
|
99
|
+
---
|
|
100
|
+
维护者:龙龙(AIXX PM)| 2026-08-08 建立 | 2026-08-14 更新:装完即用,删手动export(任务书A)
|