ai-mimo runs Claude Code through Xiaomi's Anthropic-compatible API (Token Plan or pay-as-you-go). The key's endpoint is found by probing token-plan-sgp, token-plan-ams and api.xiaomimimo.com (a key only works in its own region) and is saved to mimo_base_url; MIMO_BASE_URL overrides. Unreachable endpoints are skipped, token-plan-cn is left out of the probe since it times out from our network, and a 402 on the pay-as-you-go endpoint explains that a tp- Token Plan key is needed. Always the smartest model: mimo-v2.6-pro in every slot and for subagents, --model opus and --effort max on each start, 128000 output tokens (Claude Code's ceiling), real 1M context window. Measured on 13.10: MiMo ignores output_config.effort (even "bogus" is accepted, no length trend from low to max) and treats thinking adaptive like enabled, so reasoning is always on; EFFORT_MAPPING.md records this. /logout-mimo is registered as a command and handled by the logout hook (removes mimo_key and mimo_base_url). 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>
76 lines
3.3 KiB
Bash
Executable File
76 lines
3.3 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
# Copyright (c) 2026 Виталий Никитенко. MIT License.
|
|
# UserPromptSubmit hook: перехватывает /logout, /logout-glm, /logout-eltex, /logout-eltex-qwen, /logout-mimo, /logout-deepseek, /logout-kimi.
|
|
# Удаляет сохранённый API-ключ провайдера, чтобы при следующем запуске лаунчер
|
|
# запросил новый.
|
|
# /logout-glm | /logout-eltex | /logout-eltex-qwen | /logout-mimo | /logout-deepseek | /logout-kimi — явно указанный провайдер.
|
|
# /logout (без суффикса) — провайдер по AI_LAUNCHER (glm/eltex/eltex-qwen/mimo/deepseek/kimi).
|
|
# Для ai-claude и прочих лаунчеров /logout отступает (exit 0) — пусть работает
|
|
# нативный oauth-logout. exit 2 после удаления: LLM не нужна, и нативная
|
|
# /logout не пытается сделать бессмысленный oauth-logout для api-key провайдеров.
|
|
|
|
input=$(cat)
|
|
prompt=$(echo "$input" | jq -r '.user_prompt // .prompt // empty' 2>/dev/null)
|
|
normalized=$(echo "$prompt" | sed 's|^[[:space:]]*/||; s|[[:space:]]*$||')
|
|
cmd=$(echo "$normalized" | awk '{print $1}')
|
|
|
|
target=""
|
|
case "$cmd" in
|
|
logout-glm) target=glm ;;
|
|
logout-eltex) target=eltex ;;
|
|
logout-eltex-qwen) target=eltex-qwen ;;
|
|
logout-mimo) target=mimo ;;
|
|
logout-deepseek) target=deepseek ;;
|
|
logout-kimi) target=kimi ;;
|
|
logout)
|
|
case "${AI_LAUNCHER:-claude}" in
|
|
glm|eltex|eltex-qwen|mimo|deepseek|kimi) target="$AI_LAUNCHER" ;;
|
|
*) exit 0 ;;
|
|
esac
|
|
;;
|
|
*) exit 0 ;;
|
|
esac
|
|
|
|
CFG="$HOME/.config/ai-setup"
|
|
|
|
case "$target" in
|
|
glm)
|
|
rm -f "$CFG/glm_key"
|
|
echo "✓ GLM ключ удалён. Перезапусти ai-glm, чтобы ввести новый." >&2
|
|
;;
|
|
eltex)
|
|
rm -f "$CFG/eltex_key"
|
|
echo "✓ Eltex ключ удалён. Перезапусти ai-eltex, чтобы ввести новый." >&2
|
|
;;
|
|
eltex-qwen)
|
|
rm -f "$CFG/eltex_qwen_key"
|
|
echo "✓ Eltex Qwen ключ удалён. Перезапусти ai-eltex-qwen, чтобы ввести новый." >&2
|
|
;;
|
|
mimo)
|
|
rm -f "$CFG/mimo_key" "$CFG/mimo_base_url"
|
|
echo "✓ MiMo ключ удалён. Перезапусти ai-mimo, чтобы ввести новый." >&2
|
|
;;
|
|
deepseek)
|
|
rm -f "$CFG/deepseek_key"
|
|
echo "✓ DeepSeek ключ удалён. Перезапусти ai-deepseek, чтобы ввести новый." >&2
|
|
;;
|
|
kimi)
|
|
KEYS_DIR="$CFG/kimi_keys"
|
|
current=$(cat "$KEYS_DIR/current" 2>/dev/null || true)
|
|
if [ -n "$current" ]; then
|
|
rm -f "$KEYS_DIR/${current}.key" "$KEYS_DIR/${current}.meta"
|
|
fi
|
|
# Пересчёт current: переключаемся на первый оставшийся ключ либо сбрасываем.
|
|
mapfile -t keys < <(ls "$KEYS_DIR"/*.key 2>/dev/null | xargs -I{} basename {} .key | sort)
|
|
if [ "${#keys[@]}" -gt 0 ]; then
|
|
echo "${keys[0]}" > "$KEYS_DIR/current"
|
|
echo "✓ Kimi ключ (${current:-нет}) удалён. Активен: ${keys[0]}. Перезапусти ai-kimi." >&2
|
|
else
|
|
rm -f "$KEYS_DIR/current"
|
|
echo "✓ Kimi ключ (${current:-нет}) удалён. Других ключей нет. Перезапусти ai-kimi." >&2
|
|
fi
|
|
;;
|
|
esac
|
|
|
|
exit 2
|