Consider it done. The open-source AI agent that works out of the box · 想到,就能做到。开源、开箱即用的 AI Agent。
TypeScript agentai-agentai-assistantandroidclaude-codecodexelectroniosllmmacosreact-nativetypescriptwindows
fix(browser): 配方 CDP 复用页签别名解析
Dash07100054d756
diff --git a/packages/browser-control-runtime/src/runtime.ts b/packages/browser-control-runtime/src/runtime.tsindex 3559df07ac..9a7ff57490 100644--- a/packages/browser-control-runtime/src/runtime.ts+++ b/packages/browser-control-runtime/src/runtime.ts@@ -22,6 +22,7 @@ import type {import { parseBrowserProxyServer, redactBrowserProxyText } from './proxy.js';import { RecipeBrowserSessions } from './recipe-sessions.js';import { openRecipeSocket } from './recipe-socket.js';+import { resolveTargetIdFromTabs } from './_generated/extension/src/browser/target-id.js';type Method = 'GET' | 'POST' | 'DELETE';interface DispatchPlan {@@ -264,9 +265,14 @@ export function createBrowserControlRuntime(const listed = await dispatchBrowserControlRequest({ method: 'GET', path: '/tabs', query: request.profile ? { profile: request.profile } : undefined });if (listed.status >= 400) throw new Error('Cannot resolve browser recipe target');const tabs = (listed.body as { tabs?: Array<{ targetId: string; wsUrl?: string }> }).tabs ?? [];- const tab = tabs.find(item => item.targetId === request.targetId);+ const resolved = resolveTargetIdFromTabs(request.targetId, tabs);+ if (!resolved.ok) throw new Error(`Selected browser recipe target is ${resolved.reason}`);+ const tab = tabs.find(item => item.targetId === resolved.targetId);if (!tab?.wsUrl) throw new Error('Selected browser recipe target is unavailable');- const data = { sessionId: recipeSessions.begin(scope, await openRecipeSocket(tab.wsUrl)) };+ const data = {+ targetId: tab.targetId,+ sessionId: recipeSessions.begin(JSON.stringify([request.profile ?? '', tab.targetId]), await openRecipeSocket(tab.wsUrl)),+ };return { ok: true, action: request.action, data };} catch (error) {return { ok: false, action: request.action, message: error instanceof Error ? error.message : String(error) };diff --git a/scripts/verify-opencli-browser.mjs b/scripts/verify-opencli-browser.mjsindex b83cf9fe71..3de19b4017 100644--- a/scripts/verify-opencli-browser.mjs+++ b/scripts/verify-opencli-browser.mjs@@ -93,6 +93,19 @@ try {url,);await page.goto(url);+ // #6822 accepts labels/prefixes; adapter CDP must select the same canonical+ // target before its first command, then keep that scope through disposal.+ const labelled = await runtime.call({ action: 'open', profile: 'recipe-test', url, label: 'recipe-fixture-alias' });+ assert.equal(labelled.ok, true);+ for (const targetId of ['recipe-fixture-alias', labelled.data.targetId.slice(0, 8)]) {+ const aliasPage = new OpenCliPage({ targetId, call: (request) => runtime.call({ ...request, profile: 'recipe-test' }) });+ try {+ await aliasPage.getCookies();+ const document = await aliasPage.cdp('DOM.getDocument');+ assert.ok(document.root.nodeId);+ } finally { await aliasPage.dispose(); }+ }+ console.log(JSON.stringify({ ok: true, checks: ['CDP-label', 'CDP-target-prefix'] }));assert.equal(await page.evaluate("document.title"), "Recipe fixture");assert.equal(await page.evaluate((a, b) => a + b, 2, 3), 5);await page.fillText("#name", "Cindy fixture");