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

refactor: 用 JIUWENSWARM_EDITION 替代 USER_WEB_MODE 作为企业/个人版唯一开关

jiangchenglin8c18999f2af5
diff --git a/deploy/enterprise/.env.example b/deploy/enterprise/.env.example
index 692437565c..eda06a3d65 100644
--- a/deploy/enterprise/.env.example
+++ b/deploy/enterprise/.env.example
@@ -467,9 +467,9 @@ MANAGER_WEB_IMAGE=""
# 控制是否启动Manager 前端模块
IS_UP_MANAGER_WEB=false
-# 用户面产品形态:personal 或 enterprise;两种模式均通过 User Web NodePort 独立提供。
+# 产品形态:personal 或 enterprise。两种模式均通过 User Web NodePort 独立提供。
# personal:跳过企业登录;enterprise:启用企业登录及用户/组织/组网/Agent 面板。
-USER_WEB_MODE=personal
+JIUWENSWARM_EDITION=enterprise
# 是否模拟企业登录认证。默认 true,使用内置调试身份和三元组,不访问客户身份服务。
# false:正式身份认证模式,依赖客户侧 manager ID 认证服务。
@@ -485,7 +485,8 @@ LOGIN_AUTH_SIMULATE_AVAILABLE=true
USER_WEB_IDP_TARGET=""
USER_WEB_MANAGER_TARGET=""
-# 已废弃,仅兼容旧配置;新部署请使用 USER_WEB_MODE
+# 已废弃,仅兼容旧配置;新部署请使用 JIUWENSWARM_EDITION
+# USER_WEB_MODE=personal
# ENABLE_USER_WEB_EMBEDDING=false
# Manager 前端模块对外暴露的主机端口
diff --git a/deploy/enterprise/args_handler.sh b/deploy/enterprise/args_handler.sh
index e11adf9997..7112b0d74a 100755
--- a/deploy/enterprise/args_handler.sh
+++ b/deploy/enterprise/args_handler.sh
@@ -51,7 +51,12 @@ parse_args() {
}
process_modules() {
- MODULES=("GATEWAY" "WEB" "RUNTIME")
+ # personal 默认不带 Manager;enterprise 需要 Manager 作为统一入口
+ if [[ "${DEPLOY_VARS["JIUWENSWARM_EDITION"]:-enterprise}" == "enterprise" ]]; then
+ MODULES=("GATEWAY" "WEB" "MANAGER" "RUNTIME")
+ else
+ MODULES=("GATEWAY" "WEB" "RUNTIME")
+ fi
}
# Print help info and exit
diff --git a/deploy/enterprise/check_handler.sh b/deploy/enterprise/check_handler.sh
index 9654213232..9da02dd66e 100755
--- a/deploy/enterprise/check_handler.sh
+++ b/deploy/enterprise/check_handler.sh
@@ -17,21 +17,21 @@ check_boolean_value() {
fi
}
-check_user_web_mode_config() {
- local mode="${DEPLOY_VARS["USER_WEB_MODE"]:-personal}"
- if [[ "${mode}" != "personal" && "${mode}" != "enterprise" ]]; then
- error "USER_WEB_MODE must be personal or enterprise, current value: ${mode}"
+check_jiuwenswarm_edition_config() {
+ local edition="${DEPLOY_VARS["JIUWENSWARM_EDITION"]:-enterprise}"
+ if [[ "${edition}" != "personal" && "${edition}" != "enterprise" ]]; then
+ error "JIUWENSWARM_EDITION must be personal or enterprise, current value: ${edition}"
fi
check_boolean_value "IS_UP_MANAGER_WEB"
check_boolean_value "LOGIN_AUTH_SIMULATE"
check_boolean_value "LOGIN_AUTH_SIMULATE_AVAILABLE"
- if [[ "${mode}" == "enterprise" && "${DEPLOY_VARS["LOGIN_AUTH_SIMULATE"]}" == "true" && "${DEPLOY_VARS["LOGIN_AUTH_SIMULATE_AVAILABLE"]}" == "false" ]]; then
+ if [[ "${edition}" == "enterprise" && "${DEPLOY_VARS["LOGIN_AUTH_SIMULATE"]}" == "true" && "${DEPLOY_VARS["LOGIN_AUTH_SIMULATE_AVAILABLE"]}" == "false" ]]; then
error "配置冲突:LOGIN_AUTH_SIMULATE=true,但当前客户交付制品未包含登录认证模拟插件;请设置 LOGIN_AUTH_SIMULATE=false"
fi
- if [[ "${mode}" == "personal" && "${DEPLOY_VARS["LOGIN_AUTH_SIMULATE"]}" == "false" ]]; then
- warning "配置冲突:USER_WEB_MODE=personal 始终跳过企业登录;LOGIN_AUTH_SIMULATE=false 不会启用正式身份认证"
+ if [[ "${edition}" == "personal" && "${DEPLOY_VARS["LOGIN_AUTH_SIMULATE"]}" == "false" ]]; then
+ warning "配置冲突:JIUWENSWARM_EDITION=personal 始终跳过企业登录;LOGIN_AUTH_SIMULATE=false 不会启用正式身份认证"
fi
- if [[ "${mode}" == "enterprise" && "${DEPLOY_VARS["LOGIN_AUTH_SIMULATE"]}" == "false" ]]; then
+ if [[ "${edition}" == "enterprise" && "${DEPLOY_VARS["LOGIN_AUTH_SIMULATE"]}" == "false" ]]; then
if [[ -z "${DEPLOY_VARS["USER_WEB_IDP_TARGET"]:-}" ]]; then
error "正式身份认证模式缺少 USER_WEB_IDP_TARGET"
fi
@@ -41,6 +41,10 @@ check_user_web_mode_config() {
fi
}
+check_user_web_mode_config() {
+ check_jiuwenswarm_edition_config
+}
+
module_is_selected() {
local expected="$1"
local module=""
@@ -510,7 +514,7 @@ check_gateway_up_dependency(){
}
check_web_up_dependency(){
- check_user_web_mode_config
+ check_jiuwenswarm_edition_config
check_if_db_up
check_if_obs_up
@@ -520,7 +524,7 @@ check_web_up_dependency(){
}
check_manager_up_dependency(){
- check_user_web_mode_config
+ check_jiuwenswarm_edition_config
#check_if_rabbitmq_up
check_if_db_up
}
diff --git a/deploy/enterprise/deploy.sh b/deploy/enterprise/deploy.sh
index 9da9d38486..3a26f36d0e 100755
--- a/deploy/enterprise/deploy.sh
+++ b/deploy/enterprise/deploy.sh
@@ -93,17 +93,21 @@ process_restart() {
main() {
read_env_from_file "${CUSTOM_ENV_FILE}" "DEPLOY_VARS"
- # USER_WEB_MODE 是用户面产品形态的唯一开关;旧布尔变量仅作兼容输入。
- if [[ -z "${DEPLOY_VARS["USER_WEB_MODE"]:-}" ]]; then
- if [[ "${DEPLOY_VARS["ENABLE_USER_WEB_EMBEDDING"]:-false}" == "true" ]]; then
- DEPLOY_VARS["USER_WEB_MODE"]="enterprise"
- warning "ENABLE_USER_WEB_EMBEDDING is deprecated; use USER_WEB_MODE=enterprise"
+ # JIUWENSWARM_EDITION 是产品形态的唯一开关;USER_WEB_MODE / ENABLE_USER_WEB_EMBEDDING 仅作兼容输入。
+ if [[ -z "${DEPLOY_VARS["JIUWENSWARM_EDITION"]:-}" ]]; then
+ if [[ -n "${DEPLOY_VARS["USER_WEB_MODE"]:-}" ]]; then
+ DEPLOY_VARS["JIUWENSWARM_EDITION"]="${DEPLOY_VARS["USER_WEB_MODE"]}"
+ warning "USER_WEB_MODE is deprecated; use JIUWENSWARM_EDITION=${DEPLOY_VARS["JIUWENSWARM_EDITION"]}"
+ elif [[ "${DEPLOY_VARS["ENABLE_USER_WEB_EMBEDDING"]:-false}" == "true" ]]; then
+ DEPLOY_VARS["JIUWENSWARM_EDITION"]="enterprise"
+ warning "ENABLE_USER_WEB_EMBEDDING is deprecated; use JIUWENSWARM_EDITION=enterprise"
else
- DEPLOY_VARS["USER_WEB_MODE"]="personal"
+ DEPLOY_VARS["JIUWENSWARM_EDITION"]="enterprise"
fi
fi
+ DEPLOY_VARS["USER_WEB_MODE"]="${DEPLOY_VARS["JIUWENSWARM_EDITION"]}"
DEPLOY_VARS["ENABLE_USER_WEB_EMBEDDING"]=$(
- [[ "${DEPLOY_VARS["USER_WEB_MODE"]}" == "enterprise" ]] && printf true || printf false
+ [[ "${DEPLOY_VARS["JIUWENSWARM_EDITION"]}" == "enterprise" ]] && printf true || printf false
)
if [[ -z "${DEPLOY_VARS["LOGIN_AUTH_SIMULATE"]:-}" ]]; then
DEPLOY_VARS["LOGIN_AUTH_SIMULATE"]="true"
@@ -118,7 +122,7 @@ main() {
DEPLOY_VARS["USER_WEB_MANAGER_TARGET"]="http://${DEPLOY_VARS["MANAGER_SERVER_NAME"]}:${DEPLOY_VARS["MANAGER_REST_PORT"]}"
user_web_manager_defaulted="true"
fi
- if [[ "${DEPLOY_VARS["USER_WEB_MODE"]}" == "enterprise" ]]; then
+ if [[ "${DEPLOY_VARS["JIUWENSWARM_EDITION"]}" == "enterprise" ]]; then
if [[ "${DEPLOY_VARS["LOGIN_AUTH_SIMULATE"]}" == "true" ]]; then
info "【登录认证模拟调试模式已开启】"
elif [[ "${DEPLOY_VARS["LOGIN_AUTH_SIMULATE"]}" == "false" ]]; then
diff --git a/deploy/enterprise/global_vars.sh b/deploy/enterprise/global_vars.sh
index 3d97335463..c7973da366 100755
--- a/deploy/enterprise/global_vars.sh
+++ b/deploy/enterprise/global_vars.sh
@@ -119,6 +119,7 @@ declare -A DEPLOY_VARS=(
["ENABLE_EXTERNAL_PVC"]="false"
["ENABLE_EXTERNAL_RABBITMQ"]="false"
["ENABLE_EXTERNAL_REDIS"]="false"
+ ["JIUWENSWARM_EDITION"]="enterprise"
["USER_WEB_MODE"]=""
["LOGIN_AUTH_SIMULATE"]="true"
["LOGIN_AUTH_SIMULATE_AVAILABLE"]="true"
diff --git a/deploy/enterprise/templates/.env.custom.template b/deploy/enterprise/templates/.env.custom.template
index be75a370f9..3bcf981245 100644
--- a/deploy/enterprise/templates/.env.custom.template
+++ b/deploy/enterprise/templates/.env.custom.template
@@ -17,17 +17,13 @@ IDENTITY_IMAGE="<<IDENTITY_IMAGE>>"
JIUWENBOX_IMAGE="<<JIUWENBOX_IMAGE>>"
JIUWENSWARM_EDITION="enterprise"
-# Gateway 产品形态:personal | enterprise(影响存储选型:文件/DB、内存/Redis)
-JIUWENSWARM_EDITION="enterprise"
+# Gateway / User Web 产品形态:personal | enterprise
GATEWAY_SESSION_MAP_SCOPE="per_chat_bot_user"
JIUWENBOX_ENABLED=true
-# 是否启动 Manager Web;USER_WEB_MODE=enterprise 时必须为 true
+# 是否启动 Manager Web;JIUWENSWARM_EDITION=enterprise 时 up 会默认带上 manager
IS_UP_MANAGER_WEB=true
-# 用户面产品形态:personal(独立 NodePort 入口)或 enterprise(仅通过 Manager Web 进入)
-USER_WEB_MODE=personal
-
# 联合认证 Demo Provider(仅用于部署联调,默认关闭)
IDENTITY_FEDERATION_DEMO_ENABLED=false
IDENTITY_FEDERATION_PUBLIC_PATH_PREFIX=/idp
diff --git a/deploy/enterprise/templates/gateway.template.env b/deploy/enterprise/templates/gateway.template.env
index a57e97a098..b2ec03f7f6 100644
--- a/deploy/enterprise/templates/gateway.template.env
+++ b/deploy/enterprise/templates/gateway.template.env
@@ -3,7 +3,7 @@ LOG_ROOT_PATH=/root/.logs
EXTENSION_DIRS=<<CLAW_POD_CODE_PATH>>/packages/jiuwenclaw-ee/gateway/extensions
PIP_EXTRA_ARGS=<<PIP_EXTRA_ARGS>>
NAMESPACE=<<NAMESPACE>>
-JIUWENSWARM_EDITION=enterprise
+JIUWENSWARM_EDITION=<<JIUWENSWARM_EDITION>>
TZ=<<TIMEZONE>>
JINA_READER_ENDPOINT=<<JINA_READER_ENDPOINT>>
HTTP_PROXY=<<HTTP_PROXY>>
diff --git a/deploy/enterprise/templates/gateway.template.yaml b/deploy/enterprise/templates/gateway.template.yaml
index 73a6b09090..daa0e89b0a 100644
--- a/deploy/enterprise/templates/gateway.template.yaml
+++ b/deploy/enterprise/templates/gateway.template.yaml
@@ -103,8 +103,8 @@ spec:
- secretRef:
name: <<SECRET_CM_NAME>>
env:
- - name: USER_WEB_MODE
- value: "<<USER_WEB_MODE>>"
+ - name: JIUWENSWARM_EDITION
+ value: "<<JIUWENSWARM_EDITION>>"
- name: GATEWAY_RUNTIME_MANAGER_URL
value: "<<GATEWAY_RUNTIME_MANAGER_URL>>"
# downward API:注入当前 Pod 身份,供 RuntimeManagementAgentClient
diff --git a/deploy/enterprise/templates/runtime.template.yaml b/deploy/enterprise/templates/runtime.template.yaml
index cb066187b7..e076e72be9 100644
--- a/deploy/enterprise/templates/runtime.template.yaml
+++ b/deploy/enterprise/templates/runtime.template.yaml
@@ -112,7 +112,9 @@ spec:
- name: OPENJIUWEN_SERVICE_PORT
value: "<<AGENT_RUNTIME_PORT>>"
- name: OPENJIUWEN_SERVICE_REDIS_URL
- value: "redis://<<REDIS_HOST>>:<<REDIS_PORT>>/<<AGENT_RUNTIME_REDIS_DB>>"
+ # AgentServer checkpointer 用此 URL 连接 Redis(与 gateway 的 redis client 独立)
+ # 由 runtime_handler.sh 按 REDIS_MODE 计算:cluster -> redis+cluster://host:port / standalone -> redis://host:port/db
+ value: "<<OPENJIUWEN_SERVICE_REDIS_URL>>"
- name: OPENJIUWEN_SERVICE_REQUEST_TIMEOUT_SECONDS
value: "<<AGENT_RUNTIME_REQUEST_TIMEOUT>>"
- name: OPENJIUWEN_SERVICE_DB_TYPE
@@ -136,7 +138,7 @@ spec:
- name: AGENT_RUNTIME_LOG_LEVEL
value: "<<AGENT_RUNTIME_LOG_LEVEL>>"
- name: JIUWENSWARM_EDITION
- value: "enterprise"
+ value: "<<JIUWENSWARM_EDITION>>"
- name: TZ
value: "<<TIMEZONE>>"
diff --git a/deploy/enterprise/templates/web.template.yaml b/deploy/enterprise/templates/web.template.yaml
index 70b5c0f06c..a652690ea3 100644
--- a/deploy/enterprise/templates/web.template.yaml
+++ b/deploy/enterprise/templates/web.template.yaml
@@ -34,12 +34,10 @@ spec:
value: "0.0.0.0"
- name: FRONTEND_HOST
value: "0.0.0.0"
- - name: USER_WEB_MODE
- value: "<<USER_WEB_MODE>>"
- - name: VITE_USER_WEB_MODE
- value: "<<USER_WEB_MODE>>"
- - name: VITE_ENABLE_USER_WEB_EMBEDDING
- value: "<<ENABLE_USER_WEB_EMBEDDING>>"
+ - name: JIUWENSWARM_EDITION
+ value: "<<JIUWENSWARM_EDITION>>"
+ - name: VITE_JIUWENSWARM_EDITION
+ value: "<<JIUWENSWARM_EDITION>>"
- name: LOGIN_AUTH_SIMULATE
value: "<<LOGIN_AUTH_SIMULATE>>"
- name: VITE_LOGIN_AUTH_SIMULATE
@@ -78,8 +76,6 @@ spec:
value: "<<WEB_DB_USER>>"
- name: WEB_DB_NAME
value: "<<WEB_DB_NAME>>"
- - name: JIUWENSWARM_EDITION
- value: "enterprise"
- name: TZ
value: "<<TIMEZONE>>"
diff --git a/deploy/enterprise/tests/test_identity_user_web_deploy.sh b/deploy/enterprise/tests/test_identity_user_web_deploy.sh
index de03c98d84..fbcbc4636c 100755
--- a/deploy/enterprise/tests/test_identity_user_web_deploy.sh
+++ b/deploy/enterprise/tests/test_identity_user_web_deploy.sh
@@ -36,8 +36,13 @@ main() {
MODULES=()
process_modules
- assert_equal "GATEWAY WEB RUNTIME" "${MODULES[*]}" "default delivery must exclude Manager"
+ assert_equal "GATEWAY WEB MANAGER RUNTIME" "${MODULES[*]}" "enterprise default must include Manager"
MODULES=()
+ DEPLOY_VARS["JIUWENSWARM_EDITION"]="personal"
+ process_modules
+ assert_equal "GATEWAY WEB RUNTIME" "${MODULES[*]}" "personal default must exclude Manager"
+ MODULES=()
+ DEPLOY_VARS["JIUWENSWARM_EDITION"]="enterprise"
TEST_DIR="$(mktemp -d)"
local test_dir="${TEST_DIR}"
@@ -50,20 +55,19 @@ main() {
DEPLOY_VARS["MANAGER_WEB_NODE_PORT"]="31003"
assert_equal \
- "false" \
- "${DEPLOY_VARS["ENABLE_USER_WEB_EMBEDDING"]}" \
- "User Web embedding must be disabled by default"
- printf '%s\n' 'ENABLE_USER_WEB_EMBEDDING=true' > "${test_dir}/.env.custom"
+ "enterprise" \
+ "${DEPLOY_VARS["JIUWENSWARM_EDITION"]}" \
+ "JIUWENSWARM_EDITION must default to enterprise"
+ printf '%s\n' 'JIUWENSWARM_EDITION=personal' > "${test_dir}/.env.custom"
read_env_from_file "${test_dir}/.env.custom" "DEPLOY_VARS"
assert_equal \
- "true" \
- "${DEPLOY_VARS["ENABLE_USER_WEB_EMBEDDING"]}" \
- ".env.custom compatibility value must be read"
+ "personal" \
+ "${DEPLOY_VARS["JIUWENSWARM_EDITION"]}" \
+ ".env.custom edition value must override the default"
CONFIG["WEB_FILE"]="${test_dir}/web.yaml"
- DEPLOY_VARS["USER_WEB_MODE"]="personal"
- DEPLOY_VARS["ENABLE_USER_WEB_EMBEDDING"]="false"
+ DEPLOY_VARS["JIUWENSWARM_EDITION"]="personal"
gen_web_file
assert_equal \
"NodePort" \
@@ -73,35 +77,46 @@ main() {
"0.0.0.0" \
"$(yq eval-all 'select(.kind == "Deployment").spec.template.spec.containers[0].env[] | select(.name == "FRONTEND_HOST").value' "${CONFIG["WEB_FILE"]}")" \
"User Web frontend must listen on all interfaces"
+ assert_equal \
+ "personal" \
+ "$(yq eval-all 'select(.kind == "Deployment").spec.template.spec.containers[0].env[] | select(.name == "JIUWENSWARM_EDITION").value' "${CONFIG["WEB_FILE"]}")" \
+ "personal mode must inject JIUWENSWARM_EDITION"
- DEPLOY_VARS["USER_WEB_MODE"]="enterprise"
- DEPLOY_VARS["ENABLE_USER_WEB_EMBEDDING"]="true"
+ DEPLOY_VARS["JIUWENSWARM_EDITION"]="enterprise"
gen_web_file
assert_equal \
"NodePort" \
"$(yq eval-all 'select(.metadata.name == "jiuwenclaw-web-nodeport") | .spec.type' "${CONFIG["WEB_FILE"]}")" \
"enterprise mode must expose the independent User Web NodePort"
+ assert_equal \
+ "enterprise" \
+ "$(yq eval-all 'select(.kind == "Deployment").spec.template.spec.containers[0].env[] | select(.name == "JIUWENSWARM_EDITION").value' "${CONFIG["WEB_FILE"]}")" \
+ "enterprise mode must inject JIUWENSWARM_EDITION"
+ assert_equal \
+ "enterprise" \
+ "$(yq eval-all 'select(.kind == "Deployment").spec.template.spec.containers[0].env[] | select(.name == "VITE_JIUWENSWARM_EDITION").value' "${CONFIG["WEB_FILE"]}")" \
+ "enterprise mode must inject VITE_JIUWENSWARM_EDITION"
DEPLOY_VARS["IS_UP_MANAGER_WEB"]="false"
DEPLOY_VARS["USER_WEB_IDP_TARGET"]="http://jiuwenclaw-identity:8770"
DEPLOY_VARS["USER_WEB_MANAGER_TARGET"]="http://jiuwenclaw-manager-server:8765"
- check_user_web_mode_config
+ check_jiuwenswarm_edition_config
DEPLOY_VARS["IS_UP_MANAGER_WEB"]="true"
DEPLOY_VARS["LOGIN_AUTH_SIMULATE"]="true"
- check_user_web_mode_config
+ check_jiuwenswarm_edition_config
DEPLOY_VARS["LOGIN_AUTH_SIMULATE"]="invalid"
- if check_user_web_mode_config >/dev/null 2>&1; then
+ if check_jiuwenswarm_edition_config >/dev/null 2>&1; then
echo "FAIL: invalid LOGIN_AUTH_SIMULATE value must be rejected" >&2
exit 1
fi
DEPLOY_VARS["LOGIN_AUTH_SIMULATE"]="false"
- check_user_web_mode_config
+ check_jiuwenswarm_edition_config
- DEPLOY_VARS["USER_WEB_MODE"]="invalid"
- if (check_user_web_mode_config) >/dev/null 2>&1; then
- echo "FAIL: invalid boolean value must be rejected" >&2
+ DEPLOY_VARS["JIUWENSWARM_EDITION"]="invalid"
+ if (check_jiuwenswarm_edition_config) >/dev/null 2>&1; then
+ echo "FAIL: invalid edition value must be rejected" >&2
exit 1
fi
@@ -191,7 +206,7 @@ main() {
wait_k8s_resource_ready() { :; }
success() { :; }
- DEPLOY_VARS["USER_WEB_MODE"]="enterprise"
+ DEPLOY_VARS["JIUWENSWARM_EDITION"]="enterprise"
deploy_web
DEPLOY_VARS["IS_UP_MANAGER_WEB"]="true"
deploy_manager
diff --git a/jiuwenswarm/channels/web/app_web.py b/jiuwenswarm/channels/web/app_web.py
index 2ecf239ce7..c846dcc171 100644
--- a/jiuwenswarm/channels/web/app_web.py
+++ b/jiuwenswarm/channels/web/app_web.py
@@ -35,6 +35,7 @@ parse_dotenv_early("jiuwenswarm-web")
from jiuwenswarm.agents.harness.common.tools.ssl_config import get_insecure_ssl_context, get_ssl_verify
from jiuwenswarm.common.debug_dump import install_async_dump_handler
from jiuwenswarm.common.ws_diagnostics import describe_ws_exception, format_ws_diagnostics
+from jiuwenswarm.common.local_env_config import is_enterprise
from jiuwenswarm.common.utils import (
get_logs_dir,
get_root_dir,
@@ -70,17 +71,13 @@ def _default_dist_dir() -> Path:
def _inject_user_web_runtime_config(
document: str,
- mode: str,
login_auth_simulate: bool = True,
login_auth_simulate_available: bool = True,
) -> str:
- """Inject runtime mode values without modifying JavaScript property names."""
+ """Inject runtime edition and login-auth flags into index.html."""
+ edition = "enterprise" if is_enterprise() else "personal"
return (
- document.replace("__JIUWEN_USER_WEB_MODE_VALUE__", mode)
- .replace(
- "__JIUWEN_USER_WEB_EMBEDDING_VALUE__",
- "true" if mode == "enterprise" else "false",
- )
+ document.replace("__JIUWENSWARM_EDITION_VALUE__", edition)
.replace(
"__JIUWEN_LOGIN_AUTH_SIMULATE_VALUE__",
"true" if login_auth_simulate else "false",
@@ -157,8 +154,6 @@ class _SpaStaticHandler(SimpleHTTPRequestHandler):
idp_target = ""
manager_api_target = ""
ws_disable_compress = False
- embedding_enabled = False
- user_web_mode = "personal"
login_auth_simulate = True
login_auth_simulate_available = True
logger = logging.getLogger(__name__)
@@ -692,7 +687,6 @@ class _SpaStaticHandler(SimpleHTTPRequestHandler):
index = Path(self.directory or os.getcwd()) / "index.html"
body = _inject_user_web_runtime_config(
index.read_text(encoding="utf-8"),
- self.user_web_mode,
self.login_auth_simulate,
self.login_auth_simulate_available,
).encode("utf-8")
@@ -925,11 +919,7 @@ def main() -> None:
_ConfiguredHandler.ws_target = ws_target
_ConfiguredHandler.idp_target = os.getenv("USER_WEB_IDP_TARGET", "").strip()
_ConfiguredHandler.manager_api_target = os.getenv("USER_WEB_MANAGER_TARGET", "").strip()
- configured_mode = os.getenv("USER_WEB_MODE", "").strip().lower()
- if configured_mode not in {"personal", "enterprise"}:
- legacy_embedding = os.getenv("ENABLE_USER_WEB_EMBEDDING", "")
- configured_mode = "enterprise" if legacy_embedding.strip().lower() == "true" else "personal"
- _ConfiguredHandler.user_web_mode = configured_mode
+ enterprise = is_enterprise()
login_auth_simulate_raw = os.getenv("LOGIN_AUTH_SIMULATE")
login_auth_simulate_available_raw = os.getenv("LOGIN_AUTH_SIMULATE_AVAILABLE")
try:
@@ -943,12 +933,11 @@ def main() -> None:
raise SystemExit(str(exc)) from exc
_ConfiguredHandler.login_auth_simulate = login_auth_simulate
_ConfiguredHandler.login_auth_simulate_available = login_auth_simulate_available
- if configured_mode == "enterprise" and login_auth_simulate and not login_auth_simulate_available:
+ if enterprise and login_auth_simulate and not login_auth_simulate_available:
raise SystemExit(
"配置冲突:LOGIN_AUTH_SIMULATE=true,但当前客户交付制品未包含登录认证模拟插件;"
"请设置 LOGIN_AUTH_SIMULATE=false 并接入 manager ID认证服务"
)
- _ConfiguredHandler.embedding_enabled = configured_mode == "enterprise"
_ConfiguredHandler.web_http_target = web_http_target
_ConfiguredHandler.ws_disable_compress = args.ws_disable_compress
_ConfiguredHandler.logger = logger
@@ -960,12 +949,12 @@ def main() -> None:
logger.info(
"[jiuwenswarm-web] LOGIN_AUTH_SIMULATE 未配置,按默认值 true 启用登录认证模拟调试"
)
- if configured_mode == "personal":
+ if not enterprise:
logger.info("[jiuwenswarm-web] personal 模式:跳过企业登录认证")
if not login_auth_simulate:
logger.warning(
- "[jiuwenswarm-web] 配置冲突:USER_WEB_MODE=personal 时 "
- "LOGIN_AUTH_SIMULATE 不参与登录流程,personal 模式仍跳过企业认证"
+ "[jiuwenswarm-web] 配置冲突:personal 模式仍将跳过企业登录认证;"
+ "LOGIN_AUTH_SIMULATE=false 不会启用正式身份认证"
)
elif login_auth_simulate:
logger.info("[jiuwenswarm-web] 【登录认证模拟调试模式已开启】")
diff --git a/jiuwenswarm/channels/web/frontend/index.html b/jiuwenswarm/channels/web/frontend/index.html
index 62de7d973f..15b119c011 100644
--- a/jiuwenswarm/channels/web/frontend/index.html
+++ b/jiuwenswarm/channels/web/frontend/index.html
@@ -11,8 +11,7 @@
</head>
<body>
<script>
- window.__JIUWEN_USER_WEB_MODE__ = '__JIUWEN_USER_WEB_MODE_VALUE__';
- window.__JIUWEN_USER_WEB_EMBEDDING__ = '__JIUWEN_USER_WEB_EMBEDDING_VALUE__' === 'true';
+ window.__JIUWENSWARM_EDITION__ = '__JIUWENSWARM_EDITION_VALUE__';
window.__JIUWEN_LOGIN_AUTH_SIMULATE__ = '__JIUWEN_LOGIN_AUTH_SIMULATE_VALUE__';
window.__JIUWEN_LOGIN_AUTH_SIMULATE_AVAILABLE__ = '__JIUWEN_LOGIN_AUTH_SIMULATE_AVAILABLE_VALUE__';
</script>
diff --git a/jiuwenswarm/channels/web/frontend/package.json b/jiuwenswarm/channels/web/frontend/package.json
index f171b6dafa..5f13b595b1 100644
--- a/jiuwenswarm/channels/web/frontend/package.json
+++ b/jiuwenswarm/channels/web/frontend/package.json
@@ -23,7 +23,7 @@
"test:file-download-dedup": "tsc src/utils/fileDownloadDedup.ts --target ES2020 --module ES2020 --moduleResolution Bundler --rootDir src --outDir node_modules/.cache/file-download-dedup --skipLibCheck --noEmitOnError && node --test tests/fileDownloadDedup.test.mjs",
"test:web-http-client": "tsc src/services/webHttpClient.ts --target ES2020 --module ES2020 --moduleResolution Bundler --rootDir src --outDir node_modules/.cache/web-http-client --skipLibCheck --noEmitOnError && node --test tests/webHttpClient.test.mjs",
"test:runtime-scope": "tsc src/services/runtimeScope.ts --target ES2020 --module ES2020 --moduleResolution Bundler --rootDir src --outDir node_modules/.cache/runtime-scope --skipLibCheck --noEmitOnError && node --test tests/runtimeScope.test.mjs",
- "test:user-web-entry": "esbuild src/EnterpriseEntry.tsx --bundle --packages=external --platform=node --format=esm --outfile=node_modules/.cache/user-web-entry/EnterpriseEntry.mjs --alias:virtual:login-auth-simulate-provider=./src/auth/simulate/available.ts --define:import.meta.env.VITE_USER_WEB_MODE='\"personal\"' --define:import.meta.env.VITE_ENABLE_USER_WEB_EMBEDDING='\"false\"' --define:import.meta.env.VITE_LOGIN_AUTH_SIMULATE='\"false\"' && esbuild src/auth/config.ts src/auth/simulate/SimulatedAuthProvider.ts --bundle --packages=external --platform=node --format=esm --outdir=node_modules/.cache/user-web-entry/auth && node --test tests/userWebEntry.test.mjs",
+ "test:user-web-entry": "esbuild src/EnterpriseEntry.tsx --bundle --packages=external --platform=node --format=esm --outfile=node_modules/.cache/user-web-entry/EnterpriseEntry.mjs --alias:virtual:login-auth-simulate-provider=./src/auth/simulate/available.ts --define:import.meta.env.VITE_JIUWENSWARM_EDITION='\"personal\"' --define:import.meta.env.VITE_LOGIN_AUTH_SIMULATE='\"false\"' && esbuild src/auth/config.ts src/auth/simulate/SimulatedAuthProvider.ts --bundle --packages=external --platform=node --format=esm --outdir=node_modules/.cache/user-web-entry/auth && node --test tests/userWebEntry.test.mjs",
"test:editable-combobox": "tsc src/components/SessionSidebar/editableComboboxModel.ts --target ES2020 --module ES2020 --moduleResolution Bundler --rootDir src --outDir node_modules/.cache/editable-combobox --skipLibCheck --noEmitOnError && node --test tests/editableCombobox.test.mjs",
"test:a2a-ingress-panel": "tsc src/components/A2AIngressPanel/a2aIngressPanelState.ts --target ES2020 --module ES2020 --moduleResolution Bundler --rootDir src --outDir node_modules/.cache/a2a-ingress-panel-state --skipLibCheck --noEmitOnError && node --test tests/a2aIngressPanelState.test.mjs",
"test:chat-store-streaming": "esbuild src/stores/chatStore.ts --bundle --platform=node --format=esm --outfile=node_modules/.cache/chat-store-streaming/chatStore.mjs --define:import.meta.env.DEV=false && node --test tests/chatStoreStreaming.test.mjs",
diff --git a/jiuwenswarm/channels/web/frontend/src/App.tsx b/jiuwenswarm/channels/web/frontend/src/App.tsx
index 94f3552270..01011a344f 100644
--- a/jiuwenswarm/channels/web/frontend/src/App.tsx
+++ b/jiuwenswarm/channels/web/frontend/src/App.tsx
@@ -27,7 +27,7 @@ import {
import type { CodeReviewTarget } from './features/code-mode/types';
import { FEATURE_APP_UPDATER_UI } from './featureFlags';
-import { ENTERPRISE_HIDDEN_NAV_ITEMS, isEnterpriseMode } from './edition';
+import { ENTERPRISE_HIDDEN_NAV_ITEMS, isEnterprise } from './edition';
import {
beginHistoryRestore,
fetchHistoryPage,
@@ -271,7 +271,7 @@ function AppContent() {
return 'new';
});
- const enterpriseMode = isEnterpriseMode();
+ const enterpriseMode = isEnterprise();
const enterpriseBlockedNav = new Set<MainNavKey>(ENTERPRISE_HIDDEN_NAV_ITEMS);
const [activeNav, setActiveNav] = useState<MainNavKey>('chat');
const [serverConfig, setServerConfig] = useState<Record<string, unknown> | null>(null);
diff --git a/jiuwenswarm/channels/web/frontend/src/EnterpriseEntry.tsx b/jiuwenswarm/channels/web/frontend/src/EnterpriseEntry.tsx
index cb08a1db76..9c9996a6f3 100644
--- a/jiuwenswarm/channels/web/frontend/src/EnterpriseEntry.tsx
+++ b/jiuwenswarm/channels/web/frontend/src/EnterpriseEntry.tsx
@@ -2,7 +2,7 @@ import { type ReactNode, useCallback, useEffect, useMemo, useState } from 'react
import { isLoginAuthSimulateEnabled } from './auth/config';
import { resolveEnterpriseAuthProvider } from './auth/providerRegistry';
import { EnterpriseAuthError, type EnterpriseAuthProvider } from './auth/types';
-import { isEnterpriseMode } from './edition';
+import { isEnterprise } from './edition';
import {
EnterpriseContext,
type EnterpriseAgent,
@@ -170,7 +170,7 @@ function EntryStatus({ phase, error, onLogout }: { phase: EntryPhase; error: str
}
export function EnterpriseEntry({ children }: { children: ReactNode }) {
- const enterprise = isEnterpriseMode();
+ const enterprise = isEnterprise();
const simulateLogin = enterprise && isLoginAuthSimulateEnabled();
const provider = useMemo(
() => (enterprise ? resolveEnterpriseAuthProvider(simulateLogin) : null),
diff --git a/jiuwenswarm/channels/web/frontend/src/components/ChatPanel/InputArea.tsx b/jiuwenswarm/channels/web/frontend/src/components/ChatPanel/InputArea.tsx
index d266d3b858..5a17a5283e 100644
--- a/jiuwenswarm/channels/web/frontend/src/components/ChatPanel/InputArea.tsx
+++ b/jiuwenswarm/channels/web/frontend/src/components/ChatPanel/InputArea.tsx
@@ -28,7 +28,7 @@ import clsx from 'clsx';
import { PermissionWarningDialog } from './PermissionWarningDialog';
import { ModelProviderIcon } from '../ModelProviderIcon';
import { getEvolutionPillLabel } from './evolution-status';
-import { isEnterpriseMode } from '../../edition';
+import { isEnterprise } from '../../edition';
import { webRequest } from '../../services/webClient';
import { getSkillAvatar } from '../../utils/skillAvatar';
import { withUploadDocumentBlock } from '../../utils/documentMessage';
@@ -575,7 +575,7 @@ export const InputArea = forwardRef<InputAreaHandle, InputAreaProps>(function In
const isTeamMode = mode === 'team';
const isAutoHarnessMode = mode === 'auto_harness';
const isWorkContextLocked = Boolean(activeSessionId && activeSessionId !== NEW_CONVERSATION_ID);
- const showWorkContextRow = !isEnterpriseMode() && activeSessionId === NEW_CONVERSATION_ID;
+ const showWorkContextRow = !isEnterprise() && activeSessionId === NEW_CONVERSATION_ID;
/** Goal 入口是否适用于当前上下文(agent 模式 + 已接入 onSetGoal,如欢迎页新会话就不适用) */
const canUseGoalMenu = isAgentMode && Boolean(onSetGoal);
// 只跟 armed 挂钩:这个 tag 是"下一条消息将用于设置目标"的过渡态指示,发送后 armed 变 false
diff --git a/jiuwenswarm/channels/web/frontend/src/components/SkillPanel/index.tsx b/jiuwenswarm/channels/web/frontend/src/components/SkillPanel/index.tsx
index a028d2351b..7a879d5c2f 100644
--- a/jiuwenswarm/channels/web/frontend/src/components/SkillPanel/index.tsx
+++ b/jiuwenswarm/channels/web/frontend/src/components/SkillPanel/index.tsx
@@ -18,7 +18,7 @@ import { getSkillAvatar } from "../../utils/skillAvatar";
import { SkillGraphPanel, type SkillGraphPanelHandle } from "../SkillGraphPanel";
import { MarkdownRenderer } from "../MarkdownRenderer";
import { Switch } from "../Switch";
-import { isEnterpriseMode } from "../../edition";
+import { isEnterprise } from "../../edition";
/** 刷新会 git pull marketplace,略放宽;普通进页单次 RPC 一般很快。 */
const SKILLS_FETCH_TIMEOUT_REFRESH_MS = 60_000;
@@ -587,7 +587,7 @@ function SkillIndexTreeView({
export function SkillPanel({ sessionId, onNavigateToConfig, isActive = false }: SkillPanelProps) {
const { t, i18n } = useTranslation();
- const readOnly = isEnterpriseMode();
+ const readOnly = isEnterprise();
const [activeTab, setActiveTab] = useState<"my" | "marketplace" | "index" | "graph">("my");
const [mySkillsSubTab, setMySkillsSubTab] = useState<"all" | "enabled" | "disabled">("all");
const [marketplaceSubTab, setMarketplaceSubTab] = useState<"builtin" | "swarmskills" | "online">("builtin");
diff --git a/jiuwenswarm/channels/web/frontend/src/edition.ts b/jiuwenswarm/channels/web/frontend/src/edition.ts
index 1ee95be889..1d06955472 100644
--- a/jiuwenswarm/channels/web/frontend/src/edition.ts
+++ b/jiuwenswarm/channels/web/frontend/src/edition.ts
@@ -1,10 +1,20 @@
-export type UserWebMode = "personal" | "enterprise";
-export const getUserWebMode = (): UserWebMode => {
- const injected = String(window.__JIUWEN_USER_WEB_MODE__ || "").toLowerCase();
- if (injected === "enterprise" || injected === "personal") return injected;
- const configured = String(import.meta.env.VITE_USER_WEB_MODE || "").toLowerCase();
- if (configured === "enterprise" || configured === "personal") return configured;
- return String(import.meta.env.VITE_ENABLE_USER_WEB_EMBEDDING).toLowerCase() === "true" ? "enterprise" : "personal";
-};
-export const isEnterpriseMode = (): boolean => getUserWebMode() === "enterprise";
-export const ENTERPRISE_HIDDEN_NAV_ITEMS = ["channels", "agents", "teams", "extensions", "configpanel", "browserpanel", "updatepanel"] as const;
+/** Mirrors ``jiuwenswarm.common.local_env_config.is_enterprise`` on the frontend. */
+function readEdition(): string {
+ const injected = String(window.__JIUWENSWARM_EDITION__ ?? "").trim().toLowerCase();
+ if (injected && !injected.startsWith("__")) {
+ return injected;
+ }
+ return String(import.meta.env.VITE_JIUWENSWARM_EDITION ?? "").trim().toLowerCase();
+}
+
+export const isEnterprise = (): boolean => readEdition() === "enterprise";
+
+export const ENTERPRISE_HIDDEN_NAV_ITEMS = [
+ "channels",
+ "agents",
+ "teams",
+ "extensions",
+ "configpanel",
+ "browserpanel",
+ "updatepanel",
+] as const;
diff --git a/jiuwenswarm/channels/web/frontend/src/multi-session/routing/route.ts b/jiuwenswarm/channels/web/frontend/src/multi-session/routing/route.ts
index 906f3da1fe..b8920b5e22 100644
--- a/jiuwenswarm/channels/web/frontend/src/multi-session/routing/route.ts
+++ b/jiuwenswarm/channels/web/frontend/src/multi-session/routing/route.ts
@@ -1,4 +1,4 @@
-import { isEnterpriseMode } from '../../edition';
+import { isEnterprise } from '../../edition';
import { getRuntimeScope } from '../../services/runtimeScope';
export type ChatRoute =
@@ -16,7 +16,7 @@ export function parseChatRoute(pathname: string): ChatRoute | null {
}
function appendEnterpriseScope(path: string): string {
- if (!isEnterpriseMode()) return path;
+ if (!isEnterprise()) return path;
const scope = getRuntimeScope();
const query = new URLSearchParams(window.location.search);
if (scope.userId) query.set('user_id', scope.userId);
diff --git a/jiuwenswarm/channels/web/frontend/src/multi-session/sidebar/ConversationSidebar.tsx b/jiuwenswarm/channels/web/frontend/src/multi-session/sidebar/ConversationSidebar.tsx
index eaef62ca7b..a3a317ea69 100644
--- a/jiuwenswarm/channels/web/frontend/src/multi-session/sidebar/ConversationSidebar.tsx
+++ b/jiuwenswarm/channels/web/frontend/src/multi-session/sidebar/ConversationSidebar.tsx
@@ -34,7 +34,7 @@ import {
} from '../../features/workspace/projectDirectoryPicker';
import { toDisplaySessionTitle } from '../../utils/documentMessage';
import './ConversationSidebar.css';
-import { isEnterpriseMode } from '../../edition';
+import { isEnterprise } from '../../edition';
import '../dialogs/dialogs.css';
import AddProjectIcon from '../../assets/work-mode/add-project.svg?react';
import ArrowRightIcon from '../../assets/work-mode/arrow-right.svg?react';
@@ -710,7 +710,7 @@ export function ConversationSidebar({
isCronActive,
}: ConversationSidebarProps) {
const { t } = useTranslation();
- const enterpriseMode = isEnterpriseMode();
+ const enterpriseMode = isEnterprise();
const runtimes = useChatStore((state) => state.runtimes);
const [relativeTimeNow, setRelativeTimeNow] = useState(Date.now);
const [unreadSessions, setUnreadSessions] = useState(loadUnreadSessions);
diff --git a/jiuwenswarm/channels/web/frontend/src/vite-env.d.ts b/jiuwenswarm/channels/web/frontend/src/vite-env.d.ts
index ccaf6cf8e2..438ab0ee6c 100644
--- a/jiuwenswarm/channels/web/frontend/src/vite-env.d.ts
+++ b/jiuwenswarm/channels/web/frontend/src/vite-env.d.ts
@@ -8,6 +8,7 @@ interface ImportMetaEnv {
readonly VITE_TRANSPORT?: string;
readonly VITE_GATEWAY_HTTP_BASE?: string;
readonly VITE_WEB_HTTP_BASE?: string;
+ readonly VITE_JIUWENSWARM_EDITION?: string;
readonly VITE_LOGIN_AUTH_SIMULATE?: string;
readonly VITE_LOGIN_AUTH_SIMULATE_AVAILABLE?: string;
}
@@ -46,9 +47,8 @@ interface Window {
};
/** Durable ingest hook invoked by desktop_app.py run_js on native file drops. */
__JIUWEN_INGEST_LOCAL_FILES__?: (detail: unknown) => void;
- /** Set by the User Web server for enterprise embedding mode. */
- __JIUWEN_USER_WEB_MODE__?: string;
- __JIUWEN_USER_WEB_EMBEDDING__?: boolean;
+ /** Edition injected by the User Web server (mirrors JIUWENSWARM_EDITION). */
+ __JIUWENSWARM_EDITION__?: string;
/** Login simulation switch injected by the User Web server. */
__JIUWEN_LOGIN_AUTH_SIMULATE__?: boolean | string;
/** Whether this frontend artifact contains the optional simulation plugin. */
diff --git a/jiuwenswarm/channels/web/frontend/tests/userWebEntry.test.mjs b/jiuwenswarm/channels/web/frontend/tests/userWebEntry.test.mjs
index 0509304cf8..c3f18aec59 100644
--- a/jiuwenswarm/channels/web/frontend/tests/userWebEntry.test.mjs
+++ b/jiuwenswarm/channels/web/frontend/tests/userWebEntry.test.mjs
@@ -16,7 +16,7 @@ globalThis.localStorage = {
},
};
globalThis.window = {
- __JIUWEN_USER_WEB_MODE__: 'personal',
+ __JIUWENSWARM_EDITION__: 'personal',
history: { replaceState() {} },
location: { pathname: '/', search: '', replace() {} },
};
@@ -31,8 +31,8 @@ const {
const { parseLoginAuthSimulate } = await import('../node_modules/.cache/user-web-entry/auth/config.js');
const { buildSimulatedEnterpriseContext } = await import('../node_modules/.cache/user-web-entry/auth/simulate/SimulatedAuthProvider.js');
-function renderEntry(mode, simulate = false) {
- window.__JIUWEN_USER_WEB_MODE__ = mode;
+function renderEntry(edition, simulate = false) {
+ window.__JIUWENSWARM_EDITION__ = edition;
window.__JIUWEN_LOGIN_AUTH_SIMULATE__ = simulate;
return renderToStaticMarkup(React.createElement(EnterpriseEntry, null, React.createElement('div', { id: 'user-web-content' }, 'user web content')));
}
@@ -42,7 +42,7 @@ function resetBrowserState() {
window.location.search = '';
}
-test('personal mode renders the standalone User Web without enterprise authentication', () => {
+test('personal edition renders the standalone User Web without enterprise authentication', () => {
resetBrowserState();
const html = renderEntry('personal');
@@ -50,7 +50,7 @@ test('personal mode renders the standalone User Web without enterprise authentic
assert.doesNotMatch(html, /ENTERPRISE WORKSPACE/);
});
-test('enterprise mode redirects unauthenticated users instead of rendering User Web', () => {
+test('enterprise edition redirects unauthenticated users instead of rendering User Web', () => {
resetBrowserState();
const html = renderEntry('enterprise');
@@ -59,7 +59,7 @@ test('enterprise mode redirects unauthenticated users instead of rendering User
assert.doesNotMatch(html, /user web content/);
});
-test('enterprise mode loads and validates an authorized context before rendering User Web', () => {
+test('enterprise edition loads and validates an authorized context before rendering User Web', () => {
resetBrowserState();
localStorage.setItem('openjiuwen_access_token', 'manager-token');
window.location.search = '?user_id=user-1&group_id=group-1&bot_id=bot-1&gateway_id=gateway-1';
diff --git a/jiuwenswarm/channels/web/frontend/vite.config.ts b/jiuwenswarm/channels/web/frontend/vite.config.ts
index 6e6faab37f..23dd757e89 100644
--- a/jiuwenswarm/channels/web/frontend/vite.config.ts
+++ b/jiuwenswarm/channels/web/frontend/vite.config.ts
@@ -333,14 +333,20 @@ const loginAuthSimulateIncluded = parseLoginAuthSimulate(
process.env.INCLUDE_LOGIN_AUTH_SIMULATE ?? process.env.VITE_LOGIN_AUTH_SIMULATE_AVAILABLE
)
-function loginAuthStartupCheck(): Plugin {
- const userWebMode = (process.env.USER_WEB_MODE || process.env.VITE_USER_WEB_MODE || 'personal')
+/** Mirrors ``jiuwenswarm.common.local_env_config.is_enterprise`` for Vite startup checks. */
+function isEnterpriseEdition(): boolean {
+ const edition = (process.env.JIUWENSWARM_EDITION ?? process.env.VITE_JIUWENSWARM_EDITION ?? '')
.trim()
.toLowerCase()
+ return edition === 'enterprise'
+}
+
+function loginAuthStartupCheck(): Plugin {
+ const enterprise = isEnterpriseEdition()
const simulateRaw = process.env.LOGIN_AUTH_SIMULATE ?? process.env.VITE_LOGIN_AUTH_SIMULATE
const simulate = parseLoginAuthSimulate(simulateRaw)
- if (userWebMode === 'enterprise' && simulate && !loginAuthSimulateIncluded) {
+ if (enterprise && simulate && !loginAuthSimulateIncluded) {
throw new Error(
'配置冲突:LOGIN_AUTH_SIMULATE=true,但当前客户交付制品未包含登录认证模拟插件;' +
'请设置 LOGIN_AUTH_SIMULATE=false 并接入 manager ID认证服务'
@@ -355,11 +361,11 @@ function loginAuthStartupCheck(): Plugin {
'[jiuwenswarm-web] LOGIN_AUTH_SIMULATE 未配置,按默认值 true 启用登录认证模拟调试'
)
}
- if (userWebMode !== 'enterprise') {
+ if (!enterprise) {
console.info('[jiuwenswarm-web] 单机版模式:跳过企业登录认证')
if (!simulate) {
console.warn(
- '[jiuwenswarm-web] 配置冲突:USER_WEB_MODE=personal 始终跳过企业登录;' +
+ '[jiuwenswarm-web] 配置冲突:personal 模式仍将跳过企业登录;' +
'LOGIN_AUTH_SIMULATE=false 不会启用正式身份认证'
)
}
@@ -432,8 +438,12 @@ export default defineConfig({
},
},
server: {
+ host: '0.0.0.0',
port: frontendPort,
strictPort: true,
+ // Manager Web 企业链路把 /chat 反代到 http://jiuwenclaw-web:5173,
+ // Vite 5.4+ 默认拒绝未登记 Host,会直接 403。
+ allowedHosts: true,
proxy: {
'/idp': { target: process.env.USER_WEB_IDP_TARGET || 'http://127.0.0.1:8770', changeOrigin: true, rewrite: (p) => p.replace(/^\/idp/, '') },
'/manager-api': { target: process.env.USER_WEB_MANAGER_TARGET || 'http://127.0.0.1:8765', changeOrigin: true, rewrite: (p) => p.replace(/^\/manager-api/, '/api') },
diff --git a/packages/jiuwenclaw-ee/gateway/extensions/manager_config_receiver/extension.yaml b/packages/jiuwenclaw-ee/gateway/extensions/manager_config_receiver/extension.yaml
index 912cc32b2f..a04c8a373d 100644
--- a/packages/jiuwenclaw-ee/gateway/extensions/manager_config_receiver/extension.yaml
+++ b/packages/jiuwenclaw-ee/gateway/extensions/manager_config_receiver/extension.yaml
@@ -4,11 +4,7 @@ version: 0.2.0
description: Gateway HTTP config receiver for Claw Manager sync (replaces manager_ws_client WebSocket client)
author: openjiuwen
min_jiuwenclaw_version: "0.1.0"
-dependencies:
- pydantic-settings: ">=2.0"
- python-dotenv: ">=1.0"
- # DBHandler / link_auth;与 runtime_management_extension 同源
- openjiuwen_runtime_foundation: " @ git+https://gitcode.com/openJiuwen/agent-runtime.git@develop#subdirectory=foundation"
+dependencies: {}
config_schema:
type: object
properties:
diff --git a/tests/unit_tests/test_app_web_gateway_api_proxy.py b/tests/unit_tests/test_app_web_gateway_api_proxy.py
index cf910ca828..c63c699e87 100644
--- a/tests/unit_tests/test_app_web_gateway_api_proxy.py
+++ b/tests/unit_tests/test_app_web_gateway_api_proxy.py
@@ -41,12 +41,12 @@ def test_gateway_api_prefix_is_rewritten_for_upstream(monkeypatch) -> None:
@pytest.mark.parametrize(
- ("mode", "embedding"),
- [("personal", "false"), ("enterprise", "true")],
+ ("edition",),
+ [("personal",), ("enterprise",)],
)
def test_user_web_runtime_mode_injection_preserves_property_names(
- mode: str,
- embedding: str,
+ edition: str,
+ monkeypatch: pytest.MonkeyPatch,
) -> None:
frontend_index = (
Path(__file__).resolve().parents[2]
@@ -57,13 +57,11 @@ def test_user_web_runtime_mode_injection_preserves_property_names(
/ "index.html"
).read_text(encoding="utf-8")
- rendered = _inject_user_web_runtime_config(frontend_index, mode)
+ monkeypatch.setenv("JIUWENSWARM_EDITION", edition)
+ rendered = _inject_user_web_runtime_config(frontend_index)
- assert f"window.__JIUWEN_USER_WEB_MODE__ = '{mode}'" in rendered
- assert "window.__JIUWEN_USER_WEB_EMBEDDING__" in rendered
- assert f"'{embedding}' === 'true'" in rendered
- assert "__JIUWEN_USER_WEB_MODE_VALUE__" not in rendered
- assert "__JIUWEN_USER_WEB_EMBEDDING_VALUE__" not in rendered
+ assert f"window.__JIUWENSWARM_EDITION__ = '{edition}'" in rendered
+ assert "__JIUWENSWARM_EDITION_VALUE__" not in rendered
assert "window.__JIUWEN_LOGIN_AUTH_SIMULATE__ = 'true'" in rendered
assert "__JIUWEN_LOGIN_AUTH_SIMULATE_VALUE__" not in rendered
assert "window.__JIUWEN_LOGIN_AUTH_SIMULATE_AVAILABLE__ = 'true'" in rendered