Files
UmbraAudio/infra/remote_credential_broker/popup.py
B.D. Murphy 0c9bea72e0 Add enterprise/infra tooling and repoint Qwen3-TTS submodule to internal fork
Two groups of changes, committed together as the follow-up to the initial push:

1. .gitmodules — submodule Qwen3-TTS now points at the internal Gitea fork
   (ssh://git@mini-eq:2222/umbragit/Qwen3-TTS.git) instead of upstream GitHub,
   so a clone actually gets the UmbraAudio branding/integration commit
   012e452 rather than vanilla upstream.

2. New infra/ tooling for the cross-machine work in spec 21: agent_bridge,
   remote_credential_broker (Keychain-backed, secrets read at runtime and
   generated via read_secret/random_secret — no hardcoded credentials), the
   enterprise bootstrap scripts, and the oldbox SSH/auth prompts. Plus
   backup/ restore scripts, two specs (18 UmbraTrans, 19 enterprise control
   plane), umbraaudio/voices/lmstudio_gate.py, and in-flight edits to the
   discovery/attribution/profiling modules, config, chapter_builder, emotion,
   pronunciation, qwen_tts and routes.

Also adds *.db to .gitignore: SQLite project databases are runtime state and no
.db file was tracked before.

Verified before staging: .env's only change is UMBRA_TTS__QWEN_TTS_HELPER_URL and
the committed copy has zero secret-looking values; the broker ships only
config.example.json.
2026-10-06 06:57:41 -07:00

50 lines
1.7 KiB
Python

from __future__ import annotations
import subprocess
from typing import Protocol
class PromptCancelled(RuntimeError):
"""Raised when the user cancels a native credential prompt."""
class SecretPrompt(Protocol):
def __call__(self, profile: str, purpose: str) -> str | None:
"""Return a secret from a local UI, or None when cancelled."""
def _apple_string(value: str) -> str:
return '"' + value.replace("\\", "\\\\").replace('"', '\\"') + '"'
def macos_secret_prompt(profile: str, purpose: str) -> str | None:
"""Open a native macOS hidden-password dialog.
The returned value is intended to be passed directly to the Keychain
backend. It is never printed, logged, or included in an MCP result.
"""
message = f"Enter the password for {purpose} ({profile})."
script = (
f'display dialog {_apple_string(message)} '
'default answer "" with hidden answer buttons {"Cancel", "Save"} '
'default button "Save" with title "UmbraTrans secure credential"'
)
try:
result = subprocess.run(
["/usr/bin/osascript", "-e", script],
check=True,
capture_output=True,
text=True,
timeout=120,
)
except subprocess.CalledProcessError as exc:
detail = exc.stderr.strip().lower()
if "user canceled" in detail or "-128" in detail:
raise PromptCancelled("Credential entry was cancelled") from exc
raise RuntimeError("The macOS credential dialog could not be completed") from exc
except (OSError, subprocess.TimeoutExpired) as exc:
raise RuntimeError("The macOS credential dialog could not be opened") from exc
secret = result.stdout.rstrip("\r\n")
return secret or None