Resolve OpenSpace API base URL (for CLI scripts). Priority: ``cli_override`` → env var → host agent config → default.
(cli_override: Optional[str] = None)
| 61 | |
| 62 | |
| 63 | def get_api_base(cli_override: Optional[str] = None) -> str: |
| 64 | """Resolve OpenSpace API base URL (for CLI scripts). |
| 65 | |
| 66 | Priority: ``cli_override`` → env var → host agent config → default. |
| 67 | """ |
| 68 | from openspace.host_detection import read_host_mcp_env |
| 69 | |
| 70 | if cli_override: |
| 71 | return cli_override.rstrip("/") |
| 72 | env_base = os.environ.get("OPENSPACE_API_BASE", "").strip() |
| 73 | if env_base: |
| 74 | return env_base.rstrip("/") |
| 75 | mcp_env = read_host_mcp_env() |
| 76 | cfg_base = str(mcp_env.get("OPENSPACE_API_BASE", "")).strip() |
| 77 | if cfg_base: |
| 78 | return cfg_base.rstrip("/") |
| 79 | return OPENSPACE_DEFAULT_BASE |
| 80 | |
| 81 | |
| 82 | def get_auth_headers_or_exit() -> Dict[str, str]: |
no test coverage detected