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
fix: pass process config to jiuwenbox
chen hui12fe4185be37
diff --git a/deploy/enterprise/gen_env_custom.sh b/deploy/enterprise/gen_env_custom.shindex 61dd68150f..bf71c9eea9 100755--- a/deploy/enterprise/gen_env_custom.sh+++ b/deploy/enterprise/gen_env_custom.sh@@ -142,8 +142,19 @@ API_BASE=""API_KEY=""#LOG_MASK_ENABLED=false+EOF++if [[ "${TYPE}" == "dev" ]]; then+cat <<EOFAPPLY_PATCH=true+LOGIN_AUTH_SIMULATE=trueEOF+else+cat <<EOF+APPLY_PATCH=false+LOGIN_AUTH_SIMULATE=false+EOF+fi} > "${ENV_FILE}"echo "Generated: ${ENV_FILE} (ARCH=${ARCH}, VERSION=${VERSION}, TYPE=${TYPE})"diff --git a/jiuwenswarm/server/runtime/agent_adapter/sysop_builder.py b/jiuwenswarm/server/runtime/agent_adapter/sysop_builder.pyindex a397ced230..2f9f55636e 100644--- a/jiuwenswarm/server/runtime/agent_adapter/sysop_builder.py+++ b/jiuwenswarm/server/runtime/agent_adapter/sysop_builder.py@@ -2,9 +2,12 @@from __future__ import annotations+import grpimport hashlib+import jsonimport loggingimport os+import pwdfrom pathlib import Pathfrom typing import Any, Literal@@ -580,6 +583,30 @@ def build_filesystem_policy(return {"filesystem_policy": fs_policy}, upload_list+def build_process_policy() -> dict[str, Any]:+ """获取当前进程的有效用户名与用户组名。++ 使用 ``geteuid`` / ``getegid`` 解析有效身份;若 passwd/group 中无对应条目,+ 则回退为 UID/GID 的字符串形式。+ """+ uid = os.geteuid()+ gid = os.getegid()+ try:+ username = pwd.getpwuid(uid).pw_name+ except KeyError:+ username = str(uid)+ try:+ groupname = grp.getgrgid(gid).gr_name+ except KeyError:+ groupname = str(gid)++ process_policy: dict[str, Any] = {+ "run_as_user": username,+ "run_as_group": groupname,+ }+ return process_policy++def create_sandbox_sysop_card(sandbox_url: str,sandbox_type: str,@@ -644,6 +671,7 @@ def create_sandbox_sysop_card(startup_mode=startup_mode,shared_dir=shared_dir,)+ policy['process'] = build_process_policy()extra_params = {"policy": policy,"policy_mode": "append",@@ -675,7 +703,6 @@ def create_sandbox_sysop_card(gateway_config=gateway_config,)- fs_policy = policy.get("filesystem_policy", {}) if isinstance(policy, dict) else {}logger.info("[sysop_builder] sandbox SysOperationCard created:\n"" base_url=%s sandbox_type=%s\n"@@ -683,11 +710,7 @@ def create_sandbox_sysop_card(" idle_ttl=%s idle_check_interval=%s\n"" preserve_file_sharing_mode=%s\n"" excluded_commands(%d)=%s\n"- " filesystem_policy.files(%d)=%s\n"- " filesystem_policy.directories(%d)=%s\n"- " filesystem_policy.bind_mounts(%d)=%s\n"- " filesystem_policy.read_write(%d)=%s\n"- " filesystem_policy.read_only(%d)=%s\n"+ " policy=%s\n"" preserve_files_upload(%d)=%s\n"" policy_mode=%s",sandbox_url,@@ -698,16 +721,7 @@ def create_sandbox_sysop_card(_PRESERVE_FILE_SHARING_MODE,len(extra_params["excluded_commands"]),extra_params["excluded_commands"] or "[]",- len(fs_policy.get("files") or []),- fs_policy.get("files") or [],- len(fs_policy.get("directories") or []),- fs_policy.get("directories") or [],- len(fs_policy.get("bind_mounts") or []),- fs_policy.get("bind_mounts") or [],- len(fs_policy.get("read_write") or []),- fs_policy.get("read_write") or [],- len(fs_policy.get("read_only") or []),- fs_policy.get("read_only") or [],+ json.dumps(policy, ensure_ascii=False, indent=2),len(upload_list),upload_list or [],extra_params["policy_mode"],@@ -992,6 +1006,7 @@ def find_auto_managed_match(__all__ = ["PreserveFileSharingMode","build_filesystem_policy",+ "build_process_policy","build_yuanrong_sandbox_status_view","create_sandbox_sysop_card","create_local_sysop_card",