Skip to content

The agent that grows with you

fix: ask before installing missing extras from an interactive terminal

ethernet5da731b39a8e
diff --git a/pm/extras.py b/pm/extras.py
index b7de900db11..6e2bcbbe77f 100644
--- a/pm/extras.py
+++ b/pm/extras.py
@@ -178,6 +178,22 @@ def ensure_import(extra: str) -> None:
f"extra {extra!r} is not supported on this platform "
f"(gate: {marker!r}); the adapter degrades without it",
)
+ import sys
+ from pm.package import InstallError
+
+ # prompt_toolkit already owns stdin during a CLI turn; never read from it.
+ app_running = False
+ if "prompt_toolkit.application.current" in sys.modules:
+ from prompt_toolkit.application.current import get_app_or_none
+
+ app_running = bool(getattr(get_app_or_none(), "is_running", False))
+ if not app_running and sys.stdin.isatty() and sys.stdout.isatty():
+ try:
+ answer = input(f"\nExtra {extra!r} requires: {', '.join(missing(extra))}\nInstall now? [Y/n] ").strip().lower()
+ except (EOFError, KeyboardInterrupt):
+ answer = "n"
+ if answer and answer not in {"y", "yes"}:
+ raise InstallError("venv", f"installation of extra {extra!r} declined")
from pm.client import sync_venv
sync_venv([extra])
@@ -191,7 +207,6 @@ def ensure_import(extra: str) -> None:
if runtime_facts_path().is_file():
selected = site_packages(selected_venv(repo_root())).resolve()
if selected not in {Path(entry).resolve() for entry in sys.path}:
- from pm.package import InstallError
raise InstallError("venv", f"{extra} installed; restart Hermes to activate the new dependency environment")
diff --git a/tests/pm/test_extras.py b/tests/pm/test_extras.py
index d02eb0f099a..1ae5bcea073 100644
--- a/tests/pm/test_extras.py
+++ b/tests/pm/test_extras.py
@@ -162,6 +162,20 @@ def test_ensure_import_syncs_when_missing(monkeypatch, synced, tmp_path):
assert synced == [["fal"]]
+def test_ensure_import_respects_terminal_decline_without_installing(monkeypatch, synced):
+ import builtins
+
+ monkeypatch.setattr(extras, "available", lambda _: False)
+ monkeypatch.setattr(sys, "stdin", SimpleNamespace(isatty=lambda: True))
+ monkeypatch.setattr(sys, "stdout", SimpleNamespace(isatty=lambda: True))
+ prompts = []
+ monkeypatch.setattr(builtins, "input", lambda text: prompts.append(text) or "n")
+ with pytest.raises(pm.InstallError, match="declined"):
+ extras.ensure_import("fal")
+ assert "fal" in prompts[0] and "fal_client" in prompts[0]
+ assert synced == []
+
+
def test_ensure_import_propagates_install_error(monkeypatch):
def boom(x=None):
raise pm.InstallError("venv", "lazy installs are disabled")
diff --git a/website/docs/user-guide/features/tts.md b/website/docs/user-guide/features/tts.md
index 625a2b815c4..55845659abf 100644
--- a/website/docs/user-guide/features/tts.md
+++ b/website/docs/user-guide/features/tts.md
@@ -113,6 +113,8 @@ tts:
# normalize_audio: true
```
+KittenTTS cannot be installed in the managed Python 3.14 environment: its `misaki` dependency requires Python <3.13. The `kittentts` extra is gated off there; selecting the provider without installing it will report it unavailable. Use another provider until its dependencies support the managed interpreter.
+
MiniMax TTS selects its region, endpoint, and credential together:
- `region: "global"` uses `https://api.minimax.io/v1/t2a_v2` with `MINIMAX_API_KEY`.