Repository navigation
fix: harden browser-tool linux recovery - #867
Conversation
📝 WalkthroughWalkthroughThis PR updates the relay server package to version 0.1.16 and refactors Chrome process detection and launch logic across multiple files. Changes include conditional extension options page opening in the background script, improved SingletonLock-based process detection with PID validation, centralized Chrome launch arguments, and new Linux GUI environment setup helpers. Changes
Estimated code review effort🎯 4 (Complex) | ⏱️ ~50 minutes Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (2)
deps/browser/relay-server/src/tool-cli.ts (1)
33-50: Consider validating that the selected Xauthority file exists.The function selects the lexicographically last
.mutter-Xwaylandauth.*file, which works for typical naming patterns. However, there's no existence check before returning the path.♻️ Optional: Add existence validation
function resolveLinuxXauthority(): string | null { const runtimeDir = getLinuxRuntimeDir(); try { const candidates = fs .readdirSync(runtimeDir) .filter((name) => name.startsWith(".mutter-Xwaylandauth.")); if (candidates.length === 0) { return null; } candidates.sort(); - return `${runtimeDir}/${candidates[candidates.length - 1]}`; + const selected = `${runtimeDir}/${candidates[candidates.length - 1]}`; + return fs.existsSync(selected) ? selected : null; } catch { return null; } }🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@deps/browser/relay-server/src/tool-cli.ts` around lines 33 - 50, The resolveLinuxXauthority function may return a path that no longer exists; after selecting the lexicographically last candidate from candidates (from readdirSync and filter), validate that the resolved path exists (e.g., via fs.existsSync or fs.statSync) before returning it and otherwise return null; update resolveLinuxXauthority to construct the fullPath (using getLinuxRuntimeDir() + candidate) and verify existence, falling back to null if the file is missing.deps/browser/relay-server/src/tool.ts (1)
83-118: Extract shared functions to a common module.
isChromeRunning()andgetChromeUserDataDir()are duplicated nearly identically incli.ts(lines 150-186). Consider extracting these to a shared utility module to avoid drift between implementations.♻️ Suggested approach
Create a shared module like
chrome-utils.ts:// chrome-utils.ts import * as fs from "node:fs"; import * as path from "node:path"; import * as os from "node:os"; export function getChromeUserDataDir(): string { const defaultDir = path.join(os.homedir(), ".config", "google-chrome"); if (fs.existsSync(defaultDir)) { return defaultDir; } return path.join(os.homedir(), ".wegent-executor", "browser", "chrome-profile"); } export function isChromeRunning(): boolean { const userDataDir = getChromeUserDataDir(); const lockFile = path.join(userDataDir, "SingletonLock"); try { const stats = fs.lstatSync(lockFile); if (!stats.isSymbolicLink() && !stats.isFile()) { return false; } if (stats.isSymbolicLink()) { const target = fs.readlinkSync(lockFile); const match = target.match(/-(\d+)$/); if (match) { try { process.kill(Number(match[1]), 0); } catch { try { fs.unlinkSync(lockFile); } catch { /* ignore */ } return false; } } } return true; } catch { return false; } }Then import from both
tool.tsandcli.ts.🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@deps/browser/relay-server/src/tool.ts` around lines 83 - 118, isChromeRunning() and getChromeUserDataDir() are duplicated; extract them into a shared utility module (e.g., chrome-utils.ts) that exports getChromeUserDataDir and isChromeRunning, move the implementation from tool.ts into that module, then replace the local implementations in both tool.ts and cli.ts with imports from the new module (update any relative import paths accordingly) so both files call the same exported functions.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In `@deps/browser/relay-server/src/tool-cli.ts`:
- Around line 33-50: The resolveLinuxXauthority function may return a path that
no longer exists; after selecting the lexicographically last candidate from
candidates (from readdirSync and filter), validate that the resolved path exists
(e.g., via fs.existsSync or fs.statSync) before returning it and otherwise
return null; update resolveLinuxXauthority to construct the fullPath (using
getLinuxRuntimeDir() + candidate) and verify existence, falling back to null if
the file is missing.
In `@deps/browser/relay-server/src/tool.ts`:
- Around line 83-118: isChromeRunning() and getChromeUserDataDir() are
duplicated; extract them into a shared utility module (e.g., chrome-utils.ts)
that exports getChromeUserDataDir and isChromeRunning, move the implementation
from tool.ts into that module, then replace the local implementations in both
tool.ts and cli.ts with imports from the new module (update any relative import
paths accordingly) so both files call the same exported functions.
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 8fb5fbe4-45bd-497c-9a82-e3831a98e22f
⛔ Files ignored due to path filters (1)
deps/browser/relay-server/package-lock.jsonis excluded by!**/package-lock.json
📒 Files selected for processing (5)
deps/browser/relay-server/chrome-extension/background.jsdeps/browser/relay-server/package.jsondeps/browser/relay-server/src/cli.tsdeps/browser/relay-server/src/tool-cli.tsdeps/browser/relay-server/src/tool.ts
Co-authored-by: sifang <sifang@staff.weibo.com>
* feat: add workspace archive and recovery for Pod deletion Implement Pod recovery feature that allows users to continue conversations after executor Pods are deleted: - Add ArchiveInfo schema to store archive metadata in Task.status.archive - Add workspace_archive service for MinIO presigned URL generation - Add archive/restore endpoints in executor and executor_manager - Add ExecutorRecoveryService for Pod recreation with workspace restoration - Add skip_git_clone support to prevent git clone conflicts during restore - Add Celery Beat scheduled task for expired archive cleanup (30-day retention) - Integrate archive workflow in executor_job before Pod deletion Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * fix(backend): add missing minio dependency Add minio package to backend dependencies for workspace archive storage. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * feat(admin): add created_at field to device monitor list (#846) - Add created_at field to AdminDeviceInfo schema in backend - Add created_at to AdminDeviceInfo TypeScript interface - Display creation time in device list UI - Add i18n translations for created_at column (zh-CN and en) Co-authored-by: yunpeng7 <yunpeng7@staff.weibo.com> Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com> * perf: use async heartbeat (#849) * fix(chat_shell): prevent orphaned tool call IDs in group chat history (#852) * fix(chat_shell): prevent tool call group splitting in group chat history truncation _truncate_history blindly sliced the flat message list, which could split assistant+tool_calls and their tool response messages across the truncation boundary. This produced orphaned function_call_output items without matching function_call entries in the OpenAI Responses API format, causing 'No tool call found for function call output' errors. Add _group_messages() to treat assistant+tool_calls+tool responses as atomic units, and modify _truncate_history() to truncate by groups instead of individual messages. * fix(chat_shell): ensure tool call group integrity across all compression paths Extract group_tool_call_messages() into shared messages/utils.py and apply atomic group handling to: - HistoryTruncationStrategy.compress(): adjust first/last boundaries to avoid splitting tool call groups, add post-removal orphan cleanup - _force_compression_to_target(): Step 2 removes middle groups instead of individual messages, Step 5 keeps first/last groups - Refactor loader.py to import shared utility instead of inline helper All 95 related tests pass. Comprehensive audit confirms no other code paths in chat_shell break tool call group integrity. * test(chat_shell): add tool-call group truncation regressions Add regression coverage for preserving assistant tool calls with their matching tool results across group-chat history truncation, history compression boundaries, and forced compression fallback paths. * fix: 在里面智能体的创建人和机器人的创建人不是一个人时会报错 (#853) * docs: update contributors list * docs: update contributors list (zh) * docs: update contributors list * docs: update contributors list (zh) * fix: 在里面智能体的创建人和机器人的创建人不是一个人时会报错 * fix: 迁移其他的sql到kindReader --------- Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> Co-authored-by: hongyu9 <hongyu9@staff.weibo.com> * fix: fail fast on invalid tool call IDs across chat protocols (#854) * fix: 订阅任务执行间隔调整 & trace http接口的匹配规则调整 (#855) * docs: update contributors list * docs: update contributors list (zh) * docs: update contributors list * docs: update contributors list (zh) * fix: telemetry的匹配规则调整 * fix: 订阅任务执行间隔调整 * fix: 调整逻辑 --------- Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> Co-authored-by: hongyu9 <hongyu9@staff.weibo.com> * fix: sanitize PyInstaller LD_LIBRARY_PATH for child processes (#859) PyInstaller's bootloader prepends its extraction directory (/tmp/_MEIxxxxxx) to LD_LIBRARY_PATH, causing child processes (Claude Code, shell commands) to load wrong shared libraries (e.g., libtinfo.so.6). Extract `sanitize_ld_library_path()` into platform_compat and apply it in both local_mode_strategy (Claude SDK subprocess) and extension_handler (extension script subprocess) to restore the original library path. See: https://pyinstaller.org/en/stable/common-issues-and-pitfalls.html Co-authored-by: sifang <sifang@staff.weibo.com> * refactor(rag): move internal retrieve routing into backend (#847) * refactor(rag): move internal retrieve routing into backend * refactor(rag): move retrieve persistence into backend * refactor(rag): move kb head persistence into backend * fix(rag): tighten backend retrieve routing * refactor(rag): simplify token estimation fallback * refactor(rag): batch route token estimation * fix(rag): token estimator decimal * fix(rag): harden kb read persistence * frontend: show 'indexing' status for documents pending indexing (#858) * fix(frontend): show 'indexing' status for documents pending indexing When a document is uploaded, is_active is false while indexing is in progress. Previously, this showed 'index unavailable' which was misleading. Now documents with status='enabled' but is_active=false will show 'indexing' instead of 'index unavailable', matching the existing translation key. Changes: - Updated compact mode status indicator (line 247) - Updated normal mode status badge (line 461) Fixes: knowledge base document shows 'index unavailable' during indexing * fix(i18n): update Developer role description in Chinese locale * fix: 修复订阅器中脏数据导致的无法展示的问题 (#860) * docs: update contributors list * docs: update contributors list (zh) * docs: update contributors list * docs: update contributors list (zh) * fix: 修复订阅器中脏数据导致的无法展示的问题 --------- Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> Co-authored-by: hongyu9 <hongyu9@staff.weibo.com> * feat(backend): add knowledge base RAG support to /v1/responses API (#844) * feat(backend): add knowledge base RAG support to /v1/responses API Implement knowledge base Q&A functionality for the OpenAI-compatible /v1/responses endpoint with the following changes: Schema Changes: - Add knowledge_base_names field to WegentTool schema - Support namespace#name format for KB specification New Services: - KnowledgeBaseNameResolver: resolves KB display names to IDs with permission checking via TaskKnowledgeBaseService - KnowledgeBaseContextCreator: creates SubtaskContext records for API-specified KBs to integrate with existing RAG pipeline Integration: - Extend parse_wegent_tools() to handle knowledge_base tool type - Add parse_knowledge_base_name() for namespace#name parsing - Modify build_execution_request() to accept knowledge_base_names - Add _create_kb_contexts_from_api_request() for KB context injection - Update openapi_responses.py endpoints to pass KB names parameter Testing: - Add comprehensive unit tests for KB name resolution - Add tests for KB context creation - Add tests for helper functions with KB support - All 32 new tests passing The implementation reuses the existing RAG flow through prepare_contexts_for_chat() and KnowledgeBaseTool, ensuring consistency with the web UI behavior. * refactor(kb_resolver): optimize database query complexity from O(n) to O(m) - Add batch_get_knowledge_base_by_names() to TaskKnowledgeBaseService for efficient batch queries - Extract _check_kb_access_permission() for unified permission checking logic - Update kb_resolver to use service methods instead of direct queries - Reduce DB queries from O(n) to O(m) where m is unique namespace count - Update tests to mock service methods instead of internal functions All 15 tests pass. * refactor(backend): optimize KB permission check in kb_resolver Simplify permission checking by using get_all_knowledge_bases_grouped() which already returns all KBs accessible to the user. Changes: - Replace _batch_query_kbs() and _check_kb_access_permission() with _get_accessible_kb_lookup() that builds a lookup dict from grouped results - Remove unused resolve_single() method and batch_get_knowledge_base_by_names() - Update tests to mock KnowledgeService.get_all_knowledge_bases_grouped() This reduces database queries and simplifies the permission check logic. * feat(backend): integrate knowledge base context creation into unified AI trigger - Add knowledge_base_names parameter to build_execution_request for OpenAPI v1/responses - Create _create_kb_contexts_from_api_request helper to process KB names from API requests - Integrate KB context processing into unified trigger flow - Add KnowledgeBaseContextCreator class for creating SubtaskContext records - Add comprehensive unit tests for KnowledgeBaseContextCreator This enables RAG functionality for OpenAPI v1/responses endpoint by creating SubtaskContext records that are processed by the existing context pipeline. * fix(chat): propagate HTTPException from KnowledgeBaseNameResolver in unified trigger - Add HTTPException import from fastapi - Catch and re-raise HTTPException explicitly in _create_kb_contexts_from_api_request - Keep generic exception handling for non-HTTP exceptions to preserve best-effort behavior - This ensures 403/404 errors from KB resolution are properly propagated to callers instead of being swallowed and logged as warnings * fix(chat_shell): use model_type for provider detection instead of model_id (#861) - Extract shared detect_provider() into models/providers.py with PROVIDER_ALIASES as single source of truth - model_type (env.model) is authoritative; raise ValueError on unknown - Remove _PROVIDER_ID_PATTERNS model_id prefix fallback (same model_id can serve multiple protocols) - Unify truncation notice logic for all providers (no system-role notice in middle of messages, preventing Anthropic non-consecutive system message errors) - Pass model_type from model_config through MessageCompressor to TokenCounter for accurate provider detection - Remove duplicate provider constants from factory.py and token_counter.py Co-authored-by: wenbo17 <wenbo17@staff.weibo.com> * ix: claude的子代理模式不可用修复 (#862) * docs: update contributors list * docs: update contributors list (zh) * docs: update contributors list * docs: update contributors list (zh) * fix: claude的子代理模式不可用修复 --------- Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> Co-authored-by: hongyu9 <hongyu9@staff.weibo.com> * feat(inbox): implement work queue and message forwarding system (#851) * feat(inbox): implement work queue and message forwarding system Add a comprehensive message forwarding and work queue system that enables users to forward conversation messages to other users. Recipients can manage received messages through work queues and optionally configure AI agents for automatic processing. Backend changes: - Add QueueMessage and RecentContact database models - Add WorkQueue CRD schema stored in kinds table - Implement work queue services for CRUD operations - Implement message forwarding service with queue selection - Add WebSocket events for real-time notifications - Add API endpoints for work queue management - Add ForbiddenException to core exceptions Frontend changes: - Add inbox page with queue sidebar and message list - Implement ForwardMessageDialog for recipient selection - Add queue edit/create dialog with auto-processing config - Add message detail dialog with content preview - Add i18n translations (zh-CN and en) - Register inbox route and navigation * fix: resolve lint errors in inbox feature - Remove unused imports (RefreshCw, Settings, Menu, Button, Input, Clock) - Format Python files with Black * fix: resolve TypeScript errors in inbox feature - Add 'flow' and 'inbox' to TopNavigation activePage type - Replace Badge variant 'outline' with 'info' (outline not supported) * fix: address CodeRabbit review comments for work queue feature - Fix status parameter shadowing fastapi status module in work_queue.py - Fix NamespaceMember.namespace to use group_name column reference - Replace func.json_set with Python-level update for PostgreSQL compatibility - Fix refreshQueues dependency loop using functional state update - Remove Chinese text from inbox page comment - Add NaN validation for schedule interval input - Replace clickable Badge with accessible button for recent contacts --------- Co-authored-by: qdaxb <4157870+qdaxb@users.noreply.github.com> * Wegent/work queue and message forwarding (#863) * feat(inbox): implement work queue and message forwarding system Add a comprehensive message forwarding and work queue system that enables users to forward conversation messages to other users. Recipients can manage received messages through work queues and optionally configure AI agents for automatic processing. Backend changes: - Add QueueMessage and RecentContact database models - Add WorkQueue CRD schema stored in kinds table - Implement work queue services for CRUD operations - Implement message forwarding service with queue selection - Add WebSocket events for real-time notifications - Add API endpoints for work queue management - Add ForbiddenException to core exceptions Frontend changes: - Add inbox page with queue sidebar and message list - Implement ForwardMessageDialog for recipient selection - Add queue edit/create dialog with auto-processing config - Add message detail dialog with content preview - Add i18n translations (zh-CN and en) - Register inbox route and navigation * fix: resolve lint errors in inbox feature - Remove unused imports (RefreshCw, Settings, Menu, Button, Input, Clock) - Format Python files with Black * fix: resolve TypeScript errors in inbox feature - Add 'flow' and 'inbox' to TopNavigation activePage type - Replace Badge variant 'outline' with 'info' (outline not supported) * fix: address CodeRabbit review comments for work queue feature - Fix status parameter shadowing fastapi status module in work_queue.py - Fix NamespaceMember.namespace to use group_name column reference - Replace func.json_set with Python-level update for PostgreSQL compatibility - Fix refreshQueues dependency loop using functional state update - Remove Chinese text from inbox page comment - Add NaN validation for schedule interval input - Replace clickable Badge with accessible button for recent contacts * feat: update work queue --------- Co-authored-by: qdaxb <4157870+qdaxb@users.noreply.github.com> * fix: fix column default value * fix: fix forward message click * feat: remove unused area * feat: add inbox default message * fix: 修复脏数据导致的订阅任务无法执行的问题 (#865) * docs: update contributors list * docs: update contributors list (zh) * docs: update contributors list * docs: update contributors list (zh) * fix: 修复脏数据导致的订阅任务无法执行的问题 --------- Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> Co-authored-by: hongyu9 <hongyu9@staff.weibo.com> * fix(browser): harden browser-tool linux recovery (#867) Co-authored-by: sifang <sifang@staff.weibo.com> * fix: 修复无法使用自定义镜像以及自定义镜像无法校验的问题 (#866) * docs: update contributors list * docs: update contributors list (zh) * docs: update contributors list * docs: update contributors list (zh) * fix: 修复无法使用自定义镜像 * fix: 修复无法使用自定义镜像以及自定义镜像无法校验的问题 * fix: 修复可能的bug --------- Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> Co-authored-by: hongyu9 <hongyu9@staff.weibo.com> * fix: fix welcome timezone (#868) * docs: update inbox docs (#869) * fix: 修复单测 (#870) * docs: update contributors list * docs: update contributors list (zh) * docs: update contributors list * docs: update contributors list (zh) * fix: 修复单测 --------- Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> Co-authored-by: hongyu9 <hongyu9@staff.weibo.com> * fix: fix page error (#871) * fix: data-roleid="api-key-create-button" not in html attr (#873) * fix: 修复停止按钮偶发变成发送的问题 & 修复失败的消息会丢失的问题 (#876) * docs: update contributors list * docs: update contributors list (zh) * docs: update contributors list * docs: update contributors list (zh) * fix: 修复停止按钮偶发变成发送的问题 * fix: 修复失败的消息会丢失的问题 * fix: 修复类型报错 * fix: 修复前端复制按钮内容错误的问题 --------- Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> Co-authored-by: hongyu9 <hongyu9@staff.weibo.com> * fix: 修复“skill not found” (#877) * docs: update contributors list * docs: update contributors list (zh) * docs: update contributors list * docs: update contributors list (zh) * fix: 技能错乱 --------- Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> Co-authored-by: hongyu9 <hongyu9@staff.weibo.com> * chore(executor): upgrade claude-agent-sdk from 0.1.31 to 0.1.51 (#880) Co-authored-by: sifang <sifang@staff.weibo.com> * feat(frontend): add HTML attachment preview and share link generation (#872) - Add HtmlPreview component for previewing HTML files with iframe and source view modes - Update FilePreview to support HTML file type detection and rendering - Add createAttachmentShareLink API for generating public share links - Add share button to FilePreviewDialog and FilePreviewPage (visible for owners only) - Add Web Page type label and icon for HTML attachments in AttachmentCard - Fix preview page height to fill viewport using h-screen and h-full - Update AttachmentPreview to support HTML file preview button Fixes share link browsing and download for table-type attachments * fix(knowledge): harden document indexing state (#875) * fix(knowledge): harden document indexing state * fix(knowledge): harden indexing state transitions * fix(knowledge): tighten reindex review followups * fix(rag): KNOWLEDGE_INDEX_LOCK_MAX_RETRIES=1 * fix(knowledge): store index status without db enum * fix(alembic): correct migration revision metadata * docs: update contributors list (zh) (#879) Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> * docs: update contributors list (#878) Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> * feat: 支持skill认证 (#882) * docs: update contributors list * docs: update contributors list (zh) * docs: update contributors list * docs: update contributors list (zh) * docs: add skill http identity design and plan * feat(skill): add http identity token flow * feat: 修改样式 * feat: 修改样式 * feat: 移除计划 * feat: 调整为带有认证的接口 --------- Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> Co-authored-by: hongyu9 <hongyu9@staff.weibo.com> # Conflicts: # executor_manager/services/sandbox/manager.py * Feature/knowledge document read (#888) * docs(backend): add knowledge document read spec and plan * feat(backend): add orchestrated knowledge document reads * fix(backend): tighten knowledge document read handling * refactor(web-scraper): add configuration for specific sites that require special handling (#884) * refactor(web-scraper): extract site-specific config to scraper_config.py - Add scraper_config.py for site-specific crawling configurations * fix(web_scraper): load WEB_SCRAPER_SITE_CONFIG from Pydantic settings instead of os.environ - Add WEB_SCRAPER_SITE_CONFIG to Settings class in config.py - Refactor scraper_config.py to use settings.WEB_SCRAPER_SITE_CONFIG with proper logging - Replace module-level config loading with cached get_site_config() function - Update scraper_service.py to use new get_site_config() function - Add detailed logging for site config matching and application - Fix remove_overlay_elements duplicate key in CrawlerRunConfig This ensures the configuration is properly loaded from .env file via Pydantic settings." * refactor(backend): improve scraper_config security and type safety - Remove sensitive config value from INFO level logging - Add return type annotations to _load_site_config and get_site_config - Replace broad Exception catch with specific exception types (AttributeError, KeyError, TypeError, ValueError) - Import Dict and Any from typing module * refactor(backend): replace auto-cleanup with archive expiration check Remove automatic MinIO archive cleanup (Celery Beat task) and instead block task execution when workspace archive has expired (>30 days). Users will receive a clear error message and must create a new task. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * feat: 添加恢复行为测试和脚本路径修正 * fix: 使用 timezone.utc 替换 UTC 以确保时区正确 * test(backend): fix workspace recovery test patches --------- Co-authored-by: yunpeng7 <yunpeng7@staff.weibo.com> Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com> Co-authored-by: axb <qindi@staff.weibo.com> Co-authored-by: moqimoqidea <39821951+moqimoqidea@users.noreply.github.com> Co-authored-by: MicroLee <yudexiaozhou@gmail.com> Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> Co-authored-by: hongyu9 <hongyu9@staff.weibo.com> Co-authored-by: icycrystal4 <icycrystal4@gmail.com> Co-authored-by: sifang <sifang@staff.weibo.com> Co-authored-by: Yanhe <yanhe1@staff.weibo.com> Co-authored-by: parabala <chenyong1@staff.weibo.com> Co-authored-by: wenbo17 <wenbo17@staff.weibo.com> Co-authored-by: qdaxb <4157870+qdaxb@users.noreply.github.com> Co-authored-by: 李枨煊 <chengxuan@staff.weibo.com> Co-authored-by: johnny0120 <jiangyang7@staff.weibo.com> Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
* feat: add workspace archive and recovery for Pod deletion Implement Pod recovery feature that allows users to continue conversations after executor Pods are deleted: - Add ArchiveInfo schema to store archive metadata in Task.status.archive - Add workspace_archive service for MinIO presigned URL generation - Add archive/restore endpoints in executor and executor_manager - Add ExecutorRecoveryService for Pod recreation with workspace restoration - Add skip_git_clone support to prevent git clone conflicts during restore - Add Celery Beat scheduled task for expired archive cleanup (30-day retention) - Integrate archive workflow in executor_job before Pod deletion Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * fix(backend): add missing minio dependency Add minio package to backend dependencies for workspace archive storage. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * feat(admin): add created_at field to device monitor list (#846) - Add created_at field to AdminDeviceInfo schema in backend - Add created_at to AdminDeviceInfo TypeScript interface - Display creation time in device list UI - Add i18n translations for created_at column (zh-CN and en) Co-authored-by: yunpeng7 <yunpeng7@staff.weibo.com> Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com> * perf: use async heartbeat (#849) * fix(chat_shell): prevent orphaned tool call IDs in group chat history (#852) * fix(chat_shell): prevent tool call group splitting in group chat history truncation _truncate_history blindly sliced the flat message list, which could split assistant+tool_calls and their tool response messages across the truncation boundary. This produced orphaned function_call_output items without matching function_call entries in the OpenAI Responses API format, causing 'No tool call found for function call output' errors. Add _group_messages() to treat assistant+tool_calls+tool responses as atomic units, and modify _truncate_history() to truncate by groups instead of individual messages. * fix(chat_shell): ensure tool call group integrity across all compression paths Extract group_tool_call_messages() into shared messages/utils.py and apply atomic group handling to: - HistoryTruncationStrategy.compress(): adjust first/last boundaries to avoid splitting tool call groups, add post-removal orphan cleanup - _force_compression_to_target(): Step 2 removes middle groups instead of individual messages, Step 5 keeps first/last groups - Refactor loader.py to import shared utility instead of inline helper All 95 related tests pass. Comprehensive audit confirms no other code paths in chat_shell break tool call group integrity. * test(chat_shell): add tool-call group truncation regressions Add regression coverage for preserving assistant tool calls with their matching tool results across group-chat history truncation, history compression boundaries, and forced compression fallback paths. * fix: 在里面智能体的创建人和机器人的创建人不是一个人时会报错 (#853) * docs: update contributors list * docs: update contributors list (zh) * docs: update contributors list * docs: update contributors list (zh) * fix: 在里面智能体的创建人和机器人的创建人不是一个人时会报错 * fix: 迁移其他的sql到kindReader --------- Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> Co-authored-by: hongyu9 <hongyu9@staff.weibo.com> * fix: fail fast on invalid tool call IDs across chat protocols (#854) * fix: 订阅任务执行间隔调整 & trace http接口的匹配规则调整 (#855) * docs: update contributors list * docs: update contributors list (zh) * docs: update contributors list * docs: update contributors list (zh) * fix: telemetry的匹配规则调整 * fix: 订阅任务执行间隔调整 * fix: 调整逻辑 --------- Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> Co-authored-by: hongyu9 <hongyu9@staff.weibo.com> * fix: sanitize PyInstaller LD_LIBRARY_PATH for child processes (#859) PyInstaller's bootloader prepends its extraction directory (/tmp/_MEIxxxxxx) to LD_LIBRARY_PATH, causing child processes (Claude Code, shell commands) to load wrong shared libraries (e.g., libtinfo.so.6). Extract `sanitize_ld_library_path()` into platform_compat and apply it in both local_mode_strategy (Claude SDK subprocess) and extension_handler (extension script subprocess) to restore the original library path. See: https://pyinstaller.org/en/stable/common-issues-and-pitfalls.html Co-authored-by: sifang <sifang@staff.weibo.com> * refactor(rag): move internal retrieve routing into backend (#847) * refactor(rag): move internal retrieve routing into backend * refactor(rag): move retrieve persistence into backend * refactor(rag): move kb head persistence into backend * fix(rag): tighten backend retrieve routing * refactor(rag): simplify token estimation fallback * refactor(rag): batch route token estimation * fix(rag): token estimator decimal * fix(rag): harden kb read persistence * frontend: show 'indexing' status for documents pending indexing (#858) * fix(frontend): show 'indexing' status for documents pending indexing When a document is uploaded, is_active is false while indexing is in progress. Previously, this showed 'index unavailable' which was misleading. Now documents with status='enabled' but is_active=false will show 'indexing' instead of 'index unavailable', matching the existing translation key. Changes: - Updated compact mode status indicator (line 247) - Updated normal mode status badge (line 461) Fixes: knowledge base document shows 'index unavailable' during indexing * fix(i18n): update Developer role description in Chinese locale * fix: 修复订阅器中脏数据导致的无法展示的问题 (#860) * docs: update contributors list * docs: update contributors list (zh) * docs: update contributors list * docs: update contributors list (zh) * fix: 修复订阅器中脏数据导致的无法展示的问题 --------- Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> Co-authored-by: hongyu9 <hongyu9@staff.weibo.com> * feat(backend): add knowledge base RAG support to /v1/responses API (#844) * feat(backend): add knowledge base RAG support to /v1/responses API Implement knowledge base Q&A functionality for the OpenAI-compatible /v1/responses endpoint with the following changes: Schema Changes: - Add knowledge_base_names field to WegentTool schema - Support namespace#name format for KB specification New Services: - KnowledgeBaseNameResolver: resolves KB display names to IDs with permission checking via TaskKnowledgeBaseService - KnowledgeBaseContextCreator: creates SubtaskContext records for API-specified KBs to integrate with existing RAG pipeline Integration: - Extend parse_wegent_tools() to handle knowledge_base tool type - Add parse_knowledge_base_name() for namespace#name parsing - Modify build_execution_request() to accept knowledge_base_names - Add _create_kb_contexts_from_api_request() for KB context injection - Update openapi_responses.py endpoints to pass KB names parameter Testing: - Add comprehensive unit tests for KB name resolution - Add tests for KB context creation - Add tests for helper functions with KB support - All 32 new tests passing The implementation reuses the existing RAG flow through prepare_contexts_for_chat() and KnowledgeBaseTool, ensuring consistency with the web UI behavior. * refactor(kb_resolver): optimize database query complexity from O(n) to O(m) - Add batch_get_knowledge_base_by_names() to TaskKnowledgeBaseService for efficient batch queries - Extract _check_kb_access_permission() for unified permission checking logic - Update kb_resolver to use service methods instead of direct queries - Reduce DB queries from O(n) to O(m) where m is unique namespace count - Update tests to mock service methods instead of internal functions All 15 tests pass. * refactor(backend): optimize KB permission check in kb_resolver Simplify permission checking by using get_all_knowledge_bases_grouped() which already returns all KBs accessible to the user. Changes: - Replace _batch_query_kbs() and _check_kb_access_permission() with _get_accessible_kb_lookup() that builds a lookup dict from grouped results - Remove unused resolve_single() method and batch_get_knowledge_base_by_names() - Update tests to mock KnowledgeService.get_all_knowledge_bases_grouped() This reduces database queries and simplifies the permission check logic. * feat(backend): integrate knowledge base context creation into unified AI trigger - Add knowledge_base_names parameter to build_execution_request for OpenAPI v1/responses - Create _create_kb_contexts_from_api_request helper to process KB names from API requests - Integrate KB context processing into unified trigger flow - Add KnowledgeBaseContextCreator class for creating SubtaskContext records - Add comprehensive unit tests for KnowledgeBaseContextCreator This enables RAG functionality for OpenAPI v1/responses endpoint by creating SubtaskContext records that are processed by the existing context pipeline. * fix(chat): propagate HTTPException from KnowledgeBaseNameResolver in unified trigger - Add HTTPException import from fastapi - Catch and re-raise HTTPException explicitly in _create_kb_contexts_from_api_request - Keep generic exception handling for non-HTTP exceptions to preserve best-effort behavior - This ensures 403/404 errors from KB resolution are properly propagated to callers instead of being swallowed and logged as warnings * fix(chat_shell): use model_type for provider detection instead of model_id (#861) - Extract shared detect_provider() into models/providers.py with PROVIDER_ALIASES as single source of truth - model_type (env.model) is authoritative; raise ValueError on unknown - Remove _PROVIDER_ID_PATTERNS model_id prefix fallback (same model_id can serve multiple protocols) - Unify truncation notice logic for all providers (no system-role notice in middle of messages, preventing Anthropic non-consecutive system message errors) - Pass model_type from model_config through MessageCompressor to TokenCounter for accurate provider detection - Remove duplicate provider constants from factory.py and token_counter.py Co-authored-by: wenbo17 <wenbo17@staff.weibo.com> * ix: claude的子代理模式不可用修复 (#862) * docs: update contributors list * docs: update contributors list (zh) * docs: update contributors list * docs: update contributors list (zh) * fix: claude的子代理模式不可用修复 --------- Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> Co-authored-by: hongyu9 <hongyu9@staff.weibo.com> * feat(inbox): implement work queue and message forwarding system (#851) * feat(inbox): implement work queue and message forwarding system Add a comprehensive message forwarding and work queue system that enables users to forward conversation messages to other users. Recipients can manage received messages through work queues and optionally configure AI agents for automatic processing. Backend changes: - Add QueueMessage and RecentContact database models - Add WorkQueue CRD schema stored in kinds table - Implement work queue services for CRUD operations - Implement message forwarding service with queue selection - Add WebSocket events for real-time notifications - Add API endpoints for work queue management - Add ForbiddenException to core exceptions Frontend changes: - Add inbox page with queue sidebar and message list - Implement ForwardMessageDialog for recipient selection - Add queue edit/create dialog with auto-processing config - Add message detail dialog with content preview - Add i18n translations (zh-CN and en) - Register inbox route and navigation * fix: resolve lint errors in inbox feature - Remove unused imports (RefreshCw, Settings, Menu, Button, Input, Clock) - Format Python files with Black * fix: resolve TypeScript errors in inbox feature - Add 'flow' and 'inbox' to TopNavigation activePage type - Replace Badge variant 'outline' with 'info' (outline not supported) * fix: address CodeRabbit review comments for work queue feature - Fix status parameter shadowing fastapi status module in work_queue.py - Fix NamespaceMember.namespace to use group_name column reference - Replace func.json_set with Python-level update for PostgreSQL compatibility - Fix refreshQueues dependency loop using functional state update - Remove Chinese text from inbox page comment - Add NaN validation for schedule interval input - Replace clickable Badge with accessible button for recent contacts --------- Co-authored-by: qdaxb <4157870+qdaxb@users.noreply.github.com> * Wegent/work queue and message forwarding (#863) * feat(inbox): implement work queue and message forwarding system Add a comprehensive message forwarding and work queue system that enables users to forward conversation messages to other users. Recipients can manage received messages through work queues and optionally configure AI agents for automatic processing. Backend changes: - Add QueueMessage and RecentContact database models - Add WorkQueue CRD schema stored in kinds table - Implement work queue services for CRUD operations - Implement message forwarding service with queue selection - Add WebSocket events for real-time notifications - Add API endpoints for work queue management - Add ForbiddenException to core exceptions Frontend changes: - Add inbox page with queue sidebar and message list - Implement ForwardMessageDialog for recipient selection - Add queue edit/create dialog with auto-processing config - Add message detail dialog with content preview - Add i18n translations (zh-CN and en) - Register inbox route and navigation * fix: resolve lint errors in inbox feature - Remove unused imports (RefreshCw, Settings, Menu, Button, Input, Clock) - Format Python files with Black * fix: resolve TypeScript errors in inbox feature - Add 'flow' and 'inbox' to TopNavigation activePage type - Replace Badge variant 'outline' with 'info' (outline not supported) * fix: address CodeRabbit review comments for work queue feature - Fix status parameter shadowing fastapi status module in work_queue.py - Fix NamespaceMember.namespace to use group_name column reference - Replace func.json_set with Python-level update for PostgreSQL compatibility - Fix refreshQueues dependency loop using functional state update - Remove Chinese text from inbox page comment - Add NaN validation for schedule interval input - Replace clickable Badge with accessible button for recent contacts * feat: update work queue --------- Co-authored-by: qdaxb <4157870+qdaxb@users.noreply.github.com> * fix: fix column default value * fix: fix forward message click * feat: remove unused area * feat: add inbox default message * fix: 修复脏数据导致的订阅任务无法执行的问题 (#865) * docs: update contributors list * docs: update contributors list (zh) * docs: update contributors list * docs: update contributors list (zh) * fix: 修复脏数据导致的订阅任务无法执行的问题 --------- Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> Co-authored-by: hongyu9 <hongyu9@staff.weibo.com> * fix(browser): harden browser-tool linux recovery (#867) Co-authored-by: sifang <sifang@staff.weibo.com> * fix: 修复无法使用自定义镜像以及自定义镜像无法校验的问题 (#866) * docs: update contributors list * docs: update contributors list (zh) * docs: update contributors list * docs: update contributors list (zh) * fix: 修复无法使用自定义镜像 * fix: 修复无法使用自定义镜像以及自定义镜像无法校验的问题 * fix: 修复可能的bug --------- Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> Co-authored-by: hongyu9 <hongyu9@staff.weibo.com> * fix: fix welcome timezone (#868) * docs: update inbox docs (#869) * fix: 修复单测 (#870) * docs: update contributors list * docs: update contributors list (zh) * docs: update contributors list * docs: update contributors list (zh) * fix: 修复单测 --------- Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> Co-authored-by: hongyu9 <hongyu9@staff.weibo.com> * fix: fix page error (#871) * fix: data-roleid="api-key-create-button" not in html attr (#873) * fix: 修复停止按钮偶发变成发送的问题 & 修复失败的消息会丢失的问题 (#876) * docs: update contributors list * docs: update contributors list (zh) * docs: update contributors list * docs: update contributors list (zh) * fix: 修复停止按钮偶发变成发送的问题 * fix: 修复失败的消息会丢失的问题 * fix: 修复类型报错 * fix: 修复前端复制按钮内容错误的问题 --------- Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> Co-authored-by: hongyu9 <hongyu9@staff.weibo.com> * fix: 修复“skill not found” (#877) * docs: update contributors list * docs: update contributors list (zh) * docs: update contributors list * docs: update contributors list (zh) * fix: 技能错乱 --------- Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> Co-authored-by: hongyu9 <hongyu9@staff.weibo.com> * chore(executor): upgrade claude-agent-sdk from 0.1.31 to 0.1.51 (#880) Co-authored-by: sifang <sifang@staff.weibo.com> * feat(frontend): add HTML attachment preview and share link generation (#872) - Add HtmlPreview component for previewing HTML files with iframe and source view modes - Update FilePreview to support HTML file type detection and rendering - Add createAttachmentShareLink API for generating public share links - Add share button to FilePreviewDialog and FilePreviewPage (visible for owners only) - Add Web Page type label and icon for HTML attachments in AttachmentCard - Fix preview page height to fill viewport using h-screen and h-full - Update AttachmentPreview to support HTML file preview button Fixes share link browsing and download for table-type attachments * fix(knowledge): harden document indexing state (#875) * fix(knowledge): harden document indexing state * fix(knowledge): harden indexing state transitions * fix(knowledge): tighten reindex review followups * fix(rag): KNOWLEDGE_INDEX_LOCK_MAX_RETRIES=1 * fix(knowledge): store index status without db enum * fix(alembic): correct migration revision metadata * docs: update contributors list (zh) (#879) Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> * docs: update contributors list (#878) Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> * feat: 支持skill认证 (#882) * docs: update contributors list * docs: update contributors list (zh) * docs: update contributors list * docs: update contributors list (zh) * docs: add skill http identity design and plan * feat(skill): add http identity token flow * feat: 修改样式 * feat: 修改样式 * feat: 移除计划 * feat: 调整为带有认证的接口 --------- Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> Co-authored-by: hongyu9 <hongyu9@staff.weibo.com> # Conflicts: # executor_manager/services/sandbox/manager.py * Feature/knowledge document read (#888) * docs(backend): add knowledge document read spec and plan * feat(backend): add orchestrated knowledge document reads * fix(backend): tighten knowledge document read handling * refactor(web-scraper): add configuration for specific sites that require special handling (#884) * refactor(web-scraper): extract site-specific config to scraper_config.py - Add scraper_config.py for site-specific crawling configurations * fix(web_scraper): load WEB_SCRAPER_SITE_CONFIG from Pydantic settings instead of os.environ - Add WEB_SCRAPER_SITE_CONFIG to Settings class in config.py - Refactor scraper_config.py to use settings.WEB_SCRAPER_SITE_CONFIG with proper logging - Replace module-level config loading with cached get_site_config() function - Update scraper_service.py to use new get_site_config() function - Add detailed logging for site config matching and application - Fix remove_overlay_elements duplicate key in CrawlerRunConfig This ensures the configuration is properly loaded from .env file via Pydantic settings." * refactor(backend): improve scraper_config security and type safety - Remove sensitive config value from INFO level logging - Add return type annotations to _load_site_config and get_site_config - Replace broad Exception catch with specific exception types (AttributeError, KeyError, TypeError, ValueError) - Import Dict and Any from typing module * refactor(backend): replace auto-cleanup with archive expiration check Remove automatic MinIO archive cleanup (Celery Beat task) and instead block task execution when workspace archive has expired (>30 days). Users will receive a clear error message and must create a new task. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * feat: 添加恢复行为测试和脚本路径修正 * fix: 使用 timezone.utc 替换 UTC 以确保时区正确 * test(backend): fix workspace recovery test patches * feat: 添加工作区归档配置测试与默认值 * feat: 添加工作区归档时区配置及测试 --------- Co-authored-by: yunpeng7 <yunpeng7@staff.weibo.com> Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com> Co-authored-by: axb <qindi@staff.weibo.com> Co-authored-by: moqimoqidea <39821951+moqimoqidea@users.noreply.github.com> Co-authored-by: MicroLee <yudexiaozhou@gmail.com> Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> Co-authored-by: hongyu9 <hongyu9@staff.weibo.com> Co-authored-by: icycrystal4 <icycrystal4@gmail.com> Co-authored-by: sifang <sifang@staff.weibo.com> Co-authored-by: Yanhe <yanhe1@staff.weibo.com> Co-authored-by: parabala <chenyong1@staff.weibo.com> Co-authored-by: wenbo17 <wenbo17@staff.weibo.com> Co-authored-by: qdaxb <4157870+qdaxb@users.noreply.github.com> Co-authored-by: 李枨煊 <chengxuan@staff.weibo.com> Co-authored-by: johnny0120 <jiangyang7@staff.weibo.com> Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
fix(browser): harden browser-tool linux recovery (wecode-ai#867) See merge request weibo_rd/common/wecode/wegent!1847
Summary
tool-cliusing dynamic uid and Xauthority discoveryTesting
Summary by CodeRabbit
New Features
Bug Fixes
Version