From 026b8a6f517d5c414c491ec5f9b414c0aebdfe98 Mon Sep 17 00:00:00 2001 From: Flavio Oliva Date: Sun, 29 Nov 2026 21:54:46 +0000 Subject: [PATCH 1/3] feat(video): headless download-menu upscales by default (#1554) Under `auto` on flow.google.com, `video upscale --scale 720p` and `--scale 270p` drive the download menu in a headless browser, on the CLI and on gflow_upscale_video: each ran twice headless matching a headed control, spent no credits, and passed headless on an account that was refusing headless image upscales at the time (docs/superpowers/spikes/2026-11-30-headless-video-upscale.md). `video upscale --scale 4k` (Ultra only) follows the same path by decision, recorded as unmeasured. 1080p through the menu and every image upscale stay headed. upscale_visibility applies one rule to the download-menu path for both kinds and takes an already-planned route, so the MCP upscale tools read the catalog row once. The 270p GIF e2e launches through the production rule, and a new MCP 720p e2e asserts the headless launch. Refs #1554 --- AGENTS.md | 4 +- CHANGELOG.md | 10 +++ README.md | 6 +- README.zh-CN.md | 6 +- docs/ACCOUNT_SAFETY.md | 2 +- docs/ARCHITECTURE.md | 5 +- docs/BROWSER_MODES.md | 4 +- docs/CONFIGURATION.md | 2 +- docs/MCP.md | 2 +- .../2026-11-30-headless-video-upscale.md | 39 +++++++++ scripts/dev/spike_headless_video_upscale.py | 81 +++++++++++++++++++ src/gflow_cli/_cli_helpers.py | 39 ++++++--- src/gflow_cli/mcp/tools.py | 7 +- tests/e2e/test_migrated_upscale_e2e.py | 51 +++++++++++- tests/test_cli_browser_visibility.py | 51 ++++++++++++ website/docs/ACCOUNT_SAFETY.md | 2 +- website/docs/ARCHITECTURE.md | 5 +- website/docs/BROWSER_MODES.md | 4 +- website/docs/CONFIGURATION.md | 2 +- website/docs/MCP.md | 2 +- 20 files changed, 290 insertions(+), 34 deletions(-) create mode 100644 docs/superpowers/spikes/2026-11-30-headless-video-upscale.md create mode 100644 scripts/dev/spike_headless_video_upscale.py diff --git a/AGENTS.md b/AGENTS.md index d6689a0d7..1ac48bd25 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -70,8 +70,10 @@ In v0.108.0: direct once the file is uploaded, launches headless under `auto`, including the UI fallback (measured, #1554). - **`image upscale` stays headed:** a headless 2K upscale was refused as unusual activity on one of two accounts while headed passed (#1554). +- **`video upscale` 720p / 270p GIF** drive the download menu headless (measured, 0 credits); 4K + video follows that path headless by decision (Ultra only, unmeasured; #1554). - **The remaining UI surfaces stay headed** (`ui_automation`: `image batch`, `movie run`, r2v, edit, end-frame i2v, - 4K/720p/GIF upscale, scene/character create, instructions, the agent composer, + 1080p menu upscale, scene/character create, instructions, the agent composer, other credit-capped video; on an account served flow.google.com, gflow cannot drive instructions, scenes or characters yet in either mode, #639/#1587). Headless UI is tracked in #1554. - **`auth login`** is interactive and needs a display once; `auth renew` and the credits read diff --git a/CHANGELOG.md b/CHANGELOG.md index 3b3bfc8f5..f1972ad88 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -20,6 +20,16 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Changed +- **The video download-menu upscales run headless by default** ([#1554](https://github.com/ffroliva/gflow-cli/issues/1554)). Under `auto` on + flow.google.com, `video upscale --scale 720p` and `--scale 270p` drive the download menu in a + headless browser, on the CLI and on `gflow_upscale_video`: each ran twice headless matching a + headed control and spent no credits, including on an account that was refusing headless image + upscales at the time. `video upscale --scale 4k` (Ultra only) follows the same path headless by + decision; it was not measured, as no Ultra account was available. 1080p through the menu (a + clip outside the measured direct shape) and every image upscale stay headed. + `GFLOW_CLI_TRANSPORT=ui_automation`, an explicit `GFLOW_CLI_FLOW_HOST=labs.google` and + `--browser-visibility headed` keep the window. The MCP upscale tools now plan from the route + they already computed, so the catalog row is read once. - **`image upscale`, `image upload` and `image batch` stay headed, with the evidence recorded** ([#1554](https://github.com/ffroliva/gflow-cli/issues/1554)). A 2K upscale passed headless 5/5 on two accounts until, after a day of runs on one of them, Flow refused three headless 2K upscales as `PUBLIC_ERROR_UNUSUAL_ACTIVITY` diff --git a/README.md b/README.md index 0e4f2336d..5dd1f282b 100644 --- a/README.md +++ b/README.md @@ -52,6 +52,8 @@ Which commands open a browser, with the default `GFLOW_CLI_BROWSER_VISIBILITY=au | `video extend` | headless on `flow.google.com`; headed on labs.google | Drives Flow's Extend control; a billed headless extend was measured ([#1554](https://github.com/ffroliva/gflow-cli/issues/1554)). `GFLOW_CLI_TRANSPORT=ui_automation` keeps it headed | | `media trash` | none or headless | Sent with no browser when the direct read is available; otherwise from a flow.google.com page, measured headless ([#1554](https://github.com/ffroliva/gflow-cli/issues/1554)). Also `media restore`. `GFLOW_CLI_TRANSPORT=ui_automation` keeps the page fallback headed | | `image i2i --ref` | headless with one local file | One local reference file in an existing project, on a request that would go direct once the file is uploaded: a new file is uploaded and generated directly, a file already in the project is attached through Flow's UI, both from a headless browser ([#1554](https://github.com/ffroliva/gflow-cli/issues/1554)). More files, another reference, a character or an unmeasured model keep it headed | +| `video upscale --scale 720p` | headless on `flow.google.com` | Drives the download menu; 720p and the 270p GIF measured headless, 0 credits ([#1554](https://github.com/ffroliva/gflow-cli/issues/1554)) | +| `video upscale --scale 4k` | headless on `flow.google.com` (not measured) | Ultra only; follows the measured menu path by decision ([#1554](https://github.com/ffroliva/gflow-cli/issues/1554)) | **Headed** (Flow's UI) @@ -65,7 +67,7 @@ Which commands open a browser, with the default `GFLOW_CLI_BROWSER_VISIBILITY=au | `video r2v` | headed | Reference-to-video is not measured over direct HTTP | | `video edit` | headed | Not measured over direct HTTP | | `video i2v --end-frame` | headed | An end frame, or a start frame that is already in the project, is not a measured shape | -| `video upscale --scale 4k` | headed | 4K, 720p and the 270p GIF, and 1080p of a clip the local catalog does not hold, drive the download menu | +| `video upscale --scale 1080p` (menu) | headed | 1080p of a clip the local catalog does not hold drives the download menu; not measured headless | | `scene create` | headed | Scenes are built in the UI | | `scene show` | headed | Reads the scene in the UI | | `character create` | headed | Character creation is a UI surface | @@ -399,7 +401,7 @@ These keep the labs driver until they are ported: other UUID media references, a **Remaining limits.** - The one-time `auth login` is interactive and needs a display. -- Reference-to-video, `video edit`, image-to-video with an end frame, the 4K, 720p and GIF upscales, `scene create`, `character create`, `instructions`, the agent-only composer, and any other video run with a credit cap (`--max-credits`, MCP `max_credits`) still drive Flow's interface in a headed browser; `video extend` on flow.google.com drives it headless, `media trash`/`restore` run with no browser or in a headless one, image-to-image from one local `--ref` file in an existing project runs headless when the request would otherwise go direct. Headless operation of these surfaces is tracked in [#1554](https://github.com/ffroliva/gflow-cli/issues/1554). +- Reference-to-video, `video edit`, image-to-video with an end frame, 1080p upscales of clips outside the measured direct shape, `scene create`, `character create`, `instructions`, the agent-only composer, and any other video run with a credit cap (`--max-credits`, MCP `max_credits`) still drive Flow's interface in a headed browser; `video extend` on flow.google.com drives it headless, `media trash`/`restore` run with no browser or in a headless one, image-to-image from one local `--ref` file in an existing project runs headless when the request would otherwise go direct, and the 720p, GIF and (unmeasured) 4K video upscales run headless. Headless operation of these surfaces is tracked in [#1554](https://github.com/ffroliva/gflow-cli/issues/1554). - Request shapes that have not been measured fall back to the interface path. - The headless mint was measured on Windows only, on accounts served flow.google.com. macOS, Linux and accounts Flow serves on labs.google are unmeasured. - The headless browser reports itself as `HeadlessChrome`. It is not a stealth technique, and Google may treat it differently in future. diff --git a/README.zh-CN.md b/README.zh-CN.md index 18cb23426..7613af38e 100644 --- a/README.zh-CN.md +++ b/README.zh-CN.md @@ -44,6 +44,8 @@ | `video extend` | 在 `flow.google.com` 上为 headless;labs.google 上为 headed | 驱动 Flow 的扩展控件;已测量一次计费的无头扩展([#1554](https://github.com/ffroliva/gflow-cli/issues/1554))。`GFLOW_CLI_TRANSPORT=ui_automation` 保持有头 | | `media trash` | 无浏览器或 headless | 直接读取可用时不使用浏览器发送;否则从 flow.google.com 页面发送,已测量可无头运行([#1554](https://github.com/ffroliva/gflow-cli/issues/1554))。`media restore` 同样。`GFLOW_CLI_TRANSPORT=ui_automation` 使页面回退保持有头 | | `image i2i --ref` | 单个本地文件为 headless | 在已有项目中仅使用一个本地参考文件、且文件上传后的请求可直接发送时:新文件直接上传并生成,项目中已有的文件通过 Flow 的 UI 附加,两者均在无头浏览器中运行([#1554](https://github.com/ffroliva/gflow-cli/issues/1554))。多个文件、其他参考、角色或未测量的模型则保持有头 | +| `video upscale --scale 720p` | 在 `flow.google.com` 上为 headless | 驱动下载菜单;720p 和 270p GIF 已测量可无头运行,0 积分([#1554](https://github.com/ffroliva/gflow-cli/issues/1554)) | +| `video upscale --scale 4k` | 在 `flow.google.com` 上为 headless(未测量) | 仅 Ultra;按决定沿用已测量的菜单路径([#1554](https://github.com/ffroliva/gflow-cli/issues/1554)) | **有头**(Flow 的界面) @@ -57,7 +59,7 @@ | `video r2v` | headed | 参考图生视频尚未通过直接 HTTP 测量 | | `video edit` | headed | 尚未通过直接 HTTP 测量 | | `video i2v --end-frame` | headed | 结束帧,或已在项目中的起始帧,不是已测量的形态 | -| `video upscale --scale 4k` | headed | 4K、720p、270p GIF,以及本地媒体库中没有的片段的 1080p,都驱动下载菜单 | +| `video upscale --scale 1080p` (menu) | headed | 本地媒体库中没有的片段的 1080p 驱动下载菜单;未测量无头运行 | | `scene create` | headed | 场景在 UI 中构建 | | `scene show` | headed | 在 UI 中读取场景 | | `character create` | headed | 角色创建是 UI 界面 | @@ -433,7 +435,7 @@ gflow CLI / MCP server **其余限制:** - 一次性的 `auth login` 是交互式的,需要图形界面。 -- 参考图生视频、`video edit`、带尾帧的图生视频、4K/720p/GIF 放大、`scene create`、`character create`、`instructions`、仅 Agent 编辑器,以及其他任何设置了积分上限的视频运行(`--max-credits`、MCP `max_credits`),仍在有头浏览器中驱动 Flow 界面;`flow.google.com` 上的 `video extend` 以无头方式驱动界面,`media trash`/`restore` 不使用浏览器或在无头浏览器中运行,在已有项目中基于单个本地 `--ref` 文件、且请求本可直接发送的图生图以无头方式运行。这些界面的无头运行在 [#1554](https://github.com/ffroliva/gflow-cli/issues/1554) 中跟踪。 +- 参考图生视频、`video edit`、带尾帧的图生视频、超出已测量直连形态的 1080p 放大、`scene create`、`character create`、`instructions`、仅 Agent 编辑器,以及其他任何设置了积分上限的视频运行(`--max-credits`、MCP `max_credits`),仍在有头浏览器中驱动 Flow 界面;`flow.google.com` 上的 `video extend` 以无头方式驱动界面,`media trash`/`restore` 不使用浏览器或在无头浏览器中运行,在已有项目中基于单个本地 `--ref` 文件、且请求本可直接发送的图生图以无头方式运行,720p、GIF 和(未测量的)4K 视频放大以无头方式运行。这些界面的无头运行在 [#1554](https://github.com/ffroliva/gflow-cli/issues/1554) 中跟踪。 - 未测量的请求形态会回退到界面路径。 - 无头令牌生成只在 Windows 上、在 Flow 提供 flow.google.com 服务的账号上测量过。macOS、Linux 以及 Flow 在 labs.google 上提供服务的账号尚未测量。 - 无头浏览器会以 `HeadlessChrome` 标识自己。这不是隐身技术,Google 将来也可能区别对待它。 diff --git a/docs/ACCOUNT_SAFETY.md b/docs/ACCOUNT_SAFETY.md index 13876b983..492ff5e1e 100644 --- a/docs/ACCOUNT_SAFETY.md +++ b/docs/ACCOUNT_SAFETY.md @@ -43,7 +43,7 @@ Chromium is treated as a **fatal error**, not a fallback (#222). For the measure request shapes, Chrome runs headless only to mint the reCAPTCHA token, and the request goes to Flow over direct HTTP. The commands that still drive Flow's interface run it headed, except `video extend` on flow.google.com, the page fallback of `media trash` / -`media restore`, and image-to-image from one local `--ref` file in an existing project on an otherwise direct request, which run headless under `auto` (`GFLOW_CLI_TRANSPORT=ui_automation` keeps them headed); `GFLOW_CLI_BROWSER_VISIBILITY=headed` shows the window for every command. The +`media restore`, the video download-menu upscales (4K unmeasured), and image-to-image from one local `--ref` file in an existing project on an otherwise direct request, which run headless under `auto` (`GFLOW_CLI_TRANSPORT=ui_automation` keeps them headed); `GFLOW_CLI_BROWSER_VISIBILITY=headed` shows the window for every command. The per-command list is in [BROWSER_MODES](BROWSER_MODES.md). The headless mint was measured as accepted on two accounts on Windows ([spike](superpowers/spikes/2026-11-27-direct-video-and-headless-mint.md)); macOS, diff --git a/docs/ARCHITECTURE.md b/docs/ARCHITECTURE.md index 0a2e64f79..d4ca80425 100644 --- a/docs/ARCHITECTURE.md +++ b/docs/ARCHITECTURE.md @@ -477,9 +477,12 @@ used only where it is strictly necessary. - **Image upscale stays headed.** A headless 2K upscale was refused as unusual activity on one of two accounts while headed passed, so no image upscale scale is in `HEADLESS_UI_SURFACES`; `upscale_visibility` still decides the launch for the CLI and the MCP tool. +- **The video download-menu upscales run headless.** 720p and 270p were measured headless (0 + credits) and are in `HEADLESS_UI_SURFACES`; 4K video (Ultra only) follows them by decision, + unmeasured. 1080p through the menu stays headed. - **The UI transport (`ui_automation`) for the other surfaces.** `image batch`, `movie run`, reference-to-video, - edit, end-frame image-to-video, the 4K/720p/GIF upscales, scene and character create, + edit, end-frame image-to-video, the 1080p menu upscale, scene and character create, instructions, the agent-only composer and other credit-capped video still drive Flow's page in a headed browser. Headless operation of these surfaces is tracked in [#1554](https://github.com/ffroliva/gflow-cli/issues/1554). - **`auth login`** is interactive and needs a display once. diff --git a/docs/BROWSER_MODES.md b/docs/BROWSER_MODES.md index d1de55117..c9fece936 100644 --- a/docs/BROWSER_MODES.md +++ b/docs/BROWSER_MODES.md @@ -39,6 +39,8 @@ browser has been measured, so `auto` runs them headless. | `video extend` | headless on `flow.google.com`; headed on labs.google | Drives Flow's Extend control. A billed extend in a headless browser completed, with Flow's own quote read and enforced by `--max-credits` ([#1554](https://github.com/ffroliva/gflow-cli/issues/1554)). The labs.google path is unmeasured. `GFLOW_CLI_TRANSPORT=ui_automation` keeps it headed | | `media trash` | none or headless | Sends Flow's trash mutation (`pGCYOe`) with no browser when the direct read is on and available (`GFLOW_CLI_WIRE_READS`; skipped while a proxy is configured); otherwise sends it from a flow.google.com page, which clicks nothing and was measured headless, trash and restore 2/2 in each mode ([#1554](https://github.com/ffroliva/gflow-cli/issues/1554)). Also `media restore`. `GFLOW_CLI_TRANSPORT=ui_automation` keeps the page fallback headed | | `image i2i --ref` | headless with one local file | When the only reference is a local file, `--project` names an existing project, and, with each file in the shape an upload produces (one in-project reference), the request would go direct (for example `nano2`), the browser starts headless: a new file is uploaded and generated directly, and a file the catalog already holds in the project is attached through Flow's UI in that headless browser. Two quota runs of the UI attach matched a headed control ([#1554](https://github.com/ffroliva/gflow-cli/issues/1554)). Two or more files, a UUID reference or a character beside the file, a new project, an unmeasured model, or another reason for the UI keeps it headed. `GFLOW_CLI_TRANSPORT=ui_automation` keeps it headed | +| `video upscale --scale 720p` | headless on `flow.google.com` | Drives the video's download menu; 720p and the 270p GIF (`--scale 270p`) each ran twice in a headless browser matching a headed control, 0 credits, including on an account that was refusing headless image upscales at the time ([#1554](https://github.com/ffroliva/gflow-cli/issues/1554)). `GFLOW_CLI_TRANSPORT=ui_automation` or an explicit `GFLOW_CLI_FLOW_HOST=labs.google` keeps it headed | +| `video upscale --scale 4k` | headless on `flow.google.com` (not measured) | Ultra only, so not measured: it follows the measured video download-menu path by an explicit decision ([#1554](https://github.com/ffroliva/gflow-cli/issues/1554)). It spends credits on the click, and a failure after the click is never retried. `--browser-visibility headed` shows the window | ## Headed (Flow's UI) @@ -52,7 +54,7 @@ browser has been measured, so `auto` runs them headless. | `video r2v` | headed | Reference-to-video is not measured over direct HTTP | | `video edit` | headed | Not measured over direct HTTP | | `video i2v --end-frame` | headed | An end frame, or a start frame that is already in the project, is not a measured shape | -| `video upscale --scale 4k` | headed | 4K, 720p and the 270p GIF, and 1080p of a clip the local catalog does not hold, drive the download menu | +| `video upscale --scale 1080p` (menu) | headed | 1080p of a clip the local catalog does not hold as a measured direct source drives the download menu; not measured headless (the menu offered no 1080p on the clip tried) | | `scene create` | headed | Reads the retired labs.google session token; refused identically headless and headed on an account served flow.google.com (HTTP 410), so headless is unmeasured ([#1554](https://github.com/ffroliva/gflow-cli/issues/1554), [#639](https://github.com/ffroliva/gflow-cli/issues/639)) | | `scene show` | headed | As `scene create` | | `character create` | headed | On an account served flow.google.com, gflow cannot drive it yet in either mode ([#1587](https://github.com/ffroliva/gflow-cli/issues/1587)), so headless is unmeasured | diff --git a/docs/CONFIGURATION.md b/docs/CONFIGURATION.md index 46f96e318..94808d773 100644 --- a/docs/CONFIGURATION.md +++ b/docs/CONFIGURATION.md @@ -425,7 +425,7 @@ GFLOW_CLI_HISTORY_PROMPTS=redacted gflow image t2i "confidential brief" **Default:** `auto`. A request the direct transport can send (a measured shape) launches Chrome **headless**, and that browser only mints the reCAPTCHA token; a surface that still needs Flow's UI launches **headed**, except the surfaces measured headless (`video extend` on flow.google.com, -the page fallback of `media trash` / `media restore`, and image-to-image from one local `--ref` +the page fallback of `media trash` / `media restore`, the video download-menu upscales (720p, 270p, and 4K unmeasured), and image-to-image from one local `--ref` file in an existing project on an otherwise direct request), which launch headless. A run that holds any UI item launches headed for the whole run. A refusal Flow did not charge is retried once from a new headless browser process. The per-command list is [BROWSER_MODES](BROWSER_MODES.md). diff --git a/docs/MCP.md b/docs/MCP.md index 63eb47d99..403252e67 100644 --- a/docs/MCP.md +++ b/docs/MCP.md @@ -194,7 +194,7 @@ is [BROWSER_MODES](BROWSER_MODES.md). * `gflow_usage_stats(weeks)`: Summarize local gflow-cli usage statistics over the last N weeks (default 12, range 1..53). Returns command invocation counts across surfaces from local telemetry (or null when telemetry is off) and generation counts by command, model, status, and month from the local catalog. Its `telemetry` block includes `state`, `switch`, `upload` (`enabled` and `reason`), and the current report (#1164). The tool reads local data and spends no credits; like other MCP calls, its telemetry hook may start a separate weekly upload when eligible. MCP does not expose telemetry `on` or `off`; those controls are CLI-only by design. * `gflow_download_media(media_id, out_dir, profile)`: Fetches an already-generated asset from Flow by its media ID and writes it to disk — the recovery path for a generation that was billed but whose download failed. Spends no credits. The bytes are verified against the size Flow reports before the file is written, and the catalog's `local_files` row is updated. Returns `path`, `bytes`, `media_id`, `workflow_id`, `project_id` and `profile`. The transfer retries a dropped connection internally ([#895](https://github.com/ffroliva/gflow-cli/issues/895)), so a failure marked `retryable` means pause and call again — not immediately, and not in a tight loop: each call opens a browser under a per-profile lease, and a second concurrent call fails on that lease instead (exit 11). * `gflow_upscale_image(media_id, scale, project, out_dir, profile)`: Upscales an already-generated image to 2K or 4K; it opens a headed browser under `auto` (a headless 2K upscale was refused as unusual activity on one of two accounts, #1554). `scale` is `2k` or `4k` (4K requires Ultra; Pro accounts support 2K). A scale the download menu does not list is exit 22 (`upscale-unavailable`), naming the listed scales. 2K spends no credits; whether 4K does has not been measured, so a 4K refusal reads `charged: maybe` / `next_action: reconcile`. -* `gflow_upscale_video(media_id, scale, project, out_dir, profile, browser_visibility)`: Upscales or exports an already-generated video to 4K Ultra (spends credits), 1080p Full HD, downloads it at 720p (the original, or for a clip with a smaller original Flow's 720p upscale), or exports a 270p animated GIF. `scale` is `4k`, `1080p`, `720p`, or `270p`. Flow decides which scales each clip offers (a Veo 3.1 Lite clip lists no 1080p; `4k` requires Flow Ultra); a scale the clip's download menu does not list returns `UpscaleUnavailableError` (exit 22) naming the listed scales (#1338). Driven on `flow.google.com` only; 1080p was measured free (2026-10-07) while 4K spends credits (measured 50 credits on Omni 1.2 Flash, 2026-11-23). A 1080p upscale of a clip the local catalog records as Omni 1.2 Flash, 4 s, 16:9 goes over direct HTTP with a headless browser that only mints the reCAPTCHA token; every other upscale drives the clip's download menu in a headed browser. The result names the `route` the upscale took (`ui` when a planned direct attempt fell back to the menu) and the `visibility`. +* `gflow_upscale_video(media_id, scale, project, out_dir, profile, browser_visibility)`: Under `auto`, the download-menu scales (720p, 270p, and 4K unmeasured) run in a headless browser (#1554). Upscales or exports an already-generated video to 4K Ultra (spends credits), 1080p Full HD, downloads it at 720p (the original, or for a clip with a smaller original Flow's 720p upscale), or exports a 270p animated GIF. `scale` is `4k`, `1080p`, `720p`, or `270p`. Flow decides which scales each clip offers (a Veo 3.1 Lite clip lists no 1080p; `4k` requires Flow Ultra); a scale the clip's download menu does not list returns `UpscaleUnavailableError` (exit 22) naming the listed scales (#1338). Driven on `flow.google.com` only; 1080p was measured free (2026-10-07) while 4K spends credits (measured 50 credits on Omni 1.2 Flash, 2026-11-23). A 1080p upscale of a clip the local catalog records as Omni 1.2 Flash, 4 s, 16:9 goes over direct HTTP with a headless browser that only mints the reCAPTCHA token; every other upscale drives the clip's download menu in a headed browser. The result names the `route` the upscale took (`ui` when a planned direct attempt fell back to the menu) and the `visibility`. * `gflow_list_tools()`: Lists the prompt tools (name/title/description/category) accepted by the generate tools' `tools` param. Each `tools` item is `{"name": , "options": {...}}`, e.g. `[{"name": "creative-director"}]`. * `gflow_list_models()`: The image and video model catalog, the same object as `gflow models --json` ([#883](https://github.com/ffroliva/gflow-cli/issues/883)); each model entry is what `gflow models show --json` prints ([#1196](https://github.com/ffroliva/gflow-cli/issues/1196)): per model `name`, `label` (image: Flow's menu name), the CLI's `--model` `aliases` (the generate tools accept each of them as `model`, plus wider spellings such as `narwhal` or `veo_lite`), `ref_cap`, `default` (image), and `max_duration`, `durations` (video: the clip lengths `duration` accepts for that model) and `retires_on` (video: the ISO date Flow retires the model, or `null`; [#1375](https://github.com/ffroliva/gflow-cli/issues/1375)). `aspects` and video `tiers` sit on each section (`image` / `video`), not on the per-model entry, so `models show --json` does not carry them. Built from the same enums the generate tools use, so every alias it lists is accepted back. Static: no profile, no browser, no spend. * `gflow_instructions_list(project, profile)`: Lists a project's persistent Agent-Mode instruction cards (live server brief; credits-free). diff --git a/docs/superpowers/spikes/2026-11-30-headless-video-upscale.md b/docs/superpowers/spikes/2026-11-30-headless-video-upscale.md new file mode 100644 index 000000000..9d8afc5ae --- /dev/null +++ b/docs/superpowers/spikes/2026-11-30-headless-video-upscale.md @@ -0,0 +1,39 @@ +# Spike: the video download-menu upscales in a headless browser (#1554) + +**Date:** 2026-11-30 · **Script:** +[`scripts/dev/spike_headless_video_upscale.py`](../../../scripts/dev/spike_headless_video_upscale.py) + +## Method + +The real CLI, `gflow video upscale --scale --project --json`, with +`--browser-visibility` set to the mode, headless first and then the headed control, on one +catalogued clip of one account served flow.google.com (Windows 11, Chrome stable). Readings +were pre-registered in the script. The credit balance was read before and after. + +## Observations + +| Scale | Headless | Headed (control) | Note | +|---|---|---|---| +| `720p` | **2/2**, `route: ui`, 13–14 s | **2/2**, 13 s | | +| `270p` (GIF) | **2/2**, 21–23 s | **2/2**, 20–22 s | | +| `4k` | exit 22 (not offered, `charged: no`) | the same | Ultra only; the account is Pro | +| `1080p` through the menu (forced with `GFLOW_CLI_TRANSPORT=ui_automation`) | exit 22 (not offered) ×2 | the same ×2 | the menu offered no 1080p on this clip | + +The balance stayed at 50 credits across all runs: the 720p and 270p exports spent nothing. + +## Verdict + +- `video upscale --scale 720p` and `--scale 270p` behave the same headless: they join the + measured headless UI surfaces. +- `video upscale --scale 4k` could not be measured without an Ultra account. It follows the + measured video download-menu path headless by an explicit decision, recorded as unmeasured; + 4K video bills on the click, and a failure after it is never retried. The image 4K upscale + stays headed with the image 2K upscale, which was refused headless on one account + ([image spike](2026-11-29-headless-image-ui.md)). +- 1080p through the menu is unmeasured and stays headed (the direct 1080p route for a + catalogued measured clip was already headless). + +## Not measured + +4K on an Ultra account, 1080p through the menu, macOS, Linux, a second account, accounts Flow +serves on labs.google. diff --git a/scripts/dev/spike_headless_video_upscale.py b/scripts/dev/spike_headless_video_upscale.py new file mode 100644 index 000000000..9b29a1258 --- /dev/null +++ b/scripts/dev/spike_headless_video_upscale.py @@ -0,0 +1,81 @@ +#!/usr/bin/env python3 +"""#1554 spike (0 credits measured for 720p / 270p; 4K bills on Ultra): do the video download-menu +upscales behave the same in a headless Chrome as in a headed one? + +Method: the real CLI, ``gflow video upscale --scale --project --json`` with +``--browser-visibility`` set to the mode, ``--runs`` times per scale, headless first, then the +headed control. A run passes on exit 0 with a saved file. The credit balance is read before and +after. + +Pre-registered readings (written before the first run) +------------------------------------------------------ +| Headless | Headed | Reading | +|---|---|---| +| N/N for a scale | N/N | same behaviour: that scale can launch headless under ``auto`` | +| fewer than N/N | N/N | headless differs: that scale stays headed | +| any | fewer than N/N (for example exit 22, scale not offered) | unmeasured for that scale | + +Usage:: + + uv run python scripts/dev/spike_headless_video_upscale.py --profile \ + --media-id --project --scales 720p 270p 4k --runs 2 +""" + +from __future__ import annotations + +import argparse +import json +import os +import subprocess +import sys +import tempfile +from pathlib import Path + + +def _gflow(args: list[str]) -> subprocess.CompletedProcess[str]: + return subprocess.run( # noqa: S603 - fixed argv, the spike's own CLI + [sys.executable, "-m", "gflow_cli", *args], + capture_output=True, + text=True, + encoding="utf-8", + env={**os.environ, "PYTHONUTF8": "1"}, + check=False, + timeout=900, + ) + + +def _balance(profile: str) -> object: + proc = _gflow(["credits", "user", "--profile", profile, "--json"]) + try: + return json.loads(proc.stdout).get("credits") + except ValueError: + return None + + +def main() -> None: + parser = argparse.ArgumentParser(description=(__doc__ or "").split("\n")[0]) + parser.add_argument("--profile", required=True) + parser.add_argument("--media-id", required=True) + parser.add_argument("--project", required=True) + parser.add_argument("--scales", nargs="+", default=["720p", "270p", "4k"]) + parser.add_argument("--runs", type=int, default=2) + args = parser.parse_args() + print(json.dumps({"credits_before": _balance(args.profile)})) + for mode in ("headless", "headed"): + for scale in args.scales: + for _ in range(args.runs): + with tempfile.TemporaryDirectory() as out: + proc = _gflow( + ["video", "upscale", args.media_id, "--scale", scale] + + ["--project", args.project, "--profile", args.profile] + + ["--browser-visibility", mode, "--out", out, "--json"] + ) + saved = [p for p in Path(out).rglob("*") if p.is_file()] + record = {"mode": mode, "scale": scale, "exit": proc.returncode} + record["ok"] = proc.returncode == 0 and bool(saved) + print(json.dumps(record), flush=True) + print(json.dumps({"credits_after": _balance(args.profile)})) + + +if __name__ == "__main__": + main() diff --git a/src/gflow_cli/_cli_helpers.py b/src/gflow_cli/_cli_helpers.py index 82d454598..3e0998da0 100644 --- a/src/gflow_cli/_cli_helpers.py +++ b/src/gflow_cli/_cli_helpers.py @@ -744,18 +744,24 @@ def upscale_visibility( kind: str = "video", *, transport: str | None = None, + route: Route | None = None, ) -> BrowserVisibility: - """An upscale's launch visibility: a video upscale routes on its local catalog row (no - network read); an image upscale drives the Flow UI, measured headless at 2K (#1554).""" - if kind != "video": - if settings.flow_host == "labs.google": # only flow.google.com was measured - return client_visibility(settings) - surface = f"image upscale {scale.strip().lower()}" - return ui_surface_visibility(settings, surface, transport=transport) - from gflow_cli.api._flow_media_edit import upscale_catalog_row # noqa: PLC0415 + """An upscale's launch visibility (#1554). - row = upscale_catalog_row(settings, profile_dir, media_id) - return client_visibility(settings, (upscale_route(scale, row, transport=transport),)) + A video upscale routes on its local catalog row (no network read; a caller that already + planned the route passes it). The download-menu path (an image upscale, or a video one + routed to the UI) launches headless for a scale in :data:`HEADLESS_UI_SURFACES`, except + with an explicit labs.google host: only flow.google.com was measured. + """ + scale = scale.strip().lower() + if kind == "video" and route is None: + from gflow_cli.api._flow_media_edit import upscale_catalog_row # noqa: PLC0415 + + row = upscale_catalog_row(settings, profile_dir, media_id) + route = upscale_route(scale, row, transport=transport) + if route is Route.DIRECT or settings.flow_host == "labs.google": + return client_visibility(settings, (route or Route.UI,)) + return ui_surface_visibility(settings, f"{kind} upscale {scale}", transport=transport) def client_visibility( @@ -771,7 +777,18 @@ def client_visibility( # Flow UI surfaces measured in a headless browser (#1554). ``auto`` launches these headless; # every other UI surface stays headed until it is measured. -HEADLESS_UI_SURFACES: Final = frozenset({"video extend", "media trash", "image i2i --ref"}) +HEADLESS_UI_SURFACES: Final = frozenset( + { + "video extend", + "media trash", + "image i2i --ref", + "video upscale 720p", + "video upscale 270p", + # 4K needs an Ultra account, which was not available to measure: it follows the + # measured video download-menu path by an explicit decision (#1554). + "video upscale 4k", + } +) def ui_surface_visibility( diff --git a/src/gflow_cli/mcp/tools.py b/src/gflow_cli/mcp/tools.py index c7590a165..b77ced256 100644 --- a/src/gflow_cli/mcp/tools.py +++ b/src/gflow_cli/mcp/tools.py @@ -40,7 +40,6 @@ from gflow_cli._cli_helpers import _FLOW_ID_RE, default_project, upscale_visibility from gflow_cli.api import flow_wire, routes from gflow_cli.api.client import FlowApiClient -from gflow_cli.api.generation_route import plan_visibility from gflow_cli.api.image import AgentInstruction from gflow_cli.api.image_upscale import TargetResolution from gflow_cli.api.video import VIDEO_DURATION_CHOICES, is_media_uuid @@ -2018,11 +2017,7 @@ async def _run_upscale_tool( log.info(f"mcp.tool.upscale_{kind}", media_id=media_id, scale=scale_label, profile=profile) route = _upscale_route(settings, profile_dir, media_id, scale_label, kind) - visibility = ( - plan_visibility(settings.browser_visibility, (route,)) - if kind == "video" - else upscale_visibility(settings, profile_dir, media_id, scale_label, kind) - ) + visibility = upscale_visibility(settings, profile_dir, media_id, scale_label, kind, route=route) async with ( _profile_lock(profile), FlowApiClient( diff --git a/tests/e2e/test_migrated_upscale_e2e.py b/tests/e2e/test_migrated_upscale_e2e.py index c32bb3f52..590ded992 100644 --- a/tests/e2e/test_migrated_upscale_e2e.py +++ b/tests/e2e/test_migrated_upscale_e2e.py @@ -27,7 +27,7 @@ from gflow_cli.config import get_settings, reset_settings from gflow_cli.data.queries import list_images, list_videos from gflow_cli.errors import UpscaleUnavailableError -from tests.e2e._visibility import OUTER_VISIBILITY +from tests.e2e._visibility import OUTER_VISIBILITY, expected_visibility pytestmark = [pytest.mark.e2e] @@ -273,7 +273,12 @@ async def test_migrated_video_export_270p_gif_e2e( ] if not usable: pytest.skip(f"no catalogued videos for profile {profile!r} to export") - async with FlowApiClient(profile_dir=e2e_profile_dir) as client: + # The production launch rule (#1554): the 270p menu export is headless under ``auto``. + visibility = upscale_visibility( + get_settings(), e2e_profile_dir, usable[0].media_id, "270p", kind="video" + ) + assert visibility.value == expected_visibility() + async with FlowApiClient(profile_dir=e2e_profile_dir, visibility=visibility) as client: _row, result = await _export_first_offered( client, usable, @@ -288,6 +293,48 @@ async def test_migrated_video_export_270p_gif_e2e( assert "migrated_video_upscale.completed" in seen, f"events: {seen}" +@pytest.mark.e2e_video +@pytest.mark.asyncio +async def test_mcp_video_upscale_720p_runs_headless_e2e( + e2e_profile_dir: Path, + real_catalog: None, + tmp_path: Path, + monkeypatch: pytest.MonkeyPatch, +) -> None: + """The MCP twin of the 720p menu export: headless under ``auto`` (#1554), 0 credits.""" + from gflow_cli.mcp import tools + + if os.environ.get("GFLOW_CLI_E2E_RUN_VIDEO", "") != "1": + pytest.skip("set GFLOW_CLI_E2E_RUN_VIDEO=1 to include the 720p export e2e") + profile = os.environ.get("GFLOW_CLI_E2E_PROFILE", "").strip() + if not profile: + pytest.skip("GFLOW_CLI_E2E_PROFILE required") + row = next( + ( + r + for r in list_videos( + db_path=get_settings().resolved_db_path(), profile=profile, limit=20, offset=0 + ) + if r.project_id + ), + None, + ) + if row is None: + pytest.skip(f"no catalogued videos for profile {profile!r} to export") + monkeypatch.setenv("GFLOW_CLI_OUTPUT_DIR", str(tmp_path)) + reset_settings() + try: + result: dict[str, Any] = await tools.gflow_upscale_video( + media_id=row.media_id, scale="720p", out_dir=str(tmp_path), profile=profile + ) + finally: + reset_settings() + + assert result.get("status") == "ok", f"MCP 720p export failed: {result}" + assert (result.get("route"), result.get("visibility")) == ("ui", expected_visibility()) + assert Path(result["path"]).stat().st_size > 10_000 + + @pytest.mark.e2e_auth # zero credits: nothing is clicked @pytest.mark.asyncio async def test_migrated_video_upscale_unlisted_scale_is_unavailable_e2e( diff --git a/tests/test_cli_browser_visibility.py b/tests/test_cli_browser_visibility.py index 821488627..239bbb30e 100644 --- a/tests/test_cli_browser_visibility.py +++ b/tests/test_cli_browser_visibility.py @@ -284,3 +284,54 @@ def test_image_upscale_transport_argument_keeps_it_headed( settings, tmp_path, "m-1", "2k", kind="image", transport="ui_automation" ) assert launch is BrowserVisibility.HEADED + + +# --- #1554: video upscale download-menu scales; 4K by decision ------------------------------ + + +@pytest.mark.parametrize( + ("kind", "scale", "env", "launch"), + [ + ("video", "720p", {}, BrowserVisibility.HEADLESS), + ("video", "270p", {}, BrowserVisibility.HEADLESS), + # 4K video: Ultra only; follows the measured menu path by decision (unmeasured). + ("video", "4k", {}, BrowserVisibility.HEADLESS), + # The image upscale stays headed, 4K included. + ("image", "4k", {}, BrowserVisibility.HEADED), + # 1080p through the menu (no catalogued direct source) is unmeasured. + ("video", "1080p", {}, BrowserVisibility.HEADED), + ("video", "720p", {"GFLOW_CLI_TRANSPORT": "ui_automation"}, BrowserVisibility.HEADED), + ("video", "720p", {"GFLOW_CLI_FLOW_HOST": "labs.google"}, BrowserVisibility.HEADED), + ("video", "720p", {"GFLOW_CLI_BROWSER_VISIBILITY": "headed"}, BrowserVisibility.HEADED), + ], +) +def test_upscale_menu_visibility( + monkeypatch: pytest.MonkeyPatch, + tmp_path: Path, + kind: str, + scale: str, + env: dict[str, str], + launch: BrowserVisibility, +) -> None: + from gflow_cli._cli_helpers import upscale_visibility + + settings = _image_settings(monkeypatch, **env) + assert upscale_visibility(settings, tmp_path, "m-1", scale, kind=kind) is launch + + +def test_upscale_visibility_uses_a_planned_route_without_reading_the_catalog( + monkeypatch: pytest.MonkeyPatch, tmp_path: Path +) -> None: + """The MCP tool passes the route it already planned; no second catalog read.""" + from gflow_cli import _cli_helpers + + settings = _image_settings(monkeypatch) + + def _no_read(*_: object) -> None: + raise AssertionError("catalog read") + + monkeypatch.setattr("gflow_cli.api._flow_media_edit.upscale_catalog_row", _no_read) + launch = _cli_helpers.upscale_visibility( + settings, tmp_path, "m-1", "1080p", kind="video", route=Route.DIRECT + ) + assert launch is BrowserVisibility.HEADLESS diff --git a/website/docs/ACCOUNT_SAFETY.md b/website/docs/ACCOUNT_SAFETY.md index 797acd7c5..7355d9d0f 100644 --- a/website/docs/ACCOUNT_SAFETY.md +++ b/website/docs/ACCOUNT_SAFETY.md @@ -43,7 +43,7 @@ Chromium is treated as a **fatal error**, not a fallback (#222). For the measure request shapes, Chrome runs headless only to mint the reCAPTCHA token, and the request goes to Flow over direct HTTP. The commands that still drive Flow's interface run it headed, except `video extend` on flow.google.com, the page fallback of `media trash` / -`media restore`, and image-to-image from one local `--ref` file in an existing project on an otherwise direct request, which run headless under `auto` (`GFLOW_CLI_TRANSPORT=ui_automation` keeps them headed); `GFLOW_CLI_BROWSER_VISIBILITY=headed` shows the window for every command. The +`media restore`, the video download-menu upscales (4K unmeasured), and image-to-image from one local `--ref` file in an existing project on an otherwise direct request, which run headless under `auto` (`GFLOW_CLI_TRANSPORT=ui_automation` keeps them headed); `GFLOW_CLI_BROWSER_VISIBILITY=headed` shows the window for every command. The per-command list is in [BROWSER_MODES](BROWSER_MODES.md). The headless mint was measured as accepted on two accounts on Windows ([spike](superpowers/spikes/2026-11-27-direct-video-and-headless-mint.md)); macOS, diff --git a/website/docs/ARCHITECTURE.md b/website/docs/ARCHITECTURE.md index 352b12657..22ef446fd 100644 --- a/website/docs/ARCHITECTURE.md +++ b/website/docs/ARCHITECTURE.md @@ -477,9 +477,12 @@ used only where it is strictly necessary. - **Image upscale stays headed.** A headless 2K upscale was refused as unusual activity on one of two accounts while headed passed, so no image upscale scale is in `HEADLESS_UI_SURFACES`; `upscale_visibility` still decides the launch for the CLI and the MCP tool. +- **The video download-menu upscales run headless.** 720p and 270p were measured headless (0 + credits) and are in `HEADLESS_UI_SURFACES`; 4K video (Ultra only) follows them by decision, + unmeasured. 1080p through the menu stays headed. - **The UI transport (`ui_automation`) for the other surfaces.** `image batch`, `movie run`, reference-to-video, - edit, end-frame image-to-video, the 4K/720p/GIF upscales, scene and character create, + edit, end-frame image-to-video, the 1080p menu upscale, scene and character create, instructions, the agent-only composer and other credit-capped video still drive Flow's page in a headed browser. Headless operation of these surfaces is tracked in [#1554](https://github.com/ffroliva/gflow-cli/issues/1554). - **`auth login`** is interactive and needs a display once. diff --git a/website/docs/BROWSER_MODES.md b/website/docs/BROWSER_MODES.md index d1de55117..c9fece936 100644 --- a/website/docs/BROWSER_MODES.md +++ b/website/docs/BROWSER_MODES.md @@ -39,6 +39,8 @@ browser has been measured, so `auto` runs them headless. | `video extend` | headless on `flow.google.com`; headed on labs.google | Drives Flow's Extend control. A billed extend in a headless browser completed, with Flow's own quote read and enforced by `--max-credits` ([#1554](https://github.com/ffroliva/gflow-cli/issues/1554)). The labs.google path is unmeasured. `GFLOW_CLI_TRANSPORT=ui_automation` keeps it headed | | `media trash` | none or headless | Sends Flow's trash mutation (`pGCYOe`) with no browser when the direct read is on and available (`GFLOW_CLI_WIRE_READS`; skipped while a proxy is configured); otherwise sends it from a flow.google.com page, which clicks nothing and was measured headless, trash and restore 2/2 in each mode ([#1554](https://github.com/ffroliva/gflow-cli/issues/1554)). Also `media restore`. `GFLOW_CLI_TRANSPORT=ui_automation` keeps the page fallback headed | | `image i2i --ref` | headless with one local file | When the only reference is a local file, `--project` names an existing project, and, with each file in the shape an upload produces (one in-project reference), the request would go direct (for example `nano2`), the browser starts headless: a new file is uploaded and generated directly, and a file the catalog already holds in the project is attached through Flow's UI in that headless browser. Two quota runs of the UI attach matched a headed control ([#1554](https://github.com/ffroliva/gflow-cli/issues/1554)). Two or more files, a UUID reference or a character beside the file, a new project, an unmeasured model, or another reason for the UI keeps it headed. `GFLOW_CLI_TRANSPORT=ui_automation` keeps it headed | +| `video upscale --scale 720p` | headless on `flow.google.com` | Drives the video's download menu; 720p and the 270p GIF (`--scale 270p`) each ran twice in a headless browser matching a headed control, 0 credits, including on an account that was refusing headless image upscales at the time ([#1554](https://github.com/ffroliva/gflow-cli/issues/1554)). `GFLOW_CLI_TRANSPORT=ui_automation` or an explicit `GFLOW_CLI_FLOW_HOST=labs.google` keeps it headed | +| `video upscale --scale 4k` | headless on `flow.google.com` (not measured) | Ultra only, so not measured: it follows the measured video download-menu path by an explicit decision ([#1554](https://github.com/ffroliva/gflow-cli/issues/1554)). It spends credits on the click, and a failure after the click is never retried. `--browser-visibility headed` shows the window | ## Headed (Flow's UI) @@ -52,7 +54,7 @@ browser has been measured, so `auto` runs them headless. | `video r2v` | headed | Reference-to-video is not measured over direct HTTP | | `video edit` | headed | Not measured over direct HTTP | | `video i2v --end-frame` | headed | An end frame, or a start frame that is already in the project, is not a measured shape | -| `video upscale --scale 4k` | headed | 4K, 720p and the 270p GIF, and 1080p of a clip the local catalog does not hold, drive the download menu | +| `video upscale --scale 1080p` (menu) | headed | 1080p of a clip the local catalog does not hold as a measured direct source drives the download menu; not measured headless (the menu offered no 1080p on the clip tried) | | `scene create` | headed | Reads the retired labs.google session token; refused identically headless and headed on an account served flow.google.com (HTTP 410), so headless is unmeasured ([#1554](https://github.com/ffroliva/gflow-cli/issues/1554), [#639](https://github.com/ffroliva/gflow-cli/issues/639)) | | `scene show` | headed | As `scene create` | | `character create` | headed | On an account served flow.google.com, gflow cannot drive it yet in either mode ([#1587](https://github.com/ffroliva/gflow-cli/issues/1587)), so headless is unmeasured | diff --git a/website/docs/CONFIGURATION.md b/website/docs/CONFIGURATION.md index d4d842687..bc68322aa 100644 --- a/website/docs/CONFIGURATION.md +++ b/website/docs/CONFIGURATION.md @@ -425,7 +425,7 @@ GFLOW_CLI_HISTORY_PROMPTS=redacted gflow image t2i "confidential brief" **Default:** `auto`. A request the direct transport can send (a measured shape) launches Chrome **headless**, and that browser only mints the reCAPTCHA token; a surface that still needs Flow's UI launches **headed**, except the surfaces measured headless (`video extend` on flow.google.com, -the page fallback of `media trash` / `media restore`, and image-to-image from one local `--ref` +the page fallback of `media trash` / `media restore`, the video download-menu upscales (720p, 270p, and 4K unmeasured), and image-to-image from one local `--ref` file in an existing project on an otherwise direct request), which launch headless. A run that holds any UI item launches headed for the whole run. A refusal Flow did not charge is retried once from a new headless browser process. The per-command list is [BROWSER_MODES](BROWSER_MODES.md). diff --git a/website/docs/MCP.md b/website/docs/MCP.md index 63eb47d99..403252e67 100644 --- a/website/docs/MCP.md +++ b/website/docs/MCP.md @@ -194,7 +194,7 @@ is [BROWSER_MODES](BROWSER_MODES.md). * `gflow_usage_stats(weeks)`: Summarize local gflow-cli usage statistics over the last N weeks (default 12, range 1..53). Returns command invocation counts across surfaces from local telemetry (or null when telemetry is off) and generation counts by command, model, status, and month from the local catalog. Its `telemetry` block includes `state`, `switch`, `upload` (`enabled` and `reason`), and the current report (#1164). The tool reads local data and spends no credits; like other MCP calls, its telemetry hook may start a separate weekly upload when eligible. MCP does not expose telemetry `on` or `off`; those controls are CLI-only by design. * `gflow_download_media(media_id, out_dir, profile)`: Fetches an already-generated asset from Flow by its media ID and writes it to disk — the recovery path for a generation that was billed but whose download failed. Spends no credits. The bytes are verified against the size Flow reports before the file is written, and the catalog's `local_files` row is updated. Returns `path`, `bytes`, `media_id`, `workflow_id`, `project_id` and `profile`. The transfer retries a dropped connection internally ([#895](https://github.com/ffroliva/gflow-cli/issues/895)), so a failure marked `retryable` means pause and call again — not immediately, and not in a tight loop: each call opens a browser under a per-profile lease, and a second concurrent call fails on that lease instead (exit 11). * `gflow_upscale_image(media_id, scale, project, out_dir, profile)`: Upscales an already-generated image to 2K or 4K; it opens a headed browser under `auto` (a headless 2K upscale was refused as unusual activity on one of two accounts, #1554). `scale` is `2k` or `4k` (4K requires Ultra; Pro accounts support 2K). A scale the download menu does not list is exit 22 (`upscale-unavailable`), naming the listed scales. 2K spends no credits; whether 4K does has not been measured, so a 4K refusal reads `charged: maybe` / `next_action: reconcile`. -* `gflow_upscale_video(media_id, scale, project, out_dir, profile, browser_visibility)`: Upscales or exports an already-generated video to 4K Ultra (spends credits), 1080p Full HD, downloads it at 720p (the original, or for a clip with a smaller original Flow's 720p upscale), or exports a 270p animated GIF. `scale` is `4k`, `1080p`, `720p`, or `270p`. Flow decides which scales each clip offers (a Veo 3.1 Lite clip lists no 1080p; `4k` requires Flow Ultra); a scale the clip's download menu does not list returns `UpscaleUnavailableError` (exit 22) naming the listed scales (#1338). Driven on `flow.google.com` only; 1080p was measured free (2026-10-07) while 4K spends credits (measured 50 credits on Omni 1.2 Flash, 2026-11-23). A 1080p upscale of a clip the local catalog records as Omni 1.2 Flash, 4 s, 16:9 goes over direct HTTP with a headless browser that only mints the reCAPTCHA token; every other upscale drives the clip's download menu in a headed browser. The result names the `route` the upscale took (`ui` when a planned direct attempt fell back to the menu) and the `visibility`. +* `gflow_upscale_video(media_id, scale, project, out_dir, profile, browser_visibility)`: Under `auto`, the download-menu scales (720p, 270p, and 4K unmeasured) run in a headless browser (#1554). Upscales or exports an already-generated video to 4K Ultra (spends credits), 1080p Full HD, downloads it at 720p (the original, or for a clip with a smaller original Flow's 720p upscale), or exports a 270p animated GIF. `scale` is `4k`, `1080p`, `720p`, or `270p`. Flow decides which scales each clip offers (a Veo 3.1 Lite clip lists no 1080p; `4k` requires Flow Ultra); a scale the clip's download menu does not list returns `UpscaleUnavailableError` (exit 22) naming the listed scales (#1338). Driven on `flow.google.com` only; 1080p was measured free (2026-10-07) while 4K spends credits (measured 50 credits on Omni 1.2 Flash, 2026-11-23). A 1080p upscale of a clip the local catalog records as Omni 1.2 Flash, 4 s, 16:9 goes over direct HTTP with a headless browser that only mints the reCAPTCHA token; every other upscale drives the clip's download menu in a headed browser. The result names the `route` the upscale took (`ui` when a planned direct attempt fell back to the menu) and the `visibility`. * `gflow_list_tools()`: Lists the prompt tools (name/title/description/category) accepted by the generate tools' `tools` param. Each `tools` item is `{"name": , "options": {...}}`, e.g. `[{"name": "creative-director"}]`. * `gflow_list_models()`: The image and video model catalog, the same object as `gflow models --json` ([#883](https://github.com/ffroliva/gflow-cli/issues/883)); each model entry is what `gflow models show --json` prints ([#1196](https://github.com/ffroliva/gflow-cli/issues/1196)): per model `name`, `label` (image: Flow's menu name), the CLI's `--model` `aliases` (the generate tools accept each of them as `model`, plus wider spellings such as `narwhal` or `veo_lite`), `ref_cap`, `default` (image), and `max_duration`, `durations` (video: the clip lengths `duration` accepts for that model) and `retires_on` (video: the ISO date Flow retires the model, or `null`; [#1375](https://github.com/ffroliva/gflow-cli/issues/1375)). `aspects` and video `tiers` sit on each section (`image` / `video`), not on the per-model entry, so `models show --json` does not carry them. Built from the same enums the generate tools use, so every alias it lists is accepted back. Static: no profile, no browser, no spend. * `gflow_instructions_list(project, profile)`: Lists a project's persistent Agent-Mode instruction cards (live server brief; credits-free). From 2fcd35ed45195a001885b003d0c5846b35f541d9 Mon Sep 17 00:00:00 2001 From: Flavio Oliva Date: Sun, 29 Nov 2026 22:05:52 +0000 Subject: [PATCH 2/3] fix(video): review follow-ups for the headless menu upscales (#1554) MCP.md no longer contradicts itself; the 1080p wording names a menu route planned from the start (a planned direct 1080p that falls back stays in its headless browser); the spike record carries the same-window image refusal and its correct date; the MCP 720p e2e skips a clip whose menu offers no 720p; a memory note listing these scales as headed is updated. Refs #1554 --- CHANGELOG.md | 4 +-- docs/BROWSER_MODES.md | 2 +- docs/MCP.md | 2 +- .../memory/real-browser-auth-mandatory.md | 5 +-- ...d => 2026-11-29-headless-video-upscale.md} | 9 ++++-- tests/e2e/test_migrated_upscale_e2e.py | 32 +++++++++++-------- website/docs/BROWSER_MODES.md | 2 +- website/docs/MCP.md | 2 +- 8 files changed, 34 insertions(+), 24 deletions(-) rename docs/superpowers/spikes/{2026-11-30-headless-video-upscale.md => 2026-11-29-headless-video-upscale.md} (79%) diff --git a/CHANGELOG.md b/CHANGELOG.md index f1972ad88..0a139dc5c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -25,8 +25,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 headless browser, on the CLI and on `gflow_upscale_video`: each ran twice headless matching a headed control and spent no credits, including on an account that was refusing headless image upscales at the time. `video upscale --scale 4k` (Ultra only) follows the same path headless by - decision; it was not measured, as no Ultra account was available. 1080p through the menu (a - clip outside the measured direct shape) and every image upscale stay headed. + decision; it was not measured, as no Ultra account was available. 1080p planned through the + menu (a clip outside the measured direct shape) and every image upscale stay headed. `GFLOW_CLI_TRANSPORT=ui_automation`, an explicit `GFLOW_CLI_FLOW_HOST=labs.google` and `--browser-visibility headed` keep the window. The MCP upscale tools now plan from the route they already computed, so the catalog row is read once. diff --git a/docs/BROWSER_MODES.md b/docs/BROWSER_MODES.md index c9fece936..980b4be7b 100644 --- a/docs/BROWSER_MODES.md +++ b/docs/BROWSER_MODES.md @@ -54,7 +54,7 @@ browser has been measured, so `auto` runs them headless. | `video r2v` | headed | Reference-to-video is not measured over direct HTTP | | `video edit` | headed | Not measured over direct HTTP | | `video i2v --end-frame` | headed | An end frame, or a start frame that is already in the project, is not a measured shape | -| `video upscale --scale 1080p` (menu) | headed | 1080p of a clip the local catalog does not hold as a measured direct source drives the download menu; not measured headless (the menu offered no 1080p on the clip tried) | +| `video upscale --scale 1080p` (menu) | headed | 1080p of a clip the local catalog does not hold as a measured direct source is planned through the download menu and launches headed; not measured headless (the menu offered no 1080p on the clip tried). A planned direct 1080p that falls back to the menu at run time stays in the headless browser it launched | | `scene create` | headed | Reads the retired labs.google session token; refused identically headless and headed on an account served flow.google.com (HTTP 410), so headless is unmeasured ([#1554](https://github.com/ffroliva/gflow-cli/issues/1554), [#639](https://github.com/ffroliva/gflow-cli/issues/639)) | | `scene show` | headed | As `scene create` | | `character create` | headed | On an account served flow.google.com, gflow cannot drive it yet in either mode ([#1587](https://github.com/ffroliva/gflow-cli/issues/1587)), so headless is unmeasured | diff --git a/docs/MCP.md b/docs/MCP.md index 403252e67..ad031a2a1 100644 --- a/docs/MCP.md +++ b/docs/MCP.md @@ -194,7 +194,7 @@ is [BROWSER_MODES](BROWSER_MODES.md). * `gflow_usage_stats(weeks)`: Summarize local gflow-cli usage statistics over the last N weeks (default 12, range 1..53). Returns command invocation counts across surfaces from local telemetry (or null when telemetry is off) and generation counts by command, model, status, and month from the local catalog. Its `telemetry` block includes `state`, `switch`, `upload` (`enabled` and `reason`), and the current report (#1164). The tool reads local data and spends no credits; like other MCP calls, its telemetry hook may start a separate weekly upload when eligible. MCP does not expose telemetry `on` or `off`; those controls are CLI-only by design. * `gflow_download_media(media_id, out_dir, profile)`: Fetches an already-generated asset from Flow by its media ID and writes it to disk — the recovery path for a generation that was billed but whose download failed. Spends no credits. The bytes are verified against the size Flow reports before the file is written, and the catalog's `local_files` row is updated. Returns `path`, `bytes`, `media_id`, `workflow_id`, `project_id` and `profile`. The transfer retries a dropped connection internally ([#895](https://github.com/ffroliva/gflow-cli/issues/895)), so a failure marked `retryable` means pause and call again — not immediately, and not in a tight loop: each call opens a browser under a per-profile lease, and a second concurrent call fails on that lease instead (exit 11). * `gflow_upscale_image(media_id, scale, project, out_dir, profile)`: Upscales an already-generated image to 2K or 4K; it opens a headed browser under `auto` (a headless 2K upscale was refused as unusual activity on one of two accounts, #1554). `scale` is `2k` or `4k` (4K requires Ultra; Pro accounts support 2K). A scale the download menu does not list is exit 22 (`upscale-unavailable`), naming the listed scales. 2K spends no credits; whether 4K does has not been measured, so a 4K refusal reads `charged: maybe` / `next_action: reconcile`. -* `gflow_upscale_video(media_id, scale, project, out_dir, profile, browser_visibility)`: Under `auto`, the download-menu scales (720p, 270p, and 4K unmeasured) run in a headless browser (#1554). Upscales or exports an already-generated video to 4K Ultra (spends credits), 1080p Full HD, downloads it at 720p (the original, or for a clip with a smaller original Flow's 720p upscale), or exports a 270p animated GIF. `scale` is `4k`, `1080p`, `720p`, or `270p`. Flow decides which scales each clip offers (a Veo 3.1 Lite clip lists no 1080p; `4k` requires Flow Ultra); a scale the clip's download menu does not list returns `UpscaleUnavailableError` (exit 22) naming the listed scales (#1338). Driven on `flow.google.com` only; 1080p was measured free (2026-10-07) while 4K spends credits (measured 50 credits on Omni 1.2 Flash, 2026-11-23). A 1080p upscale of a clip the local catalog records as Omni 1.2 Flash, 4 s, 16:9 goes over direct HTTP with a headless browser that only mints the reCAPTCHA token; every other upscale drives the clip's download menu in a headed browser. The result names the `route` the upscale took (`ui` when a planned direct attempt fell back to the menu) and the `visibility`. +* `gflow_upscale_video(media_id, scale, project, out_dir, profile, browser_visibility)`: Under `auto`, the download-menu scales (720p, 270p, and 4K unmeasured) run in a headless browser (#1554). Upscales or exports an already-generated video to 4K Ultra (spends credits), 1080p Full HD, downloads it at 720p (the original, or for a clip with a smaller original Flow's 720p upscale), or exports a 270p animated GIF. `scale` is `4k`, `1080p`, `720p`, or `270p`. Flow decides which scales each clip offers (a Veo 3.1 Lite clip lists no 1080p; `4k` requires Flow Ultra); a scale the clip's download menu does not list returns `UpscaleUnavailableError` (exit 22) naming the listed scales (#1338). Driven on `flow.google.com` only; 1080p was measured free (2026-10-07) while 4K spends credits (measured 50 credits on Omni 1.2 Flash, 2026-11-23). A 1080p upscale of a clip the local catalog records as Omni 1.2 Flash, 4 s, 16:9 goes over direct HTTP with a headless browser that only mints the reCAPTCHA token; 1080p planned through the menu drives it in a headed browser. The result names the `route` the upscale took (`ui` when a planned direct attempt fell back to the menu) and the `visibility`. * `gflow_list_tools()`: Lists the prompt tools (name/title/description/category) accepted by the generate tools' `tools` param. Each `tools` item is `{"name": , "options": {...}}`, e.g. `[{"name": "creative-director"}]`. * `gflow_list_models()`: The image and video model catalog, the same object as `gflow models --json` ([#883](https://github.com/ffroliva/gflow-cli/issues/883)); each model entry is what `gflow models show --json` prints ([#1196](https://github.com/ffroliva/gflow-cli/issues/1196)): per model `name`, `label` (image: Flow's menu name), the CLI's `--model` `aliases` (the generate tools accept each of them as `model`, plus wider spellings such as `narwhal` or `veo_lite`), `ref_cap`, `default` (image), and `max_duration`, `durations` (video: the clip lengths `duration` accepts for that model) and `retires_on` (video: the ISO date Flow retires the model, or `null`; [#1375](https://github.com/ffroliva/gflow-cli/issues/1375)). `aspects` and video `tiers` sit on each section (`image` / `video`), not on the per-model entry, so `models show --json` does not carry them. Built from the same enums the generate tools use, so every alias it lists is accepted back. Static: no profile, no browser, no spend. * `gflow_instructions_list(project, profile)`: Lists a project's persistent Agent-Mode instruction cards (live server brief; credits-free). diff --git a/docs/superpowers/memory/real-browser-auth-mandatory.md b/docs/superpowers/memory/real-browser-auth-mandatory.md index 9dd63be5c..a8eb20307 100644 --- a/docs/superpowers/memory/real-browser-auth-mandatory.md +++ b/docs/superpowers/memory/real-browser-auth-mandatory.md @@ -43,8 +43,9 @@ headless mints were accepted at a rate comparable to headed ones, and page fresh visibility, decided acceptance. A not-charged refusal is retried once from a fresh headless process. **What did not change.** The real browser is still required: the token is minted only inside a real -Flow page in the profile's Chrome, never synthesised, stored or replayed. Every unmeasured surface -(r2v, extend, edit, end-frame i2v, 4K/720p/GIF upscale, scenes, characters, instructions, the agent +Flow page in the profile's Chrome, never synthesised, stored or replayed. A UI surface runs headless +only once it is measured headless (`HEADLESS_UI_SURFACES`, docs/BROWSER_MODES.md); every other +surface (r2v, edit, end-frame i2v, image upscale, scenes, characters, instructions, the agent composer, credit-capped video) still drives the Flow UI, headed. The Chrome-channel rule above binds headless launches exactly as headed ones: a marker-less profile still downgrades to bundled Chromium, so generation paths still require a Chrome-strategy profile. diff --git a/docs/superpowers/spikes/2026-11-30-headless-video-upscale.md b/docs/superpowers/spikes/2026-11-29-headless-video-upscale.md similarity index 79% rename from docs/superpowers/spikes/2026-11-30-headless-video-upscale.md rename to docs/superpowers/spikes/2026-11-29-headless-video-upscale.md index 9d8afc5ae..511c38b03 100644 --- a/docs/superpowers/spikes/2026-11-30-headless-video-upscale.md +++ b/docs/superpowers/spikes/2026-11-29-headless-video-upscale.md @@ -1,6 +1,6 @@ # Spike: the video download-menu upscales in a headless browser (#1554) -**Date:** 2026-11-30 · **Script:** +**Date:** 2026-11-29 · **Script:** [`scripts/dev/spike_headless_video_upscale.py`](../../../scripts/dev/spike_headless_video_upscale.py) ## Method @@ -21,6 +21,10 @@ were pre-registered in the script. The credit balance was read before and after. The balance stayed at 50 credits across all runs: the 720p and 270p exports spent nothing. +Later the same evening, the same account refused headless 2K image upscales while accepting a +headed one ([image spike addendum](2026-11-29-headless-image-ui.md)); in that window the 270p +and 720p exports (CLI and MCP e2e) still passed headless. + ## Verdict - `video upscale --scale 720p` and `--scale 270p` behave the same headless: they join the @@ -35,5 +39,6 @@ The balance stayed at 50 credits across all runs: the 720p and 270p exports spen ## Not measured -4K on an Ultra account, 1080p through the menu, macOS, Linux, a second account, accounts Flow +4K on an Ultra account, 1080p through the menu (planned, or a planned direct 1080p that falls +back to the menu in the browser it launched headless), macOS, Linux, a second account, accounts Flow serves on labs.google. diff --git a/tests/e2e/test_migrated_upscale_e2e.py b/tests/e2e/test_migrated_upscale_e2e.py index 590ded992..aef154186 100644 --- a/tests/e2e/test_migrated_upscale_e2e.py +++ b/tests/e2e/test_migrated_upscale_e2e.py @@ -309,26 +309,30 @@ async def test_mcp_video_upscale_720p_runs_headless_e2e( profile = os.environ.get("GFLOW_CLI_E2E_PROFILE", "").strip() if not profile: pytest.skip("GFLOW_CLI_E2E_PROFILE required") - row = next( - ( - r - for r in list_videos( - db_path=get_settings().resolved_db_path(), profile=profile, limit=20, offset=0 - ) - if r.project_id - ), - None, - ) - if row is None: + rows = [ + r + for r in list_videos( + db_path=get_settings().resolved_db_path(), profile=profile, limit=20, offset=0 + ) + if r.project_id + ] + if not rows: pytest.skip(f"no catalogued videos for profile {profile!r} to export") monkeypatch.setenv("GFLOW_CLI_OUTPUT_DIR", str(tmp_path)) reset_settings() + result: dict[str, Any] = {} try: - result: dict[str, Any] = await tools.gflow_upscale_video( - media_id=row.media_id, scale="720p", out_dir=str(tmp_path), profile=profile - ) + # Flow decides per clip which scales its menu offers: a clip without 720p is exit 22. + for row in rows: + result = await tools.gflow_upscale_video( + media_id=row.media_id, scale="720p", out_dir=str(tmp_path), profile=profile + ) + if (result.get("error") or {}).get("exit_code") != 22: + break finally: reset_settings() + if (result.get("error") or {}).get("exit_code") == 22: + pytest.skip("no catalogued clip offers a 720p export") assert result.get("status") == "ok", f"MCP 720p export failed: {result}" assert (result.get("route"), result.get("visibility")) == ("ui", expected_visibility()) diff --git a/website/docs/BROWSER_MODES.md b/website/docs/BROWSER_MODES.md index c9fece936..980b4be7b 100644 --- a/website/docs/BROWSER_MODES.md +++ b/website/docs/BROWSER_MODES.md @@ -54,7 +54,7 @@ browser has been measured, so `auto` runs them headless. | `video r2v` | headed | Reference-to-video is not measured over direct HTTP | | `video edit` | headed | Not measured over direct HTTP | | `video i2v --end-frame` | headed | An end frame, or a start frame that is already in the project, is not a measured shape | -| `video upscale --scale 1080p` (menu) | headed | 1080p of a clip the local catalog does not hold as a measured direct source drives the download menu; not measured headless (the menu offered no 1080p on the clip tried) | +| `video upscale --scale 1080p` (menu) | headed | 1080p of a clip the local catalog does not hold as a measured direct source is planned through the download menu and launches headed; not measured headless (the menu offered no 1080p on the clip tried). A planned direct 1080p that falls back to the menu at run time stays in the headless browser it launched | | `scene create` | headed | Reads the retired labs.google session token; refused identically headless and headed on an account served flow.google.com (HTTP 410), so headless is unmeasured ([#1554](https://github.com/ffroliva/gflow-cli/issues/1554), [#639](https://github.com/ffroliva/gflow-cli/issues/639)) | | `scene show` | headed | As `scene create` | | `character create` | headed | On an account served flow.google.com, gflow cannot drive it yet in either mode ([#1587](https://github.com/ffroliva/gflow-cli/issues/1587)), so headless is unmeasured | diff --git a/website/docs/MCP.md b/website/docs/MCP.md index 403252e67..ad031a2a1 100644 --- a/website/docs/MCP.md +++ b/website/docs/MCP.md @@ -194,7 +194,7 @@ is [BROWSER_MODES](BROWSER_MODES.md). * `gflow_usage_stats(weeks)`: Summarize local gflow-cli usage statistics over the last N weeks (default 12, range 1..53). Returns command invocation counts across surfaces from local telemetry (or null when telemetry is off) and generation counts by command, model, status, and month from the local catalog. Its `telemetry` block includes `state`, `switch`, `upload` (`enabled` and `reason`), and the current report (#1164). The tool reads local data and spends no credits; like other MCP calls, its telemetry hook may start a separate weekly upload when eligible. MCP does not expose telemetry `on` or `off`; those controls are CLI-only by design. * `gflow_download_media(media_id, out_dir, profile)`: Fetches an already-generated asset from Flow by its media ID and writes it to disk — the recovery path for a generation that was billed but whose download failed. Spends no credits. The bytes are verified against the size Flow reports before the file is written, and the catalog's `local_files` row is updated. Returns `path`, `bytes`, `media_id`, `workflow_id`, `project_id` and `profile`. The transfer retries a dropped connection internally ([#895](https://github.com/ffroliva/gflow-cli/issues/895)), so a failure marked `retryable` means pause and call again — not immediately, and not in a tight loop: each call opens a browser under a per-profile lease, and a second concurrent call fails on that lease instead (exit 11). * `gflow_upscale_image(media_id, scale, project, out_dir, profile)`: Upscales an already-generated image to 2K or 4K; it opens a headed browser under `auto` (a headless 2K upscale was refused as unusual activity on one of two accounts, #1554). `scale` is `2k` or `4k` (4K requires Ultra; Pro accounts support 2K). A scale the download menu does not list is exit 22 (`upscale-unavailable`), naming the listed scales. 2K spends no credits; whether 4K does has not been measured, so a 4K refusal reads `charged: maybe` / `next_action: reconcile`. -* `gflow_upscale_video(media_id, scale, project, out_dir, profile, browser_visibility)`: Under `auto`, the download-menu scales (720p, 270p, and 4K unmeasured) run in a headless browser (#1554). Upscales or exports an already-generated video to 4K Ultra (spends credits), 1080p Full HD, downloads it at 720p (the original, or for a clip with a smaller original Flow's 720p upscale), or exports a 270p animated GIF. `scale` is `4k`, `1080p`, `720p`, or `270p`. Flow decides which scales each clip offers (a Veo 3.1 Lite clip lists no 1080p; `4k` requires Flow Ultra); a scale the clip's download menu does not list returns `UpscaleUnavailableError` (exit 22) naming the listed scales (#1338). Driven on `flow.google.com` only; 1080p was measured free (2026-10-07) while 4K spends credits (measured 50 credits on Omni 1.2 Flash, 2026-11-23). A 1080p upscale of a clip the local catalog records as Omni 1.2 Flash, 4 s, 16:9 goes over direct HTTP with a headless browser that only mints the reCAPTCHA token; every other upscale drives the clip's download menu in a headed browser. The result names the `route` the upscale took (`ui` when a planned direct attempt fell back to the menu) and the `visibility`. +* `gflow_upscale_video(media_id, scale, project, out_dir, profile, browser_visibility)`: Under `auto`, the download-menu scales (720p, 270p, and 4K unmeasured) run in a headless browser (#1554). Upscales or exports an already-generated video to 4K Ultra (spends credits), 1080p Full HD, downloads it at 720p (the original, or for a clip with a smaller original Flow's 720p upscale), or exports a 270p animated GIF. `scale` is `4k`, `1080p`, `720p`, or `270p`. Flow decides which scales each clip offers (a Veo 3.1 Lite clip lists no 1080p; `4k` requires Flow Ultra); a scale the clip's download menu does not list returns `UpscaleUnavailableError` (exit 22) naming the listed scales (#1338). Driven on `flow.google.com` only; 1080p was measured free (2026-10-07) while 4K spends credits (measured 50 credits on Omni 1.2 Flash, 2026-11-23). A 1080p upscale of a clip the local catalog records as Omni 1.2 Flash, 4 s, 16:9 goes over direct HTTP with a headless browser that only mints the reCAPTCHA token; 1080p planned through the menu drives it in a headed browser. The result names the `route` the upscale took (`ui` when a planned direct attempt fell back to the menu) and the `visibility`. * `gflow_list_tools()`: Lists the prompt tools (name/title/description/category) accepted by the generate tools' `tools` param. Each `tools` item is `{"name": , "options": {...}}`, e.g. `[{"name": "creative-director"}]`. * `gflow_list_models()`: The image and video model catalog, the same object as `gflow models --json` ([#883](https://github.com/ffroliva/gflow-cli/issues/883)); each model entry is what `gflow models show --json` prints ([#1196](https://github.com/ffroliva/gflow-cli/issues/1196)): per model `name`, `label` (image: Flow's menu name), the CLI's `--model` `aliases` (the generate tools accept each of them as `model`, plus wider spellings such as `narwhal` or `veo_lite`), `ref_cap`, `default` (image), and `max_duration`, `durations` (video: the clip lengths `duration` accepts for that model) and `retires_on` (video: the ISO date Flow retires the model, or `null`; [#1375](https://github.com/ffroliva/gflow-cli/issues/1375)). `aspects` and video `tiers` sit on each section (`image` / `video`), not on the per-model entry, so `models show --json` does not carry them. Built from the same enums the generate tools use, so every alias it lists is accepted back. Static: no profile, no browser, no spend. * `gflow_instructions_list(project, profile)`: Lists a project's persistent Agent-Mode instruction cards (live server brief; credits-free). From 1b624a067d46d624386608faba6a03824a9aa39f Mon Sep 17 00:00:00 2001 From: Flavio Oliva Date: Sun, 29 Nov 2026 22:09:14 +0000 Subject: [PATCH 3/3] docs(video): the MCP surfaces name the headless menu upscales (#1554) The gflow_upscale_video tool description and the MCP.md visibility paragraph named every menu upscale headed; they now name 720p, 270p and the unmeasured 4K as headless under auto and 1080p planned through the menu as headed. The CHANGELOG and README say 4K spends credits on the click; the spike script measures the free scales unless 4K is named. Refs #1554 --- CHANGELOG.md | 3 ++- README.md | 4 ++-- docs/MCP.md | 7 ++++--- scripts/dev/spike_headless_video_upscale.py | 6 ++++-- src/gflow_cli/mcp/tools.py | 5 +++-- website/docs/MCP.md | 7 ++++--- 6 files changed, 19 insertions(+), 13 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0a139dc5c..9ab4bc8b5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -25,7 +25,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 headless browser, on the CLI and on `gflow_upscale_video`: each ran twice headless matching a headed control and spent no credits, including on an account that was refusing headless image upscales at the time. `video upscale --scale 4k` (Ultra only) follows the same path headless by - decision; it was not measured, as no Ultra account was available. 1080p planned through the + decision; it was not measured, as no Ultra account was available, and it spends credits on the + click, which is never retried. 1080p planned through the menu (a clip outside the measured direct shape) and every image upscale stay headed. `GFLOW_CLI_TRANSPORT=ui_automation`, an explicit `GFLOW_CLI_FLOW_HOST=labs.google` and `--browser-visibility headed` keep the window. The MCP upscale tools now plan from the route diff --git a/README.md b/README.md index 5dd1f282b..fcd978369 100644 --- a/README.md +++ b/README.md @@ -53,7 +53,7 @@ Which commands open a browser, with the default `GFLOW_CLI_BROWSER_VISIBILITY=au | `media trash` | none or headless | Sent with no browser when the direct read is available; otherwise from a flow.google.com page, measured headless ([#1554](https://github.com/ffroliva/gflow-cli/issues/1554)). Also `media restore`. `GFLOW_CLI_TRANSPORT=ui_automation` keeps the page fallback headed | | `image i2i --ref` | headless with one local file | One local reference file in an existing project, on a request that would go direct once the file is uploaded: a new file is uploaded and generated directly, a file already in the project is attached through Flow's UI, both from a headless browser ([#1554](https://github.com/ffroliva/gflow-cli/issues/1554)). More files, another reference, a character or an unmeasured model keep it headed | | `video upscale --scale 720p` | headless on `flow.google.com` | Drives the download menu; 720p and the 270p GIF measured headless, 0 credits ([#1554](https://github.com/ffroliva/gflow-cli/issues/1554)) | -| `video upscale --scale 4k` | headless on `flow.google.com` (not measured) | Ultra only; follows the measured menu path by decision ([#1554](https://github.com/ffroliva/gflow-cli/issues/1554)) | +| `video upscale --scale 4k` | headless on `flow.google.com` (not measured) | Ultra only; spends credits on the click; follows the measured menu path by decision ([#1554](https://github.com/ffroliva/gflow-cli/issues/1554)) | **Headed** (Flow's UI) @@ -67,7 +67,7 @@ Which commands open a browser, with the default `GFLOW_CLI_BROWSER_VISIBILITY=au | `video r2v` | headed | Reference-to-video is not measured over direct HTTP | | `video edit` | headed | Not measured over direct HTTP | | `video i2v --end-frame` | headed | An end frame, or a start frame that is already in the project, is not a measured shape | -| `video upscale --scale 1080p` (menu) | headed | 1080p of a clip the local catalog does not hold drives the download menu; not measured headless | +| `video upscale --scale 1080p` (menu) | headed | 1080p of a clip the local catalog does not hold as a measured direct source drives the download menu; not measured headless | | `scene create` | headed | Scenes are built in the UI | | `scene show` | headed | Reads the scene in the UI | | `character create` | headed | Character creation is a UI surface | diff --git a/docs/MCP.md b/docs/MCP.md index ad031a2a1..be907d28d 100644 --- a/docs/MCP.md +++ b/docs/MCP.md @@ -117,8 +117,9 @@ headless browser that only mints the reCAPTCHA token and is sent over direct HTT shape, and any video with a `max_credits` cap, opens a headed browser. The exception is `gflow_extend_video` on `flow.google.com`: it drives Flow's UI, which is measured headless, so `auto` runs it headless ([#1554](https://github.com/ffroliva/gflow-cli/issues/1554)), as do the page fallback of -`gflow_media_trash` / `gflow_media_restore` and a `gflow_generate_image` call whose only reference -is one local file in an existing project, when the request would go direct once the file is uploaded. A refusal Flow did not +`gflow_media_trash` / `gflow_media_restore`, a `gflow_generate_image` call whose only reference +is one local file in an existing project, when the request would go direct once the file is uploaded, +and the `gflow_upscale_video` download-menu scales (720p, 270p, and 4K, which is unmeasured). A refusal Flow did not charge is retried once from a new headless browser; a second one is final (`WafRejectionError`, `charged: "no"`, `retryable: false`, `next_action: "wait"`). `headless` for any other Flow UI shape is unsupported in v0.108.0 ([#1554](https://github.com/ffroliva/gflow-cli/issues/1554)). The @@ -194,7 +195,7 @@ is [BROWSER_MODES](BROWSER_MODES.md). * `gflow_usage_stats(weeks)`: Summarize local gflow-cli usage statistics over the last N weeks (default 12, range 1..53). Returns command invocation counts across surfaces from local telemetry (or null when telemetry is off) and generation counts by command, model, status, and month from the local catalog. Its `telemetry` block includes `state`, `switch`, `upload` (`enabled` and `reason`), and the current report (#1164). The tool reads local data and spends no credits; like other MCP calls, its telemetry hook may start a separate weekly upload when eligible. MCP does not expose telemetry `on` or `off`; those controls are CLI-only by design. * `gflow_download_media(media_id, out_dir, profile)`: Fetches an already-generated asset from Flow by its media ID and writes it to disk — the recovery path for a generation that was billed but whose download failed. Spends no credits. The bytes are verified against the size Flow reports before the file is written, and the catalog's `local_files` row is updated. Returns `path`, `bytes`, `media_id`, `workflow_id`, `project_id` and `profile`. The transfer retries a dropped connection internally ([#895](https://github.com/ffroliva/gflow-cli/issues/895)), so a failure marked `retryable` means pause and call again — not immediately, and not in a tight loop: each call opens a browser under a per-profile lease, and a second concurrent call fails on that lease instead (exit 11). * `gflow_upscale_image(media_id, scale, project, out_dir, profile)`: Upscales an already-generated image to 2K or 4K; it opens a headed browser under `auto` (a headless 2K upscale was refused as unusual activity on one of two accounts, #1554). `scale` is `2k` or `4k` (4K requires Ultra; Pro accounts support 2K). A scale the download menu does not list is exit 22 (`upscale-unavailable`), naming the listed scales. 2K spends no credits; whether 4K does has not been measured, so a 4K refusal reads `charged: maybe` / `next_action: reconcile`. -* `gflow_upscale_video(media_id, scale, project, out_dir, profile, browser_visibility)`: Under `auto`, the download-menu scales (720p, 270p, and 4K unmeasured) run in a headless browser (#1554). Upscales or exports an already-generated video to 4K Ultra (spends credits), 1080p Full HD, downloads it at 720p (the original, or for a clip with a smaller original Flow's 720p upscale), or exports a 270p animated GIF. `scale` is `4k`, `1080p`, `720p`, or `270p`. Flow decides which scales each clip offers (a Veo 3.1 Lite clip lists no 1080p; `4k` requires Flow Ultra); a scale the clip's download menu does not list returns `UpscaleUnavailableError` (exit 22) naming the listed scales (#1338). Driven on `flow.google.com` only; 1080p was measured free (2026-10-07) while 4K spends credits (measured 50 credits on Omni 1.2 Flash, 2026-11-23). A 1080p upscale of a clip the local catalog records as Omni 1.2 Flash, 4 s, 16:9 goes over direct HTTP with a headless browser that only mints the reCAPTCHA token; 1080p planned through the menu drives it in a headed browser. The result names the `route` the upscale took (`ui` when a planned direct attempt fell back to the menu) and the `visibility`. +* `gflow_upscale_video(media_id, scale, project, out_dir, profile, browser_visibility)`: Upscales or exports an already-generated video to 4K Ultra (spends credits), 1080p Full HD, downloads it at 720p (the original, or for a clip with a smaller original Flow's 720p upscale), or exports a 270p animated GIF. `scale` is `4k`, `1080p`, `720p`, or `270p`. Flow decides which scales each clip offers (a Veo 3.1 Lite clip lists no 1080p; `4k` requires Flow Ultra); a scale the clip's download menu does not list returns `UpscaleUnavailableError` (exit 22) naming the listed scales (#1338). Driven on `flow.google.com` only; 1080p was measured free (2026-10-07) while 4K spends credits (measured 50 credits on Omni 1.2 Flash, 2026-11-23). A 1080p upscale of a clip the local catalog records as Omni 1.2 Flash, 4 s, 16:9 goes over direct HTTP with a headless browser that only mints the reCAPTCHA token; 1080p planned through the menu drives it in a headed browser. The result names the `route` the upscale took (`ui` when a planned direct attempt fell back to the menu) and the `visibility`. Under `auto`, the download-menu scales (720p, 270p, and 4K unmeasured) run in a headless browser (#1554). * `gflow_list_tools()`: Lists the prompt tools (name/title/description/category) accepted by the generate tools' `tools` param. Each `tools` item is `{"name": , "options": {...}}`, e.g. `[{"name": "creative-director"}]`. * `gflow_list_models()`: The image and video model catalog, the same object as `gflow models --json` ([#883](https://github.com/ffroliva/gflow-cli/issues/883)); each model entry is what `gflow models show --json` prints ([#1196](https://github.com/ffroliva/gflow-cli/issues/1196)): per model `name`, `label` (image: Flow's menu name), the CLI's `--model` `aliases` (the generate tools accept each of them as `model`, plus wider spellings such as `narwhal` or `veo_lite`), `ref_cap`, `default` (image), and `max_duration`, `durations` (video: the clip lengths `duration` accepts for that model) and `retires_on` (video: the ISO date Flow retires the model, or `null`; [#1375](https://github.com/ffroliva/gflow-cli/issues/1375)). `aspects` and video `tiers` sit on each section (`image` / `video`), not on the per-model entry, so `models show --json` does not carry them. Built from the same enums the generate tools use, so every alias it lists is accepted back. Static: no profile, no browser, no spend. * `gflow_instructions_list(project, profile)`: Lists a project's persistent Agent-Mode instruction cards (live server brief; credits-free). diff --git a/scripts/dev/spike_headless_video_upscale.py b/scripts/dev/spike_headless_video_upscale.py index 9b29a1258..cdd252027 100644 --- a/scripts/dev/spike_headless_video_upscale.py +++ b/scripts/dev/spike_headless_video_upscale.py @@ -18,7 +18,7 @@ Usage:: uv run python scripts/dev/spike_headless_video_upscale.py --profile \ - --media-id --project --scales 720p 270p 4k --runs 2 + --media-id --project --scales 720p 270p --runs 2 """ from __future__ import annotations @@ -57,7 +57,9 @@ def main() -> None: parser.add_argument("--profile", required=True) parser.add_argument("--media-id", required=True) parser.add_argument("--project", required=True) - parser.add_argument("--scales", nargs="+", default=["720p", "270p", "4k"]) + parser.add_argument( + "--scales", nargs="+", default=["720p", "270p"], help="add 4k explicitly: it bills on Ultra" + ) parser.add_argument("--runs", type=int, default=2) args = parser.parse_args() print(json.dumps({"credits_before": _balance(args.profile)})) diff --git a/src/gflow_cli/mcp/tools.py b/src/gflow_cli/mcp/tools.py index b77ced256..0d7e15e02 100644 --- a/src/gflow_cli/mcp/tools.py +++ b/src/gflow_cli/mcp/tools.py @@ -1908,8 +1908,9 @@ async def gflow_upscale_image( "Measured: 1080p export spent 0 credits (2026-10-07); 4k Ultra export spends credits " "(measured 50 credits on Omni 1.2 Flash, 2026-11-23). " "A 1080p upscale of a catalogued measured source goes over direct HTTP with a " - "headless browser that only mints the reCAPTCHA token; every other upscale drives " - "the clip's download menu in a visible browser (browser_visibility overrides). The " + "headless browser that only mints the reCAPTCHA token. Under auto, the download-menu " + "scales (720p, 270p, and 4k, which is unmeasured) run in a headless browser; 1080p " + "planned through the menu opens a visible one (browser_visibility overrides). The " "result names route and visibility." ), ) diff --git a/website/docs/MCP.md b/website/docs/MCP.md index ad031a2a1..be907d28d 100644 --- a/website/docs/MCP.md +++ b/website/docs/MCP.md @@ -117,8 +117,9 @@ headless browser that only mints the reCAPTCHA token and is sent over direct HTT shape, and any video with a `max_credits` cap, opens a headed browser. The exception is `gflow_extend_video` on `flow.google.com`: it drives Flow's UI, which is measured headless, so `auto` runs it headless ([#1554](https://github.com/ffroliva/gflow-cli/issues/1554)), as do the page fallback of -`gflow_media_trash` / `gflow_media_restore` and a `gflow_generate_image` call whose only reference -is one local file in an existing project, when the request would go direct once the file is uploaded. A refusal Flow did not +`gflow_media_trash` / `gflow_media_restore`, a `gflow_generate_image` call whose only reference +is one local file in an existing project, when the request would go direct once the file is uploaded, +and the `gflow_upscale_video` download-menu scales (720p, 270p, and 4K, which is unmeasured). A refusal Flow did not charge is retried once from a new headless browser; a second one is final (`WafRejectionError`, `charged: "no"`, `retryable: false`, `next_action: "wait"`). `headless` for any other Flow UI shape is unsupported in v0.108.0 ([#1554](https://github.com/ffroliva/gflow-cli/issues/1554)). The @@ -194,7 +195,7 @@ is [BROWSER_MODES](BROWSER_MODES.md). * `gflow_usage_stats(weeks)`: Summarize local gflow-cli usage statistics over the last N weeks (default 12, range 1..53). Returns command invocation counts across surfaces from local telemetry (or null when telemetry is off) and generation counts by command, model, status, and month from the local catalog. Its `telemetry` block includes `state`, `switch`, `upload` (`enabled` and `reason`), and the current report (#1164). The tool reads local data and spends no credits; like other MCP calls, its telemetry hook may start a separate weekly upload when eligible. MCP does not expose telemetry `on` or `off`; those controls are CLI-only by design. * `gflow_download_media(media_id, out_dir, profile)`: Fetches an already-generated asset from Flow by its media ID and writes it to disk — the recovery path for a generation that was billed but whose download failed. Spends no credits. The bytes are verified against the size Flow reports before the file is written, and the catalog's `local_files` row is updated. Returns `path`, `bytes`, `media_id`, `workflow_id`, `project_id` and `profile`. The transfer retries a dropped connection internally ([#895](https://github.com/ffroliva/gflow-cli/issues/895)), so a failure marked `retryable` means pause and call again — not immediately, and not in a tight loop: each call opens a browser under a per-profile lease, and a second concurrent call fails on that lease instead (exit 11). * `gflow_upscale_image(media_id, scale, project, out_dir, profile)`: Upscales an already-generated image to 2K or 4K; it opens a headed browser under `auto` (a headless 2K upscale was refused as unusual activity on one of two accounts, #1554). `scale` is `2k` or `4k` (4K requires Ultra; Pro accounts support 2K). A scale the download menu does not list is exit 22 (`upscale-unavailable`), naming the listed scales. 2K spends no credits; whether 4K does has not been measured, so a 4K refusal reads `charged: maybe` / `next_action: reconcile`. -* `gflow_upscale_video(media_id, scale, project, out_dir, profile, browser_visibility)`: Under `auto`, the download-menu scales (720p, 270p, and 4K unmeasured) run in a headless browser (#1554). Upscales or exports an already-generated video to 4K Ultra (spends credits), 1080p Full HD, downloads it at 720p (the original, or for a clip with a smaller original Flow's 720p upscale), or exports a 270p animated GIF. `scale` is `4k`, `1080p`, `720p`, or `270p`. Flow decides which scales each clip offers (a Veo 3.1 Lite clip lists no 1080p; `4k` requires Flow Ultra); a scale the clip's download menu does not list returns `UpscaleUnavailableError` (exit 22) naming the listed scales (#1338). Driven on `flow.google.com` only; 1080p was measured free (2026-10-07) while 4K spends credits (measured 50 credits on Omni 1.2 Flash, 2026-11-23). A 1080p upscale of a clip the local catalog records as Omni 1.2 Flash, 4 s, 16:9 goes over direct HTTP with a headless browser that only mints the reCAPTCHA token; 1080p planned through the menu drives it in a headed browser. The result names the `route` the upscale took (`ui` when a planned direct attempt fell back to the menu) and the `visibility`. +* `gflow_upscale_video(media_id, scale, project, out_dir, profile, browser_visibility)`: Upscales or exports an already-generated video to 4K Ultra (spends credits), 1080p Full HD, downloads it at 720p (the original, or for a clip with a smaller original Flow's 720p upscale), or exports a 270p animated GIF. `scale` is `4k`, `1080p`, `720p`, or `270p`. Flow decides which scales each clip offers (a Veo 3.1 Lite clip lists no 1080p; `4k` requires Flow Ultra); a scale the clip's download menu does not list returns `UpscaleUnavailableError` (exit 22) naming the listed scales (#1338). Driven on `flow.google.com` only; 1080p was measured free (2026-10-07) while 4K spends credits (measured 50 credits on Omni 1.2 Flash, 2026-11-23). A 1080p upscale of a clip the local catalog records as Omni 1.2 Flash, 4 s, 16:9 goes over direct HTTP with a headless browser that only mints the reCAPTCHA token; 1080p planned through the menu drives it in a headed browser. The result names the `route` the upscale took (`ui` when a planned direct attempt fell back to the menu) and the `visibility`. Under `auto`, the download-menu scales (720p, 270p, and 4K unmeasured) run in a headless browser (#1554). * `gflow_list_tools()`: Lists the prompt tools (name/title/description/category) accepted by the generate tools' `tools` param. Each `tools` item is `{"name": , "options": {...}}`, e.g. `[{"name": "creative-director"}]`. * `gflow_list_models()`: The image and video model catalog, the same object as `gflow models --json` ([#883](https://github.com/ffroliva/gflow-cli/issues/883)); each model entry is what `gflow models show --json` prints ([#1196](https://github.com/ffroliva/gflow-cli/issues/1196)): per model `name`, `label` (image: Flow's menu name), the CLI's `--model` `aliases` (the generate tools accept each of them as `model`, plus wider spellings such as `narwhal` or `veo_lite`), `ref_cap`, `default` (image), and `max_duration`, `durations` (video: the clip lengths `duration` accepts for that model) and `retires_on` (video: the ISO date Flow retires the model, or `null`; [#1375](https://github.com/ffroliva/gflow-cli/issues/1375)). `aspects` and video `tiers` sit on each section (`image` / `video`), not on the per-model entry, so `models show --json` does not carry them. Built from the same enums the generate tools use, so every alias it lists is accepted back. Static: no profile, no browser, no spend. * `gflow_instructions_list(project, profile)`: Lists a project's persistent Agent-Mode instruction cards (live server brief; credits-free).