Skip to content

JiuwenSwarm is an intelligent AI Agent built on openJiuwen. It extends the powerful capabilities of large language models directly to your fingertips through various communication apps you use daily.

Python
897 B
Raw Blame
# Copyright (c) Huawei Technologies Co., Ltd. 2026. All rights reserved.
"""Gateway Config Receiver 对外可访问 endpoint 解析。"""

from __future__ import annotations

from jiuwenswarm.common.security.link_mtls import LinkMTLSConfig

from .config import Settings, get_settings


def resolve_public_endpoint(cfg: Settings | None = None) -> str:
    """Manager 回调用的 Gateway Config Receiver Base URL(无尾斜杠)。

    由 ``GATEWAY_CONFIG_PUBLIC_SCHEME``、``GATEWAY_CONFIG_PUBLIC_HOST`` 和
    ``GATEWAY_CONFIG_HTTP_PORT`` 拼接;host 未配置时默认 ``127.0.0.1``。
    """
    cfg = cfg or get_settings()
    port = int(cfg.gateway_config_http_port or 8775)
    host = (cfg.gateway_config_public_host or "").strip() or "127.0.0.1"
    scheme = "https" if LinkMTLSConfig.from_env().enforced else cfg.gateway_config_public_scheme
    return f"{scheme}://{host}:{port}"