Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,9 @@ ONLY_COLLECT_CURRENT_USER_ATTACHMENTS=false
# 启动模式 (normal, headless, virtual_display, direct_debug_no_browser)
LAUNCH_MODE=normal

# 快速启动
DIRECT_LAUNCH=false

# =============================================================================
# API 默认参数配置
# =============================================================================
Expand Down Expand Up @@ -204,4 +207,4 @@ USER_INPUT_END_MARKER_SERVER=__USER_INPUT_END__
# 流超时日志状态配置
STREAM_MAX_INITIAL_ERRORS=3
STREAM_WARNING_INTERVAL_AFTER_SUPPRESS=60.0
STREAM_SUPPRESS_DURATION_AFTER_INITIAL_BURST=400.0
STREAM_SUPPRESS_DURATION_AFTER_INITIAL_BURST=400.0
12 changes: 12 additions & 0 deletions docs/env-variables-reference.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,18 @@

---

## 启动配置

### DIRECT_LAUNCH

- **用途**: 快速启动
- **类型**: 布尔值
- **默认值**: `false`
- **示例**: `DIRECT_LAUNCH=false`
- **说明**: 跳过等待选项超时,直接使用默认选项快速启动

---

## 代理配置

### HTTP_PROXY
Expand Down
6 changes: 6 additions & 0 deletions docs/environment-configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,12 @@ ENDPOINT_CAPTURE_TIMEOUT=45
STREAM_PORT=3120
```

### 启动配置
```env
# 快速启动
DIRECT_LAUNCH=false
```

### 代理配置

```env
Expand Down
1 change: 1 addition & 0 deletions launcher/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
HTTPS_PROXY = os.environ.get("HTTPS_PROXY", "")
LOG_DIR = os.path.join(os.path.dirname(os.path.dirname(__file__)), "logs")
LAUNCHER_LOG_FILE_PATH = os.path.join(LOG_DIR, "launch_app.log")
DIRECT_LAUNCH = os.environ.get("DIRECT_LAUNCH", False)

# --- WebSocket 端点正则表达式 ---
import re
Expand Down
95 changes: 54 additions & 41 deletions launcher/runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
SAVED_AUTH_DIR,
determine_proxy_configuration,
parse_args,
DIRECT_LAUNCH
)
from launcher.internal import run_internal_camoufox
from launcher.logging_setup import setup_launcher_logging
Expand Down Expand Up @@ -77,7 +78,8 @@ def run(self):

self._check_deprecated_auth_file()
self._determine_launch_mode()
self._handle_auth_file_selection()
if not DIRECT_LAUNCH:
self._handle_auth_file_selection()
self._check_xvfb()
self._check_server_port()

Expand Down Expand Up @@ -158,6 +160,12 @@ def _determine_launch_mode(self):
"3" if platform.system() == "Linux" else "1"
)

if DIRECT_LAUNCH:
self.final_launch_mode = (
default_mode_from_env or "headless"
)
return

logger.info("--- 请选择启动模式 (未通过命令行参数指定) ---")
if env_launch_mode and default_mode_from_env:
logger.info(
Expand Down Expand Up @@ -443,47 +451,52 @@ def _resolve_auth_file_path(self):
if available_profiles:
# 对可用配置文件列表进行排序,以确保一致的显示顺序
available_profiles.sort(key=lambda x: x["name"])
print("-" * 60 + "\n 找到以下可用的认证文件:", flush=True)
for i, profile in enumerate(available_profiles):
print(f" {i + 1}: {profile['name']}", flush=True)
print(
" N: 不加载任何文件 (使用浏览器当前状态)\n" + "-" * 60,
flush=True,
)
choice = input_with_timeout(
f" 请选择要加载的认证文件编号 (输入 N 或直接回车则不加载, {self.args.auth_save_timeout}s超时): ",
self.args.auth_save_timeout,
)
if choice.strip().lower() not in ["n", ""]:
try:
choice_index = int(choice.strip()) - 1
if 0 <= choice_index < len(available_profiles):
selected_profile = available_profiles[choice_index]
self.effective_active_auth_json_path = selected_profile[
"path"
]
logger.info(
f" 已选择加载认证文件: {selected_profile['name']}"
)
print(
f" 已选择加载: {selected_profile['name']}",
flush=True,
)
else:
logger.info(
" 无效的选择编号或超时。将不加载认证文件。"
)
print(
" 无效的选择编号或超时。将不加载认证文件。",
flush=True,
)
except ValueError:
logger.info(" 无效的输入。将不加载认证文件。")
print(" 无效的输入。将不加载认证文件。", flush=True)
if DIRECT_LAUNCH:
selected_profile = available_profiles[0]
self.effective_active_auth_json_path = selected_profile["path"]
logger.info(f" 快速启动:自动选择第一个可用认证文件: {selected_profile['name']}")
else:
logger.info(" 好的,不加载认证文件或超时。")
print(" 好的,不加载认证文件或超时。", flush=True)
print("-" * 60, flush=True)
print("-" * 60 + "\n 找到以下可用的认证文件:", flush=True)
for i, profile in enumerate(available_profiles):
print(f" {i + 1}: {profile['name']}", flush=True)
print(
" N: 不加载任何文件 (使用浏览器当前状态)\n" + "-" * 60,
flush=True,
)
choice = input_with_timeout(
f" 请选择要加载的认证文件编号 (输入 N 或直接回车则不加载, {self.args.auth_save_timeout}s超时): ",
self.args.auth_save_timeout,
)
if choice.strip().lower() not in ["n", ""]:
try:
choice_index = int(choice.strip()) - 1
if 0 <= choice_index < len(available_profiles):
selected_profile = available_profiles[choice_index]
self.effective_active_auth_json_path = selected_profile[
"path"
]
logger.info(
f" 已选择加载认证文件: {selected_profile['name']}"
)
print(
f" 已选择加载: {selected_profile['name']}",
flush=True,
)
else:
logger.info(
" 无效的选择编号或超时。将不加载认证文件。"
)
print(
" 无效的选择编号或超时。将不加载认证文件。",
flush=True,
)
except ValueError:
logger.info(" 无效的输入。将不加载认证文件。")
print(" 无效的输入。将不加载认证文件。", flush=True)
else:
logger.info(" 好的,不加载认证文件或超时。")
print(" 好的,不加载认证文件或超时。", flush=True)
print("-" * 60, flush=True)
else:
logger.info(" 未找到认证文件。将使用浏览器当前状态。")
print(" 未找到认证文件。将使用浏览器当前状态。", flush=True)
Expand Down