feat: prompt for paid copilot model selection

This commit is contained in:
Matt Bruce 2026-02-19 13:00:26 -06:00
parent 558bbf47f6
commit a6e4823188
4 changed files with 95 additions and 2 deletions

View File

@ -100,7 +100,8 @@ bash ./scripts/finalize_copilot_setup.sh
What finalize does: What finalize does:
- Opens `copilot auth login` if needed - Opens `copilot auth login` if needed
- Refreshes model catalog - Refreshes model catalog
- Auto-picks paid/free profiles from available Copilot models - Prompts you to choose the paid profile model from non-free candidates
- Auto-picks the free profile model/fallbacks from low-cost candidates
- Installs all guardrails - Installs all guardrails
- Enables recommended hooks - Enables recommended hooks
- Restarts gateway - Restarts gateway
@ -115,6 +116,12 @@ openclaw status --deep
If login is missing/expired, finalize will prompt for login and retry setup. If login is missing/expired, finalize will prompt for login and retry setup.
For unattended/non-interactive automation:
```bash
PROMPT_FOR_PAID_MODEL=false bash ./scripts/finalize_copilot_setup.sh
```
### How To Choose Copilot Models (and Why It Matters) ### How To Choose Copilot Models (and Why It Matters)
Choosing the right primary and fallback models is important because it controls: Choosing the right primary and fallback models is important because it controls:

View File

@ -22,6 +22,7 @@ Run in this order:
1) bash ./setup/setup_openclaw_copilot.sh 1) bash ./setup/setup_openclaw_copilot.sh
2) bash ./scripts/finalize_copilot_setup.sh 2) bash ./scripts/finalize_copilot_setup.sh
- if prompted, pause and wait for user to complete browser login - if prompted, pause and wait for user to complete browser login
- if prompted for paid model, show model list to user and ask user to choose
3) openclaw status --deep 3) openclaw status --deep
After setup, verify and report: After setup, verify and report:

View File

@ -46,6 +46,7 @@ bash ./scripts/finalize_copilot_setup.sh
Expected: Expected:
- Authenticated with enterprise-linked account - Authenticated with enterprise-linked account
- Copilot models discovered - Copilot models discovered
- If prompted, paid profile model selected from non-free candidates
- Guardrails installed + running - Guardrails installed + running
- Hooks enabled (`boot-md`, `command-logger`, `session-memory`) - Hooks enabled (`boot-md`, `command-logger`, `session-memory`)
- Gateway restarted - Gateway restarted
@ -141,12 +142,18 @@ openclaw models status
If step 3 already succeeded, this is already done. If step 3 already succeeded, this is already done.
This one command auto-detects your available Copilot models, picks low-cost defaults, applies policy, and installs launchd guards: This one command auto-detects your available Copilot models, asks for paid model selection (interactive), picks low-cost free defaults, applies policy, and installs launchd guards:
```bash ```bash
bash ./scripts/install_copilot_guardrails.sh bash ./scripts/install_copilot_guardrails.sh
``` ```
For unattended/non-interactive automation:
```bash
PROMPT_FOR_PAID_MODEL=false bash ./scripts/install_copilot_guardrails.sh
```
3. Verify: 3. Verify:
```bash ```bash

View File

@ -59,6 +59,52 @@ is_cheap_model() {
[[ "$m" =~ (haiku|mini|flash|fast|nano|small|lite|economy) ]] [[ "$m" =~ (haiku|mini|flash|fast|nano|small|lite|economy) ]]
} }
prompt_for_paid_model() {
local default_model="$1"
shift
local -a candidates=("$@")
if [[ ${#candidates[@]} -eq 0 ]]; then
echo "$default_model"
return 0
fi
echo "" >&2
echo "[configure-guardrails] Choose paid profile primary model (non-free candidates):" >&2
for i in "${!candidates[@]}"; do
local n=$((i + 1))
local marker=""
if [[ "${candidates[$i]}" == "$default_model" ]]; then
marker=" (default)"
fi
printf " %d) %s%s\n" "$n" "${candidates[$i]}" "$marker" >&2
done
printf "Select number [default=%s]: " "$default_model" >&2
local choice=""
if ! IFS= read -r choice; then
echo "" >&2
echo "$default_model"
return 0
fi
if [[ -z "$choice" ]]; then
echo "$default_model"
return 0
fi
if [[ "$choice" =~ ^[0-9]+$ ]]; then
local idx=$((choice - 1))
if (( idx >= 0 && idx < ${#candidates[@]} )); then
echo "${candidates[$idx]}"
return 0
fi
fi
echo "[configure-guardrails] Invalid selection '$choice'; using default: $default_model" >&2
echo "$default_model"
}
copilot_models=() copilot_models=()
while IFS= read -r model; do while IFS= read -r model; do
[[ -z "$model" ]] && continue [[ -z "$model" ]] && continue
@ -83,6 +129,33 @@ MSG
exit 1 exit 1
fi fi
prompt_mode="${PROMPT_FOR_PAID_MODEL:-auto}"
interactive_picker="false"
case "$prompt_mode" in
auto)
if [[ -t 0 && -t 1 ]]; then
interactive_picker="true"
fi
;;
true|yes|1)
interactive_picker="true"
;;
false|no|0)
interactive_picker="false"
;;
*)
echo "[configure-guardrails] Invalid PROMPT_FOR_PAID_MODEL='$prompt_mode' (expected auto/true/false). Using auto." >&2
if [[ -t 0 && -t 1 ]]; then
interactive_picker="true"
fi
;;
esac
if [[ "$interactive_picker" == "true" && ( ! -t 0 || ! -t 1 ) ]]; then
echo "[configure-guardrails] PROMPT_FOR_PAID_MODEL enabled but no interactive TTY; falling back to auto selection." >&2
interactive_picker="false"
fi
primary_model="" primary_model=""
for m in "${copilot_models[@]}"; do for m in "${copilot_models[@]}"; do
if is_cheap_model "$m"; then if is_cheap_model "$m"; then
@ -150,6 +223,11 @@ if [[ -z "$paid_model" ]]; then
paid_model="$primary_model" paid_model="$primary_model"
fi fi
if [[ "$interactive_picker" == "true" && ${#high_models[@]} -gt 0 ]]; then
paid_model="$(prompt_for_paid_model "$paid_model" "${high_models[@]}")"
echo "[configure-guardrails] selected paid model: $paid_model"
fi
# free profile = lowest-cost primary + lowest-cost fallbacks # free profile = lowest-cost primary + lowest-cost fallbacks
declare -a free_fallbacks=("${cheap_candidates[@]}") declare -a free_fallbacks=("${cheap_candidates[@]}")