





















@@ -231,6 +231,12 @@ type BrowserTab = {
231231url?: string;
232232};
233233234+const GOOGLE_MEET_NEW_URL = "https://meet.google.com/new";
235+const GOOGLE_MEET_BROWSER_CREATE_TIMEOUT_MS = 60_000;
236+const GOOGLE_MEET_BROWSER_STEP_TIMEOUT_MS = 10_000;
237+const GOOGLE_MEET_BROWSER_NAVIGATION_RETRY_MS = 1_000;
238+const GOOGLE_MEET_BROWSER_POLL_MS = 500;
239+234240type BrowserCreateStepResult = {
235241meetingUri?: string;
236242browserUrl?: string;
@@ -324,6 +330,50 @@ function readBrowserTab(result: unknown): BrowserTab | undefined {
324330return result && typeof result === "object" ? (result as BrowserTab) : undefined;
325331}
326332333+function isGoogleMeetCreateTab(tab: BrowserTab): boolean {
334+const url = tab.url ?? "";
335+if (/^https:\/\/meet\.google\.com\/(?:new|[a-z]{3}-[a-z]{4}-[a-z]{3})(?:$|[/?#])/i.test(url)) {
336+return true;
337+}
338+return (
339+url.startsWith("https://accounts.google.com/") &&
340+/sign in|google accounts|meet/i.test(tab.title ?? "")
341+);
342+}
343+344+async function findGoogleMeetCreateTab(params: {
345+runtime: PluginRuntime;
346+nodeId: string;
347+timeoutMs: number;
348+}): Promise<BrowserTab | undefined> {
349+const tabs = asBrowserTabs(
350+await callBrowserProxyOnNode({
351+runtime: params.runtime,
352+nodeId: params.nodeId,
353+method: "GET",
354+path: "/tabs",
355+timeoutMs: params.timeoutMs,
356+}),
357+);
358+return tabs.find(isGoogleMeetCreateTab);
359+}
360+361+async function focusBrowserTab(params: {
362+runtime: PluginRuntime;
363+nodeId: string;
364+targetId: string;
365+timeoutMs: number;
366+}): Promise<void> {
367+await callBrowserProxyOnNode({
368+runtime: params.runtime,
369+nodeId: params.nodeId,
370+method: "POST",
371+path: "/tabs/focus",
372+body: { targetId: params.targetId },
373+timeoutMs: params.timeoutMs,
374+});
375+}
376+327377function readStringArray(value: unknown): string[] | undefined {
328378return Array.isArray(value)
329379 ? value.filter((entry): entry is string => typeof entry === "string")
@@ -454,17 +504,35 @@ export async function createMeetWithBrowserProxyOnNode(params: {
454504runtime: params.runtime,
455505requestedNode: params.config.chromeNode.node,
456506});
457-const timeoutMs = Math.max(15_000, params.config.chrome.joinTimeoutMs);
458-const tab = readBrowserTab(
459-await callBrowserProxyOnNode({
507+const timeoutMs = Math.max(
508+GOOGLE_MEET_BROWSER_CREATE_TIMEOUT_MS,
509+params.config.chrome.joinTimeoutMs,
510+);
511+const stepTimeoutMs = Math.min(timeoutMs, GOOGLE_MEET_BROWSER_STEP_TIMEOUT_MS);
512+let tab = await findGoogleMeetCreateTab({
513+runtime: params.runtime,
514+ nodeId,
515+timeoutMs: stepTimeoutMs,
516+});
517+if (tab?.targetId) {
518+await focusBrowserTab({
460519runtime: params.runtime,
461520 nodeId,
462-method: "POST",
463-path: "/tabs/open",
464-body: { url: "https://meet.google.com/new" },
465- timeoutMs,
466-}),
467-);
521+targetId: tab.targetId,
522+timeoutMs: stepTimeoutMs,
523+});
524+} else {
525+tab = readBrowserTab(
526+await callBrowserProxyOnNode({
527+runtime: params.runtime,
528+ nodeId,
529+method: "POST",
530+path: "/tabs/open",
531+body: { url: GOOGLE_MEET_NEW_URL },
532+timeoutMs: stepTimeoutMs,
533+}),
534+);
535+}
468536const targetId = tab?.targetId;
469537if (!targetId) {
470538throw new Error("Browser fallback opened Google Meet but did not return a targetId.");
@@ -485,7 +553,7 @@ export async function createMeetWithBrowserProxyOnNode(params: {
485553 targetId,
486554fn: CREATE_MEET_FROM_BROWSER_SCRIPT,
487555},
488-timeoutMs: Math.min(timeoutMs, 10_000),
556+timeoutMs: stepTimeoutMs,
489557});
490558const result = readBrowserCreateResult(evaluated);
491559lastResult = result;
@@ -509,13 +577,13 @@ export async function createMeetWithBrowserProxyOnNode(params: {
509577}
510578throw new Error(result.manualAction);
511579}
512-await sleep(result.retryAfterMs ?? 500);
580+await sleep(result.retryAfterMs ?? GOOGLE_MEET_BROWSER_POLL_MS);
513581} catch (error) {
514582lastError = error;
515583if (!isBrowserNavigationInterruption(error)) {
516584throw error;
517585}
518-await sleep(1_000);
586+await sleep(GOOGLE_MEET_BROWSER_NAVIGATION_RETRY_MS);
519587}
520588}
521589throw new Error(
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。