Skip to content

feat: add standalone web server mode#398

Closed
ZeroRegister wants to merge 176 commits intolbjlaq:mainfrom
ZeroRegister:main
Closed

feat: add standalone web server mode#398
ZeroRegister wants to merge 176 commits intolbjlaq:mainfrom
ZeroRegister:main

Conversation

@ZeroRegister
Copy link
Copy Markdown

  • Add axum-based REST API layer (web_api.rs)
  • Add standalone server binary (antigravity-server)
  • Add frontend Tauri compatibility layer (tauriCompat.ts)
  • Add HTTP request adapter with endpoint mapping (request.ts)
  • Update all components to use compatibility APIs
  • Add manual OAuth callback URL support for remote deployment
  • Add deployment documentation (DEPLOYMENT.md)
  • Add packaging script (package-server.sh)

⚠️ 本 PR 不影响默认 Tauri 桌面应用的编译和运行。Web Server 模式需要显式指定 --features web-server。

🚀 功能: 独立 Web 服务端模式

概述

本 PR 为 Antigravity Manager 添加了独立 Web 服务端模式,允许将应用部署到远程 Linux 服务器通过浏览器访问,无需 Tauri 桌面环境。

主要改动

后端

  • 新增 web_api.rs: axum REST API 层,封装所有 Tauri 命令为 HTTP 端点 (~40 个端点 + SSE)
  • 新增 main_server.rs: 独立二进制入口,支持命令行参数配置
  • 条件编译: 使用 feature flags (tauri-app / web-server) 分离代码路径

前端

  • 新增 tauriCompat.ts: Tauri API 兼容层 (事件/窗口/对话框/路径/opener)
  • 重构 request.ts: 自动检测运行环境,Tauri 用 IPC,Web 用 HTTP
  • 手动 OAuth 回调: 支持远程部署时粘贴回调 URL 完成登录

文档

  • 新增 DEPLOYMENT.md: 完整服务器部署教程
  • 更新 README.md: 添加 Web Server 模式说明
  • 新增 package-server.sh: 一键打包脚本

使用方式

# 编译
cargo build --release --bin antigravity-server --no-default-features --features web-server

# 启动
./antigravity-server --port 8765 --static-dir ../dist --data-dir ~/.antigravity

- 🔧 API 代理优化: 403 错误智能处理、Claude CLI 响应优化
- 🐛 Bug 修复: OAuth 环境检查优化
- 📝 文档更新: 更新 README 和更新日志
- 🧹 项目清理: 移除无用的测试文件和 Python 脚本
- 🔇 忽略  造成的空文本警告 (这是 Gemini 的内部思考过程)
- 🔧 移除  参数传递, 避免 Gemini 尝试调用工具导致
karasungur and others added 21 commits January 3, 2026 15:34
- Extract web search model to named constant for maintainability
- Add informative logging for tool injection decisions
- Add parse_error_count and last_valid_state tracking to StreamingState
- Implement handle_parse_error() for graceful degradation
- Add reset_error_state() for recovery after errors
- Include debug logging for troubleshooting
- Warn on high error rates (>5 errors)
- Add changelog for PR lbjlaq#289 (Claude Protocol Robustness Improvements)
- Add changelog for PR lbjlaq#285 (Dashboard Statistics Fix)
- Update version in all config files
- Update version display in Settings page
Configure git to normalize all text files to LF line endings.
This prevents CRLF/LF inconsistencies across different platforms.
Add SafetyThreshold enum and environment variable configuration
for Gemini API safety filters. Users can now control content
filtering via GEMINI_SAFETY_THRESHOLD environment variable.

Supported values: OFF, LOW, MEDIUM, HIGH, NONE

Default behavior (OFF) is preserved for backwards compatibility.
Add OutputConfig struct with effort field for Claude API v2.0.67+
compatibility. Maps Claude's output_config.effort values (high,
medium, low) to Gemini's effortLevel configuration.

Changes:
- Added OutputConfig struct to models.rs
- Added output_config field to ClaudeRequest
- Added effort level mapping in build_generation_config()
- Updated all test cases with output_config: None
Move background task model names to module-level constants for
better maintainability. This allows easier configuration and
centralized model management.

Changes:
- Added BACKGROUND_MODEL_LITE constant (gemini-2.5-flash-lite)
- Added BACKGROUND_MODEL_STANDARD constant (gemini-2.5-flash)
- Updated select_background_model() to use constants

