takomi 2.1.40 → 2.1.41

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (68) hide show
  1. package/.agents/plugins/marketplace.json +22 -22
  2. package/README.md +3 -3
  3. package/assets/.agent/skills/remotion/rules/assets/charts-bar-chart.tsx +173 -173
  4. package/assets/.agent/skills/remotion/rules/assets/text-animations-typewriter.tsx +100 -100
  5. package/assets/.agent/skills/remotion/rules/text-animations.md +20 -20
  6. package/assets/.agent/skills/remotion/rules/videos.md +171 -171
  7. package/assets/.agent/skills/remotion-real-ui-video/SKILL.md +264 -0
  8. package/assets/.agent/skills/remotion-real-ui-video/references/anti-patterns.md +114 -0
  9. package/assets/.agent/skills/remotion-real-ui-video/references/completion-checklist.md +75 -0
  10. package/assets/.agent/skills/remotion-real-ui-video/references/real-ui-bridge-example.md +93 -0
  11. package/assets/.agent/skills/takomi-flow/SKILL.md +244 -244
  12. package/docs/features/TakomiFlow_Portable_Plugin.md +82 -82
  13. package/docs/takomi-flow-onboarding.md +86 -86
  14. package/docs/takomi-flow-public-distribution.md +94 -94
  15. package/package.json +1 -1
  16. package/plugins/takomi-flow/.mcp.json +11 -11
  17. package/plugins/takomi-flow/assets/capabilities.json +203 -203
  18. package/plugins/takomi-flow/assets/collection.schema.json +29 -29
  19. package/plugins/takomi-flow/assets/examples.json +94 -94
  20. package/plugins/takomi-flow/assets/request.schema.json +91 -91
  21. package/plugins/takomi-flow/assets/result.schema.json +46 -46
  22. package/plugins/takomi-flow/assets/templates/image-request.json +17 -17
  23. package/plugins/takomi-flow/assets/templates/video-request.json +19 -19
  24. package/plugins/takomi-flow/package.json +38 -38
  25. package/plugins/takomi-flow/pnpm-lock.yaml +813 -813
  26. package/plugins/takomi-flow/references/flow-provider-contract.md +349 -349
  27. package/plugins/takomi-flow/scripts/lib/agent-plan.mjs +140 -140
  28. package/plugins/takomi-flow/scripts/lib/api.mjs +113 -113
  29. package/plugins/takomi-flow/scripts/lib/args.mjs +66 -66
  30. package/plugins/takomi-flow/scripts/lib/audit.mjs +65 -65
  31. package/plugins/takomi-flow/scripts/lib/browser.mjs +78 -78
  32. package/plugins/takomi-flow/scripts/lib/capabilities.mjs +11 -11
  33. package/plugins/takomi-flow/scripts/lib/collect.mjs +53 -53
  34. package/plugins/takomi-flow/scripts/lib/commands.mjs +192 -192
  35. package/plugins/takomi-flow/scripts/lib/doctor.mjs +77 -77
  36. package/plugins/takomi-flow/scripts/lib/examples.mjs +17 -17
  37. package/plugins/takomi-flow/scripts/lib/flow-media.mjs +39 -39
  38. package/plugins/takomi-flow/scripts/lib/flow-outcome.mjs +115 -115
  39. package/plugins/takomi-flow/scripts/lib/flow-project-session.mjs +153 -153
  40. package/plugins/takomi-flow/scripts/lib/flow-ui.mjs +204 -204
  41. package/plugins/takomi-flow/scripts/lib/generation.mjs +190 -190
  42. package/plugins/takomi-flow/scripts/lib/inspect.mjs +81 -81
  43. package/plugins/takomi-flow/scripts/lib/mcp-prompts.mjs +39 -39
  44. package/plugins/takomi-flow/scripts/lib/mcp-resources.mjs +16 -16
  45. package/plugins/takomi-flow/scripts/lib/mcp-tools.mjs +165 -165
  46. package/plugins/takomi-flow/scripts/lib/media.mjs +78 -78
  47. package/plugins/takomi-flow/scripts/lib/observe.mjs +54 -54
  48. package/plugins/takomi-flow/scripts/lib/paths.mjs +37 -37
  49. package/plugins/takomi-flow/scripts/lib/playwright-loader.mjs +23 -23
  50. package/plugins/takomi-flow/scripts/lib/prompts.mjs +72 -72
  51. package/plugins/takomi-flow/scripts/lib/report.mjs +141 -141
  52. package/plugins/takomi-flow/scripts/lib/request-validator.mjs +73 -73
  53. package/plugins/takomi-flow/scripts/lib/request.mjs +66 -66
  54. package/plugins/takomi-flow/scripts/lib/resource-files.mjs +69 -69
  55. package/plugins/takomi-flow/scripts/lib/result.mjs +31 -31
  56. package/plugins/takomi-flow/scripts/lib/review.mjs +44 -44
  57. package/plugins/takomi-flow/scripts/lib/selftest.mjs +153 -153
  58. package/plugins/takomi-flow/scripts/lib/settings-plan.mjs +44 -44
  59. package/plugins/takomi-flow/scripts/lib/templates.mjs +37 -37
  60. package/plugins/takomi-flow/scripts/lib/trusted-chrome.mjs +67 -67
  61. package/plugins/takomi-flow/scripts/lib/workflow.mjs +56 -56
  62. package/plugins/takomi-flow/scripts/mcp-server.mjs +18 -18
  63. package/plugins/takomi-flow/scripts/mcp-smoke.mjs +144 -144
  64. package/plugins/takomi-flow/scripts/takomi-flow.mjs +17 -17
  65. package/plugins/takomi-flow/skills/takomi-flow/SKILL.md +244 -244
  66. package/plugins/takomi-flow/skills/takomi-flow/agents/openai.yaml +7 -7
  67. package/scripts/install-takomi-flow.ps1 +85 -85
  68. package/src/skills-catalog.js +10 -9
