Extension broken against current flow.google.com — auth, captcha, and callback all need fixes
Flow's product has moved from labs.google/fx/tools/flow to flow.google.com, and several parts of the extension/backend no longer work against the new site. Found and fixed the following while debugging (happy to open a PR if useful):
background.js — getOrOpenFlowTab() returns retryTabs[0], an undefined variable, when creating a fresh tab. Should return createdTab. This throws retryTabs is not defined on every fresh-tab path. manifest.json — missing flow.google.com everywhere labs.google appears: host_permissions, content_scripts.matches, web_accessible_resources.matches. Without it, Chrome blocks all extension scripting on the new domain with Extension manifest must request permission to access this host. rules.json — declarativeNetRequest rule hardcodes Referer/Origin to https://labs.google/ for all aisandbox-pa.googleapis.com requests. Should be https://flow.google.com/ to match the real current frontend origin. No Bearer token is ever sent by the new site — flow.google.com authenticates its own //AiSandboxAngularFrontend/data/batchexecute calls via cookies, not Authorization: Bearer ya29.... The extension's token-capture listener (chrome.webRequest.onBeforeSendHeaders) never fires, so has_flow_key stays false indefinitely on a fresh session. grecaptcha is not present on flow.google.com (confirmed via window.grecaptcha → undefined in console) — at least not until deep in the actual generate flow, where the real page instead calls google.com/recaptcha/enterprise/clr directly. The extension's hardcoded SITE_KEY + grecaptcha.enterprise.execute() approach in injected.js doesn't apply. The real generate call is rpcids=ogiZ0b on batchexecute, using image model enum HARBOR_SEAL (and presumably others per the narwhal/GEM_PIX list from the HTrJv app-config call) — a completely different shape from the old aisandbox-pa.googleapis.com/v1/images:batchGenerateImages REST call flow_engine/config.py's API_BASE targets. Confirmed this call succeeds and returns a real signed flow-content.google/image/... CDN URL when the page's own UI does it. Separately, sendToAgent()'s HTTP-callback path doesn't handle a 401/403 from /api/ext/callback — fetch() doesn't throw on those, and .catch(() => {}) swallows it. Since the server generates a new _callback_secret on every restart but the extension's httpConnected flag doesn't reset with it, a restarted backend silently stops receiving anything from an already-connected extension until the next full extension reload.