diff --git a/portable/Mac-Start.command b/portable/Mac-Start.command index 80cfc7c..815c22d 100755 --- a/portable/Mac-Start.command +++ b/portable/Mac-Start.command @@ -95,6 +95,11 @@ fi export OPENCLAW_HOME="$DATA_DIR" export OPENCLAW_STATE_DIR="$STATE_DIR" export OPENCLAW_CONFIG_PATH="$CONFIG_FILE" +# U-Claw opens the local dashboard directly; disable mDNS/Bonjour discovery. +# On macOS the bonjour plugin auto-starts and advertises the gateway on the LAN +# (_openclaw-gw._tcp.local), which is unnecessary for local use and triggers +# "no IPv4 address available on utunN" warnings on machines with VPN/Tailscale. +export OPENCLAW_DISABLE_BONJOUR=1 # ---- 7. Check dependencies ---- if [ ! -d "$CORE_DIR/node_modules" ]; then @@ -148,17 +153,38 @@ OPENCLAW_MJS="$CORE_DIR/node_modules/openclaw/openclaw.mjs" "$NODE_BIN" "$OPENCLAW_MJS" gateway run --allow-unconfigured --force --port $PORT & GW_PID=$! -# ---- 11. Wait for gateway, then open browser ---- -for i in $(seq 1 30); do - sleep 0.5 +# ---- 11. 是否已配置模型?openclaw.json 含 "providers" 即视为已配置 (issue #24) ---- +# 已配置:只开 Dashboard,不再每次弹配置页。未配置(首次):开 Config Center 引导填 Key。 +MODEL_CONFIGURED=0 +if grep -q '"providers"' "$CONFIG_FILE" 2>/dev/null; then + MODEL_CONFIGURED=1 +fi + +# ---- 12. Wait for gateway, then open browser ---- +# 首次启动会 staging ~35 个 bundled deps,慢盘上实测可达 90 秒以上,期间端口还没 +# LISTENING。轮询上限必须覆盖这段,否则浏览器在 gateway ready 前就放弃打开,用户 +# 看到"拒绝连接"以为坏了(同 Windows issue #46/#48)。最多等 ~3 分钟(180×1s)。 +echo -e " ${YELLOW}首次启动需准备运行环境,约 30-90 秒,请稍候...${NC}" +GATEWAY_READY=0 +for i in $(seq 1 180); do if curl -s -o /dev/null "http://127.0.0.1:$PORT/" 2>/dev/null; then - # Open Dashboard - open "http://127.0.0.1:$PORT/#token=uclaw" 2>/dev/null || true - # Open Config Center - open "http://127.0.0.1:18788/" 2>/dev/null || true + GATEWAY_READY=1 + if [ "$MODEL_CONFIGURED" = "1" ]; then + # 已配置:只开 Dashboard + open "http://127.0.0.1:$PORT/#token=uclaw" 2>/dev/null || true + else + # 首次:开 Config Center 引导填 Key + open "http://127.0.0.1:18788/" 2>/dev/null || true + fi break fi + sleep 1 done +if [ "$GATEWAY_READY" != "1" ]; then + # 超时回退:gateway 还没就绪也别让用户干等,先开 Config Center + echo -e " ${YELLOW}Gateway 启动较慢,先打开配置中心...${NC}" + open "http://127.0.0.1:18788/" 2>/dev/null || true +fi echo -e " ${GREEN}════════════════════════════════${NC}" echo -e " ${GREEN}🦞 U-Claw is running!${NC}" diff --git a/portable/setup.sh b/portable/setup.sh index 000e34d..3907326 100755 --- a/portable/setup.sh +++ b/portable/setup.sh @@ -131,9 +131,12 @@ PKGJSON fi # Install with China mirror(缓存留盘内,拔盘不留痕) + # --ignore-scripts 必须加:openclaw 的 preinstall 脚本会调系统 `node`,但便携版 + # 用的是 app/runtime 下的 node(不在 PATH),未装 Node 的 Mac 用户会因 + # "node: command not found" 安装失败 (code 127)。与 Mac-Start.command 的 fallback 对齐。 NODE_BIN="$NODE_TARGET/bin/node" NPM_BIN="$NODE_TARGET/bin/npm" - npm_config_cache="$APP_DIR/.npm-cache" "$NODE_BIN" "$NPM_BIN" install --prefix "$CORE_DIR" --registry="$MIRROR" + npm_config_cache="$APP_DIR/.npm-cache" "$NODE_BIN" "$NPM_BIN" install --prefix "$CORE_DIR" --registry="$MIRROR" --ignore-scripts --no-audit --no-fund --omit=dev echo -e " ${GREEN}✓${NC} OpenClaw 安装完成" fi @@ -145,7 +148,7 @@ else echo -e " ${CYAN}↓${NC} 安装 QQ 插件..." NODE_BIN="$NODE_TARGET/bin/node" NPM_BIN="$NODE_TARGET/bin/npm" - npm_config_cache="$APP_DIR/.npm-cache" "$NODE_BIN" "$NPM_BIN" install @sliverp/qqbot@latest --prefix "$CORE_DIR" --registry="$MIRROR" 2>/dev/null || true + npm_config_cache="$APP_DIR/.npm-cache" "$NODE_BIN" "$NPM_BIN" install @sliverp/qqbot@latest --prefix "$CORE_DIR" --registry="$MIRROR" --ignore-scripts --no-audit --no-fund --omit=dev 2>/dev/null || true echo -e " ${GREEN}✓${NC} QQ 插件安装完成" fi