@@ -1,349 +1,349 @@
1
- # TakomiFlow Provider Contract
2
-
3
- ## Purpose
4
-
5
- TakomiFlow gives agents a stable interface for asking Google Flow to create assets through a browser profile the user controls.
6
-
7
- ## Surfaces
8
-
9
- - Skill: route Codex behavior and safety rules.
10
- - CLI: run browser workflows, request preparation, validation, and asset inspection.
11
- - MCP: expose safe no-spend commands as callable agent tools.
12
-
13
- MCP server:
14
-
15
- ```bash
16
- node scripts/mcp-server.mjs
17
- ```
18
-
19
- Smoke test:
20
-
21
- ```bash
22
- node scripts/mcp-smoke.mjs
23
- ```
24
-
25
- MCP tools mirror stable JSON operations: capabilities, doctor, audit, examples, template, prepare, workflow, validate, observe, generate, selftest, inspect, latest, runs, assets, review, collect, and report.
26
-
27
- Browser-capable MCP tools require explicit `allowBrowser=true`. Generation also requires the normal spend guard.
28
-
29
- MCP resources:
30
-
31
- - `takomi-flow://contract`
32
- - `takomi-flow://capabilities`
33
- - `takomi-flow://examples`
34
- - `takomi-flow://schemas/request`
35
- - `takomi-flow://schemas/result`
36
- - `takomi-flow://schemas/collection`
37
- - `takomi-flow://templates/video`
38
- - `takomi-flow://templates/image`
39
-
40
- MCP prompts:
41
-
42
- - `takomi_flow_video_workflow`
43
- - `takomi_flow_image_workflow`
44
- - `takomi_flow_review_workflow`
45
- - `takomi_flow_collect_workflow`
46
-
47
- ## Agent Preflight
48
-
49
- Run this before browser work when reliability matters:
50
-
51
- ```bash
52
- node scripts/takomi-flow.mjs doctor
53
- node scripts/takomi-flow.mjs audit
54
- ```
55
-
56
- `audit` is the preferred agent preflight. It reports readiness, safe no-spend actions, gated browser/spend actions, recent runs, and recommended next steps.
57
-
58
- First-run agents should also check for an existing trusted Chrome DevTools endpoint before launching a new browser:
59
-
60
- ```bash
61
- curl http://127.0.0.1:9222/json/version
62
- ```
63
-
64
- If the endpoint exists, reuse it with `--cdp-url http://127.0.0.1:9222`. If it does not exist, run `trusted-chrome` and ask the user to sign into Google Flow manually. Browser commands should start from trusted Chrome/CDP by default; Playwright-launched browser contexts are only an explicit fallback. MCP is optional; every MCP operation has a CLI equivalent through `node scripts/takomi-flow.mjs`.
65
-
66
- Repeated generations should reuse a Flow project instead of creating a new one. Pass `projectUrl` / `--project-url`, or attach to trusted Chrome while it is already on a `/project/` editor tab. TakomiFlow prefers the current project by default, does not click `New project` unless `allowNewProject=true` / `--allow-new-project` is set, and can recover a stale or broken chat by starting one fresh chat inside the same project.
67
-
68
- Flow should be treated as one active paid generation at a time. A gray preview placeholder plus scheduled, queue, or ready-shortly copy means the generation was accepted and is still in progress; do not classify it as failed or submit another paid generation until the current media is ready and downloaded.
69
-
70
- During polling, stale scheduled or failure text may remain visible after the current media is ready. The agent should probe for an open media view or ready media tile and exit as soon as the top toolbar Download control is available, instead of waiting for the full timeout.
71
-
72
- The Flow project name can be edited from the top-left header title/date-time input after opening the project.
73
-
74
- Run this after install or edits:
75
-
76
- ```bash
77
- node scripts/takomi-flow.mjs selftest
78
- ```
79
-
80
- Discover supported agent options:
81
-
82
- ```bash
83
- node scripts/takomi-flow.mjs capabilities
84
- node scripts/takomi-flow.mjs examples
85
- ```
86
-
87
- Observe the current Flow UI without spending credits:
88
-
89
- ```bash
90
- node scripts/takomi-flow.mjs observe
91
- node scripts/takomi-flow.mjs observe --browser-channel chrome
92
- ```
93
-
94
- If Google login shows "This browser or app may not be secure", rerun browser commands with
95
- `trusted-chrome`. Playwright-launched Chrome can still expose automation flags such as
96
- `--no-sandbox`; `trusted-chrome` starts Chrome directly with a remote debugging port and a dedicated
97
- TakomiFlow profile. After manual login, pass `--cdp-url http://127.0.0.1:9222` so TakomiFlow attaches
98
- to the trusted browser session instead of automating credential entry.
99
-
100
- Verified signed-in observation currently sees a Flow dashboard with project cards, `PRO` account
101
- state, and a `New project` button. Treat this as the preferred selector discovery starting point.
102
- The project editor currently exposes a prompt textbox with text `What do you want to create?`, plus
103
- `Agent`, `Agent Instructions`, `Settings`, file input, and `Create` buttons. Prompt filling has been
104
- verified without pressing Create.
105
- Live video durations are `4`, `6`, `8`, and `10` seconds. If the agent asks for an unsupported
106
- duration, Flow may ask a follow-up. A verified generation also asked for explicit approval before
107
- spending 7 credits for one video. After output creation, opening the generated media reveals a
108
- top toolbar download icon. Aim for the button with tooltip, title, aria label, or visible text
109
- `Download`; clicking it saves the MP4.
110
-
111
- Use templates when starting a request from scratch:
112
-
113
- ```bash
114
- node scripts/takomi-flow.mjs template --kind video
115
- node scripts/takomi-flow.mjs template --kind image
116
- ```
117
-
118
- Validate before generation:
119
-
120
- ```bash
121
- node scripts/takomi-flow.mjs validate --request <request.json>
122
- ```
123
-
124
- One-call agent workflow:
125
-
126
- ```bash
127
- node scripts/takomi-flow.mjs workflow --kind video --prompt "cinematic AI lab scene" --variations 2
128
- ```
129
-
130
- `workflow` prepares and validates a request in one call. Add `--submit --allow-browser --allow-spend` only after explicit user approval; the normal spend guard still applies.
131
-
132
- ## Request JSON
133
-
134
- Agents can read `takomi-flow://schemas/request` for the JSON Schema version of this shape.
135
-
136
- ```json
137
- {
138
- "schemaVersion": 1,
139
- "kind": "video",
140
- "prompt": "cinematic AI lab scene with practical lighting",
141
- "variations": 2,
142
- "aspectRatio": "16:9",
143
- "durationSeconds": 8,
144
- "mode": "text-to-video",
145
- "modelHint": "best-available",
146
- "outputDir": "C:/Users/johno/.takomi-flow/runs",
147
- "allowSpend": false,
148
- "extractFrames": 4,
149
- "projectUrl": "https://labs.google/fx/tools/flow/project/example",
150
- "reuseCurrentProject": true,
151
- "allowNewProject": false,
152
- "freshChatOnFailure": true,
153
- "editorWaitMs": 90000,
154
- "notes": "Optional agent notes for traceability."
155
- }
156
- ```
157
-
158
- ## Fields
159
-
160
- Agents can discover the same fields from `capabilities.requestFields`.
161
-
162
- - `kind`: `video` or `image`.
163
- - `prompt`: Required non-empty generation prompt.
164
- - `variations`: Positive integer. Defaults to `1`.
165
- - `aspectRatio`: Optional UI hint such as `16:9`, `9:16`, or `1:1`.
166
- - `durationSeconds`: Optional video duration hint.
167
- - `mode`: Optional Flow mode hint such as `text-to-video`, `image-to-video`, or `text-to-image`.
168
- - `modelHint`: Optional human-readable model or quality hint.
169
- - `outputDir`: Optional base output directory.
170
- - `allowSpend`: Must be `true` for generation submission.
171
- - `extractFrames`: Optional number of review frames to extract from downloaded videos.
172
- - `sourceAssets`: Optional array of local file paths for future image/video-to-video flows.
173
- - `projectUrl`: Optional existing Flow project/editor URL to reuse.
174
- - `reuseCurrentProject`: Prefer an already open Flow project tab when attached through CDP. Defaults to `true`.
175
- - `allowNewProject`: Permit clicking `New project` when no reusable project/editor exists. Defaults to `false`.
176
- - `freshChatOnFailure`: Try one fresh chat inside the same project when prompt or submit controls are broken. Defaults to `true`.
177
- - `editorWaitMs`: Optional wait budget for Flow editor readiness.
178
-
179
- ## Validation JSON
180
-
181
- `validate` normalizes request values, checks them against `capabilities`, verifies source asset paths, and reports spend-guard state:
182
-
183
- ```json
184
- {
185
- "schemaVersion": 1,
186
- "status": "ok",
187
- "normalized": {},
188
- "errors": [],
189
- "warnings": []
190
- }
191
- ```
192
-
193
- ## Result JSON
194
-
195
- Agents can read `takomi-flow://schemas/result` for the JSON Schema version of run metadata.
196
-
197
- ```json
198
- {
199
- "schemaVersion": 1,
200
- "status": "manual_action_required",
201
- "runId": "20260701-120000-flow",
202
- "kind": "video",
203
- "prompt": "cinematic AI lab scene with practical lighting",
204
- "projectUrl": "https://labs.google/fx/tools/flow/project/example",
205
- "projectSession": {
206
- "projectUrl": "https://labs.google/fx/tools/flow/project/example",
207
- "recovered": false
208
- },
209
- "settingsPlan": {
210
- "requested": {
211
- "mode": "text-to-video",
212
- "variations": 2,
213
- "aspectRatio": "16:9",
214
- "durationSeconds": 8
215
- },
216
- "automatic": ["prompt", "download folder", "metadata", "asset catalog"],
217
- "selectorDependent": [
218
- { "field": "aspectRatio", "value": "16:9" }
219
- ]
220
- },
221
- "assets": [],
222
- "assetCatalogPath": "C:/Users/johno/.takomi-flow/runs/20260701-120000-flow/assets.json",
223
- "screenshots": [],
224
- "errors": [],
225
- "manualActions": [
226
- "Complete Google login or Flow consent in the opened browser."
227
- ],
228
- "metadataPath": "C:/Users/johno/.takomi-flow/runs/20260701-120000-flow/run.json"
229
- }
230
- ```
231
-
232
- `projectUrl` records the exact Flow project/editor URL used for the run so agents do not lose track of generated projects. `settingsPlan` preserves the user's requested Flow options in run metadata. Prompt entry, downloads, metadata, asset cataloging, and frame extraction are automated. Mode, aspect ratio, duration, model controls, source assets, and multi-variation UI selection are selector-dependent until `observe` captures the live Flow controls.
233
-
234
- ## Status Values
235
-
236
- - `prepared`: Request file created; no browser action happened.
237
- - `ok`: Command completed and artifacts were written.
238
- - `downloaded`: One or more assets were downloaded.
239
- - `manual_action_required`: User action is required in the browser.
240
- - `blocked`: Flow showed quota, safety, captcha, account, or unsupported UI state.
241
- - `failed`: Script error or unrecoverable automation failure.
242
-
243
- ## Safety Invariants
244
-
245
- - Never store Google credentials.
246
- - Never submit generation unless request `allowSpend` is true or `TAKOMI_FLOW_ALLOW_SPEND=true`.
247
- - Never bypass Google account, captcha, safety, or quota controls.
248
- - Always write a result file, even on failure.
249
- - Always save downloads into the run directory unless the request explicitly overrides it.
250
-
251
- ## Asset Catalog
252
-
253
- Run:
254
-
255
- ```bash
256
- node scripts/takomi-flow.mjs assets --run <run.json|run-dir> --frames 4
257
- ```
258
-
259
- The command writes `assets.json` next to `run.json`. Video assets are probed with `ffprobe` when available, and review frames are extracted with `ffmpeg` when `--frames` is greater than zero.
260
-
261
- ## Run Review
262
-
263
- Run:
264
-
265
- ```bash
266
- node scripts/takomi-flow.mjs review --run <run.json|run-dir> --frames 4
267
- ```
268
-
269
- `review` is the preferred post-generation agent command. It inspects the run, catalogs downloaded assets, extracts review frames, writes a Markdown report, and returns next actions.
270
-
271
- ## Collection
272
-
273
- Run:
274
-
275
- ```bash
276
- node scripts/takomi-flow.mjs collect --run <run.json|run-dir> --target-dir <path> --frames 4 --include-frames
277
- ```
278
-
279
- `collect` reviews a run, copies assets/report/optional frames into a downstream target folder, and writes `takomi-flow-collection.json` as a manifest.
280
-
281
- Agents can read `takomi-flow://schemas/collection` for the JSON Schema version of the collection manifest.
282
-
283
- ## Markdown Reports
284
-
285
- Run:
286
-
287
- ```bash
288
- node scripts/takomi-flow.mjs report --run <run.json|run-dir>
289
- node scripts/takomi-flow.mjs report --output-dir <runs-dir> --limit 10
290
- ```
291
-
292
- The command writes `report.md` next to a single run, or `takomi-flow-report.md` in a runs directory. Reports include status, metadata paths, screenshots, assets, errors, manual actions, and catalog details when `assets.json` exists.
293
-
294
- ## Diagnostics JSON
295
-
296
- `doctor` returns:
297
-
298
- ```json
299
- {
300
- "schemaVersion": 1,
301
- "status": "ok",
302
- "flowUrl": "https://labs.google/fx/tools/flow",
303
- "profileDir": "C:/Users/johno/.takomi-flow/browser-profile",
304
- "outputDir": "C:/Users/johno/.takomi-flow/runs",
305
- "checks": [],
306
- "recommendations": []
307
- }
308
- ```
309
-
310
- ## Capabilities JSON
311
-
312
- `capabilities` returns supported kinds, modes, variation limits, aspect ratios, output artifact names, safety invariants, and available commands. Agents should prefer this over hard-coded assumptions.
313
-
314
- ## Observation JSON
315
-
316
- `observe` writes a normal `run.json` and includes a `controls` object:
317
-
318
- ```json
319
- {
320
- "controls": {
321
- "buttons": [],
322
- "inputs": [],
323
- "links": []
324
- }
325
- }
326
- ```
327
-
328
- Use it to tune Flow selectors after Google changes the UI.
329
-
330
- ## Self-Test JSON
331
-
332
- `selftest` runs a deterministic no-spend verification pass:
333
-
334
- - doctor diagnostics
335
- - readiness audit
336
- - capability loading
337
- - example loading
338
- - video/image template loading
339
- - request preparation
340
- - one-call workflow preparation/validation
341
- - settings-plan metadata for requested Flow options
342
- - request validation
343
- - spend-guard expectation
344
- - synthetic MP4 cataloging and frame extraction
345
- - Markdown report generation
346
- - one-call run review
347
- - downstream asset collection
348
-
349
- It writes artifacts under `<outputDir>/selftest`.
1
+ # TakomiFlow Provider Contract
2
+
3
+ ## Purpose
4
+
5
+ TakomiFlow gives agents a stable interface for asking Google Flow to create assets through a browser profile the user controls.
6
+
7
+ ## Surfaces
8
+
9
+ - Skill: route Codex behavior and safety rules.
10
+ - CLI: run browser workflows, request preparation, validation, and asset inspection.
11
+ - MCP: expose safe no-spend commands as callable agent tools.
12
+
13
+ MCP server:
14
+
15
+ ```bash
16
+ node scripts/mcp-server.mjs
17
+ ```
18
+
19
+ Smoke test:
20
+
21
+ ```bash
22
+ node scripts/mcp-smoke.mjs
23
+ ```
24
+
25
+ MCP tools mirror stable JSON operations: capabilities, doctor, audit, examples, template, prepare, workflow, validate, observe, generate, selftest, inspect, latest, runs, assets, review, collect, and report.
26
+
27
+ Browser-capable MCP tools require explicit `allowBrowser=true`. Generation also requires the normal spend guard.
28
+
29
+ MCP resources:
30
+
31
+ - `takomi-flow://contract`
32
+ - `takomi-flow://capabilities`
33
+ - `takomi-flow://examples`
34
+ - `takomi-flow://schemas/request`
35
+ - `takomi-flow://schemas/result`
36
+ - `takomi-flow://schemas/collection`
37
+ - `takomi-flow://templates/video`
38
+ - `takomi-flow://templates/image`
39
+
40
+ MCP prompts:
41
+
42
+ - `takomi_flow_video_workflow`
43
+ - `takomi_flow_image_workflow`
44
+ - `takomi_flow_review_workflow`
45
+ - `takomi_flow_collect_workflow`
46
+
47
+ ## Agent Preflight
48
+
49
+ Run this before browser work when reliability matters:
50
+
51
+ ```bash
52
+ node scripts/takomi-flow.mjs doctor
53
+ node scripts/takomi-flow.mjs audit
54
+ ```
55
+
56
+ `audit` is the preferred agent preflight. It reports readiness, safe no-spend actions, gated browser/spend actions, recent runs, and recommended next steps.
57
+
58
+ First-run agents should also check for an existing trusted Chrome DevTools endpoint before launching a new browser:
59
+
60
+ ```bash
61
+ curl http://127.0.0.1:9222/json/version
62
+ ```
63
+
64
+ If the endpoint exists, reuse it with `--cdp-url http://127.0.0.1:9222`. If it does not exist, run `trusted-chrome` and ask the user to sign into Google Flow manually. Browser commands should start from trusted Chrome/CDP by default; Playwright-launched browser contexts are only an explicit fallback. MCP is optional; every MCP operation has a CLI equivalent through `node scripts/takomi-flow.mjs`.
65
+
66
+ Repeated generations should reuse a Flow project instead of creating a new one. Pass `projectUrl` / `--project-url`, or attach to trusted Chrome while it is already on a `/project/` editor tab. TakomiFlow prefers the current project by default, does not click `New project` unless `allowNewProject=true` / `--allow-new-project` is set, and can recover a stale or broken chat by starting one fresh chat inside the same project.
67
+
68
+ Flow should be treated as one active paid generation at a time. A gray preview placeholder plus scheduled, queue, or ready-shortly copy means the generation was accepted and is still in progress; do not classify it as failed or submit another paid generation until the current media is ready and downloaded.
69
+
70
+ During polling, stale scheduled or failure text may remain visible after the current media is ready. The agent should probe for an open media view or ready media tile and exit as soon as the top toolbar Download control is available, instead of waiting for the full timeout.
71
+
72
+ The Flow project name can be edited from the top-left header title/date-time input after opening the project.
73
+
74
+ Run this after install or edits:
75
+
76
+ ```bash
77
+ node scripts/takomi-flow.mjs selftest
78
+ ```
79
+
80
+ Discover supported agent options:
81
+
82
+ ```bash
83
+ node scripts/takomi-flow.mjs capabilities
84
+ node scripts/takomi-flow.mjs examples
85
+ ```
86
+
87
+ Observe the current Flow UI without spending credits:
88
+
89
+ ```bash
90
+ node scripts/takomi-flow.mjs observe
91
+ node scripts/takomi-flow.mjs observe --browser-channel chrome
92
+ ```
93
+
94
+ If Google login shows "This browser or app may not be secure", rerun browser commands with
95
+ `trusted-chrome`. Playwright-launched Chrome can still expose automation flags such as
96
+ `--no-sandbox`; `trusted-chrome` starts Chrome directly with a remote debugging port and a dedicated
97
+ TakomiFlow profile. After manual login, pass `--cdp-url http://127.0.0.1:9222` so TakomiFlow attaches
98
+ to the trusted browser session instead of automating credential entry.
99
+
100
+ Verified signed-in observation currently sees a Flow dashboard with project cards, `PRO` account
101
+ state, and a `New project` button. Treat this as the preferred selector discovery starting point.
102
+ The project editor currently exposes a prompt textbox with text `What do you want to create?`, plus
103
+ `Agent`, `Agent Instructions`, `Settings`, file input, and `Create` buttons. Prompt filling has been
104
+ verified without pressing Create.
105
+ Live video durations are `4`, `6`, `8`, and `10` seconds. If the agent asks for an unsupported
106
+ duration, Flow may ask a follow-up. A verified generation also asked for explicit approval before
107
+ spending 7 credits for one video. After output creation, opening the generated media reveals a
108
+ top toolbar download icon. Aim for the button with tooltip, title, aria label, or visible text
109
+ `Download`; clicking it saves the MP4.
110
+
111
+ Use templates when starting a request from scratch:
112
+
113
+ ```bash
114
+ node scripts/takomi-flow.mjs template --kind video
115
+ node scripts/takomi-flow.mjs template --kind image
116
+ ```
117
+
118
+ Validate before generation:
119
+
120
+ ```bash
121
+ node scripts/takomi-flow.mjs validate --request <request.json>
122
+ ```
123
+
124
+ One-call agent workflow:
125
+
126
+ ```bash
127
+ node scripts/takomi-flow.mjs workflow --kind video --prompt "cinematic AI lab scene" --variations 2
128
+ ```
129
+
130
+ `workflow` prepares and validates a request in one call. Add `--submit --allow-browser --allow-spend` only after explicit user approval; the normal spend guard still applies.
131
+
132
+ ## Request JSON
133
+
134
+ Agents can read `takomi-flow://schemas/request` for the JSON Schema version of this shape.
135
+
136
+ ```json
137
+ {
138
+ "schemaVersion": 1,
139
+ "kind": "video",
140
+ "prompt": "cinematic AI lab scene with practical lighting",
141
+ "variations": 2,
142
+ "aspectRatio": "16:9",
143
+ "durationSeconds": 8,
144
+ "mode": "text-to-video",
145
+ "modelHint": "best-available",
146
+ "outputDir": "C:/Users/johno/.takomi-flow/runs",
147
+ "allowSpend": false,
148
+ "extractFrames": 4,
149
+ "projectUrl": "https://labs.google/fx/tools/flow/project/example",
150
+ "reuseCurrentProject": true,
151
+ "allowNewProject": false,
152
+ "freshChatOnFailure": true,
153
+ "editorWaitMs": 90000,
154
+ "notes": "Optional agent notes for traceability."
155
+ }
156
+ ```
157
+
158
+ ## Fields
159
+
160
+ Agents can discover the same fields from `capabilities.requestFields`.
161
+
162
+ - `kind`: `video` or `image`.
163
+ - `prompt`: Required non-empty generation prompt.
164
+ - `variations`: Positive integer. Defaults to `1`.
165
+ - `aspectRatio`: Optional UI hint such as `16:9`, `9:16`, or `1:1`.
166
+ - `durationSeconds`: Optional video duration hint.
167
+ - `mode`: Optional Flow mode hint such as `text-to-video`, `image-to-video`, or `text-to-image`.
168
+ - `modelHint`: Optional human-readable model or quality hint.
169
+ - `outputDir`: Optional base output directory.
170
+ - `allowSpend`: Must be `true` for generation submission.
171
+ - `extractFrames`: Optional number of review frames to extract from downloaded videos.
172
+ - `sourceAssets`: Optional array of local file paths for future image/video-to-video flows.
173
+ - `projectUrl`: Optional existing Flow project/editor URL to reuse.
174
+ - `reuseCurrentProject`: Prefer an already open Flow project tab when attached through CDP. Defaults to `true`.
175
+ - `allowNewProject`: Permit clicking `New project` when no reusable project/editor exists. Defaults to `false`.
176
+ - `freshChatOnFailure`: Try one fresh chat inside the same project when prompt or submit controls are broken. Defaults to `true`.
177
+ - `editorWaitMs`: Optional wait budget for Flow editor readiness.
178
+
179
+ ## Validation JSON
180
+
181
+ `validate` normalizes request values, checks them against `capabilities`, verifies source asset paths, and reports spend-guard state:
182
+
183
+ ```json
184
+ {
185
+ "schemaVersion": 1,
186
+ "status": "ok",
187
+ "normalized": {},
188
+ "errors": [],
189
+ "warnings": []
190
+ }
191
+ ```
192
+
193
+ ## Result JSON
194
+
195
+ Agents can read `takomi-flow://schemas/result` for the JSON Schema version of run metadata.
196
+
197
+ ```json
198
+ {
199
+ "schemaVersion": 1,
200
+ "status": "manual_action_required",
201
+ "runId": "20260701-120000-flow",
202
+ "kind": "video",
203
+ "prompt": "cinematic AI lab scene with practical lighting",
204
+ "projectUrl": "https://labs.google/fx/tools/flow/project/example",
205
+ "projectSession": {
206
+ "projectUrl": "https://labs.google/fx/tools/flow/project/example",
207
+ "recovered": false
208
+ },
209
+ "settingsPlan": {
210
+ "requested": {
211
+ "mode": "text-to-video",
212
+ "variations": 2,
213
+ "aspectRatio": "16:9",
214
+ "durationSeconds": 8
215
+ },
216
+ "automatic": ["prompt", "download folder", "metadata", "asset catalog"],
217
+ "selectorDependent": [
218
+ { "field": "aspectRatio", "value": "16:9" }
219
+ ]
220
+ },
221
+ "assets": [],
222
+ "assetCatalogPath": "C:/Users/johno/.takomi-flow/runs/20260701-120000-flow/assets.json",
223
+ "screenshots": [],
224
+ "errors": [],
225
+ "manualActions": [
226
+ "Complete Google login or Flow consent in the opened browser."
227
+ ],
228
+ "metadataPath": "C:/Users/johno/.takomi-flow/runs/20260701-120000-flow/run.json"
229
+ }
230
+ ```
231
+
232
+ `projectUrl` records the exact Flow project/editor URL used for the run so agents do not lose track of generated projects. `settingsPlan` preserves the user's requested Flow options in run metadata. Prompt entry, downloads, metadata, asset cataloging, and frame extraction are automated. Mode, aspect ratio, duration, model controls, source assets, and multi-variation UI selection are selector-dependent until `observe` captures the live Flow controls.
233
+
234
+ ## Status Values
235
+
236
+ - `prepared`: Request file created; no browser action happened.
237
+ - `ok`: Command completed and artifacts were written.
238
+ - `downloaded`: One or more assets were downloaded.
239
+ - `manual_action_required`: User action is required in the browser.
240
+ - `blocked`: Flow showed quota, safety, captcha, account, or unsupported UI state.
241
+ - `failed`: Script error or unrecoverable automation failure.
242
+
243
+ ## Safety Invariants
244
+
245
+ - Never store Google credentials.
246
+ - Never submit generation unless request `allowSpend` is true or `TAKOMI_FLOW_ALLOW_SPEND=true`.
247
+ - Never bypass Google account, captcha, safety, or quota controls.
248
+ - Always write a result file, even on failure.
249
+ - Always save downloads into the run directory unless the request explicitly overrides it.
250
+
251
+ ## Asset Catalog
252
+
253
+ Run:
254
+
255
+ ```bash
256
+ node scripts/takomi-flow.mjs assets --run <run.json|run-dir> --frames 4
257
+ ```
258
+
259
+ The command writes `assets.json` next to `run.json`. Video assets are probed with `ffprobe` when available, and review frames are extracted with `ffmpeg` when `--frames` is greater than zero.
260
+
261
+ ## Run Review
262
+
263
+ Run:
264
+
265
+ ```bash
266
+ node scripts/takomi-flow.mjs review --run <run.json|run-dir> --frames 4
267
+ ```
268
+
269
+ `review` is the preferred post-generation agent command. It inspects the run, catalogs downloaded assets, extracts review frames, writes a Markdown report, and returns next actions.
270
+
271
+ ## Collection
272
+
273
+ Run:
274
+
275
+ ```bash
276
+ node scripts/takomi-flow.mjs collect --run <run.json|run-dir> --target-dir <path> --frames 4 --include-frames
277
+ ```
278
+
279
+ `collect` reviews a run, copies assets/report/optional frames into a downstream target folder, and writes `takomi-flow-collection.json` as a manifest.
280
+
281
+ Agents can read `takomi-flow://schemas/collection` for the JSON Schema version of the collection manifest.
282
+
283
+ ## Markdown Reports
284
+
285
+ Run:
286
+
287
+ ```bash
288
+ node scripts/takomi-flow.mjs report --run <run.json|run-dir>
289
+ node scripts/takomi-flow.mjs report --output-dir <runs-dir> --limit 10
290
+ ```
291
+
292
+ The command writes `report.md` next to a single run, or `takomi-flow-report.md` in a runs directory. Reports include status, metadata paths, screenshots, assets, errors, manual actions, and catalog details when `assets.json` exists.
293
+
294
+ ## Diagnostics JSON
295
+
296
+ `doctor` returns:
297
+
298
+ ```json
299
+ {
300
+ "schemaVersion": 1,
301
+ "status": "ok",
302
+ "flowUrl": "https://labs.google/fx/tools/flow",
303
+ "profileDir": "C:/Users/johno/.takomi-flow/browser-profile",
304
+ "outputDir": "C:/Users/johno/.takomi-flow/runs",
305
+ "checks": [],
306
+ "recommendations": []
307
+ }
308
+ ```
309
+
310
+ ## Capabilities JSON
311
+
312
+ `capabilities` returns supported kinds, modes, variation limits, aspect ratios, output artifact names, safety invariants, and available commands. Agents should prefer this over hard-coded assumptions.
313
+
314
+ ## Observation JSON
315
+
316
+ `observe` writes a normal `run.json` and includes a `controls` object:
317
+
318
+ ```json
319
+ {
320
+ "controls": {
321
+ "buttons": [],
322
+ "inputs": [],
323
+ "links": []
324
+ }
325
+ }
326
+ ```
327
+
328
+ Use it to tune Flow selectors after Google changes the UI.
329
+
330
+ ## Self-Test JSON
331
+
332
+ `selftest` runs a deterministic no-spend verification pass:
333
+
334
+ - doctor diagnostics
335
+ - readiness audit
336
+ - capability loading
337
+ - example loading
338
+ - video/image template loading
339
+ - request preparation
340
+ - one-call workflow preparation/validation
341
+ - settings-plan metadata for requested Flow options
342
+ - request validation
343
+ - spend-guard expectation
344
+ - synthetic MP4 cataloging and frame extraction
345
+ - Markdown report generation
346
+ - one-call run review
347
+ - downstream asset collection
348
+
349
+ It writes artifacts under `<outputDir>/selftest`.