feat(qwen): add ai-qwen launcher for Alibaba Token Plan (Qwen3.8)

ai-qwen runs Claude Code through Alibaba Cloud Model Studio's
Anthropic-compatible Token Plan endpoint
(token-plan.ap-southeast-1.maas.aliyuncs.com/apps/anthropic). The shared
key is built into the generated script, so it starts right away without
asking for a key.

qwen3.8-max (the smartest model the key has) is in opus/sonnet and for
subagents, --model opus on each start; qwen3.8-flash is in haiku for
background tasks. Measured on 20.10: both models accept up to 983616
input tokens (CLAUDE_CODE_MAX_CONTEXT_TOKENS=1000000, autocompact fires
before the API limit) and see images. Qwen validates
output_config.effort (bogus -> 400), Max shows no trend from low to
max, Flash thinks ~2x longer on max; the launcher starts on --effort max
like ai-mimo, EFFORT_MAPPING.md records the measurements.

setup.sh status, statusline brand color, README, QUICK_START and
AGENTS.md list the new launcher.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Виталий Никитенко
2026-10-20 12:01:31 +07:00
parent 41c5cf9b10
commit 0502478081
8 changed files with 119 additions and 10 deletions

View File

@@ -20,6 +20,7 @@ GLM_SECTION=$(awk '/^cat > "\$BIN_DIR\/ai-glm"/,/^GLMEOF/' "$SCRIPT")
ELTEX_SECTION=$(awk '/^cat > "\$BIN_DIR\/ai-eltex"/,/^ELTEXEOF/' "$SCRIPT")
ELTEX_QWEN_SECTION=$(awk '/^cat > "\$BIN_DIR\/ai-eltex-qwen"/,/^ELTEXQWENEOF/' "$SCRIPT")
MIMO_SECTION=$(awk '/^cat > "\$BIN_DIR\/ai-mimo"/,/^MIMOEOF/' "$SCRIPT")
QWEN_SECTION=$(awk '/^cat > "\$BIN_DIR\/ai-qwen"/,/^QWENEOF/' "$SCRIPT")
LOGOUT_HOOK="$(cd "$(dirname "$0")/.." && pwd)/home-configs/claude/hooks/logout-account-hook.sh"
GEMINI_SECTION=$(awk '/^cat > "\$BIN_DIR\/ai-gemini"/,/^GEMINIEOF/' "$SCRIPT")
OPENCODE_SECTION=$(awk '/^cat > "\$BIN_DIR\/ai-opencode"/,/^OPENCODEEOF/' "$SCRIPT")
@@ -431,6 +432,43 @@ test_logout_mimo() {
rm -rf "$tmp_home"
}
# ── ai-qwen: Claude Code через Alibaba Token Plan, ключ вшит ───────────────
test_qwen_launcher() {
if echo "$QWEN_SECTION" | grep -q 'CLAUDE_CONFIG_DIR="$HOME/.config/ai-setup/cfg/qwen"' \
&& echo "$QWEN_SECTION" | grep -q '^ANTHROPIC_BASE_URL="$qwen_base_url"' \
&& echo "$QWEN_SECTION" | grep -q '^ANTHROPIC_DEFAULT_OPUS_MODEL=qwen3.8-max' \
&& echo "$QWEN_SECTION" | grep -q '^ANTHROPIC_DEFAULT_SONNET_MODEL=qwen3.8-max' \
&& echo "$QWEN_SECTION" | grep -q '^ANTHROPIC_DEFAULT_HAIKU_MODEL=qwen3.8-flash' \
&& echo "$QWEN_SECTION" | grep -q '^CLAUDE_CODE_SUBAGENT_MODEL=qwen3.8-max' \
&& echo "$QWEN_SECTION" | grep -q '^CLAUDE_CODE_MAX_CONTEXT_TOKENS=1000000' \
&& echo "$QWEN_SECTION" | grep -q -- 'claude --dangerously-skip-permissions --model opus --effort "${AI_EFFORT:-max}"'; then
ok "ai-qwen: own config, qwen3.8-max in opus/sonnet/subagents, flash in haiku, 1M window, effort max"
else
fail "ai-qwen: must use cfg/qwen, qwen3.8-max/flash slots, 1M window, --model opus and --effort max"
fi
}
# ── ai-qwen: стартует сразу со вшитым ключом, ничего не спрашивая ─────────
test_qwen_starts_without_prompt() {
local tmp url token ok_run=1
tmp=$(mktemp -d)
mkdir -p "$tmp/bin" "$tmp/mock" "$tmp/home"
echo "$HELPERS_SECTION" | HELPERS_FILE="$tmp/bin/ai-api-helpers.sh" bash
echo "$QWEN_SECTION" | BIN_DIR="$tmp/bin" bash
printf '#!/usr/bin/env bash\necho "$ANTHROPIC_BASE_URL $ANTHROPIC_AUTH_TOKEN" > "%s/claude.env"\n' "$tmp" > "$tmp/mock/claude"
chmod +x "$tmp/mock/claude"
(cd "$tmp" && HOME="$tmp/home" PATH="$tmp/mock:$PATH" AI_EFFORT= bash "$tmp/bin/ai-qwen" </dev/null >/dev/null 2>&1) || ok_run=0
read -r url token < "$tmp/claude.env" 2>/dev/null || ok_run=0
[ "${url:-}" = "https://token-plan.ap-southeast-1.maas.aliyuncs.com/apps/anthropic" ] || ok_run=0
case "${token:-}" in sk-sp-?*) ;; *) ok_run=0 ;; esac
if [ "$ok_run" -eq 1 ]; then
ok "ai-qwen: starts Claude Code with the built-in endpoint and key, no prompt"
else
fail "ai-qwen: must start Claude Code right away with the built-in Token Plan endpoint and sk-sp- key"
fi
rm -rf "$tmp"
}
# ── ai-glm: default effort is xhigh (still overridable via AI_EFFORT) ──────
test_glm_default_effort() {
if echo "$GLM_SECTION" | grep -q -- '--effort "${AI_EFFORT:-xhigh}"' \
@@ -656,6 +694,8 @@ test_mimo_launcher
test_mimo_region_probe
test_mimo_effort
test_logout_mimo
test_qwen_launcher
test_qwen_starts_without_prompt
test_gemini_native_launcher
test_cursor_native_launcher
test_global_rules_source_installed