Make your computer a home for your AI partner. Avibe is the local-first Agent OS: Vibey, its built-in AI partner, works out of the box, and Claude Code, Codex & OpenCode run unchanged beside it — reach them from your browser, phone, or any chat app.
Python agentagent-osaiai-agentsai-partnerchatopsclaudeclaude-codecodexdevtoolsdiscord-botlark-botllmlocal-firstlong-term-memoryopencodeslack-botvibe-codingvibeywechat
chore(merge): integrate latest master
Max16ee11d49016
diff --cc tests/scenarios/auth_setup/test_auth_setup_scenarios.pyindex 03e0adf9e,87bc36ea2..f3cefeee0--- a/tests/scenarios/auth_setup/test_auth_setup_scenarios.py+++ b/tests/scenarios/auth_setup/test_auth_setup_scenarios.py@@@ -25,12 -26,11 +26,16 @@@ from modules.agents.codex.agent importfrom tests.scenario_harness.auth_setup import AuthSetupScenarioHarness, FakeProcessfrom tests.scenario_harness.core import ScenarioExpect, ScenarioRunner, ScenarioStepfrom tests.scenario_harness.model_hub_native_oauth import NativeOAuthScenarioHarness+from tests.scenario_harness.organization_management import (+ REMOTE_ORIGIN,+ OrganizationManagementScenarioHarness,+)+from vibe import cloud_management- from vibe.api import get_claude_auth, save_claude_auth+ from vibe.api import (+ get_claude_auth,+ save_claude_auth,+ test_backend_auth_async as probe_backend_auth_async,+ )from vibe.claude_config import (build_claude_subprocess_env,materialize_claude_subprocess_env,@@@ -75,269 -76,16 +81,275 @@@ class _CodexProviderBindingSessionsdef bind_agent_session(self, *_args, **_kwargs):return "ses-provider"+class OrganizationManagementAuthScenarioTests(unittest.TestCase):+ def setUp(self):+ self.harness = OrganizationManagementScenarioHarness()+ self.addCleanup(self.harness.close)++ def test_explicit_management_sign_in_starts_interactive_handoff(self):+ """Scenario: AUTH-SETUP-301"""+ client = self.harness.remote_client()+ with patch.object(+ cloud_management,+ "begin_authorization",+ return_value=("https://avibe.bot/oauth/management/authorize?state=state-1", "state-1"),+ ) as begin:+ response = client.post(+ "/api/cloud-management/session/start",+ json={"mode": "interactive", "next": "/admin/organization/members"},+ headers=self.harness.csrf(client),+ base_url=REMOTE_ORIGIN,+ )++ self.assertEqual(response.status_code, 202)+ self.assertEqual(response.get_json()["mode"], "interactive")+ begin.assert_called_once()+ self.assertFalse(begin.call_args.kwargs["silent"])+ self.assertEqual(begin.call_args.kwargs["remote_subject"], "user-1")++ def test_silent_reauthorization_stops_after_login_required(self):+ """Scenarios: AUTH-SETUP-302, AUTH-SETUP-306"""+ client = self.harness.remote_client()+ with patch.object(+ cloud_management,+ "begin_authorization",+ return_value=("https://avibe.bot/oauth/management/authorize?prompt=none", "state-1"),+ ) as begin:+ first = client.post(+ "/api/cloud-management/session/start",+ json={"mode": "silent", "next": "/admin/organization/overview"},+ headers=self.harness.csrf(client),+ base_url=REMOTE_ORIGIN,+ )+ self.assertEqual(first.status_code, 202)+ self.assertTrue(begin.call_args.kwargs["silent"])++ with patch.object(+ cloud_management,+ "fail_handshake",+ return_value="/admin/organization/overview",+ ):+ callback = client.get(+ "/auth/organization/callback?error=login_required&state=state-1",+ base_url=REMOTE_ORIGIN,+ )+ self.assertEqual(callback.status_code, 302)+ self.assertIn("cloud_management_error=login_required", callback.headers["location"])++ second = client.post(+ "/api/cloud-management/session/start",+ json={"mode": "silent", "next": "/admin/organization/overview"},+ headers=self.harness.csrf(client),+ base_url=REMOTE_ORIGIN,+ )+ self.assertEqual(second.status_code, 401)++ def test_logout_suppresses_silent_reauthorization(self):+ """Scenario: AUTH-SETUP-303"""+ client = self.harness.remote_client()+ client.set_cookie(cloud_management.HANDLE_COOKIE_NAME, "grant-1", domain="alex.avibe.bot")+ client.set_cookie(cloud_management.BROWSER_COOKIE_NAME, "browser-1", domain="alex.avibe.bot")+ logout = client.delete(+ "/api/cloud-management/session",+ headers=self.harness.csrf(client),+ base_url=REMOTE_ORIGIN,+ )+ self.assertEqual(logout.status_code, 200)+ session = client.get("/api/cloud-management/session", base_url=REMOTE_ORIGIN)+ self.assertEqual(session.status_code, 200)+ self.assertFalse(session.get_json()["can_silent_reauthorize"])++ def test_subject_mismatch_is_terminal(self):+ """Scenario: AUTH-SETUP-304"""+ client = self.harness.remote_client()+ client.set_cookie(cloud_management.HANDLE_COOKIE_NAME, "grant-1", domain="alex.avibe.bot")+ client.set_cookie(cloud_management.BROWSER_COOKIE_NAME, "browser-1", domain="alex.avibe.bot")+ with patch.object(+ cloud_management,+ "resolve_grant",+ return_value=(None, "cloud_management_subject_mismatch"),+ ):+ response = client.get("/api/cloud-management/session", base_url=REMOTE_ORIGIN)+ self.assertEqual(response.status_code, 409)+ self.assertEqual(response.get_json()["state"], "subject_mismatch")++ def test_invalid_callback_token_requires_manual_sign_in(self):+ """Scenario: AUTH-SETUP-305"""+ client = self.harness.remote_client()+ client.set_cookie(cloud_management.BROWSER_COOKIE_NAME, "browser-1", domain="alex.avibe.bot")+ with patch.object(+ cloud_management,+ "complete_authorization",+ side_effect=cloud_management.CloudManagementError(+ "invalid_cloud_management_token",+ status=400,+ ),+ ):+ response = client.get(+ "/auth/organization/callback?code=bad-code&state=bad-state",+ base_url=REMOTE_ORIGIN,+ )+ self.assertEqual(response.status_code, 302)+ self.assertIn("cloud_management_error=invalid_cloud_management_token", response.headers["location"])+ session = client.get("/api/cloud-management/session", base_url=REMOTE_ORIGIN)+ self.assertFalse(session.get_json()["can_silent_reauthorize"])++ def test_remote_callback_keeps_the_bound_subject(self):+ """Scenario: AUTH-SETUP-307"""+ backend = SimpleNamespace(base_url="https://avibe.bot")+ with patch.object(cloud_management, "_validated_backend", return_value=backend):+ _, state = cloud_management.begin_authorization(+ self.harness.config,+ browser_id="browser-1",+ remote_subject="user-1",+ callback_origin=REMOTE_ORIGIN,+ next_path="/admin/organization/overview",+ silent=False,+ )+ client = self.harness.remote_client(subject="user-2")+ client.set_cookie(cloud_management.BROWSER_COOKIE_NAME, "browser-1", domain="alex.avibe.bot")+ token_payload = {+ "access_token": "not-exposed",+ "token_type": "Bearer",+ "subject": "user-2",+ "vibe_instance_id": "inst_123",+ }+ token_claims = {+ "sub": "user-2",+ "email": "[email protected]",+ "vibe_instance_id": "inst_123",+ "exp": 4_102_444_800,+ }+ with (+ patch.object(cloud_management, "_backend_request", return_value=(200, token_payload)),+ patch.object(cloud_management, "_validate_management_token", return_value=token_claims),+ ):+ response = client.get(+ f"/auth/organization/callback?code=code-1&state={state}",+ base_url=REMOTE_ORIGIN,+ )+ self.assertEqual(response.status_code, 302)+ self.assertIn("cloud_management_error=cloud_management_subject_mismatch", response.headers["location"])+ self.assertNotIn("not-exposed", response.text)++ def test_trusted_loopback_flow_can_establish_the_first_subject(self):+ """Scenario: AUTH-SETUP-308"""+ client = self.harness.unbound_remote_client()+ client.set_cookie(cloud_management.BROWSER_COOKIE_NAME, "browser-1", domain="alex.avibe.bot")+ grant = cloud_management.ManagementGrant(+ handle="grant-1",+ browser_id="browser-1",+ subject="first-user",+ email="[email protected]",+ token="not-exposed",+ expires_at=4_102_444_800,+ )+ with patch.object(+ cloud_management,+ "complete_authorization",+ return_value=(grant, "/admin/organization/overview"),+ ) as complete:+ response = client.get(+ "/auth/organization/callback?code=code-1&state=state-1",+ base_url=REMOTE_ORIGIN,+ )+ self.assertEqual(response.status_code, 302)+ self.assertIsNone(complete.call_args.kwargs["remote_subject"])++ def test_unbound_loopback_requires_interactive_sign_in(self):+ """Scenario: AUTH-SETUP-309"""+ client = self.harness.unbound_remote_client()+ loopback_origin = "http://127.0.0.1:15131"++ session = client.get("/api/cloud-management/session", base_url=loopback_origin)+ silent = client.post(+ "/api/cloud-management/session/start",+ json={"mode": "silent", "next": "/admin/organization/overview"},+ headers=self.harness.csrf(client, loopback_origin),+ base_url=loopback_origin,+ )++ self.assertEqual(session.status_code, 200)+ self.assertFalse(session.get_json()["can_silent_reauthorize"])+ self.assertEqual(silent.status_code, 401)+ self.assertEqual(+ silent.get_json(),+ {+ "error": "cloud_management_authorization_required",+ "retryable": False,+ },+ )++ def test_subject_mismatch_can_reenter_with_clean_return_path(self):+ """Scenario: AUTH-SETUP-310"""+ client = self.harness.remote_client()+ client.set_cookie(cloud_management.BROWSER_COOKIE_NAME, "browser-1", domain="alex.avibe.bot")+ with patch.object(+ cloud_management,+ "complete_authorization",+ side_effect=cloud_management.CloudManagementError(+ "cloud_management_subject_mismatch",+ status=409,+ ),+ ):+ mismatch = client.get(+ "/auth/organization/callback?code=wrong-user&state=state-1",+ base_url=REMOTE_ORIGIN,+ )++ self.assertEqual(mismatch.status_code, 302)+ self.assertIn(+ "cloud_management_error=cloud_management_subject_mismatch",+ mismatch.headers["location"],+ )++ clean_next = "/admin/organization/overview"+ with patch.object(+ cloud_management,+ "begin_authorization",+ return_value=("https://avibe.bot/oauth/management/authorize?state=state-2", "state-2"),+ ) as begin:+ reentry = client.post(+ "/api/cloud-management/session/start",+ json={"mode": "interactive", "next": clean_next},+ headers=self.harness.csrf(client),+ base_url=REMOTE_ORIGIN,+ )++ self.assertEqual(reentry.status_code, 202)+ self.assertEqual(begin.call_args.kwargs["next_path"], clean_next)++ grant = cloud_management.ManagementGrant(+ handle="grant-2",+ browser_id="browser-1",+ subject="user-1",+ email="[email protected]",+ token="not-exposed",+ expires_at=4_102_444_800,+ )+ with patch.object(+ cloud_management,+ "complete_authorization",+ return_value=(grant, clean_next),+ ):+ success = client.get(+ "/auth/organization/callback?code=right-user&state=state-2",+ base_url=REMOTE_ORIGIN,+ )++ self.assertEqual(success.status_code, 302)+ self.assertEqual(success.headers["location"], clean_next)+ self.assertNotIn("cloud_management_error", success.headers["location"])+ class _ReloadingV2ConfigController:+ @property+ def config(self):+ return V2Config.load()++class AgentAuthSetupScenarioTests(unittest.IsolatedAsyncioTestCase):- async def test_claude_oauth_to_relay_key_reaches_next_turn_with_bearer_auth(self):+ async def test_claude_oauth_to_explicit_auth_token_reaches_next_turn(self):"""Scenario: AUTH-SETUP-904"""state_dir = tempfile.TemporaryDirectory()self.addCleanup(state_dir.cleanup)diff --cc vibe/i18n/en.jsonindex 0a83af76a,344069000..75a205186--- a/vibe/i18n/en.json+++ b/vibe/i18n/en.json@@@ -293,6 -254,52 +293,7 @@@"hint": "Choose an Agent name without path separators."}},- "channelNotEnabled": "This channel is not enabled. Please go to the control panel to enable it.",- "unknownCommand": "Unknown command: `/{command}`\n\nPlease use `@avibe /start` to access all bot features.",- "clearSession": "Error clearing session: {error}",- "settingsFailed": "Failed to open settings. Please try again.",- "cwdChangeFailed": "Failed to open directory change dialog. Please try again.",- "resumeFailed": "Failed to open resume dialog. Please try again.",- "stopFailed": "Error sending stop command: {error}",- "cwdSetFailed": "Error setting working directory: {error}",- "cwdCreateFailed": "Cannot create directory: {error}",- "cwdNotDirectory": "Path exists but is not a directory: `{path}`",- "cwdGetFailed": "Error getting working directory: {error}",- "showSettings": "Error showing settings: {error}",- "toggleSettingFailed": "Failed to toggle setting: {error}",- "messageTypesInfoFailed": "Error showing message types info",- "helpInfoFailed": "Error showing help information",- "routingFailed": "Error showing routing settings: {error}",- "routingModalFailed": "Failed to open agent settings. Please try again.",- "settingsUpdateFailed": "Failed to update settings: {error}",- "languageUpdateFailed": "Language update failed. Please try again.",- "resumeSubmitFailed": "Failed to resume session: {error}",- "routingUpdateFailed": "Failed to update routing: {error}",- "updateUnavailable": "Update action is not available right now.",- "unknownAction": "Unknown action: {action}",- "processActionFailed": "Error processing action: {error}",- "agentNotConfigured": "Agent `{agent}` uses the {backend} backend, but that backend is not available. {hint}",- "agentNotConfiguredHint": {- "opencode": "Enable the OpenCode backend, install the OpenCode CLI, or set OPENCODE_CLI_PATH.",- "claude": "Enable the Claude Code backend and make sure the Claude Code CLI path is configured.",- "codex": "Enable the Codex backend, install the Codex CLI, or set CODEX_CLI_PATH.",- "generic": "Choose an enabled Agent in Agent settings, or enable the backend this Agent uses."- },- "processMessageFailed": "Error: {error}",- "streamTurnInProgress": "⚠️ A reply is already streaming for this session — wait for it to finish, then try again.",- "sessionReset": "Session error detected. Session has been reset. Please try your message again.",- "sessionConnectionLost": "Connection to Claude was lost. Please try your message again.",+ "claudeCredentialTypeInvalid": "Choose either API key or auth token for the Claude Code credential.",- "claudeSessionNotFound": "Claude Code could not find the historical session `{sessionId}` in the current working directory:\n`{path}`\n\nClaude Code sessions are scoped to a working directory. This usually means the conversation was resumed after switching workdirs, or the local Claude Code session data changed. Switch back to the original working directory to continue that session, or start a new Claude Code session from the current directory.",- "sessionGeneric": "An error occurred: {error}",- "resultAttachmentUploadFailed": "Failed to upload attachment. Want me to split the result into multiple messages?",- "resultDeliveryFailed": "⚠️ Message delivery failed. The content may be too long or incompatible. Ask me to resend it.",- "fileAttachmentUploadFailedWithLink": "⚠️ I could not deliver {filename} as a WeChat file. You can download it from Avibe after signing in if prompted:\n{url}",- "fileAttachmentUploadFailedNoLink": "⚠️ I could not deliver {filename} as a WeChat file. Please ask me to resend it or use another channel.",- "opencodeQuestionToolDisabled": "OpenCode asked an interactive question, but Avibe disables the OpenCode question tool. Please send a new follow-up message with your answer or direction.",- "opencodeQuestionToolDisabledRestored": "Restored OpenCode session asked an interactive question, but Avibe disables the OpenCode question tool. Please send a new follow-up message with your answer or direction.",- "opencodeEmptyResponse": "OpenCode finished without a model reply. Provider: {provider}; model: {model}; reasoning: {variant}. OpenCode did not expose a provider error for this run.",- "opencodeProviderRuntimeError": "OpenCode provider request failed. Provider: {provider}; model: {model}; reasoning: {variant}. Detail: {detail}","opencodeBackendError": "OpenCode error: {error}"},"success": {diff --cc vibe/i18n/zh.jsonindex a56d6fb8b,518d17775..88bbcb074--- a/vibe/i18n/zh.json+++ b/vibe/i18n/zh.json@@@ -293,6 -254,52 +293,7 @@@"hint": "请选择不含路径分隔符的 Agent 名称。"}},- "channelNotEnabled": "此频道未启用。请前往控制面板启用它。",- "unknownCommand": "未知命令:`/{command}`\n\n请使用 `@avibe /start` 访问所有机器人功能。",- "clearSession": "清除会话时出错:{error}",- "settingsFailed": "无法打开设置。请重试。",- "cwdChangeFailed": "无法打开目录更改对话框。请重试。",- "resumeFailed": "无法打开恢复对话框。请重试。",- "stopFailed": "发送停止命令时出错:{error}",- "cwdSetFailed": "设置工作目录时出错:{error}",- "cwdCreateFailed": "无法创建目录:{error}",- "cwdNotDirectory": "路径存在但不是目录:`{path}`",- "cwdGetFailed": "获取工作目录时出错:{error}",- "showSettings": "显示设置时出错:{error}",- "toggleSettingFailed": "切换设置失败:{error}",- "messageTypesInfoFailed": "显示消息类型说明时出错",- "helpInfoFailed": "显示帮助信息时出错",- "routingFailed": "显示路由设置时出错:{error}",- "routingModalFailed": "无法打开 Agent 设置。请重试。",- "settingsUpdateFailed": "更新设置失败:{error}",- "languageUpdateFailed": "语言更新失败,请重试。",- "resumeSubmitFailed": "恢复会话失败:{error}",- "routingUpdateFailed": "更新路由失败:{error}",- "updateUnavailable": "当前无法执行更新操作。",- "unknownAction": "未知操作:{action}",- "processActionFailed": "处理操作时出错:{error}",- "agentNotConfigured": "Agent `{agent}` 使用 {backend} backend,但该 backend 当前不可用。{hint}",- "agentNotConfiguredHint": {- "opencode": "请启用 OpenCode backend,安装 OpenCode CLI,或设置 OPENCODE_CLI_PATH。",- "claude": "请启用 Claude Code backend,并确认 Claude Code CLI 路径已配置。",- "codex": "请启用 Codex backend,安装 Codex CLI,或设置 CODEX_CLI_PATH。",- "generic": "请在 Agent 设置里选择一个已启用的 Agent,或启用该 Agent 使用的 backend。"- },- "processMessageFailed": "出错:{error}",- "streamTurnInProgress": "⚠️ 这个会话已经有一条回复在生成中,请等它完成后再试。",- "sessionReset": "检测到会话错误。会话已重置,请重试。",- "sessionConnectionLost": "与 Claude 的连接已断开,请重试。",+ "claudeCredentialTypeInvalid": "Claude Code 凭据类型只能选择 API Key 或 Auth Token。",- "claudeSessionNotFound": "Claude Code 在当前工作目录下找不到历史会话 `{sessionId}`:\n`{path}`\n\nClaude Code 的会话和工作目录相关。通常是恢复会话后切换了工作目录,或本地 Claude Code 会话数据发生变化。请切回原来的工作目录继续该会话,或在当前目录开始一个新的 Claude Code 会话。",- "sessionGeneric": "发生错误:{error}",- "resultAttachmentUploadFailed": "附件上传失败。要我改成拆分成多条消息发送吗?",- "resultDeliveryFailed": "⚠️ 消息投递失败,内容可能过长或格式不兼容。你可以让我重新发送一次。",- "fileAttachmentUploadFailedWithLink": "⚠️ {filename} 没能作为微信文件直接发送。你可以通过 Avibe 下载;如提示登录,请先登录:\n{url}",- "fileAttachmentUploadFailedNoLink": "⚠️ {filename} 没能作为微信文件直接发送。请让我重新发送,或换一个渠道接收这个文件。",- "opencodeQuestionToolDisabled": "OpenCode 发起了交互式提问,但 Avibe 已禁用 OpenCode 的 question 工具。请直接发送一条新消息,告诉我你的答案或下一步方向。",- "opencodeQuestionToolDisabledRestored": "恢复中的 OpenCode 会话发起了交互式提问,但 Avibe 已禁用 OpenCode 的 question 工具。请直接发送一条新消息,告诉我你的答案或下一步方向。",- "opencodeEmptyResponse": "OpenCode 已结束,但没有产出模型回复。Provider:{provider};模型:{model};推理强度:{variant}。这次运行里 OpenCode 没有暴露服务商错误。",- "opencodeProviderRuntimeError": "OpenCode 服务商请求失败。Provider:{provider};模型:{model};推理强度:{variant}。详情:{detail}","opencodeBackendError": "OpenCode 错误:{error}"},"success": {