feat(eltex): add ai-eltex-qwen, effort max by default; fix model pick and /logout-eltex

ai-eltex-qwen: new launcher for the Eltex proxy on Qwen models
(Coder-Senior, then Flash-Next), own key eltex_qwen_key, config dir and
/logout-eltex-qwen hook branch, 200K window.

Effort: ai-glm and ai-eltex start on max via CLI --effort (AI_EFFORT
overrides), CLAUDE_CODE_MAX_OUTPUT_TOKENS=64000 so long GLM answers are
not cut at 32000. EFFORT_MAPPING notes the proxy passes effort for
anth-glm-5.3 since 09.10.

ai-eltex model pick: no longer falls back to the first /v1/models entry,
which twice picked something unusable (zai-glm-5.3 routed to flash, and
the access-group name ZAI-Test-Group -> 400). Without anth-glm-5.3 the
launcher exits with a clear message; ELTEX_MODEL still overrides.

/logout-eltex: Claude Code answered "Unknown command" and never called
the logout hook (the built-in /logout bypasses hooks too). ai-eltex now
registers commands/logout-eltex.md in its config dir, so the hook
receives the command and deletes eltex_key (checked end to end).

ru-bypass: resolve exception hosts via ahostsv4 first.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Виталий Никитенко
2026-10-12 11:52:45 +07:00
parent e3a1c500fd
commit 6c507b4549
9 changed files with 298 additions and 46 deletions

View File

