AI-native knowledge base & Evernote/Obsidian alternative with instant sync & native MCP. Free on Cloudflare or self-hosted via Docker.
HTML ai-agentcloudflarecloudflare-d1cloudflare-r2cloudflare-workersdockerelectronevernoteevernote-alternativeknowledge-basemcpnote-takingobsidian-alternativeoffline-firstpersonal-knowledge-basepwaself-hostedsqlitetiptapweb-clipper
fix(desktop): recover transient ACP note access failures
tianma-ife66b0d707ebc
diff --git a/apps/desktop/src/main/acp-host.test.mjs b/apps/desktop/src/main/acp-host.test.mjsindex 2a10cfe1..fef55b88 100644--- a/apps/desktop/src/main/acp-host.test.mjs+++ b/apps/desktop/src/main/acp-host.test.mjs@@ -761,16 +761,20 @@ describe("ACP stdio session", () => {const directory = await mkdtemp(path.join(tmpdir(), "edgeever-acp-mcp-status-"));try {const scriptPath = await writeFakeAgent(directory, { reportPath: path.join(directory, "report.json"), secretPath: path.join(directory, "secret.txt") });+ let noteAccessFailure = "workspace_unavailable";const runtime = createAcpHostRuntime({adapterManager: { get: (id) => id === "codex" ? { version: "2.1.1", command: { command: process.execPath, args: [scriptPath] } } : null },pathEnv: "",- mcpAccess: () => { throw new Error("workspace_unavailable"); },+ mcpAccess: () => { throw new Error(noteAccessFailure); },});expect((await runtime.probeAdapter({ id: "codex" })).state).toBe("available");- const events = collector();- await runtime.prompt({ adapterId: "codex", prompt: "Hello" }, events.emit);- expect((await events.waitFor((event) => event.type === "error")).message).toBe("workspace_unavailable");- expect(runtime.listAdapters().find((adapter) => adapter.id === "codex").state).toBe("available");+ for (const message of ["workspace_unavailable", "note_access_network", "note_access_login_required", "note_access_changed"]) {+ noteAccessFailure = message;+ const events = collector();+ await runtime.prompt({ adapterId: "codex", prompt: "Hello" }, events.emit);+ expect((await events.waitFor((event) => event.type === "error")).message).toBe(message);+ expect(runtime.listAdapters().find((adapter) => adapter.id === "codex").state).toBe("available");+ }} finally {await rm(directory, { recursive: true, force: true });}diff --git a/apps/desktop/src/main/acp-mcp-bridge.mjs b/apps/desktop/src/main/acp-mcp-bridge.mjsindex b58be01d..cb702a7e 100644--- a/apps/desktop/src/main/acp-mcp-bridge.mjs+++ b/apps/desktop/src/main/acp-mcp-bridge.mjs@@ -1,6 +1,7 @@import { randomBytes, timingSafeEqual } from "node:crypto";import { once } from "node:events";import { createServer } from "node:http";+import { setTimeout as delay } from "node:timers/promises";const MAX_REQUEST_BYTES = 32 * 1024 * 1024;const FORWARDED_HEADERS = ["mcp-protocol-version", "mcp-method", "mcp-name"];@@ -23,28 +24,80 @@ const readBody = async (request) => {return Buffer.concat(chunks);};-export async function startAcpMcpBridge({ baseUrl, sessionToken, accountId, isCurrent, fetchImpl = fetch } = {}) {- if (typeof baseUrl !== "string" || !/^https?:\/\//.test(baseUrl) || !sessionToken) {- throw new Error("note_access_unavailable");- }+const TRANSIENT_SESSION_STATUSES = new Set([408, 429, 500, 502, 503, 504]);+const NOTE_ACCESS_ERRORS = {+ missing_session: "note_access_login_required",+ session_unauthenticated: "note_access_login_required",+ account_mismatch: "note_access_changed",+ session_changed: "note_access_changed",+ session_network: "note_access_network",+ session_response: "note_access_network",+ session_transient: "note_access_network",+};++// Only the read-only session check can be retried. Never replay MCP tool calls:+// a failed response can follow a successful write to the user's notes.+export async function verifyAcpNoteAccess({ baseUrl, sessionToken, accountId, isCurrent, fetchImpl = fetch, onDiagnostic = () => {} } = {}) {+ const unavailable = (reason, details = {}) => {+ // Never include URLs, tokens, response bodies, or raw error messages.+ try { onDiagnostic({ reason, ...details }); } catch { /* Diagnostics cannot block requests. */ }+ return new Error(NOTE_ACCESS_ERRORS[reason] ?? "note_access_unavailable");+ };+ const assertCurrent = () => {+ if (isCurrent && !isCurrent()) throw unavailable("session_changed");+ };+ if (typeof baseUrl !== "string" || !/^https?:\/\//.test(baseUrl)) throw unavailable("invalid_instance");+ if (typeof sessionToken !== "string" || !sessionToken.trim()) throw unavailable("missing_session");let instance;try { instance = new URL(baseUrl); }- catch { throw new Error("note_access_unavailable"); }- if (instance.username || instance.password || instance.search || instance.hash) throw new Error("note_access_unavailable");+ catch { throw unavailable("invalid_instance"); }+ if (instance.username || instance.password || instance.search || instance.hash) throw unavailable("invalid_instance");const origin = instance.href.replace(/\/+$/, "");- let session;- try {- session = await fetchImpl(`${origin}/api/v1/auth/session`, {- headers: { Authorization: `Bearer ${sessionToken}` },- redirect: "manual",- signal: AbortSignal.timeout(10_000),- });- } catch { throw new Error("note_access_unavailable"); }- const identity = await session.json().catch(() => null);- if (!session.ok || identity?.authenticated !== true || (accountId && identity?.user?.id !== accountId)) {- throw new Error("note_access_unavailable");+ const budget = AbortSignal.timeout(10_000);+ for (let attempt = 1; attempt <= 2; attempt++) {+ assertCurrent();+ let session;+ let identity;+ let transientReason;+ try {+ session = await fetchImpl(`${origin}/api/v1/auth/session`, {+ headers: { Authorization: `Bearer ${sessionToken}` },+ redirect: "manual",+ signal: AbortSignal.any([budget, AbortSignal.timeout(5_000)]),+ });+ if (session.ok) {+ try { identity = await session.json(); }+ catch { transientReason = "session_response"; }+ } else {+ // Consume no potentially sensitive error body; release its connection.+ await session.body?.cancel().catch(() => {});+ }+ } catch { transientReason = "session_network"; }+ assertCurrent();+ if (!transientReason && session?.ok) {+ if (!identity || typeof identity.authenticated !== "boolean") transientReason = "session_response";+ else {+ if (!identity.authenticated) throw unavailable("session_unauthenticated");+ if (accountId && identity.user?.id !== accountId) throw unavailable("account_mismatch");+ return origin;+ }+ }+ if (!transientReason && TRANSIENT_SESSION_STATUSES.has(session.status)) transientReason = "session_transient";+ if (!transientReason) {+ if (session.status === 401) throw unavailable("session_unauthenticated");+ throw unavailable("session_http", { status: session.status });+ }+ if (attempt === 2 || budget.aborted) {+ throw unavailable(transientReason, { attempts: attempt, ...(session ? { status: session.status } : {}) });+ }+ try { await delay(250, undefined, { signal: budget }); }+ catch { throw unavailable(transientReason, { attempts: attempt }); }}+}+export async function startAcpMcpBridge(access = {}) {+ const origin = await verifyAcpNoteAccess(access);+ const { sessionToken, isCurrent, fetchImpl = fetch } = access;const secret = randomBytes(32).toString("hex");const server = createServer(async (request, response) => {response.setHeader("Cache-Control", "no-store");diff --git a/apps/desktop/src/main/acp-mcp-bridge.test.mjs b/apps/desktop/src/main/acp-mcp-bridge.test.mjsindex 148d133d..c59a54b1 100644--- a/apps/desktop/src/main/acp-mcp-bridge.test.mjs+++ b/apps/desktop/src/main/acp-mcp-bridge.test.mjs@@ -20,8 +20,127 @@ test("ACP bridge protects the session and connects the packaged MCP adapter", ()security: true,invalidSession: true,stdio: true,+ retryRecovery: true,+ noWriteReplay: true,});} finally {rmSync(directory, { recursive: true, force: true });}}, 15_000);++import { verifyAcpNoteAccess } from "./acp-mcp-bridge.mjs";++const access = { baseUrl: "https://private-instance.example", sessionToken: "secret-token", accountId: "current-account", isCurrent: () => true };+const authenticatedSession = () => Response.json({ authenticated: true, user: { id: "current-account" } });++test("session preflight recovers from a dropped connection without exposing credentials", async () => {+ const requests = [];+ const diagnostics = [];+ const origin = await verifyAcpNoteAccess({ ...access,+ onDiagnostic: details => diagnostics.push(details),+ fetchImpl: async (url, init) => {+ requests.push({ url, init });+ if (requests.length === 1) throw new Error("secret-token private response");+ return authenticatedSession();+ },+ });+ expect(origin).toBe(access.baseUrl);+ expect(requests).toHaveLength(2);+ expect(requests.every(({ url, init }) => url.endsWith("/api/v1/auth/session") && init.headers.Authorization === "Bearer secret-token" && init.redirect === "manual")).toBe(true);+ expect(diagnostics).toEqual([]);+});++for (const status of [408, 429, 500, 502, 503, 504]) {+ test(`session preflight recovers from HTTP ${status}`, async () => {+ let attempts = 0;+ await expect(verifyAcpNoteAccess({ ...access, fetchImpl: async () => ++attempts === 1 ? new Response("unavailable", { status }) : authenticatedSession() })).resolves.toBe(access.baseUrl);+ expect(attempts).toBe(2);+ });+}++for (const brokenResponse of [() => new Response("truncated json"), () => Response.json({})]) {+ test("session preflight retries an unreadable response instead of misreporting a lost login", async () => {+ let attempts = 0;+ await expect(verifyAcpNoteAccess({ ...access, fetchImpl: async () => ++attempts === 1 ? brokenResponse() : authenticatedSession() })).resolves.toBe(access.baseUrl);+ expect(attempts).toBe(2);+ });+}++test("persistent connection failure is bounded and reports a safe network error", async () => {+ let attempts = 0;+ const diagnostics = [];+ await expect(verifyAcpNoteAccess({ ...access,+ onDiagnostic: details => diagnostics.push(details),+ fetchImpl: async () => { attempts++; throw new Error("secret-token private response"); },+ })).rejects.toThrow("note_access_network");+ expect(attempts).toBe(2);+ expect(diagnostics).toEqual([{ reason: "session_network", attempts: 2 }]);+});++test("a stalled session request times out and retries within the overall budget", async () => {+ let attempts = 0;+ await expect(verifyAcpNoteAccess({ ...access, fetchImpl: async (_url, { signal }) => {+ attempts++;+ if (attempts === 2) return authenticatedSession();+ return new Promise((resolve, reject) => signal.addEventListener("abort", () => reject(signal.reason), { once: true }));+ } })).resolves.toBe(access.baseUrl);+ expect(attempts).toBe(2);+}, 8_000);++test("session rejection and account mismatch fail closed without retrying or launching an agent", async () => {+ const cases = [+ { sessionToken: "", reason: "missing_session", error: "note_access_login_required", calls: 0 },+ { fetchImpl: async () => Response.json({ authenticated: false }), reason: "session_unauthenticated", error: "note_access_login_required", calls: 1 },+ { fetchImpl: async () => new Response("rejected", { status: 401 }), reason: "session_unauthenticated", error: "note_access_login_required", calls: 1 },+ { fetchImpl: async () => Response.json({ authenticated: true, user: { id: "another-account" } }), reason: "account_mismatch", error: "note_access_changed", calls: 1 },+ { fetchImpl: async () => new Response("redirect", { status: 302 }), reason: "session_http", error: "note_access_unavailable", status: 302, calls: 1 },+ { fetchImpl: async () => new Response("forbidden", { status: 403 }), reason: "session_http", error: "note_access_unavailable", status: 403, calls: 1 },+ ];+ for (const { reason, error, status, calls, fetchImpl = authenticatedSession, ...overrides } of cases) {+ let attempts = 0;+ const diagnostics = [];+ await expect(verifyAcpNoteAccess({ ...access, ...overrides,+ onDiagnostic: details => diagnostics.push(details),+ fetchImpl: async () => { attempts++; return fetchImpl(); },+ })).rejects.toThrow(error);+ expect(attempts).toBe(calls);+ expect(diagnostics).toEqual([{ reason, ...(status ? { status } : {}) }]);+ }+});++test("switching account during preflight stops the request before a retry", async () => {+ let current = true;+ let attempts = 0;+ await expect(verifyAcpNoteAccess({ ...access, isCurrent: () => current, fetchImpl: async () => {+ attempts++;+ current = false;+ throw new Error("disconnected");+ } })).rejects.toThrow("note_access_changed");+ expect(attempts).toBe(1);+});++test("switching account during retry backoff prevents another request", async () => {+ let attempts = 0;+ // Checked before each fetch, after each fetch, and again after backoff.+ let checks = 0;+ await expect(verifyAcpNoteAccess({ ...access, isCurrent: () => ++checks <= 2, fetchImpl: async () => {+ attempts++;+ throw new Error("disconnected");+ } })).rejects.toThrow("note_access_changed");+ expect(attempts).toBe(1);+});++test("diagnostic failures cannot replace the note access error", async () => {+ await expect(verifyAcpNoteAccess({ ...access, sessionToken: "", onDiagnostic: () => { throw new Error("log failed"); } })).rejects.toThrow("note_access_login_required");+});++test("persistent timeouts stop within the overall ten-second budget", async () => {+ let attempts = 0;+ const started = Date.now();+ await expect(verifyAcpNoteAccess({ ...access, fetchImpl: async (_url, { signal }) => {+ attempts++;+ return new Promise((resolve, reject) => signal.addEventListener("abort", () => reject(signal.reason), { once: true }));+ } })).rejects.toThrow("note_access_network");+ expect(attempts).toBe(2);+ expect(Date.now() - started).toBeLessThan(11_000);+}, 12_000);diff --git a/apps/desktop/src/main/index.mjs b/apps/desktop/src/main/index.mjsindex c75b5ce9..6d48d522 100644--- a/apps/desktop/src/main/index.mjs+++ b/apps/desktop/src/main/index.mjs@@ -1788,6 +1788,9 @@ const startApplication = async () => {baseUrl,sessionToken,accountId,+ // Share the renderer's system proxy and desktop network behavior.+ fetchImpl: (url, init) => net.fetch(url, { ...init, credentials: "omit" }),+ onDiagnostic: (details) => { void writeDiagnostic("acp.note-access-failed", details); },isCurrent: () => configuredApiBaseUrl === baseUrl && desktopSessionToken === sessionToken && activeAccountId === accountId,};},diff --git a/apps/web/src/components/ai-sidebar/AiSidebar.tsx b/apps/web/src/components/ai-sidebar/AiSidebar.tsxindex 398b8965..da1e0482 100644--- a/apps/web/src/components/ai-sidebar/AiSidebar.tsx+++ b/apps/web/src/components/ai-sidebar/AiSidebar.tsx@@ -61,6 +61,7 @@ import {subscribeDesktopAcp,startsNewLocalAgentThread,type DesktopAcpEvent,+ desktopAcpNoteAccessErrorKey,} from "@/lib/desktop-acp";import {chatThreadsFromTurns,@@ -995,7 +996,8 @@ function AiSidebarSession({? { ...turn, status: event.type === "error" ? "failed" : "completed" }: turn));if (event.type === "error" && event.message) {- setError(event.message === "note_access_unavailable" ? t("aiAssistant.sidebar.noteAccessUnavailable")+ const noteAccessErrorKey = desktopAcpNoteAccessErrorKey(event.message);+ setError(noteAccessErrorKey ? t(noteAccessErrorKey): event.message === "workbuddy_credentials_unavailable" ? t("aiAssistant.agentSource.workbuddyCredentialsUnavailable"): event.message === "needs_login" ? t(localAdapterId === "workbuddyCn" || localAdapterId === "workbuddyIntl"? "aiAssistant.sidebar.workbuddyLoginRequired" : "aiAssistant.sidebar.localLoginRequired")diff --git a/apps/web/src/lib/desktop-acp.test.mjs b/apps/web/src/lib/desktop-acp.test.mjsindex 9835cc85..0ca2a1a1 100644--- a/apps/web/src/lib/desktop-acp.test.mjs+++ b/apps/web/src/lib/desktop-acp.test.mjs@@ -1,5 +1,5 @@import { expect, test } from "bun:test";-import { aiSidebarAdapterFromStorage, aiSidebarSourceFromStorage, displayedDesktopAcpAdapter } from "./desktop-acp.ts";+import { desktopAcpNoteAccessErrorKey, aiSidebarAdapterFromStorage, aiSidebarSourceFromStorage, displayedDesktopAcpAdapter } from "./desktop-acp.ts";test("a checked custom Antigravity executable takes priority over the managed connector status", () => {const managed = { id: "antigravity", label: "Antigravity", state: "failed", version: "1.2.1", managed: true };@@ -135,3 +135,11 @@ test("the quick selector hides absent connectors while keeping detected agents aexpect(desktopAcpSelectorVisible(custom, " /custom/agy ")).toBe(true);expect(desktopAcpSelectorVisible(custom, " ")).toBe(false);});++test("note access failures distinguish network, EdgeEver sign-in, and account changes", () => {+ expect(desktopAcpNoteAccessErrorKey("note_access_network")).toBe("aiAssistant.sidebar.noteAccessNetwork");+ expect(desktopAcpNoteAccessErrorKey("note_access_login_required")).toBe("aiAssistant.sidebar.noteAccessLoginRequired");+ expect(desktopAcpNoteAccessErrorKey("note_access_changed")).toBe("aiAssistant.sidebar.noteAccessChanged");+ expect(desktopAcpNoteAccessErrorKey("note_access_unavailable")).toBe("aiAssistant.sidebar.noteAccessUnavailable");+ expect(desktopAcpNoteAccessErrorKey("needs_login")).toBeNull();+});diff --git a/apps/web/src/lib/desktop-acp.ts b/apps/web/src/lib/desktop-acp.tsindex 3aec6d80..20c61092 100644--- a/apps/web/src/lib/desktop-acp.ts+++ b/apps/web/src/lib/desktop-acp.ts@@ -203,3 +203,13 @@ export const subscribeDesktopAcp = (callback: (event: DesktopAcpEvent) => void)if (!desktop?.onAcpEvent) return () => undefined;return desktop.onAcpEvent(callback);};++export const desktopAcpNoteAccessErrorKey = (message: string) => {+ switch (message) {+ case "note_access_network": return "aiAssistant.sidebar.noteAccessNetwork";+ case "note_access_login_required": return "aiAssistant.sidebar.noteAccessLoginRequired";+ case "note_access_changed": return "aiAssistant.sidebar.noteAccessChanged";+ case "note_access_unavailable": return "aiAssistant.sidebar.noteAccessUnavailable";+ default: return null;+ }+};diff --git a/apps/web/src/lib/infographic-local-agent.test.mjs b/apps/web/src/lib/infographic-local-agent.test.mjsindex b59b5ea0..1897fa9b 100644--- a/apps/web/src/lib/infographic-local-agent.test.mjs+++ b/apps/web/src/lib/infographic-local-agent.test.mjs@@ -1,6 +1,7 @@import { expect, test } from "bun:test";import {buildInfographicLocalAgentContext,+ infographicLocalAgentErrorKey,collectInfographicLocalAgentText,parseInfographicLocalReply,visibleInfographicAgentReply,@@ -89,3 +90,9 @@ test("local infographic text follows one ACP request and can be cancelled", asyn})).rejects.toThrow("aborted");expect(cancelId).toBe("req-2");});++test("infographic requests use the same note access errors without blaming the agent login", () => {+ expect(infographicLocalAgentErrorKey("note_access_network", "workbuddyIntl")).toBe("aiAssistant.sidebar.noteAccessNetwork");+ expect(infographicLocalAgentErrorKey("note_access_login_required", "workbuddyIntl")).toBe("aiAssistant.sidebar.noteAccessLoginRequired");+ expect(infographicLocalAgentErrorKey("note_access_changed", "codex")).toBe("aiAssistant.sidebar.noteAccessChanged");+});diff --git a/apps/web/src/lib/infographic-local-agent.ts b/apps/web/src/lib/infographic-local-agent.tsindex 7d22aa91..2c2aa258 100644--- a/apps/web/src/lib/infographic-local-agent.ts+++ b/apps/web/src/lib/infographic-local-agent.ts@@ -1,6 +1,7 @@import { infographicRequestsTimeline } from "@edgeever/shared";import {cancelDesktopAcp,+ desktopAcpNoteAccessErrorKey,promptDesktopAcp,subscribeDesktopAcp,type DesktopAcpEvent,@@ -110,7 +111,8 @@ export const infographicLocalAgentErrorKey = (message: string, adapterId: string: "aiAssistant.sidebar.localLoginRequired";}if (message === "agent_refused") return "aiAssistant.sidebar.agentRefused";- if (message === "note_access_unavailable") return "aiAssistant.sidebar.noteAccessUnavailable";+ const noteAccessErrorKey = desktopAcpNoteAccessErrorKey(message);+ if (noteAccessErrorKey) return noteAccessErrorKey;if (message === "not_installed" || message === "desktop_acp_unavailable") return "aiAssistant.sidebar.localMissing";return null;};diff --git a/packages/shared/src/i18n/en-US.ts b/packages/shared/src/i18n/en-US.tsindex 73fc8a1b..6eea2013 100644--- a/packages/shared/src/i18n/en-US.ts+++ b/packages/shared/src/i18n/en-US.ts@@ -1673,6 +1673,9 @@ export const enUS = {localStatus: "Local agent",localMissing: "No local agent is available. Choose an adapter, or use the built-in assistant.",noteAccessUnavailable: "Could not connect to this account's notes. Check the instance connection and sign-in status, then try again.",+ noteAccessNetwork: "Could not connect to your notes right now. Check your network or instance service, then try again.",+ noteAccessLoginRequired: "Your EdgeEver session is unavailable or expired. Sign in to the current instance again, then retry.",+ noteAccessChanged: "The instance or account changed, so this request was stopped. Try again with the current account.",localLoginRequired: "This local agent needs sign-in. Sign in under Settings → Models & Agents, then try again.",workbuddyLoginRequired: "WorkBuddy ACP could not use a saved sign-in. Choose an ACP sign-in method under Settings → Models & Agents, then try again.",agentRefused: "The local agent refused this request. Check its sign-in status or model settings, then try again.",diff --git a/packages/shared/src/i18n/ja.ts b/packages/shared/src/i18n/ja.tsindex 9b419467..7d507a93 100644--- a/packages/shared/src/i18n/ja.ts+++ b/packages/shared/src/i18n/ja.ts@@ -1662,6 +1662,9 @@ export const ja = {localStatus: "ローカル Agent",localMissing: "使えるローカル Agent がありません。アダプターを選ぶか、内蔵アシスタントを使ってください。",noteAccessUnavailable: "このアカウントのノートに接続できません。インスタンスへの接続とログイン状態を確認して、再試行してください。",+ noteAccessNetwork: "現在ノートに接続できません。ネットワークまたはインスタンスのサービスを確認して再試行してください。",+ noteAccessLoginRequired: "EdgeEver のログイン情報がないか期限切れです。現在のインスタンスに再度ログインして再試行してください。",+ noteAccessChanged: "インスタンスまたはアカウントが変更されたため、このリクエストを停止しました。現在のアカウントで再試行してください。",localLoginRequired: "ローカル Agent へのログインが必要です。「設定 → モデルとエージェント」でログインしてから再試行してください。",workbuddyLoginRequired: "WorkBuddy ACP は保存済みのログインを利用できませんでした。「設定 → モデルとエージェント」で ACP のログイン方法を選び、再試行してください。",agentRefused: "ローカル Agent がこのリクエストを拒否しました。ログイン状態またはモデル設定を確認して再試行してください。",diff --git a/packages/shared/src/i18n/pl.ts b/packages/shared/src/i18n/pl.tsindex a8faca68..5a31ee74 100644--- a/packages/shared/src/i18n/pl.ts+++ b/packages/shared/src/i18n/pl.ts@@ -1662,6 +1662,9 @@ export const pl = {localStatus: "Lokalny agent",localMissing: "Brak dostępnego lokalnego agenta. Wybierz adapter lub użyj wbudowanego asystenta.",noteAccessUnavailable: "Nie udało się połączyć z notatkami tego konta. Sprawdź połączenie z instancją i stan logowania, a potem spróbuj ponownie.",+ noteAccessNetwork: "Nie można teraz połączyć się z notatkami. Sprawdź sieć lub usługę instancji i spróbuj ponownie.",+ noteAccessLoginRequired: "Sesja EdgeEver jest niedostępna lub wygasła. Zaloguj się ponownie do bieżącej instancji i ponów próbę.",+ noteAccessChanged: "Instancja lub konto uległo zmianie, więc to żądanie zostało zatrzymane. Spróbuj ponownie z bieżącym kontem.",localLoginRequired: "Ten lokalny agent wymaga zalogowania. Zaloguj się w Ustawienia → Modele i agenci, a potem spróbuj ponownie.",workbuddyLoginRequired: "WorkBuddy ACP nie mógł użyć zapisanego logowania. Wybierz metodę logowania ACP w Ustawienia → Modele i agenci, a potem spróbuj ponownie.",agentRefused: "Lokalny agent odrzucił to żądanie. Sprawdź jego stan logowania lub ustawienia modelu, a potem spróbuj ponownie.",diff --git a/packages/shared/src/i18n/zh-CN.ts b/packages/shared/src/i18n/zh-CN.tsindex 30e3d236..c55a8e37 100644--- a/packages/shared/src/i18n/zh-CN.ts+++ b/packages/shared/src/i18n/zh-CN.ts@@ -1673,6 +1673,9 @@ export const zhCN = {localStatus: "本地 Agent",localMissing: "还没有可用的本地 Agent。请先选择适配器,或改用内置助手。",noteAccessUnavailable: "无法连接当前账号的笔记库。请检查实例连接和登录状态后重试。",+ noteAccessNetwork: "暂时无法连接笔记库。请检查网络或实例服务后重试。",+ noteAccessLoginRequired: "EdgeEver 登录已失效,无法连接笔记库。请重新登录当前实例后重试。",+ noteAccessChanged: "当前实例或账号已变化,本次请求已停止。请在当前账号下重试。",localLoginRequired: "本地 Agent 需要登录。请在“设置 → 模型与代理”中完成登录后重试。",workbuddyLoginRequired: "WorkBuddy ACP 未能使用已有登录。请在“设置 → 模型与代理”中选择 ACP 登录方式,完成后重试。",agentRefused: "本地 Agent 拒绝了这次请求。请检查代理的登录状态或模型配置后重试。",diff --git a/tests/fixtures/acp-mcp-bridge-stdio-harness.mjs b/tests/fixtures/acp-mcp-bridge-stdio-harness.mjsindex 3a1bc175..f394d021 100644--- a/tests/fixtures/acp-mcp-bridge-stdio-harness.mjs+++ b/tests/fixtures/acp-mcp-bridge-stdio-harness.mjs@@ -7,16 +7,29 @@ import { startAcpMcpBridge } from "../../apps/desktop/src/main/acp-mcp-bridge.mjconst sessionToken = "long-lived-session";const authorizations = [];+let failNextSession = false;+let failToolCall = false;+let toolCalls = 0;const upstream = createServer((request, response) => {authorizations.push(request.headers.authorization);response.setHeader("Content-Type", "application/json");if (request.url === "/api/v1/auth/session") {+ if (failNextSession) {+ failNextSession = false;+ response.writeHead(503).end("temporary outage");+ return;+ }response.end(JSON.stringify({authenticated: request.headers.authorization === `Bearer ${sessionToken}`,user: { id: "account-one" },}));return;}+ if (failToolCall) {+ toolCalls++;+ response.writeHead(503).end("write response unavailable");+ return;+ }response.end(JSON.stringify({ jsonrpc: "2.0", id: 1, result: { tools: [] } }));});@@ -54,13 +67,40 @@ try {baseUrl: upstreamUrl,sessionToken: "invalid-session",isCurrent: () => true,- }), /note_access_unavailable/);+ }), /note_access_login_required/);await assert.rejects(startAcpMcpBridge({baseUrl: upstreamUrl,sessionToken,accountId: "account-two",isCurrent: () => true,- }), /note_access_unavailable/);+ }), /note_access_changed/);++ failNextSession = true;+ const transportCalls = [];+ const recoveredBridge = await startAcpMcpBridge({+ baseUrl: upstreamUrl, sessionToken, accountId: "account-one", isCurrent: () => true,+ fetchImpl: async (url, init) => {+ transportCalls.push({ url, method: init.method ?? "GET" });+ return fetch(url, init);+ },+ });+ try {+ assert.equal(transportCalls.length, 2);+ assert.equal(transportCalls.every(call => call.method === "GET" && call.url.endsWith("/api/v1/auth/session")), true);+ failToolCall = true;+ const result = await fetch(`${recoveredBridge.url}/mcp`, {+ method: "POST",+ headers: { authorization: `Bearer ${recoveredBridge.secret}`, "content-type": "application/json" },+ body: JSON.stringify({ jsonrpc: "2.0", id: 2, method: "tools/call", params: { name: "memo_create", arguments: {} } }),+ });+ assert.equal(result.status, 503);+ assert.equal(toolCalls, 1);+ assert.equal(transportCalls.length, 3);+ assert.equal(transportCalls.at(-1).method, "POST");+ } finally {+ failToolCall = false;+ await recoveredBridge.close();+ }const script = fileURLToPath(new URL("../../scripts/edgeever-mcp-stdio.mjs", import.meta.url));child = spawn(process.execPath, [script], {@@ -83,7 +123,7 @@ try {const response = await responsePromise;assert.deepEqual(response.result, { tools: [] });assert.equal(authorizations.at(-1), `Bearer ${sessionToken}`);- writeFileSync(process.env.EDGE_EVER_TEST_RESULT_PATH, JSON.stringify({ security: true, invalidSession: true, stdio: true }));+ writeFileSync(process.env.EDGE_EVER_TEST_RESULT_PATH, JSON.stringify({ security: true, invalidSession: true, stdio: true, retryRecovery: true, noWriteReplay: true }));} catch (error) {console.error(error);process.exitCode = 1;