Skip to content

armgit / cindy

Public Imported from GitHub
0

Consider it done. The open-source AI agent that works out of the box · 想到,就能做到。开源、开箱即用的 AI Agent。

fix(desktop): 浏览器自动化目标默认回到外置 Chrome

Lizi5e935399f01e
diff --git a/apps/desktop/src/main/browser-backend-settings-store.ts b/apps/desktop/src/main/browser-backend-settings-store.ts
index 3de7de77b5..ad45c2995c 100644
--- a/apps/desktop/src/main/browser-backend-settings-store.ts
+++ b/apps/desktop/src/main/browser-backend-settings-store.ts
@@ -4,15 +4,45 @@
*
* File: <userData>/browser-backend-settings.json
*
- * Defaults: `kind: 'rsb-webview'`. The internal sidebar browser is the new
- * product default — users who installed before Phase 5 see a behavioral
- * change on first launch. Switching to `'external'` restores the old managed
- * Chrome behavior verbatim (backend wraps the unchanged vendored runtime).
+ * Defaults: `kind: 'external'` — the standalone managed Chrome. Rationale for
+ * making the *external* browser the default rather than the in-app webview:
+ * browser automation spends its time on arbitrary untrusted pages, so engine
+ * patch freshness matters more here than anywhere else in the app. Chrome
+ * Stable self-updates within days of a Chromium 0-day; the in-app webview runs
+ * on the Chromium bundled with our Electron, which only moves when we ship a
+ * client update. The external backend still isolates the agent from the user's
+ * everyday browsing: same Chrome binary, but a dedicated `Cindy` profile with
+ * its own user-data-dir (see mcp-integrations/browser.ts).
*
- * Stored as a single field so future Phase 5+ knobs (e.g. snapshot format
- * preference) can join the same file under override-settings-file semantics
- * (rule 20: system default vs. user override is preserved, "reset" clears the
- * override rather than overwriting with a frozen snapshot).
+ * Accepted trade-offs of this default (do not "fix" one without re-reading the
+ * other): the managed Chrome exposes a loopback CDP port, and its process
+ * teardown is best-effort (win32 process-tree cleanup is unverified — see the
+ * NOTE in mcp-integrations/browser.ts `disposeBrowserRuntime`). Users who want
+ * the tighter in-app isolation (no CDP port, session-dir-confined uploads)
+ * switch to `'rsb-webview'` in Settings →「自动操作」.
+ *
+ * DEFAULT HISTORY — this value has flipped twice; the override semantics below
+ * are what keep that from thrashing users:
+ * - Phase 1: `'external'` was the only backend.
+ * - Phase 5: default became `'rsb-webview'` when the in-app browser shipped.
+ * - Now: back to `'external'` for the patch-freshness reason above.
+ * Per docs/dev-rules/configuration-and-overrides.md §3, the flip is driven by
+ * *override state*, never by guessing intent from the stored value:
+ * - new users → `'external'`;
+ * - existing users who never touched the toggle (no override file / no `kind`
+ * key) → follow the new default, i.e. move back to `'external'`;
+ * - existing users who explicitly picked either backend → keep their choice
+ * untouched, including anyone who deliberately chose `'rsb-webview'`.
+ * No migration step is needed for this: `createOverrideSettingsFile` persists
+ * only the override, so "never customized" is directly observable. Note the
+ * two backends do NOT share login state — a user moved back to `'external'` by
+ * this default change starts from that profile's own cookies, and whatever they
+ * logged into inside the sidebar browser stays in the webview partition.
+ *
+ * Stored as a single field so future knobs (e.g. snapshot format preference)
+ * can join the same file under override-settings-file semantics (rule 20:
+ * system default vs. user override is preserved, "reset" clears the override
+ * rather than overwriting with a frozen snapshot).
*/
import { app } from 'electron';
@@ -32,7 +62,7 @@ export interface BrowserBackendSettings {
}
const DEFAULTS: BrowserBackendSettings = {
- kind: 'rsb-webview',
+ kind: 'external',
};
const VALID_KINDS: readonly BackendKind[] = ['external', 'rsb-webview'];
diff --git a/apps/desktop/src/main/mcp-integrations/browser.ts b/apps/desktop/src/main/mcp-integrations/browser.ts
index 3887b83aa3..848d644b00 100644
--- a/apps/desktop/src/main/mcp-integrations/browser.ts
+++ b/apps/desktop/src/main/mcp-integrations/browser.ts
@@ -101,11 +101,13 @@ const MANAGED_CDP_PORT = 18800;
* Default ("managed") config: a single playwright-launched Chrome profile, headed,
* with a STABLE persistent user-data-dir (logins survive across sessions). This is
* the product default — a "dedicated persistent login automation browser".
+ * (`browser-backend-settings-store` resolves `'external'` as the system default,
+ * so this config is what a user who never touched the toggle gets.)
*
* SECURITY POSTURE (intentional, owner-decided 2026-06):
* - No `ssrfPolicy` is set → the strict browser-side DNS-rebinding gate +
* redirect-chain inspection stay OFF, so the agent CAN navigate to
- * localhost / private-network hosts. This is deliberate: XDMaker is an internal
+ * localhost / private-network hosts. This is deliberate: Cindy is an internal
* tool and users need the agent to drive local dev servers / internal sites.
* (Private-IP *literals* are still classified by the vendored resolver; what's
* intentionally allowed is hostname→private navigation.) Do not arm
@@ -224,9 +226,11 @@ const rsbBackend = new RsbWebviewBackend({
});
/**
- * Initial backend selection — driven by the persisted Phase 5 settings file.
- * On first launch (no override) the system default `'rsb-webview'` is applied
- * so users see the new behavior out of the box.
+ * Initial backend selection — driven by the persisted settings file. On first
+ * launch (no override) the system default from `browser-backend-settings-store`
+ * is applied; that default is `'external'` (the managed Chrome below). Users
+ * who explicitly picked a backend keep their choice — see the DEFAULT HISTORY
+ * note in that store for the override semantics behind the two flips.
*/
function backendForKind(kind: BackendKind): BrowserBackend {
switch (kind) {
@@ -368,8 +372,8 @@ export async function getBrowserAvailability(): Promise<BrowserAvailability> {
}
/**
- * Read the currently-active backend kind. Phase 1 always returns `'external'`;
- * Phase 5 wires this to a Settings-driven toggle.
+ * Read the currently-active backend kind. Reflects the Settings-driven toggle
+ * (persisted override) merged over the system default, not a fixed value.
*/
export function getActiveBrowserBackendKind(): BackendKind {
return router.getCurrentBackendKind();
@@ -444,7 +448,7 @@ export async function openBrowserForLogin(): Promise<void> {
//
// **Always** goes to the vendored runtime, NOT the router — "打开 Agent 专用浏
// 览器" is the external Chrome workflow: user clicks it to log into sites in
- // the dedicated XDMaker profile. If the user picked the rsb-webview backend
+ // the dedicated `Cindy` profile. If the user picked the rsb-webview backend
// they don't need this button at all (logins go through the sidebar webview);
// routing through router would either no-op (rsb backend's `start` is a
// no-op) or open the wrong thing.
diff --git a/apps/desktop/src/renderer/vite-env.d.ts b/apps/desktop/src/renderer/vite-env.d.ts
index 527fb57707..b6b54069fa 100644
--- a/apps/desktop/src/renderer/vite-env.d.ts
+++ b/apps/desktop/src/renderer/vite-env.d.ts
@@ -2517,7 +2517,7 @@ interface ElectronAPI {
force?: boolean;
/** 完整安装目标路径。不传 → global scope 默认路径。*/
installPath?: string;
- /** force 覆盖时跳过 XDMaker 持久备份,直接 rmrf 旧目录(完整替换)。 */
+ /** force 覆盖时跳过 Cindy 持久备份,直接 rmrf 旧目录(完整替换)。 */
skipBackup?: boolean;
}) => Promise<
| { success: true; name: string; version: string; absolutePath: string }
@@ -3509,9 +3509,10 @@ interface ElectronAPI {
};
/**
- * Browser backend toggle (Phase 5): 切换 MCP `browser` 工具实际控制的浏览器。
- * - `external`: vendored Playwright + 独立 Chrome(老行为)
- * - `rsb-webview`: 右侧栏内置 webview tab(新默认)
+ * Browser backend toggle: 切换 MCP `browser` 工具实际控制的浏览器。
+ * - `external`: vendored Playwright + 独立 Chrome(**系统默认**)
+ * - `rsb-webview`: 右侧栏内置 webview tab
+ * 默认值口径与两次翻转的 override 语义见 main/browser-backend-settings-store.ts。
*/
browserBackend: {
getState: () => Promise<{