@@ -18,6 +18,7 @@ GPT_SECTION=$(awk '/^cat > "\$BIN_DIR\/ai-gpt"/,/^GPTEOF/' "$SCRIPT")
KIMI_SECTION=$(awk '/^cat > "\$BIN_DIR\/ai-kimi"/,/^KIMIEOF/' "$SCRIPT")
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")
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")
@@ -123,12 +124,13 @@ test_eltex_claude_launcher() {
test_eltex_model_from_key() {
if echo "$ELTEX_SECTION" | grep -q '/v1/models' \
&& echo "$ELTEX_SECTION" | grep -q 'model="${ELTEX_MODEL:-}"' \
&& echo "$ELTEX_SECTION" | grep -q '"anth-glm-5.3" if "anth-glm-5.3" in ids' \
&& echo "$ELTEX_SECTION" | grep -q '\*" anth-glm-5.3 "\*) model="anth-glm-5.3"' \
&& ! echo "$ELTEX_SECTION" | grep -q 'ids\[0\]' \
&& echo "$ELTEX_SECTION" | grep -q 'ANTHROPIC_DEFAULT_OPUS_MODEL="$model"' \
&& echo "$ELTEX_SECTION" | grep -q 'ANTHROPIC_DEFAULT_HAIKU_MODEL="$model"'; then
ok "ai-eltex: prefers anth-glm-5.3 from the key's /v1/models (ELTEX_MODEL overrides)"
ok "ai-eltex: uses anth-glm-5.3, never the first /v1/models entry (ELTEX_MODEL overrides)"
else
fail "ai-eltex: must prefer anth-glm-5.3 from /v1/models, ELTEX_MODEL overrides"
fail "ai-eltex: must use anth-glm-5.3 (not the first /v1/models entry), ELTEX_MODEL overrides"
fi
}
@@ -152,6 +154,67 @@ test_eltex_context_window() {
fi
}
# ── ai-eltex-qwen: свой ключ и конфиг, модели Qwen, окно 200K ─────────────
test_eltex_qwen_launcher() {
if echo "$ELTEX_QWEN_SECTION" | grep -q 'claude --dangerously-skip-permissions' \
&& echo "$ELTEX_QWEN_SECTION" | grep -q 'key_file="$HOME/.config/ai-setup/eltex_qwen_key"' \
&& echo "$ELTEX_QWEN_SECTION" | grep -q 'CLAUDE_CONFIG_DIR="$HOME/.config/ai-setup/cfg/eltex-qwen"' \
&& echo "$ELTEX_QWEN_SECTION" | grep -q 'model="${ELTEX_QWEN_MODEL:-}"' \
&& echo "$ELTEX_QWEN_SECTION" | grep -q '("Eltex-Coder-Senior", "Eltex-Qwen3_8-Flash-Next")' \
&& echo "$ELTEX_QWEN_SECTION" | grep -q 'api_key="${AI_ELTEX_LLM_API_KEY:-}"' \
&& echo "$ELTEX_QWEN_SECTION" | grep -q '^CLAUDE_CODE_DISABLE_1M_CONTEXT=1'; then
ok "ai-eltex-qwen: own key/config, Coder-Senior then Flash-Next, 200K window"
else
fail "ai-eltex-qwen: must use eltex_qwen_key, cfg/eltex-qwen, Qwen model preference and DISABLE_1M"
fi
}
test_logout_eltex_qwen() {
local tmp_home rc=0
tmp_home=$(mktemp -d)
mkdir -p "$tmp_home/.config/ai-setup"
echo "sk-test" > "$tmp_home/.config/ai-setup/eltex_qwen_key"
echo "sk-glm" > "$tmp_home/.config/ai-setup/eltex_key"
echo '{"prompt":"/logout"}' | HOME="$tmp_home" AI_LAUNCHER=eltex-qwen bash "$LOGOUT_HOOK" 2>/dev/null || rc=$?
if [ "$rc" -eq 2 ] && [ ! -f "$tmp_home/.config/ai-setup/eltex_qwen_key" ] && [ -f "$tmp_home/.config/ai-setup/eltex_key" ]; then
ok "logout hook: /logout in ai-eltex-qwen removes only eltex_qwen_key"
else
fail "logout hook: /logout in ai-eltex-qwen must remove eltex_qwen_key and keep eltex_key (rc=$rc)"
fi
rm -rf "$tmp_home"
}
# ── ai-eltex / ai-eltex-qwen: effort max по умолчанию через CLI, вывод 64000 ────
test_eltex_effort() {
if echo "$ELTEX_SECTION" | grep -q -- '--effort "${AI_EFFORT:-max}"' \
&& echo "$ELTEX_SECTION" | grep -q '^CLAUDE_CODE_ALWAYS_ENABLE_EFFORT=1' \
&& echo "$ELTEX_SECTION" | grep -q '^CLAUDE_CODE_MAX_OUTPUT_TOKENS=64000' \
&& ! echo "$ELTEX_SECTION" | grep -q '^_apply_effort'; then
ok "ai-eltex: starts with --effort max by default, AI_EFFORT via CLI, 64000 output tokens"
else
fail "ai-eltex: must start with --effort \"\${AI_EFFORT:-max}\", CLAUDE_CODE_ALWAYS_ENABLE_EFFORT=1, MAX_OUTPUT_TOKENS=64000, no _apply_effort"
fi
}
test_eltex_qwen_effort() {
if echo "$ELTEX_QWEN_SECTION" | grep -q -- '--effort "${AI_EFFORT:-max}"' \
&& echo "$ELTEX_QWEN_SECTION" | grep -q '^CLAUDE_CODE_MAX_OUTPUT_TOKENS=64000' \
&& ! echo "$ELTEX_QWEN_SECTION" | grep -q '^_apply_effort'; then
ok "ai-eltex-qwen: starts with --effort max by default, 64000 output tokens"
else
fail "ai-eltex-qwen: must start with --effort \"\${AI_EFFORT:-max}\" and MAX_OUTPUT_TOKENS=64000, no _apply_effort"
fi
}
# ── ai-eltex: команда /logout-eltex зарегистрирована (иначе Unknown command, хук не зовётся) ──
test_eltex_logout_command() {
if echo "$ELTEX_SECTION" | grep -q 'cat > "$CLAUDE_CONFIG_DIR/commands/logout-eltex.md"'; then
ok "ai-eltex: registers /logout-eltex command so the logout hook receives it"
else
fail "ai-eltex: must create \$CLAUDE_CONFIG_DIR/commands/logout-eltex.md"
fi
}
# ── logout hook: /logout-eltex удаляет eltex_key ──────────────────────────
test_logout_eltex() {
local tmp_home rc=0
@@ -167,13 +230,14 @@ test_logout_eltex() {
rm -rf "$tmp_home"
}
# ── ai-glm: default effort is xhigh (still overridable via AI_EFFORT) ─────
# ── ai-glm: default effort is max (still overridable via AI_EFFORT) ───────
test_glm_default_effort() {
if echo "$GLM_SECTION" | grep -q -- '--effort "${AI_EFFORT:-xhigh}"' \
if echo "$GLM_SECTION" | grep -q -- '--effort "${AI_EFFORT:-max}"' \
&& echo "$GLM_SECTION" | grep -q '^CLAUDE_CODE_MAX_OUTPUT_TOKENS=64000' \
&& echo "$GLM_SECTION" | grep -q 'CLAUDE_CODE_ALWAYS_ENABLE_EFFORT=1'; then
ok "ai-glm: starts with --effort xhigh by default, effort sent to Z.ai"
ok "ai-glm: starts with --effort max by default, effort sent to Z.ai, 64000 output tokens"
else
fail "ai-glm: must start with --effort \"\${AI_EFFORT:-xhigh}\" and CLAUDE_CODE_ALWAYS_ENABLE_EFFORT=1"
fail "ai-glm: must start with --effort \"\${AI_EFFORT:-max}\", CLAUDE_CODE_ALWAYS_ENABLE_EFFORT=1 and MAX_OUTPUT_TOKENS=64000"
fi
}
@@ -379,7 +443,12 @@ test_eltex_claude_launcher
test_eltex_model_from_key
test_eltex_no_tool_search
test_eltex_context_window
test_eltex_logout_command
test_eltex_effort
test_eltex_qwen_effort
test_logout_eltex
test_eltex_qwen_launcher
test_logout_eltex_qwen
test_gemini_native_launcher
test_cursor_native_launcher
test_global_rules_source_installed