fix(update): migrate config in non-interactive updates

This commit is contained in:
Steven Chou 2026-05-03 21:10:42 +08:00 committed by Teknium
parent 84287b0de8
commit 9442a8fa22
2 changed files with 25 additions and 17 deletions

View file

@ -7404,11 +7404,8 @@ def _cmd_update_impl(args, gateway_mode: bool):
.lower()
)
elif not (sys.stdin.isatty() and sys.stdout.isatty()):
print(" Non-interactive session — skipping config migration prompt.")
print(
" Run 'hermes config migrate' later to apply any new config/env options."
)
response = "n"
print(" Non-interactive session — applying safe config migrations.")
response = "auto"
else:
try:
response = (
@ -7419,19 +7416,22 @@ def _cmd_update_impl(args, gateway_mode: bool):
except EOFError:
response = "n"
if response in ("", "y", "yes"):
if response in ("", "y", "yes", "auto"):
print()
# In gateway mode OR under --yes, run auto-migrations only (no
# input() prompts for API keys which would hang the detached
# process / defeat the point of --yes).
results = migrate_config(
interactive=not (gateway_mode or assume_yes), quiet=False
# Gateway mode, --yes, and non-interactive update contexts
# (dashboard / web server actions) cannot prompt for API keys.
# Still run the non-interactive migration pass before restarting
# so new default config fields and version bumps are written
# before the freshly updated gateway validates config at startup.
interactive_migration = not (
gateway_mode or assume_yes or response == "auto"
)
results = migrate_config(interactive=interactive_migration, quiet=False)
if results["env_added"] or results["config_added"]:
print()
print("✓ Configuration updated!")
if (gateway_mode or assume_yes) and missing_env:
if (gateway_mode or assume_yes or response == "auto") and missing_env:
print(" API keys require manual entry: hermes config migrate")
else:
print()