@wwkit/freetoken 1.0.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/LICENSE +21 -0
- package/README.md +96 -0
- package/cli/helpers/args.js +48 -0
- package/cli/index.js +374 -0
- package/cli/pid-manager.js +87 -0
- package/client/index.html +25 -0
- package/client/public/favicon.svg +1 -0
- package/client/public/icons.svg +24 -0
- package/client/src/App.vue +136 -0
- package/client/src/assets/vite.svg +1 -0
- package/client/src/assets/vue.svg +1 -0
- package/client/src/components/ChatBox.vue +320 -0
- package/client/src/components/CheckList.vue +52 -0
- package/client/src/components/CodeBlock.vue +99 -0
- package/client/src/components/DetailBlock.vue +47 -0
- package/client/src/components/HelloWorld.vue +95 -0
- package/client/src/components/LangSwitch.vue +32 -0
- package/client/src/components/LinkList.vue +32 -0
- package/client/src/components/OsSwitch.vue +42 -0
- package/client/src/components/OsToggle.vue +15 -0
- package/client/src/components/PageHeader.vue +31 -0
- package/client/src/components/StepList.vue +92 -0
- package/client/src/composables/useClipboard.js +26 -0
- package/client/src/composables/useOs.js +22 -0
- package/client/src/data/docs/agent.js +1002 -0
- package/client/src/data/docs/auth.js +631 -0
- package/client/src/data/docs/builtin-tools.js +322 -0
- package/client/src/data/docs/chat.js +181 -0
- package/client/src/data/docs/index.js +9 -0
- package/client/src/data/docs/skills.js +396 -0
- package/client/src/data/docs/spec-conversion.js +1042 -0
- package/client/src/data/freeModels/bluesliu.js +97 -0
- package/client/src/data/freeModels/index.js +11 -0
- package/client/src/data/freeModels/nvidia.js +126 -0
- package/client/src/data/freeModels/openrouter.js +116 -0
- package/client/src/data/harness/claude.js +89 -0
- package/client/src/data/harness/codex.js +66 -0
- package/client/src/data/harness/dsh.js +86 -0
- package/client/src/data/harness/hermes.js +56 -0
- package/client/src/data/harness/index.js +22 -0
- package/client/src/data/harness/opencode.js +77 -0
- package/client/src/data/proxy/api-relay.js +53 -0
- package/client/src/data/proxy/builtin-proxy.js +54 -0
- package/client/src/data/proxy/cf-workers.js +67 -0
- package/client/src/data/proxy/ecs-forward.js +75 -0
- package/client/src/data/proxy/ecs-reverse.js +89 -0
- package/client/src/data/proxy/index.js +15 -0
- package/client/src/docs/claudecode.md +44 -0
- package/client/src/docs/codex.md +90 -0
- package/client/src/docs/hermesagent.md +42 -0
- package/client/src/docs/opencode.md +103 -0
- package/client/src/locales/en.js +436 -0
- package/client/src/locales/index.js +31 -0
- package/client/src/locales/zh-CN.js +461 -0
- package/client/src/main.js +16 -0
- package/client/src/router/index.js +76 -0
- package/client/src/style.css +15 -0
- package/client/src/views/AdminModelsView.vue +214 -0
- package/client/src/views/DocsView.vue +1604 -0
- package/client/src/views/FreeModelsView.vue +518 -0
- package/client/src/views/HarnessView.vue +314 -0
- package/client/src/views/HomeView.vue +147 -0
- package/client/src/views/ProxyView.vue +112 -0
- package/client/src/views/TokenMarketView.vue +26 -0
- package/client/vite.config.js +41 -0
- package/package.json +85 -0
- package/scripts/build-zip.sh +61 -0
- package/scripts/postinstall.js +7 -0
- package/server/src/config/targets.json +1 -0
- package/server/src/index.js +52 -0
- package/server/src/lib/coding-test.js +215 -0
- package/server/src/lib/database.js +353 -0
- package/server/src/lib/run-test.js +15 -0
- package/server/src/lib/scheduler.js +21 -0
- package/server/src/lib/tester.js +310 -0
- package/server/src/routes/admin.js +48 -0
- package/server/src/routes/proxy.js +64 -0
- package/server/src/routes/speed.js +87 -0
- package/src/config.js +45 -0
- package/src/config.json5 +27 -0
- package/src/index.js +10 -0
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
// OpenCode 配置
|
|
2
|
+
export default {
|
|
3
|
+
id: 'opencode',
|
|
4
|
+
nameKey: 'harness.tools.opencode.name',
|
|
5
|
+
taglineKey: 'harness.tools.opencode.tagline',
|
|
6
|
+
descriptionKey: 'harness.tools.opencode.description',
|
|
7
|
+
badgeKey: 'harness.tools.opencode.badge',
|
|
8
|
+
|
|
9
|
+
// 环境依赖
|
|
10
|
+
requirements: {
|
|
11
|
+
node: '>=18.0.0',
|
|
12
|
+
envVars: ['BLUESLIU_API_KEY'],
|
|
13
|
+
},
|
|
14
|
+
|
|
15
|
+
// 启动方式
|
|
16
|
+
startup: {
|
|
17
|
+
command: 'opencode',
|
|
18
|
+
description: '启动 CLI 交互界面',
|
|
19
|
+
},
|
|
20
|
+
|
|
21
|
+
install: {
|
|
22
|
+
// curl 一键安装
|
|
23
|
+
curl: {
|
|
24
|
+
display: `# One-line install via curl
|
|
25
|
+
curl -fsSL https://opencode.ai/install.sh | bash
|
|
26
|
+
|
|
27
|
+
# Verify installation
|
|
28
|
+
opencode --version`,
|
|
29
|
+
copy: {
|
|
30
|
+
unix: 'curl -fsSL https://opencode.ai/install.sh | bash && opencode --version',
|
|
31
|
+
windows: 'curl -fsSL https://opencode.ai/install.sh | bash; opencode --version',
|
|
32
|
+
},
|
|
33
|
+
},
|
|
34
|
+
|
|
35
|
+
// npm 全局安装
|
|
36
|
+
npm: {
|
|
37
|
+
display: `# Install globally via npm
|
|
38
|
+
npm install -g opencode-ai
|
|
39
|
+
|
|
40
|
+
# Verify installation
|
|
41
|
+
opencode --version`,
|
|
42
|
+
pkg: 'opencode-ai',
|
|
43
|
+
verify: 'opencode --version',
|
|
44
|
+
},
|
|
45
|
+
},
|
|
46
|
+
|
|
47
|
+
// 配置示例
|
|
48
|
+
config: `{
|
|
49
|
+
"$schema": "https://opencode.ai/config.json",
|
|
50
|
+
"provider": {
|
|
51
|
+
"bluesliu": {
|
|
52
|
+
"npm": "@ai-sdk/openai-compatible",
|
|
53
|
+
"name": "BluesLiu",
|
|
54
|
+
"options": {
|
|
55
|
+
"baseURL": "http://7.237.94.74:32527/v1",
|
|
56
|
+
"apiKey": "{env: BLUES_LIU_API_KEY}"
|
|
57
|
+
},
|
|
58
|
+
"models": {
|
|
59
|
+
"maas-glm-5.1-zhipu": {
|
|
60
|
+
"name": "maas-glm-5.1-zhipu"
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
}`,
|
|
66
|
+
configFilename: '~/.config/opencode/opencode.json',
|
|
67
|
+
configFormat: 'json',
|
|
68
|
+
|
|
69
|
+
// 切换模型
|
|
70
|
+
modelSwitch: '修改配置文件中 provider.bluesliu.models 字段',
|
|
71
|
+
|
|
72
|
+
// 相关链接
|
|
73
|
+
links: [
|
|
74
|
+
{ labelKey: 'harness.tools.opencode.links.0', url: 'https://opencode.ai' },
|
|
75
|
+
{ labelKey: 'harness.tools.opencode.links.1', url: 'https://github.com/anomalyco/opencode' },
|
|
76
|
+
],
|
|
77
|
+
}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
export default {
|
|
2
|
+
id: 'api-relay',
|
|
3
|
+
name: 'API 中转服务',
|
|
4
|
+
tagline: '使用第三方中转平台转发请求',
|
|
5
|
+
description: '使用第三方 API 中转服务(如 API2D、OpenAI-SB 等),将请求转发到 OpenAI 或 Anthropic。中转平台提供国内可访问的 baseURL,使用方式与官方 API 完全一致,GPT 和 Claude 均可使用。',
|
|
6
|
+
badge: '中转',
|
|
7
|
+
|
|
8
|
+
steps: [
|
|
9
|
+
'注册中转服务平台账号',
|
|
10
|
+
'获取中转平台分配的 API Key(格式通常为 sk-xxx 或 sk-ant-xxx)',
|
|
11
|
+
'确认该平台支持的目标模型(GPT / Claude / 其他)',
|
|
12
|
+
'在 Harness 中将 baseURL 替换为中转平台地址,apiKey 替换为中转 Key',
|
|
13
|
+
'模型名称保持与官方一致(如 gpt-4o、claude-sonnet-4-20250514)',
|
|
14
|
+
],
|
|
15
|
+
|
|
16
|
+
config: `# ===== GPT Model Usage =====
|
|
17
|
+
|
|
18
|
+
# Environment variables
|
|
19
|
+
export OPENAI_API_KEY="key-assigned-by-relay-platform"
|
|
20
|
+
export OPENAI_BASE_URL="https://relay-platform-url/v1"
|
|
21
|
+
|
|
22
|
+
# ~/.config/opencode/opencode.json
|
|
23
|
+
{
|
|
24
|
+
"model": "gpt-4o",
|
|
25
|
+
"provider": "openai",
|
|
26
|
+
"apiKey": "{OPENAI_API_KEY}",
|
|
27
|
+
"baseURL": "https://relay-platform-url/v1"
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
# ===== Claude Model Usage =====
|
|
31
|
+
|
|
32
|
+
# Environment variables
|
|
33
|
+
export ANTHROPIC_API_KEY="key-assigned-by-relay-platform"
|
|
34
|
+
export ANTHROPIC_BASE_URL="https://relay-platform-url"
|
|
35
|
+
|
|
36
|
+
# ~/.config/opencode/opencode.json
|
|
37
|
+
{
|
|
38
|
+
"model": "claude-sonnet-4-20250514",
|
|
39
|
+
"provider": "anthropic",
|
|
40
|
+
"apiKey": "{ANTHROPIC_API_KEY}",
|
|
41
|
+
"baseURL": "https://relay-platform-url"
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
# Claude Code can also use this directly
|
|
45
|
+
export ANTHROPIC_BASE_URL="https://relay-platform-url"`,
|
|
46
|
+
|
|
47
|
+
tips: [
|
|
48
|
+
'中转服务可能存在数据安全风险,请选择可信平台',
|
|
49
|
+
'GPT 的 baseURL 末尾需带 /v1,Claude 的 baseURL 末尾不带 /v1',
|
|
50
|
+
'部分中转平台只支持 GPT 或只支持 Claude,注册前需确认',
|
|
51
|
+
'建议同时准备多个方案作为备选',
|
|
52
|
+
],
|
|
53
|
+
}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
export default {
|
|
2
|
+
id: 'builtin-proxy',
|
|
3
|
+
name: 'Harness 内置代理',
|
|
4
|
+
tagline: '通过环境变量或 baseURL 配置实现访问',
|
|
5
|
+
description: '在已有稳定代理通道(VPN / Clash / Shadowsocks 等)的前提下,通过设置 HTTP 代理环境变量,或直接在 Harness 配置中指定 baseURL,让 GPT 和 Claude 请求走代理通道。无需修改代码,配置即可生效。',
|
|
6
|
+
badge: '内置',
|
|
7
|
+
|
|
8
|
+
steps: [
|
|
9
|
+
'确保本地已有可用的代理通道(VPN / Clash / SS 等)',
|
|
10
|
+
'方式一:设置 HTTPS_PROXY 环境变量,所有 HTTP 请求走代理(需代理可达目标 API)',
|
|
11
|
+
'方式二:在 Harness 配置中直接指定官方 baseURL(代理通道负责网络可达)',
|
|
12
|
+
'GPT 和 Claude 使用相同的环境变量,无需区分配置',
|
|
13
|
+
'验证代理延迟和稳定性,确保不影响开发体验',
|
|
14
|
+
],
|
|
15
|
+
|
|
16
|
+
config: `# ===== Method 1: Environment Variable Proxy (Recommended) =====
|
|
17
|
+
# Applicable to all Harness tools (OpenCode / Codex / Claude Code)
|
|
18
|
+
|
|
19
|
+
export HTTPS_PROXY="http://127.0.0.1:7890"
|
|
20
|
+
export HTTP_PROXY="http://127.0.0.1:7890"
|
|
21
|
+
# Clash default port 7890, Shadowsocks local port usually 1080/1087
|
|
22
|
+
|
|
23
|
+
# After setting, use official API Key and address directly
|
|
24
|
+
export OPENAI_API_KEY="sk-your-key"
|
|
25
|
+
export ANTHROPIC_API_KEY="sk-ant-your-key"
|
|
26
|
+
|
|
27
|
+
# ===== Method 2: Specify baseURL in Harness config =====
|
|
28
|
+
|
|
29
|
+
# GPT — ~/.config/opencode/opencode.json
|
|
30
|
+
{
|
|
31
|
+
"model": "gpt-4o",
|
|
32
|
+
"provider": "openai",
|
|
33
|
+
"apiKey": "sk-your-key",
|
|
34
|
+
"baseURL": "https://api.openai.com/v1"
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
# Claude — ~/.config/opencode/opencode.json
|
|
38
|
+
{
|
|
39
|
+
"model": "claude-sonnet-4-20250514",
|
|
40
|
+
"provider": "anthropic",
|
|
41
|
+
"apiKey": "sk-ant-your-key",
|
|
42
|
+
"baseURL": "https://api.anthropic.com"
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
# Claude Code can also be configured via environment variable
|
|
46
|
+
export ANTHROPIC_BASE_URL="https://api.anthropic.com"`,
|
|
47
|
+
|
|
48
|
+
tips: [
|
|
49
|
+
'此方案需要已有代理通道,代理本身的稳定性决定体验',
|
|
50
|
+
'环境变量方式最通用,所有 Harness 工具均可生效',
|
|
51
|
+
'注意区分 HTTP 代理端口(通常 7890/1087)和 SOCKS5 端口(通常 1080)',
|
|
52
|
+
'设置 ALL_PROXY=socks5://127.0.0.1:1080 可让终端工具全部走 SOCKS5 代理',
|
|
53
|
+
],
|
|
54
|
+
}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
export default {
|
|
2
|
+
id: 'cf-workers',
|
|
3
|
+
name: 'Cloudflare Workers 自建中转',
|
|
4
|
+
tagline: '通过 CF Workers 搭建 API 转发服务',
|
|
5
|
+
description: '通过 Cloudflare Workers 搭建自己的 API 中转服务,稳定性高且不依赖第三方中转平台。需要一个域名和 Cloudflare 账号。GPT 和 Claude 需分别部署不同的 Worker(目标 host 不同),但机制完全相同。',
|
|
6
|
+
badge: 'CF',
|
|
7
|
+
|
|
8
|
+
steps: [
|
|
9
|
+
'注册 Cloudflare 账号,添加一个域名',
|
|
10
|
+
'创建两个 Worker:一个转发到 api.openai.com,一个转发到 api.anthropic.com',
|
|
11
|
+
'部署 Worker 脚本',
|
|
12
|
+
'配置自定义域名路由(如 openai.your-domain.com 和 claude.your-domain.com)',
|
|
13
|
+
'在 Harness 中将 baseURL 指向对应的 Worker 域名',
|
|
14
|
+
],
|
|
15
|
+
|
|
16
|
+
config: `# ===== Worker 1: GPT API Forwarding =====
|
|
17
|
+
# worker-openai.js
|
|
18
|
+
export default {
|
|
19
|
+
async fetch(request) {
|
|
20
|
+
const url = new URL(request.url);
|
|
21
|
+
url.host = 'api.openai.com';
|
|
22
|
+
return fetch(new Request(url, request));
|
|
23
|
+
}
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
# Route binding: openai.your-domain.com/* -> worker-openai
|
|
27
|
+
|
|
28
|
+
# ===== Worker 2: Claude API Forwarding =====
|
|
29
|
+
# worker-anthropic.js
|
|
30
|
+
export default {
|
|
31
|
+
async fetch(request) {
|
|
32
|
+
const url = new URL(request.url);
|
|
33
|
+
url.host = 'api.anthropic.com';
|
|
34
|
+
return fetch(new Request(url, request));
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
# Route binding: claude.your-domain.com/* -> worker-anthropic
|
|
39
|
+
|
|
40
|
+
# ===== Harness Side Configuration =====
|
|
41
|
+
|
|
42
|
+
# GPT — ~/.config/opencode/opencode.json
|
|
43
|
+
{
|
|
44
|
+
"model": "gpt-4o",
|
|
45
|
+
"provider": "openai",
|
|
46
|
+
"apiKey": "sk-your-key",
|
|
47
|
+
"baseURL": "https://openai.your-domain.com/v1"
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
# Claude — ~/.config/opencode/opencode.json
|
|
51
|
+
{
|
|
52
|
+
"model": "claude-sonnet-4-20250514",
|
|
53
|
+
"provider": "anthropic",
|
|
54
|
+
"apiKey": "sk-ant-your-key",
|
|
55
|
+
"baseURL": "https://claude.your-domain.com"
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
# Claude Code
|
|
59
|
+
export ANTHROPIC_BASE_URL="https://claude.your-domain.com"`,
|
|
60
|
+
|
|
61
|
+
tips: [
|
|
62
|
+
'此方案最安全可靠,自己掌控全部流量转发',
|
|
63
|
+
'需要一定的技术能力来部署和配置 Cloudflare',
|
|
64
|
+
'GPT 和 Claude 的 Worker 脚本几乎一样,仅 target host 不同',
|
|
65
|
+
'Cloudflare 免费额度每天 10 万次请求,个人使用足够',
|
|
66
|
+
],
|
|
67
|
+
}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
export default {
|
|
2
|
+
id: 'ecs-forward',
|
|
3
|
+
name: 'ECS 正向代理',
|
|
4
|
+
tagline: 'Shadowsocks 浏览器通用代理',
|
|
5
|
+
description: '在阿里云海外 ECS 上部署 Shadowsocks 服务端,本地通过 SS 客户端连接后,所有流量(浏览器、终端、APP)均经过 ECS 转发。此方案为「正向代理」,客户端主动将流量发往代理服务器,GPT 和 Claude 均可通过此方式访问。',
|
|
6
|
+
badge: '正向',
|
|
7
|
+
|
|
8
|
+
steps: [
|
|
9
|
+
'登录阿里云控制台,购买 ECS 实例(推荐香港/新加坡/美国地域,1 核 1G 即可)',
|
|
10
|
+
'选择 Ubuntu 22.04 或 Debian 12 系统镜像,记录公网 IP',
|
|
11
|
+
'在安全组规则中开放 TCP 端口 8388(Shadowsocks 默认端口)',
|
|
12
|
+
'SSH 登录 ECS,安装 Shadowsocks-libev',
|
|
13
|
+
'编辑配置文件 /etc/shadowsocks/config.json',
|
|
14
|
+
'启动 ss-server 服务并设置开机自启',
|
|
15
|
+
'在本地安装 Shadowsocks 客户端,填入 ECS 公网 IP、端口、密码和加密方式',
|
|
16
|
+
'开启系统代理或 PAC 模式,浏览器即可通过 ECS 访问外网',
|
|
17
|
+
],
|
|
18
|
+
|
|
19
|
+
config: `# ===== ECS Server Operations =====
|
|
20
|
+
|
|
21
|
+
# 1. Install Shadowsocks-libev
|
|
22
|
+
apt update && apt install -y shadowsocks-libev
|
|
23
|
+
|
|
24
|
+
# 2. Edit config file
|
|
25
|
+
# /etc/shadowsocks/config.json
|
|
26
|
+
{
|
|
27
|
+
"server": "0.0.0.0",
|
|
28
|
+
"server_port": 8388,
|
|
29
|
+
"password": "your-strong-password",
|
|
30
|
+
"timeout": 300,
|
|
31
|
+
"method": "aes-256-gcm",
|
|
32
|
+
"fast_open": true,
|
|
33
|
+
"mode": "tcp_and_udp"
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
# 3. Start and enable auto-start on boot
|
|
37
|
+
systemctl start shadowsocks-libev
|
|
38
|
+
systemctl enable shadowsocks-libev
|
|
39
|
+
systemctl status shadowsocks-libev
|
|
40
|
+
|
|
41
|
+
# 4. Verify port listening
|
|
42
|
+
ss -tlnp | grep 8388
|
|
43
|
+
|
|
44
|
+
# ===== Local Client Operations =====
|
|
45
|
+
|
|
46
|
+
# macOS / Windows: Download Shadowsocks client
|
|
47
|
+
# https://shadowsocks.org/guide/getting-started.html
|
|
48
|
+
#
|
|
49
|
+
# Client config:
|
|
50
|
+
# Server address: ECS public IP
|
|
51
|
+
# Port: 8388
|
|
52
|
+
# Password: your-strong-password
|
|
53
|
+
# Encryption: aes-256-gcm
|
|
54
|
+
#
|
|
55
|
+
# After enabling, set system SOCKS5 proxy to 127.0.0.1:1080
|
|
56
|
+
|
|
57
|
+
# ===== Terminal Tools Using This Proxy =====
|
|
58
|
+
|
|
59
|
+
# Set environment variables (for OpenCode / Codex / Claude Code)
|
|
60
|
+
export ALL_PROXY="socks5://127.0.0.1:1080"
|
|
61
|
+
export HTTP_PROXY="http://127.0.0.1:1087"
|
|
62
|
+
export HTTPS_PROXY="http://127.0.0.1:1087"
|
|
63
|
+
|
|
64
|
+
# All Harness tool requests will be forwarded through ECS
|
|
65
|
+
# No need to modify baseURL, just use official API address
|
|
66
|
+
export OPENAI_API_KEY="sk-your-key"
|
|
67
|
+
export ANTHROPIC_API_KEY="sk-ant-your-key"`,
|
|
68
|
+
|
|
69
|
+
tips: [
|
|
70
|
+
'正向代理适合全局翻墙,浏览器和终端都可使用',
|
|
71
|
+
'所有流量都经过 ECS 转发,带宽消耗较大',
|
|
72
|
+
'ECS 地域必须能访问目标 API(香港/新加坡/美西均可)',
|
|
73
|
+
'可在一台 ECS 上同时部署 Shadowsocks 和 Nginx 反向代理',
|
|
74
|
+
],
|
|
75
|
+
}
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
export default {
|
|
2
|
+
id: 'ecs-reverse',
|
|
3
|
+
name: 'ECS 反向代理',
|
|
4
|
+
tagline: 'Nginx 模型 API 专用代理',
|
|
5
|
+
description: '在阿里云海外 ECS 上部署 Nginx 反向代理,将 API 请求转发到 OpenAI / Anthropic。此方案为「反向代理」,客户端访问 ECS 地址,由 Nginx 转发到目标 API。仅代理模型 API 请求,更轻量低延迟,但不能作为浏览器代理。GPT 和 Claude 可在同一个 Nginx 中配置不同 location 路径。',
|
|
6
|
+
badge: '反向',
|
|
7
|
+
|
|
8
|
+
steps: [
|
|
9
|
+
'购买阿里云 ECS 实例(同样需要海外地域,以能访问 OpenAI/Anthropic 为准)',
|
|
10
|
+
'安装 Nginx',
|
|
11
|
+
'配置反向代理,分别转发 /openai/ → api.openai.com 和 /anthropic/ → api.anthropic.com',
|
|
12
|
+
'在阿里云安全组开放 80 和 443 端口',
|
|
13
|
+
'(可选)配置域名 + Let\'s Encrypt SSL 证书',
|
|
14
|
+
'在 Harness 工具中将 baseURL 指向 ECS 的代理地址',
|
|
15
|
+
],
|
|
16
|
+
|
|
17
|
+
config: `# ===== ECS Server Operations =====
|
|
18
|
+
|
|
19
|
+
# 1. Install Nginx
|
|
20
|
+
apt update && apt install -y nginx
|
|
21
|
+
|
|
22
|
+
# 2. Configure reverse proxy
|
|
23
|
+
# /etc/nginx/sites-available/ai-proxy
|
|
24
|
+
server {
|
|
25
|
+
listen 80;
|
|
26
|
+
server_name your-ecs-ip-or-domain;
|
|
27
|
+
|
|
28
|
+
# GPT API reverse proxy
|
|
29
|
+
location /openai/ {
|
|
30
|
+
proxy_pass https://api.openai.com/;
|
|
31
|
+
proxy_set_header Host api.openai.com;
|
|
32
|
+
proxy_set_header X-Real-IP $remote_addr;
|
|
33
|
+
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
|
34
|
+
proxy_ssl_server_name on;
|
|
35
|
+
proxy_ssl_name api.openai.com;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
# Claude API reverse proxy
|
|
39
|
+
location /anthropic/ {
|
|
40
|
+
proxy_pass https://api.anthropic.com/;
|
|
41
|
+
proxy_set_header Host api.anthropic.com;
|
|
42
|
+
proxy_set_header X-Real-IP $remote_addr;
|
|
43
|
+
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
|
44
|
+
proxy_ssl_server_name on;
|
|
45
|
+
proxy_ssl_name api.anthropic.com;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
# 3. Enable site and restart Nginx
|
|
50
|
+
ln -s /etc/nginx/sites-available/ai-proxy /etc/nginx/sites-enabled/
|
|
51
|
+
nginx -t && systemctl restart nginx
|
|
52
|
+
|
|
53
|
+
# ===== (Optional) Configure HTTPS =====
|
|
54
|
+
|
|
55
|
+
# Install Certbot
|
|
56
|
+
apt install -y certbot python3-certbot-nginx
|
|
57
|
+
|
|
58
|
+
# Apply for Let's Encrypt certificate (need to bind domain to ECS first)
|
|
59
|
+
certbot --nginx -d your-domain.com
|
|
60
|
+
|
|
61
|
+
# ===== Harness Side Configuration =====
|
|
62
|
+
|
|
63
|
+
# GPT — ~/.config/opencode/opencode.json
|
|
64
|
+
{
|
|
65
|
+
"model": "gpt-4o",
|
|
66
|
+
"provider": "openai",
|
|
67
|
+
"apiKey": "sk-your-key",
|
|
68
|
+
"baseURL": "http://your-ecs-ip/openai/v1"
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
# Claude — ~/.config/opencode/opencode.json
|
|
72
|
+
{
|
|
73
|
+
"model": "claude-sonnet-4-20250514",
|
|
74
|
+
"provider": "anthropic",
|
|
75
|
+
"apiKey": "sk-ant-your-key",
|
|
76
|
+
"baseURL": "http://your-ecs-ip/anthropic"
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
# Claude Code environment variable
|
|
80
|
+
export ANTHROPIC_BASE_URL="http://your-ecs-ip/anthropic"`,
|
|
81
|
+
|
|
82
|
+
tips: [
|
|
83
|
+
'反向代理仅代理 API 请求,更轻量低延迟,但不能作为浏览器代理',
|
|
84
|
+
'GPT 和 Claude 可共用一个 Nginx,通过不同 location 路径区分',
|
|
85
|
+
'建议配置 HTTPS 证书,避免 API Key 在传输中被截获',
|
|
86
|
+
'ECS 带宽选择 5Mbps 以上,模型 API 响应通常较大',
|
|
87
|
+
'注意阿里云按量付费的流量费用,海外 ECS 流量费略高',
|
|
88
|
+
],
|
|
89
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import apiRelay from './api-relay.js'
|
|
2
|
+
import builtinProxy from './builtin-proxy.js'
|
|
3
|
+
import cfWorkers from './cf-workers.js'
|
|
4
|
+
import ecsForward from './ecs-forward.js'
|
|
5
|
+
import ecsReverse from './ecs-reverse.js'
|
|
6
|
+
|
|
7
|
+
export const proxySolutions = [
|
|
8
|
+
apiRelay,
|
|
9
|
+
builtinProxy,
|
|
10
|
+
cfWorkers,
|
|
11
|
+
ecsForward,
|
|
12
|
+
ecsReverse,
|
|
13
|
+
]
|
|
14
|
+
|
|
15
|
+
export default proxySolutions
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
Claude Code
|
|
2
|
+
|
|
3
|
+
复制本文
|
|
4
|
+
|
|
5
|
+
在 Claude Code 中使用千问AI平台模型
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
安装 Claude Code
|
|
9
|
+
macOS/Linux
|
|
10
|
+
Windows
|
|
11
|
+
安装或更新 Node.js(v18.0 或更高版本)。
|
|
12
|
+
在终端中执行下列命令,安装 Claude Code。
|
|
13
|
+
npm install -g @anthropic-ai/claude-code
|
|
14
|
+
运行以下命令验证安装。若有版本号输出,则表示安装成功。
|
|
15
|
+
claude --version
|
|
16
|
+
|
|
17
|
+
在 Claude Code 中接入 Token Plan 个人版,需要配置以下信息:
|
|
18
|
+
ANTHROPIC_BASE_URL:设置为 https://token-plan.cn-beijing.maas.aliyuncs.com/apps/anthropic。
|
|
19
|
+
ANTHROPIC_AUTH_TOKEN:设置为 Token Plan 个人版专属 API Key。
|
|
20
|
+
ANTHROPIC_MODEL:设置为 Token Plan 个人版支持的模型。
|
|
21
|
+
|
|
22
|
+
创建并打开配置文件 ~/.claude/settings.json。
|
|
23
|
+
~ 代表当前系统账户的主目录。如果 .claude 目录不存在,需要先行创建。可在终端执行 mkdir -p ~/.claude 来创建。
|
|
24
|
+
nano ~/.claude/settings.json
|
|
25
|
+
|
|
26
|
+
编辑配置文件。将 YOUR_API_KEY 替换为 Token Plan 个人版专属 API Key。
|
|
27
|
+
{
|
|
28
|
+
"env": {
|
|
29
|
+
"ANTHROPIC_AUTH_TOKEN": "YOUR_API_KEY",
|
|
30
|
+
"ANTHROPIC_BASE_URL": "https://token-plan.cn-beijing.maas.aliyuncs.com/apps/anthropic",
|
|
31
|
+
"ANTHROPIC_MODEL": "qwen3.8-max",
|
|
32
|
+
"ANTHROPIC_DEFAULT_HAIKU_MODEL": "qwen3.6-flash",
|
|
33
|
+
"ANTHROPIC_DEFAULT_SONNET_MODEL": "qwen3.8-max",
|
|
34
|
+
"ANTHROPIC_DEFAULT_OPUS_MODEL": "qwen3.8-max",
|
|
35
|
+
"CLAUDE_CODE_SUBAGENT_MODEL": "qwen3.7-max",
|
|
36
|
+
"CLAUDE_CODE_MAX_CONTEXT_TOKENS": "983616"
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
保存配置文件,重新打开一个终端即可生效。
|
|
40
|
+
编辑或新增 ~/.claude.json 文件,将 hasCompletedOnboarding 字段的值设置为 true 并保存文件。
|
|
41
|
+
{
|
|
42
|
+
"hasCompletedOnboarding": true
|
|
43
|
+
}
|
|
44
|
+
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
参考文档 :千问AI平台 https://platform.qianwenai.com/docs/developer-guides/clients-and-developer-tools/codex
|
|
2
|
+
|
|
3
|
+
Codex
|
|
4
|
+
|
|
5
|
+
复制本文
|
|
6
|
+
|
|
7
|
+
在 Codex 中使用千问AI平台模型
|
|
8
|
+
|
|
9
|
+
Codex 是 OpenAI 推出的终端 AI 编程助手。可通过 Token Plan 个人版、Token Plan 团队版或按量计费接入千问AI平台。
|
|
10
|
+
|
|
11
|
+
安装 Codex
|
|
12
|
+
安装或更新 Node.js(v18.0 或更高版本)。
|
|
13
|
+
在终端中执行以下命令安装 Codex。
|
|
14
|
+
npm install -g @openai/codex
|
|
15
|
+
执行以下命令验证安装。
|
|
16
|
+
codex --version
|
|
17
|
+
|
|
18
|
+
配置接入凭证
|
|
19
|
+
接入需要编辑配置文件 ~/.codex/config.toml 并配置环境变量 OPENAI_API_KEY。根据所选计费方案替换对应值,千问AI平台提供以下计费方案:
|
|
20
|
+
|
|
21
|
+
配置模型元数据
|
|
22
|
+
使用自定义模型(如 qwen3.8-max)时,需要配置模型元数据文件,使 Codex 正确识别模型的上下文窗口、推理深度等参数。
|
|
23
|
+
新建文件 ~/.codex/model-catalog.local.json,写入以下内容:
|
|
24
|
+
{
|
|
25
|
+
"models": [
|
|
26
|
+
{
|
|
27
|
+
"slug": "qwen3.8-max",
|
|
28
|
+
"display_name": "qwen3.8-max",
|
|
29
|
+
"description": "DashScope model: qwen3.8-max",
|
|
30
|
+
"default_reasoning_level": "xhigh",
|
|
31
|
+
"supported_reasoning_levels": [
|
|
32
|
+
{
|
|
33
|
+
"effort": "low",
|
|
34
|
+
"description": "Fast responses with lighter reasoning"
|
|
35
|
+
},
|
|
36
|
+
{
|
|
37
|
+
"effort": "medium",
|
|
38
|
+
"description": "Greater reasoning depth for complex problems"
|
|
39
|
+
},
|
|
40
|
+
{
|
|
41
|
+
"effort": "xhigh",
|
|
42
|
+
"description": "Extra high reasoning depth for complex problems"
|
|
43
|
+
}
|
|
44
|
+
],
|
|
45
|
+
"context_window": 983616,
|
|
46
|
+
"effective_context_window_percent": 95,
|
|
47
|
+
"supports_parallel_tool_calls": false,
|
|
48
|
+
"supports_image_detail_original": true,
|
|
49
|
+
"input_modalities": ["text", "image"],
|
|
50
|
+
"shell_type": "default",
|
|
51
|
+
"visibility": "list",
|
|
52
|
+
"supported_in_api": true,
|
|
53
|
+
"priority": 1,
|
|
54
|
+
"base_instructions": "",
|
|
55
|
+
"support_verbosity": false,
|
|
56
|
+
"supports_reasoning_summaries": false,
|
|
57
|
+
"experimental_supported_tools": [],
|
|
58
|
+
"truncation_policy": {
|
|
59
|
+
"mode": "bytes",
|
|
60
|
+
"limit": 10000
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
]
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
在 ~/.codex/config.toml 中添加以下配置,指向元数据文件:
|
|
67
|
+
model_catalog_json = "~/.codex/model-catalog.local.json"
|
|
68
|
+
|
|
69
|
+
model_provider = "Model_Studio_Token_Plan_Personal"
|
|
70
|
+
model = "qwen3.8-max"
|
|
71
|
+
[model_providers.Model_Studio_Token_Plan_Personal]
|
|
72
|
+
name = "Model_Studio_Token_Plan_Personal"
|
|
73
|
+
base_url = "https://token-plan.cn-beijing.maas.aliyuncs.com/compatible-mode/v1"
|
|
74
|
+
env_key = "OPENAI_API_KEY"
|
|
75
|
+
wire_api = "responses"
|
|
76
|
+
|
|
77
|
+
将 OPENAI_API_KEY 环境变量设置为 Token Plan 个人版专属 API Key。
|
|
78
|
+
macOS
|
|
79
|
+
Windows
|
|
80
|
+
在终端中执行以下命令,查看默认 Shell 类型。
|
|
81
|
+
echo $SHELL
|
|
82
|
+
根据 Shell 类型设置环境变量:
|
|
83
|
+
zsh
|
|
84
|
+
bash
|
|
85
|
+
# 将 YOUR_API_KEY 替换为 Token Plan 个人版 API Key
|
|
86
|
+
echo 'export OPENAI_API_KEY="YOUR_API_KEY"' >> ~/.zshrc
|
|
87
|
+
在终端中执行下列命令,使环境变量生效。
|
|
88
|
+
zsh
|
|
89
|
+
bash
|
|
90
|
+
source ~/.zshrc
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
Hermes Agent
|
|
2
|
+
|
|
3
|
+
复制本文
|
|
4
|
+
|
|
5
|
+
在 Hermes Agent 中使用千问AI平台模型
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
安装 Hermes Agent
|
|
9
|
+
在终端中执行以下命令,安装脚本会自动安装 Python、Git 等依赖。
|
|
10
|
+
curl -fsSL https://raw.githubusercontent.com/NousResearch/hermes-agent/main/scripts/install.sh | bash
|
|
11
|
+
Windows 不支持原生安装,请先安装 WSL2,在 WSL2 中运行以上命令。
|
|
12
|
+
安装完成后,重新加载终端环境。
|
|
13
|
+
source ~/.bashrc # 如果使用 zsh,改为 source ~/.zshrc
|
|
14
|
+
验证安装是否成功。
|
|
15
|
+
hermes --version
|
|
16
|
+
|
|
17
|
+
配置接入凭证
|
|
18
|
+
通过 hermes config set 命令配置 Base URL 和 API Key,
|
|
19
|
+
|
|
20
|
+
将 YOUR_API_KEY 替换为 Token Plan 个人版专属 API Key。
|
|
21
|
+
hermes config set model.provider custom
|
|
22
|
+
hermes config set model.base_url https://token-plan.cn-beijing.maas.aliyuncs.com/apps/anthropic
|
|
23
|
+
hermes config set model.api_mode anthropic_messages
|
|
24
|
+
hermes config set model.api_key YOUR_API_KEY
|
|
25
|
+
hermes config set model.default qwen3.8-max
|
|
26
|
+
|
|
27
|
+
以上命令将配置写入 ~/.hermes/config.yaml。也可以直接编辑该文件,写入以下内容:
|
|
28
|
+
config.yaml 配置示例
|
|
29
|
+
|
|
30
|
+
model:
|
|
31
|
+
default: qwen3.8-max
|
|
32
|
+
provider: custom
|
|
33
|
+
base_url: https://token-plan.cn-beijing.maas.aliyuncs.com/apps/anthropic
|
|
34
|
+
api_mode: anthropic_messages
|
|
35
|
+
api_key: YOUR_API_KEY
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
切换模型
|
|
39
|
+
配置完成后,可以通过 -m 参数在对话时切换模型。
|
|
40
|
+
hermes chat -m qwen3.7-max
|
|
41
|
+
也可以通过 hermes config set 修改默认模型:
|
|
42
|
+
hermes config set model.default qwen3.7-max
|