Note: WEB_SEARCH_FALLBACK_MODEL was already a const in request.rs
Add automatic thinking mode enablement for Opus 4.5 models, matching
Claude Code v2.0.67+ behavior where thinking is enabled by default
for these models.

Changes:
- Added should_enable_thinking_by_default() function
- Opus 4.5 variants now auto-enable thinking when no config provided
- Models with "-thinking" suffix also get auto-enabled

This improves compatibility with Claude Code clients that expect
Opus 4.5 to use thinking mode by default.
Add randomized jitter (±20%) to all retry delay strategies to prevent
thundering herd problem when multiple requests fail simultaneously.

Changes:
- Added JITTER_FACTOR constant (0.2 = ±20%)
- Added apply_jitter() helper function
- Updated FixedDelay, LinearBackoff, and ExponentialBackoff to use jitter
- Enhanced logging to show both base and actual delay values

This improves stability under high load by distributing retry attempts
over time instead of synchronizing them.
Convert CRLF line endings to LF for consistency across platforms.
This ensures the .gitattributes configuration takes effect and
prevents future line ending inconsistencies.

Files normalized:
- src-tauri/src/proxy/handlers/openai.rs
- src-tauri/src/proxy/mappers/claude/streaming.rs
- src-tauri/src/proxy/mappers/openai/request.rs
- src-tauri/src/proxy/mappers/openai/streaming.rs
Fixes Issue lbjlaq#295 where Gemini 3 Pro rejects function calls without
thought_signature when thinking mode is enabled.

Changes:
- Add has_valid_signature_for_function_calls() helper function
- Add MIN_SIGNATURE_LENGTH constant (10 chars minimum)
- Auto-disable thinking mode if no valid signature available
- Prevents 400 "Function call is missing a thought_signature" errors
Fixes Issue lbjlaq#290 where Anthropic API rejects requests with
cache_control in thinking blocks causing "Extra inputs are not
permitted" errors.

Changes:
- Add deep_remove_cache_control() recursive JSON cleaner
- Apply cleanup before forwarding to Anthropic API
- Works regardless of serde annotations
Fixes tool calling issues where Gemini uses different parameter
names than Claude Code expects (e.g., "query" vs "pattern").

Changes:
- Add remap_function_call_args() for known tool remappings
- Handle Grep: query → pattern
- Handle Glob: query → pattern
- Handle Read: path → file_path
- Apply remapping in both streaming and non-streaming paths
Adds additional JSON Schema fields to the cleanup blacklist
for better compatibility with MCP tool definitions.

New fields added:
- $id: JSON Schema identifier
- contentEncoding: base64 encoding hint
- contentMediaType: MIME type hint
- deprecated: Gemini doesn't understand this
- readOnly, writeOnly: access modifiers
Captures thought_signature from thinking blocks immediately
rather than waiting for function calls, improving signature
availability for subsequent requests.

Changes:
- Store signature to global storage in process_thinking()
- Add debug logging for captured signatures
- Improves Issue lbjlaq#295 fix by ensuring signatures are available earlier
- Fix Issue lbjlaq#298: Opus 4.5 first request error
- Merge PR lbjlaq#296: Claude Code compatibility enhancements
- Extended signature validation to all first-time thinking requests
- Added cache_control recursive cleanup
- Added tool parameter remapping
- Added configurable safety settings
- Added effort parameter support
- Added retry jitter optimization
- Add axum-based REST API layer (web_api.rs)
- Add standalone server binary (antigravity-server)
- Add frontend Tauri compatibility layer (tauriCompat.ts)
- Add HTTP request adapter with endpoint mapping (request.ts)
- Update all components to use compatibility APIs
- Add manual OAuth callback URL support for remote deployment
- Add deployment documentation (DEPLOYMENT.md)
- Add packaging script (package-server.sh)
@jhao0413
Copy link
Copy Markdown

请问现在可以用了吗

@fishundbug
Copy link
Copy Markdown

等这个功能好久了,希望能出

@hzexe
Copy link
Copy Markdown

hzexe commented Jan 20, 2026

期待,no no-vnc的一天

@ranxi2001
Copy link
Copy Markdown

期待,上线蹲一下

@xylplm
Copy link
Copy Markdown

xylplm commented Jan 22, 2026

同样很期待,现在docker很不方便 @lbjlaq

@jhao0413
Copy link
Copy Markdown

@lbjlaq readme中可以加一下web mode的启动说明嘛~

@hzexe
Copy link
Copy Markdown

hzexe commented Jan 26, 2026

@lbjlaq docker 回调公网url长什么样,url的后半断能给个示例吗

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.