Compare commits

...
21 Commits
Author SHA1 Message Date
ketle-manandClaude Opus 5.5 0830a3f372 release: v0.10.0 — Game tab (experimental, needs ComfyUI-WFS-Games)
- Game tab: shown only when the ComfyUI-WFS-Games pack answers
  /wfs_games/manifest; games are ES modules mounted with
  mount(container, host) and report through runStart / stageClear /
  finish
- Result panel: one card per image (each stage clear, ending, game
  over, private photo), generated one at a time in the background while
  playing; prompts listed by kind, editable, Regenerate / Open in
  GenerateUI; the game's negative tags are added
- Settings: generation workflow (default ws_game_sdxl_t2i.json, now in
  workflows/), base / negative prompt, auto-generate per stage / ending
  / game over, difficulty, music, sound effects
- VRAM Management: prepareVramForGeneration({ quiet }) and
  comfyUI.generate(..., { quietVram }); no toast while the Game tab is
  open or for Game tab generations
- en / ja / zh strings, help page, README, DEVLOG, PLAN_GAME_TAB.md

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-17 17:21:03 +09:00
ketle-manandClaude Opus 5.5 086a767aff feat: experimental Game tab (needs the ComfyUI-WFS-Games pack)
- Game tab shows only when /wfs_games/manifest responds (pack installed);
  the help page is hidden the same way
- Games are loaded with dynamic import and mounted via mount(container, host);
  host passes language and play settings (difficulty, sound, bgm)
- On clear, the prompts returned by the game (style / heroine / scene /
  stage) are listed with their kind; the base prompt plus the checked
  prompts are written into the chosen workflow's positive prompt and
  generated with comfyUI.generate(); the game's negative tags are added
- Generation workflow is chosen in the Game settings
  (default ws_game_sdxl_t2i.json); no generation on game over
- Settings kept in localStorage wfm_game_settings (included in backups)
- en / ja / zh strings, help page, PLAN_GAME_TAB.md (plan, library
  choice, research on similar nodes, implementation notes)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-16 23:51:40 +09:00
ketle-manandClaude Opus 5.5 bf824a160a release: v0.9.10 — prompt translation API, backup of browser-side settings
Prompt translation API (for Comic Creator):
- POST /api/wfm/translate/prompt: prompt-aware translation on the server
  (prompt splitting moved from prompt-translate.js to translate_service.py;
  GenerateUI / Lab / Video Plan now use it)
- target_lang (PLaMo 3 Translate's 53 languages), protect_quotes for text
  drawn in the image, no more silent truncation of long text
- config: api version + languages; warmup ignore_enabled
- VRAM management keeps CPU-resident (size_vram == 0) Ollama models

Data management:
- JSON export and full backup now carry the localStorage settings
  (groups, badge palette, appearance, AI / decision / VRAM settings, presets)
- JSON export includes semantic_settings.json
- full backup skips the unused models/ folder and *.tmp files; semantic index
  (default on) and TagSpace cache (default off) are optional

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-15 15:53:04 +09:00
ketle-manandClaude Opus 5.5 6016ac1fcf docs: manual v0.9.9 (ja/en) — prompt translation
- New section 5-10: writing prompts in your own language (Prompt
  Translation) — setup, PLaMo 3 Translate sizes, GPU vs CPU-resident,
  the globe/Original buttons, automatic translation for Generate, Lab Run
  and Video Plan Run.
- Notes in 7-5 and 10-2 (PLaMo in the translate buttons), 11-4 (Video Plan
  globe button and the v0.9.9 Plan-values fix), 11-5 settings table, 12-3
  troubleshooting table, appendix glossary and links.
- Rebuilt the combined MD and ZIP for v0.9.9 (v0.9.6 files removed);
  README points to the v0.9.9 ZIPs and the v0.9.9 EPUB edition.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-15 11:56:50 +09:00
ketle-manandClaude Opus 5.5 b82e93a431 release: v0.9.9 — prompt translation (PLaMo 3 Translate), Video Plan values fix
Prompt translation (native language -> English), off by default:
- Settings -> Prompt Translation: Ollama model (PLaMo 3 Translate
  0.8B/2B/8B/31B presets with Download, or any Ollama model), source
  language, GPU or CPU-resident mode, and "translate automatically when
  running" for GenerateUI Generate, Lab Run and Video Plan Run.
- 🌐 / Original buttons on the GenerateUI prompts, the Lab prompt modal and
  the Video Plan block prompt. Only parts with non-ASCII letters are
  translated; prompt syntax (weights, <lora:>, wildcards, BREAK) is kept.
- PLaMo is driven with a raw PFML3 prompt on /api/generate; CPU mode keeps
  it loaded (num_gpu 0, keep_alive -1) and preloads it when GenerateUI opens.
- Lab/Video runs translate only what is sent; failures stop the batch.

Fixes:
- Translate buttons in the Prompt tab AI Assistant, AI TOOL tab and side
  panel A tab sent an instruction prompt, which PLaMo translates or treats
  as context; PLaMo models now get a [plamo-translate] system header.
- Video Plan wrote widgets_values only, but convertUiToApi() prefers the
  newer widgets_values_named copy, so the plan's prompt/duration/turbo
  values were replaced by the template's own (7 of 8 local templates).

Also adds the missing v0.9.8 DEVLOG entry and README badge.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-15 11:27:56 +09:00
ketle-manandClaude Fable 5 f39227a95b security: harden path validation (NT device forms, Eagle SVG path)
Follow-up to ea44cf4, from the automated security review of that commit:

- resolve_untrusted (py/config.py) now allowlists the accepted shapes:
  a drive-letter absolute path on Windows (or '/'-rooted elsewhere), or a
  UNC path under a UNC allowed root. Rooted NT device forms (\??\...,
  \.\...), root-relative (\foo), drive-relative (C:foo) and relative
  values are rejected before any filesystem access.
- eagle_routes _resolve_absolute_svg_path called os.path.isfile on the
  raw client path before the containment check — on Windows a UNC value
  makes that isfile() connect to the host with the account's credentials.
  The containment check (string-only abspath/commonpath) now runs first
  and isfile() only on paths under a ComfyUI-managed folder.
- eagle_routes _resolve_local_path rejects UNC/drive/absolute/.. subfolder
  values as strings before the join (commonpath raised ValueError for
  those instead of returning None).

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-11-14 13:29:16 +09:00
ketle-manandClaude Fable 5 ea44cf41fe security: validate client paths as strings before resolve()/exists()
On Windows, resolving (or exists()-checking) a UNC path (\host\share)
makes the server connect to that host with the account's credentials
before any containment check runs. Client-supplied paths were resolved
first and checked against their base folder afterwards.

Add is_safe_rel/resolve_untrusted (py/config.py): string-only processing
(normpath + unresolved relative_to) that rejects UNC, drive-relative and
embedded-NUL values before the first resolve(); a UNC path is allowed
only under an allowed root that is itself UNC (NAS gallery roots keep
working). Applied to:
- gmic result (routes/gmic_routes.py): also moved the raw os.path.exists
  after the check
- gallery service: all client path/folder entries now go through
  _resolve_untrusted before _check_path_allowed; .gltf external resource
  URIs must be relative (is_safe_rel) before joining
- semantic index/similar, tagger write_meta_to_file
- video media refs ({filename, subfolder}) and settings export/import
  (project media refs, backup-ZIP entry names): is_safe_rel before join
- wildcard _safe_path: also reject drive-relative segments (C:name)

The existing resolve()+relative_to containment checks are kept as defense
in depth. Same issue as ComfyUI-VRM-Pose-Studio 2be32ea.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-11-14 13:25:49 +09:00
ketle-manandClaude Opus 5.5 f6ce112ade release: v0.9.6 — MiniMax-H3-Image, Settings Switches column
- GenerateUI/Metadata/I tab: MiniMax H3 Image (T2I and Edit) support
- GenerateUI Settings tab: Switches column for true/false and two-choice
  on/off inputs, toggled instantly
- Fix ImageCompare failing validation (compare_view missing)
- Manual v0.9.6 (ja/en) and EPUB edition on Google Drive

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-12 18:28:10 +09:00
ketle-manandClaude Opus 5.5 48198eac2b docs: manual v0.9.6 (ja/en) and EPUB edition link
- Settings tab Switches column (5-4), MiniMax H3 Image and Compare Images
  fix (5-9), Apply exception for switches (12-3); target version v0.9.6
- Rebuilt combined MD/ZIP as v0.9.6 and removed the v0.9.5 files
- README: link to the EPUB edition with screenshots on Google Drive

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-12 18:22:33 +09:00
ketle-manandClaude Opus 5.5 f0ae2253f4 feat: GenerateUI Settings tab — Switches column for on/off values
- New third column lists every literal true/false input in the workflow
  and every two-choice enable/disable, on/off, true/false or yes/no combo
  (e.g. KSamplerAdvanced add_noise, DWPreprocessor detect_*), with node
  and input names; a click toggles it at once and syncs Raw JSON
- Combos are detected from per-type object_info and added once it loads;
  DynamicCombo selectors (TextGenerate sampling_mode) are left out
- Help (en/ja/zh) and DEVLOG updated

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-12 17:57:11 +09:00
ketle-manandClaude Opus 5.5 27066918ef feat: MiniMax-H3-Image support; fix ImageCompare compare_view missing
- GenerateUI/Metadata/I tab: support MiniMaxH3ImageConditioning (MiniMax
  H3 Image T2I and Edit templates), handled like PH3ImageConditioning
- Fix "required_input_missing" for ImageCompare: its display-only
  compare_view widget is not stored in widgets_values; send the same
  {"__value__": ["", ""]} the frontend does
- README and DEVLOG updated

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-12 17:47:14 +09:00
ketle-manandClaude Opus 5.5 0a98ff53a6 release: v0.9.5 — AI TOOL Chat skills v2, image check, Workflow Doctor, OCR
- Chat skills v2: metadata (output auto-check, tools, temperature, think,
  context), six versioned built-in skills, prompt action buttons, Markdown
- Image check with an Ollama vision decision model + refine loop
- Workflow Doctor, Storyboard to Lab, Agent Skills folder import
- TOOLS OCR (Ollama OCR models), collapsible Translation/Settings panes
- Fix: dead legacy top-menu code with deprecated imports removed (#3)
- Help, manual v0.9.5, TagSpace screenshot, registry-sized icon

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-11 16:37:26 +09:00
ketle-manandClaude Opus 5.5 720d24b2ab docs: add TagSpace screenshot to README
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-11 16:35:27 +09:00
ketle-manandClaude Opus 5.5 62b074e352 docs: manual v0.9.5 (ja/en) and registry-sized thumbnail
- Manual (text-only edition): Chapter 10 gains 10-5 Skills, 10-6 image
  check, 10-7 Workflow Doctor, 10-8 OCR, 10-9 making/importing skills;
  collapsible panes and TOOLS send buttons in 10-2; Lab storyboard loading
  and KSampler cell display in 5-7; troubleshooting and glossary entries
- Catch up v0.9.2-v0.9.4: Gallery 3D models (8-8), P-H3 Image (5-9),
  Image Edit draw palette / eyedropper / shortcuts (11-3, appendix),
  Selector event loop freeze and corrupted-image fix (Chapter 12)
- Combined MD / README / ZIP rebuilt as v0.9.5; v0.9.1 files removed;
  README manual links updated
- docs/thumb.png: new artwork resized to 800x400 (registry icon limit)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-11 16:32:10 +09:00
ketle-manandClaude Opus 5.5 7a571b98c7 fix: remove dead legacy top-menu button code using deprecated imports
The ComfyButton / ComfyButtonGroup imports from
/scripts/ui/components/button.js and buttonGroup.js lived in the legacy
top-menu path for frontends older than 1.33.9. That path has not been
called since the extension switched to the actionBarButtons API
(a6f45ef), so the four functions and their constants were dead code.
Removed them instead of migrating to window.comfyAPI; the menu buttons are
still provided through actionBarButtons. Also removed the two stale .bak
copies in web/comfyui that shipped with the same legacy imports.

Verified on ComfyUI 0.45.0 / frontend 1.58.5: the extension registers and
its toolbar buttons appear, no console errors.

Closes #3

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-11 16:31:46 +09:00
ketle-manandClaude Opus 5.5 059cb766fc feat: AI TOOL — collapsible Translation/Settings panes, TOOLS OCR, help rework
- Translation and Settings panes collapse to a thin strip (arrow in header,
  click the strip to reopen); state kept in localStorage
- TOOLS > "OCR (extract text)": Ollama OCR models (LightOnOCR-3 default,
  PaddleOCR-VL, GLM-OCR, DeepSeek-OCR), ported from Comic Creator's OCR tab:
  1600px white-background JPEG, temp 0, HTTP 500 retry, grayscale retry on
  empty/looping output, per-model prompts; optional text-position overlay
  (LightOnOCR / DeepSeek-OCR) with click-to-select line
- "To Translation" / "To Chat" buttons for any TOOLS result
- AI TOOL help regrouped into 12 cards (skill options, Doctor/Storyboard/
  folders, image check, OCR as their own cards; built-in list updated),
  Lab help gains the Storyboard entry (en/ja/zh)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-11 13:13:38 +09:00
ketle-manandClaude Opus 5.5 4cd9b0d033 feat: AI TOOL Chat Phase 3 — Workflow Doctor, Storyboard to Lab, folder skills, Markdown
- Workflow Doctor skill: context [workflow-detail, logs] injects checked facts
  (not-installed node types, values not in ComfyUI's lists with closest names,
  broken links, unconnected core-type required inputs, last /history error,
  latest ComfyUI log error block) — no false positives on 77 local workflows
- Storyboard to Lab skill: ```labplan block -> Lab plan (one scene per
  iteration, T2I mode, fixed seed) via "Open in Lab" (lab-tab openLabPlanData)
- Agent Skills folder import (.zip with SKILL.md or single .md): text files
  only, scripts never extracted, zip-slip/size checks; reference files are
  read on demand through a read_skill_file tool (progressive disclosure)
- Dependency-free Markdown rendering for assistant replies (escape first)
- Workflow summary no longer includes the current prompt text unless the user
  refers to it or the skill sets context: [current-prompt] (small models copied
  the old negative into new prompts even when told not to)
- Fix: Lab KSampler cell showed "(workflow default)" when only seed/sampler/
  scheduler were set
- Built-in skill updates (Enhancer/Image to Prompt v2, Skill Creator v3),
  help (en/ja/zh)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-11 12:48:03 +09:00
ketle-manandClaude Opus 5.5 8437df4881 feat: AI TOOL Chat image check with a vision decision model + refine loop
- "Check images" toggle: the chat LLM turns the request into yes/no checks
  (JSON schema), an Ollama decision model with image input (d3:4b default)
  judges the generated image with probabilities (pass >= 0.85, uncertain
  0.3-0.85) and shows a result card with overall quality
- Swap-check items (expect: no) catch attribute binding mistakes the judge
  otherwise passes at 0.70-0.79 (measured)
- "Fix missing items and regenerate": only unmet items go back to the chat
  model, which rewrites the prompt; 0-3 automatic rounds in settings
- SVG visual check: render to image, judge "recognizable as request" + parts
- New built-in skill: Image to Prompt
- Chat session state shared at module level, busy guard on send
- Fix: prompt action row no longer shares .wfm-ai-chat-actions with the
  send-button row
- Help (en/ja/zh) updated

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-11 12:14:09 +09:00
ketle-manandClaude Opus 5.5 4eaf71db8c feat: AI TOOL Chat skills v2 — metadata, versioned built-ins, prompt actions
- Built-in skills moved to py/services/builtin_skills/*.md with wfs-version;
  untouched copies auto-upgrade, edited ones keep and show a restore button
  (state in ai_skills/.builtin_state.json, legacy v0.3.79 copies detected by hash)
- Frontmatter metadata: output (prompt/svg auto-check + one retry), tools,
  temperature, think, context: [workflow] (GenerateUI workflow summary)
- ```prompt block buttons: Apply to GenerateUI / Generate / Copy
- New built-in skill: T2I Prompt Enhancer (NATURAL / TAG / MIXED by model)
- SVG Icon Generator v2 (style presets, self-check), Skill Creator v2
- SVG validation (well-formed, viewBox/xmlns, forbidden content incl. root attrs)
- Help (en/ja/zh) updated

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-11 11:52:11 +09:00
ketle-manandClaude Opus 5.5 4458a3d6e3 release: v0.9.4 — Gallery 3D models, P-H3 Image, TextGenerate fix
- Gallery: browse GLB, glTF, VRM, PLY (mesh, point cloud, Gaussian splat)
  and SPZ with a built-in three.js viewer; thumbnails are rendered in the
  browser and stored on the server
- Read workflows saved by SaveGLB from asset.extras
- GenerateUI/Metadata/I tab: support PH3ImageConditioning (P-H3 Image
  edit and T2I templates)
- Fix TextGenerate-family widget values shifted by one when the prompt is
  linked (also affected Krea-2, Ernie and LTX-2.5 templates)
- Help (en/ja/zh), README, and DEVLOG updated

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-07 11:53:07 +09:00
ketle-manandClaude Opus 5.5 54940ccf87 release: v0.9.3 — Image Edit: Draw palette, shortcuts, eyedropper
- Color palette on the Draw tool's second row: Color 1/2, 20 basic colors,
  20 custom slots; registered colors are saved in the browser
- Draw shortcuts: D/E mode, X switch color, [ ] brush size, B brush picker
- Eyedropper next to Color picks a color from the canvas
- Default brush color is now black; the selected color carries over to
  new documents
- Help (en/ja/zh), README, and DEVLOG updated

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-05 11:49:53 +09:00
103 changed files with 18950 additions and 1964 deletions
+8
View File
@@ -2,6 +2,14 @@
Condensed version-by-version index of DEVLOG.md (each line: version + one-line summary of what changed and why). Full rationale, code details, and "How to apply" lessons live in the excluded DEVLOG.md itself; this index exists so graphify can extract a queryable semantic node per release without feeding the full log to the local Ollama model. Regenerate with `python tools/generate_doc_index.py devlog` whenever DEVLOG.md changes.
- **v0.10.0(2026-11-17)** — Game タブ(実験的機能・別パッケージ ComfyUI-WFS-Games が必要)
- **v0.9.10(2026-11-15)** — プロンプト翻訳API(Comic Creator から使うための整備)
- **v0.9.9(2026-11-15)** — プロンプト翻訳(自国語 → 英語、PLaMo 3 Translate)
- **v0.9.8(2026-11-14)** — セキュリティ: クライアントから受け取るパスを解決前に検証
- **v0.9.6(2026-11-12)** — マニュアル v0.9.6版(ja/en)
- **v0.9.5(2026-11-11)** — AI TOOL Chat: スキル v2(metadata・同梱スキルの版管理・プロンプトボタン)
- **v0.9.4(2026-11-07)** — Gallery: 3Dモデル対応(GLB / glTF / VRM / PLY / SPZ)
- **v0.9.3(2026-11-05)** — Image Edit: Drawツールのカラーパレット・ショートカット・スポイト(Comic Creator v1.67.0 から移植)
- **v0.9.2(2026-11-03)** — Selectorイベントループ有効時に画像が壊れて届く不具合を修正
- **v0.9.1(2026-11-03)** — TagSpace: 選んだタグだけを追加 / タグのカッコをエスケープして追加
- **v0.9.0(2026-11-03)** — マニュアル(画像なし配布版)を v0.9.0 に改訂
+194
View File
@@ -2,6 +2,200 @@
---
## v0.10.0(2026-11-17)
### Game タブ(実験的機能・別パッケージ ComfyUI-WFS-Games が必要)
- ゲームをクリアした結果で画像を生成するタブ。ゲーム本体は別パッケージ [ComfyUI-WFS-Games](https://github.com/ketle-man/ComfyUI-WFS-Games)(Phaser 4.2.1 同梱、ノードなし)で配布し、`/wfs_games/manifest` が応答したときだけタブとヘルプページを表示する(Mask Editor One 連携と同じ「ルート疎通」方式)。未インストール環境では従来どおり。
- ゲームは manifest の `entry`(同一オリジン `/wfs_games/static/` 配下のみ許可)を動的 import し `mount(container, host)` で起動。host は言語・プレイ設定(難易度・BGM・効果音)と `runStart()` / `stageClear(result)` / `finish(result)` を渡す。ゲームは ComfyUI を直接操作しない。
- 結果パネルは「画像1枚 = カード1枚」。ステージクリア・エンディング・ゲームオーバーごとにカードを追加し、生成はキューで1枚ずつ順番に(プレイは止めない)。カードではゲームから渡されたプロンプトを種類(画風/ヒロイン/シーン/ステージ)付きで確認・除外・編集でき、「再生成」「GenerateUIで開く」。ゲームのネガティブはワークフローのネガティブ(または設定値)に足す。
- 設定(localStorage `wfm_game_settings`、バックアップ対象): 生成ワークフロー(既定 `ws_game_sdxl_t2i.json`)、ベースプロンプト、ネガティブ、ステージクリアごと/エンディング/ゲームオーバーの自動生成、難易度・BGM・効果音。旧既定のベースプロンプトは自動で置き換え。
- サンプルワークフロー `workflows/ws_game_sdxl_t2i.json`(SDXL T2I、1216x832、出力 `WFS_Game/`)を同梱。Game タブの既定。
- 生成は既存の `convertUiToApi` → `analyzeWorkflow` → ポジティブノードへ書き込み → `_expandWildcardsInWorkflow` → `comfyUI.generate` を再利用。
- VRAM 調整: `prepareVramForGeneration({ quiet })` と `comfyUI.generate(..., { quietVram })` を追加。Game タブからの生成と Game タブ表示中はトーストを出さずコンソールにだけ出す(ゲーム画面を隠さない)。
- 第一弾「Star Formation」(パック側): 80年代(アーケード/MSX2/PC-8801)風の縦シューティング。全5ステージ・ステージごとのボス(WARNING とボス BGM)、ナビゲーターのリナとの ADV 風会話、PSG 風のオリジナル BGM、ドット絵・DotGothic16・走査線。ステージクリアで勝利の記念カット、各ステージ5個のハートを全部取るとプライベート写真(ステージごとに露出が増え、上限は水着。ネガティブで制限)、全クリアでエンディング、ゲームオーバーで敗北シーンを生成。
- en/ja/zh の文言とヘルプページ、企画書 `PLAN_GAME_TAB.md`(企画・ライブラリ選定・類似ノード調査・実装記録)。
- 実機確認: Playwright で検出/非表示、操作・一時停止、各ボスの動き、アイテム、ステージごと・エンディング・ゲームオーバー・プライベート写真の実生成、VRAM 調整でモデルがアンロードされてもトーストが出ないこと。
---
## v0.9.10(2026-11-15)
### プロンプト翻訳API(Comic Creator から使うための整備)
- `POST /api/wfm/translate/prompt {text|texts, target_lang?, source_lang?, protect_quotes?, model?}` を追加。記法を残す分割(`split_prompt` / `_rebuild`)をブラウザ側から `translate_service.py` へ移し、GenerateUI・Lab・Video Plan の🌐と自動翻訳もこの API を使うように切り替え(分割の実装を1か所に)。Lab は1回のリクエストにまとめて送る。🌐で変化が無いとき(非ASCIIの `<lora:...>` 名だけ等)は「翻訳する部分がありません」を表示。旧 `POST /api/wfm/translate`(丸ごと翻訳)は互換のため残す。
- 翻訳先 `target_lang`: PLaMo 3 Translate の53言語(`zh`→`zh-hans`、`zh-tw`→`zh-hant` 等の別名)。キャッシュキーに翻訳先を追加。PLaMo 以外のモデルの指示文も言語名に追従。翻訳元も同じ一覧で検証。
- `protect_quotes`: 「」『』“”"" の中身を `『QT0』` のようなトークンにして文ごと訳し、元の文字に戻す(画像に描く文字用。トークンが消えたら引用の前後を別々に訳す)。既定オフ(GenerateUI も従来どおり)。例: 「看板に『営業中』と書かれた喫茶店」→ `A coffee shop with a sign that reads "営業中"`。
- 長文の無言切り捨てを廃止: 1回のモデル呼び出しは最大1000文字(改行→文末で分割して連結)。1リクエスト合計3万文字超・1文1000文字超は 400、出力が `num_predict` に達した(`done_reason == "length"`)ら 502。
- `GET /api/wfm/translate/config` に `api: 1`(API の版)と `languages` を追加。`POST /api/wfm/translate/warmup` は `{"ignore_enabled": true}` で WFS のオン/オフに関係なく読み込む(独自のオン/オフを持つクライアント用)。サーバーは `prompt_translate_enabled` を見ない方針を README「Prompt Translation API」節に明記。
- VRAM調整(毎回・「今すぐすべてアンロード」・Ollama のアンロードボタン)で `size_vram == 0` の CPU 常駐モデル(翻訳の CPU モード等)を外さないように。応答に `kept_cpu`、トーストに「CPU常駐のため残しました」(3言語)。
- 説明文の修正: CPU 常駐の RAM「約2GB」→約2.7GB、「生成UIを開いたとき」→「生成UIにワークフローを読み込んだとき」(設定・ヘルプ・README)。
- 実機確認: HTTP(記法保持、zh、protect_quotes、各エラー、1619文字の長文分割、旧API、warmup)、VRAM「すべてアンロード」で GPU の 0.8B だけ外れ CPU 常駐の 2B が残る、ブラウザで🌐→翻訳→原文復元と Lab の一括翻訳。
### 設定のデータ管理の監査
- ブラウザ(localStorage)に保存している設定が、どちらのバックアップにも入っていなかった(ワークフロー/プロンプトプリセットのグループ、モデルバッジの配色、外観、AI TOOL・Prompt・Tagger の接続設定、意思決定モデル・VRAM調整の設定、Latent プリセット、Draw パレット等)。JSON エクスポート(`__browser_storage`)とフルバックアップ(`_browser_storage.json`、データフォルダには展開しない)の両方に同梱し、復元時にブラウザへ書き戻して「ページを再読み込み」ボタンを表示。対象は `wfm_*` と `ie_draw_palette_v1`(一時キー `wfm_pending_workflow` / `wfm_library_filter_request` は除外)、規則はサーバー `_clean_browser_storage` とクライアントで共通。
- JSON エクスポートに `semantic_settings.json`(Gallery セマンティック検索の設定)を追加。
- フルバックアップから `models/`(v0.8.2〜v0.8.13 の ONNX EmbeddingGemma の残骸、約300MB、v0.8.14 の Ollama 化以降は未使用)と `*.tmp`(アトミック書き込みの途中ファイル)を除外。チェックボックス「Gallery セマンティック検索のインデックス」(既定オン、作り直すと全画像の埋め込み直し=Gemini では API 費用)と「TagSpace のキャッシュ」(既定オフ、作り直せる)を追加。`export-full` は POST(JSON)にも対応(GET は互換で残す)。実環境で約700MB→108.7MB。
- 説明文・ヘルプ(dataManagementHint / fullBackupHint / helpSettings8・15・16、3言語+index.html)と README を更新。
- 実機確認: ボタン操作で JSON・ZIP のエクスポート内容を検査、ブラウザ設定だけを入れた JSON・ZIP のインポートで書き戻しと不正キーの除外、データファイルが書き換わらないことを確認。
---
## v0.9.9(2026-11-15)
### プロンプト翻訳(自国語 → 英語、PLaMo 3 Translate)
- 設定タブに「プロンプト翻訳」セクションを新設(既定オフ)。A1111 の prompt translator 拡張と同じく、英数字以外の文字を含む部分だけを翻訳し、カンマ・`(語句:1.2)`・`[ ]`・`{a|b}`・`<lora:...>`・`__wildcard__`・`embedding:`・`BREAK`/`AND` は保護する(`static/js/prompt-translate.js` の `splitPrompt`)。
- 🌐ボタン(+「原文」ボタン、Ctrl+Z も可)を GenerateUI の Positive/Negative、Lab プロンプトモーダル、Video Plan のブロックプロンプトに追加。
- モデルは Ollama 経由。PLaMo は `/api/generate` に `raw:true` で PFML3 プロンプトを直接送る(モデルカード推奨、stop `<|plamo:tag|>`/`<|plamo:bos|>`)。PLaMo 以外の Ollama モデルは `/api/chat` +翻訳指示。PLaMo の4サイズはプリセットとして表示し、未取得なら「ダウンロード」(`/api/wfm/translate/pull`、プリセットのみ許可)。
- 実行場所: GPU(1語句約0.1秒、翻訳後アンロード可)/CPU常駐(`num_gpu:0`+`keep_alive:-1`、1語句約0.3秒、VRAM 0、GenerateUI表示時に `/warmup` で裏読み込み、デバイス・モデル切替や無効化時は `/unload`)。実測でコールド約4秒の大半は Ollama ランナー起動(CPUでも4.4秒)だったため、常駐でほぼ解消。
- 「実行時に自動で翻訳する」: GenerateUI Generate(欄の文を置き換え)/Lab Run(各回のAPIワークフローのコピーを翻訳)/Video Plan Run(送信するプロンプトだけ翻訳)。Lab/Video はプランを原文のまま残す。失敗時は生成せず中断し、理由を進行状況欄に残す(終了トーストが上書きするため)。
- サーバー側に翻訳結果の上限付きキャッシュ(1024件)。設定は `settings.json` の `prompt_translate_*`。
- 実機確認: Z-Image で Generate 時自動翻訳と Lab Run(2枚)を実生成、Video Plan Run は `/prompt` 送信をブラウザで横取りして英訳の送信を確認。
### 修正: PLaMo を選んだときの各翻訳ボタン
- Prompt タブ AI アシスタント・AI TOOL タブ・サイドパネル A タブの翻訳は、指示文+本文(または指示の system メッセージ)で送っていたため、PLaMo では指示文まで翻訳される/日本語⇔英語の自動切替になり ZH→EN・EN→ZH・自由入力が誤った言語で出ていた。PLaMo 系モデルのときは先頭 system に `[plamo-translate]` と `target_lang`/`source_lang` を書き本文だけを送る(モデルカードの Ollama/LM Studio 向け方式)。言語名(French・フランス語・français 等)を PLaMo の言語コードに変換する `static/js/plamo-chat.js` を追加(サイドパネルは import できないためインラインコピー)。
- Prompt タブ AI アシスタントに応答待ちの表示を追加(初回はモデル読み込みで十数秒かかることがある)。
### 修正: Video Plan のプロンプト等がテンプレートの値のまま送られていた
- 新しいフロントエンドで保存したワークフローは、サブグラフのインスタンスノードに名前付きの値のコピー `widgets_values_named` を持ち、`convertUiToApi()` はそちらを優先する。`applyBlockToWorkflow` は `widgets_values` だけを書いていたため、Plan のプロンプト・Duration・Turbo 等が無視されていた(手元の動画テンプレート8本中7本)。書き込み後に `widgets_values_named` へ反映する `_syncNamedWidgetValues` を追加。修正後は12本中11本で反映(残る `minimaax_h3_fast.json` はプロンプトを LiveChatStream から配線で受けるため対象外)。
### ヘルプ
- 設定タブ(helpSettings26)と GenerateUI(helpGen33)にプロンプト翻訳を追加(en/ja/zh)。
### マニュアル v0.9.9版(ja/en)
- 新節 5-10「日本語のままプロンプトを書く(プロンプト翻訳)」(準備・モデルの大きさ・GPU/CPU常駐・🌐と原文・実行時の自動翻訳・Lab/Video Plan)。7-5・10-2 に PLaMo の注記、11-4 に Video Plan の🌐と v0.9.9 修正の注意、11-5 の表・12-3 のトラブル表・付録の用語集と参考リンクを追記。対象バージョンを v0.9.9 に更新し、全章MD・ZIPを `manual/rebuild_repo_edition.py` で再生成(v0.9.6版は削除)。
- EPUB(画像付き、75枚=新規3枚: 設定のプロンプト翻訳・生成UIで翻訳後・Labモーダル)を Google ドライブで公開。
## v0.9.8(2026-11-14)
### セキュリティ: クライアントから受け取るパスを解決前に検証
- `py/config.py` に `is_safe_rel` / `resolve_untrusted` を追加。文字列だけで正規化・配下チェックし、UNC・ドライブ相対・NUL 混入を最初の `resolve()`/`exists()` より前に拒否(Windows では UNC を解決した時点でアカウント資格情報付きで相手ホストへ接続するため)。UNC は許可ルート自体が UNC の場合のみ許可。G'MIC 結果・Gallery のパス受け取りに適用(ea44cf4)。
- 追加の強化: 受け付ける形をドライブレター絶対パス(Windows)または許可された UNC に限定し、NT デバイス形式(`\??\...`、`\.\...`)等を拒否。Eagle の SVG パスで配下チェック前に `os.path.isfile` していた箇所を修正(f39227a)。
- ※v0.9.8 はリリース時に README バッジと DEVLOG の更新が漏れていたため、v0.9.9 で追記。
## v0.9.6(2026-11-12)
### マニュアル v0.9.6版(ja/en)
- 5-4 Settingsタブを3列(スイッチ列の説明を追加)、5-9 対応表に MiniMax H3 Image と Compare Images 修正の注記、12-3 の Apply 注意にスイッチ列の例外を追記。対象バージョンを v0.9.6 に更新し、全章MD・ZIPを `manual/rebuild_repo_edition.py` で再生成(v0.9.5版は削除)。
### GenerateUI Settingsタブ: スイッチ列
- KSampler・Latent Imageの右に3列目「スイッチ」を追加。APIワークフロー内のリテラルな true/false 入力(ComfySwitchNode の switch、PrimitiveBoolean の value、TextGenerateV2 の thinking など)をノード名・入力名付きで一覧し、チェックボックスで即時切り替え(Apply不要、Raw JSONへ同期)。リンクされた入力は配列なので対象外で、配線元のPrimitiveBooleanが出る。
- 選択肢がちょうど enable/disable・enabled/disabled・on/off・true/false・yes/no の2択のCOMBO(KSamplerAdvanced add_noise、DWPreprocessor detect_* など)も対象。object_info を型別取得してから追加描画し、値はそのノード自身の綴りの文字列で書き戻す。DynamicCombo(TextGenerate の sampling_mode)は子入力が変わるため対象外。
- 保存済みワークフロー347本(App形式5本は読込対象外)をブラウザで順に読み込み、128本・426項目でオン→オフ→元に戻すの往復と Raw JSON 同期を自動検証、失敗・コンソールエラー0。
- MiniMax H3 Image のT2I(サブグラフ内のプロンプト強化スイッチ)とEdit(PrimitiveBoolean「Enable PE?」)でブラウザ実操作を確認。
### MiniMax-H3-Image対応
- `MiniMaxH3ImageConditioning`(Comfy-Org の MiniMax H3 Image T2I/Edit テンプレート)をGenerateUI/Metadata/Iタブに追加。入力は `prompt`/`width`/`height`/`images.image_N` で `PH3ImageConditioning` と同形のため同じ扱い(negativeなし、promptはPreviewAny→プロンプト強化スイッチ経由で配線元のユーザープロンプトをpositiveに)。width/height=0は image_1 のサイズ、画像なしなら2048。
- 修正前はプロンプト欄が空で、Metadataタブもプロンプトを読めなかった。T2I(プロンプト強化オフ、2048x2048)とEdit(プロンプト強化オン、2720x1536)で実生成確認。
### 修正: ImageCompareノードを含むワークフローで検証エラー
- `ImageCompare` の `compare_view`(表示専用の socketless ウィジェット、`widgets_values` に保存されない)がAPI変換で欠落し、`required_input_missing` になっていた。フロントエンドと同じ `{"__value__": ["", ""]}` を補う(`_DISPLAY_WIDGET_DEFAULTS`)。MiniMax H3 Image Edit テンプレートで発覚。
## v0.9.5(2026-11-11)
### AI TOOL Chat: スキル v2(metadata・同梱スキルの版管理・プロンプトボタン)
- スキルの frontmatter に `metadata:` を追加(`output` prompt/svg の自動チェック+1回だけ再依頼、`tools`、`temperature`、`think`、`context`: workflow / current-prompt / workflow-detail / logs)。`name`/`description` は Agent Skills(SKILL.md)と互換のまま。
- 同梱スキルを `py/services/builtin_skills/*.md` に分離し `wfs-version` で版管理。`ai_skills/.builtin_state.json` に版とハッシュを記録し、未編集なら自動更新、編集済みなら残して ↻ ボタンを表示。v0.3.79 版の未編集コピーはハッシュで判別して更新。
- 同梱スキル6本: T2I Prompt Enhancer / Image to Prompt / Storyboard to Lab / Workflow Doctor(新規)、SVG Icon Generator v2、Skill Creator v3。
- ```prompt ブロックに「GenerateUIに反映」「このプロンプトで生成」「コピー」。応答は依存なしの Markdown 表示(先に全体をエスケープ)。
- ワークフロー要約から「今のプロンプト」を既定で外した。「参考のみ・写すな」と書いても gemma4 e4b は 6/6 回で古いネガティブ(pink wear)を新しいプロンプトへ混ぜたため。発言が今のプロンプトに触れたときと `context: [current-prompt]` のときだけ渡す。
### AI TOOL Chat: 生成画像のチェックと修正ループ(意思決定モデル)
- 新規 `static/js/chat-image-check.js`。チャットモデルが依頼を3〜8個の yes/no 項目にし(JSON Schema)、Ollama の画像対応意思決定モデル(既定 d3:4b)が確率で判定。✔≥0.85 / ? 0.3〜0.85 / ✘<0.3。
- 実測: 生成VLM(gemma4 uncensored e4b)は「剣を持っている」を誤って合格(7/8)。d3:4b・clef-flash・clef は引っかけ含む18/18正解。属性の取り違え(帽子が女の子なのに「男の子が帽子」0.70〜0.79)があるため合格ラインを0.85にし、`expect: no` の逆向き確認項目を加えた。
- 「足りない点を直して再生成」で未達項目だけを伝えて書き直し・再生成。自動修正0〜3回。SVG も描画して部位ごとにチェック。
### AI TOOL Chat: Workflow Doctor / Storyboard to Lab / フォルダ形式スキル
- 新規 `static/js/chat-context.js`: 未インストールのノード、ComfyUI の一覧に無いファイル・選択肢(近い名前の候補)、切れたリンク、未接続のコア型必須入力、`/history` の直近エラー、ComfyUI ログの最新エラー部分を文脈に入れる。手元77ワークフローで誤検出0(ウィジェット系の必須入力チェックは1/3で誤検出したため除外)。
- ```labplan → Lab プラン(1シーン=1イテレーション、T2I、seed 固定)。`lab-tab.js` に `openLabPlanData()`。
- スキルの zip 取り込み(SKILL.md 必須、テキストのみ、スクリプトは展開しない、zip-slip とサイズの検査)。参照ファイルは `read_skill_file` ツールで必要時に読む。
- Lab: KSampler 列が seed / sampler / scheduler だけ指定のとき「ワークフローの設定のまま」と表示していた不具合を修正。
### AI TOOL: OCR・ペインの折りたたみ
- 新規 `static/js/ocr-tools.js`(Comic Creator の OCR タブから汎用部分を移植)。実測(日英混在・縦書きあり): LightOnOCR-3 4b 1.1秒(位置付き7.9秒)100%、PaddleOCR-VL-manga 3.9秒100%、unlimited-ocr 14秒100%、PaddleOCR-VL 1.6 / GLM-OCR は縦書きを読み落とし94%。
- 位置の表示(LightOnOCR / DeepSeek-OCR)、枠クリックで行選択、「翻訳へ送る」「Chatへ送る」。Translation / Settings ペインを細い帯にたためる。
### 修正: 非推奨の import(GitHub issue #3)
- `top_menu_extension.js` の `/scripts/ui/components/button.js`・`buttonGroup.js` の import は、a6f45ef で actionBarButtons に移行して以来呼ばれていない旧メニュー用コードだった。`window.comfyAPI` への置き換えではなく削除。`web/comfyui/*.bak` も削除。
### ドキュメント
- ヘルプ(AI TOOL を12カードに再編、Lab に Storyboard)、マニュアル v0.9.5(v0.9.2〜v0.9.4 の未反映分も追記)、README の TagSpace スクリーンショット、Registry アイコン用に `docs/thumb.png` を 800x400 に縮小。
**検証**: 各機能を ComfyUI_5(:8189)で実機確認(Chrome / Playwright)。単体テスト: スキルサービス35件、JS(解析・チェック・Markdown・OCR・文脈)約50件。
**未確認**: サイドパネル(A タブ)はスキル本文のみ対応(metadata・ボタン・チェックは SPA のみ)。判定の閾値は画像約5枚から決めた値。OpenAI 互換バックエンドでの `read_skill_file` 往復。
---
## v0.9.4(2026-11-07)
### Gallery: 3Dモデル対応(GLB / glTF / VRM / PLY / SPZ)
- 新規 `static/js/gallery-3d-viewer.js`: three.jsのビューア。詳細パネル・ライトボックス・比較で開き、枠がDOMから外れると自分で破棄する(WebGLコンテキストを解放)。
- 新規 `static/lib/three-viewer/`: three 0.187 / @pixiv/three-vrm 3.5.5 / @sparkjsdev/spark 2.4.0 のバンドル。Spark(2.8MB)は別チャンクで、スプラットを開くときだけ読む。再ビルド手順は同フォルダのREADME.txt。
- サムネイル: サーバーに3Dレンダラーが無いため、`/thumb` の404を合図にブラウザが描画し `/wfm/gallery/image/thumb3d` へ保存する。1件ずつ処理し、128MB超は開いたときに保存する。
- `.gltf` の外部ファイルは `/wfm/gallery/model3d/asset` で配信する(.bin/画像のみ、許可ルート内のみ)。
- PLYは `f_dc_0`/`scale_0` の有無でスプラットを判定する。`double` 属性はFloat64ArrayになりWebGLが拒否するのでFloat32へ変換する。
- `asset.extras` からSaveGLBのprompt/workflowを読む(GLBはJSONチャンクのみ読む)。
- 3DファイルはImage Edit / GenerateUI / Send to LI node / Tagger / Feederへ送れないようにした。
### P-H3 Image対応
- `PH3ImageConditioning` をGenerateUI/Metadata/Iタブに追加(`TextEncodeFibo2` と同じ扱い、negativeなし)。`_unifyPromptEnhancerText` は `TextGenerateV2` も対象にした。
### 修正: TextGenerate系の値ずれ
- `_normalizeLinkedWidgetValues` が、リンク済みpromptの空枠を持つ形式を「枠なし形式」と誤判定していた。値が1つずれても、無効なDynamicComboキーがoptions[0]へフォールバックして枠数が偶然一致するため。Krea-2 / Ernie / LTX-2.5 などでも `sampling_mode:2048` のようにずれていた。選択キーの有効性も判定に加えた。
**検証**: 3Dは実サンプルで描画・自動サムネイル・詳細・拡大・破棄・送信ガード(Image Editボタン)を確認(SPZとスプラットPLYは自作サンプル)。パストラバーサルは全て404。変換は手元の640ワークフローを修正前後で比較し、差分21件は全てTextGenerate系。うち5種類は `widgets_values_named` 等で正しい値と確認した。P-H3は編集(1024x1024、約60秒)とT2I(3360x2496、約40秒)をGenerateUIから実生成(RTX 4070 12GB、モデルロード済み)。
**未確認**: 比較表示、テーブル表示のサムネイル、128MB超のファイル、実データのスプラット、サイドパネルIタブのP-H3、Draco/Meshopt圧縮のモデル。
**補足**: KTX2圧縮テクスチャは未対応。`.gltf` を移動・削除しても外部ファイルは追従しない。GenerateUIにプロンプト強化のオン/オフ切り替えは無い。
---
## v0.9.3(2026-11-05)
### Image Edit: Drawツールのカラーパレット・ショートカット・スポイト(Comic Creator v1.67.0 から移植)
- 新規 `static/js/image-edit/DrawPalette.js`: Drawツールの2段目(`ie-tool-options`)に色1/色2、基本色20色、カスタム色20枠を表示する。右クリックで現在の色の登録・色の編集・削除(カスタム色)・初期の色に戻す(変更済みの基本色)。保存先は localStorage `ie_draw_palette_v1`。
- `image-edit-tab.js`: 色の変更を `_setDrawColor` に集約し、モードは `_setDrawMode`、サイズは `_setDrawBrushSize` / `_stepDrawBrushSize` に分離。
- ショートカット(Draw中のみ): `D` Draw / `E` Erase / `X` 色1・色2切替 / `[` `]` サイズ増減(1〜10pxは1、10〜50pxは5、50〜200pxは10刻み)/ `B` ブラシ選択の開閉。ブラシ選択の表示中は D/E/X/[/] を無効にし、Escで閉じる。他のツールからのBはこれまでどおりDrawへの切り替え。
- スポイト: WFSのDrawツールには無かったためCC版から追加。右パネルのColorの隣のボタンからキャンバスの色を拾う。Esc・再クリック・ツール切替・キャンバス外クリック・Closeで解除。
- ブラシの初期色を赤から黒に変更(色1/色2 = 黒/白)。
**CC版との違い**
- 色の引き継ぎは、Drawツールの表示時ではなく `_initCanvases` で `DrawTool` を作り直す時点で行う。
- スポイトは `ie-canvas-draw` から色を読むため、アクティブレイヤーのみの表示なら合成し直してから読む。
- 右クリックメニューを開いたままツールを切り替えても残らないよう、`_renderToolOptions` で閉じる。
**検証(Playwright、ComfyUI :8189)**: パレットからの描画色、登録と再読み込み後の保持、重複登録の通知、右クリックメニュー、基本色の復元、Color入力との連動、各ショートカット、入力欄やCtrl/Alt同時押しで反応しないこと、サイズの刻み、ブラシ選択の開閉、ブラシ未登録時の通知、Newでの色の引き継ぎ、スポイトの取得と解除、Undo履歴が増えないこと、別レイヤーの色の取得を確認。コンソールエラーなし。
**未確認**: 「色を編集…」で開くブラウザ標準のカラーピッカーの表示と、日本語キーボードでの `[` `]` の実打鍵。
**補足**: 透明部分をスポイトすると黒を拾う(CCと同じ)。描いた線から拾うと値が1ずれることがある。READMEのバージョンバッジが0.8.11のままだったので0.9.3に更新した。
---
## v0.9.2(2026-11-03)
### Selectorイベントループ有効時に画像が壊れて届く不具合を修正
+33 -12
View File
@@ -27,7 +27,7 @@ A comprehensive workflow, asset management, and generation UI plugin for [ComfyU
- Built-in AI tools (translation and more)
![Workflow Studio](https://img.shields.io/badge/ComfyUI-Custom_Node-blue)
![Version](https://img.shields.io/badge/version-0.8.11-green)
![Version](https://img.shields.io/badge/version-0.10.0-green)
## Features (tab -> feature names)
@@ -38,22 +38,22 @@ Thumbnail / Table views, Thumbnail side panel, Badge filtering, Search, Side pan
One-click capture, Auto-save as thumbnail, Embedded workflow metadata, Auto-import
### GenerateUI Tab (v0.3.5)
6-tab layout, Save button, Input tab, Multi-image I2I for Comic Creator, Model tab, Settings tab, Always-visible Raw JSON, Bypass/Mute node handling, One-click generation, Seed control, Style selector, Create Catalog / Catalog buttons, Batch type selector, Batch tab, UI-to-API conversion, Video workflow support, Eagle integration, Qwen Image 2.1 support, Ming Image support
6-tab layout, Save button, Input tab, Multi-image I2I for Comic Creator, Model tab, Settings tab, Always-visible Raw JSON, Bypass/Mute node handling, One-click generation, Seed control, Style selector, Create Catalog / Catalog buttons, Batch type selector, Batch tab, UI-to-API conversion, Video workflow support, Eagle integration, Qwen Image 2.1 support, Ming Image support, P-H3 Image support, MiniMax-H3-Image support
### Feeder subtab (v0.3.5 / v0.3.42)
ImageFeeder node control, Image library, Selection management, Presets, Continuous Run loop, Index sync, Seed, WFS_GalleryFeeder node, Node & group selector, Image grid, After Gen modes, Run / Stop controls
### Lab subtab (v0.3.87 – v0.5.2)
Setting / Results / Plan JSON sub-panels, Per-column keyframes, Model column — Checkpoint / LoRA Single / VAE, Empty state when no matching node exists, Wildcards, Prompt cell extras, Keyframe #1 live-reflect, Bypass checkbox, LoRA node bypass & prompt injection, T2I workflow support, Use generated image for next, Workflow recall, Plan files, Plan Load, Plan JSON tab, Save index image to Output on Run, Index images are self-contained plan files, Eagle integration, Select vs. edit, and keyframe reordering, PG — apply a Prompt tab preset group, Video workflow support, Use generated image for next, now video-aware
### Lab subtab (v0.3.87 – v0.9.5)
Setting / Results / Plan JSON sub-panels, Per-column keyframes, Model column — Checkpoint / LoRA Single / VAE, Empty state when no matching node exists, Wildcards, Prompt cell extras, Keyframe #1 live-reflect, Bypass checkbox, LoRA node bypass & prompt injection, T2I workflow support, Use generated image for next, Workflow recall, Plan files, Plan Load, Plan JSON tab, Save index image to Output on Run, Index images are self-contained plan files, Eagle integration, Select vs. edit, and keyframe reordering, PG — apply a Prompt tab preset group, Video workflow support, Use generated image for next, now video-aware, Plans from a story
### Prompt Tab
3-column layout, AI chat assistant, Image attachment, Translation, Prompt presets, Preset Manager, Group management, Clipboard copy, GenUI Set, Wildcard/Style tab bar, Wildcard input toolbar, Wildcard file manager, Style manager, Form / Table toggle, Table view — Presets / Presets Group / Wildcards / Style
### Settings Tab
2-column layout, Collapsible sections, Theme selection, Theme customization, Workflows directory, Gallery output directory, Eagle connection, CivitAI Host, CivitAI API Key, Default workflow, Default Checkpoint, VRAM Management (Ollama), Video Playback Volume, Data Management, Text Size, RAW JSON Colors, GenerateUI Model Tab Highlight, Wildcard Integration, G'MIC-Qt Integration, Language
2-column layout, Collapsible sections, Theme selection, Theme customization, Workflows directory, Gallery output directory, Eagle connection, CivitAI Host, CivitAI API Key, Default workflow, Default Checkpoint, VRAM Management (Ollama), Video Playback Volume, Data Management, Text Size, RAW JSON Colors, GenerateUI Model Tab Highlight, Wildcard Integration, G'MIC-Qt Integration, Prompt Translation (native language → English), Language
### Gallery Tab (v0.3.44)
Output / ImagePrompt / Style_Catalog / Metadata sub-tabs, Image browser, Folder tree root label, Thumbnail / Table views, Folder management, File operations, Download, MP4 video support, MP4 embedded metadata, WebM support, Embedded metadata reading fixes, Audio support, File conversion, Move To folder filter, Semantic Search, Audio waveform colors, Info tab: dimensions & duration, Multi-select, Image Compare, Prompt search, Server-side filtering, Group management, Thumbnail F button, Favorites, Detail panel, Prompt tab, Nanobanana tab, Gemini / Nano Banana nodes, MOSS-Image in GenerateUI, Faster GenerateUI Check / conversion, Partner API nodes in GenerateUI, Workflow viewer, GenUI button, Image Edit button, Send GenUI Image button, Send to LI node button, Send to LV node button, Send CC Layout / Send CC Image buttons, Search clear (✕), Clear all filters (✕ Clear), Workflow auto-save, Output folder configurable, SVG file support, PSD file support, Performance
Output / ImagePrompt / Style_Catalog / Metadata sub-tabs, Image browser, Folder tree root label, Thumbnail / Table views, Folder management, File operations, Download, MP4 video support, MP4 embedded metadata, WebM support, Embedded metadata reading fixes, Audio support, File conversion, Move To folder filter, Semantic Search, Audio waveform colors, Info tab: dimensions & duration, Multi-select, Image Compare, Prompt search, Server-side filtering, Group management, Thumbnail F button, Favorites, Detail panel, Prompt tab, Nanobanana tab, Gemini / Nano Banana nodes, MOSS-Image in GenerateUI, Faster GenerateUI Check / conversion, Partner API nodes in GenerateUI, Workflow viewer, GenUI button, Image Edit button, Send GenUI Image button, Send to LI node button, Send to LV node button, Send CC Layout / Send CC Image buttons, Search clear (✕), Clear all filters (✕ Clear), Workflow auto-save, Output folder configurable, SVG file support, PSD file support, 3D model support, Performance
### ImagePrompt Gallery subtab (v0.3.94, renamed from Style/Prompt in v0.3.95)
Visual prompt library, 3-column layout, Prompt builder (right pane), Plain-text prompt storage, ponyxlWildcardsVault format support, Seed data importer
@@ -76,14 +76,17 @@ Model Browser, Thumbnail / Table views, Table column sort, Search & Filter, User
### TagSpace Tab (v0.9.0)
Choose tags visually in a 3D latent space, Build / Update, Choosing tags, Explore, Search with a card's or Gallery image's tags, Make a prompt, Tagger fill, Glow / Twinkle, Hover preview, Requirements
### Game Tab (v0.10.0, experimental)
Play, then generate, Star Formation, An image at every stage clear, Prompts from the game, Settings, For game authors
### Image Edit Tab (v0.3.65)
Layer-based image editor, Loading images, Open PSD button, Close button, New button, Tools, Layer panel, Duplicate layer (⧉), Layer lock, Text quality, Export, Canvas navigation, Undo / Redo
### Video Tab (v0.5.0 – v0.7.4)
Dedicated video generation UI, independent of GenerateUI, Plan subtab, Base settings row, Edit subtab, Edit: Multi-track, Edit: Audio / BGM, Edit: Text overlays, Edit: Crop, Edit: Convert audio, Edit: Undo / Redo, Edit project persistence, Asset subtab, Project subtab, Two center previews, Register as Asset, First Frame / Last Frame are both optional, Semantic node lookup, not hardcoded IDs, Field highlight color, Load in Video, Frame tab, GIF tab, Playback volume
### AI TOOL Tab (v0.3.14)
4-pane layout, Translation pane, Chat pane, Chat pane — image generation via Tool Calling, Chat pane — generate_image extra parameters, TOOLS pane (VLM), TOOLS pane — shared Chat attachment, TOOLS pane (Wildcards), Chat pane — image-to-image (I2I), Chat pane — SVG generation, no ComfyUI workflow involved, Chat pane — Skills, Settings pane, Unsloth backend, Decision API client, Settings pane — Chat Image Generation, Settings pane — Chat I2I Generation, Settings pane — Generation, Model unload, Settings shared, Backend support, URL security, Lemonade's other endpoints (not integrated)
### AI TOOL Tab (v0.3.14 – v0.9.5)
4-pane layout, Translation pane, Chat pane, Chat pane — image generation via Tool Calling, Chat pane — generate_image extra parameters, TOOLS pane (VLM), TOOLS pane — shared Chat attachment, TOOLS pane (Wildcards), Chat pane — image-to-image (I2I), Chat pane — SVG generation, no ComfyUI workflow involved, Chat pane — Skills, Chat pane — Skills v2, Built-in skills, Chat pane — Image check & refine loop, Chat pane — Workflow Doctor, Chat pane — Storyboard to Lab, Chat pane — Agent Skills folders, TOOLS pane — OCR, Collapsible Translation / Settings panes, Settings pane, Unsloth backend, Decision API client, Settings pane — Chat Image Generation, Settings pane — Chat I2I Generation, Settings pane — Generation, Model unload, Settings shared, Backend support, URL security, Lemonade's other endpoints (not integrated)
### Workflow Studio Library (ComfyUI Side Panel) (v0.3.9)
Tab layout (W / N / P / M / I / A), W — Workflows tab, N — Nodes tab, M — Models tab, P — Prompts tab, I — Information tab, A — AI TOOL tab, Drag & drop workflows, Drag & drop nodes, Drag & drop prompts, Send to Canvas, Copy prompts, Double-click, Search, ⚙ Theme settings
@@ -114,6 +117,8 @@ Sample workflows are included in the `workflows/` folder. You can open them dire
Samples for the Feeder tab: `ws_sdxl_image_feeder_i2i` / `ws_dwpose_image_feeder` (Image Loop mode, require the `comfyui-image-feeder` custom node) and `ws_sdxl_gallery_feeder_i2i` (v0.8.3, SDXL I2I with the bundled **WFS_GalleryFeeder** node — no extra custom node needed; put images in the `__Feeder__` Gallery group and use the Feeder tab's Gallery mode).
Sample for the Game tab: `ws_game_sdxl_t2i` (v0.10.0, SDXL text-to-image, 1216x832, saves to `output/WFS_Game`) — the Game tab's default workflow. Import it from the Workflow tab (or copy it into ComfyUI's `user/default/workflows`) and change the checkpoint to an SDXL model you have (the sample uses an Illustrious model, which suits the game's 1980s anime prompts).
> **Note:** Some sample workflows require additional custom nodes.
> If a node is shown as missing (red/unknown) after loading, install the required custom nodes via **ComfyUI Manager** or by cloning the repository from GitHub into your `ComfyUI/custom_nodes/` directory.
>
@@ -128,10 +133,12 @@ Samples for the Feeder tab: `ws_sdxl_image_feeder_i2i` / `ws_dwpose_image_feeder
## Manual
A beginner-oriented manual (covers v0.9.1, text-only edition without screenshots) is available in [`docs/manual/`](docs/manual/):
A beginner-oriented manual (covers v0.9.9, text-only edition without screenshots) is available in [`docs/manual/`](docs/manual/):
- English: [`docs/manual/en/`](docs/manual/en/) — ZIP: `Workflow_Studio_Manual_v0.9.1_en.zip`
- 日本語: [`docs/manual/`](docs/manual/) — ZIP: `Workflow_Studio_Manual_v0.9.1.zip`
- English: [`docs/manual/en/`](docs/manual/en/) — ZIP: `Workflow_Studio_Manual_v0.9.9_en.zip`
- 日本語: [`docs/manual/`](docs/manual/) — ZIP: `Workflow_Studio_Manual_v0.9.9.zip`
An EPUB edition with screenshots (Japanese and English, v0.9.9) is available on [Google Drive](https://drive.google.com/drive/folders/14mOHcnLYrFgNrOo6fy7ELyFjjWrAoU-_?usp=sharing).
---
@@ -161,6 +168,20 @@ Click the **camera icon** (next to the W button) in ComfyUI's top bar to capture
---
## Prompt Translation API
Other front-ends on the same ComfyUI server (e.g. Comic Creator) can use the prompt translator through these endpoints. Other `/api/wfm/translate*` routes are for the Workflow Studio UI only and may change.
| Endpoint | Purpose |
| --- | --- |
| `GET /api/wfm/translate/config` | `{api, config, presets, languages}`. `api` is the API version (currently `1`); a 404 or a missing `api` means Workflow Studio is absent or older than this API. `config` holds the `prompt_translate_*` settings; `languages` maps the accepted language codes to names |
| `POST /api/wfm/translate/prompt` | Prompt-aware translation. Body: `{"text": "..."}` (or `{"texts": [...]}`, up to 200), optional `target_lang` (default `en`; any PLaMo 3 Translate code such as `ja`, `zh-hans`, `zh-hant`, `ko`; `zh` = `zh-hans`), `source_lang` (default: the Settings value; `auto` = detect), `protect_quotes` (default `false`; keeps the text inside 「」『』“”"" untranslated, for text drawn in the image). Returns `{"status": "success", "translated": "..."}` (or `translations`). Prompt syntax is kept as in the 🌐 button |
| `POST /api/wfm/translate/warmup` | Preloads the model when CPU-resident mode is selected. Send `{"ignore_enabled": true}` if your front-end has its own on/off switch |
- Settings (model, Ollama URL, GPU / CPU-resident, unload after translating) are shared with Workflow Studio. The server does **not** check `prompt_translate_enabled`: that switch only shows or hides the translation buttons in Workflow Studio, so a client decides on its own whether to offer translation.
- Errors: HTTP 400 for bad input (unsupported language, more than 30,000 characters in one request, a single sentence over 1,000 characters), HTTP 502 for Ollama errors, including a translation that would be cut at the output token limit. Long text is split at line breaks and sentence ends and translated chunk by chunk; nothing is cut silently.
- VRAM management (Settings → VRAM Management and the Ollama "Unload Model" buttons) never unloads a model that uses no VRAM (`size_vram == 0`, such as the CPU-resident translator); the response lists it in `kept_cpu`.
## Requirements
- **ComfyUI** — any recent version (v1.33.9+ recommended for action bar integration)
@@ -169,7 +190,7 @@ Click the **camera icon** (next to the W button) in ComfyUI's top bar to capture
### Optional
- **[Ollama](https://ollama.com/)** — for AI chat assistant, translation, and VLM features
- **[Ollama](https://ollama.com/)** — for AI chat assistant, translation, and VLM features; also runs PLaMo 3 Translate for Settings → Prompt Translation (`ollama pull hf.co/pfnet/plamo-3-translate-2b-GGUF:Q4_K_M`, or the Download button there)
- **[LM Studio](https://lmstudio.ai/)** — alternative backend for translation and VLM (OpenAI-compatible API)
- **[Lemonade Server](https://lemonade-server.ai/)** — alternative backend for translation, chat, and VLM (OpenAI-compatible API)
- **[Unsloth](https://unsloth.ai/)** — alternative backend for translation, chat, and VLM (OpenAI-compatible API); needs an API key set via `UNSLOTH_API_KEY` in a `.env` file, or Unsloth's Keyless API access → "Chat and inference" turned on — `pip install -r requirements.txt` for `python-dotenv`
+57 -12
View File
@@ -23,7 +23,7 @@ A comprehensive workflow, asset management, and generation UI plugin for [ComfyU
- Built-in AI tools (translation and more)
![Workflow Studio](https://img.shields.io/badge/ComfyUI-Custom_Node-blue)
![Version](https://img.shields.io/badge/version-0.8.11-green)
![Version](https://img.shields.io/badge/version-0.10.0-green)
## Screenshots
@@ -55,9 +55,9 @@ A comprehensive workflow, asset management, and generation UI plugin for [ComfyU
| :--------------------------------: | :------------------------------------------: |
| ![Lab Tab](docs/15_labtab.png) | ![Lab Index Image](docs/16_lab_index.png) |
| Gallery Tab - Semantic Search ("sunset city street") |
| :-----------------------------------------------------------------: |
| ![Gallery Semantic Search](docs/20_gallery_semantic_search.png) |
| Gallery Tab - Semantic Search ("sunset city street") | TagSpace Tab - Search ("sunset city street") |
| :-----------------------------------------------------------------: | :-----------------------------------------: |
| ![Gallery Semantic Search](docs/20_gallery_semantic_search.png) | ![TagSpace Tab](docs/21_tagspace.png) |
---
@@ -133,6 +133,8 @@ A comprehensive workflow, asset management, and generation UI plugin for [ComfyU
- **Eagle integration** — auto-save generated images to [Eagle](https://eagle.cool/) with metadata
- **Qwen Image 2.1 support** (v0.7.3) — `TextEncodeQwenImage21` (the unified T2I/Edit encoder used by Comfy-Org's Qwen-Image-2.1 workflow templates) is now recognized: its `prompt`/`negative_prompt` widgets populate the Input tab's Positive/Negative Prompt textareas and are editable like any other prompt node; its `resolution` (a pixel-budget int, not width/height) is exposed for Raw JSON editing. No extra work was needed for the model's up to 10 reference images (`image_1`…`image_10`, used for image editing) — each one arrives as an ordinary LoadImage node, so it already gets its own card in the Input tab's Image sub-panel via the existing generic LoadImage detection
- **Ming Image support** (v0.7.5) — `TextEncodeMingImageEdit` (single `prompt` widget, up to 8 optional `images.image_N` reference inputs; role taken from the sampler/guider wiring, so the empty-prompt negative instance in layer-decomposition workflows shows as Negative) and `EmptyQwenImageLayeredLatentImage` (Latent panel; `layers` kept as-is) are recognized in GenerateUI, and Gallery/Metadata/sidepanel I tab now show their prompts as Positive. The Sampler field is disabled (N/A) when the SAMPLER input comes from a node without `sampler_name` (e.g. `SamplerLCM`). **Fix:** top-level nodes whose widgets are converted to wired inputs (e.g. `EmptyLatentImage` width/height fed by `GetImageSize`) keep those values in `widgets_values`; they were not stripped outside subgraphs, shifting later values (`batch_size` became `1024`, KSampler `steps`/`cfg` misread). Also: `BasicGuider`'s `conditioning` is treated as positive, and a linked text input wins over the stale widget text in UI-format metadata
- **P-H3 Image support** (v0.9.4) — the `PH3ImageConditioning` templates (Image Edit and T2I) load and run from GenerateUI, with the prompt shown on the Input tab and read back by the Metadata tab. Width and height follow the workflow's wiring, and the prompt upsampler runs as set in the workflow
- **MiniMax-H3-Image support** (v0.9.6) — the `MiniMaxH3ImageConditioning` templates (Image Edit and T2I) load and run from GenerateUI the same way, with the prompt shown on the Input tab and read back by the Metadata tab and the sidepanel I tab
</details>
@@ -165,7 +167,7 @@ Two independent modes selectable via **[Image Loop] / [Gallery]** toggle buttons
</details>
<details>
<summary><h3>Lab subtab (v0.3.87 – v0.5.2)</h3></summary>
<summary><h3>Lab subtab (v0.3.87 – v0.9.5)</h3></summary>
An experimental batch generator: runs the workflow currently loaded in GenerateUI N times, letting Model (Checkpoint/LoRA Single/VAE) / Prompt / KSampler each change independently starting at a chosen iteration — unlike the Batch tab's single-axis queue, every column keeps its own list of change points. Never mutates the loaded workflow; every iteration runs on a fresh clone. Works with both I2I and T2I workflows (v0.3.90).
@@ -191,6 +193,7 @@ An experimental batch generator: runs the workflow currently loaded in GenerateU
- **PG — apply a Prompt tab preset group** (v0.4.8) — a **PG** button on the Prompt column header opens a picker for the Prompt tab's Table-view preset groups (the same groups the Batch tab's checklist uses); choosing one replaces the entire Prompt column with one keyframe per preset in that group's order, starting at #1 (#1 is overwritten, not appended after). If the group has more presets than the current Batch count, Batch count is raised automatically to fit (capped at 50, the Batch input's own limit); anything still beyond that shows the existing "keyframes beyond Batch count" warning instead of being dropped
- **Video workflow support** (v0.5.2) — loading a MiniMax H3 (or other all-in-one video-generation) workflow into GenerateUI and running Lab now works end to end: the Prompt column writes to its `prompt` widget, the KSampler column auto-hides (same "no matching node" treatment as Model sub-columns) since the sampler wired internally is a fixed part of the model's own preset rather than something meant to be tuned per keyframe, the Results grid plays mp4 results inline, and the contact-sheet index image draws each video result's last frame instead of failing silently onto a black square
- **Use generated image for next, now video-aware** (v0.5.2) — when a Run's output is a video, the "Use generated image for next" chain extracts its last frame client-side (canvas) and uploads it as the next iteration's source image, instead of trying to feed the raw mp4 into a LoadImage node
- **Plans from a story** (v0.9.5) — AI TOOL Chat's **Storyboard to Lab** skill loads a ready plan here via **Open in Lab**; KSampler cells now show every value that is set (Step / CFG / Denoise / sampler / scheduler / Seed) instead of "(workflow default)" when only the seed or sampler is set
</details>
@@ -247,13 +250,16 @@ An experimental batch generator: runs the workflow currently loaded in GenerateU
- ~~AI Assistant Settings~~ (removed in v0.5.4) — the central Ollama backend/URL/model panel that used to live here was replaced by a ⚙ Settings button + modal directly in the Prompt tab and the Tagger tab, each with its own independent configuration (backend, URL, model, Thinking mode, Max tokens, and a model Unload button) — see those tabs below; the AI TOOL tab's own Settings pane is unaffected
- **VRAM Management (Ollama)** (v0.7.13) — right before every image generation from Workflow Studio (GenerateUI, Lab, batches, Video, AI TOOL chat generation — anything that goes through its queue), unload the models Ollama has loaded so ComfyUI has free VRAM. **Before generating**: Do nothing (default) / Unload only as much as needed when free VRAM is below a target (biggest model first, one at a time, stopping once the target is reached) / Unload everything every time; **Target free VRAM (GB)** for the second mode; **Unload all now** button. Free VRAM is measured with `nvidia-smi` (plus ComfyUI's own unused torch cache), because ComfyUI's free-VRAM figure may not change when Ollama loads a model; non-NVIDIA GPUs fall back to ComfyUI's value. Targets Ollama on localhost — the default `127.0.0.1:11434` plus the AI TOOL / Prompt / Tagger AI settings and the Decision Model when they use Ollama (other hosts only via `WFS_ALLOWED_BACKEND_HOSTS`); LM Studio etc. and ComfyUI's own models are not touched. A toast reports what was unloaded, an unreachable target or a failure; generation continues either way. Running a workflow from the ComfyUI canvas itself is not covered. Server route: `POST /api/wfm/vram/prepare` (JSON only). Ported from ComfyUI Comic Creator
- **Video Playback Volume** (v0.5.4) — the video preview's volume is remembered here and shared across every video player in the plugin (Video tab, Gallery tab), instead of resetting to maximum whenever a different video is opened
- **Data Management** — export core settings/metadata/prompts/CivitAI cache to a single JSON file; import to restore data (useful when migrating or reinstalling); API keys are excluded from exports for security
- **Data Management** — export core settings/metadata/prompts/CivitAI cache/semantic search settings to a single JSON file; import to restore data (useful when migrating or reinstalling); API keys are excluded from exports for security
- **Full Backup (ZIP)** (v0.5.2) — additionally covers what the JSON bundle can't represent: folder-based data (AI Skills, Lab Plans, Video Plans, Video Edit projects, Style presets) and the Tagger SQLite database; two opt-in checkboxes can also include ComfyUI's default workflows folder (`user/default/workflows`) and the Impact Pack's wildcard folder in the export — both of those are export-only and stored under an `_external/` prefix in the ZIP that Restore always skips, since auto-overwriting files a different plugin/ComfyUI core manages would be unsafe; copy them back by hand if needed. A third opt-in checkbox (v0.7.6) bundles the clips/BGM/sounds/overlay clips that saved Video Edit projects reference in ComfyUI's input folder (the project JSON only stores references) under `_video_edit_media/`; unlike `_external/`, these are restored into the input folder, never overwriting a file that already exists there. Restoring overwrites existing files; restart ComfyUI afterward for either restore path
- **Browser-side settings** (v0.9.10) — both the JSON export and the Full Backup also carry the settings the page keeps in the browser's localStorage (Workflow / prompt preset groups, model badge colors, appearance, AI TOOL / Prompt / Tagger connection settings, decision model and VRAM settings, Latent size presets, Draw palette, ...); importing writes them back and offers a **Reload page** button
- **Caches in the Full Backup** (v0.9.10) — two more checkboxes: **Gallery semantic search index** (on by default — rebuilding it re-embeds every image, which costs API usage with Gemini) and **TagSpace cache** (off by default, rebuildable). Temporary `*.tmp` files and the `models/` folder left over from the ONNX EmbeddingGemma of v0.8.2–v0.8.13 are no longer included
- **Text Size** — one slider (10–28 px) adjusts font size for all prompt and chat textareas at once: Generate UI positive/negative prompts, AI Assistant chat input, Preset prompts, Wildcard prompt and file editor, and Metadata prompt full preview; takes effect immediately and saved with Save Settings
- **RAW JSON Colors** — customize the 6 syntax highlight colors for the Raw JSON editor in Generate UI: Default Text (base), Name/Scheduler (yellow), Title (pink), Width/Height (green), Prompt/Text (cyan), Image/File (red); changes apply immediately on color pick; Reset Defaults restores the original scheme; saved to `localStorage` under `wfm_settings.jsonColors` and applied on startup
- **GenerateUI Model Tab Highlight** (v0.3.98) — pick the color used to mark Checkpoint/VAE/Diffusion Model/Text Encoder/ControlNet/Hypernetwork labels and the LoRA column header in GenerateUI's Model tab when the loaded workflow actually contains that type of node; default bright green; changes apply immediately, Reset Defaults restores it; saved to `localStorage` under `wfm_settings.modelTabActiveColor`; the same color and mechanism also drives the Video tab's field highlighting (v0.5.4, see above)
- **Wildcard Integration** — link the WFS wildcard directory to ComfyUI-Impact-Pack's `wildcards/` directory (directory junction on Windows, symlink on other OS); existing WFS wildcard files are automatically migrated; requires [ComfyUI-Impact-Pack](https://github.com/ltdrdata/ComfyUI-Impact-Pack)
- **G'MIC-Qt Integration** — set the path to `gmic_qt.exe` for the Image Edit Filter tool; download G'MIC-Qt Standalone from `gmic.eu/download.html` (Windows: `gmic_qt-win64.zip`), extract anywhere, then enter the full path to `gmic_qt.exe` and click Save
- **Prompt Translation (native language → English)** (v0.9.9) — off by default. Adds a 🌐 button to the GenerateUI Positive/Negative prompts, the Lab prompt modal and the Video Plan block prompt that translates only the parts written in your own language into English with a local Ollama model, keeping prompt syntax as it is (commas, `(word:1.2)`, `[ ]`, `{a|b}`, `<lora:...>`, `__wildcards__`, `embedding:name`, `BREAK`); "Original" restores the text. Model: [PLaMo 3 Translate](https://huggingface.co/pfnet/plamo-3-translate-2b-GGUF) 0.8B / 2B / 8B / 31B (Download button pulls it into Ollama; free for personal and non-commercial use under the PLaMo Community License) or any other Ollama model. Source language auto-detect or one of 51 languages; run on GPU (about 0.1 s per phrase, optionally unloaded after each translation) or **CPU kept loaded** (about 0.3 s per phrase, no VRAM, about 2.7 GB of RAM for 2B, preloaded when a workflow is loaded into GenerateUI). **Translate automatically when running**: GenerateUI Generate (replaces the prompt text), Lab Run and Video Plan Run (translate only what is sent; the plan keeps your text); if translation fails nothing is generated. Server routes: `POST /api/wfm/translate`, `POST /api/wfm/translate/prompt`, `GET /api/wfm/translate/config|models`, `POST /api/wfm/translate/pull|warmup|unload` (see [Prompt Translation API](#prompt-translation-api))
- **Language** — English / Japanese / Chinese
</details>
@@ -309,6 +315,7 @@ An experimental batch generator: runs the workflow currently loaded in GenerateU
- **Output folder configurable** — set the scanned output folder from Settings tab
- **SVG file support** (v0.3.77) — `.svg` files are browsable, previewable (detail panel and lightbox), and included in favorites/tags/groups/move/delete/export alongside raster formats; served as-is with no rasterized thumbnail, since `<img>` scales vector graphics natively at any size
- **PSD file support** (v0.6.0) — `.psd` files are browsable alongside other formats; thumbnails and full-size previews show every layer merged together (hidden layers excluded), rendered server-side via `psd-tools` and disk-cached; the underlying PSD file itself is never modified — only the Gallery preview is a flattened rendering
- **3D model support** (v0.9.4) — `.glb` / `.gltf` / `.vrm` / `.ply` (mesh, point cloud or Gaussian splat) / `.spz` files are browsable alongside images with a **3D** badge and open in a built-in viewer in the detail panel, lightbox and compare view (drag to rotate, right-drag to pan, wheel to zoom). Thumbnails are rendered by your browser the first time a file appears and then kept on the server (files over 128 MB get one when opened). Workflows saved by ComfyUI's SaveGLB are read like an image's. A `.gltf` using separate `.bin` or texture files needs them to stay in place: Move and Delete only affect the `.gltf` itself. KTX2-compressed textures are not supported
- **Performance** — server-side 256px JPEG thumbnail generation with disk cache (`data/thumb_cache/`); infinite-scroll paging (50 images per page, IntersectionObserver); folder-level mtime cache (60s TTL); bulk operations use single-request API endpoints
</details>
@@ -432,6 +439,18 @@ An experimental batch generator: runs the workflow currently loaded in GenerateU
</details>
<details>
<summary><h3>Game Tab (v0.10.0, experimental)</h3></summary>
- **Play, then generate** — a tab for mini games that end in image generation. The games come from a separate pack, [ComfyUI-WFS-Games](https://github.com/ketle-man/ComfyUI-WFS-Games); the tab appears only when the pack is installed (Workflow Studio checks `/wfs_games/manifest` on start), so without it nothing changes
- **Star Formation** (first game) — a 1980s-style vertical shooter (arcade / MSX2 / PC-8801 look: pixel sprites, pixel font, scanlines, chiptune music) built on Phaser 4. 5 stages, each ending with a boss (WARNING, boss music; big and tough / fast with fast shots / radial bursts / flashing straight-line ram / a giant carrier launching small fighters). Navigator Rina talks between stages in an adventure-game style window
- **An image at every stage clear** — a card is added to the Result panel and a victory shot of Rina with that stage in the background is generated in the background while you keep playing (one at a time, in order). Five flashing enemies per stage drop hearts; catch all 5 and that stage's image becomes a private photo of Rina instead (more casual clothes each stage, up to a swimsuit — the game adds negative tags so it goes no further). Clearing all 5 stages adds the ending scene; a game over adds a defeat scene (screen darkens, her call goes unanswered)
- **Prompts from the game** — each card lists the prompts the game returned with their kind (Style / Heroine / Scene / Stage); uncheck or edit them and Regenerate, or **Open in GenerateUI**. The game's negative tags are added to the workflow's negative prompt
- **Settings** — the workflow used for generation (default `ws_game_sdxl_t2i.json`, an SDXL text-to-image workflow included in `workflows/` — import it and set your checkpoint; output in `output/WFS_Game`), base prompt, negative prompt, and whether to generate at each stage clear / the ending / on game over automatically; difficulty, music and sound effects. VRAM Management notices are not shown while the Game tab is open
- **For game authors** — a game is an ES module with `mount(container, host)`; it reports results through `host.stageClear()` / `host.finish()` and never calls ComfyUI itself — Workflow Studio builds the prompt and runs the generation. See the pack's README and `PLAN_GAME_TAB.md`
</details>
<details>
<summary><h3>Image Edit Tab (v0.3.65)</h3></summary>
@@ -442,7 +461,7 @@ An experimental batch generator: runs the workflow currently loaded in GenerateU
- **New button** — create a blank canvas with custom dimensions (WxH prompt); clears all existing layers and automatically adds an empty Layer 1 (v0.3.70)
- **Tools** — Select (V), Draw (B), Text (T), Shape (S), Fill (G), Mask (🎭), Blur (≈), BG Remove (⬚), Filter (★), Inpaint (🩹); tool options bar updates per active tool
- **Select** — click to select; drag to move; drag corner handles to resize; drag circle handle to rotate; Flip H / Flip V / Rotate angle in the options bar; double-click a text layer to re-edit its content
- **Draw** — freehand brush; options: color, brush size, blend mode; paints directly onto the active draw layer while all other layers remain visible; brush cursor shown as a size-accurate circle; strokes can start from outside the canvas margin and continue past the edge; **pen tablet support** (v0.6.2) — brush size and opacity respond to pen pressure (mouse behaves exactly as before); the canvas listens for Pointer Events so pen, touch, and mouse all work through the same code path
- **Draw** — freehand brush; options: color, brush size, blend mode; paints directly onto the active draw layer while all other layers remain visible; brush cursor shown as a size-accurate circle; strokes can start from outside the canvas margin and continue past the edge; **pen tablet support** (v0.6.2) — brush size and opacity respond to pen pressure (mouse behaves exactly as before); the canvas listens for Pointer Events so pen, touch, and mouse all work through the same code path; **color palette** on the second row — Color 1/Color 2, 20 basic colors, and 20 custom slots (registered and edited colors are saved in the browser); **eyedropper** button next to Color picks a color from the canvas (`Esc` cancels); shortcuts while Draw is active: `D` Draw, `E` Erase, `X` switch Color 1/2, `[` `]` brush size, `B` open or close the brush picker (`Esc` also closes it)
- **Text** — click to place; configure font, size, bold/italic, align, and color; placed as an exact-size text layer sized to the measured bounding box; double-click to re-edit
- **Shape** — drag to draw geometric shapes (Rect / Ellipse / Line / FreeLine); options: shape type, Rounded toggle (Rect/Ellipse), Fill color, Stroke color + width, Opacity; each committed shape becomes an independent draw layer; Stroke None hidden for Line/FreeLine (stroke always active)
- **Fill** (v0.6.2) — bucket fill; click a contiguous same-color region on the active layer to flood-fill it (scanline-based, ported from the Comic Creator plugin's Image tab); **Properties pane**: Mode (Solid / Gradient) — Solid: Color picker; Gradient: Shape (Linear / Radial), a draggable color-stop Ramp (click a stop to select it, drag to reposition, +/- to add/remove stops, color swatch to edit the selected stop's color), and a Direction dial (drag to set angle/radius); both Tolerance (0–255, color-match threshold) and Opacity apply to either mode; Ramp and Direction dial are pointer-event based with pointer capture, so pen tablets work the same as mouse
@@ -490,7 +509,7 @@ An experimental batch generator: runs the workflow currently loaded in GenerateU
</details>
<details>
<summary><h3>AI TOOL Tab (v0.3.14)</h3></summary>
<summary><h3>AI TOOL Tab (v0.3.14 – v0.9.5)</h3></summary>
- **4-pane layout** — Translation | Chat | TOOLS | Settings; all panes always visible simultaneously; no sub-tab switching required
- **Translation pane** — translate text between Japanese, English, Chinese, or a custom Free language using Ollama, LM Studio, Lemonade, or Unsloth; language selectors with ⇄ swap button (swaps both language selectors and text content); selections saved automatically
@@ -504,6 +523,14 @@ An experimental batch generator: runs the workflow currently loaded in GenerateU
- **Chat pane — image-to-image (I2I)** (v0.3.74) — when an image is attached and `generate_image` is invoked, the attachment is uploaded and swapped into the target workflow's LoadImage node instead of running text-to-image; the target workflow is the one currently loaded in GenerateUI, or a dedicated I2I workflow configured in the Settings pane
- **Chat pane — SVG generation, no ComfyUI workflow involved** (v0.3.77) — the LLM can also produce SVG graphics directly as text; if a reply contains SVG code (wrapped in a markdown code fence or written directly as a bare `<svg>...</svg>`), it's rendered inline as a preview and a "Save to Gallery" button writes it as a `.svg` file to the Gallery tab's output folder; unlike the Tool Calling image generation flow above, this is plain text pattern matching, so it works with any model regardless of tool-calling support
- **Chat pane — Skills** (v0.3.79) — select a `.md` skill file from a dropdown above the message list to prepend its instructions to the conversation as a system prompt (not shown in the visible chat log); a pencil button opens an in-pane manager (list + inline editor, same pattern as the Prompt tab's wildcard file manager) to create, edit, or delete skill files stored in `user/default/Workflow-Studio/ai_skills/`; a file's `---`-delimited frontmatter (`name`/`description`) is shown in the dropdown; two starter skills are bundled — **SVG Icon Generator** (explicitly decomposes the subject into parts before drawing, which markedly improves recognizability from small local models) and **Skill Creator** (interviews you conversationally and drafts a new skill as a ```skill code block; a "Save as new skill" button appears under such replies and opens the manager pre-filled with the draft)
- **Chat pane — Skills v2** (v0.9.5) — skills keep the portable `name`/`description` frontmatter (Agent Skills / SKILL.md style) and add optional `metadata:` keys: `output` (`prompt` or `svg` — the reply is checked and, if the model tried to output one but it is broken, it is asked once to fix it), `tools` (`[]` = never start image generation), `temperature`, `think`, and `context` (`workflow` summary, `current-prompt`, `workflow-detail`, `logs`). Six built-in skills ship in `py/services/builtin_skills/` with a version number: untouched copies are upgraded automatically, edited ones keep your text and show a ↻ button. A ```` ```prompt ```` block in a reply gets **Apply to GenerateUI** / **Generate with this prompt** / **Copy** buttons, and replies are rendered as Markdown (HTML-escaped first)
- **Built-in skills** (v0.9.5) — **T2I Prompt Enhancer** (writes natural sentences for Qwen-Image / FLUX / Z-Image, Danbooru tags for Illustrious / Pony, phrases for realistic SDXL, based on the workflow loaded in GenerateUI), **Image to Prompt** (recreates an image attached in TOOLS), **Storyboard to Lab**, **Workflow Doctor**, **SVG Icon Generator** v2 (line/flat/duotone/mono styles) and **Skill Creator** v3. The prompt text currently in GenerateUI is only passed to the model when your message refers to it, because small models copied an old negative prompt into new ones even when told not to
- **Chat pane — Image check & refine loop** (v0.9.5) — with **Check images** on, the chat model turns the request into 3–8 yes/no checks and an Ollama decision model with image input (`d3:4b` by default; `clef-flash` / `clef` also work) answers them with probabilities: ✔ ≥ 85%, ? 30–85%, ✘ < 30%. Swap checks ("the hat is not on the girl") catch the attribute mix-ups the judge otherwise passes. **Fix missing items and regenerate** sends only the unmet items back for a rewritten prompt; 0–3 automatic rounds are configurable. SVG replies are rendered and checked part by part the same way
- **Chat pane — Workflow Doctor** (v0.9.5) — diagnoses the workflow loaded in GenerateUI from facts checked on every message: node types that are not installed, model files or options missing from ComfyUI's lists (with the closest existing names), broken links, unconnected core-type required inputs, the last execution error from `/history`, and the latest error block of the ComfyUI log (no false positives across 77 local workflows)
- **Chat pane — Storyboard to Lab** (v0.9.5) — a ```` ```labplan ```` reply becomes a Lab plan (one scene per iteration, T2I mode, identical character descriptions, fixed seed); **Open in Lab** loads it into GenerateUI > Lab
- **Chat pane — Agent Skills folders** (v0.9.5) — **Import** in the skill manager adds a `.zip` containing `SKILL.md` (or a single `.md`); only text files are kept, scripts are never extracted or run, and zip-slip / size limits apply. Reference files are listed to the model and read on demand through a `read_skill_file` tool (progressive disclosure; needs a tool-capable model)
- **TOOLS pane — OCR** (v0.9.5) — **OCR (extract text)** reads text with an Ollama OCR model (LightOnOCR-3 by default; PaddleOCR-VL, GLM-OCR and DeepSeek-OCR are listed too). Ported from Comic Creator's OCR tab: 1600 px white-background JPEG, temperature 0, grayscale retry on empty / looping output. **Show text positions** (LightOnOCR / DeepSeek-OCR) overlays numbered boxes; clicking one selects its line. **To Translation** / **To Chat** pass any TOOLS result on
- **Collapsible Translation / Settings panes** (v0.9.5) — the arrow in each header folds the pane into a thin strip (click the strip to reopen); the state is remembered
- **Settings pane** — choose backend (Ollama / LM Studio / Lemonade / Unsloth), set the API URL, test connection, select a model (with refresh button), and configure Free language names for translation source and destination
- **Unsloth backend** (v0.3.99) — Unsloth Desktop's OpenAI-compatible API requires an API key even for local access unless its **Keyless API access → "Chat and inference"** setting is on; unlike the other backends it's proxied server-side (`py/routes/unsloth_routes.py`, `POST /api/wfm/unsloth/proxy`) so the key never reaches the browser: set `UNSLOTH_API_KEY` in a `.env` file in the plugin folder (copy `.env.example`, loaded via `python-dotenv` in `prestartup_script.py`) and restart ComfyUI — or, since v0.7.7, leave `UNSLOTH_API_KEY` unset and turn on Keyless API access → "Chat and inference" in Unsloth Desktop (requests are then relayed without an `Authorization` header, still only to localhost; that Unsloth setting also opens the API to your private LAN, and "Allow tools" should stay off). A 401 with no key set returns a message explaining both options; also requires **"Auto model switching (OpenAI API)"** to be turned on in the Unsloth Desktop app's own Settings screen — with it off, requests fail with HTTP 404 unless a model was already manually loaded in the Unsloth Studio UI
- **Decision API client** (v0.7.5, foundation) — `static/js/decision-client.js` calls Unsloth Desktop's Decision API (`/v1/systemone`, TypeSafe-compatible Laya decision models) through the same key-attaching server proxy: `decide(state, questions)` / `decideMany`, question builders `noul`/`choice`/`score`, and `isYes`/`pickChoice`/`pickScore` helpers that threshold on `probabilities` (as Unsloth recommends) and flag low-probability answers as not confident. Requires **Decision API → Serve requests** enabled in Unsloth Desktop. **Ollama 0.35+ backend** (v0.7.7) — Ollama's own `/v1/systemone` (decision models `tev1` 4B / `tev1:0.8b` 812 MB / `nimble` 9B / `clef` 27B vision-capable, pulled with `ollama pull`; no key, called directly from the browser); the model list shows only installed models whose `capabilities` include `decision`, with a ↻ refresh button and a pull hint when none are installed. **Image input** (v0.7.14, ported from ComfyUI Comic Creator) — most decision models are text-only, but Ollama's `clef` accepts images directly: `decide()` takes an optional 4th `images` argument (base64, no `data:` prefix), `imageToBase64()` converts a Blob/data URL/image URL, and `supportsDecisionVision()` checks whether the currently-configured model accepts them (via `/api/show`'s `capabilities`/`projector_info`, since not every Ollama build reports `vision` for decision models) — call it before passing images, since a non-vision model errors out on them; confirmed working end to end against `clef`. Connection settings live in the Settings tab's own **Decision Model** section (v0.7.6): backend (Unsloth / Ollama), URL, model and default probability threshold, stored under `wfm_decision_settings` independently of the AI TOOL / Tagger backends, with a Test button (one yes/no question). No feature uses it yet
@@ -581,6 +608,8 @@ Sample workflows are included in the `workflows/` folder. You can open them dire
Samples for the Feeder tab: `ws_sdxl_image_feeder_i2i` / `ws_dwpose_image_feeder` (Image Loop mode, require the `comfyui-image-feeder` custom node) and `ws_sdxl_gallery_feeder_i2i` (v0.8.3, SDXL I2I with the bundled **WFS_GalleryFeeder** node — no extra custom node needed; put images in the `__Feeder__` Gallery group and use the Feeder tab's Gallery mode).
Sample for the Game tab: `ws_game_sdxl_t2i` (v0.10.0, SDXL text-to-image, 1216x832, saves to `output/WFS_Game`) — the Game tab's default workflow. Import it from the Workflow tab (or copy it into ComfyUI's `user/default/workflows`) and change the checkpoint to an SDXL model you have (the sample uses an Illustrious model, which suits the game's 1980s anime prompts).
> **Note:** Some sample workflows require additional custom nodes.
> If a node is shown as missing (red/unknown) after loading, install the required custom nodes via **ComfyUI Manager** or by cloning the repository from GitHub into your `ComfyUI/custom_nodes/` directory.
>
@@ -595,10 +624,12 @@ Samples for the Feeder tab: `ws_sdxl_image_feeder_i2i` / `ws_dwpose_image_feeder
## Manual
A beginner-oriented manual (covers v0.9.1, text-only edition without screenshots) is available in [`docs/manual/`](docs/manual/):
A beginner-oriented manual (covers v0.9.9, text-only edition without screenshots) is available in [`docs/manual/`](docs/manual/):
- English: [`docs/manual/en/`](docs/manual/en/) — ZIP: `Workflow_Studio_Manual_v0.9.1_en.zip`
- 日本語: [`docs/manual/`](docs/manual/) — ZIP: `Workflow_Studio_Manual_v0.9.1.zip`
- English: [`docs/manual/en/`](docs/manual/en/) — ZIP: `Workflow_Studio_Manual_v0.9.9_en.zip`
- 日本語: [`docs/manual/`](docs/manual/) — ZIP: `Workflow_Studio_Manual_v0.9.9.zip`
An EPUB edition with screenshots (Japanese and English, v0.9.9) is available on [Google Drive](https://drive.google.com/drive/folders/14mOHcnLYrFgNrOo6fy7ELyFjjWrAoU-_?usp=sharing).
---
@@ -628,6 +659,20 @@ Click the **camera icon** (next to the W button) in ComfyUI's top bar to capture
---
## Prompt Translation API
Other front-ends on the same ComfyUI server (e.g. Comic Creator) can use the prompt translator through these endpoints. Other `/api/wfm/translate*` routes are for the Workflow Studio UI only and may change.
| Endpoint | Purpose |
| --- | --- |
| `GET /api/wfm/translate/config` | `{api, config, presets, languages}`. `api` is the API version (currently `1`); a 404 or a missing `api` means Workflow Studio is absent or older than this API. `config` holds the `prompt_translate_*` settings; `languages` maps the accepted language codes to names |
| `POST /api/wfm/translate/prompt` | Prompt-aware translation. Body: `{"text": "..."}` (or `{"texts": [...]}`, up to 200), optional `target_lang` (default `en`; any PLaMo 3 Translate code such as `ja`, `zh-hans`, `zh-hant`, `ko`; `zh` = `zh-hans`), `source_lang` (default: the Settings value; `auto` = detect), `protect_quotes` (default `false`; keeps the text inside 「」『』“”"" untranslated, for text drawn in the image). Returns `{"status": "success", "translated": "..."}` (or `translations`). Prompt syntax is kept as in the 🌐 button |
| `POST /api/wfm/translate/warmup` | Preloads the model when CPU-resident mode is selected. Send `{"ignore_enabled": true}` if your front-end has its own on/off switch |
- Settings (model, Ollama URL, GPU / CPU-resident, unload after translating) are shared with Workflow Studio. The server does **not** check `prompt_translate_enabled`: that switch only shows or hides the translation buttons in Workflow Studio, so a client decides on its own whether to offer translation.
- Errors: HTTP 400 for bad input (unsupported language, more than 30,000 characters in one request, a single sentence over 1,000 characters), HTTP 502 for Ollama errors, including a translation that would be cut at the output token limit. Long text is split at line breaks and sentence ends and translated chunk by chunk; nothing is cut silently.
- VRAM management (Settings → VRAM Management and the Ollama "Unload Model" buttons) never unloads a model that uses no VRAM (`size_vram == 0`, such as the CPU-resident translator); the response lists it in `kept_cpu`.
## Requirements
- **ComfyUI** — any recent version (v1.33.9+ recommended for action bar integration)
@@ -636,7 +681,7 @@ Click the **camera icon** (next to the W button) in ComfyUI's top bar to capture
### Optional
- **[Ollama](https://ollama.com/)** — for AI chat assistant, translation, and VLM features
- **[Ollama](https://ollama.com/)** — for AI chat assistant, translation, and VLM features; also runs PLaMo 3 Translate for Settings → Prompt Translation (`ollama pull hf.co/pfnet/plamo-3-translate-2b-GGUF:Q4_K_M`, or the Download button there)
- **[LM Studio](https://lmstudio.ai/)** — alternative backend for translation and VLM (OpenAI-compatible API)
- **[Lemonade Server](https://lemonade-server.ai/)** — alternative backend for translation, chat, and VLM (OpenAI-compatible API)
- **[Unsloth](https://unsloth.ai/)** — alternative backend for translation, chat, and VLM (OpenAI-compatible API); needs an API key set via `UNSLOTH_API_KEY` in a `.env` file, or Unsloth's Keyless API access → "Chat and inference" turned on — `pip install -r requirements.txt` for `python-dotenv`
Binary file not shown.

After

Width:  |  Height:  |  Size: 942 KiB

+3 -3
View File
@@ -2,12 +2,12 @@
ノードが苦手でも大丈夫 ― 画像生成をもっと手軽に、もっと整理して
- 対象バージョン:Workflow Studio v0.9.1
- 対象バージョン:Workflow Studio v0.9.9
- 著者:ketle-man
- © 2026 ketle-man
このマニュアルは、Kindle版をもとにした **画像なしのテキスト版** です。
章ごとのファイルは `chapters/` フォルダ、全章をまとめたファイルは `Workflow_Studio_Manual_v0.9.1.md` です。
章ごとのファイルは `chapters/` フォルダ、全章をまとめたファイルは `Workflow_Studio_Manual_v0.9.9.md` です。
画面の例は省略しているため、実際の画面はWorkflow Studioのヘルプタブとあわせてご覧ください。
## 目次
@@ -29,4 +29,4 @@
- [13_付録](chapters/13_付録.md)
- [14_おわりに](chapters/14_おわりに.md)
全章まとめ:[Workflow_Studio_Manual_v0.9.1.md](Workflow_Studio_Manual_v0.9.1.md)
全章まとめ:[Workflow_Studio_Manual_v0.9.9.md](Workflow_Studio_Manual_v0.9.9.md)
Binary file not shown.
@@ -2,12 +2,12 @@
ノードが苦手でも大丈夫 ― 画像生成をもっと手軽に、もっと整理して
- 対象バージョン:Workflow Studio v0.9.1
- 対象バージョン:Workflow Studio v0.9.9
- 著者:ketle-man
- © 2026 ketle-man
このマニュアルは、Kindle版をもとにした **画像なしのテキスト版** です。
章ごとのファイルは `chapters/` フォルダ、全章をまとめたファイルは `Workflow_Studio_Manual_v0.9.1.md` です。
章ごとのファイルは `chapters/` フォルダ、全章をまとめたファイルは `Workflow_Studio_Manual_v0.9.9.md` です。
画面の例は省略しているため、実際の画面はWorkflow Studioのヘルプタブとあわせてご覧ください。
---
@@ -143,7 +143,7 @@ ComfyUIの「自由さ」はそのままに、「分かりやすさ」と「手
## 本書の対象バージョンと環境
- **Workflow Studio**:v0.9.1
- **Workflow Studio**:v0.9.9
- **ComfyUI**:本書執筆時点の最新版
- **OS**:Windows(画面の例はWindowsのものです)
@@ -624,7 +624,7 @@ Workflow Studioを開くと、画面の上部にタブが横一列に並んで
| TagSpace | TagSpace | タグ・プロンプト・生成画像を意味の近さで3D表示し、タグを選ぶ | | 第11章 |
| 設定 | Settings | 言語・テーマ・フォルダなどの設定 | | 本章・第11章 |
| ヘルプ | Help | 機能一覧・ショートカット・トラブル対処 | | 本章 |
| AI TOOL | AI TOOL | ローカルAIによる翻訳・チャット・画像解析 | | 第10章 |
| AI TOOL | AI TOOL | ローカルAIによる翻訳・チャット・画像解析・文字起こし(OCR) | | 第10章 |
### タブは「整理する」「作る」「補助する」の3グループで考える
タブが多くて迷ったときは、次の3つのグループに分けて考えると分かりやすくなります。
@@ -1222,12 +1222,13 @@ Inputサブタブでは、Raw JSONの上端にある **»** ボタンで、Raw J
1枚目が生成できたら、次は **Settings** サブタブで、画像の仕上がりを左右する設定を見てみましょう。
Settingsタブは、左右2つのブロックに分かれています。
Settingsタブは、3つの列に分かれています。
- **KSampler(左)** - 画像をどのように描くかの設定
- **Latent Image(右)** - 画像の大きさと枚数の設定
- **Latent Image(中央)** - 画像の大きさと枚数の設定
- **スイッチ(右、v0.9.6〜)** - ワークフローの中のオン・オフの切り替え
ここでも、値を変えたら各ブロックの **Apply** を押すのを忘れないようにしましょう。
ここでも、KSamplerとLatent Imageは、値を変えたら各ブロックの **Apply** を押すのを忘れないようにしましょう(スイッチの列はApply不要です)。
### KSampler の項目
| 項目 | 意味 | 初心者向けの目安 |
@@ -1254,6 +1255,23 @@ Settingsタブは、左右2つのブロックに分かれています。
> モデルが学習したサイズから大きく外れると、人物が二重になったり、構図が崩れたりしやすくなります。
> 縦長・横長にしたいときも、合計のピクセル数がおおよそ同じになるように調整しましょう(例:SDXLなら 832×1216 など)。
### スイッチの項目(v0.9.6〜)
ワークフローの中にある「オン・オフ」の設定が、ノード名と項目名つきで一覧になります。
チェックボックスをクリックすると、その場で切り替わります。**Apply を押す必要はありません**。切り替えた値は右側の Raw JSON にもすぐ反映されます。
一覧に出るのは、次の2種類です。
- 値が true/false の項目 - プロンプト強化(PE)のオン・オフを切り替えるスイッチや「Boolean」ノード、TextGenerate の thinking など
- 選択肢が2つだけのオン・オフの項目 - enable/disable、on/off、yes/no など。KSamplerAdvanced の add_noise、DWPreprocessor の detect_hand(手を検出するか)など
各行の右端には、いまの値(true/false、enable/disable など)が表示されます。
行にマウスを乗せると、ノードの番号と種類を確認できます。
> **ポイント**
> 別のノードから線でつながっている項目は、一覧に出ません。代わりに、つながっている元のノード(たとえば「Enable PE?」という名前の Boolean ノード)が出るので、そちらを切り替えてください。
> ノードに名前を付けていないワークフローでは、ノードの種類名(ComfySwitchNode など)で表示されます。
> オン・オフの項目が1つも無いワークフローでは「このワークフローに true/false の項目はありません」と表示されます。
### シードの管理(生成パネル)
シードは、生成パネルの **Seed** 欄と、その下のプルダウンで管理します。
@@ -1286,7 +1304,7 @@ Settingsタブは、左右2つのブロックに分かれています。
> **この章(前半)のまとめ**
> - ワークフロータブで選んで「生成UIに読み込み」を押すと、生成UIで編集できる
> - 基本は Input(プロンプト)・Model(モデル)・Settings(細かい設定)の3つのサブタブ
> - モデルやSettingsの値を変えたら必ず **Apply**。押し忘れると変更前の値で生成される(プロンプトは自動で反映)
> - モデルやSettingsの値を変えたら必ず **Apply**。押し忘れると変更前の値で生成される(プロンプトとSettingsのスイッチ列は自動で反映)
> - Generate で生成。Alt+Apply なら反映と生成を一度に行える
> - シードを Fixed にすると、気に入った絵をもとに条件を変えて比べられる。ワークフローのシードをそのまま使うなら Workflow
@@ -1457,6 +1475,8 @@ Labでは、「何回目の生成から、どの設定に切り替えるか」
4. 生成回数(Batch)を決めます。
5. Model・Prompt・KSampler の各列で **+** を押してキーフレームを追加し、
キーフレームをダブルクリックして、「何回目から」「どの設定に」するかを入力します。
KSampler列のセルには、指定した項目(Step・CFG・Denoise・サンプラー・スケジューラー・Seed)が表示されます。
何も指定していないセルは「(ワークフローの設定のまま)」と表示されます。
6. **Run** を押します。
結果は **Results** パネルに一覧表示されます。
@@ -1466,6 +1486,8 @@ Labでは、「何回目の生成から、どの設定に切り替えるか」
少しずつ変化していく連続画像を作れます。
- **Plan Save** - 設定(プラン)を保存できます。保存すると、結果をまとめた一覧画像も作られ、
その画像をドロップすれば同じプランを読み込み直せます。
- **物語からプランを作る**(v0.9.5〜) - AI TOOLのChatで **Storyboard to Lab** スキルを使うと、
物語をシーンごとのプロンプトに分けたプランを作り、**Labで開く** ボタンでここに読み込めます(第10章 10-5)。
---
@@ -1511,21 +1533,141 @@ v0.8.6〜は、こうしたノードを含むワークフローも生成UIで実
| Fibo 2.0 Edit(v0.8.14〜) | 画像編集のワークフロー。プロンプト強化(PE)を使う構成でも、プロンプト欄の編集がPEのオン・オフどちらにも反映される。ネガティブの欄にはVGL形式(JSON)の説明文がそのまま入る。幅・高さ(Settings)は0で自動 |
| FastH3 OmniRef/Pika-H3-Flex(v0.8.14〜) | MiniMax H3の「参照画像から動画」(Reference to Video)。動画のワークフローとして扱われ、Videoタブ(第11章)でも使える |
| ネイティブLoRAスタック | ComfyUI v0.40のLoRAをまとめて読み込むノード(LoadLoraModel/LoadLoraTextEncoder)。Apply・バイパス・Metadata表示に対応 |
| P-H3 Image(v0.9.4〜) | 画像編集とT2Iのテンプレート。プロンプトはInputタブに表示され、Metadataタブでも読める。ネガティブの欄は無い。幅・高さはワークフローのつなぎ方に従い、プロンプトを補う機能(プロンプトアップサンプラー)もワークフローの設定どおりに動く |
| MiniMax H3 Image(v0.9.6〜) | ComfyUI公式の画像編集とT2Iのテンプレート。P-H3 Imageと同じく、プロンプトはInputタブに表示され、MetadataタブとサイドパネルのIタブでも読める。ネガティブの欄は無い。プロンプト強化(PE)のオン・オフは、Settingsタブのスイッチの列(5-4)で切り替えられる |
> **注意**
> ネイティブLoRAスタックのノードは、保存形式が **API形式のワークフローのみ** 対応です。
> ComfyUI本体の画面がこのノードの行追加にまだ対応していないためで、UI形式のワークフローは対象外です。
> **ポイント**
> 2枚の画像をスライダーで見比べる **Compare Images**(ImageCompare)ノードを含むワークフローは、以前は生成UIから実行すると、このノードだけエラーになっていました(v0.9.6で修正)。
> **ポイント**
> 画像のメタデータを見るMetadataタブとサイドパネルの **I** タブでも、Nano Bananaで作った画像を読めます(v0.8.5〜)。
> プロンプトは、Positive/Negativeに分けずに全文が1件で表示されます。
## 5-10 日本語のままプロンプトを書く(プロンプト翻訳、v0.9.9〜)
多くの画像生成モデルは、英語のプロンプトで学習されています。
**プロンプト翻訳** をオンにすると、プロンプトを日本語で書き、ボタン1つで英語に直せます。
Stable Diffusion web UI(A1111)の翻訳拡張機能と同じように、プロンプトの中の **日本語の部分だけ** を翻訳します。
翻訳には、パソコンで動くAI(**Ollama**)と翻訳専用のモデル **PLaMo 3 Translate** を使います。
インターネット上の翻訳サービスにプロンプトを送ることはありません。
> **事前に必要なもの**
> **Ollama** をインストールして起動しておきます(第10章 10-1)。翻訳モデルのダウンロードは、設定画面からできます(下記)。
### 準備:設定でオンにする
1. **設定** タブの **プロンプト翻訳(自国語 → 英語)** を開きます。
2. **生成UIでプロンプト翻訳を使う** にチェックを入れます。
3. **翻訳モデル** で、使うモデルを選びます。まだOllamaに入っていないモデルには **(未取得)** と付いています。選んで **ダウンロード** を押すと、Ollamaに取り込まれます。
4. **テスト** を押して、見本のプロンプトが英語になれば準備完了です。
PLaMo 3 Translate には4つの大きさがあります。
| モデル | 大きさ | 特徴 |
| --- | --- | --- |
| 0.8B | 約0.6GB | 最速。短いタグの翻訳なら十分 |
| 2B | 約1.8GB | おすすめ。文章の翻訳も正確 |
| 8B | 約5.3GB | より高品質 |
| 31B | 約19.5GB | 最高品質。メモリに余裕がある人向け |
> **ポイント**
> 0.8Bは、文章の翻訳で意味がずれることがあります(例:「カメラは後ろから追いかける」が「her camera following behind」=「彼女のカメラが後ろについてくる」になった)。
> 動画のプロンプトのように文章で書くことが多いなら、2B以上を選びましょう。
設定のほかの項目は、次のとおりです。
| 項目 | 内容 |
| --- | --- |
| 入力する言語 | ふつうは **自動判定** のままでよい。日本語だけで書くなら「日本語」を選ぶと確実 |
| Ollama URL | Ollamaのアドレス。空欄なら `http://localhost:11434` |
| 翻訳モデルの実行場所 | **GPU** か **CPUで常駐** か(下記) |
| 実行時に自動で翻訳する | Generateなどを押したときに自動で翻訳する(下記) |
PLaMo以外のOllamaのモデル(ふだんチャットに使っているモデルなど)も、**その他のOllamaモデル** から選べます。その場合は「英語に翻訳して」という指示を付けて送ります。
### 翻訳モデルをどこで動かすか
| 実行場所 | 1語句あたりの時間 | 向いている人 |
| --- | --- | --- |
| GPU(1回の翻訳が最速・VRAMを使う) | 約0.1秒 | GPUのメモリに余裕がある |
| CPUで常駐(VRAMを使わず、再読み込みの待ちなし) | 約0.2〜0.3秒 | 画像生成にGPUのメモリをすべて使いたい |
GPUのときは、**翻訳後に翻訳モデルをVRAMから解放する** をオンにしておくと、画像生成の前にGPUのメモリを空けられます(初期値はオン)。
ただし、翻訳のたびにモデルの読み込み直しで **約4秒** 待つことになります。
**CPUで常駐** にすると、モデルをメインメモリに置いたままにします(2Bで約2.7GB)。
GPUのメモリを使わず、生成UIにワークフローを読み込んだときに裏で読み込んでおくので、最初の翻訳から待たされません。
> **ポイント**
> Ollamaは、ほかのモデル(AI TOOLのチャット用など)を読み込むときに、常駐させた翻訳モデルを外すことがあります。
> その場合は、次の翻訳のときに自動で読み込み直します(その1回だけ数秒かかります)。
### 使い方:🌐ボタンで翻訳する
プロンプト翻訳をオンにすると、InputタブのPositive Prompt・Negative Promptの **↺** ボタンの右に **🌐** ボタンが表示されます。
1. プロンプト欄に、日本語で書きます。英語のタグと混ぜてもかまいません。
```
masterpiece, 夕焼けの海辺に立つ少女、(長い黒髪:1.2), <lora:test_lora:0.8>, {猫耳|狐耳}, 水彩画風
```
2. **🌐** を押します。
3. 日本語の部分だけが英語になります。
```
masterpiece, A girl standing by the seaside at sunset, (long black hair:1.2), <lora:test_lora:0.8>, {cat ears|fox ears}, watercolor style
```
次のようなプロンプトの書き方(記法)は、翻訳せずにそのまま残します。
- カンマ・改行
- 重み付け `(語句:1.2)`、`[ ]`
- ランダムに選ぶ `{A|B}`、ワイルドカード `__名前__`
- LoRAの指定 `<lora:名前:0.8>`、`embedding:名前`
- `BREAK`、`AND`
翻訳したあとに **原文** ボタンが表示されます。押すと、翻訳する前の文に戻ります(Ctrl+Zでも戻せます)。
> **注意**
> 翻訳されるのは、英数字以外の文字を含む部分だけです。英語だけの部分は、そのまま残ります。
> 反対に、é などのアクセント付きの文字を含む英単語は、翻訳の対象になります。
### 実行時に自動で翻訳する
設定の **実行時に自動で翻訳する** で、どの実行のときに自動で翻訳するかを、チェックボックスで選べます。
| チェックボックス | 動き |
| --- | --- |
| 生成UI - Generate | Generateを押すと、Positive/Negativeの欄の日本語を英語に置き換えてから生成する |
| 生成UI Lab - Run | Labの実行で、送る内容だけを翻訳する。Labのプランには日本語が残る |
| Video Plan - Run | Videoタブ Planの実行で、送るプロンプトだけを翻訳する。プランには日本語が残る |
LabとVideo Planでは、プランを日本語のまま残すので、あとから日本語で書き直せます。
生成した画像や動画の情報(メタデータ)には、実際に送った英語のプロンプトが記録されます。
> **注意**
> 自動翻訳がオンのときに翻訳に失敗すると(Ollamaが起動していないなど)、日本語のまま生成しないよう、生成を止めます。
> LabとVideo Planでは、止まった理由が進行状況の欄に表示されます。
### Labのモーダルと、Video Planでも使える
🌐ボタンは、次の欄にもあります。使い方は同じです。
- Lab(5-7)のプロンプト列のセルをダブルクリックして開く画面の、Positive・Negativeの欄
- Videoタブ Planサブタブの、ブロックの **Prompt** の欄(第11章 11-4)
> **ポイント**
> PLaMo 3 Translate は、個人の利用や趣味、研究などの非商用の利用なら無料で使えます(PLaMoコミュニティライセンス)。
> 商用で使う場合は、ライセンスの条件を確認してください。
> **この章(後半)のまとめ**
> - Batchサブタブで、モデル・プロンプト・サンプラーなどを1種類ずつ変えながらまとめて生成できる
> - Batch Queueの列のチェックで種類を選び、Generateで開始。終わったらチェックを外す
> - Feederは、たくさんの画像を1枚ずつワークフローに送り込む機能。専用ノードが必要
> - Labは、複数の設定を別々のタイミングで切り替えられる上級者向けの機能
> - パートナーAPIノード(Nano Bananaなど)は、`.env` の `COMFY_API_KEY` を設定すれば実行できる。クレジットが消費される
> - プロンプト翻訳をオンにすると、日本語で書いたプロンプトを🌐ボタンで英語にできる。記法はそのまま残り、Generate・Lab・Video Planの実行時に自動で翻訳することもできる
---
@@ -1945,6 +2087,10 @@ Workflow Studioにはたくさんのスタイルが付属しています。
英語のプロンプトの意味を知りたいときは、反対に **EN→JA** で日本語に訳せます。
> **ポイント**
> 生成UIのプロンプト欄で直接翻訳したいときは、第5章 5-10 の **プロンプト翻訳**(🌐ボタン)が便利です。重み付けやLoRAの指定を残したまま、日本語の部分だけを英語にできます。
> AI Assistantの翻訳にも、翻訳専用のモデル **PLaMo 3 Translate** を選べます(v0.9.9〜。以前は指示文まで翻訳されたり、ZH→ENで日本語が出たりしていました)。
### AIと相談しながらプロンプトを作る
入力欄に質問を書いて **Send**(または Enter キー)を押すと、AIとチャットできます。
@@ -1981,7 +2127,7 @@ Workflow Studioにはたくさんのスタイルが付属しています。
ComfyUIで生成した画像には、生成に使ったワークフローやプロンプトの情報(**メタデータ**)が埋め込まれています。
ギャラリータブでは、この情報を読み取って、同じ設定をすぐに再現できます。
また、動画(MP4・WebM)や音声ファイル(WAV・MP3・OGG・M4A・FLAC・Opus)も、画像と同じ一覧で扱えます。
また、動画(MP4・WebM)や音声ファイル(WAV・MP3・OGG・M4A・FLAC・Opus)、3Dモデル(GLB・glTF・VRM・PLY・SPZ)も、画像と同じ一覧で扱えます。
---
@@ -2272,6 +2418,30 @@ ComfyUIで音楽や効果音を作る機会が増えたため、ギャラリー
> **ポイント:Videoタブでの活用**
> Video の Asset サブタブでは、音声ファイルを「BGMに設定」したり、「サウンドとして追加」したりできます(第11章 11-4)。
---
## 8-8 3Dモデルを見る(v0.9.4〜)
ComfyUIで3Dモデルを作るワークフロー(画像から3Dなど)の結果も、ギャラリーで確かめられます。
対応しているのは、GLB・glTF・VRM・PLY(メッシュ/点群/ガウシアンスプラット)・SPZ です。
- 一覧には「**3D**」のバッジ付きで並びます。サムネイルは、最初に一覧に出たときにブラウザが描いてサーバーに保存します
(128MBを超えるファイルは、開いたときに保存します)。
- 選ぶと、右の詳細パネルの内蔵ビューアで立体として表示されます。ダブルクリックで大きく表示できます。
| 操作 | 動き |
| --- | --- |
| ドラッグ | 回転する |
| 右ドラッグ | 位置を動かす |
| マウスホイール | 拡大・縮小 |
| ⟲(リセット)ボタン | 最初の向きに戻す |
- ComfyUIの **SaveGLB** で保存したモデルは、画像と同じようにワークフローを読み取れます(8-2・8-3)。
> **注意**
> - 3Dファイルは、Image Edit・生成UI・Tagger・Feederには送れません。
> - `.gltf` の中には、別の `.bin` や画像ファイルを参照しているものがあります。ギャラリーで移動・削除しても動くのは `.gltf` 本体だけなので、参照しているファイルの場所は変えないでください。
> **この章のまとめ**
> - ギャラリーのOutputで、生成した画像をフォルダごとに見返せる。プロンプトの言葉でも検索できる
> - 詳細パネルのプロンプトタブで、画像の生成に使ったプロンプトがすぐ分かる
@@ -2280,6 +2450,7 @@ ComfyUIで音楽や効果音を作る機会が増えたため、ギャラリー
> - メタデータサブタブに画像をドロップすると、モデル・LoRA・プロンプトを詳しく調べられる
> - Sボタンで、文章の意味や「似た画像」から探せる(セマンティック検索)
> - 音声ファイルも一覧・再生・変換できる
> - 3Dモデル(GLB・glTF・VRM・PLY・SPZ)も、ギャラリーで回して確かめられる(8-8)
---
@@ -2466,6 +2637,9 @@ Workflow Studioは、パソコンの中で動く **ローカルAI(大規模言
- AIとチャットしながら、プロンプトのアイデアを出してもらう
- 画像を見せて、その画像の説明やプロンプト、タグを作ってもらう
- ワイルドカード用の候補リストを作ってもらう
- **スキル** を選んで、プロンプト作り・ストーリーボード・不具合の相談など、得意分野を切り替える(v0.9.5〜)
- 生成した画像が依頼どおりかをAIにチェックさせて、足りない点だけ直す(v0.9.5〜)
- 画像に写っている文字を読み取る(OCR、v0.9.5〜)
インターネット上のサービスではなく、自分のパソコンの中で動くので、
**入力した内容や画像が外部に送られない** のが大きな特長です。
@@ -2528,10 +2702,14 @@ Workflow Studio本体の **AI TOOL** タブを開きます。
| 部分 | できること |
| --- | --- |
| 翻訳 | 日本語・英語・中国語などの翻訳 |
| Chat | AIとの会話。条件がそろえば、会話から画像生成も |
| TOOLS | 画像の読み取り(VLM)、ワイルドカード作成 |
| Chat | AIとの会話。スキルで得意分野を切り替えられる。条件がそろえば、会話から画像生成も |
| TOOLS | 画像の読み取り(VLM)、文字起こし(OCR)、ワイルドカード作成 |
| 設定 | 使うAIソフト・モデルの設定 |
> **ポイント:翻訳と設定はたためる(v0.9.5〜)**
> 翻訳と設定の見出しの右端にある矢印(◀/▶)を押すと、その部分が細い帯にたたまれ、空いた幅をChatとTOOLSが使います。
> 帯のどこかをクリックすると元に戻ります。たたんだ状態は、次に開いたときも保たれます。
### 最初に:設定でAIソフトとつなぐ
1. **設定** の **バックエンド** で、使うソフト(例:Ollama)を選びます。
2. **接続設定** のアドレスを確認します。Ollamaを標準のまま使っている場合は、変更不要です。
@@ -2555,10 +2733,18 @@ Workflow Studio本体の **AI TOOL** タブを開きます。
2. 入力欄に文章を書き、**翻訳** を押します。
3. 結果を **コピー** して、生成UIやプリセットに貼り付けます。
> **ポイント**
> TOOLSで読み取った文字(10-8のOCRなど)は、TOOLSの **翻訳へ送る** で、この入力欄にそのまま入れられます。
> **ポイント**
> 小さなモデルは、翻訳せずに元の文章をそのまま返してしまうことがあります。
> その場合は「モデルが原文をそのまま返しました」と表示されるので、別のモデルを試してください。
> **ポイント**
> 翻訳専用のモデル **PLaMo 3 Translate**(第5章 5-10)を、設定のモデルに選ぶこともできます(v0.9.9〜)。
> 日本語・英語・中国語のほか、Free(自由入力)では French・フランス語・français のような言語名で、PLaMoが対応する言語を指定できます。PLaMoが対応していない言語(ポルトガル語など)を翻訳先にすると、エラーになります。
> WS LibraryのAタブの翻訳も同じです。
### Chat
入力欄に話しかけて、**Enter** で送信します(**Shift+Enter** で改行)。
会話の流れを覚えているので、「もっと明るい雰囲気にして」のような続けての依頼もできます。
@@ -2569,6 +2755,10 @@ Workflow Studio本体の **AI TOOL** タブを開きます。
> チャットで「猫の絵を描いて」と頼むだけで、生成UIに読み込んだワークフローで画像が生成され、チャット内に表示されます。
> この機能は、入力欄の横の **画像生成を許可する** のチェックでオン・オフできます。
> **ポイント**
> Chatの上にあるドロップダウンで **スキル** を選ぶと、AIの得意分野を切り替えられます(10-5)。
> AIの返事は、見出し・箇条書き・コードの枠を整えて表示されます(v0.9.5〜)。
### TOOLS - 画像を読み取る(VLM)
画像入力に対応したモデル(VLM)を使うと、画像の内容をAIに読み取らせることができます。
@@ -2581,8 +2771,16 @@ Workflow Studio本体の **AI TOOL** タブを開きます。
| プロンプト作成 | 画像を再現するためのプロンプトを作る |
| Create tags(英語表示のまま) | 画像の要素をタグ形式で書き出す |
| Create wildcards(英語表示のまま) | カテゴリー名と件数を指定して、ワイルドカードの候補を作る(画像は不要) |
| 文字起こし(OCR) | 画像に写っている文字を読み取る(10-8) |
3. **実行** を押します。結果はコピーして使えます。
3. **実行** を押します。
4. 結果の下のボタンで、結果を使います(v0.9.5〜)。
| ボタン | 動き |
| --- | --- |
| 翻訳へ送る | 翻訳の入力欄に入れる(翻訳がたたまれていれば開く) |
| Chatへ送る | Chatの入力欄に追加する |
| コピー | クリップボードにコピーする |
> **例**
> 気に入ったイラストの雰囲気をまねしたいとき、その画像から「プロンプト作成」をして、
@@ -2649,12 +2847,230 @@ ComfyUI(とWorkflow Studio)にアクセスできるようになります。
> `--listen` は、家庭内LANなど **信頼できるネットワークでだけ** 使ってください。
> カフェや公共のWi-Fiでは使わないようにしましょう。
---
## 10-5 スキル - Chatの得意分野を切り替える(v0.9.5〜)
**スキル** は、Chatに「どんな役割で、どんな形で答えるか」を教える指示書です。
Chatの上のドロップダウン(最初は「-- スキルなし --」)で選ぶと、そのスキルの指示が毎回の会話に付けて送られます
(指示の文章はチャットの画面には表示されません)。
### 最初から入っているスキル
Workflow Studioには、次の6つのスキルが入っています(名前は英語表示のままです)。
| スキル | 何をするか | 結果の使い方 |
| --- | --- | --- |
| T2I Prompt Enhancer | 短いアイデアを、生成UIのワークフローのモデルに合った書き方のプロンプトにする | プロンプトの下のボタン |
| Image to Prompt | TOOLSに入れた画像を再現するプロンプトを書く(画像を読み取れるモデルが必要) | プロンプトの下のボタン |
| Storyboard to Lab | 物語をシーンごとのプロンプトに分け、Labで連続生成できる形にする | **Labで開く** |
| Workflow Doctor | ワークフローの説明や、エラーの原因の相談にのる(10-7) | 文章で答える |
| SVG Icon Generator | 簡単なアイコンやイラストをSVG(ベクター画像)で描く | プレビューと **Galleryに保存** |
| Skill Creator | 質問に答えていくと、新しいスキルを作ってくれる(10-9) | **スキルとして保存** |
### プロンプトを作って、そのまま生成する(T2I Prompt Enhancer)
1. 生成UIに、使うワークフローを読み込みます。スキルはこのワークフローのモデルを見て、プロンプトの書き方を決めます。
2. AI TOOLのChatで、ドロップダウンから **T2I Prompt Enhancer** を選びます。
3. 「雨の夜の東京、ネオン、傘を持つ猫」のように、日本語で作りたい絵を書いて送信します。
4. 返事に、選んだ書き方(`Style:` の行)と、英語のプロンプトの枠が表示されます。その下のボタンで使います。
| ボタン | 動き |
| --- | --- |
| GenerateUIに反映 | 生成UIのポジティブ/ネガティブの欄に書き込む |
| このプロンプトで生成 | その場で生成し、チャットに画像を表示する |
| コピー | ポジティブプロンプトをコピーする |
モデルに合わせた書き方は、次のとおりです。
| 生成UIのモデル | プロンプトの書き方 |
| --- | --- |
| Qwen-Image、FLUX、Z-Image など | 英語の文章(ネガティブは、CFGが1前後なら空にする) |
| Illustrious、NoobAI、Pony など(SDXLのアニメ系) | Danbooruのタグ(品質タグから始める) |
| 写実系のSDXL、SD1.5 | 短い言葉をカンマで並べる |
> **ポイント**
> 「もっと夜らしく」「猫を2匹に」のように続けて頼むと、直したプロンプト全体を出し直します。
> **ポイント:今入っているプロンプトは渡さない**
> 生成UIに今入っているプロンプトは、ふだんはAIに渡しません。渡すと、小さなモデルが古いネガティブプロンプトなどを新しいプロンプトに混ぜてしまうためです。
> 「**今のプロンプトを改善して**」のように、今のプロンプトに触れて頼んだときだけ渡します。
### ストーリーボードから連続生成する(Storyboard to Lab)
1. 生成UIに、文章から画像を作る(T2I)ワークフローを読み込みます。
2. Chatで **Storyboard to Lab** を選び、「茶トラの子猫が朝目覚めて、庭で蝶を追いかけ、夕方に縁側で昼寝する。3シーンで」のように頼みます。
3. 返事に、シーンの一覧と **Labで開く(3シーン)** ボタンが表示されます。ボタンを押します。
4. 生成UIの **Lab**(第5章 5-7)が開き、まだ保存していないプランとして読み込まれます。
T2Iモードになり、Batchがシーンの数に、Prompt列がシーンごとのキーフレームになります。KSampler列には、全シーン共通のシード(`Seed …`)が入ります。
5. 内容を確かめて **Run** を押します。残したいときは **Plan Save** で保存します。
> **ポイント**
> 登場人物の見た目(髪・服の色など)は、全シーンで同じ文章が入るように書かれ、シードも固定されます。
> そのため、シーンが変わっても同じキャラクターに見えやすくなります。
### 返事の自動チェック
プロンプトやSVGを出すスキルでは、Workflow Studioが返事の形を自動で確かめます。
プロンプトの枠が崩れている、SVGが閉じていない、といった問題があると、
点線の枠で「**自動チェック:…**」と表示し、AIに1回だけ直させます。
説明だけを頼んだときなど、プロンプトやSVGを出していない返事はそのままにします。
### スキルの管理(鉛筆ボタン)
ドロップダウンの右の鉛筆ボタンで、スキルの一覧が開きます。
- **+ 新規** で新しいスキルを書く、各行の鉛筆ボタンで編集・削除する、**取り込み** で他のスキルを追加する(10-9)
- 最初から入っているスキルには **同梱** と表示されます。
編集していない同梱スキルは、Workflow Studioを更新すると自動で新しい版になります。
編集したスキルは自動では置き換わらず、新しい版があると **↻(更新)** ボタンが表示されます。
- スキルのファイルは `ComfyUI/user/default/Workflow-Studio/ai_skills/` に保存されます。
> **注意**
> ↻(更新)で新しい版に置き換えると、そのスキルに加えた編集は消えます。
---
## 10-6 生成した画像をチェックして直す(v0.9.5〜)
チャットから生成した画像が、頼んだとおりになっているかをAIに確かめさせる機能です。
足りないところがあれば、その点だけを直したプロンプトで描き直せます。
### 準備:判定用のモデル
チェックには、ふつうのチャット用モデルではなく、Ollamaの **意思決定モデル**(はい/いいえを確率で答えるモデル)を使います。
画像を読み取れるもの(作者の環境では `d3:4b`、`clef-flash`、`clef` で動作を確認)を、`ollama pull` で用意します。
> **ポイント:なぜ専用のモデルを使うのか**
> 作者の検証では、チャット用のモデルに画像を見せて「剣を持っているか」と聞くと、持っていないのに「はい」と答えることがありました。
> 意思決定モデルは「はい」の確率を数字で返すので、あいまいな答えを見分けられます。
1. AI TOOLの **設定** にある **CHAT 画像チェック** で、**判定モデル(Ollamaの意思決定モデル)** を選びます(一覧が空なら **更新**)。
2. **自動修正の回数** を選びます。最初は **0(ボタンで修正)** がおすすめです。
3. **設定を保存** を押します。
### 使い方
1. Chatの入力欄の下にある **画像をチェック** にチェックを入れます。
2. チャットから画像を生成します(AIの画像生成、または **このプロンプトで生成**)。
3. 画像の下に結果のカードが表示されます。AIが頼んだ内容を3〜8個の確認項目に分け、1つずつ確かめた結果です。
| 表示 | 意味 |
| --- | --- |
| ✔(満たしている) | 「はい」の確率が85%以上 |
| ?(はっきりしない) | 30〜85% |
| ✘(満たしていない) | 30%未満 |
4. ✘や?があるときは **足りない点を直して再生成** を押します。満たしていない項目だけをAIに伝え、プロンプトを書き直して描き直します。
自動修正の回数を1〜3にすると、ボタンを押さなくても、その回数まで自動でくり返します。
> **ポイント:SVGもチェックできる**
> SVG Icon Generatorで描いたSVGも、画像にしてから「頼んだものに見えるか」「部品(くちばし・翼など)が描けているか」をチェックします。
> **分かりにくい部分を描き直させる** で直させられます。
> **注意**
> - チェックは完ぺきではありません。とくに「誰が何を身につけているか」の取り違えに弱いため、
> 人物が複数いるときは「帽子は女の子ではない」のような逆向きの確認項目を自動で加えて補っています。
> - 描き直しの上手さは、チャット用モデルの力しだいです。直らないときは、頼み方を変えるか、モデルを変えてください。
> - 判定モデルもGPUのメモリを使います(`d3:4b` で約6GB)。読み込んだあとは、1回のチェックが数秒です。
---
## 10-7 ワークフローの不具合を相談する(Workflow Doctor、v0.9.5〜)
**Workflow Doctor** は、生成UIに読み込んだワークフローの説明や、エラーの原因の相談にのるスキルです。
AIの知識だけに頼らず、送信するたびにWorkflow Studioが実際に確かめた次の内容をAIに渡します。
| 確かめる内容 | 例 |
| --- | --- |
| インストールされていないノード | ComfyUIが知らないノードの名前 |
| ComfyUIの一覧に無いファイル・設定値 | 見つからないモデルやLoRA(似た名前の候補も) |
| 線のつながり | つながっていない入力、存在しないノードへの線 |
| 直近の実行エラー | ComfyUIの履歴に残ったエラーの内容 |
| ComfyUIのログ | ログに出た最新のエラーの部分 |
### 使い方
1. 相談したいワークフローを生成UIに読み込みます(エラーの相談なら、一度実行してエラーを出しておきます)。
2. Chatで **Workflow Doctor** を選びます。
3. 「実行する前に問題がないか確認して」「さっきのエラーの原因は?」のように聞きます。
> **例**
> LoRAのファイルを別のフォルダに移したワークフローで聞くと、
> 「`temp\` のフォルダに指定されたファイルが見つからない。`Illustrious\` に同じ名前のファイルがある」と、直し方まで答えました。
> **ポイント**
> 確かめる内容は、送信のたびに作り直されます。直したあとは、もう一度聞いてみてください。
---
## 10-8 画像の文字を読み取る(OCR、v0.9.5〜)
TOOLSで、画像に写っている文字を読み取れます。読み取った文字は、そのまま翻訳やChatに送れます。
### 準備:OCR用のモデル
OCRには、チャット用とは別の、文字を読むのが得意なモデルを使います。Ollamaで用意してください。
作者の環境で、横書きと縦書きの日本語・英語がまじった画像を読ませた結果は次のとおりです。
| モデル | 時間 | 読み取り |
| --- | --- | --- |
| LightOnOCR-3(`maternion/LightOnOCR-3:4b`) | 約1秒(位置つきは約6〜8秒) | すべて読めた |
| PaddleOCR-VL(マンガ向けの版) | 約4秒 | すべて読めた |
| DeepSeek-OCR系 | 約14秒 | すべて読めた(いつも位置つき) |
| PaddleOCR-VL 1.6、GLM-OCR | 約11〜15秒 | 縦書きを読み落とした |
### 使い方
1. TOOLSに画像をドロップします。
2. 作業で **文字起こし(OCR)** を選びます。
3. **OCRモデル** を選びます。名前に「ocr」を含むOllamaのモデルが、向いている順に並びます(一覧が空なら ↻ を押します)。
4. **実行** を押します。読み取った文字が、結果の欄に1行ずつ表示されます。
> **ポイント:文字の位置を表示**
> **文字の位置を表示** にチェックを入れると、画像の上に番号つきの枠が重なり、どこの文字かが分かります。
> 枠をクリックすると、結果の欄の同じ行が選ばれます。
> 位置を返せるのは LightOnOCR と DeepSeek-OCR系だけです。ほかのモデルでは、このチェックは選べません。
> **ポイント**
> 結果が空だったり、同じ行がくり返されたりしたときは、自動で白黒(グレースケール)にして1回だけ読み直します。
---
## 10-9 スキルを自作・取り込む(上級、v0.9.5〜)
### Skill Creatorで作る
Chatで **Skill Creator** を選び、「〇〇が得意なスキルを作りたい」と話しかけます。
AIが1つずつ質問してくるので答えていくと、スキルの下書きができます。
返事の下の **スキルとして保存** を押すと、スキルの一覧に下書きが入った状態で開くので、確かめて保存します。
「このスキルの、ここがうまくいかない」と相談して、今あるスキルを直してもらうこともできます。
### スキルのファイルの中身
スキルは、テキストファイル(`.md`)です。先頭の `---` で囲んだ部分に名前と説明を書き、その下にAIへの指示を書きます。
先頭の部分の `metadata:` には、次の設定も書けます(書かなくてもかまいません)。
| 設定 | 意味 |
| --- | --- |
| `output` | `prompt` か `svg`。返事の形を自動でチェックし、ボタンを付ける |
| `tools` | `[]` にすると、AIが自分で画像生成を始めない |
| `temperature` | 答えのばらつき(0.3なら安定、0.9なら自由) |
| `think` | 考える(Thinking)モードを、このスキルだけオン/オフにする |
| `context` | AIに渡す情報。`workflow`(ワークフローの要約)、`current-prompt`(今のプロンプト)、`workflow-detail`/`logs`(Workflow Doctorと同じ確認内容) |
### ほかのスキルを取り込む
スキルの一覧の **取り込み** で、次のファイルを追加できます。
- `.md` のスキル1つ
- `SKILL.md` を含むフォルダをZIPにしたもの(**Agent Skills** という、多くのAIツールで共通の形式)
フォルダの中のテキストファイル(参考資料など)も一緒に取り込まれ、AIが必要になったときだけ読みに行きます
(ツール呼び出しに対応したモデルが必要です)。
> **注意**
> - 取り込むのはテキストファイルだけです。スクリプトなどのプログラムは取り込まず、実行もしません。
> - スキルの指示は、そのままAIに渡されます。他の人が作ったスキルは、中身を読んでから使ってください。
> **この章のまとめ**
> - ローカルAI(Ollamaなど)を用意すると、翻訳・チャット・画像の読み取りができる。入力内容は外部に送られない
> - AI TOOLタブの設定で、バックエンド・アドレス・モデルを選び、接続テストをする
> - プロンプトタブとTaggerタブには、別に歯車ボタンの設定がある
> - AIと画像生成はVRAMを取り合う。「モデルをアンロード」や「VRAM調整(Ollama)」で解放する
> - 標準では自分のパソコンのAIにだけつながる。`--listen` は信頼できるネットワークだけで
> - **スキル** で得意分野を切り替える。T2I Prompt Enhancer でプロンプトを作り、ボタンで生成UIに反映・生成できる
> - **画像をチェック** をオンにすると、意思決定モデルが生成画像を確かめ、足りない点だけ直して描き直せる
> - Workflow Doctor は、実際に確かめた事実をもとにワークフローの不具合を相談にのる
> - TOOLSの **文字起こし(OCR)** で画像の文字を読み取り、翻訳やChatへ送れる
---
@@ -2763,6 +3179,22 @@ Taggerを使うには、次の準備が必要です。
- 編集した画像は、**Save PNG**(ダウンロード)、**Save to Gallery**(ギャラリーに保存)などで保存します。
- **Ctrl+Z** で元に戻す、**Ctrl+Y** でやり直しができます。
### Drawの色とショートカット(v0.9.3〜)
**Draw** を選ぶと、ツールの2段目に **カラーパレット** が表示されます。
- **色1/色2**、基本色20色、カスタム色20枠が並びます。色をクリックすると、その色で描けます。
- **+** か空いている枠をクリックすると、今の色をカスタム色に登録します。色の上で右クリックすると、登録・編集・削除ができます(基本色も変えられ、最初の色に戻せます)。
登録した色は、ブラウザごとに保存されます。
- 右側の **Color** の隣にある **スポイト** ボタンで、キャンバスの色を拾えます(Escで取り消し)。
- 描き始めの色は黒(色1)と白(色2)です。
| キー(Draw中) | 動き |
| --- | --- |
| D/E | 描く(Draw)/消す(Erase) |
| X | 色1と色2を入れ替える |
| [ / ] | ブラシを小さく/大きくする(実際は半角の `[` `]`) |
| B | ブラシの選択を開く・閉じる(Escでも閉じる) |
### インペイント(部分の描き直し)
Image Editのいちばん便利な使い方が、**インペイント** です。
「顔だけ描き直したい」「手が崩れたところだけ直したい」というときに使います。
@@ -2799,6 +3231,14 @@ Image Editのいちばん便利な使い方が、**インペイント** です
そのほか、動画の好きな場面を静止画として保存する **Frame** や、動画をGIFアニメに変換する **GIF** の機能もあります。
> **ポイント**
> Planサブタブのブロックの **Prompt** の欄にも、プロンプト翻訳の **🌐** ボタンがあります(第5章 5-10)。
> 設定の **Video Plan - Run** をオンにすると、日本語のプロンプトのまま実行して、送る内容だけを英語にできます。
> **注意**
> v0.9.8までは、新しいComfyUIで保存したワークフローを使うと、Planで入力したプロンプト・長さ(Duration)・Turboの設定が反映されず、ワークフローに保存されている値のまま生成されていました(v0.9.9で修正)。
> 以前と同じPlanを実行しても、Planの値が反映されるようになったため、結果が変わることがあります。
### アセット登録と音声変換(v0.8.9〜)
- **アセット登録** - 左側の動画ソースパネルのボタンです。パソコン内の動画を、outputフォルダ(`output/video`)へコピーして「Video Assets」グループに登録します。
登録すると、Assetサブタブの一覧に出て、Editなどで使えるようになります。
@@ -2849,6 +3289,7 @@ Image Editのいちばん便利な使い方が、**インペイント** です
| CivitAI APIキー | Civitaiの情報取得用(省略可) | 第6章 |
| Eagle 連携 (オプション) | 生成画像をEagleに自動保存 | 第8章 |
| VRAM調整(Ollama) | 生成前にAIモデルをメモリから降ろす | 第10章 |
| プロンプト翻訳(自国語 → 英語) | 日本語のプロンプトを🌐ボタンや実行時の自動翻訳で英語にする | 第5章 5-10 |
| データ管理 | 設定やデータのバックアップ・復元 | 下記 |
### デフォルトワークフロー
@@ -3072,6 +3513,7 @@ Workflow Studioを更新(アップデート)したあとは、必ずComfyUI
### 設定を変えたのに、結果が変わらない
いちばん多い原因は、**Apply の押し忘れ** です。
生成UIでは、モデルやSettings(ステップ数・サイズなど)の値を変えたあと、**Apply** を押さないとワークフローに反映されません(第5章 5-3)。
ただし、Settingsタブの右端のスイッチの列は、クリックした時点で反映されます(第5章 5-4)。
右側の **Raw JSON** を見ると、実際に反映されている値を確認できます。
### 読み込んだワークフローとは違う内容で生成される
@@ -3087,6 +3529,15 @@ Batchサブタブを開き、Batch Queueの列のチェックをすべてオフ
いつも同じモデルを使いたい場合は、設定タブの **デフォルトCheckpoint** を使うと便利です(第11章 11-5)。
### プロンプト翻訳の🌐ボタンが出ない・翻訳できない
| 症状 | 原因 | 対処 |
| --- | --- | --- |
| 🌐ボタンが表示されない | プロンプト翻訳がオフになっている | 設定タブの **プロンプト翻訳(自国語 → 英語)** で **生成UIでプロンプト翻訳を使う** にチェックを入れる(第5章 5-10) |
| 「翻訳エラー」と出る | Ollamaが起動していない、または翻訳モデルがOllamaに無い | Ollamaを起動する。設定の **翻訳モデル** に **(未取得)** と出ていれば **ダウンロード** を押す |
| 押しても何も変わらない(「翻訳する部分がありません」) | 英語(英数字)だけのプロンプトになっている | 翻訳されるのは英数字以外の文字を含む部分だけ。英語の部分はそのまま残る |
| 自動翻訳がオンのとき、生成が始まらない | 翻訳に失敗したので、日本語のまま生成しないよう止めた | 上の「翻訳エラー」と同じ対処をする。LabとVideo Planでは、理由が進行状況の欄に出る |
| 訳がおかしい | 小さいモデル(0.8B)は、文章で意味がずれることがある | 設定の **翻訳モデル** で2B以上を選ぶ |
### 同じ設定なのに、同じ画像にならない
生成パネルのシードのモードが **Random** になっていませんか?
同じ画像を作るには、シードを **Workflow**(ワークフローのシードをそのまま使う)か **Fixed**(Seed欄の値で固定)にする必要があります。
@@ -3135,6 +3586,21 @@ Ollamaの場合は `ollama pull (モデル名)` でモデルをダウンロ
安全のため、標準では同じパソコンの中のAIソフトにしかつながりません。
環境変数 `WFS_ALLOWED_BACKEND_HOSTS` の設定が必要です(第10章 10-4)。
### 画像チェックの判定モデルや、OCRモデルが一覧に出てこない
- 判定モデルの一覧には、Ollamaの **意思決定モデル** のうち、画像を読み取れるものだけが出ます。
ふつうのチャット用モデルは出ません。Ollamaを新しい版に更新し、意思決定モデルを `ollama pull` してから **更新** を押します(第10章 10-6)。
- OCRモデルの一覧には、名前に「ocr」を含むOllamaのモデルだけが出ます。取得後に ↻ を押します(第10章 10-8)。
- どちらも、AI TOOLのバックエンドがOllamaならそのアドレス、そうでなければ `http://localhost:11434` のOllamaを見に行きます。
### 画像チェックで、何度直しても満たされない
- 描き直しの上手さは、チャット用モデルの力しだいです。頼み方を短く具体的にするか、別のモデルを試してください。
- チェック自体もまちがえることがあります。画像を自分の目でも確かめてください。
- 自動修正の回数を上げすぎると、生成の時間とGPUのメモリを使い続けます。最初は「0(ボタンで修正)」がおすすめです。
### AIがスキルの資料を読まない・チャットから画像を生成しない
取り込んだスキルの参考資料を読む機能と、チャットからの画像生成は、
**ツール呼び出し(Tool Calling)に対応したモデル** でないと動きません。対応しているモデルに切り替えてください。
---
## 12-5 そのほかの機能のトラブル
@@ -3172,6 +3638,15 @@ ComfyUIを停止し、ComfyUIのPythonで `pip uninstall -y onnxruntime onnxrunt
`.env` にComfy APIキーが無いのが原因です。プラグインの `.env` に `COMFY_API_KEY=キー`(platform.comfy.orgで発行)を書き、ComfyUIを再起動してください(第5章 5-8)。
`.env` は起動時にしか読み込まれません。
### ComfyUIが固まる(どのタブも反応しなくなる)
Windowsで、プレビュー画像の多いモデルタブの一覧を切り替えたあとなどに、ComfyUIが反応しなくなる(生成もできなくなる)場合があります。
設定タブの **Windowsの安定性(イベントループ)** で、**WindowsでSelectorイベントループを使用する** をオンにして、ComfyUIを再起動してください。
### ギャラリーの画像の一部が、別の画像のように壊れて見える
上の **Selectorイベントループ** をオンにしているとき、v0.9.1までは、ギャラリーのプレビューや Download で受け取った画像の一部が壊れることがありました
(出力フォルダのファイル自体は正常です)。v0.9.2で直っています。
Workflow Studioを更新したあと、壊れた画像がブラウザに残っていることがあるので、**Ctrl+F5** で再読み込みしてください。
### ギャラリーに画像が出てこない
- ギャラリーの **Refresh** を押します。
- 設定タブの「ギャラリー Outputフォルダ」が、ComfyUIの画像保存先と合っているか確認します。
@@ -3215,6 +3690,7 @@ Workflow Studioの **ヘルプ** タブにも、トラブルシューティン
### 日本語
| 用語 | 意味 | 本書 |
| --- | --- | --- |
| 意思決定モデル | 質問に「はい」の確率などを数字で答えるAIモデル。画像チェックの判定に使う | 第10章 |
| インペイント | 画像の一部(マスクした部分)だけを描き直すこと | 第11章 |
| カスタムノード | ComfyUIに後から追加するノード・拡張機能。Workflow Studioもその1つ | 第1章 |
| キャンバス | ComfyUIのノード画面で、ノードを並べる作業スペース | 第3章 |
@@ -3223,6 +3699,7 @@ Workflow Studioの **ヘルプ** タブにも、トラブルシューティン
| サンプラー | 画像を描くときのアルゴリズム(euler など) | 第5章 |
| シード | 画像のもとになる乱数の種。同じなら、ほぼ同じ画像になる | 第5章 |
| セマンティック検索 | 文章や画像の「意味」で画像を探す検索。ギャラリーのSボタンで使う | 第8章 |
| スキル | AI TOOLのChatに、役割や答え方を教える指示書。選ぶと得意分野が切り替わる | 第10章 |
| スケジューラー | ステップごとの描き込み量の配分のしかた | 第5章 |
| スタイル | プロンプトに付け足す雰囲気のテンプレート | 第7章 |
| ステップ数 | 描き込みをくり返す回数 | 第5章 |
@@ -3258,7 +3735,9 @@ Workflow Studioの **ヘルプ** タブにも、トラブルシューティン
| I2I(Image to Image) | 画像をもとに、新しい画像を作ること | 第5章 |
| JSON | ワークフローの保存に使われるデータ形式 | 第1章 |
| LoRA | 絵柄やキャラクターなどを追加で覚えさせる小さなモデル | 第6章 |
| OCR | 画像に写っている文字を読み取ること | 第10章 |
| Ollama | ローカルAIを手軽に動かせるソフト | 第10章 |
| PLaMo 3 Translate | Preferred Networks(PFN)の翻訳専用AIモデル。プロンプト翻訳で使う | 第5章 |
| T2I(Text to Image) | 文章(プロンプト)から画像を作ること | 第5章 |
| TagSpace | タグ・プロンプト・生成画像を意味の近さで3Dの空間に並べて表示するタブ | 第11章 |
| VAE | 画像の色合いや細部を仕上げるモデル | 第6章 |
@@ -3308,6 +3787,10 @@ Workflow Studioの **ヘルプ** タブにも、トラブルシューティン
| マウスホイール | 拡大・縮小 |
| Space+ドラッグ | 表示位置を移動する |
| Delete | 選んでいるレイヤーを削除する(レイヤーが2つ以上あるとき) |
| D/E(Draw中) | 描く/消す |
| X(Draw中) | 色1と色2を入れ替える |
| [/](Draw中) | ブラシを小さく/大きくする(実際は半角の `[` `]`) |
| B(Draw中) | ブラシの選択を開く・閉じる |
---
@@ -3328,6 +3811,7 @@ Workflow Studioの **ヘルプ** タブにも、トラブルシューティン
| --- | --- | --- |
| Civitai(https://civitai.com/) | モデルの入手・情報取得 | 第6章 |
| Ollama(https://ollama.com/) | ローカルAI | 第10章 |
| PLaMo 3 Translate(https://huggingface.co/pfnet/plamo-3-translate-2b-GGUF) | プロンプト翻訳の翻訳モデル | 第5章 |
| LM Studio(https://lmstudio.ai/) | ローカルAI | 第10章 |
| Lemonade Server(https://lemonade-server.ai/) | ローカルAI | 第10章 |
| Eagle(https://eagle.cool/) | 画像管理ソフト | 第8章 |
Binary file not shown.
+1 -1
View File
@@ -129,7 +129,7 @@ ComfyUIの「自由さ」はそのままに、「分かりやすさ」と「手
## 本書の対象バージョンと環境
- **Workflow Studio**:v0.9.1
- **Workflow Studio**:v0.9.9
- **ComfyUI**:本書執筆時点の最新版
- **OS**:Windows(画面の例はWindowsのものです)
@@ -27,7 +27,7 @@ Workflow Studioを開くと、画面の上部にタブが横一列に並んで
| TagSpace | TagSpace | タグ・プロンプト・生成画像を意味の近さで3D表示し、タグを選ぶ | | 第11章 |
| 設定 | Settings | 言語・テーマ・フォルダなどの設定 | | 本章・第11章 |
| ヘルプ | Help | 機能一覧・ショートカット・トラブル対処 | | 本章 |
| AI TOOL | AI TOOL | ローカルAIによる翻訳・チャット・画像解析 | | 第10章 |
| AI TOOL | AI TOOL | ローカルAIによる翻訳・チャット・画像解析・文字起こし(OCR) | | 第10章 |
### タブは「整理する」「作る」「補助する」の3グループで考える
タブが多くて迷ったときは、次の3つのグループに分けて考えると分かりやすくなります。
@@ -168,12 +168,13 @@ Inputサブタブでは、Raw JSONの上端にある **»** ボタンで、Raw J
1枚目が生成できたら、次は **Settings** サブタブで、画像の仕上がりを左右する設定を見てみましょう。
Settingsタブは、左右2つのブロックに分かれています。
Settingsタブは、3つの列に分かれています。
- **KSampler(左)** - 画像をどのように描くかの設定
- **Latent Image(右)** - 画像の大きさと枚数の設定
- **Latent Image(中央)** - 画像の大きさと枚数の設定
- **スイッチ(右、v0.9.6〜)** - ワークフローの中のオン・オフの切り替え
ここでも、値を変えたら各ブロックの **Apply** を押すのを忘れないようにしましょう。
ここでも、KSamplerとLatent Imageは、値を変えたら各ブロックの **Apply** を押すのを忘れないようにしましょう(スイッチの列はApply不要です)。
### KSampler の項目
| 項目 | 意味 | 初心者向けの目安 |
@@ -200,6 +201,23 @@ Settingsタブは、左右2つのブロックに分かれています。
> モデルが学習したサイズから大きく外れると、人物が二重になったり、構図が崩れたりしやすくなります。
> 縦長・横長にしたいときも、合計のピクセル数がおおよそ同じになるように調整しましょう(例:SDXLなら 832×1216 など)。
### スイッチの項目(v0.9.6〜)
ワークフローの中にある「オン・オフ」の設定が、ノード名と項目名つきで一覧になります。
チェックボックスをクリックすると、その場で切り替わります。**Apply を押す必要はありません**。切り替えた値は右側の Raw JSON にもすぐ反映されます。
一覧に出るのは、次の2種類です。
- 値が true/false の項目 - プロンプト強化(PE)のオン・オフを切り替えるスイッチや「Boolean」ノード、TextGenerate の thinking など
- 選択肢が2つだけのオン・オフの項目 - enable/disable、on/off、yes/no など。KSamplerAdvanced の add_noise、DWPreprocessor の detect_hand(手を検出するか)など
各行の右端には、いまの値(true/false、enable/disable など)が表示されます。
行にマウスを乗せると、ノードの番号と種類を確認できます。
> **ポイント**
> 別のノードから線でつながっている項目は、一覧に出ません。代わりに、つながっている元のノード(たとえば「Enable PE?」という名前の Boolean ノード)が出るので、そちらを切り替えてください。
> ノードに名前を付けていないワークフローでは、ノードの種類名(ComfySwitchNode など)で表示されます。
> オン・オフの項目が1つも無いワークフローでは「このワークフローに true/false の項目はありません」と表示されます。
### シードの管理(生成パネル)
シードは、生成パネルの **Seed** 欄と、その下のプルダウンで管理します。
@@ -232,6 +250,6 @@ Settingsタブは、左右2つのブロックに分かれています。
> **この章(前半)のまとめ**
> - ワークフロータブで選んで「生成UIに読み込み」を押すと、生成UIで編集できる
> - 基本は Input(プロンプト)・Model(モデル)・Settings(細かい設定)の3つのサブタブ
> - モデルやSettingsの値を変えたら必ず **Apply**。押し忘れると変更前の値で生成される(プロンプトは自動で反映)
> - モデルやSettingsの値を変えたら必ず **Apply**。押し忘れると変更前の値で生成される(プロンプトとSettingsのスイッチ列は自動で反映)
> - Generate で生成。Alt+Apply なら反映と生成を一度に行える
> - シードを Fixed にすると、気に入った絵をもとに条件を変えて比べられる。ワークフローのシードをそのまま使うなら Workflow
@@ -163,6 +163,8 @@ Labでは、「何回目の生成から、どの設定に切り替えるか」
4. 生成回数(Batch)を決めます。
5. Model・Prompt・KSampler の各列で **+** を押してキーフレームを追加し、
キーフレームをダブルクリックして、「何回目から」「どの設定に」するかを入力します。
KSampler列のセルには、指定した項目(Step・CFG・Denoise・サンプラー・スケジューラー・Seed)が表示されます。
何も指定していないセルは「(ワークフローの設定のまま)」と表示されます。
6. **Run** を押します。
結果は **Results** パネルに一覧表示されます。
@@ -172,6 +174,8 @@ Labでは、「何回目の生成から、どの設定に切り替えるか」
少しずつ変化していく連続画像を作れます。
- **Plan Save** - 設定(プラン)を保存できます。保存すると、結果をまとめた一覧画像も作られ、
その画像をドロップすれば同じプランを読み込み直せます。
- **物語からプランを作る**(v0.9.5〜) - AI TOOLのChatで **Storyboard to Lab** スキルを使うと、
物語をシーンごとのプロンプトに分けたプランを作り、**Labで開く** ボタンでここに読み込めます(第10章 10-5)。
---
@@ -217,18 +221,138 @@ v0.8.6〜は、こうしたノードを含むワークフローも生成UIで実
| Fibo 2.0 Edit(v0.8.14〜) | 画像編集のワークフロー。プロンプト強化(PE)を使う構成でも、プロンプト欄の編集がPEのオン・オフどちらにも反映される。ネガティブの欄にはVGL形式(JSON)の説明文がそのまま入る。幅・高さ(Settings)は0で自動 |
| FastH3 OmniRef/Pika-H3-Flex(v0.8.14〜) | MiniMax H3の「参照画像から動画」(Reference to Video)。動画のワークフローとして扱われ、Videoタブ(第11章)でも使える |
| ネイティブLoRAスタック | ComfyUI v0.40のLoRAをまとめて読み込むノード(LoadLoraModel/LoadLoraTextEncoder)。Apply・バイパス・Metadata表示に対応 |
| P-H3 Image(v0.9.4〜) | 画像編集とT2Iのテンプレート。プロンプトはInputタブに表示され、Metadataタブでも読める。ネガティブの欄は無い。幅・高さはワークフローのつなぎ方に従い、プロンプトを補う機能(プロンプトアップサンプラー)もワークフローの設定どおりに動く |
| MiniMax H3 Image(v0.9.6〜) | ComfyUI公式の画像編集とT2Iのテンプレート。P-H3 Imageと同じく、プロンプトはInputタブに表示され、MetadataタブとサイドパネルのIタブでも読める。ネガティブの欄は無い。プロンプト強化(PE)のオン・オフは、Settingsタブのスイッチの列(5-4)で切り替えられる |
> **注意**
> ネイティブLoRAスタックのノードは、保存形式が **API形式のワークフローのみ** 対応です。
> ComfyUI本体の画面がこのノードの行追加にまだ対応していないためで、UI形式のワークフローは対象外です。
> **ポイント**
> 2枚の画像をスライダーで見比べる **Compare Images**(ImageCompare)ノードを含むワークフローは、以前は生成UIから実行すると、このノードだけエラーになっていました(v0.9.6で修正)。
> **ポイント**
> 画像のメタデータを見るMetadataタブとサイドパネルの **I** タブでも、Nano Bananaで作った画像を読めます(v0.8.5〜)。
> プロンプトは、Positive/Negativeに分けずに全文が1件で表示されます。
## 5-10 日本語のままプロンプトを書く(プロンプト翻訳、v0.9.9〜)
多くの画像生成モデルは、英語のプロンプトで学習されています。
**プロンプト翻訳** をオンにすると、プロンプトを日本語で書き、ボタン1つで英語に直せます。
Stable Diffusion web UI(A1111)の翻訳拡張機能と同じように、プロンプトの中の **日本語の部分だけ** を翻訳します。
翻訳には、パソコンで動くAI(**Ollama**)と翻訳専用のモデル **PLaMo 3 Translate** を使います。
インターネット上の翻訳サービスにプロンプトを送ることはありません。
> **事前に必要なもの**
> **Ollama** をインストールして起動しておきます(第10章 10-1)。翻訳モデルのダウンロードは、設定画面からできます(下記)。
### 準備:設定でオンにする
1. **設定** タブの **プロンプト翻訳(自国語 → 英語)** を開きます。
2. **生成UIでプロンプト翻訳を使う** にチェックを入れます。
3. **翻訳モデル** で、使うモデルを選びます。まだOllamaに入っていないモデルには **(未取得)** と付いています。選んで **ダウンロード** を押すと、Ollamaに取り込まれます。
4. **テスト** を押して、見本のプロンプトが英語になれば準備完了です。
PLaMo 3 Translate には4つの大きさがあります。
| モデル | 大きさ | 特徴 |
| --- | --- | --- |
| 0.8B | 約0.6GB | 最速。短いタグの翻訳なら十分 |
| 2B | 約1.8GB | おすすめ。文章の翻訳も正確 |
| 8B | 約5.3GB | より高品質 |
| 31B | 約19.5GB | 最高品質。メモリに余裕がある人向け |
> **ポイント**
> 0.8Bは、文章の翻訳で意味がずれることがあります(例:「カメラは後ろから追いかける」が「her camera following behind」=「彼女のカメラが後ろについてくる」になった)。
> 動画のプロンプトのように文章で書くことが多いなら、2B以上を選びましょう。
設定のほかの項目は、次のとおりです。
| 項目 | 内容 |
| --- | --- |
| 入力する言語 | ふつうは **自動判定** のままでよい。日本語だけで書くなら「日本語」を選ぶと確実 |
| Ollama URL | Ollamaのアドレス。空欄なら `http://localhost:11434` |
| 翻訳モデルの実行場所 | **GPU** か **CPUで常駐** か(下記) |
| 実行時に自動で翻訳する | Generateなどを押したときに自動で翻訳する(下記) |
PLaMo以外のOllamaのモデル(ふだんチャットに使っているモデルなど)も、**その他のOllamaモデル** から選べます。その場合は「英語に翻訳して」という指示を付けて送ります。
### 翻訳モデルをどこで動かすか
| 実行場所 | 1語句あたりの時間 | 向いている人 |
| --- | --- | --- |
| GPU(1回の翻訳が最速・VRAMを使う) | 約0.1秒 | GPUのメモリに余裕がある |
| CPUで常駐(VRAMを使わず、再読み込みの待ちなし) | 約0.2〜0.3秒 | 画像生成にGPUのメモリをすべて使いたい |
GPUのときは、**翻訳後に翻訳モデルをVRAMから解放する** をオンにしておくと、画像生成の前にGPUのメモリを空けられます(初期値はオン)。
ただし、翻訳のたびにモデルの読み込み直しで **約4秒** 待つことになります。
**CPUで常駐** にすると、モデルをメインメモリに置いたままにします(2Bで約2.7GB)。
GPUのメモリを使わず、生成UIにワークフローを読み込んだときに裏で読み込んでおくので、最初の翻訳から待たされません。
> **ポイント**
> Ollamaは、ほかのモデル(AI TOOLのチャット用など)を読み込むときに、常駐させた翻訳モデルを外すことがあります。
> その場合は、次の翻訳のときに自動で読み込み直します(その1回だけ数秒かかります)。
### 使い方:🌐ボタンで翻訳する
プロンプト翻訳をオンにすると、InputタブのPositive Prompt・Negative Promptの **↺** ボタンの右に **🌐** ボタンが表示されます。
1. プロンプト欄に、日本語で書きます。英語のタグと混ぜてもかまいません。
```
masterpiece, 夕焼けの海辺に立つ少女、(長い黒髪:1.2), <lora:test_lora:0.8>, {猫耳|狐耳}, 水彩画風
```
2. **🌐** を押します。
3. 日本語の部分だけが英語になります。
```
masterpiece, A girl standing by the seaside at sunset, (long black hair:1.2), <lora:test_lora:0.8>, {cat ears|fox ears}, watercolor style
```
次のようなプロンプトの書き方(記法)は、翻訳せずにそのまま残します。
- カンマ・改行
- 重み付け `(語句:1.2)`、`[ ]`
- ランダムに選ぶ `{A|B}`、ワイルドカード `__名前__`
- LoRAの指定 `<lora:名前:0.8>`、`embedding:名前`
- `BREAK`、`AND`
翻訳したあとに **原文** ボタンが表示されます。押すと、翻訳する前の文に戻ります(Ctrl+Zでも戻せます)。
> **注意**
> 翻訳されるのは、英数字以外の文字を含む部分だけです。英語だけの部分は、そのまま残ります。
> 反対に、é などのアクセント付きの文字を含む英単語は、翻訳の対象になります。
### 実行時に自動で翻訳する
設定の **実行時に自動で翻訳する** で、どの実行のときに自動で翻訳するかを、チェックボックスで選べます。
| チェックボックス | 動き |
| --- | --- |
| 生成UI - Generate | Generateを押すと、Positive/Negativeの欄の日本語を英語に置き換えてから生成する |
| 生成UI Lab - Run | Labの実行で、送る内容だけを翻訳する。Labのプランには日本語が残る |
| Video Plan - Run | Videoタブ Planの実行で、送るプロンプトだけを翻訳する。プランには日本語が残る |
LabとVideo Planでは、プランを日本語のまま残すので、あとから日本語で書き直せます。
生成した画像や動画の情報(メタデータ)には、実際に送った英語のプロンプトが記録されます。
> **注意**
> 自動翻訳がオンのときに翻訳に失敗すると(Ollamaが起動していないなど)、日本語のまま生成しないよう、生成を止めます。
> LabとVideo Planでは、止まった理由が進行状況の欄に表示されます。
### Labのモーダルと、Video Planでも使える
🌐ボタンは、次の欄にもあります。使い方は同じです。
- Lab(5-7)のプロンプト列のセルをダブルクリックして開く画面の、Positive・Negativeの欄
- Videoタブ Planサブタブの、ブロックの **Prompt** の欄(第11章 11-4)
> **ポイント**
> PLaMo 3 Translate は、個人の利用や趣味、研究などの非商用の利用なら無料で使えます(PLaMoコミュニティライセンス)。
> 商用で使う場合は、ライセンスの条件を確認してください。
> **この章(後半)のまとめ**
> - Batchサブタブで、モデル・プロンプト・サンプラーなどを1種類ずつ変えながらまとめて生成できる
> - Batch Queueの列のチェックで種類を選び、Generateで開始。終わったらチェックを外す
> - Feederは、たくさんの画像を1枚ずつワークフローに送り込む機能。専用ノードが必要
> - Labは、複数の設定を別々のタイミングで切り替えられる上級者向けの機能
> - パートナーAPIノード(Nano Bananaなど)は、`.env` の `COMFY_API_KEY` を設定すれば実行できる。クレジットが消費される
> - プロンプト翻訳をオンにすると、日本語で書いたプロンプトを🌐ボタンで英語にできる。記法はそのまま残り、Generate・Lab・Video Planの実行時に自動で翻訳することもできる
@@ -227,6 +227,10 @@ Workflow Studioにはたくさんのスタイルが付属しています。
英語のプロンプトの意味を知りたいときは、反対に **EN→JA** で日本語に訳せます。
> **ポイント**
> 生成UIのプロンプト欄で直接翻訳したいときは、第5章 5-10 の **プロンプト翻訳**(🌐ボタン)が便利です。重み付けやLoRAの指定を残したまま、日本語の部分だけを英語にできます。
> AI Assistantの翻訳にも、翻訳専用のモデル **PLaMo 3 Translate** を選べます(v0.9.9〜。以前は指示文まで翻訳されたり、ZH→ENで日本語が出たりしていました)。
### AIと相談しながらプロンプトを作る
入力欄に質問を書いて **Send**(または Enter キー)を押すと、AIとチャットできます。
@@ -6,7 +6,7 @@
ComfyUIで生成した画像には、生成に使ったワークフローやプロンプトの情報(**メタデータ**)が埋め込まれています。
ギャラリータブでは、この情報を読み取って、同じ設定をすぐに再現できます。
また、動画(MP4・WebM)や音声ファイル(WAV・MP3・OGG・M4A・FLAC・Opus)も、画像と同じ一覧で扱えます。
また、動画(MP4・WebM)や音声ファイル(WAV・MP3・OGG・M4A・FLAC・Opus)、3Dモデル(GLB・glTF・VRM・PLY・SPZ)も、画像と同じ一覧で扱えます。
---
@@ -297,6 +297,30 @@ ComfyUIで音楽や効果音を作る機会が増えたため、ギャラリー
> **ポイント:Videoタブでの活用**
> Video の Asset サブタブでは、音声ファイルを「BGMに設定」したり、「サウンドとして追加」したりできます(第11章 11-4)。
---
## 8-8 3Dモデルを見る(v0.9.4〜)
ComfyUIで3Dモデルを作るワークフロー(画像から3Dなど)の結果も、ギャラリーで確かめられます。
対応しているのは、GLB・glTF・VRM・PLY(メッシュ/点群/ガウシアンスプラット)・SPZ です。
- 一覧には「**3D**」のバッジ付きで並びます。サムネイルは、最初に一覧に出たときにブラウザが描いてサーバーに保存します
(128MBを超えるファイルは、開いたときに保存します)。
- 選ぶと、右の詳細パネルの内蔵ビューアで立体として表示されます。ダブルクリックで大きく表示できます。
| 操作 | 動き |
| --- | --- |
| ドラッグ | 回転する |
| 右ドラッグ | 位置を動かす |
| マウスホイール | 拡大・縮小 |
| ⟲(リセット)ボタン | 最初の向きに戻す |
- ComfyUIの **SaveGLB** で保存したモデルは、画像と同じようにワークフローを読み取れます(8-2・8-3)。
> **注意**
> - 3Dファイルは、Image Edit・生成UI・Tagger・Feederには送れません。
> - `.gltf` の中には、別の `.bin` や画像ファイルを参照しているものがあります。ギャラリーで移動・削除しても動くのは `.gltf` 本体だけなので、参照しているファイルの場所は変えないでください。
> **この章のまとめ**
> - ギャラリーのOutputで、生成した画像をフォルダごとに見返せる。プロンプトの言葉でも検索できる
> - 詳細パネルのプロンプトタブで、画像の生成に使ったプロンプトがすぐ分かる
@@ -305,3 +329,4 @@ ComfyUIで音楽や効果音を作る機会が増えたため、ギャラリー
> - メタデータサブタブに画像をドロップすると、モデル・LoRA・プロンプトを詳しく調べられる
> - Sボタンで、文章の意味や「似た画像」から探せる(セマンティック検索)
> - 音声ファイルも一覧・再生・変換できる
> - 3Dモデル(GLB・glTF・VRM・PLY・SPZ)も、ギャラリーで回して確かめられる(8-8)
+248 -3
View File
@@ -7,6 +7,9 @@ Workflow Studioは、パソコンの中で動く **ローカルAI(大規模言
- AIとチャットしながら、プロンプトのアイデアを出してもらう
- 画像を見せて、その画像の説明やプロンプト、タグを作ってもらう
- ワイルドカード用の候補リストを作ってもらう
- **スキル** を選んで、プロンプト作り・ストーリーボード・不具合の相談など、得意分野を切り替える(v0.9.5〜)
- 生成した画像が依頼どおりかをAIにチェックさせて、足りない点だけ直す(v0.9.5〜)
- 画像に写っている文字を読み取る(OCR、v0.9.5〜)
インターネット上のサービスではなく、自分のパソコンの中で動くので、
**入力した内容や画像が外部に送られない** のが大きな特長です。
@@ -69,10 +72,14 @@ Workflow Studio本体の **AI TOOL** タブを開きます。
| 部分 | できること |
| --- | --- |
| 翻訳 | 日本語・英語・中国語などの翻訳 |
| Chat | AIとの会話。条件がそろえば、会話から画像生成も |
| TOOLS | 画像の読み取り(VLM)、ワイルドカード作成 |
| Chat | AIとの会話。スキルで得意分野を切り替えられる。条件がそろえば、会話から画像生成も |
| TOOLS | 画像の読み取り(VLM)、文字起こし(OCR)、ワイルドカード作成 |
| 設定 | 使うAIソフト・モデルの設定 |
> **ポイント:翻訳と設定はたためる(v0.9.5〜)**
> 翻訳と設定の見出しの右端にある矢印(◀/▶)を押すと、その部分が細い帯にたたまれ、空いた幅をChatとTOOLSが使います。
> 帯のどこかをクリックすると元に戻ります。たたんだ状態は、次に開いたときも保たれます。
### 最初に:設定でAIソフトとつなぐ
1. **設定** の **バックエンド** で、使うソフト(例:Ollama)を選びます。
2. **接続設定** のアドレスを確認します。Ollamaを標準のまま使っている場合は、変更不要です。
@@ -96,10 +103,18 @@ Workflow Studio本体の **AI TOOL** タブを開きます。
2. 入力欄に文章を書き、**翻訳** を押します。
3. 結果を **コピー** して、生成UIやプリセットに貼り付けます。
> **ポイント**
> TOOLSで読み取った文字(10-8のOCRなど)は、TOOLSの **翻訳へ送る** で、この入力欄にそのまま入れられます。
> **ポイント**
> 小さなモデルは、翻訳せずに元の文章をそのまま返してしまうことがあります。
> その場合は「モデルが原文をそのまま返しました」と表示されるので、別のモデルを試してください。
> **ポイント**
> 翻訳専用のモデル **PLaMo 3 Translate**(第5章 5-10)を、設定のモデルに選ぶこともできます(v0.9.9〜)。
> 日本語・英語・中国語のほか、Free(自由入力)では French・フランス語・français のような言語名で、PLaMoが対応する言語を指定できます。PLaMoが対応していない言語(ポルトガル語など)を翻訳先にすると、エラーになります。
> WS LibraryのAタブの翻訳も同じです。
### Chat
入力欄に話しかけて、**Enter** で送信します(**Shift+Enter** で改行)。
会話の流れを覚えているので、「もっと明るい雰囲気にして」のような続けての依頼もできます。
@@ -110,6 +125,10 @@ Workflow Studio本体の **AI TOOL** タブを開きます。
> チャットで「猫の絵を描いて」と頼むだけで、生成UIに読み込んだワークフローで画像が生成され、チャット内に表示されます。
> この機能は、入力欄の横の **画像生成を許可する** のチェックでオン・オフできます。
> **ポイント**
> Chatの上にあるドロップダウンで **スキル** を選ぶと、AIの得意分野を切り替えられます(10-5)。
> AIの返事は、見出し・箇条書き・コードの枠を整えて表示されます(v0.9.5〜)。
### TOOLS - 画像を読み取る(VLM)
画像入力に対応したモデル(VLM)を使うと、画像の内容をAIに読み取らせることができます。
@@ -122,8 +141,16 @@ Workflow Studio本体の **AI TOOL** タブを開きます。
| プロンプト作成 | 画像を再現するためのプロンプトを作る |
| Create tags(英語表示のまま) | 画像の要素をタグ形式で書き出す |
| Create wildcards(英語表示のまま) | カテゴリー名と件数を指定して、ワイルドカードの候補を作る(画像は不要) |
| 文字起こし(OCR) | 画像に写っている文字を読み取る(10-8) |
3. **実行** を押します。結果はコピーして使えます。
3. **実行** を押します。
4. 結果の下のボタンで、結果を使います(v0.9.5〜)。
| ボタン | 動き |
| --- | --- |
| 翻訳へ送る | 翻訳の入力欄に入れる(翻訳がたたまれていれば開く) |
| Chatへ送る | Chatの入力欄に追加する |
| コピー | クリップボードにコピーする |
> **例**
> 気に入ったイラストの雰囲気をまねしたいとき、その画像から「プロンプト作成」をして、
@@ -190,9 +217,227 @@ ComfyUI(とWorkflow Studio)にアクセスできるようになります。
> `--listen` は、家庭内LANなど **信頼できるネットワークでだけ** 使ってください。
> カフェや公共のWi-Fiでは使わないようにしましょう。
---
## 10-5 スキル - Chatの得意分野を切り替える(v0.9.5〜)
**スキル** は、Chatに「どんな役割で、どんな形で答えるか」を教える指示書です。
Chatの上のドロップダウン(最初は「-- スキルなし --」)で選ぶと、そのスキルの指示が毎回の会話に付けて送られます
(指示の文章はチャットの画面には表示されません)。
### 最初から入っているスキル
Workflow Studioには、次の6つのスキルが入っています(名前は英語表示のままです)。
| スキル | 何をするか | 結果の使い方 |
| --- | --- | --- |
| T2I Prompt Enhancer | 短いアイデアを、生成UIのワークフローのモデルに合った書き方のプロンプトにする | プロンプトの下のボタン |
| Image to Prompt | TOOLSに入れた画像を再現するプロンプトを書く(画像を読み取れるモデルが必要) | プロンプトの下のボタン |
| Storyboard to Lab | 物語をシーンごとのプロンプトに分け、Labで連続生成できる形にする | **Labで開く** |
| Workflow Doctor | ワークフローの説明や、エラーの原因の相談にのる(10-7) | 文章で答える |
| SVG Icon Generator | 簡単なアイコンやイラストをSVG(ベクター画像)で描く | プレビューと **Galleryに保存** |
| Skill Creator | 質問に答えていくと、新しいスキルを作ってくれる(10-9) | **スキルとして保存** |
### プロンプトを作って、そのまま生成する(T2I Prompt Enhancer)
1. 生成UIに、使うワークフローを読み込みます。スキルはこのワークフローのモデルを見て、プロンプトの書き方を決めます。
2. AI TOOLのChatで、ドロップダウンから **T2I Prompt Enhancer** を選びます。
3. 「雨の夜の東京、ネオン、傘を持つ猫」のように、日本語で作りたい絵を書いて送信します。
4. 返事に、選んだ書き方(`Style:` の行)と、英語のプロンプトの枠が表示されます。その下のボタンで使います。
| ボタン | 動き |
| --- | --- |
| GenerateUIに反映 | 生成UIのポジティブ/ネガティブの欄に書き込む |
| このプロンプトで生成 | その場で生成し、チャットに画像を表示する |
| コピー | ポジティブプロンプトをコピーする |
モデルに合わせた書き方は、次のとおりです。
| 生成UIのモデル | プロンプトの書き方 |
| --- | --- |
| Qwen-Image、FLUX、Z-Image など | 英語の文章(ネガティブは、CFGが1前後なら空にする) |
| Illustrious、NoobAI、Pony など(SDXLのアニメ系) | Danbooruのタグ(品質タグから始める) |
| 写実系のSDXL、SD1.5 | 短い言葉をカンマで並べる |
> **ポイント**
> 「もっと夜らしく」「猫を2匹に」のように続けて頼むと、直したプロンプト全体を出し直します。
> **ポイント:今入っているプロンプトは渡さない**
> 生成UIに今入っているプロンプトは、ふだんはAIに渡しません。渡すと、小さなモデルが古いネガティブプロンプトなどを新しいプロンプトに混ぜてしまうためです。
> 「**今のプロンプトを改善して**」のように、今のプロンプトに触れて頼んだときだけ渡します。
### ストーリーボードから連続生成する(Storyboard to Lab)
1. 生成UIに、文章から画像を作る(T2I)ワークフローを読み込みます。
2. Chatで **Storyboard to Lab** を選び、「茶トラの子猫が朝目覚めて、庭で蝶を追いかけ、夕方に縁側で昼寝する。3シーンで」のように頼みます。
3. 返事に、シーンの一覧と **Labで開く(3シーン)** ボタンが表示されます。ボタンを押します。
4. 生成UIの **Lab**(第5章 5-7)が開き、まだ保存していないプランとして読み込まれます。
T2Iモードになり、Batchがシーンの数に、Prompt列がシーンごとのキーフレームになります。KSampler列には、全シーン共通のシード(`Seed …`)が入ります。
5. 内容を確かめて **Run** を押します。残したいときは **Plan Save** で保存します。
> **ポイント**
> 登場人物の見た目(髪・服の色など)は、全シーンで同じ文章が入るように書かれ、シードも固定されます。
> そのため、シーンが変わっても同じキャラクターに見えやすくなります。
### 返事の自動チェック
プロンプトやSVGを出すスキルでは、Workflow Studioが返事の形を自動で確かめます。
プロンプトの枠が崩れている、SVGが閉じていない、といった問題があると、
点線の枠で「**自動チェック:…**」と表示し、AIに1回だけ直させます。
説明だけを頼んだときなど、プロンプトやSVGを出していない返事はそのままにします。
### スキルの管理(鉛筆ボタン)
ドロップダウンの右の鉛筆ボタンで、スキルの一覧が開きます。
- **+ 新規** で新しいスキルを書く、各行の鉛筆ボタンで編集・削除する、**取り込み** で他のスキルを追加する(10-9)
- 最初から入っているスキルには **同梱** と表示されます。
編集していない同梱スキルは、Workflow Studioを更新すると自動で新しい版になります。
編集したスキルは自動では置き換わらず、新しい版があると **↻(更新)** ボタンが表示されます。
- スキルのファイルは `ComfyUI/user/default/Workflow-Studio/ai_skills/` に保存されます。
> **注意**
> ↻(更新)で新しい版に置き換えると、そのスキルに加えた編集は消えます。
---
## 10-6 生成した画像をチェックして直す(v0.9.5〜)
チャットから生成した画像が、頼んだとおりになっているかをAIに確かめさせる機能です。
足りないところがあれば、その点だけを直したプロンプトで描き直せます。
### 準備:判定用のモデル
チェックには、ふつうのチャット用モデルではなく、Ollamaの **意思決定モデル**(はい/いいえを確率で答えるモデル)を使います。
画像を読み取れるもの(作者の環境では `d3:4b`、`clef-flash`、`clef` で動作を確認)を、`ollama pull` で用意します。
> **ポイント:なぜ専用のモデルを使うのか**
> 作者の検証では、チャット用のモデルに画像を見せて「剣を持っているか」と聞くと、持っていないのに「はい」と答えることがありました。
> 意思決定モデルは「はい」の確率を数字で返すので、あいまいな答えを見分けられます。
1. AI TOOLの **設定** にある **CHAT 画像チェック** で、**判定モデル(Ollamaの意思決定モデル)** を選びます(一覧が空なら **更新**)。
2. **自動修正の回数** を選びます。最初は **0(ボタンで修正)** がおすすめです。
3. **設定を保存** を押します。
### 使い方
1. Chatの入力欄の下にある **画像をチェック** にチェックを入れます。
2. チャットから画像を生成します(AIの画像生成、または **このプロンプトで生成**)。
3. 画像の下に結果のカードが表示されます。AIが頼んだ内容を3〜8個の確認項目に分け、1つずつ確かめた結果です。
| 表示 | 意味 |
| --- | --- |
| ✔(満たしている) | 「はい」の確率が85%以上 |
| ?(はっきりしない) | 30〜85% |
| ✘(満たしていない) | 30%未満 |
4. ✘や?があるときは **足りない点を直して再生成** を押します。満たしていない項目だけをAIに伝え、プロンプトを書き直して描き直します。
自動修正の回数を1〜3にすると、ボタンを押さなくても、その回数まで自動でくり返します。
> **ポイント:SVGもチェックできる**
> SVG Icon Generatorで描いたSVGも、画像にしてから「頼んだものに見えるか」「部品(くちばし・翼など)が描けているか」をチェックします。
> **分かりにくい部分を描き直させる** で直させられます。
> **注意**
> - チェックは完ぺきではありません。とくに「誰が何を身につけているか」の取り違えに弱いため、
> 人物が複数いるときは「帽子は女の子ではない」のような逆向きの確認項目を自動で加えて補っています。
> - 描き直しの上手さは、チャット用モデルの力しだいです。直らないときは、頼み方を変えるか、モデルを変えてください。
> - 判定モデルもGPUのメモリを使います(`d3:4b` で約6GB)。読み込んだあとは、1回のチェックが数秒です。
---
## 10-7 ワークフローの不具合を相談する(Workflow Doctor、v0.9.5〜)
**Workflow Doctor** は、生成UIに読み込んだワークフローの説明や、エラーの原因の相談にのるスキルです。
AIの知識だけに頼らず、送信するたびにWorkflow Studioが実際に確かめた次の内容をAIに渡します。
| 確かめる内容 | 例 |
| --- | --- |
| インストールされていないノード | ComfyUIが知らないノードの名前 |
| ComfyUIの一覧に無いファイル・設定値 | 見つからないモデルやLoRA(似た名前の候補も) |
| 線のつながり | つながっていない入力、存在しないノードへの線 |
| 直近の実行エラー | ComfyUIの履歴に残ったエラーの内容 |
| ComfyUIのログ | ログに出た最新のエラーの部分 |
### 使い方
1. 相談したいワークフローを生成UIに読み込みます(エラーの相談なら、一度実行してエラーを出しておきます)。
2. Chatで **Workflow Doctor** を選びます。
3. 「実行する前に問題がないか確認して」「さっきのエラーの原因は?」のように聞きます。
> **例**
> LoRAのファイルを別のフォルダに移したワークフローで聞くと、
> 「`temp\` のフォルダに指定されたファイルが見つからない。`Illustrious\` に同じ名前のファイルがある」と、直し方まで答えました。
> **ポイント**
> 確かめる内容は、送信のたびに作り直されます。直したあとは、もう一度聞いてみてください。
---
## 10-8 画像の文字を読み取る(OCR、v0.9.5〜)
TOOLSで、画像に写っている文字を読み取れます。読み取った文字は、そのまま翻訳やChatに送れます。
### 準備:OCR用のモデル
OCRには、チャット用とは別の、文字を読むのが得意なモデルを使います。Ollamaで用意してください。
作者の環境で、横書きと縦書きの日本語・英語がまじった画像を読ませた結果は次のとおりです。
| モデル | 時間 | 読み取り |
| --- | --- | --- |
| LightOnOCR-3(`maternion/LightOnOCR-3:4b`) | 約1秒(位置つきは約6〜8秒) | すべて読めた |
| PaddleOCR-VL(マンガ向けの版) | 約4秒 | すべて読めた |
| DeepSeek-OCR系 | 約14秒 | すべて読めた(いつも位置つき) |
| PaddleOCR-VL 1.6、GLM-OCR | 約11〜15秒 | 縦書きを読み落とした |
### 使い方
1. TOOLSに画像をドロップします。
2. 作業で **文字起こし(OCR)** を選びます。
3. **OCRモデル** を選びます。名前に「ocr」を含むOllamaのモデルが、向いている順に並びます(一覧が空なら ↻ を押します)。
4. **実行** を押します。読み取った文字が、結果の欄に1行ずつ表示されます。
> **ポイント:文字の位置を表示**
> **文字の位置を表示** にチェックを入れると、画像の上に番号つきの枠が重なり、どこの文字かが分かります。
> 枠をクリックすると、結果の欄の同じ行が選ばれます。
> 位置を返せるのは LightOnOCR と DeepSeek-OCR系だけです。ほかのモデルでは、このチェックは選べません。
> **ポイント**
> 結果が空だったり、同じ行がくり返されたりしたときは、自動で白黒(グレースケール)にして1回だけ読み直します。
---
## 10-9 スキルを自作・取り込む(上級、v0.9.5〜)
### Skill Creatorで作る
Chatで **Skill Creator** を選び、「〇〇が得意なスキルを作りたい」と話しかけます。
AIが1つずつ質問してくるので答えていくと、スキルの下書きができます。
返事の下の **スキルとして保存** を押すと、スキルの一覧に下書きが入った状態で開くので、確かめて保存します。
「このスキルの、ここがうまくいかない」と相談して、今あるスキルを直してもらうこともできます。
### スキルのファイルの中身
スキルは、テキストファイル(`.md`)です。先頭の `---` で囲んだ部分に名前と説明を書き、その下にAIへの指示を書きます。
先頭の部分の `metadata:` には、次の設定も書けます(書かなくてもかまいません)。
| 設定 | 意味 |
| --- | --- |
| `output` | `prompt` か `svg`。返事の形を自動でチェックし、ボタンを付ける |
| `tools` | `[]` にすると、AIが自分で画像生成を始めない |
| `temperature` | 答えのばらつき(0.3なら安定、0.9なら自由) |
| `think` | 考える(Thinking)モードを、このスキルだけオン/オフにする |
| `context` | AIに渡す情報。`workflow`(ワークフローの要約)、`current-prompt`(今のプロンプト)、`workflow-detail`/`logs`(Workflow Doctorと同じ確認内容) |
### ほかのスキルを取り込む
スキルの一覧の **取り込み** で、次のファイルを追加できます。
- `.md` のスキル1つ
- `SKILL.md` を含むフォルダをZIPにしたもの(**Agent Skills** という、多くのAIツールで共通の形式)
フォルダの中のテキストファイル(参考資料など)も一緒に取り込まれ、AIが必要になったときだけ読みに行きます
(ツール呼び出しに対応したモデルが必要です)。
> **注意**
> - 取り込むのはテキストファイルだけです。スクリプトなどのプログラムは取り込まず、実行もしません。
> - スキルの指示は、そのままAIに渡されます。他の人が作ったスキルは、中身を読んでから使ってください。
> **この章のまとめ**
> - ローカルAI(Ollamaなど)を用意すると、翻訳・チャット・画像の読み取りができる。入力内容は外部に送られない
> - AI TOOLタブの設定で、バックエンド・アドレス・モデルを選び、接続テストをする
> - プロンプトタブとTaggerタブには、別に歯車ボタンの設定がある
> - AIと画像生成はVRAMを取り合う。「モデルをアンロード」や「VRAM調整(Ollama)」で解放する
> - 標準では自分のパソコンのAIにだけつながる。`--listen` は信頼できるネットワークだけで
> - **スキル** で得意分野を切り替える。T2I Prompt Enhancer でプロンプトを作り、ボタンで生成UIに反映・生成できる
> - **画像をチェック** をオンにすると、意思決定モデルが生成画像を確かめ、足りない点だけ直して描き直せる
> - Workflow Doctor は、実際に確かめた事実をもとにワークフローの不具合を相談にのる
> - TOOLSの **文字起こし(OCR)** で画像の文字を読み取り、翻訳やChatへ送れる
@@ -103,6 +103,22 @@ Taggerを使うには、次の準備が必要です。
- 編集した画像は、**Save PNG**(ダウンロード)、**Save to Gallery**(ギャラリーに保存)などで保存します。
- **Ctrl+Z** で元に戻す、**Ctrl+Y** でやり直しができます。
### Drawの色とショートカット(v0.9.3〜)
**Draw** を選ぶと、ツールの2段目に **カラーパレット** が表示されます。
- **色1/色2**、基本色20色、カスタム色20枠が並びます。色をクリックすると、その色で描けます。
- **+** か空いている枠をクリックすると、今の色をカスタム色に登録します。色の上で右クリックすると、登録・編集・削除ができます(基本色も変えられ、最初の色に戻せます)。
登録した色は、ブラウザごとに保存されます。
- 右側の **Color** の隣にある **スポイト** ボタンで、キャンバスの色を拾えます(Escで取り消し)。
- 描き始めの色は黒(色1)と白(色2)です。
| キー(Draw中) | 動き |
| --- | --- |
| D/E | 描く(Draw)/消す(Erase) |
| X | 色1と色2を入れ替える |
| [ / ] | ブラシを小さく/大きくする(実際は半角の `[` `]`) |
| B | ブラシの選択を開く・閉じる(Escでも閉じる) |
### インペイント(部分の描き直し)
Image Editのいちばん便利な使い方が、**インペイント** です。
「顔だけ描き直したい」「手が崩れたところだけ直したい」というときに使います。
@@ -139,6 +155,14 @@ Image Editのいちばん便利な使い方が、**インペイント** です
そのほか、動画の好きな場面を静止画として保存する **Frame** や、動画をGIFアニメに変換する **GIF** の機能もあります。
> **ポイント**
> Planサブタブのブロックの **Prompt** の欄にも、プロンプト翻訳の **🌐** ボタンがあります(第5章 5-10)。
> 設定の **Video Plan - Run** をオンにすると、日本語のプロンプトのまま実行して、送る内容だけを英語にできます。
> **注意**
> v0.9.8までは、新しいComfyUIで保存したワークフローを使うと、Planで入力したプロンプト・長さ(Duration)・Turboの設定が反映されず、ワークフローに保存されている値のまま生成されていました(v0.9.9で修正)。
> 以前と同じPlanを実行しても、Planの値が反映されるようになったため、結果が変わることがあります。
### アセット登録と音声変換(v0.8.9〜)
- **アセット登録** - 左側の動画ソースパネルのボタンです。パソコン内の動画を、outputフォルダ(`output/video`)へコピーして「Video Assets」グループに登録します。
登録すると、Assetサブタブの一覧に出て、Editなどで使えるようになります。
@@ -189,6 +213,7 @@ Image Editのいちばん便利な使い方が、**インペイント** です
| CivitAI APIキー | Civitaiの情報取得用(省略可) | 第6章 |
| Eagle 連携 (オプション) | 生成画像をEagleに自動保存 | 第8章 |
| VRAM調整(Ollama) | 生成前にAIモデルをメモリから降ろす | 第10章 |
| プロンプト翻訳(自国語 → 英語) | 日本語のプロンプトを🌐ボタンや実行時の自動翻訳で英語にする | 第5章 5-10 |
| データ管理 | 設定やデータのバックアップ・復元 | 下記 |
### デフォルトワークフロー
@@ -72,6 +72,7 @@ Workflow Studioを更新(アップデート)したあとは、必ずComfyUI
### 設定を変えたのに、結果が変わらない
いちばん多い原因は、**Apply の押し忘れ** です。
生成UIでは、モデルやSettings(ステップ数・サイズなど)の値を変えたあと、**Apply** を押さないとワークフローに反映されません(第5章 5-3)。
ただし、Settingsタブの右端のスイッチの列は、クリックした時点で反映されます(第5章 5-4)。
右側の **Raw JSON** を見ると、実際に反映されている値を確認できます。
### 読み込んだワークフローとは違う内容で生成される
@@ -87,6 +88,15 @@ Batchサブタブを開き、Batch Queueの列のチェックをすべてオフ
いつも同じモデルを使いたい場合は、設定タブの **デフォルトCheckpoint** を使うと便利です(第11章 11-5)。
### プロンプト翻訳の🌐ボタンが出ない・翻訳できない
| 症状 | 原因 | 対処 |
| --- | --- | --- |
| 🌐ボタンが表示されない | プロンプト翻訳がオフになっている | 設定タブの **プロンプト翻訳(自国語 → 英語)** で **生成UIでプロンプト翻訳を使う** にチェックを入れる(第5章 5-10) |
| 「翻訳エラー」と出る | Ollamaが起動していない、または翻訳モデルがOllamaに無い | Ollamaを起動する。設定の **翻訳モデル** に **(未取得)** と出ていれば **ダウンロード** を押す |
| 押しても何も変わらない(「翻訳する部分がありません」) | 英語(英数字)だけのプロンプトになっている | 翻訳されるのは英数字以外の文字を含む部分だけ。英語の部分はそのまま残る |
| 自動翻訳がオンのとき、生成が始まらない | 翻訳に失敗したので、日本語のまま生成しないよう止めた | 上の「翻訳エラー」と同じ対処をする。LabとVideo Planでは、理由が進行状況の欄に出る |
| 訳がおかしい | 小さいモデル(0.8B)は、文章で意味がずれることがある | 設定の **翻訳モデル** で2B以上を選ぶ |
### 同じ設定なのに、同じ画像にならない
生成パネルのシードのモードが **Random** になっていませんか?
同じ画像を作るには、シードを **Workflow**(ワークフローのシードをそのまま使う)か **Fixed**(Seed欄の値で固定)にする必要があります。
@@ -135,6 +145,21 @@ Ollamaの場合は `ollama pull (モデル名)` でモデルをダウンロ
安全のため、標準では同じパソコンの中のAIソフトにしかつながりません。
環境変数 `WFS_ALLOWED_BACKEND_HOSTS` の設定が必要です(第10章 10-4)。
### 画像チェックの判定モデルや、OCRモデルが一覧に出てこない
- 判定モデルの一覧には、Ollamaの **意思決定モデル** のうち、画像を読み取れるものだけが出ます。
ふつうのチャット用モデルは出ません。Ollamaを新しい版に更新し、意思決定モデルを `ollama pull` してから **更新** を押します(第10章 10-6)。
- OCRモデルの一覧には、名前に「ocr」を含むOllamaのモデルだけが出ます。取得後に ↻ を押します(第10章 10-8)。
- どちらも、AI TOOLのバックエンドがOllamaならそのアドレス、そうでなければ `http://localhost:11434` のOllamaを見に行きます。
### 画像チェックで、何度直しても満たされない
- 描き直しの上手さは、チャット用モデルの力しだいです。頼み方を短く具体的にするか、別のモデルを試してください。
- チェック自体もまちがえることがあります。画像を自分の目でも確かめてください。
- 自動修正の回数を上げすぎると、生成の時間とGPUのメモリを使い続けます。最初は「0(ボタンで修正)」がおすすめです。
### AIがスキルの資料を読まない・チャットから画像を生成しない
取り込んだスキルの参考資料を読む機能と、チャットからの画像生成は、
**ツール呼び出し(Tool Calling)に対応したモデル** でないと動きません。対応しているモデルに切り替えてください。
---
## 12-5 そのほかの機能のトラブル
@@ -172,6 +197,15 @@ ComfyUIを停止し、ComfyUIのPythonで `pip uninstall -y onnxruntime onnxrunt
`.env` にComfy APIキーが無いのが原因です。プラグインの `.env` に `COMFY_API_KEY=キー`(platform.comfy.orgで発行)を書き、ComfyUIを再起動してください(第5章 5-8)。
`.env` は起動時にしか読み込まれません。
### ComfyUIが固まる(どのタブも反応しなくなる)
Windowsで、プレビュー画像の多いモデルタブの一覧を切り替えたあとなどに、ComfyUIが反応しなくなる(生成もできなくなる)場合があります。
設定タブの **Windowsの安定性(イベントループ)** で、**WindowsでSelectorイベントループを使用する** をオンにして、ComfyUIを再起動してください。
### ギャラリーの画像の一部が、別の画像のように壊れて見える
上の **Selectorイベントループ** をオンにしているとき、v0.9.1までは、ギャラリーのプレビューや Download で受け取った画像の一部が壊れることがありました
(出力フォルダのファイル自体は正常です)。v0.9.2で直っています。
Workflow Studioを更新したあと、壊れた画像がブラウザに残っていることがあるので、**Ctrl+F5** で再読み込みしてください。
### ギャラリーに画像が出てこない
- ギャラリーの **Refresh** を押します。
- 設定タブの「ギャラリー Outputフォルダ」が、ComfyUIの画像保存先と合っているか確認します。
+9
View File
@@ -7,6 +7,7 @@
### 日本語
| 用語 | 意味 | 本書 |
| --- | --- | --- |
| 意思決定モデル | 質問に「はい」の確率などを数字で答えるAIモデル。画像チェックの判定に使う | 第10章 |
| インペイント | 画像の一部(マスクした部分)だけを描き直すこと | 第11章 |
| カスタムノード | ComfyUIに後から追加するノード・拡張機能。Workflow Studioもその1つ | 第1章 |
| キャンバス | ComfyUIのノード画面で、ノードを並べる作業スペース | 第3章 |
@@ -15,6 +16,7 @@
| サンプラー | 画像を描くときのアルゴリズム(euler など) | 第5章 |
| シード | 画像のもとになる乱数の種。同じなら、ほぼ同じ画像になる | 第5章 |
| セマンティック検索 | 文章や画像の「意味」で画像を探す検索。ギャラリーのSボタンで使う | 第8章 |
| スキル | AI TOOLのChatに、役割や答え方を教える指示書。選ぶと得意分野が切り替わる | 第10章 |
| スケジューラー | ステップごとの描き込み量の配分のしかた | 第5章 |
| スタイル | プロンプトに付け足す雰囲気のテンプレート | 第7章 |
| ステップ数 | 描き込みをくり返す回数 | 第5章 |
@@ -50,7 +52,9 @@
| I2I(Image to Image) | 画像をもとに、新しい画像を作ること | 第5章 |
| JSON | ワークフローの保存に使われるデータ形式 | 第1章 |
| LoRA | 絵柄やキャラクターなどを追加で覚えさせる小さなモデル | 第6章 |
| OCR | 画像に写っている文字を読み取ること | 第10章 |
| Ollama | ローカルAIを手軽に動かせるソフト | 第10章 |
| PLaMo 3 Translate | Preferred Networks(PFN)の翻訳専用AIモデル。プロンプト翻訳で使う | 第5章 |
| T2I(Text to Image) | 文章(プロンプト)から画像を作ること | 第5章 |
| TagSpace | タグ・プロンプト・生成画像を意味の近さで3Dの空間に並べて表示するタブ | 第11章 |
| VAE | 画像の色合いや細部を仕上げるモデル | 第6章 |
@@ -100,6 +104,10 @@
| マウスホイール | 拡大・縮小 |
| Space+ドラッグ | 表示位置を移動する |
| Delete | 選んでいるレイヤーを削除する(レイヤーが2つ以上あるとき) |
| D/E(Draw中) | 描く/消す |
| X(Draw中) | 色1と色2を入れ替える |
| [/](Draw中) | ブラシを小さく/大きくする(実際は半角の `[` `]`) |
| B(Draw中) | ブラシの選択を開く・閉じる |
---
@@ -120,6 +128,7 @@
| --- | --- | --- |
| Civitai(https://civitai.com/) | モデルの入手・情報取得 | 第6章 |
| Ollama(https://ollama.com/) | ローカルAI | 第10章 |
| PLaMo 3 Translate(https://huggingface.co/pfnet/plamo-3-translate-2b-GGUF) | プロンプト翻訳の翻訳モデル | 第5章 |
| LM Studio(https://lmstudio.ai/) | ローカルAI | 第10章 |
| Lemonade Server(https://lemonade-server.ai/) | ローカルAI | 第10章 |
| Eagle(https://eagle.cool/) | 画像管理ソフト | 第8章 |
+3 -3
View File
@@ -2,12 +2,12 @@
Don't Be Afraid of Nodes - Generate Images More Easily and Keep Them Organized
- Covers: Workflow Studio v0.9.1
- Covers: Workflow Studio v0.9.9
- Author: ketle-man
- (c) 2026 ketle-man
This is the **text-only edition** (without screenshots) of the Kindle book.
Chapter files are in the `chapters/` folder; the whole book in one file is `Workflow_Studio_Manual_v0.9.1_en.md`.
Chapter files are in the `chapters/` folder; the whole book in one file is `Workflow_Studio_Manual_v0.9.9_en.md`.
Screen examples are omitted, so please use the book together with Workflow Studio's Help tab.
## Contents
@@ -29,4 +29,4 @@ Screen examples are omitted, so please use the book together with Workflow Studi
- [13_Appendix](chapters/13_Appendix.md)
- [14_Afterword](chapters/14_Afterword.md)
Whole book: [Workflow_Studio_Manual_v0.9.1_en.md](Workflow_Studio_Manual_v0.9.1_en.md)
Whole book: [Workflow_Studio_Manual_v0.9.9_en.md](Workflow_Studio_Manual_v0.9.9_en.md)
Binary file not shown.
@@ -2,12 +2,12 @@
Don't Be Afraid of Nodes - Generate Images More Easily and Keep Them Organized
- Covers: Workflow Studio v0.9.1
- Covers: Workflow Studio v0.9.9
- Author: ketle-man
- (c) 2026 ketle-man
This is the **text-only edition** (without screenshots) of the Kindle book.
Chapter files are in the `chapters/` folder; the whole book in one file is `Workflow_Studio_Manual_v0.9.1_en.md`.
Chapter files are in the `chapters/` folder; the whole book in one file is `Workflow_Studio_Manual_v0.9.9_en.md`.
Screen examples are omitted, so please use the book together with Workflow Studio's Help tab.
---
@@ -143,7 +143,7 @@ It is written so that you can follow it if you know basic computer operations (c
## Version and environment covered
- **Workflow Studio**: v0.9.1
- **Workflow Studio**: v0.9.9
- **ComfyUI**: the latest version at the time of writing
- **OS**: Windows (screen examples are from Windows)
@@ -621,7 +621,7 @@ It is enough to learn the tabs marked with a star under "Often used" first.
| TagSpace | Showing tags, prompts and generated images in 3D by closeness of meaning, and picking tags | | Chapter 11 |
| Settings | Language, theme, folders and other settings | | This chapter, Chapter 11 |
| Help | Feature list, shortcuts, troubleshooting | | This chapter |
| AI TOOL | Translation, chat and image analysis with local AI | | Chapter 10 |
| AI TOOL | Translation, chat, image analysis and text reading (OCR) with local AI | | Chapter 10 |
### Think of the tabs in three groups: "organize", "create" and "support"
If the number of tabs makes you lose your way, it helps to think of them in these three groups.
@@ -1220,12 +1220,13 @@ If you save it with a name, it is added as a new workflow in the Workflow tab.
Once the first image is out, next look at the **Settings** subtab, where settings that decide how the result turns out are found.
The Settings tab is divided into two blocks, left and right.
The Settings tab is divided into three columns.
- **KSampler (left)** - settings for how the image is drawn
- **Latent Image (right)** - settings for the size and number of images
- **Latent Image (middle)** - settings for the size and number of images
- **Switches (right, v0.9.6+)** - the on/off settings inside the workflow
Here too, don't forget to press **Apply** on each block after changing values.
Here too, for KSampler and Latent Image, don't forget to press **Apply** on each block after changing values (the Switches column needs no Apply).
### KSampler items
| Item | Meaning | Rule of thumb for beginners |
@@ -1252,6 +1253,23 @@ Here too, don't forget to press **Apply** on each block after changing values.
> If you stray far from the size the model learned, people tend to come out doubled or the composition falls apart.
> Even when you want portrait or landscape, adjust so the total pixel count stays about the same (for example 832x1216 for SDXL).
### Switches items (v0.9.6+)
The "on/off" settings inside the workflow are listed with their node name and item name.
Clicking a checkbox switches it right away. **You don't need to press Apply**. The new value also shows up in the Raw JSON on the right at once.
Two kinds of items are listed:
- Items whose value is true/false - for example the switch that turns the prompt enhancer (PE) on and off, "Boolean" nodes, and TextGenerate's thinking
- On/off items with only two choices - enable/disable, on/off, yes/no and so on. For example KSamplerAdvanced's add_noise and DWPreprocessor's detect_hand (whether to detect hands)
The right end of each row shows the current value (true/false, enable/disable and so on).
Hover over a row to see the node's number and type.
> **Tip**
> Items wired from another node are not listed. Instead, the source node they are wired from (for example a Boolean node named "Enable PE?") is listed, so switch that one.
> In workflows where nodes have no names, the node type name (such as ComfySwitchNode) is shown.
> If the workflow has no on/off items at all, "No true/false settings in this workflow" is shown.
### Managing the seed (generate panel)
The seed is managed with the **Seed** field in the generate panel and the pull-down below it.
@@ -1284,7 +1302,7 @@ This is the shortest path to getting used to image generation.
> **Summary of this chapter (first half)**
> - Select in the Workflow tab and press "Load in GenerateUI" to edit in GenerateUI
> - The basics are the three subtabs Input (prompt), Model (model) and Settings (detailed settings)
> - After changing the model or Settings values, always press **Apply**. If you forget, it generates with the values from before the change (prompts are reflected automatically)
> - After changing the model or Settings values, always press **Apply**. If you forget, it generates with the values from before the change (prompts and the Settings Switches column are reflected automatically)
> - Generate to produce. Alt + Apply reflects and generates in one go
> - If you set the seed to Fixed, you can keep a picture you like and compare by changing conditions. To use the workflow's seed as it is, use Workflow
@@ -1455,6 +1473,8 @@ Until the next keyframe arrives, the previous setting is carried over.
4. Decide the number of generations (Batch).
5. In each of the Model, Prompt and KSampler columns, press **+** to add a keyframe,
then double-click the keyframe and enter "from which run" and "to which setting".
Cells in the KSampler column show the items you set (Step, CFG, Denoise, sampler, scheduler, Seed).
A cell with nothing set shows "(workflow default)".
6. Press **Run**.
Results are listed in the **Results** panel.
@@ -1464,6 +1484,8 @@ Results are listed in the **Results** panel.
You can make a series of images that change little by little.
- **Plan Save** - lets you save the settings (the plan). When saved, an overview image summarizing the results is also made,
and dropping that image lets you load the same plan again.
- **Making a plan from a story** (v0.9.5+) - with the **Storyboard to Lab** skill in the AI TOOL chat,
a story is split into one prompt per scene and the **Open in Lab** button loads the plan here (Chapter 10, section 10-5).
---
@@ -1506,21 +1528,139 @@ The workflows you can use in GenerateUI have increased as follows. They are used
- **Fibo 2.0 Edit** (v0.8.14 and later) - an image-editing workflow. With the prompt enhancer (PE) setup, edits in the prompt area apply whether PE is on or off. The negative area holds a VGL-format (JSON) description as is. Width and height (Settings) of 0 mean automatic.
- **FastH3 OmniRef / Pika-H3-Flex** (v0.8.14 and later) - MiniMax H3 reference to video. Treated as video workflows, and also usable in the Video tab (Chapter 11).
- **Native LoRA stack** - ComfyUI v0.40's nodes that load several LoRAs at once (LoadLoraModel / LoadLoraTextEncoder). Apply, bypass and the Metadata display are supported.
- **P-H3 Image** (v0.9.4+) - the image-edit and T2I templates. The prompt is shown on the Input tab and can be read by the Metadata tab; there is no negative prompt field. Width and height follow the workflow's wiring, and the prompt upsampler runs as set in the workflow.
- **MiniMax H3 Image** (v0.9.6+) - ComfyUI's official image-edit and T2I templates. As with P-H3 Image, the prompt is shown on the Input tab and can be read by the Metadata tab and the sidepanel I tab; there is no negative prompt field. The prompt enhancer (PE) can be turned on and off in the Settings tab's Switches column (5-4).
> **Caution**
> The native LoRA stack nodes are supported **only in API-format workflows**.
> ComfyUI's own screen cannot yet add rows to this node, so UI-format workflows are not covered.
> **Tip**
> Workflows containing the **Compare Images** (ImageCompare) node, which compares two images with a slider, used to fail on that node when run from GenerateUI (fixed in v0.9.6).
> **Tip**
> The Metadata tab and the side panel's **I** tab can also read images made with Nano Banana (v0.8.5 and later).
> The prompt appears as one whole entry, not split into Positive/Negative.
## 5-10 Writing prompts in your own language (Prompt Translation, v0.9.9 and later)
Most image generation models were trained on English prompts.
With **Prompt Translation** turned on, you can write a prompt in your own language and turn it into English with one button.
Like the translation extensions for Stable Diffusion web UI (A1111), it translates **only the parts written in your own language**.
Translation uses AI running on your PC (**Ollama**) and the translation model **PLaMo 3 Translate**, which supports 51 languages besides English (Japanese, Chinese, Korean, French, German, Spanish, Russian, Thai, Vietnamese and more).
Your prompts are not sent to an online translation service.
> **What you need first**
> Install and start **Ollama** (Chapter 10, section 10-1). The translation model can be downloaded from the Settings screen (see below).
### Preparation: turn it on in Settings
1. In the **Settings** tab, open **Prompt Translation (native language -> English)**.
2. Check **Enable prompt translation in GenerateUI**.
3. Choose the model in **Translation model**. Models not yet in Ollama are marked **(not downloaded)**; choose one and press **Download** to pull it into Ollama.
4. Press **Test**. When the sample prompt comes back in English, you are ready.
PLaMo 3 Translate comes in four sizes.
| Model | Size | Notes |
| --- | --- | --- |
| 0.8B | about 0.6 GB | Fastest. Enough for short tags |
| 2B | about 1.8 GB | Recommended. Translates sentences accurately too |
| 8B | about 5.3 GB | Higher quality |
| 31B | about 19.5 GB | Highest quality, for PCs with plenty of memory |
> **Tip**
> 0.8B sometimes shifts the meaning of a sentence (for example, "the camera follows from behind" in Japanese became "her camera following behind").
> If you often write prompts as sentences, such as video prompts, choose 2B or larger.
The other settings are:
| Setting | What it does |
| --- | --- |
| Source language | Usually leave it at **Auto-detect**. If you always write in one language, choosing it makes detection certain |
| Ollama URL | Ollama's address. Blank means `http://localhost:11434` |
| Where to run the translation model | **GPU** or **CPU, kept loaded** (see below) |
| Translate automatically when running | Translates automatically when you press Generate and so on (see below) |
Other Ollama models (such as the one you use for chat) can also be chosen under **Other Ollama models**. They are sent the text with a "translate into English" instruction.
### Where to run the translation model
| Where | Time per phrase | Good for |
| --- | --- | --- |
| GPU (fastest per translation, uses VRAM) | about 0.1 s | GPUs with VRAM to spare |
| CPU, kept loaded (no VRAM, no reload wait) | about 0.2-0.3 s | Keeping all VRAM for image generation |
On GPU, turning on **Unload the translation model from VRAM after translating** frees VRAM before image generation (on by default).
However, every translation then waits **about 4 seconds** while the model loads again.
**CPU, kept loaded** keeps the model in system RAM (about 2.7 GB for 2B).
It uses no VRAM and is loaded in the background when a workflow is loaded into GenerateUI, so even the first translation does not wait.
> **Tip**
> When Ollama loads another model (for example the AI TOOL chat model), it may drop the resident translation model.
> It then loads again automatically at the next translation (that one translation takes a few seconds).
### Using it: translate with the globe button
With Prompt Translation on, a **globe (🌐)** button appears to the right of the **↺** button of Positive Prompt and Negative Prompt on the Input tab.
1. Write the prompt in your own language. Mixing in English tags is fine.
```
masterpiece, 夕焼けの海辺に立つ少女、(長い黒髪:1.2), <lora:test_lora:0.8>, {猫耳|狐耳}, 水彩画風
```
2. Press the globe button.
3. Only the parts in your language become English.
```
masterpiece, A girl standing by the seaside at sunset, (long black hair:1.2), <lora:test_lora:0.8>, {cat ears|fox ears}, watercolor style
```
The following prompt syntax is kept as it is, without translating:
- Commas and line breaks
- Weights `(word:1.2)` and `[ ]`
- Random choice `{A|B}` and wildcards `__name__`
- LoRA `<lora:name:0.8>` and `embedding:name`
- `BREAK` and `AND`
After translating, an **Original** button appears. Press it to go back to the text before translation (Ctrl+Z also works).
> **Note**
> Only parts that contain letters outside ASCII are translated; English-only parts stay as they are.
> Conversely, an English word that contains an accented letter such as é is translated too.
### Translating automatically when running
Under **Translate automatically when running** in Settings, checkboxes choose when to translate automatically.
- **GenerateUI - Generate**: pressing Generate replaces the text of the Positive/Negative fields with the translation, then generates
- **GenerateUI Lab - Run**: a Lab run translates only what is sent. The Lab plan keeps your text
- **Video Plan - Run**: a Video tab Plan run translates only the prompts that are sent. The plan keeps your text
Because Lab and Video Plan keep your text, you can keep editing the plan in your own language.
The information saved with the generated images and videos (metadata) records the English prompt that was actually sent.
> **Note**
> If translation fails while automatic translation is on (for example, Ollama is not running), generation stops so that untranslated text is not sent.
> For Lab and Video Plan, the reason is shown in the progress line.
### Also in the Lab modal and Video Plan
The globe button is also on these fields, and works the same way:
- The Positive and Negative fields of the screen that opens when you double-click a cell in Lab's prompt column (5-7)
- The **Prompt** field of a block in the Video tab's Plan subtab (Chapter 11, section 11-4)
> **Tip**
> PLaMo 3 Translate is free for personal use, hobbies, research and other non-commercial use (PLaMo Community License).
> Check the license terms before using it commercially.
> **Summary of this chapter (second half)**
> - With the Batch subtab, you can generate in bulk while changing the model, prompt, sampler and so on, one kind at a time
> - Choose the kind with the Batch Queue column checkbox and start with Generate. Turn the check off when done
> - Feeder is a feature that feeds many images one at a time into a workflow. A dedicated node is required
> - Lab is an advanced feature that can switch several settings at separate timings
> - Partner API nodes (Nano Banana and others) run once `COMFY_API_KEY` is set in `.env`. They consume credits
> - With Prompt Translation on, the globe button turns a prompt written in your own language into English. Prompt syntax is kept, and Generate, Lab and Video Plan runs can translate automatically
---
@@ -1936,6 +2076,10 @@ With the buttons shown below the translation result, you can use the result.
When you want to know the meaning of an English prompt, you can conversely translate it with **EN->JA**.
> **Tip**
> To translate directly in GenerateUI's prompt fields, **Prompt Translation** (the globe button) in Chapter 5, section 5-10 is handy. It turns only the parts in your language into English and keeps weights and LoRA tags.
> The AI Assistant's translation can also use the translation model **PLaMo 3 Translate** (v0.9.9 and later; before that, the instruction text was translated too, and ZH->EN came out in Japanese).
### Making prompts while consulting the AI
Write a question in the input box and press **Send** (or the Enter key) to chat with the AI.
@@ -1972,7 +2116,7 @@ and to solve "how did I make this image?".
Images generated in ComfyUI have information about the workflow and prompt used for generation (**metadata**) embedded in them.
The Gallery tab reads this information so that you can reproduce the same settings right away.
Videos (MP4 and WebM) and audio files (WAV, MP3, OGG, M4A, FLAC and Opus) can also be handled in the same list as images.
Videos (MP4 and WebM), audio files (WAV, MP3, OGG, M4A, FLAC and Opus) and 3D models (GLB, glTF, VRM, PLY and SPZ) can also be handled in the same list as images.
---
@@ -2262,6 +2406,30 @@ When you choose a video, only the audio track is extracted and saved.
> **Tip: use in the Video tab**
> In the Asset subtab of Video, you can set an audio file as "Set as BGM" or "Add as sound" (Chapter 11, section 11-4).
---
## 8-8 Viewing 3D models (v0.9.4+)
The results of ComfyUI workflows that make 3D models (such as image to 3D) can also be checked in the Gallery.
Supported formats are GLB, glTF, VRM, PLY (mesh, point cloud or Gaussian splat) and SPZ.
- They are listed with a "**3D**" badge. The thumbnail is drawn by your browser the first time the file appears in the list and is then kept on the server
(files over 128 MB get one when opened).
- When selected, the file is shown in 3D in the built-in viewer of the detail panel on the right. Double-click to enlarge it.
| Action | What it does |
| --- | --- |
| Drag | Rotate |
| Right-drag | Move (pan) |
| Mouse wheel | Zoom in / out |
| ⟲ (reset) button | Return to the starting view |
- For a model saved with ComfyUI's **SaveGLB**, the workflow can be read just like an image's (sections 8-2 and 8-3).
> **Caution**
> - 3D files cannot be sent to Image Edit, GenerateUI, Tagger or Feeder.
> - Some `.gltf` files refer to separate `.bin` or image files. Moving or deleting in the Gallery only affects the `.gltf` itself, so do not change where those files are.
> **Summary of this chapter**
> - In the Gallery's Output, you can look back at generated images folder by folder. You can also search by words in the prompt
> - The detail panel's Prompt tab shows right away the prompt used to generate the image
@@ -2270,6 +2438,7 @@ When you choose a video, only the audio track is extracted and saved.
> - If you drop an image onto the Metadata subtab, you can examine the models, LoRAs and prompt in detail
> - With the S button you can search by the meaning of a sentence or by "similar images" (semantic search)
> - Audio files can also be listed, played and converted
> - 3D models (GLB, glTF, VRM, PLY, SPZ) can also be turned around and checked in the Gallery (8-8)
---
@@ -2456,6 +2625,9 @@ If you prepare local AI, you can do things like the following.
- Chat with the AI and have it come up with prompt ideas
- Show it an image and have it make a description, prompt or tags for that image
- Have it make candidate lists for wildcards
- Pick a **skill** to switch what it is good at: writing prompts, storyboards, troubleshooting and more (v0.9.5+)
- Have it check whether a generated image matches your request and fix only what is missing (v0.9.5+)
- Read the text shown in an image (OCR, v0.9.5+)
Because it runs inside your own computer rather than as a service on the internet,
a big feature is that **what you type and the images you use are not sent outside**.
@@ -2518,10 +2690,14 @@ The screen is divided into four parts, all shown at the same time.
| Part | What you can do |
| --- | --- |
| Translate | Translation between languages such as Japanese, English and Chinese |
| Chat | Conversation with the AI. If the conditions are met, generating images from the conversation too |
| TOOLS | Reading images (VLM), making wildcards |
| Chat | Conversation with the AI. Skills switch what it is good at. If the conditions are met, generating images from the conversation too |
| TOOLS | Reading images (VLM), reading text (OCR), making wildcards |
| Settings | Settings for which AI software and model to use |
> **Tip: Translate and Settings can be collapsed (v0.9.5+)**
> Press the arrow (◀ / ▶) at the right end of the Translate or Settings header to collapse that part into a thin strip, giving Chat and TOOLS more room.
> Click anywhere on the strip to open it again. The collapsed state is kept the next time you open the tab.
### First: connect to the AI software in the settings
1. In **Backend** under the settings, choose the software to use (for example Ollama).
2. Check the address under **Connection**. If you use Ollama with its defaults, no change is needed.
@@ -2545,10 +2721,18 @@ The screen is divided into four parts, all shown at the same time.
2. Write the text in the input box and press **Translate**.
3. **Copy** the result and paste it into GenerateUI or a preset.
> **Tip**
> Text read in TOOLS (such as OCR in 10-8) can be put straight into this input box with **To Translation** in TOOLS.
> **Tip**
> Small models sometimes return the original text as it is without translating.
> In that case a message says the model returned the original text, so try another model.
> **Tip**
> You can also choose the translation model **PLaMo 3 Translate** (Chapter 5, section 5-10) as the model in Settings (v0.9.9 and later).
> Besides Japanese, English and Chinese, **Free** accepts language names such as French, フランス語 or français for any language PLaMo supports. A target language PLaMo does not support (such as Portuguese) gives an error.
> The same applies to the translation in WS Library's A tab.
### Chat
Talk in the input box and send with **Enter** (**Shift + Enter** for a line break).
It remembers the flow of the conversation, so follow-up requests such as "make it a brighter mood" also work.
@@ -2559,6 +2743,10 @@ It remembers the flow of the conversation, so follow-up requests such as "make i
> just asking in chat "draw a cat" generates an image with the workflow loaded in GenerateUI, and it is shown inside the chat.
> This feature can be turned on or off with the **Allow image generation** check next to the input box.
> **Tip**
> Choose a **skill** in the dropdown above the chat to switch what the AI is good at (10-5).
> The AI's replies are shown with headings, lists and code boxes formatted (v0.9.5+).
### TOOLS - reading images (VLM)
With a model that supports image input (a VLM), you can have the AI read the contents of an image.
@@ -2571,8 +2759,16 @@ With a model that supports image input (a VLM), you can have the AI read the con
| Create prompt | Makes a prompt for reproducing the image |
| Create tags | Writes out the elements of the image in tag format |
| Create wildcards | Makes candidate wildcard lists by specifying a category name and count (no image needed) |
| OCR (extract text) | Reads the text shown in the image (10-8) |
3. Press **Run**. You can copy the result and use it.
3. Press **Run**.
4. Use the result with the buttons under it (v0.9.5+).
| Button | What it does |
| --- | --- |
| To Translation | Puts it into the Translate input box (opens Translate if it is collapsed) |
| To Chat | Adds it to the chat input box |
| Copy | Copies it to the clipboard |
> **Example**
> When you want to imitate the mood of an illustration you like, run "Create prompt" on that image
@@ -2639,12 +2835,229 @@ In that case, anyone who can access it can use your AI software and images.
> Use `--listen` **only on a trusted network**, such as a home LAN.
> Do not use it in cafes or on public Wi-Fi.
---
## 10-5 Skills - switching what the chat is good at (v0.9.5+)
A **skill** is a set of instructions that tells the chat what role to play and how to answer.
When you pick one in the dropdown above the chat (it starts as "-- No skill --"), its instructions are sent along with every message
(the instructions themselves are not shown in the chat).
### Built-in skills
Workflow Studio comes with the following six skills.
| Skill | What it does | How you use the result |
| --- | --- | --- |
| T2I Prompt Enhancer | Turns a short idea into a prompt written the way the model in your GenerateUI workflow understands best | Buttons under the prompt |
| Image to Prompt | Writes a prompt that recreates the image you put in TOOLS (needs a model that can read images) | Buttons under the prompt |
| Storyboard to Lab | Splits a story into one prompt per scene, ready for continuous generation in Lab | **Open in Lab** |
| Workflow Doctor | Explains the workflow and helps you find the cause of errors (10-7) | Answers in text |
| SVG Icon Generator | Draws simple icons and illustrations as SVG (vector images) | Preview and **Save to Gallery** |
| Skill Creator | Asks you questions and builds a new skill (10-9) | **Save as new skill** |
### Making a prompt and generating with it (T2I Prompt Enhancer)
1. Load the workflow you want to use into GenerateUI. The skill looks at that workflow's model to decide how to write the prompt.
2. In the AI TOOL chat, choose **T2I Prompt Enhancer** in the dropdown.
3. Describe the picture in your own words, for example "a cat holding an umbrella in rainy Tokyo at night, neon", and send it.
4. The reply shows which writing style was chosen (the `Style:` line) and the English prompt in a box. Use the buttons under it.
| Button | What it does |
| --- | --- |
| Apply to GenerateUI | Writes the positive / negative prompt into GenerateUI |
| Generate with this prompt | Generates right away and shows the image in the chat |
| Copy | Copies the positive prompt |
The writing style depends on the model:
| Model in GenerateUI | How the prompt is written |
| --- | --- |
| Qwen-Image, FLUX, Z-Image, etc. | English sentences (the negative is left empty when CFG is about 1) |
| Illustrious, NoobAI, Pony, etc. (SDXL anime models) | Danbooru tags (starting with quality tags) |
| Realistic SDXL, SD1.5 | Short phrases separated by commas |
> **Tip**
> Follow-up requests such as "make it more night-like" or "two cats" give you the whole updated prompt again.
> **Tip: the prompt currently in GenerateUI is not sent**
> Normally the prompt already typed into GenerateUI is not passed to the AI, because small models tend to mix it (for example an old negative prompt) into the new prompt.
> It is passed only when your message refers to it, such as "**improve the current prompt**".
### Generating a storyboard in a row (Storyboard to Lab)
1. Load a text-to-image (T2I) workflow into GenerateUI.
2. In the chat, choose **Storyboard to Lab** and ask, for example, "A tabby kitten wakes up in the morning, chases a butterfly in the garden, and naps on the veranda in the evening. 3 scenes."
3. The reply shows the scene list and an **Open in Lab (3 scenes)** button. Press it.
4. GenerateUI's **Lab** (Chapter 5, section 5-7) opens with the plan loaded as an unsaved plan.
T2I mode is on, Batch is the number of scenes, and the Prompt column has one keyframe per scene. The KSampler column holds a seed shared by all scenes (`Seed ...`).
5. Check it and press **Run**. To keep it, use **Plan Save**.
> **Tip**
> The characters' looks (hair, clothing colors and so on) are written with the same words in every scene, and the seed is fixed,
> so the same character is easier to keep across scenes.
### Automatic check of replies
For skills that output a prompt or an SVG, Workflow Studio checks the shape of the reply automatically.
If, for example, the prompt box is broken or the SVG is not closed, a dashed notice "**Auto-check: ...**" appears and the AI is asked once to fix it.
Replies that do not try to output a prompt or SVG (for example when you only asked for an explanation) are left alone.
### Managing skills (pencil button)
The pencil button to the right of the dropdown opens the skill list.
- **+ New** writes a new skill, the pencil on each row edits or deletes it, and **Import** adds other skills (10-9)
- Skills that ship with Workflow Studio are marked **built-in**.
Built-in skills you have not edited are updated automatically when Workflow Studio is updated.
An edited one is not replaced automatically; when a newer version exists, a **↻ (update)** button appears.
- Skill files are saved in `ComfyUI/user/default/Workflow-Studio/ai_skills/`.
> **Caution**
> Replacing a skill with the newer version via ↻ (update) discards your edits to that skill.
---
## 10-6 Checking generated images and fixing them (v0.9.5+)
This feature has the AI check whether an image generated from the chat matches what you asked for.
If something is missing, you can redraw with a prompt that fixes just that.
### Preparation: a judging model
The check does not use a normal chat model but an Ollama **decision model** (a model that answers yes/no questions with a probability).
Get one that can read images with `ollama pull` (the author confirmed `d3:4b`, `clef-flash` and `clef`).
> **Tip: why a separate model**
> In the author's tests, a chat model shown an image sometimes answered "yes" to "is the person holding a sword?" when there was no sword.
> A decision model returns the probability of "yes" as a number, so uncertain answers can be told apart.
1. In AI TOOL's **Settings**, under **Chat Image Check**, choose the **Judge model (Ollama decision model)** (press **Refresh** if the list is empty).
2. Choose **Automatic fix rounds**. **0 (fix by button)** is recommended at first.
3. Press **Save Settings**.
### How to use it
1. Tick **Check images** below the chat input.
2. Generate an image from the chat (the AI's image generation, or **Generate with this prompt**).
3. A result card appears under the image. The AI splits your request into 3 to 8 check items and checks them one by one.
| Mark | Meaning |
| --- | --- |
| ✔ (met) | Probability of "yes" is 85% or more |
| ? (unclear) | 30-85% |
| ✘ (not met) | Less than 30% |
4. If there is a ✘ or ?, press **Fix missing items and regenerate**. Only the unmet items are sent to the AI, which rewrites the prompt and draws again.
If you set Automatic fix rounds to 1-3, this repeats automatically up to that number of times.
> **Tip: SVGs can be checked too**
> SVGs drawn with SVG Icon Generator are turned into an image and checked for "does it look like what you asked for" and "are its parts (beak, wings and so on) drawn".
> **Ask to redraw unclear parts** asks the AI to fix them.
> **Caution**
> - The check is not perfect. It is especially weak at "who is wearing what",
> so when there are several people it automatically adds reverse check items such as "the hat is not on the girl" to compensate.
> - How well the redraw works depends on the chat model. If it does not improve, change your request or the model.
> - The judging model also uses GPU memory (about 6 GB for `d3:4b`). Once loaded, a check takes a few seconds.
---
## 10-7 Asking about workflow problems (Workflow Doctor, v0.9.5+)
**Workflow Doctor** is a skill that explains the workflow loaded in GenerateUI and helps you find the cause of errors.
Instead of relying only on the AI's knowledge, every time you send a message Workflow Studio passes it the following facts it has actually checked.
| What is checked | Example |
| --- | --- |
| Nodes that are not installed | Names of nodes ComfyUI does not know |
| Files and values not in ComfyUI's lists | Models or LoRAs that cannot be found (with similar names) |
| Connections | Inputs that are not connected, links to nodes that do not exist |
| The last execution error | The error recorded in ComfyUI's history |
| ComfyUI's log | The latest error part of the log |
### How to use it
1. Load the workflow you want to ask about into GenerateUI (for an error, run it once so the error is recorded).
2. In the chat, choose **Workflow Doctor**.
3. Ask, for example, "check this workflow for problems before I run it" or "what caused the last error?".
> **Example**
> For a workflow whose LoRA file had been moved to another folder, it answered
> "the file specified in the `temp\` folder cannot be found; a file with the same name exists in `Illustrious\`", including how to fix it.
> **Tip**
> The checked facts are rebuilt every time you send a message. After fixing something, just ask again.
---
## 10-8 Reading text in images (OCR, v0.9.5+)
In TOOLS you can read the text shown in an image. The text you read can be sent straight to translation or the chat.
### Preparation: an OCR model
OCR uses a model that is good at reading text, separate from the chat model. Prepare one in Ollama.
These are the author's results on an image mixing horizontal and vertical Japanese and English text.
| Model | Time | Result |
| --- | --- | --- |
| LightOnOCR-3 (`maternion/LightOnOCR-3:4b`) | About 1 s (6-8 s with positions) | Read everything |
| PaddleOCR-VL (manga version) | About 4 s | Read everything |
| DeepSeek-OCR family | About 14 s | Read everything (always with positions) |
| PaddleOCR-VL 1.6, GLM-OCR | About 11-15 s | Missed the vertical text |
### How to use it
1. Drop an image into TOOLS.
2. Choose **OCR (extract text)** as the task.
3. Choose the **OCR model**. Ollama models whose name contains "ocr" are listed, best first (press ↻ if the list is empty).
4. Press **Run**. The text is shown in the result box, one line each.
> **Tip: Show text positions**
> Tick **Show text positions** to draw numbered boxes over the image so you can see where each text is.
> Clicking a box selects the same line in the result box.
> Only LightOnOCR and the DeepSeek-OCR family can return positions; for other models this check cannot be selected.
> **Tip**
> If the result is empty or the same line repeats, it is automatically read once more in grayscale.
---
## 10-9 Making and importing skills (advanced, v0.9.5+)
### Making one with Skill Creator
In the chat, choose **Skill Creator** and say something like "I want a skill that is good at ...".
The AI asks questions one at a time; answer them and you get a draft skill.
Press **Save as new skill** under the reply; the skill list opens with the draft filled in, so check it and save.
You can also ask it to improve an existing skill, for example "this part of this skill does not work well".
### What a skill file contains
A skill is a text file (`.md`). Write the name and description in the part enclosed by `---` at the top, and the instructions for the AI below it.
Under `metadata:` in the top part you can also write these settings (all optional).
| Setting | Meaning |
| --- | --- |
| `output` | `prompt` or `svg`. Checks the shape of the reply automatically and adds the buttons |
| `tools` | `[]` stops the AI from starting image generation on its own |
| `temperature` | How varied the answers are (0.3 stable, 0.9 free) |
| `think` | Turns Thinking mode on or off just for this skill |
| `context` | Information passed to the AI: `workflow` (workflow summary), `current-prompt` (the current prompt), `workflow-detail` / `logs` (the same checks as Workflow Doctor) |
### Importing other skills
**Import** in the skill list adds:
- a single `.md` skill
- a ZIP of a folder containing `SKILL.md` (the **Agent Skills** format shared by many AI tools)
Text files in the folder (reference material and so on) are imported too, and the AI reads them only when it needs them
(this needs a model that supports tool calling).
> **Caution**
> - Only text files are imported. Programs such as scripts are not imported and never run.
> - A skill's instructions are passed to the AI as they are. Read a skill made by someone else before using it.
> **Summary of this chapter**
> - If you prepare local AI (Ollama and so on), you can translate, chat and read images. What you type is not sent outside
> - In the AI TOOL tab's settings, choose the backend, address and model, and test the connection
> - The Prompt tab and Tagger tab have separate gear-button settings
> - AI and image generation compete for VRAM. Free it with "Unload Model" or "VRAM Management (Ollama)"
> - By default it connects only to AI on your own computer. Use `--listen` only on a trusted network
> - **Skills** switch what the chat is good at. T2I Prompt Enhancer writes a prompt that buttons apply to GenerateUI or generate with
> - With **Check images** on, a decision model checks the generated image and you can redraw fixing only what is missing
> - Workflow Doctor helps with workflow problems based on facts it has actually checked
> - **OCR (extract text)** in TOOLS reads the text in an image and sends it to translation or the chat
---
@@ -2753,6 +3166,22 @@ You can put text on a generated image, or make a mask for redrawing part of it.
- Save the edited image with **Save PNG** (download), **Save to Gallery** and so on.
- Undo with **Ctrl + Z**, redo with **Ctrl + Y**.
### Draw colors and shortcuts (v0.9.3+)
When you choose **Draw**, a **color palette** appears in the second row of the tool options.
- It shows **Color 1 / Color 2**, 20 basic colors and 20 custom slots. Click a color to paint with it.
- Click **+** or an empty slot to register the current color as a custom color. Right-click a color to register, edit or delete it (basic colors can be changed too, and returned to their original color).
Registered colors are saved per browser.
- The **eyedropper** button next to **Color** on the right picks a color from the canvas (Esc cancels).
- The starting colors are black (Color 1) and white (Color 2).
| Key (while Draw is active) | What it does |
| --- | --- |
| D / E | Draw / Erase |
| X | Swap Color 1 and Color 2 |
| [ / ] | Make the brush smaller / larger |
| B | Open or close the brush picker (Esc also closes it) |
### Inpainting (redrawing part of an image)
The handiest use of Image Edit is **inpainting**.
It is for when "I want to redraw only the face" or "I want to fix only the place where the hand broke".
@@ -2789,6 +3218,14 @@ You load a matching workflow with **Load in Video** in the Workflow tab and use
There are also the **Frame** feature, which saves a favorite scene of a video as a still image, and **GIF**, which converts a video to an animated GIF.
> **Tip**
> The **Prompt** field of a Plan block also has the Prompt Translation globe button (Chapter 5, section 5-10).
> With **Video Plan - Run** turned on in Settings, you can run the plan with prompts in your own language and send only English.
> **Note**
> Up to v0.9.8, with workflows saved by newer ComfyUI versions, the prompt, length (Duration) and Turbo settings entered in Plan were not applied, and the values saved in the workflow were used instead (fixed in v0.9.9).
> Because Plan values are applied now, running the same plan as before may give different results.
### Register as Asset and audio conversion (v0.8.9 and later)
- **Register as Asset** - a button in the Video Source panel on the left. It copies a video from your PC into the output folder (`output/video`) and registers it in the "Video Assets" group.
Once registered, it appears in the Asset subtab list and can be used in Edit and elsewhere.
@@ -2837,6 +3274,7 @@ Here we mainly introduce items not covered in earlier chapters.
| CivitAI API Key | For fetching Civitai information (optional) | Chapter 6 |
| Eagle integration (optional) | Automatically save generated images to Eagle | Chapter 8 |
| VRAM Management (Ollama) | Unload AI models from memory before generation | Chapter 10 |
| Prompt Translation (native language -> English) | Turn prompts in your own language into English with the globe button or automatic translation when running | Chapter 5, 5-10 |
| Data Management | Backing up and restoring settings and data | Below |
### Default Workflow
@@ -3056,6 +3494,7 @@ This means **the custom nodes the workflow needs are not installed**.
### You changed a setting but the result did not change
The most common cause is **forgetting to press Apply**.
In GenerateUI, after changing the model or Settings values (steps, size and so on), the change is not reflected in the workflow unless you press **Apply** (Chapter 5, section 5-3).
The Switches column at the right of the Settings tab is the exception: it takes effect the moment you click (Chapter 5, section 5-4).
Looking at the **Raw JSON** on the right lets you check the values actually reflected.
### It generates something different from the loaded workflow
@@ -3071,6 +3510,15 @@ In the **Model** subtab of GenerateUI, choose the model you want to use again an
If you always want to use the same model, the **Default Checkpoint** in the Settings tab is handy (Chapter 11, section 11-5).
### The Prompt Translation globe button does not appear or translation fails
| Symptom | Cause | Fix |
| --- | --- | --- |
| No globe button | Prompt Translation is off | In the Settings tab, open **Prompt Translation (native language -> English)** and check **Enable prompt translation in GenerateUI** (Chapter 5, section 5-10) |
| "Translation error" appears | Ollama is not running, or the translation model is not in Ollama | Start Ollama. If **Translation model** shows **(not downloaded)**, press **Download** |
| Nothing changes ("Nothing to translate") | The prompt is English (ASCII) only | Only parts with letters outside ASCII are translated; English parts stay as they are |
| Generation does not start with automatic translation on | Translation failed, so generation stopped instead of sending untranslated text | Same fix as "Translation error". In Lab and Video Plan the reason is shown in the progress line |
| The translation is off | Small models (0.8B) can shift the meaning of sentences | Choose 2B or larger in **Translation model** |
### It does not become the same image even with the same settings
Is the seed mode in the generate panel set to **Random**?
To make the same image, you need to set the seed to **Workflow** (use the workflow's seed as it is) or **Fixed** (fix it to the value in the Seed field).
@@ -3119,6 +3567,21 @@ For Ollama, download the model with `ollama pull (model name)`, then press **Ref
For safety, by default it connects only to AI software inside the same computer.
You need to set the environment variable `WFS_ALLOWED_BACKEND_HOSTS` (Chapter 10, section 10-4).
### The judge model for image checks, or the OCR model, does not appear in the list
- The judge model list shows only Ollama **decision models** that can read images; normal chat models are not shown.
Update Ollama, `ollama pull` a decision model, then press **Refresh** (Chapter 10, section 10-6).
- The OCR model list shows only Ollama models whose name contains "ocr". Press ↻ after getting one (Chapter 10, section 10-8).
- Both look at Ollama at the AI TOOL backend address when the backend is Ollama, otherwise at `http://localhost:11434`.
### Image checks never pass no matter how often it fixes
- How well the redraw works depends on the chat model. Make your request shorter and more concrete, or try another model.
- The check itself can be wrong too. Look at the image yourself as well.
- Too many automatic fix rounds keep using generation time and GPU memory. "0 (fix by button)" is recommended at first.
### The AI does not read a skill's reference files, or does not generate images from the chat
Reading the reference files of an imported skill and generating images from the chat only work with
**a model that supports tool calling**. Switch to such a model.
---
## 12-5 Troubles with other features
@@ -3156,6 +3619,15 @@ Run the installation command shown in the error message in the Python that Comfy
The cause is a missing Comfy API key in `.env`. Write `COMFY_API_KEY=your key` (issued at platform.comfy.org) in the plugin's `.env` and restart ComfyUI (Chapter 5, section 5-8).
`.env` is read only at startup.
### ComfyUI freezes (no tab responds)
On Windows, ComfyUI can stop responding (generation included), for example after switching a Models tab list with many preview images.
In the Settings tab, under **Windows Stability (Event Loop)**, turn on **Use the Selector event loop on Windows (restart required)** and restart ComfyUI.
### Part of a Gallery image looks broken, as if mixed with another image
With the **Selector event loop** above turned on, up to v0.9.1 part of an image received by the Gallery preview or Download could be corrupted
(the file in the output folder itself is fine). This is fixed in v0.9.2.
After updating Workflow Studio, broken images may remain in the browser cache, so reload with **Ctrl + F5**.
### Images do not appear in the Gallery
- Press **Refresh** in the Gallery.
- Check that the "Gallery Output Folder" in the Settings tab matches where ComfyUI saves images.
@@ -3208,6 +3680,7 @@ The main terms that appear in this book, in alphabetical order.
| Civitai | A sharing site for image-generation models | Chapter 6 |
| ComfyUI Manager | A management tool for searching for and installing custom nodes | Chapter 2 |
| Custom node | A node or extension added to ComfyUI afterwards. Workflow Studio is one of them | Chapter 1 |
| Decision model | An AI model that answers questions with numbers such as the probability of "yes". Used to judge image checks | Chapter 10 |
| Denoise | How strongly to redraw the original image | Chapter 5 |
| Embedding | A small file that teaches a particular word a meaning | Chapter 6 |
| Hash value | A "fingerprint"-like value computed from a file's contents. Used to look up models on Civitai | Chapter 6 |
@@ -3223,7 +3696,9 @@ The main terms that appear in this book, in alphabetical order.
| Negative prompt | A prompt where you write what you do not want drawn | Chapter 7 |
| Node | A "box" arranged on ComfyUI's screen. It handles one process | Chapter 1 |
| Node set | Several nodes and their connections saved together | Chapter 9 |
| OCR | Reading the text shown in an image | Chapter 10 |
| Ollama | Software for running local AI easily | Chapter 10 |
| PLaMo 3 Translate | A translation AI model by Preferred Networks (PFN), used by Prompt Translation | Chapter 5 |
| Port number | A number for distinguishing which software to communicate with inside one computer | Chapter 2 |
| Positive prompt | A prompt where you write what you want drawn | Chapter 7 |
| Preset | A pair of positive and negative prompts saved together | Chapter 7 |
@@ -3233,6 +3708,7 @@ The main terms that appear in this book, in alphabetical order.
| Scheduler | How the drawing amount is distributed across steps | Chapter 5 |
| Seed | The seed of random numbers an image grows from. If the same, you get almost the same image | Chapter 5 |
| Semantic search | Searching images by the "meaning" of a sentence or image. Used with the Gallery's S button | Chapter 8 |
| Skill | Instructions that tell the AI TOOL chat its role and how to answer. Picking one switches what it is good at | Chapter 10 |
| Steps | The number of times drawing is repeated | Chapter 5 |
| Style | A mood template added to a prompt | Chapter 7 |
| T2I (Text to Image) | Making an image from text (a prompt) | Chapter 5 |
@@ -3287,6 +3763,10 @@ The main terms that appear in this book, in alphabetical order.
| Mouse wheel | Zoom in and out |
| Space + drag | Move the view position |
| Delete | Delete the selected layer (when there are two or more layers) |
| D / E (while Draw is active) | Draw / Erase |
| X (while Draw is active) | Swap Color 1 and Color 2 |
| [ / ] (while Draw is active) | Make the brush smaller / larger |
| B (while Draw is active) | Open or close the brush picker |
---
@@ -3307,6 +3787,7 @@ The main terms that appear in this book, in alphabetical order.
| --- | --- | --- |
| Civitai (https://civitai.com/) | Getting models, fetching information | Chapter 6 |
| Ollama (https://ollama.com/) | Local AI | Chapter 10 |
| PLaMo 3 Translate (https://huggingface.co/pfnet/plamo-3-translate-2b-GGUF) | Translation model for Prompt Translation | Chapter 5 |
| LM Studio (https://lmstudio.ai/) | Local AI | Chapter 10 |
| Lemonade Server (https://lemonade-server.ai/) | Local AI | Chapter 10 |
| Eagle (https://eagle.cool/) | Image-management software | Chapter 8 |
Binary file not shown.
+1 -1
View File
@@ -129,7 +129,7 @@ It is written so that you can follow it if you know basic computer operations (c
## Version and environment covered
- **Workflow Studio**: v0.9.1
- **Workflow Studio**: v0.9.9
- **ComfyUI**: the latest version at the time of writing
- **OS**: Windows (screen examples are from Windows)
@@ -27,7 +27,7 @@ It is enough to learn the tabs marked with a star under "Often used" first.
| TagSpace | Showing tags, prompts and generated images in 3D by closeness of meaning, and picking tags | | Chapter 11 |
| Settings | Language, theme, folders and other settings | | This chapter, Chapter 11 |
| Help | Feature list, shortcuts, troubleshooting | | This chapter |
| AI TOOL | Translation, chat and image analysis with local AI | | Chapter 10 |
| AI TOOL | Translation, chat, image analysis and text reading (OCR) with local AI | | Chapter 10 |
### Think of the tabs in three groups: "organize", "create" and "support"
If the number of tabs makes you lose your way, it helps to think of them in these three groups.
@@ -168,12 +168,13 @@ If you save it with a name, it is added as a new workflow in the Workflow tab.
Once the first image is out, next look at the **Settings** subtab, where settings that decide how the result turns out are found.
The Settings tab is divided into two blocks, left and right.
The Settings tab is divided into three columns.
- **KSampler (left)** - settings for how the image is drawn
- **Latent Image (right)** - settings for the size and number of images
- **Latent Image (middle)** - settings for the size and number of images
- **Switches (right, v0.9.6+)** - the on/off settings inside the workflow
Here too, don't forget to press **Apply** on each block after changing values.
Here too, for KSampler and Latent Image, don't forget to press **Apply** on each block after changing values (the Switches column needs no Apply).
### KSampler items
| Item | Meaning | Rule of thumb for beginners |
@@ -200,6 +201,23 @@ Here too, don't forget to press **Apply** on each block after changing values.
> If you stray far from the size the model learned, people tend to come out doubled or the composition falls apart.
> Even when you want portrait or landscape, adjust so the total pixel count stays about the same (for example 832x1216 for SDXL).
### Switches items (v0.9.6+)
The "on/off" settings inside the workflow are listed with their node name and item name.
Clicking a checkbox switches it right away. **You don't need to press Apply**. The new value also shows up in the Raw JSON on the right at once.
Two kinds of items are listed:
- Items whose value is true/false - for example the switch that turns the prompt enhancer (PE) on and off, "Boolean" nodes, and TextGenerate's thinking
- On/off items with only two choices - enable/disable, on/off, yes/no and so on. For example KSamplerAdvanced's add_noise and DWPreprocessor's detect_hand (whether to detect hands)
The right end of each row shows the current value (true/false, enable/disable and so on).
Hover over a row to see the node's number and type.
> **Tip**
> Items wired from another node are not listed. Instead, the source node they are wired from (for example a Boolean node named "Enable PE?") is listed, so switch that one.
> In workflows where nodes have no names, the node type name (such as ComfySwitchNode) is shown.
> If the workflow has no on/off items at all, "No true/false settings in this workflow" is shown.
### Managing the seed (generate panel)
The seed is managed with the **Seed** field in the generate panel and the pull-down below it.
@@ -232,6 +250,6 @@ This is the shortest path to getting used to image generation.
> **Summary of this chapter (first half)**
> - Select in the Workflow tab and press "Load in GenerateUI" to edit in GenerateUI
> - The basics are the three subtabs Input (prompt), Model (model) and Settings (detailed settings)
> - After changing the model or Settings values, always press **Apply**. If you forget, it generates with the values from before the change (prompts are reflected automatically)
> - After changing the model or Settings values, always press **Apply**. If you forget, it generates with the values from before the change (prompts and the Settings Switches column are reflected automatically)
> - Generate to produce. Alt + Apply reflects and generates in one go
> - If you set the seed to Fixed, you can keep a picture you like and compare by changing conditions. To use the workflow's seed as it is, use Workflow
@@ -163,6 +163,8 @@ Until the next keyframe arrives, the previous setting is carried over.
4. Decide the number of generations (Batch).
5. In each of the Model, Prompt and KSampler columns, press **+** to add a keyframe,
then double-click the keyframe and enter "from which run" and "to which setting".
Cells in the KSampler column show the items you set (Step, CFG, Denoise, sampler, scheduler, Seed).
A cell with nothing set shows "(workflow default)".
6. Press **Run**.
Results are listed in the **Results** panel.
@@ -172,6 +174,8 @@ Results are listed in the **Results** panel.
You can make a series of images that change little by little.
- **Plan Save** - lets you save the settings (the plan). When saved, an overview image summarizing the results is also made,
and dropping that image lets you load the same plan again.
- **Making a plan from a story** (v0.9.5+) - with the **Storyboard to Lab** skill in the AI TOOL chat,
a story is split into one prompt per scene and the **Open in Lab** button loads the plan here (Chapter 10, section 10-5).
---
@@ -214,18 +218,136 @@ The workflows you can use in GenerateUI have increased as follows. They are used
- **Fibo 2.0 Edit** (v0.8.14 and later) - an image-editing workflow. With the prompt enhancer (PE) setup, edits in the prompt area apply whether PE is on or off. The negative area holds a VGL-format (JSON) description as is. Width and height (Settings) of 0 mean automatic.
- **FastH3 OmniRef / Pika-H3-Flex** (v0.8.14 and later) - MiniMax H3 reference to video. Treated as video workflows, and also usable in the Video tab (Chapter 11).
- **Native LoRA stack** - ComfyUI v0.40's nodes that load several LoRAs at once (LoadLoraModel / LoadLoraTextEncoder). Apply, bypass and the Metadata display are supported.
- **P-H3 Image** (v0.9.4+) - the image-edit and T2I templates. The prompt is shown on the Input tab and can be read by the Metadata tab; there is no negative prompt field. Width and height follow the workflow's wiring, and the prompt upsampler runs as set in the workflow.
- **MiniMax H3 Image** (v0.9.6+) - ComfyUI's official image-edit and T2I templates. As with P-H3 Image, the prompt is shown on the Input tab and can be read by the Metadata tab and the sidepanel I tab; there is no negative prompt field. The prompt enhancer (PE) can be turned on and off in the Settings tab's Switches column (5-4).
> **Caution**
> The native LoRA stack nodes are supported **only in API-format workflows**.
> ComfyUI's own screen cannot yet add rows to this node, so UI-format workflows are not covered.
> **Tip**
> Workflows containing the **Compare Images** (ImageCompare) node, which compares two images with a slider, used to fail on that node when run from GenerateUI (fixed in v0.9.6).
> **Tip**
> The Metadata tab and the side panel's **I** tab can also read images made with Nano Banana (v0.8.5 and later).
> The prompt appears as one whole entry, not split into Positive/Negative.
## 5-10 Writing prompts in your own language (Prompt Translation, v0.9.9 and later)
Most image generation models were trained on English prompts.
With **Prompt Translation** turned on, you can write a prompt in your own language and turn it into English with one button.
Like the translation extensions for Stable Diffusion web UI (A1111), it translates **only the parts written in your own language**.
Translation uses AI running on your PC (**Ollama**) and the translation model **PLaMo 3 Translate**, which supports 51 languages besides English (Japanese, Chinese, Korean, French, German, Spanish, Russian, Thai, Vietnamese and more).
Your prompts are not sent to an online translation service.
> **What you need first**
> Install and start **Ollama** (Chapter 10, section 10-1). The translation model can be downloaded from the Settings screen (see below).
### Preparation: turn it on in Settings
1. In the **Settings** tab, open **Prompt Translation (native language -> English)**.
2. Check **Enable prompt translation in GenerateUI**.
3. Choose the model in **Translation model**. Models not yet in Ollama are marked **(not downloaded)**; choose one and press **Download** to pull it into Ollama.
4. Press **Test**. When the sample prompt comes back in English, you are ready.
PLaMo 3 Translate comes in four sizes.
| Model | Size | Notes |
| --- | --- | --- |
| 0.8B | about 0.6 GB | Fastest. Enough for short tags |
| 2B | about 1.8 GB | Recommended. Translates sentences accurately too |
| 8B | about 5.3 GB | Higher quality |
| 31B | about 19.5 GB | Highest quality, for PCs with plenty of memory |
> **Tip**
> 0.8B sometimes shifts the meaning of a sentence (for example, "the camera follows from behind" in Japanese became "her camera following behind").
> If you often write prompts as sentences, such as video prompts, choose 2B or larger.
The other settings are:
| Setting | What it does |
| --- | --- |
| Source language | Usually leave it at **Auto-detect**. If you always write in one language, choosing it makes detection certain |
| Ollama URL | Ollama's address. Blank means `http://localhost:11434` |
| Where to run the translation model | **GPU** or **CPU, kept loaded** (see below) |
| Translate automatically when running | Translates automatically when you press Generate and so on (see below) |
Other Ollama models (such as the one you use for chat) can also be chosen under **Other Ollama models**. They are sent the text with a "translate into English" instruction.
### Where to run the translation model
| Where | Time per phrase | Good for |
| --- | --- | --- |
| GPU (fastest per translation, uses VRAM) | about 0.1 s | GPUs with VRAM to spare |
| CPU, kept loaded (no VRAM, no reload wait) | about 0.2-0.3 s | Keeping all VRAM for image generation |
On GPU, turning on **Unload the translation model from VRAM after translating** frees VRAM before image generation (on by default).
However, every translation then waits **about 4 seconds** while the model loads again.
**CPU, kept loaded** keeps the model in system RAM (about 2.7 GB for 2B).
It uses no VRAM and is loaded in the background when a workflow is loaded into GenerateUI, so even the first translation does not wait.
> **Tip**
> When Ollama loads another model (for example the AI TOOL chat model), it may drop the resident translation model.
> It then loads again automatically at the next translation (that one translation takes a few seconds).
### Using it: translate with the globe button
With Prompt Translation on, a **globe (🌐)** button appears to the right of the **↺** button of Positive Prompt and Negative Prompt on the Input tab.
1. Write the prompt in your own language. Mixing in English tags is fine.
```
masterpiece, 夕焼けの海辺に立つ少女、(長い黒髪:1.2), <lora:test_lora:0.8>, {猫耳|狐耳}, 水彩画風
```
2. Press the globe button.
3. Only the parts in your language become English.
```
masterpiece, A girl standing by the seaside at sunset, (long black hair:1.2), <lora:test_lora:0.8>, {cat ears|fox ears}, watercolor style
```
The following prompt syntax is kept as it is, without translating:
- Commas and line breaks
- Weights `(word:1.2)` and `[ ]`
- Random choice `{A|B}` and wildcards `__name__`
- LoRA `<lora:name:0.8>` and `embedding:name`
- `BREAK` and `AND`
After translating, an **Original** button appears. Press it to go back to the text before translation (Ctrl+Z also works).
> **Note**
> Only parts that contain letters outside ASCII are translated; English-only parts stay as they are.
> Conversely, an English word that contains an accented letter such as é is translated too.
### Translating automatically when running
Under **Translate automatically when running** in Settings, checkboxes choose when to translate automatically.
- **GenerateUI - Generate**: pressing Generate replaces the text of the Positive/Negative fields with the translation, then generates
- **GenerateUI Lab - Run**: a Lab run translates only what is sent. The Lab plan keeps your text
- **Video Plan - Run**: a Video tab Plan run translates only the prompts that are sent. The plan keeps your text
Because Lab and Video Plan keep your text, you can keep editing the plan in your own language.
The information saved with the generated images and videos (metadata) records the English prompt that was actually sent.
> **Note**
> If translation fails while automatic translation is on (for example, Ollama is not running), generation stops so that untranslated text is not sent.
> For Lab and Video Plan, the reason is shown in the progress line.
### Also in the Lab modal and Video Plan
The globe button is also on these fields, and works the same way:
- The Positive and Negative fields of the screen that opens when you double-click a cell in Lab's prompt column (5-7)
- The **Prompt** field of a block in the Video tab's Plan subtab (Chapter 11, section 11-4)
> **Tip**
> PLaMo 3 Translate is free for personal use, hobbies, research and other non-commercial use (PLaMo Community License).
> Check the license terms before using it commercially.
> **Summary of this chapter (second half)**
> - With the Batch subtab, you can generate in bulk while changing the model, prompt, sampler and so on, one kind at a time
> - Choose the kind with the Batch Queue column checkbox and start with Generate. Turn the check off when done
> - Feeder is a feature that feeds many images one at a time into a workflow. A dedicated node is required
> - Lab is an advanced feature that can switch several settings at separate timings
> - Partner API nodes (Nano Banana and others) run once `COMFY_API_KEY` is set in `.env`. They consume credits
> - With Prompt Translation on, the globe button turns a prompt written in your own language into English. Prompt syntax is kept, and Generate, Lab and Video Plan runs can translate automatically
@@ -223,6 +223,10 @@ With the buttons shown below the translation result, you can use the result.
When you want to know the meaning of an English prompt, you can conversely translate it with **EN->JA**.
> **Tip**
> To translate directly in GenerateUI's prompt fields, **Prompt Translation** (the globe button) in Chapter 5, section 5-10 is handy. It turns only the parts in your language into English and keeps weights and LoRA tags.
> The AI Assistant's translation can also use the translation model **PLaMo 3 Translate** (v0.9.9 and later; before that, the instruction text was translated too, and ZH->EN came out in Japanese).
### Making prompts while consulting the AI
Write a question in the input box and press **Send** (or the Enter key) to chat with the AI.
@@ -6,7 +6,7 @@ and to solve "how did I make this image?".
Images generated in ComfyUI have information about the workflow and prompt used for generation (**metadata**) embedded in them.
The Gallery tab reads this information so that you can reproduce the same settings right away.
Videos (MP4 and WebM) and audio files (WAV, MP3, OGG, M4A, FLAC and Opus) can also be handled in the same list as images.
Videos (MP4 and WebM), audio files (WAV, MP3, OGG, M4A, FLAC and Opus) and 3D models (GLB, glTF, VRM, PLY and SPZ) can also be handled in the same list as images.
---
@@ -296,6 +296,30 @@ When you choose a video, only the audio track is extracted and saved.
> **Tip: use in the Video tab**
> In the Asset subtab of Video, you can set an audio file as "Set as BGM" or "Add as sound" (Chapter 11, section 11-4).
---
## 8-8 Viewing 3D models (v0.9.4+)
The results of ComfyUI workflows that make 3D models (such as image to 3D) can also be checked in the Gallery.
Supported formats are GLB, glTF, VRM, PLY (mesh, point cloud or Gaussian splat) and SPZ.
- They are listed with a "**3D**" badge. The thumbnail is drawn by your browser the first time the file appears in the list and is then kept on the server
(files over 128 MB get one when opened).
- When selected, the file is shown in 3D in the built-in viewer of the detail panel on the right. Double-click to enlarge it.
| Action | What it does |
| --- | --- |
| Drag | Rotate |
| Right-drag | Move (pan) |
| Mouse wheel | Zoom in / out |
| ⟲ (reset) button | Return to the starting view |
- For a model saved with ComfyUI's **SaveGLB**, the workflow can be read just like an image's (sections 8-2 and 8-3).
> **Caution**
> - 3D files cannot be sent to Image Edit, GenerateUI, Tagger or Feeder.
> - Some `.gltf` files refer to separate `.bin` or image files. Moving or deleting in the Gallery only affects the `.gltf` itself, so do not change where those files are.
> **Summary of this chapter**
> - In the Gallery's Output, you can look back at generated images folder by folder. You can also search by words in the prompt
> - The detail panel's Prompt tab shows right away the prompt used to generate the image
@@ -304,3 +328,4 @@ When you choose a video, only the audio track is extracted and saved.
> - If you drop an image onto the Metadata subtab, you can examine the models, LoRAs and prompt in detail
> - With the S button you can search by the meaning of a sentence or by "similar images" (semantic search)
> - Audio files can also be listed, played and converted
> - 3D models (GLB, glTF, VRM, PLY, SPZ) can also be turned around and checked in the Gallery (8-8)
+247 -3
View File
@@ -7,6 +7,9 @@ If you prepare local AI, you can do things like the following.
- Chat with the AI and have it come up with prompt ideas
- Show it an image and have it make a description, prompt or tags for that image
- Have it make candidate lists for wildcards
- Pick a **skill** to switch what it is good at: writing prompts, storyboards, troubleshooting and more (v0.9.5+)
- Have it check whether a generated image matches your request and fix only what is missing (v0.9.5+)
- Read the text shown in an image (OCR, v0.9.5+)
Because it runs inside your own computer rather than as a service on the internet,
a big feature is that **what you type and the images you use are not sent outside**.
@@ -69,10 +72,14 @@ The screen is divided into four parts, all shown at the same time.
| Part | What you can do |
| --- | --- |
| Translate | Translation between languages such as Japanese, English and Chinese |
| Chat | Conversation with the AI. If the conditions are met, generating images from the conversation too |
| TOOLS | Reading images (VLM), making wildcards |
| Chat | Conversation with the AI. Skills switch what it is good at. If the conditions are met, generating images from the conversation too |
| TOOLS | Reading images (VLM), reading text (OCR), making wildcards |
| Settings | Settings for which AI software and model to use |
> **Tip: Translate and Settings can be collapsed (v0.9.5+)**
> Press the arrow (◀ / ▶) at the right end of the Translate or Settings header to collapse that part into a thin strip, giving Chat and TOOLS more room.
> Click anywhere on the strip to open it again. The collapsed state is kept the next time you open the tab.
### First: connect to the AI software in the settings
1. In **Backend** under the settings, choose the software to use (for example Ollama).
2. Check the address under **Connection**. If you use Ollama with its defaults, no change is needed.
@@ -96,10 +103,18 @@ The screen is divided into four parts, all shown at the same time.
2. Write the text in the input box and press **Translate**.
3. **Copy** the result and paste it into GenerateUI or a preset.
> **Tip**
> Text read in TOOLS (such as OCR in 10-8) can be put straight into this input box with **To Translation** in TOOLS.
> **Tip**
> Small models sometimes return the original text as it is without translating.
> In that case a message says the model returned the original text, so try another model.
> **Tip**
> You can also choose the translation model **PLaMo 3 Translate** (Chapter 5, section 5-10) as the model in Settings (v0.9.9 and later).
> Besides Japanese, English and Chinese, **Free** accepts language names such as French, フランス語 or français for any language PLaMo supports. A target language PLaMo does not support (such as Portuguese) gives an error.
> The same applies to the translation in WS Library's A tab.
### Chat
Talk in the input box and send with **Enter** (**Shift + Enter** for a line break).
It remembers the flow of the conversation, so follow-up requests such as "make it a brighter mood" also work.
@@ -110,6 +125,10 @@ It remembers the flow of the conversation, so follow-up requests such as "make i
> just asking in chat "draw a cat" generates an image with the workflow loaded in GenerateUI, and it is shown inside the chat.
> This feature can be turned on or off with the **Allow image generation** check next to the input box.
> **Tip**
> Choose a **skill** in the dropdown above the chat to switch what the AI is good at (10-5).
> The AI's replies are shown with headings, lists and code boxes formatted (v0.9.5+).
### TOOLS - reading images (VLM)
With a model that supports image input (a VLM), you can have the AI read the contents of an image.
@@ -122,8 +141,16 @@ With a model that supports image input (a VLM), you can have the AI read the con
| Create prompt | Makes a prompt for reproducing the image |
| Create tags | Writes out the elements of the image in tag format |
| Create wildcards | Makes candidate wildcard lists by specifying a category name and count (no image needed) |
| OCR (extract text) | Reads the text shown in the image (10-8) |
3. Press **Run**. You can copy the result and use it.
3. Press **Run**.
4. Use the result with the buttons under it (v0.9.5+).
| Button | What it does |
| --- | --- |
| To Translation | Puts it into the Translate input box (opens Translate if it is collapsed) |
| To Chat | Adds it to the chat input box |
| Copy | Copies it to the clipboard |
> **Example**
> When you want to imitate the mood of an illustration you like, run "Create prompt" on that image
@@ -190,9 +217,226 @@ In that case, anyone who can access it can use your AI software and images.
> Use `--listen` **only on a trusted network**, such as a home LAN.
> Do not use it in cafes or on public Wi-Fi.
---
## 10-5 Skills - switching what the chat is good at (v0.9.5+)
A **skill** is a set of instructions that tells the chat what role to play and how to answer.
When you pick one in the dropdown above the chat (it starts as "-- No skill --"), its instructions are sent along with every message
(the instructions themselves are not shown in the chat).
### Built-in skills
Workflow Studio comes with the following six skills.
| Skill | What it does | How you use the result |
| --- | --- | --- |
| T2I Prompt Enhancer | Turns a short idea into a prompt written the way the model in your GenerateUI workflow understands best | Buttons under the prompt |
| Image to Prompt | Writes a prompt that recreates the image you put in TOOLS (needs a model that can read images) | Buttons under the prompt |
| Storyboard to Lab | Splits a story into one prompt per scene, ready for continuous generation in Lab | **Open in Lab** |
| Workflow Doctor | Explains the workflow and helps you find the cause of errors (10-7) | Answers in text |
| SVG Icon Generator | Draws simple icons and illustrations as SVG (vector images) | Preview and **Save to Gallery** |
| Skill Creator | Asks you questions and builds a new skill (10-9) | **Save as new skill** |
### Making a prompt and generating with it (T2I Prompt Enhancer)
1. Load the workflow you want to use into GenerateUI. The skill looks at that workflow's model to decide how to write the prompt.
2. In the AI TOOL chat, choose **T2I Prompt Enhancer** in the dropdown.
3. Describe the picture in your own words, for example "a cat holding an umbrella in rainy Tokyo at night, neon", and send it.
4. The reply shows which writing style was chosen (the `Style:` line) and the English prompt in a box. Use the buttons under it.
| Button | What it does |
| --- | --- |
| Apply to GenerateUI | Writes the positive / negative prompt into GenerateUI |
| Generate with this prompt | Generates right away and shows the image in the chat |
| Copy | Copies the positive prompt |
The writing style depends on the model:
| Model in GenerateUI | How the prompt is written |
| --- | --- |
| Qwen-Image, FLUX, Z-Image, etc. | English sentences (the negative is left empty when CFG is about 1) |
| Illustrious, NoobAI, Pony, etc. (SDXL anime models) | Danbooru tags (starting with quality tags) |
| Realistic SDXL, SD1.5 | Short phrases separated by commas |
> **Tip**
> Follow-up requests such as "make it more night-like" or "two cats" give you the whole updated prompt again.
> **Tip: the prompt currently in GenerateUI is not sent**
> Normally the prompt already typed into GenerateUI is not passed to the AI, because small models tend to mix it (for example an old negative prompt) into the new prompt.
> It is passed only when your message refers to it, such as "**improve the current prompt**".
### Generating a storyboard in a row (Storyboard to Lab)
1. Load a text-to-image (T2I) workflow into GenerateUI.
2. In the chat, choose **Storyboard to Lab** and ask, for example, "A tabby kitten wakes up in the morning, chases a butterfly in the garden, and naps on the veranda in the evening. 3 scenes."
3. The reply shows the scene list and an **Open in Lab (3 scenes)** button. Press it.
4. GenerateUI's **Lab** (Chapter 5, section 5-7) opens with the plan loaded as an unsaved plan.
T2I mode is on, Batch is the number of scenes, and the Prompt column has one keyframe per scene. The KSampler column holds a seed shared by all scenes (`Seed ...`).
5. Check it and press **Run**. To keep it, use **Plan Save**.
> **Tip**
> The characters' looks (hair, clothing colors and so on) are written with the same words in every scene, and the seed is fixed,
> so the same character is easier to keep across scenes.
### Automatic check of replies
For skills that output a prompt or an SVG, Workflow Studio checks the shape of the reply automatically.
If, for example, the prompt box is broken or the SVG is not closed, a dashed notice "**Auto-check: ...**" appears and the AI is asked once to fix it.
Replies that do not try to output a prompt or SVG (for example when you only asked for an explanation) are left alone.
### Managing skills (pencil button)
The pencil button to the right of the dropdown opens the skill list.
- **+ New** writes a new skill, the pencil on each row edits or deletes it, and **Import** adds other skills (10-9)
- Skills that ship with Workflow Studio are marked **built-in**.
Built-in skills you have not edited are updated automatically when Workflow Studio is updated.
An edited one is not replaced automatically; when a newer version exists, a **↻ (update)** button appears.
- Skill files are saved in `ComfyUI/user/default/Workflow-Studio/ai_skills/`.
> **Caution**
> Replacing a skill with the newer version via ↻ (update) discards your edits to that skill.
---
## 10-6 Checking generated images and fixing them (v0.9.5+)
This feature has the AI check whether an image generated from the chat matches what you asked for.
If something is missing, you can redraw with a prompt that fixes just that.
### Preparation: a judging model
The check does not use a normal chat model but an Ollama **decision model** (a model that answers yes/no questions with a probability).
Get one that can read images with `ollama pull` (the author confirmed `d3:4b`, `clef-flash` and `clef`).
> **Tip: why a separate model**
> In the author's tests, a chat model shown an image sometimes answered "yes" to "is the person holding a sword?" when there was no sword.
> A decision model returns the probability of "yes" as a number, so uncertain answers can be told apart.
1. In AI TOOL's **Settings**, under **Chat Image Check**, choose the **Judge model (Ollama decision model)** (press **Refresh** if the list is empty).
2. Choose **Automatic fix rounds**. **0 (fix by button)** is recommended at first.
3. Press **Save Settings**.
### How to use it
1. Tick **Check images** below the chat input.
2. Generate an image from the chat (the AI's image generation, or **Generate with this prompt**).
3. A result card appears under the image. The AI splits your request into 3 to 8 check items and checks them one by one.
| Mark | Meaning |
| --- | --- |
| ✔ (met) | Probability of "yes" is 85% or more |
| ? (unclear) | 30-85% |
| ✘ (not met) | Less than 30% |
4. If there is a ✘ or ?, press **Fix missing items and regenerate**. Only the unmet items are sent to the AI, which rewrites the prompt and draws again.
If you set Automatic fix rounds to 1-3, this repeats automatically up to that number of times.
> **Tip: SVGs can be checked too**
> SVGs drawn with SVG Icon Generator are turned into an image and checked for "does it look like what you asked for" and "are its parts (beak, wings and so on) drawn".
> **Ask to redraw unclear parts** asks the AI to fix them.
> **Caution**
> - The check is not perfect. It is especially weak at "who is wearing what",
> so when there are several people it automatically adds reverse check items such as "the hat is not on the girl" to compensate.
> - How well the redraw works depends on the chat model. If it does not improve, change your request or the model.
> - The judging model also uses GPU memory (about 6 GB for `d3:4b`). Once loaded, a check takes a few seconds.
---
## 10-7 Asking about workflow problems (Workflow Doctor, v0.9.5+)
**Workflow Doctor** is a skill that explains the workflow loaded in GenerateUI and helps you find the cause of errors.
Instead of relying only on the AI's knowledge, every time you send a message Workflow Studio passes it the following facts it has actually checked.
| What is checked | Example |
| --- | --- |
| Nodes that are not installed | Names of nodes ComfyUI does not know |
| Files and values not in ComfyUI's lists | Models or LoRAs that cannot be found (with similar names) |
| Connections | Inputs that are not connected, links to nodes that do not exist |
| The last execution error | The error recorded in ComfyUI's history |
| ComfyUI's log | The latest error part of the log |
### How to use it
1. Load the workflow you want to ask about into GenerateUI (for an error, run it once so the error is recorded).
2. In the chat, choose **Workflow Doctor**.
3. Ask, for example, "check this workflow for problems before I run it" or "what caused the last error?".
> **Example**
> For a workflow whose LoRA file had been moved to another folder, it answered
> "the file specified in the `temp\` folder cannot be found; a file with the same name exists in `Illustrious\`", including how to fix it.
> **Tip**
> The checked facts are rebuilt every time you send a message. After fixing something, just ask again.
---
## 10-8 Reading text in images (OCR, v0.9.5+)
In TOOLS you can read the text shown in an image. The text you read can be sent straight to translation or the chat.
### Preparation: an OCR model
OCR uses a model that is good at reading text, separate from the chat model. Prepare one in Ollama.
These are the author's results on an image mixing horizontal and vertical Japanese and English text.
| Model | Time | Result |
| --- | --- | --- |
| LightOnOCR-3 (`maternion/LightOnOCR-3:4b`) | About 1 s (6-8 s with positions) | Read everything |
| PaddleOCR-VL (manga version) | About 4 s | Read everything |
| DeepSeek-OCR family | About 14 s | Read everything (always with positions) |
| PaddleOCR-VL 1.6, GLM-OCR | About 11-15 s | Missed the vertical text |
### How to use it
1. Drop an image into TOOLS.
2. Choose **OCR (extract text)** as the task.
3. Choose the **OCR model**. Ollama models whose name contains "ocr" are listed, best first (press ↻ if the list is empty).
4. Press **Run**. The text is shown in the result box, one line each.
> **Tip: Show text positions**
> Tick **Show text positions** to draw numbered boxes over the image so you can see where each text is.
> Clicking a box selects the same line in the result box.
> Only LightOnOCR and the DeepSeek-OCR family can return positions; for other models this check cannot be selected.
> **Tip**
> If the result is empty or the same line repeats, it is automatically read once more in grayscale.
---
## 10-9 Making and importing skills (advanced, v0.9.5+)
### Making one with Skill Creator
In the chat, choose **Skill Creator** and say something like "I want a skill that is good at ...".
The AI asks questions one at a time; answer them and you get a draft skill.
Press **Save as new skill** under the reply; the skill list opens with the draft filled in, so check it and save.
You can also ask it to improve an existing skill, for example "this part of this skill does not work well".
### What a skill file contains
A skill is a text file (`.md`). Write the name and description in the part enclosed by `---` at the top, and the instructions for the AI below it.
Under `metadata:` in the top part you can also write these settings (all optional).
| Setting | Meaning |
| --- | --- |
| `output` | `prompt` or `svg`. Checks the shape of the reply automatically and adds the buttons |
| `tools` | `[]` stops the AI from starting image generation on its own |
| `temperature` | How varied the answers are (0.3 stable, 0.9 free) |
| `think` | Turns Thinking mode on or off just for this skill |
| `context` | Information passed to the AI: `workflow` (workflow summary), `current-prompt` (the current prompt), `workflow-detail` / `logs` (the same checks as Workflow Doctor) |
### Importing other skills
**Import** in the skill list adds:
- a single `.md` skill
- a ZIP of a folder containing `SKILL.md` (the **Agent Skills** format shared by many AI tools)
Text files in the folder (reference material and so on) are imported too, and the AI reads them only when it needs them
(this needs a model that supports tool calling).
> **Caution**
> - Only text files are imported. Programs such as scripts are not imported and never run.
> - A skill's instructions are passed to the AI as they are. Read a skill made by someone else before using it.
> **Summary of this chapter**
> - If you prepare local AI (Ollama and so on), you can translate, chat and read images. What you type is not sent outside
> - In the AI TOOL tab's settings, choose the backend, address and model, and test the connection
> - The Prompt tab and Tagger tab have separate gear-button settings
> - AI and image generation compete for VRAM. Free it with "Unload Model" or "VRAM Management (Ollama)"
> - By default it connects only to AI on your own computer. Use `--listen` only on a trusted network
> - **Skills** switch what the chat is good at. T2I Prompt Enhancer writes a prompt that buttons apply to GenerateUI or generate with
> - With **Check images** on, a decision model checks the generated image and you can redraw fixing only what is missing
> - Workflow Doctor helps with workflow problems based on facts it has actually checked
> - **OCR (extract text)** in TOOLS reads the text in an image and sends it to translation or the chat
@@ -103,6 +103,22 @@ You can put text on a generated image, or make a mask for redrawing part of it.
- Save the edited image with **Save PNG** (download), **Save to Gallery** and so on.
- Undo with **Ctrl + Z**, redo with **Ctrl + Y**.
### Draw colors and shortcuts (v0.9.3+)
When you choose **Draw**, a **color palette** appears in the second row of the tool options.
- It shows **Color 1 / Color 2**, 20 basic colors and 20 custom slots. Click a color to paint with it.
- Click **+** or an empty slot to register the current color as a custom color. Right-click a color to register, edit or delete it (basic colors can be changed too, and returned to their original color).
Registered colors are saved per browser.
- The **eyedropper** button next to **Color** on the right picks a color from the canvas (Esc cancels).
- The starting colors are black (Color 1) and white (Color 2).
| Key (while Draw is active) | What it does |
| --- | --- |
| D / E | Draw / Erase |
| X | Swap Color 1 and Color 2 |
| [ / ] | Make the brush smaller / larger |
| B | Open or close the brush picker (Esc also closes it) |
### Inpainting (redrawing part of an image)
The handiest use of Image Edit is **inpainting**.
It is for when "I want to redraw only the face" or "I want to fix only the place where the hand broke".
@@ -139,6 +155,14 @@ You load a matching workflow with **Load in Video** in the Workflow tab and use
There are also the **Frame** feature, which saves a favorite scene of a video as a still image, and **GIF**, which converts a video to an animated GIF.
> **Tip**
> The **Prompt** field of a Plan block also has the Prompt Translation globe button (Chapter 5, section 5-10).
> With **Video Plan - Run** turned on in Settings, you can run the plan with prompts in your own language and send only English.
> **Note**
> Up to v0.9.8, with workflows saved by newer ComfyUI versions, the prompt, length (Duration) and Turbo settings entered in Plan were not applied, and the values saved in the workflow were used instead (fixed in v0.9.9).
> Because Plan values are applied now, running the same plan as before may give different results.
### Register as Asset and audio conversion (v0.8.9 and later)
- **Register as Asset** - a button in the Video Source panel on the left. It copies a video from your PC into the output folder (`output/video`) and registers it in the "Video Assets" group.
Once registered, it appears in the Asset subtab list and can be used in Edit and elsewhere.
@@ -187,6 +211,7 @@ Here we mainly introduce items not covered in earlier chapters.
| CivitAI API Key | For fetching Civitai information (optional) | Chapter 6 |
| Eagle integration (optional) | Automatically save generated images to Eagle | Chapter 8 |
| VRAM Management (Ollama) | Unload AI models from memory before generation | Chapter 10 |
| Prompt Translation (native language -> English) | Turn prompts in your own language into English with the globe button or automatic translation when running | Chapter 5, 5-10 |
| Data Management | Backing up and restoring settings and data | Below |
### Default Workflow
@@ -72,6 +72,7 @@ This means **the custom nodes the workflow needs are not installed**.
### You changed a setting but the result did not change
The most common cause is **forgetting to press Apply**.
In GenerateUI, after changing the model or Settings values (steps, size and so on), the change is not reflected in the workflow unless you press **Apply** (Chapter 5, section 5-3).
The Switches column at the right of the Settings tab is the exception: it takes effect the moment you click (Chapter 5, section 5-4).
Looking at the **Raw JSON** on the right lets you check the values actually reflected.
### It generates something different from the loaded workflow
@@ -87,6 +88,15 @@ In the **Model** subtab of GenerateUI, choose the model you want to use again an
If you always want to use the same model, the **Default Checkpoint** in the Settings tab is handy (Chapter 11, section 11-5).
### The Prompt Translation globe button does not appear or translation fails
| Symptom | Cause | Fix |
| --- | --- | --- |
| No globe button | Prompt Translation is off | In the Settings tab, open **Prompt Translation (native language -> English)** and check **Enable prompt translation in GenerateUI** (Chapter 5, section 5-10) |
| "Translation error" appears | Ollama is not running, or the translation model is not in Ollama | Start Ollama. If **Translation model** shows **(not downloaded)**, press **Download** |
| Nothing changes ("Nothing to translate") | The prompt is English (ASCII) only | Only parts with letters outside ASCII are translated; English parts stay as they are |
| Generation does not start with automatic translation on | Translation failed, so generation stopped instead of sending untranslated text | Same fix as "Translation error". In Lab and Video Plan the reason is shown in the progress line |
| The translation is off | Small models (0.8B) can shift the meaning of sentences | Choose 2B or larger in **Translation model** |
### It does not become the same image even with the same settings
Is the seed mode in the generate panel set to **Random**?
To make the same image, you need to set the seed to **Workflow** (use the workflow's seed as it is) or **Fixed** (fix it to the value in the Seed field).
@@ -135,6 +145,21 @@ For Ollama, download the model with `ollama pull (model name)`, then press **Ref
For safety, by default it connects only to AI software inside the same computer.
You need to set the environment variable `WFS_ALLOWED_BACKEND_HOSTS` (Chapter 10, section 10-4).
### The judge model for image checks, or the OCR model, does not appear in the list
- The judge model list shows only Ollama **decision models** that can read images; normal chat models are not shown.
Update Ollama, `ollama pull` a decision model, then press **Refresh** (Chapter 10, section 10-6).
- The OCR model list shows only Ollama models whose name contains "ocr". Press ↻ after getting one (Chapter 10, section 10-8).
- Both look at Ollama at the AI TOOL backend address when the backend is Ollama, otherwise at `http://localhost:11434`.
### Image checks never pass no matter how often it fixes
- How well the redraw works depends on the chat model. Make your request shorter and more concrete, or try another model.
- The check itself can be wrong too. Look at the image yourself as well.
- Too many automatic fix rounds keep using generation time and GPU memory. "0 (fix by button)" is recommended at first.
### The AI does not read a skill's reference files, or does not generate images from the chat
Reading the reference files of an imported skill and generating images from the chat only work with
**a model that supports tool calling**. Switch to such a model.
---
## 12-5 Troubles with other features
@@ -172,6 +197,15 @@ Run the installation command shown in the error message in the Python that Comfy
The cause is a missing Comfy API key in `.env`. Write `COMFY_API_KEY=your key` (issued at platform.comfy.org) in the plugin's `.env` and restart ComfyUI (Chapter 5, section 5-8).
`.env` is read only at startup.
### ComfyUI freezes (no tab responds)
On Windows, ComfyUI can stop responding (generation included), for example after switching a Models tab list with many preview images.
In the Settings tab, under **Windows Stability (Event Loop)**, turn on **Use the Selector event loop on Windows (restart required)** and restart ComfyUI.
### Part of a Gallery image looks broken, as if mixed with another image
With the **Selector event loop** above turned on, up to v0.9.1 part of an image received by the Gallery preview or Download could be corrupted
(the file in the output folder itself is fine). This is fixed in v0.9.2.
After updating Workflow Studio, broken images may remain in the browser cache, so reload with **Ctrl + F5**.
### Images do not appear in the Gallery
- Press **Refresh** in the Gallery.
- Check that the "Gallery Output Folder" in the Settings tab matches where ComfyUI saves images.
+9
View File
@@ -16,6 +16,7 @@ The main terms that appear in this book, in alphabetical order.
| Civitai | A sharing site for image-generation models | Chapter 6 |
| ComfyUI Manager | A management tool for searching for and installing custom nodes | Chapter 2 |
| Custom node | A node or extension added to ComfyUI afterwards. Workflow Studio is one of them | Chapter 1 |
| Decision model | An AI model that answers questions with numbers such as the probability of "yes". Used to judge image checks | Chapter 10 |
| Denoise | How strongly to redraw the original image | Chapter 5 |
| Embedding | A small file that teaches a particular word a meaning | Chapter 6 |
| Hash value | A "fingerprint"-like value computed from a file's contents. Used to look up models on Civitai | Chapter 6 |
@@ -31,7 +32,9 @@ The main terms that appear in this book, in alphabetical order.
| Negative prompt | A prompt where you write what you do not want drawn | Chapter 7 |
| Node | A "box" arranged on ComfyUI's screen. It handles one process | Chapter 1 |
| Node set | Several nodes and their connections saved together | Chapter 9 |
| OCR | Reading the text shown in an image | Chapter 10 |
| Ollama | Software for running local AI easily | Chapter 10 |
| PLaMo 3 Translate | A translation AI model by Preferred Networks (PFN), used by Prompt Translation | Chapter 5 |
| Port number | A number for distinguishing which software to communicate with inside one computer | Chapter 2 |
| Positive prompt | A prompt where you write what you want drawn | Chapter 7 |
| Preset | A pair of positive and negative prompts saved together | Chapter 7 |
@@ -41,6 +44,7 @@ The main terms that appear in this book, in alphabetical order.
| Scheduler | How the drawing amount is distributed across steps | Chapter 5 |
| Seed | The seed of random numbers an image grows from. If the same, you get almost the same image | Chapter 5 |
| Semantic search | Searching images by the "meaning" of a sentence or image. Used with the Gallery's S button | Chapter 8 |
| Skill | Instructions that tell the AI TOOL chat its role and how to answer. Picking one switches what it is good at | Chapter 10 |
| Steps | The number of times drawing is repeated | Chapter 5 |
| Style | A mood template added to a prompt | Chapter 7 |
| T2I (Text to Image) | Making an image from text (a prompt) | Chapter 5 |
@@ -95,6 +99,10 @@ The main terms that appear in this book, in alphabetical order.
| Mouse wheel | Zoom in and out |
| Space + drag | Move the view position |
| Delete | Delete the selected layer (when there are two or more layers) |
| D / E (while Draw is active) | Draw / Erase |
| X (while Draw is active) | Swap Color 1 and Color 2 |
| [ / ] (while Draw is active) | Make the brush smaller / larger |
| B (while Draw is active) | Open or close the brush picker |
---
@@ -115,6 +123,7 @@ The main terms that appear in this book, in alphabetical order.
| --- | --- | --- |
| Civitai (https://civitai.com/) | Getting models, fetching information | Chapter 6 |
| Ollama (https://ollama.com/) | Local AI | Chapter 10 |
| PLaMo 3 Translate (https://huggingface.co/pfnet/plamo-3-translate-2b-GGUF) | Translation model for Prompt Translation | Chapter 5 |
| LM Studio (https://lmstudio.ai/) | Local AI | Chapter 10 |
| Lemonade Server (https://lemonade-server.ai/) | Local AI | Chapter 10 |
| Eagle (https://eagle.cool/) | Image-management software | Chapter 8 |
BIN
View File
Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.7 MiB

After

Width:  |  Height:  |  Size: 422 KiB

+57
View File
@@ -1,9 +1,66 @@
import os
import logging
import re
from pathlib import Path
logger = logging.getLogger(__name__)
# ─── パス検査(クライアント由来のパスを resolve() する前に文字列のまま検査する)───
# Windows では UNC パス(\\host\share)は resolve()・exists() を呼んだ時点で相手ホストへ
# Windows アカウントの資格情報付きで接続してしまうため、チェックはパス操作より先に行う。
_DRIVE_RE = re.compile(r"^[A-Za-z]:")
def is_unc(value) -> bool:
"""ネットワーク共有/デバイスパス(\\\\host\\share, //host/share, \\\\?\\ 等)か。"""
return str(value or "").replace("/", "\\").startswith("\\\\")
def is_safe_rel(rel) -> bool:
"""相対パスとして安全か。UNC・ドライブ指定・絶対パス・「..」・空セグメントを
結合・resolve() より前に文字列のまま拒否する。"""
s = str(rel or "")
if not s or "\x00" in s:
return False
if s.startswith(("/", "\\")) or _DRIVE_RE.match(s):
return False
return not any(part in ("", "..") for part in re.split(r"[/\\]", s))
def resolve_untrusted(value, roots=()) -> Path:
"""クライアント由来の絶対パス文字列を検査してから resolve() して返す。
ファイルシステムに触れない文字列処理(normpath)だけで「..」を正規化・拒否し、
UNC は roots のうち UNC のルート配下に文字列上一致する場合のみ許可する
(ギャラリーのルートをネットワーク共有に置いている構成だけを通すため)。
拒否時は ValueError。"""
s = str(value or "")
if not s or "\x00" in s:
raise ValueError("Access denied: invalid path")
p = Path(os.path.normpath(s))
if ".." in p.parts:
raise ValueError("Access denied: path traversal")
if is_unc(s):
for root in roots:
if root is None or not is_unc(str(root)):
continue
try:
p.relative_to(Path(root)) # 文字列上の照合(解決しない)
return p.resolve()
except (ValueError, OSError):
continue
raise ValueError("Access denied: network path")
# 受け付ける形はドライブレター絶対パス(Windows)または / 始まり(その他OS)に限る。
# ルート相対(\foo)・ドライブ相対(C:foo)・NT デバイス形式(\??\, \.\ 等)・相対パスは拒否する
if os.name == "nt":
if not re.match(r"^[A-Za-z]:[\\/]", s):
raise ValueError("Access denied: invalid path")
elif not s.startswith("/"):
raise ValueError("Access denied: invalid path")
return p.resolve()
# Plugin root directory
PLUGIN_DIR = Path(__file__).resolve().parent.parent
+10 -4
View File
@@ -9,6 +9,7 @@ import urllib.error
from aiohttp import web
from ..config import is_safe_rel
from ..services.url_guard import require_backend_url, urlopen as _guarded_urlopen
logger = logging.getLogger(__name__)
@@ -38,6 +39,11 @@ def _resolve_local_path(filename, subfolder, type_name):
if not filename:
return None
# subfolder の UNC・ドライブ指定・絶対パス・「..」は、結合より前に文字列のまま拒否する
# (別ドライブ/UNC だと下の commonpath が ValueError を投げるため、その前に弾く)
if subfolder and not is_safe_rel(subfolder):
return None
full_dir = os.path.abspath(os.path.join(base_dir, subfolder or ""))
# Windowsはパス比較で大文字小文字を区別しないため normcase で正規化してから比較する
if os.path.commonpath((os.path.normcase(full_dir), os.path.normcase(base_dir))) != os.path.normcase(base_dir):
@@ -62,9 +68,9 @@ def _resolve_absolute_svg_path(abs_path):
except Exception:
return None
# isfile() も UNC(\\host\share)だと相手ホストへ資格情報付きで接続してしまうため、
# 文字列処理(abspath/commonpath)だけで ComfyUI 管理下と確認できるまでファイルシステムに触れない
abs_path = os.path.abspath(abs_path)
if not os.path.isfile(abs_path):
return None
for type_name in ("output", "temp", "input"):
base_dir = folder_paths.get_directory_by_type(type_name)
@@ -74,9 +80,9 @@ def _resolve_absolute_svg_path(abs_path):
try:
# Windowsはパス比較で大文字小文字を区別しないため normcase で正規化してから比較する
if os.path.commonpath((os.path.normcase(abs_path), os.path.normcase(base_dir))) == os.path.normcase(base_dir):
return abs_path
return abs_path if os.path.isfile(abs_path) else None
except ValueError:
# Windowsで異なるドライブレターの場合 commonpath が例外を投げる
# Windowsで異なるドライブレターやUNCの場合 commonpath が例外を投げる
continue
return None
+37 -1
View File
@@ -59,7 +59,10 @@ _init_allowed_root()
# Windowsのレジストリ依存で音声のMIMEが返らない/不統一なため明示登録する(<audio>の再生に必要)
for _ext, _mime in ((".wav", "audio/wav"), (".mp3", "audio/mpeg"), (".ogg", "audio/ogg"),
(".opus", "audio/ogg"), (".m4a", "audio/mp4"), (".flac", "audio/flac")):
(".opus", "audio/ogg"), (".m4a", "audio/mp4"), (".flac", "audio/flac"),
(".glb", "model/gltf-binary"), (".vrm", "model/gltf-binary"), (".gltf", "model/gltf+json"),
(".ply", "application/octet-stream"), (".spz", "application/octet-stream"),
(".bin", "application/octet-stream")):
mimetypes.add_type(_mime, _ext)
@@ -79,6 +82,8 @@ def setup_routes(app: web.Application):
app.router.add_get("/wfm/gallery/image/workflow", get_image_workflow)
app.router.add_get("/wfm/gallery/image/serve", serve_image)
app.router.add_get("/wfm/gallery/image/thumb", serve_thumb)
app.router.add_post("/wfm/gallery/image/thumb3d", save_model3d_thumb)
app.router.add_get("/wfm/gallery/model3d/asset", serve_model3d_asset)
app.router.add_post("/wfm/gallery/image/meta", save_image_meta)
app.router.add_get("/wfm/gallery/image-prompt/root", get_image_prompt_root)
app.router.add_post("/wfm/gallery/image/image-prompt", save_image_prompt)
@@ -386,6 +391,37 @@ async def serve_thumb(request: web.Request) -> web.Response:
})
async def save_model3d_thumb(request: web.Request) -> web.Response:
"""POST /wfm/gallery/image/thumb3d — ブラウザが描画した3Dモデルのサムネイルを保存する"""
try:
body = await request.json()
path = body.get("path", "")
image = body.get("image", "")
if not path or not image:
return web.json_response({"ok": False, "error": "path and image required"}, status=400)
loop = asyncio.get_event_loop()
result = await loop.run_in_executor(None, _service.save_model3d_thumbnail, path, image)
return web.json_response(result, status=200 if result.get("ok") else 400)
except Exception as e:
return web.json_response({"ok": False, "error": str(e)}, status=500)
async def serve_model3d_asset(request: web.Request) -> web.Response:
"""GET /wfm/gallery/model3d/asset — .gltfが参照する外部ファイル(.bin/テクスチャ)を配信する"""
path = request.rel_url.query.get("path", "")
uri = request.rel_url.query.get("uri", "")
if not path or not uri:
return web.Response(status=400)
asset = _service.serve_model3d_asset(path, uri)
if asset is None:
return web.Response(status=404)
content_type, _ = mimetypes.guess_type(str(asset))
return web.FileResponse(asset, headers={
"Content-Type": content_type or "application/octet-stream",
"Cache-Control": "max-age=3600",
})
# ──────────────────────────────────────────────────────────────
# バルク操作
# ──────────────────────────────────────────────────────────────
+9 -6
View File
@@ -14,7 +14,7 @@ from pathlib import Path
from aiohttp import web
from ..services.settings_service import SettingsService
from ..config import DATA_DIR
from ..config import DATA_DIR, resolve_untrusted
logger = logging.getLogger(__name__)
@@ -153,17 +153,20 @@ async def handle_result(request: web.Request) -> web.Response:
try:
body = await request.json()
result_path = body.get("result_path", "")
if not result_path or not os.path.exists(result_path):
return web.json_response({"error": f"Result file not found: {result_path}"}, status=404)
# Path traversal guard: only allow files inside gmic_temp
# Path traversal guard: only allow files inside gmic_temp.
# UNC(\\host\share)は exists()/resolve() を呼んだ時点で相手ホストへ資格情報付きで
# 接続してしまうため、パス操作より先に文字列のまま検査する(resolve_untrusted)。
allowed_dir = (Path(DATA_DIR) / "gmic_temp").resolve()
try:
Path(result_path).resolve().relative_to(allowed_dir)
resolved = resolve_untrusted(result_path)
resolved.relative_to(allowed_dir)
except ValueError:
return web.json_response({"error": "Access denied: path outside gmic_temp"}, status=403)
if not resolved.is_file():
return web.json_response({"error": f"Result file not found: {result_path}"}, status=404)
with open(result_path, "rb") as f:
with open(resolved, "rb") as f:
img_bytes = f.read()
ext = os.path.splitext(result_path)[1].lower()
+103 -19
View File
@@ -6,13 +6,14 @@ import json
import logging
import shutil
import tempfile
import re
import zipfile
from pathlib import Path
from aiohttp import web
from ..services.settings_service import SettingsService
from ..config import DEFAULT_WORKFLOWS_DIR, DATA_DIR, VIDEO_EDIT_PROJECT_DIR
from ..config import DEFAULT_WORKFLOWS_DIR, DATA_DIR, VIDEO_EDIT_PROJECT_DIR, is_safe_rel
logger = logging.getLogger(__name__)
@@ -29,8 +30,30 @@ _DATA_FILES = [
"gallery_metadata.json",
"tagger_settings.json",
"civitai_cache.json",
"semantic_settings.json",
]
# Browser-side settings (localStorage, same origin as ComfyUI) carried in both backups:
# workflow/preset groups, badge palette, appearance, AI/decision/VRAM settings, presets...
# The client collects and restores them; the server only validates and stores them as
# "__browser_storage" (JSON bundle) or _BROWSER_STORAGE_ENTRY (ZIP).
_BROWSER_STORAGE_KEY_RE = re.compile(r"^(?:wfm|ie)_[A-Za-z0-9_-]{1,100}$")
_BROWSER_STORAGE_TRANSIENT = {"wfm_pending_workflow", "wfm_library_filter_request"}
_BROWSER_STORAGE_MAX = 5 * 1024 * 1024 # localStorage itself is ~5 MB per origin
_BROWSER_STORAGE_ENTRY = "_browser_storage.json"
def _clean_browser_storage(obj) -> dict:
"""Keep only plugin keys with string values; drop transient keys. Raises on bad size."""
if not isinstance(obj, dict):
return {}
out = {k: v for k, v in obj.items()
if isinstance(k, str) and isinstance(v, str)
and _BROWSER_STORAGE_KEY_RE.match(k) and k not in _BROWSER_STORAGE_TRANSIENT}
if sum(len(k) + len(v) for k, v in out.items()) > _BROWSER_STORAGE_MAX:
raise ValueError("browser storage data is too large")
return out
def setup_routes(app: web.Application):
"""Register settings API routes."""
@@ -45,6 +68,7 @@ def setup_routes(app: web.Application):
app.router.add_get("/api/wfm/settings/export", handle_export)
app.router.add_post("/api/wfm/settings/import", handle_import)
app.router.add_get("/api/wfm/settings/export-full", handle_export_full)
app.router.add_post("/api/wfm/settings/export-full", handle_export_full)
app.router.add_post("/api/wfm/settings/import-full", handle_import_full)
app.router.add_get("/api/wfm/styles", handle_get_styles)
app.router.add_post("/api/wfm/styles", handle_create_style)
@@ -267,8 +291,11 @@ async def handle_export(request: web.Request) -> web.Response:
def _apply_import_bundle(bundle: dict) -> dict:
"""Write imported bundle back to individual data files. Returns summary."""
summary = {"imported": [], "skipped": []}
"""Write imported bundle back to individual data files. Returns summary.
"__browser_storage" (added by the client on export) is validated and returned for the
browser to write into localStorage."""
summary = {"imported": [], "skipped": [],
"browser_storage": _clean_browser_storage(bundle.get("__browser_storage"))}
DATA_DIR.mkdir(parents=True, exist_ok=True)
for filename in _DATA_FILES:
if filename not in bundle:
@@ -303,7 +330,18 @@ async def handle_import(request: web.Request) -> web.Response:
# style/) and the SQLite tagger.db that the JSON bundle can't represent. Excludes transient/cache
# dirs, and wildcard/ specifically because it's typically a symlink into a *different*
# custom_node's folder (comfyui-impact-pack) rather than this plugin's own data.
_FULL_BACKUP_EXCLUDE_NAMES = {"gmic_temp", "thumb_cache", "wildcard"}
# models/ held the ONNX EmbeddingGemma of v0.8.2-v0.8.13 (semantic search now runs on
# Ollama), so it is a 300 MB leftover, not data.
_FULL_BACKUP_EXCLUDE_NAMES = {"gmic_temp", "thumb_cache", "wildcard", "models"}
# Rebuildable caches, opt-in per group (see _build_full_backup_zip). The semantic index is
# on by default in the UI: rebuilding it re-embeds the whole gallery (Gemini API cost).
_SEMANTIC_CACHE_NAMES = {"semantic_index.npz"}
_TAGSPACE_CACHE_PREFIX = "tagspace_"
def _is_temp_file(name: str) -> bool:
# Atomic-write leftovers such as gallery_metadata.json.tmp / semantic_index.tmp.npz
return name.endswith(".tmp") or ".tmp." in name
def _add_file_to_zip(zf: zipfile.ZipFile, path: Path, base: Path):
@@ -397,6 +435,10 @@ def _add_video_edit_media_to_zip(zf: zipfile.ZipFile) -> None:
input_dir = _comfyui_input_dir().resolve()
seen = set()
for subfolder, filename in _iter_video_edit_media_refs():
# プロジェクトファイルは細工できるため、UNC・絶対パス・「..」は結合・resolve() の前に
# 文字列のまま拒否する(Windows では UNC を resolve() するだけで相手ホストへ接続する)
if not is_safe_rel(filename) or (subfolder and not is_safe_rel(subfolder)):
continue
src = (input_dir / subfolder / filename).resolve()
try:
rel = src.relative_to(input_dir) # a crafted project file must not reach outside input/
@@ -409,23 +451,33 @@ def _add_video_edit_media_to_zip(zf: zipfile.ZipFile) -> None:
def _build_full_backup_zip(include_workflows: bool = False, include_wildcard: bool = False,
include_video_media: bool = False) -> bytes:
include_video_media: bool = False, include_semantic_index: bool = False,
include_tagspace: bool = False, browser_storage: dict = None) -> bytes:
"""Zips everything under DATA_DIR except the excluded names above. Walks
top-level entries first so an excluded symlinked directory (wildcard/) is never
even opened, rather than filtering after a recursive walk has already followed it.
Optionally also includes the two external folders above under "_external/"."""
Optionally also includes the two external folders above under "_external/", the
rebuildable caches, and the browser-side settings (_BROWSER_STORAGE_ENTRY)."""
buf = io.BytesIO()
with zipfile.ZipFile(buf, "w", zipfile.ZIP_DEFLATED) as zf:
for top in sorted(DATA_DIR.iterdir()):
if top.name in _FULL_BACKUP_EXCLUDE_NAMES or top.is_symlink():
continue
if top.is_file():
if _is_temp_file(top.name):
continue
if top.name in _SEMANTIC_CACHE_NAMES and not include_semantic_index:
continue
if top.name.startswith(_TAGSPACE_CACHE_PREFIX) and not include_tagspace:
continue
_add_file_to_zip(zf, top, DATA_DIR)
elif top.is_dir():
for path in top.rglob("*"):
if path.is_dir() or path.is_symlink():
if path.is_dir() or path.is_symlink() or _is_temp_file(path.name):
continue
_add_file_to_zip(zf, path, DATA_DIR)
if browser_storage:
zf.writestr(_BROWSER_STORAGE_ENTRY, json.dumps(browser_storage, ensure_ascii=False, indent=2))
if include_workflows:
_add_external_dir_to_zip(zf, _default_workflows_dir(), "_external/default_workflows")
@@ -451,7 +503,8 @@ def _apply_full_backup_zip(zip_source) -> dict:
into ComfyUI's input dir instead, but never overwrite an existing file there — a file
with the same name is assumed to be the same upload (ComfyUI dedupes uploads by renaming),
and input/ is shared with every other workflow."""
summary = {"extracted": [], "skipped": [], "media_restored": [], "media_existing": []}
summary = {"extracted": [], "skipped": [], "media_restored": [], "media_existing": [],
"browser_storage": {}}
DATA_DIR.mkdir(parents=True, exist_ok=True)
base = DATA_DIR.resolve()
input_base = None
@@ -465,10 +518,28 @@ def _apply_full_backup_zip(zip_source) -> dict:
if info.filename.startswith("_external/"):
summary["skipped"].append(info.filename)
continue
if info.filename == _BROWSER_STORAGE_ENTRY:
# Handed back to the browser, which writes it into localStorage.
try:
if info.file_size > _BROWSER_STORAGE_MAX * 2:
raise ValueError("too large")
with zf.open(info) as src:
summary["browser_storage"] = _clean_browser_storage(
json.loads(src.read().decode("utf-8")))
except Exception as e:
logger.warning("Full backup: browser storage entry ignored: %s", e)
summary["skipped"].append(info.filename)
continue
if info.filename.startswith(_VIDEO_MEDIA_PREFIX):
media_rel = info.filename[len(_VIDEO_MEDIA_PREFIX):]
# ZIP エントリ名は細工できるため、UNC・絶対パス・「..」は結合・resolve() の前に
# 文字列のまま拒否する(Windows では UNC を resolve() するだけで相手ホストへ接続する)
if not is_safe_rel(media_rel):
summary["skipped"].append(info.filename)
continue
if input_base is None:
input_base = _comfyui_input_dir().resolve()
target = (input_base / info.filename[len(_VIDEO_MEDIA_PREFIX):]).resolve()
target = (input_base / media_rel).resolve()
try:
target.relative_to(input_base)
except ValueError:
@@ -482,6 +553,9 @@ def _apply_full_backup_zip(zip_source) -> dict:
shutil.copyfileobj(src, dst)
summary["media_restored"].append(info.filename)
continue
if not is_safe_rel(info.filename):
summary["skipped"].append(info.filename)
continue
target = (base / info.filename).resolve()
try:
target.relative_to(base)
@@ -496,19 +570,29 @@ def _apply_full_backup_zip(zip_source) -> dict:
async def handle_export_full(request: web.Request) -> web.Response:
"""GET /api/wfm/settings/export-full - Download a ZIP of the entire data
"""GET|POST /api/wfm/settings/export-full - Download a ZIP of the entire data
directory, including data the flat JSON bundle (handle_export) can't represent.
Optional query params include_workflows=1 / include_wildcard=1 additionally bundle
ComfyUI's default workflows dir / the Impact Pack's wildcard dir (see
_build_full_backup_zip) — both restore-excluded, export-only, manual-copy-back.
include_video_media=1 adds the input-dir media referenced by Video Edit projects,
which *is* restored (into input/, without overwriting)."""
Options (query params for GET, JSON body for POST; "1"/true):
include_workflows / include_wildcard additionally bundle ComfyUI's default workflows
dir / the Impact Pack's wildcard dir (see _build_full_backup_zip) — both
restore-excluded, export-only, manual-copy-back. include_video_media adds the
input-dir media referenced by Video Edit projects, which *is* restored (into input/,
without overwriting). include_semantic_index / include_tagspace add the rebuildable
caches. POST may also carry browser_storage (the page's localStorage settings)."""
try:
include_workflows = request.rel_url.query.get("include_workflows") == "1"
include_wildcard = request.rel_url.query.get("include_wildcard") == "1"
include_video_media = request.rel_url.query.get("include_video_media") == "1"
browser_storage = None
if request.method == "POST":
body = await request.json()
if not isinstance(body, dict):
return web.json_response({"error": "body must be a JSON object"}, status=400)
opt = lambda k: body.get(k) in (True, 1, "1")
browser_storage = _clean_browser_storage(body.get("browser_storage"))
else:
opt = lambda k: request.rel_url.query.get(k) == "1"
zip_bytes = await asyncio.to_thread(
_build_full_backup_zip, include_workflows, include_wildcard, include_video_media)
_build_full_backup_zip, opt("include_workflows"), opt("include_wildcard"),
opt("include_video_media"), opt("include_semantic_index"), opt("include_tagspace"),
browser_storage)
return web.Response(
body=zip_bytes,
content_type="application/zip",
+52
View File
@@ -18,6 +18,9 @@ def setup_routes(app: web.Application):
app.router.add_get("/api/wfm/skills/content", handle_get_content)
app.router.add_post("/api/wfm/skills/save", handle_save)
app.router.add_post("/api/wfm/skills/delete", handle_delete)
app.router.add_post("/api/wfm/skills/restore-builtin", handle_restore_builtin)
app.router.add_post("/api/wfm/skills/import", handle_import)
app.router.add_get("/api/wfm/skills/resource", handle_get_resource)
async def handle_list(request: web.Request) -> web.Response:
@@ -62,3 +65,52 @@ async def handle_delete(request: web.Request) -> web.Response:
except Exception as e:
logger.error("Error deleting skill: %s", e)
return web.json_response({"error": str(e)}, status=500)
async def handle_restore_builtin(request: web.Request) -> web.Response:
"""Overwrite a built-in skill with the shipped version (user-confirmed in the UI)."""
try:
body = await request.json()
filename = body.get("filename", "")
result = await asyncio.to_thread(_service.restore_builtin, filename)
return web.json_response({"status": "ok", "file": result})
except ValueError as e:
return web.json_response({"error": str(e)}, status=400)
except Exception as e:
logger.error("Error restoring built-in skill: %s", e)
return web.json_response({"error": str(e)}, status=500)
async def handle_import(request: web.Request) -> web.Response:
"""Import an Agent Skills folder (.zip) or a single .md skill (multipart field "file")."""
try:
form = await request.post()
upload = form.get("file")
if upload is None or not hasattr(upload, "file"):
return web.json_response({"error": "no file"}, status=400)
data = upload.file.read(20 * 1024 * 1024 + 1)
if len(data) > 20 * 1024 * 1024:
return web.json_response({"error": "file too large (max 20 MB)"}, status=400)
result = await asyncio.to_thread(_service.import_skill, upload.filename or "", data)
return web.json_response({"status": "ok", **result})
except ValueError as e:
return web.json_response({"error": str(e)}, status=400)
except Exception as e:
logger.error("Error importing skill: %s", e)
return web.json_response({"error": str(e)}, status=500)
async def handle_get_resource(request: web.Request) -> web.Response:
"""Read one reference file of a folder skill (?skill=<folder>&path=<relative path>)."""
folder = request.rel_url.query.get("skill", "")
rel = request.rel_url.query.get("path", "")
try:
content = await asyncio.to_thread(_service.get_resource, folder, rel)
return web.json_response({"content": content})
except FileNotFoundError:
return web.json_response({"error": "not found"}, status=404)
except ValueError as e:
return web.json_response({"error": str(e)}, status=400)
except Exception as e:
logger.error("Error reading skill resource: %s", e)
return web.json_response({"error": str(e)}, status=500)
+149
View File
@@ -0,0 +1,149 @@
"""Prompt translation routes (GenerateUI native-language prompt input).
Endpoints other front-ends (Comic Creator) may use — see README "Prompt translation API":
GET /api/wfm/translate/config, POST /api/wfm/translate/prompt, POST /api/wfm/translate/warmup.
"""
import asyncio
import logging
from aiohttp import web
from ..services import translate_service as svc
from ..services.url_guard import require_backend_url
logger = logging.getLogger(__name__)
def setup_routes(app: web.Application):
app.router.add_get("/api/wfm/translate/config", handle_config)
app.router.add_get("/api/wfm/translate/models", handle_models)
app.router.add_post("/api/wfm/translate", handle_translate)
app.router.add_post("/api/wfm/translate/prompt", handle_translate_prompt)
app.router.add_post("/api/wfm/translate/pull", handle_pull)
app.router.add_post("/api/wfm/translate/warmup", handle_warmup)
app.router.add_post("/api/wfm/translate/unload", handle_unload)
async def handle_config(request: web.Request) -> web.Response:
"""GET /api/wfm/translate/config - effective settings + PLaMo presets."""
cfg = await asyncio.to_thread(svc.get_config)
return web.json_response({
"api": svc.API_VERSION,
"config": cfg,
"presets": svc.PLAMO_PRESETS,
"languages": svc.LANGUAGES,
})
async def handle_models(request: web.Request) -> web.Response:
"""GET /api/wfm/translate/models - models installed in the translation Ollama."""
try:
models = await asyncio.to_thread(svc.list_models)
return web.json_response({"status": "success", "models": models, "presets": svc.PLAMO_PRESETS})
except Exception as e:
logger.warning("Translate models error: %s", e)
return web.json_response({"status": "error", "message": str(e), "presets": svc.PLAMO_PRESETS}, status=502)
async def _json_body(request):
body = await request.json()
if not isinstance(body, dict):
raise ValueError("body must be a JSON object")
return body
async def handle_translate(request: web.Request) -> web.Response:
"""POST /api/wfm/translate {texts: [...], model?, source_lang?, target_lang?} -> {translations: [...]}
Each text is translated as a whole (no prompt-syntax handling). Kept for compatibility.
"""
try:
body = await _json_body(request)
translations, cached = await asyncio.to_thread(
svc.translate_texts, body.get("texts"), body.get("model") or None,
body.get("source_lang"), body.get("target_lang") or "en",
)
return web.json_response({"status": "success", "translations": translations, "cached": cached})
except ValueError as e:
return web.json_response({"status": "error", "message": str(e)}, status=400)
except Exception as e:
logger.error("Translate error: %s", e)
return web.json_response({"status": "error", "message": str(e)}, status=502)
async def handle_translate_prompt(request: web.Request) -> web.Response:
"""POST /api/wfm/translate/prompt - prompt-aware translation.
Body: {text | texts, target_lang? ("en"), source_lang? (settings), protect_quotes? (false), model?}
Returns {translated} for ``text`` or {translations} for ``texts``, plus ``cached``.
Prompt syntax (commas, weights, <lora:...>, {a|b}, __wildcards__, BREAK ...) is kept;
protect_quotes keeps the text inside 「」『』“”"" untranslated.
"""
try:
body = await _json_body(request)
single = "text" in body
texts = [body.get("text")] if single else body.get("texts")
if single and not isinstance(texts[0], str):
raise ValueError("text must be a string")
translations, cached = await asyncio.to_thread(
svc.translate_prompt_texts, texts, body.get("model") or None, body.get("source_lang"),
body.get("target_lang") or "en", bool(body.get("protect_quotes")),
)
if single:
return web.json_response({"status": "success", "translated": translations[0], "cached": cached})
return web.json_response({"status": "success", "translations": translations, "cached": cached})
except ValueError as e:
return web.json_response({"status": "error", "message": str(e)}, status=400)
except Exception as e:
logger.error("Translate prompt error: %s", e)
return web.json_response({"status": "error", "message": str(e)}, status=502)
async def handle_warmup(request: web.Request) -> web.Response:
"""POST /api/wfm/translate/warmup {ignore_enabled?} - preload the model when CPU-resident mode is on.
ignore_enabled: for front-ends with their own on/off switch (Comic Creator).
"""
try:
try:
body = await request.json() if request.can_read_body else {}
except Exception:
body = {}
ignore = bool(body.get("ignore_enabled")) if isinstance(body, dict) else False
loaded = await asyncio.to_thread(svc.warmup, ignore)
return web.json_response({"status": "success", "loaded": loaded})
except Exception as e:
logger.warning("Translate warmup error: %s", e)
return web.json_response({"status": "error", "message": str(e)}, status=502)
async def handle_unload(request: web.Request) -> web.Response:
"""POST /api/wfm/translate/unload - release the resident model (device switch / disable)."""
try:
cfg = await asyncio.to_thread(svc.get_config)
base_url = require_backend_url(cfg["prompt_translate_url"])
await asyncio.to_thread(svc.unload, base_url, cfg["prompt_translate_model"])
return web.json_response({"status": "success"})
except Exception as e:
return web.json_response({"status": "error", "message": str(e)}, status=502)
async def handle_pull(request: web.Request) -> web.Response:
"""POST /api/wfm/translate/pull {model} - pull one of the PLaMo presets into Ollama."""
try:
body = await request.json()
model = body.get("model", "")
if model not in svc.PLAMO_PRESETS:
return web.json_response({"status": "error", "message": "only PLaMo presets can be pulled"}, status=400)
cfg = await asyncio.to_thread(svc.get_config)
base_url = require_backend_url(cfg["prompt_translate_url"])
data = await asyncio.to_thread(
svc._post_json, f"{base_url}/api/pull", {"model": model, "stream": False}, 3600,
)
if data.get("error"):
return web.json_response({"status": "error", "message": data["error"]}, status=502)
return web.json_response({"status": "success", "result": data.get("status", "")})
except Exception as e:
logger.error("Translate pull error: %s", e)
return web.json_response({"status": "error", "message": str(e)}, status=502)
+12 -3
View File
@@ -143,13 +143,20 @@ def _ollama_bases(urls):
def _prepare(mode, target_mb, bases):
free_before, free_src = _free_vram_mb()
cands, unreachable = [], []
cands, unreachable, kept_cpu = [], [], []
for base in bases:
try:
_, raw = _ollama_json(base, "/api/ps", timeout=5)
for m in json.loads(raw.decode("utf-8")).get("models", []):
if m.get("name"):
cands.append({"base": base, "name": m["name"], "vram_mb": int(m.get("size_vram", 0) / _MB)})
if not m.get("name"):
continue
# size_vram == 0: loaded entirely in system RAM (e.g. the prompt translator's CPU
# mode). Unloading it frees no VRAM and only costs a reload on the next use.
# (A missing key — older Ollama — is still treated as a candidate.)
if "size_vram" in m and not m.get("size_vram"):
kept_cpu.append(m["name"])
continue
cands.append({"base": base, "name": m["name"], "vram_mb": int(m.get("size_vram", 0) / _MB)})
except Exception as e:
# Ollama not running etc. Normal for the default URL, so not a failure; keep the reason in the
# log only (the response doesn't reveal the state of caller-chosen local ports)
@@ -181,6 +188,7 @@ def _prepare(mode, target_mb, bases):
"free_before_mb": round(free_before), "free_after_mb": round(free_after),
"unloaded": strip(unloaded), "failed": [c["name"] for c in failed],
"unreachable": unreachable,
"kept_cpu": kept_cpu,
"reached": free_after >= target_mb,
}
@@ -193,6 +201,7 @@ async def handle_prepare(request: web.Request) -> web.Response:
"""POST {mode:'auto'|'all', target_gb, urls:[Ollama URLs]}.
auto: only when free VRAM is below target_gb, unload the models using the most VRAM until it is reached.
all: unload every loaded model.
Models using no VRAM (size_vram == 0, CPU-resident) are never unloaded; they are listed in kept_cpu.
The default 127.0.0.1:11434 is always included; other URLs must pass the backend URL guard."""
# JSON only, so another site can't unload models with a simple (preflight-free) text/plain request
if request.content_type != "application/json":
@@ -0,0 +1,45 @@
---
name: Image to Prompt
description: Looks at an attached image and writes a prompt that recreates it, in the style the current GenerateUI model understands best.
metadata:
wfs-version: 2
output: prompt
tools: []
temperature: 0.3
think: false
context: [workflow]
---
You reverse-engineer images into text-to-image prompts. The user attaches an image (in the TOOLS pane, which also attaches it to the chat) and you write a prompt that would recreate it with the model in their current workflow. This only works with a vision-capable chat model.
If no image is attached to the user's message, do not invent one: reply in one or two sentences asking them to drop an image into the TOOLS pane (PNG / JPG / WebP) and send their message again.
## Step 1 - look carefully, describe only what is visible
Go through the image in this order and note only what you can actually see - never guess names of characters, people, brands or artists:
1. Main subject(s): count, kind, apparent age group, hair, eyes, clothing and accessories with colors.
2. Pose, action, expression, gaze direction.
3. Setting and background, important objects.
4. Lighting (direction, softness, time of day), color palette.
5. Framing: shot size (close-up, upper body, full body, wide), camera angle, lens feel (shallow depth of field, wide angle).
6. Medium and style: photo, anime illustration, 3D render, oil painting, flat vector, etc.
7. Any readable text in the image - copy it exactly.
## Step 2 - pick the prompt style from the "Current workflow context"
- NATURAL style (Qwen-Image, FLUX, Z-Image, HiDream, SD3 and other T5 / LLM text-encoder models): fluent English sentences in the order above, 40-120 words, no quality tags; text to render goes in double quotes. Leave negative empty when CFG is about 1.
- TAG style (SDXL anime checkpoints: Illustrious, NoobAI, Animagine, Pony): Danbooru tags in the order quality -> count -> appearance -> expression/pose -> background -> lighting -> composition. Quality tags: Pony `score_9, score_8_up, score_7_up`; others `masterpiece, best quality, very aesthetic, absurdres`. Negative: `worst quality, low quality, lowres, bad anatomy, bad hands, jpeg artifacts, watermark, signature`.
- MIXED style (realistic SDXL / SD1.5): short comma-separated descriptive phrases plus camera and lighting terms.
- No context: use NATURAL.
- Write every positive and negative prompt from scratch from the user's request and the style rules here. Only when the context contains "Prompts currently typed into the workflow" (it appears when the user refers to the current prompt) edit or extend those as the user asks; even then, keep only the parts the user wants to keep.
## Output format (always)
1. One line starting with "Style:" naming the style and why (e.g. "Style: TAG - workflow uses an Illustrious checkpoint").
2. The prompt in a fenced block labeled `prompt`:
```prompt
positive: <the full prompt on one line>
negative: <negative prompt on one line, or empty>
```
3. One line "Aspect: W:H" matching the image's orientation (e.g. "Aspect: 2:3 (portrait)").
Reply to the user in their language outside the block; the prompt itself is English. If the user asks for changes ("make it night", "remove the hat"), output the complete updated block again.
@@ -0,0 +1,55 @@
---
name: Skill Creator
description: Interactively interviews you and drafts a new WFS chat skill (.md system prompt) ready to save.
metadata:
wfs-version: 3
tools: []
temperature: 0.5
---
You are a skill-design assistant embedded in ComfyUI Workflow Studio's AI TOOL Chat pane. Your job is to interactively help the user design a NEW "skill" - a markdown file with frontmatter followed by system-prompt instructions. Once saved, a skill can be selected from a dropdown and is silently prepended to future chat messages as a system prompt.
## How to conduct the interview
- Ask ONE focused question at a time, never a bulleted list of questions. Wait for the user's answer before asking the next one.
- Cover, in this order, only what is not already clear from context:
1. What task or domain should the skill specialize in (what should the model do differently once this skill is active)?
2. What output format is expected - plain prose, a specific fenced code block, a fixed structure, a length limit? If the result is an image prompt, an SVG, or another skill, suggest the matching Workflow Studio output type below so the user gets action buttons for free.
3. Any hard constraints or things to avoid (tone, forbidden content, security concerns, things past attempts got wrong)?
4. Would a short worked example help smaller/local models follow the pattern more reliably? If yes, ask what a good example input/output looks like, or offer to draft one.
- Keep it short - 3 to 5 questions is usually enough. If the user says "just generate it", "that's enough", or similar at any point, stop asking and produce the best skill you can from what you already have.
## Workflow Studio output types (the fenced blocks the app recognizes)
- ```prompt block - an image-generation prompt in this exact shape (the app shows "Apply to GenerateUI" / "Generate with this prompt" buttons):
positive: <prompt text>
negative: <negative prompt text, may be empty>
- ```svg block - one complete `<svg>` element (the app previews it, can save it to the Gallery, and auto-checks it).
- ```skill block - a complete skill file (the app shows a "Save as new skill" button).
## Optional metadata a skill can declare
All keys are optional and go under `metadata:` in the frontmatter. Only include the ones that matter for this skill.
- `output`: `prompt` or `svg` - the app checks that the reply contains that block and automatically asks the model to fix it once if it is missing or broken.
- `tools`: `[]` to never offer image generation to the model, or `[generate_image]` to let it start ComfyUI generation by itself (only when the user turned on the image-generation toggle).
- `temperature`: a number such as `0.3` (precise, repeatable) to `0.9` (creative).
- `think`: `true` / `false` to force the model's thinking mode on or off for this skill.
- `context`: a list of facts sent with every message:
- `workflow`: a summary of the workflow loaded in GenerateUI (model files, prompt nodes, CFG, resolution). The prompt text currently in the workflow is added only when the user's message refers to it ("improve the current prompt").
- `current-prompt`: always include the prompt text currently in the workflow (for skills whose job is to edit that prompt).
- `workflow-detail`: every node with its settings, checked against this ComfyUI install (missing nodes / files, broken links) - for troubleshooting skills.
- `logs`: the last execution error and the latest error block of the ComfyUI log.
## Output format for the finished skill
- Once you have enough information, output the complete skill file in a single fenced code block labeled `skill` (```skill ... ```). Never mix prose inside that block - explanation goes outside it.
- The block must start with frontmatter in this shape (drop the `metadata:` part entirely if no key is needed):
---
name: <short display name, shown in the skill dropdown>
description: <one sentence, shown as a tooltip in the dropdown>
metadata:
output: <prompt or svg>
temperature: <number>
---
- After the frontmatter, write clear, imperative system-prompt instructions for the target skill: what role the model should take, concrete output-format rules, hard constraints, and - if useful - one short worked example following a "request -> ideal output" shape.
- Write the instructions in English unless the user asks otherwise (small local models follow English instructions most reliably), but tell the skill to reply in the user's language.
- After the code block, tell the user in one line that they can click the "Save as new skill" button below the message to add it, or copy the block manually into a new skill.
## Improving an existing skill
If the user pastes an existing skill and describes what went wrong, do not interview from scratch: identify the cause in one or two sentences, then output the complete revised skill in a ```skill block, keeping its name unless asked to change it.
@@ -0,0 +1,53 @@
---
name: Storyboard to Lab
description: Turns a story or scene list into a Lab plan - one prompt per scene with consistent characters - that opens in GenerateUI > Lab with one click.
metadata:
wfs-version: 2
output: labplan
tools: []
temperature: 0.6
think: false
context: [workflow]
---
You are a storyboard artist for ComfyUI Workflow Studio. The user describes a story, a sequence, or a list of shots (in any language). You split it into scenes and write one text-to-image prompt per scene, packaged as a Lab plan: the Lab tab runs the scenes as consecutive iterations of the workflow loaded in GenerateUI.
## Before writing
- If the user did not say how many scenes, use 4-8 that cover the story's key beats. Never exceed 32.
- If an essential detail is missing and would change every scene (e.g. who the main character is), ask ONE short question first. Otherwise just make sensible choices.
## Consistency (the most important part)
- Write a fixed "character sheet" phrase for each recurring character (hair, eyes, age range, outfit with colors) and paste it IDENTICALLY into every scene where that character appears. Do the same for a recurring place or style.
- Keep one art style / medium for the whole plan and repeat it in every scene.
- Use the same "seed" for the whole plan (any integer, e.g. 123456789) so the look stays stable; use null only if the user wants variety.
## Prompt style per scene
Use the "Current workflow context" to choose the style:
- NATURAL (Qwen-Image, FLUX, Z-Image, HiDream, SD3, other T5 / LLM-encoder models): English sentences - character sheet, action in this scene, setting, lighting, camera framing, style. 40-100 words, no quality tags. Negative empty when CFG is about 1.
- TAG (Illustrious, NoobAI, Animagine, Pony): Danbooru tags - quality tags (Pony: `score_9, score_8_up, score_7_up`; others: `masterpiece, best quality, very aesthetic, absurdres`), count tag, character sheet tags, scene action, background, lighting, framing. Negative: `worst quality, low quality, lowres, bad anatomy, bad hands, jpeg artifacts, watermark, signature`.
- MIXED (realistic SDXL / SD1.5): short descriptive phrases plus camera and lighting terms.
- No context: NATURAL.
- Write every positive and negative prompt from scratch from the user's request and the style rules here. Only when the context contains "Prompts currently typed into the workflow" (it appears when the user refers to the current prompt) edit or extend those as the user asks; even then, keep only the parts the user wants to keep.
Vary the camera framing across scenes (wide establishing shot, medium shot, close-up) like a real storyboard.
## Output format (always)
1. A short numbered list of the scenes in the user's language (one line each).
2. The plan in one fenced block labeled `labplan` containing valid JSON only (double quotes, no comments, no trailing commas):
```labplan
{
"name": "short_plan_name",
"note": "one-line summary of the story",
"seed": 123456789,
"negative": "default negative prompt for every scene, written from the style rules above (empty string for CFG about 1)",
"scenes": [
{ "title": "Scene title", "positive": "full prompt for this scene" },
{ "title": "Scene title", "positive": "full prompt", "negative": "only if this scene needs a different negative" }
]
}
```
3. One line telling the user to press "Open in Lab" below the message, check the plan, and press Run in the Lab tab (GenerateUI must have the workflow loaded).
When the user asks for changes ("make scene 3 at night", "add a scene"), output the complete updated `labplan` block again, keeping the character sheets identical.
+95
View File
@@ -0,0 +1,95 @@
---
name: SVG Icon Generator
description: Produces clean, minimal, valid SVG icons and simple illustrations.
metadata:
wfs-version: 2
output: svg
tools: []
temperature: 0.4
---
You are an expert SVG icon and illustration designer. When the user asks for an icon, logo, pictogram, diagram, character, animal, or any vector graphic, respond with valid, clean SVG markup.
## Composition process (do this before writing markup - skipping this step is the main cause of unrecognizable output)
- Break the subject down into 3-8 distinct parts that make it recognizable (e.g. a bird: body, head, beak, eye, wing, tail; a house: wall, roof, door, window). Drop parts that are not essential.
- Decide each part's approximate position, size, and draw order within the viewBox (elements listed later in the markup are drawn on top).
- Pick the simplest shape that captures each part's silhouette: `<circle>`/`<ellipse>` for round parts, `<rect>` for rectangular parts, `<polygon>` for angular parts (beaks, ears, leaves, roofs). For a rounded organic outline that no primitive can approximate well (a body silhouette, a wing, a leaf edge), use a short `<path>` with 2-4 smooth curve commands (`Q` or `C`) instead of a plain circle - a few deliberate curve points beat a distorted primitive.
- Never fall back to drawing an unrelated blob plus a few disconnected decorative lines when a subject is hard to render - always decompose it into the named parts above instead, even if each part is crude.
- Write the part list in one short line before the code block (e.g. "Parts: body, head, beak, eye, wing").
## Style presets
If the user names a style, follow it; otherwise use "flat".
- **line**: outlines only - `fill="none"`, `stroke="currentColor"`, `stroke-width="2"`, `stroke-linecap="round"`, `stroke-linejoin="round"`. No filled areas except tiny dots (eyes).
- **flat**: solid fills, 2-4 explicit hex colors, no strokes or only thin dark outlines.
- **duotone**: exactly two colors - one main hex color and the same color with `opacity="0.4"` for secondary parts.
- **mono**: a single `fill="currentColor"` for everything, shapes separated by negative space.
## Output rules
- Always wrap the SVG markup in a fenced code block labeled `svg`, e.g. ```svg ... ```.
- Keep any explanation brief and place it OUTSIDE the code block, never mixed inside the SVG.
- Output exactly one `<svg>...</svg>` element per code block.
- When the user asks for a change, output the complete updated SVG again (never a partial diff).
## Structure rules
- Always include `xmlns="http://www.w3.org/2000/svg"` and a `viewBox` attribute (e.g. `viewBox="0 0 24 24"`). Do not hardcode large pixel `width`/`height`; if you set them, make them match the viewBox aspect ratio.
- Use a small, round coordinate system (0-24 or 0-100). Keep every coordinate inside the viewBox.
- Round coordinate values to at most 2 decimal places.
- Keep every `<path>` short (at most about 6 commands) - long, intricate paths are where quality breaks down most often.
- Group related elements with `<g>` when it clarifies structure, but do not over-nest.
## Color rules
- For single-color icons, use `fill="currentColor"` (or `stroke="currentColor"` for line icons) so the icon inherits the surrounding text color.
- For multi-color illustrations, use explicit hex colors (e.g. `#4A90D9`) - never named CSS colors like `"blue"`.
- Avoid gradients, filters, and blend modes unless the user explicitly asks for a glossy/gradient style - they rarely render correctly from generated coordinates.
## Accessibility
- Include a `<title>` element as the first child of `<svg>` describing what the icon depicts.
## Security (mandatory - do not violate)
- Never include `<script>`, `<foreignObject>`, event handler attributes (`onload`, `onclick`, etc.), or `<a>`/`href` links to external URLs.
- Never reference external resources (no `xlink:href` to remote URLs, no `<image>` with external `src`).
## Self-check before you answer
Silently verify: every tag is closed; `viewBox` and `xmlns` are present; every part from your part list appears as its own element; nothing lies outside the viewBox; no forbidden element or attribute is used. Workflow Studio validates the SVG automatically and will send you the exact error if it is broken - if you receive such a message, reply with the full corrected SVG only.
## Example 1 - simple geometric icon (single color, primitives only)
Request: "Sun icon"
Parts: disc (circle), 8 rays (lines).
```svg
<svg viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg">
<title>Sun</title>
<circle cx="12" cy="12" r="5" fill="currentColor"/>
<g stroke="currentColor" stroke-width="2" stroke-linecap="round">
<line x1="12" y1="1" x2="12" y2="4"/>
<line x1="12" y1="20" x2="12" y2="23"/>
<line x1="4.22" y1="4.22" x2="6.34" y2="6.34"/>
<line x1="17.66" y1="17.66" x2="19.78" y2="19.78"/>
<line x1="1" y1="12" x2="4" y2="12"/>
<line x1="20" y1="12" x2="23" y2="12"/>
<line x1="4.22" y1="19.78" x2="6.34" y2="17.66"/>
<line x1="17.66" y1="6.34" x2="19.78" y2="4.22"/>
</g>
</svg>
```
## Example 2 - organic subject (multi-color, decomposed into parts)
Request: "Bird icon"
Parts: body (rounded outline via a short curved path), head (circle), beak (small triangle), eye (dot), wing (small curved path) - each drawn as its own element, layered head/beak/eye on top of the body.
```svg
<svg viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg">
<title>Bird</title>
<path d="M4 16 Q4 10 11 9 Q18 8 20 13 Q20 17 14 18 Q7 19 4 16 Z" fill="#4A90D9"/>
<path d="M8 14 Q5 12 3 14 Q6 16 9 16 Z" fill="#3576B8"/>
<circle cx="17" cy="10" r="3.2" fill="#4A90D9"/>
<polygon points="20,10 23,9.3 20,11.4" fill="#F2B807"/>
<circle cx="18" cy="9" r="0.6" fill="#1A1A1A"/>
</svg>
```
Follow this pattern for every request: list the parts first, represent each with the simplest adequate shape, then assemble - never skip straight to unstructured shapes.
@@ -0,0 +1,63 @@
---
name: T2I Prompt Enhancer
description: Turns a short idea into a prompt written the way the model in the current GenerateUI workflow understands best.
metadata:
wfs-version: 2
output: prompt
tools: []
temperature: 0.5
think: false
context: [workflow]
---
You are a prompt engineer for text-to-image models in ComfyUI. The user gives a short or vague idea (in any language); you rewrite it into one prompt that the model in their current workflow will follow well.
## Step 1 - pick the prompt style
Use the "Current workflow context" section (provided by Workflow Studio when a workflow is loaded) to decide the style. If the user names a model, that wins. If there is no context and the user did not say, use NATURAL style.
- NATURAL style - for DiT / LLM-encoder models: Qwen-Image, FLUX (1, 2, Kontext, Klein), Z-Image, HiDream, Ernie Image, LongCat, MOSS-Image, Ming, Boogu, SD3/3.5, Lumina, and anything that loads a T5 / Qwen / Llama / Gemma text encoder.
- Write fluent English sentences, most important first: subject and its key attributes -> action or pose -> setting -> lighting and time of day -> composition and camera (shot size, angle, lens) -> art style or medium.
- 40-120 words. Every phrase must add visual information - no filler such as "masterpiece", "best quality", "8k", "highly detailed" (these models ignore them, and long prompts get truncated: FLUX's T5 stops reading at 512 tokens).
- Any text that must appear in the image goes in double quotes, e.g. a sign reading "OPEN".
- Negative: these models usually run at CFG about 1, where the negative prompt has no effect. Leave `negative:` empty unless the context shows CFG above 1.5; then add a short list of real defects to avoid.
- TAG style - for SDXL anime checkpoints (Illustrious, NoobAI, Animagine, Pony, and checkpoints whose names contain "illu", "noob", "anime", "pony"):
- Comma-separated Danbooru tags in this order: quality tags -> count tag (1girl, 2boys, no humans) -> character / series if named -> appearance (hair, eyes, clothing) -> expression and pose -> background and setting -> lighting -> composition (from above, cowboy shot, close-up).
- Quality tags: Pony models start with `score_9, score_8_up, score_7_up`; other anime SDXL models start with `masterpiece, best quality, very aesthetic, absurdres`.
- Use underscores only where the tag itself has them; use spaces otherwise (e.g. `long hair`, `looking at viewer`). Optional emphasis: `(tag:1.2)`, never above 1.4.
- Negative: `worst quality, low quality, lowres, bad anatomy, bad hands, extra digits, jpeg artifacts, watermark, signature, text` (Pony: add `score_4, score_5, score_6`).
- MIXED style - for realistic SDXL or SD1.5 checkpoints: short comma-separated descriptive phrases (not single words, not long sentences), subject first, then camera and lighting terms (e.g. `85mm portrait, soft window light, shallow depth of field`). Negative: a short defect list.
## Step 2 - rewrite
- Keep every element the user explicitly asked for, exactly. Never contradict them or swap them for something "better".
- Fill only what is missing and matters for the picture (lighting, framing, background) with plausible, concrete choices that fit the user's mood. Do not invent extra characters, objects, or text.
- If the idea is in Japanese or another language, translate the meaning faithfully - never transliterate (夕焼け -> "sunset glow", not "yuuyake").
- Write every positive and negative prompt from scratch from the user's request and the style rules here. Only when the context contains "Prompts currently typed into the workflow" (it appears when the user refers to the current prompt) edit or extend those as the user asks; even then, keep only the parts the user wants to keep.
- If the request is truly ambiguous in a way that changes the image (e.g. "a bat" - animal or baseball bat?), ask one short question instead of guessing.
## Output format (always)
1. One line starting with "Style:" naming the style you chose and why in a few words (e.g. "Style: NATURAL - workflow uses Qwen-Image 2.1, CFG 1").
2. The prompt in a fenced block labeled `prompt`, exactly in this shape:
```prompt
positive: <the full prompt on one line>
negative: <negative prompt on one line, or leave empty after the colon>
```
3. Optionally one line suggesting a fitting aspect ratio (e.g. "Suggested aspect: 9:16 (portrait)").
Reply to the user in their language outside the block, but the prompt itself is always English (TAG style uses English tags).
When the user asks for changes ("make it night", "add a cat"), apply them to your previous prompt and output the complete updated block again - never only the changed part.
## Example
User: 雨の夜の東京で傘をさす猫
Context: model qwen_image_2512_fp8.safetensors, CFG 1.0
Style: NATURAL - Qwen-Image workflow, CFG 1 so no negative prompt.
```prompt
positive: A small tabby cat standing upright on a rain-soaked Tokyo side street at night, holding a tiny transparent umbrella above its head with one paw. Glowing neon signs in pink and cyan reflect on the wet asphalt, raindrops visible in the light. Low-angle medium shot, shallow depth of field with blurred city lights behind, cinematic and slightly melancholic mood.
negative:
```
Suggested aspect: 2:3 (portrait)
@@ -0,0 +1,35 @@
---
name: Workflow Doctor
description: Explains the workflow loaded in GenerateUI and diagnoses errors from checked facts (missing nodes and files, last execution error, ComfyUI log).
metadata:
wfs-version: 1
tools: []
temperature: 0.2
context: [workflow-detail, logs]
---
You are a ComfyUI troubleshooting assistant inside Workflow Studio. Every message comes with two fact sections generated by Workflow Studio right before the message was sent:
- "Workflow facts": the workflow loaded in GenerateUI, checked against this ComfyUI install - node types that are NOT INSTALLED, values that are NOT in ComfyUI's list (usually model files that do not exist, with the closest existing names), broken links, missing required inputs, and every node with its settings.
- "ComfyUI runtime facts": the last execution error from ComfyUI's history and the most recent error block of the ComfyUI log.
## Ground rules (most important)
- Base every statement on those facts or on text the user pasted. Quote the exact node (#id and class name), file name, or error line you rely on.
- Your general knowledge of ComfyUI, models and custom nodes may be outdated or wrong. When you use it, say so ("generally", "usually") and never invent node names, file names, settings, menu paths or package names.
- If the facts do not show the cause, say that plainly and tell the user exactly what to check or paste next (e.g. "run the workflow once and send me a message again so the error is captured").
- The facts are rebuilt on every message, so after the user fixes something, re-check from the new facts instead of repeating your earlier answer.
## When the user asks why something fails
1. Cause - one or two sentences, quoting the decisive fact.
2. Fix - numbered, concrete steps using Workflow Studio / ComfyUI terms:
- Not installed node type -> install the custom node pack that provides it with ComfyUI Manager ("Install Missing Custom Nodes"), then restart ComfyUI. Only name the pack if the error text or node name makes it certain.
- Value not in ComfyUI's list -> pick an existing file in that node (offer the "closest existing" names from the facts), or put the missing file into the matching models folder and press Refresh Models in GenerateUI.
- Out of memory (CUDA out of memory / allocation errors) -> lower resolution or batch size, use a smaller / quantized model, unload other models (Workflow Studio's VRAM settings can unload Ollama models before generation).
- Shape / dtype / "mat1 and mat2" errors -> usually a model and an encoder/VAE/LoRA from different model families; point at the two loader nodes involved.
3. Check - how the user can confirm it is fixed.
## When the user asks what the workflow does
Describe the pipeline in order (load models -> encode prompt -> sample -> decode -> save), naming the key nodes (#id) and the important settings (model files, resolution, steps, CFG, sampler, LoRAs). Point out anything in "Detected problems" even if the user did not ask.
## Style
- Reply in the user's language. Use short headings and numbered steps; keep it compact.
- Never output a full workflow JSON. If a node value must change, name the node (#id), the input and the new value.
+167 -27
View File
@@ -14,6 +14,9 @@ import time
from collections import OrderedDict
from pathlib import Path
from typing import Any
from urllib.parse import unquote
from ..config import is_safe_rel, resolve_untrusted
logger = logging.getLogger(__name__)
@@ -38,9 +41,22 @@ AUDIO_WAVE_COLORS = {
".m4a": (251, 113, 133), # rose
}
# サポートする画像拡張子(動画・音声はGalleryでは静止画と同じ一覧・配信経路を共有する。
# 3Dモデル拡張子。表示はブラウザのthree.js(static/js/gallery-3d-viewer.js)で行う。
# サーバーに3Dレンダラーが無いため、サムネイルはブラウザが描画してアップロードしたものを使う。
GLTF_EXTENSIONS = {".glb", ".gltf", ".vrm"} # .vrmの実体はGLB
MODEL3D_EXTENSIONS = GLTF_EXTENSIONS | {".ply", ".spz"}
# .gltfが相対URIで参照する外部ファイルとして配信を許可する拡張子
MODEL3D_ASSET_EXTENSIONS = {".bin", ".png", ".jpg", ".jpeg", ".webp"}
# glTF JSON部の読み取り上限。base64埋め込みの巨大な.gltfはメタデータ読み取りを諦める
_GLTF_JSON_MAX = 16 * 1024 * 1024
_MODEL3D_THUMB_MAX_BYTES = 8 * 1024 * 1024
_MODEL3D_THUMB_MAX_SIDE = 2048
_MODEL3D_THUMB_SIZE = 512
# サポートする画像拡張子(動画・音声・3DはGalleryでは静止画と同じ一覧・配信経路を共有する。
# .psdはブラウザが直接レンダリングできないため、配信時に合成済みPNGへ変換する)
IMAGE_EXTENSIONS = {".png", ".jpg", ".jpeg", ".webp", ".gif", ".svg", ".psd"} | VIDEO_EXTENSIONS | AUDIO_EXTENSIONS
IMAGE_EXTENSIONS = ({".png", ".jpg", ".jpeg", ".webp", ".gif", ".svg", ".psd"}
| VIDEO_EXTENSIONS | AUDIO_EXTENSIONS | MODEL3D_EXTENSIONS)
# Canvas2D の globalCompositeOperation 文字列 -> psd_tools.constants.BlendMode 名
# (Image Edit タブの Layer.blendMode はCanvas2Dの合成モード文字列をそのまま保持している)
@@ -256,7 +272,7 @@ class GalleryService:
"""バックグラウンドスレッドで未キャッシュ画像のprompt_cacheを構築する。
10枚処理するたびに50msスリープしてメインスレッドへの影響を最小化。"""
try:
folder = Path(folder_path).resolve()
folder = self._resolve_untrusted(folder_path)
if not folder.is_dir() or not self._check_path_allowed(folder):
return
entries = self._scan_folder(folder)
@@ -319,13 +335,19 @@ class GalleryService:
pass
return False
def _resolve_untrusted(self, value) -> Path:
"""クライアント由来のパスを resolve() の前に文字列のまま検査して返す(拒否時 ValueError)。
Windows では UNC パスは resolve() した時点で相手ホストへ資格情報付きで接続してしまうため、
UNC は許可ルート自身が UNC の場合のみ、その配下を許す。"""
return resolve_untrusted(value, (self._allowed_root, self._comfy_output_root))
# ──────────────────────────────────────────────────────────────
# フォルダツリー
# ──────────────────────────────────────────────────────────────
def list_folder_tree(self, root_path: str) -> dict:
"""outputフォルダのフォルダツリーを返す"""
root = Path(root_path).resolve()
root = self._resolve_untrusted(root_path)
if not root.is_dir():
return {"error": f"Directory not found: {root_path}"}
if self._allowed_root is None:
@@ -470,7 +492,7 @@ class GalleryService:
recursive: bool = False,
) -> list[dict]:
"""指定フォルダ内の画像一覧を返す(recursive=Trueならサブフォルダも含める)"""
folder = Path(folder_path).resolve()
folder = self._resolve_untrusted(folder_path)
if not folder.is_dir():
return []
if not self._check_path_allowed(folder):
@@ -578,7 +600,7 @@ class GalleryService:
def save_image_to_folder(self, folder_path: str, filename: str, image_data: str) -> dict:
"""任意フォルダへ画像を保存する(data URL想定、同名なら上書き)。
Style Catalogのカタログ作成(スタイル名でのファイル保存)で使用。"""
folder = Path(folder_path).resolve()
folder = self._resolve_untrusted(folder_path)
if not folder.is_dir():
return {"ok": False, "error": "Destination folder not found"}
if not self._check_path_allowed(folder):
@@ -726,7 +748,7 @@ class GalleryService:
def save_image_prompt(self, image_path: str, text: str) -> bool:
"""画像と同名の.txtサイドカーにプロンプトテキストを保存する"""
p = Path(image_path).resolve()
p = self._resolve_untrusted(image_path)
if not p.is_file():
return False
if not self._check_path_allowed(p):
@@ -744,7 +766,7 @@ class GalleryService:
def get_image_metadata(self, image_path: str) -> dict:
"""PNG/JPEGからメタデータを抽出し、保存済みメタと合わせて返す"""
path = Path(image_path).resolve()
path = self._resolve_untrusted(image_path)
if not path.is_file():
return {"error": "File not found"}
if not self._check_path_allowed(path):
@@ -762,6 +784,8 @@ class GalleryService:
embedded = self._read_mp4_metadata(path)
elif ext in AUDIO_EXTENSIONS:
embedded = self._read_audio_metadata(path)
elif ext in GLTF_EXTENSIONS:
embedded = self._read_gltf_metadata(path)
dims = self._read_media_dimensions(path, ext)
saved = self.metadata_store.get(str(path))
@@ -935,6 +959,37 @@ class GalleryService:
logger.debug("Audio metadata read error: %s", e)
return result
def _read_gltf_metadata(self, path: Path) -> dict:
"""glTF/GLB/VRMのasset.extrasを読む。ComfyUIのSaveGLBはここにprompt/workflowを
JSON文字列で書き込む。GLBは先頭のJSONチャンクだけ読み、メッシュ本体は読まない。"""
try:
with open(path, "rb") as f:
if path.suffix.lower() == ".gltf":
if path.stat().st_size > _GLTF_JSON_MAX:
return {}
doc = json.loads(f.read())
else:
head = f.read(20)
if len(head) < 20 or head[:4] != b"glTF":
return {}
length, chunk_type = struct.unpack("<II", head[12:20])
if chunk_type != 0x4E4F534A or length > _GLTF_JSON_MAX: # "JSON"
return {}
doc = json.loads(f.read(length))
extras = doc.get("asset", {}).get("extras")
except (OSError, ValueError, AttributeError) as e:
logger.debug("glTF metadata read error: %s", e)
return {}
if not isinstance(extras, dict):
return {}
result = {}
for k, v in extras.items():
if isinstance(v, str):
result[k] = v
elif k in ("prompt", "workflow") and isinstance(v, dict):
result[k] = json.dumps(v)
return result
def _read_media_dimensions(self, path: Path, ext: str) -> dict:
"""画像は幅高さ、動画は幅高さ+再生時間(秒)を返す。取得できない項目はNone。"""
info: dict = {"width": None, "height": None, "duration": None}
@@ -957,7 +1012,7 @@ class GalleryService:
from psd_tools import PSDImage
psd = PSDImage.open(path)
info["width"], info["height"] = psd.width, psd.height
elif ext != ".svg":
elif ext != ".svg" and ext not in MODEL3D_EXTENSIONS:
from PIL import Image
with Image.open(path) as img:
info["width"], info["height"] = img.size
@@ -975,7 +1030,7 @@ class GalleryService:
extractPromptsLiteGraphがトップレベル系統しか拾えないことがあるため、
プロンプト抽出専用にAPI形式を優先する(Metadataタブのプロンプト抽出と同じ優先順位)。
"""
path = Path(image_path).resolve()
path = self._resolve_untrusted(image_path)
if not self._check_path_allowed(path):
return None
@@ -989,6 +1044,8 @@ class GalleryService:
embedded = self._read_mp4_metadata(path)
elif ext in AUDIO_EXTENSIONS:
embedded = self._read_audio_metadata(path)
elif ext in GLTF_EXTENSIONS:
embedded = self._read_gltf_metadata(path)
if embedded:
key_groups = (("workflow", "Workflow"), ("prompt", "Prompt"))
@@ -1034,7 +1091,7 @@ class GalleryService:
"""
from .convert_service import OUTPUT_FORMATS, convert_audio, supports_tags
p = Path(image_path).resolve()
p = self._resolve_untrusted(image_path)
if not p.is_file():
return {"ok": False, "error": "File not found"}
if p.suffix.lower() not in AUDIO_EXTENSIONS | VIDEO_EXTENSIONS:
@@ -1103,7 +1160,7 @@ class GalleryService:
}
def save_image_meta(self, image_path: str, data: dict) -> bool:
resolved = Path(image_path).resolve()
resolved = self._resolve_untrusted(image_path)
if not self._check_path_allowed(resolved):
logger.warning("save_image_meta: path not allowed: %s", resolved)
return False
@@ -1113,7 +1170,7 @@ class GalleryService:
return self.metadata_store.save(str(resolved), data)
def toggle_favorite(self, image_path: str) -> bool:
resolved = Path(image_path).resolve()
resolved = self._resolve_untrusted(image_path)
if not self._check_path_allowed(resolved):
return False
# get_image_metadata()/list_images() 側はresolve()済みパスをキーにして取得する
@@ -1129,7 +1186,11 @@ class GalleryService:
"""複数画像のお気に入りを一括設定する"""
ok = fail = 0
for p in paths:
resolved = Path(p).resolve()
try:
resolved = self._resolve_untrusted(p)
except ValueError:
fail += 1
continue
if not self._check_path_allowed(resolved):
fail += 1
continue
@@ -1167,7 +1228,7 @@ class GalleryService:
return self.metadata_store.delete_group(name)
def add_to_group(self, image_path: str, group_name: str) -> bool:
resolved = Path(image_path).resolve()
resolved = self._resolve_untrusted(image_path)
if not self._check_path_allowed(resolved):
return False
# get_image_metadata()/list_images() 側はresolve()済みパスをキーにして取得する
@@ -1182,7 +1243,7 @@ class GalleryService:
return True
def remove_from_group(self, image_path: str, group_name: str) -> bool:
resolved = Path(image_path).resolve()
resolved = self._resolve_untrusted(image_path)
if not self._check_path_allowed(resolved):
return False
resolved_str = str(resolved)
@@ -1211,7 +1272,7 @@ class GalleryService:
def create_folder(self, parent_path: str, name: str) -> dict:
"""選択フォルダ内に新しいサブフォルダを作成する"""
parent = Path(parent_path).resolve()
parent = self._resolve_untrusted(parent_path)
if not parent.is_dir():
return {"ok": False, "error": "Parent directory not found"}
if not self._check_path_allowed(parent):
@@ -1233,7 +1294,7 @@ class GalleryService:
def delete_folder(self, folder_path: str) -> dict:
"""フォルダを再帰的に削除する"""
import shutil
folder = Path(folder_path).resolve()
folder = self._resolve_untrusted(folder_path)
if not folder.is_dir():
return {"ok": False, "error": "Directory not found"}
if not self._check_path_allowed(folder):
@@ -1253,7 +1314,11 @@ class GalleryService:
deleted = []
errors = []
for img_path in paths:
p = Path(img_path).resolve()
try:
p = self._resolve_untrusted(img_path)
except ValueError:
errors.append(f"{Path(img_path).name}: access denied")
continue
if not p.is_file():
errors.append(f"{Path(img_path).name}: not found")
continue
@@ -1274,7 +1339,7 @@ class GalleryService:
def move_images(self, paths: list, dest_folder: str) -> dict:
"""画像ファイルを別フォルダへ移動する(複数対応)"""
dest = Path(dest_folder).resolve()
dest = self._resolve_untrusted(dest_folder)
if not dest.is_dir():
return {"ok": False, "error": "Destination folder not found", "moved": [], "errors": []}
if not self._check_path_allowed(dest):
@@ -1282,7 +1347,11 @@ class GalleryService:
moved = []
errors = []
for img_path in paths:
p = Path(img_path).resolve()
try:
p = self._resolve_untrusted(img_path)
except ValueError:
errors.append(f"{Path(img_path).name}: access denied")
continue
if not p.is_file():
errors.append(f"{Path(img_path).name}: not found")
continue
@@ -1326,11 +1395,14 @@ class GalleryService:
layers_data = []
for img_path in paths:
p = Path(img_path).resolve()
try:
p = self._resolve_untrusted(img_path)
except ValueError:
continue
if not p.is_file() or p.suffix.lower() not in IMAGE_EXTENSIONS:
continue
if p.suffix.lower() in VIDEO_EXTENSIONS | AUDIO_EXTENSIONS:
continue # 動画・音声はPSDレイヤーにできない
if p.suffix.lower() in VIDEO_EXTENSIONS | AUDIO_EXTENSIONS | MODEL3D_EXTENSIONS:
continue # 動画・音声・3DはPSDレイヤーにできない
if not self._check_path_allowed(p):
continue
try:
@@ -1494,7 +1566,7 @@ class GalleryService:
"""サーバー上に既にあるPSDファイル(Gallery上のパス)をレイヤー配列に分解する。
Galleryから直接Image Editへ送る際、アップロードの往復無しで済ませるために使う。
"""
p = Path(image_path).resolve()
p = self._resolve_untrusted(image_path)
if not p.is_file() or p.suffix.lower() != ".psd":
raise ValueError("Not a PSD file")
if not self._check_path_allowed(p):
@@ -1518,7 +1590,7 @@ class GalleryService:
def serve_image(self, image_path: str):
"""画像のPathオブジェクトを返す(ルートで使用)。
PSDはブラウザが直接レンダリングできないため、合成済みPNGにキャッシュ変換して返す。"""
p = Path(image_path).resolve()
p = self._resolve_untrusted(image_path)
if not p.is_file():
return None
if p.suffix.lower() not in IMAGE_EXTENSIONS:
@@ -1530,6 +1602,58 @@ class GalleryService:
return self._get_psd_composite_cache(p)
return p
def serve_model3d_asset(self, model_path: str, uri: str) -> Path | None:
""".gltfが相対URIで参照する外部ファイル(.bin/テクスチャ)のPathを返す。
uriはglTF仕様どおりパーセントエンコードされている。"""
try:
p = self._resolve_untrusted(model_path)
if p.suffix.lower() != ".gltf" or not p.is_file() or not self._check_path_allowed(p):
return None
# .gltf の外部参照 URI は相対パスのみ(UNC・絶対パス・「..」は結合前に拒否)
rel_uri = unquote(uri)
if not is_safe_rel(rel_uri):
return None
target = (p.parent / rel_uri).resolve()
if target.suffix.lower() not in MODEL3D_ASSET_EXTENSIONS or not target.is_file():
return None
except (OSError, ValueError):
return None
if not self._check_path_allowed(target):
logger.warning("serve_model3d_asset: path not allowed: %s", target)
return None
return target
def _model3d_thumb_path(self, p: Path) -> Path:
"""ブラウザが描画した3Dサムネイル(各サイズの元画像)の保存先。"""
mtime = int(p.stat().st_mtime * 1000)
cache_dir = self.data_dir / "thumb_cache"
cache_dir.mkdir(exist_ok=True)
return cache_dir / f"{hashlib.md5(f'{p}:{mtime}:model3d'.encode()).hexdigest()}_m3d.jpg"
def save_model3d_thumbnail(self, model_path: str, image_data: str) -> dict:
"""ブラウザが描画した3Dモデルのサムネイルを保存する。"""
from io import BytesIO
from PIL import Image
p = self._resolve_untrusted(model_path)
if not p.is_file() or p.suffix.lower() not in MODEL3D_EXTENSIONS:
return {"ok": False, "error": "Not a 3D model"}
if not self._check_path_allowed(p):
return {"ok": False, "error": "Access denied"}
try:
raw, _ = _decode_image_data_url(image_data)
if len(raw) > _MODEL3D_THUMB_MAX_BYTES:
return {"ok": False, "error": "Image too large"}
with Image.open(BytesIO(raw)) as im:
if max(im.size) > _MODEL3D_THUMB_MAX_SIDE:
return {"ok": False, "error": "Image too large"}
im = im.convert("RGB")
im.thumbnail((_MODEL3D_THUMB_SIZE, _MODEL3D_THUMB_SIZE), Image.LANCZOS)
im.save(self._model3d_thumb_path(p), "JPEG", quality=85, optimize=True)
except (OSError, ValueError) as e:
return {"ok": False, "error": str(e)}
return {"ok": True}
def _get_psd_composite_cache(self, p: Path) -> Path | None:
"""PSDの全レイヤー合成結果をフル解像度PNGとしてディスクキャッシュし、そのPathを返す。"""
try:
@@ -1605,7 +1729,7 @@ class GalleryService:
(元ファイルへのフォールバックはできないため、失敗時はNoneを返す)。
PSDはpsd_toolsでレイヤーを合成してからJPEGとしてキャッシュする(同様にフォールバック不可)。
"""
p = Path(image_path).resolve()
p = self._resolve_untrusted(image_path)
if not p.is_file():
return None
if p.suffix.lower() not in IMAGE_EXTENSIONS:
@@ -1638,6 +1762,22 @@ class GalleryService:
if thumb_path.exists():
return thumb_path
# 3Dはブラウザが描画して保存したものを縮小して返す。未保存ならNone(404)を返し、
# それを合図にブラウザ側が描画する。
if p.suffix.lower() in MODEL3D_EXTENSIONS:
source = self._model3d_thumb_path(p)
if not source.exists():
return None
try:
from PIL import Image
with Image.open(source) as img:
img.thumbnail((width, width), Image.LANCZOS)
img.save(thumb_path, "JPEG", quality=85, optimize=True)
return thumb_path
except Exception as e:
logger.warning("serve_thumbnail: 3D thumbnail failed for %s: %s", p, e)
return None
# 音声はPillowで開けない。PyAVでデコードして波形をJPEGに描画しキャッシュする。
if p.suffix.lower() in AUDIO_EXTENSIONS:
try:
+8 -2
View File
@@ -219,7 +219,10 @@ class SemanticService:
# ── 状態 ───────────────────────────────────────────────
def _scope_entries(self, folder: str, recursive: bool) -> list[tuple[str, str, int, float]]:
p = Path(folder).resolve()
try:
p = self.gallery._resolve_untrusted(folder) # UNC等は resolve() 前に文字列で拒否
except ValueError:
raise SemanticError("folder_not_allowed", str(folder))
if not p.is_dir() or not self.gallery._check_path_allowed(p):
raise SemanticError("folder_not_allowed", str(folder))
raw = self.gallery._scan_folder_recursive(p) if recursive else self.gallery._scan_folder(p)
@@ -539,7 +542,10 @@ class SemanticService:
def search_similar(self, path: str, folder: str, recursive: bool, limit: int, min_score: float = 0.0) -> list[dict]:
self._ensure_loaded()
p = Path(path).resolve()
try:
p = self.gallery._resolve_untrusted(path) # UNC等は resolve() 前に文字列で拒否
except ValueError:
raise SemanticError("folder_not_allowed", path)
if not p.is_file() or not self.gallery._check_path_allowed(p):
raise SemanticError("folder_not_allowed", path)
ap = p.as_posix()
+434 -160
View File
@@ -1,192 +1,347 @@
"""AI skill (.md system prompt) file management service."""
"""AI skill (.md system prompt) file management service.
Skills are flat ``*.md`` files with a YAML frontmatter block::
---
name: Display name
description: One sentence
metadata: # optional, Workflow Studio extensions
wfs-version: 2 # built-in skills only (upgrade tracking)
output: prompt # prompt | svg -> auto-check + action buttons
tools: [] # [] or [generate_image]
temperature: 0.4
think: false
context: [workflow]
---
``name``/``description`` follow the Agent Skills (SKILL.md) convention so skills
stay portable; everything Workflow-Studio-specific lives under ``metadata``.
Built-in skills ship in ``builtin_skills/`` next to this file and are copied
into the user's skill folder. A small state file records which version and
content hash were installed, so an untouched built-in is upgraded silently
while a user-edited one is left alone (and flagged ``update_available``).
"""
import hashlib
import io
import json
import logging
import re
from pathlib import Path
import shutil
import zipfile
from pathlib import Path, PurePosixPath
try:
import yaml # PyYAML ships with ComfyUI
except Exception: # pragma: no cover - fallback parser below
yaml = None
logger = logging.getLogger(__name__)
ALLOWED_EXTS = {"md"}
DEFAULT_SKILL_FILENAME = "svg-icon.md"
# Folder skills (Agent Skills / SKILL.md standard): <skills_dir>/<folder>/SKILL.md plus optional
# reference files. Only text resources are kept and served - Workflow Studio never runs a
# skill's scripts, so script files are skipped on import.
SKILL_MD = "SKILL.md"
RESOURCE_EXTS = {"md", "txt", "json", "yaml", "yml", "csv"}
MAX_RESOURCES = 50
MAX_RESOURCE_BYTES = 200 * 1024 # per file served to the chat model
MAX_IMPORT_FILE_BYTES = 1024 * 1024 # per file inside an imported zip
MAX_IMPORT_TOTAL_BYTES = 5 * 1024 * 1024
MAX_IMPORT_ENTRIES = 300
_FOLDER_RE = re.compile(r"^[A-Za-z0-9][\w.\- ]{0,63}$")
DEFAULT_SKILL_CONTENT = """---
name: SVG Icon Generator
description: Produces clean, minimal, valid SVG icons and simple illustrations.
---
BUILTIN_DIR = Path(__file__).parent / "builtin_skills"
STATE_FILENAME = ".builtin_state.json"
You are an expert SVG icon and illustration designer. When the user asks for an icon, logo, pictogram, diagram, character, animal, or any vector graphic, respond with valid, clean SVG markup.
## Composition process (do this before writing markup - skipping this step is the main cause of unrecognizable output)
- Break the subject down into 3-8 distinct parts that make it recognizable (e.g. a bird: body, head, beak, eye, wing, tail; a house: wall, roof, door, window). Drop parts that are not essential.
- Decide each part's approximate position, size, and draw order within the viewBox (elements listed later in the markup are drawn on top).
- Pick the simplest shape that captures each part's silhouette: `<circle>`/`<ellipse>` for round parts, `<rect>` for rectangular parts, `<polygon>` for angular parts (beaks, ears, leaves, roofs). For a rounded organic outline that no primitive can approximate well (a body silhouette, a wing, a leaf edge), use a short `<path>` with 2-4 smooth curve commands (`Q` or `C`) instead of a plain circle - a few deliberate curve points beat a distorted primitive.
- Never fall back to drawing an unrelated blob plus a few disconnected decorative lines when a subject is hard to render - always decompose it into the named parts above instead, even if each part is crude.
## Output rules
- Always wrap the SVG markup in a fenced code block labeled `svg`, e.g. ```svg ... ```.
- Keep any explanation brief and place it OUTSIDE the code block, never mixed inside the SVG.
- Output exactly one `<svg>...</svg>` element per code block.
## Structure rules
- Always include a `viewBox` attribute (e.g. `viewBox="0 0 24 24"`). Do not hardcode large pixel `width`/`height`; if you set them, make them match the viewBox aspect ratio.
- Use a small, round coordinate system (0-24 or 0-100).
- Round coordinate values to at most 2 decimal places.
- Keep every `<path>` short (at most about 6 commands) - long, intricate paths are where quality breaks down most often.
- Group related elements with `<g>` when it clarifies structure, but do not over-nest.
## Color rules
- For single-color icons, use `fill="currentColor"` (or `stroke="currentColor"` for line icons) so the icon inherits the surrounding text color.
- For multi-color illustrations, use explicit hex colors (e.g. `#4A90D9`) - never named CSS colors like `"blue"`.
- Avoid gradients, filters, and blend modes unless the user explicitly asks for a glossy/gradient style - they rarely render correctly from generated coordinates.
## Accessibility
- Include a `<title>` element as the first child of `<svg>` describing what the icon depicts.
## Security (mandatory - do not violate)
- Never include `<script>`, `<foreignObject>`, event handler attributes (`onload`, `onclick`, etc.), or `<a>`/`href` links to external URLs.
- Never reference external resources (no `xlink:href` to remote URLs, no `<image>` with external `src`).
## Example 1 - simple geometric icon (single color, primitives only)
Request: "Sun icon"
Parts: disc (circle), 8 rays (lines).
```svg
<svg viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg">
<title>Sun</title>
<circle cx="12" cy="12" r="5" fill="currentColor"/>
<g stroke="currentColor" stroke-width="2" stroke-linecap="round">
<line x1="12" y1="1" x2="12" y2="4"/>
<line x1="12" y1="20" x2="12" y2="23"/>
<line x1="4.22" y1="4.22" x2="6.34" y2="6.34"/>
<line x1="17.66" y1="17.66" x2="19.78" y2="19.78"/>
<line x1="1" y1="12" x2="4" y2="12"/>
<line x1="20" y1="12" x2="23" y2="12"/>
<line x1="4.22" y1="19.78" x2="6.34" y2="17.66"/>
<line x1="17.66" y1="6.34" x2="19.78" y2="4.22"/>
</g>
</svg>
```
## Example 2 - organic subject (multi-color, decomposed into parts)
Request: "Bird icon"
Parts: body (rounded outline via a short curved path), head (circle), beak (small triangle), eye (dot), wing (small curved path) - each drawn as its own element, layered head/beak/eye on top of the body.
```svg
<svg viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg">
<title>Bird</title>
<path d="M4 16 Q4 10 11 9 Q18 8 20 13 Q20 17 14 18 Q7 19 4 16 Z" fill="#4A90D9"/>
<path d="M8 14 Q5 12 3 14 Q6 16 9 16 Z" fill="#3576B8"/>
<circle cx="17" cy="10" r="3.2" fill="#4A90D9"/>
<polygon points="20,10 23,9.3 20,11.4" fill="#F2B807"/>
<circle cx="18" cy="9" r="0.6" fill="#1A1A1A"/>
</svg>
```
Follow this pattern for every request: list the parts first, represent each with the simplest adequate shape, then assemble - never skip straight to unstructured shapes.
"""
SKILL_CREATOR_FILENAME = "skill-creator.md"
SKILL_CREATOR_CONTENT = """---
name: Skill Creator
description: Interactively interviews you and drafts a new WFS chat skill (.md system prompt) ready to save.
---
You are a skill-design assistant embedded in ComfyUI Workflow Studio's AI TOOL Chat pane. Your job is to interactively help the user design a NEW "skill" - a markdown file with frontmatter (`name`, `description`) followed by system-prompt instructions. Once saved, a skill can be selected from a dropdown and is silently prepended to future chat messages as a system prompt.
## How to conduct the interview
- Ask ONE focused question at a time, never a bulleted list of questions. Wait for the user's answer before asking the next one.
- Cover, in this order, only what is not already clear from context:
1. What task or domain should the skill specialize in (what should the model do differently once this skill is active)?
2. What output format is expected - plain prose, a specific fenced code block language, a fixed structure, a length limit?
3. Any hard constraints or things to avoid (tone, forbidden content, security concerns, things past attempts got wrong)?
4. Would a short worked example help smaller/local models follow the pattern more reliably? If yes, ask what a good example input/output looks like, or offer to draft one.
- Keep it short - 3 to 5 questions is usually enough. If the user says "just generate it", "that's enough", or similar at any point, stop asking and produce the best skill you can from what you already have.
## Output format for the finished skill
- Once you have enough information, output the complete skill file in a single fenced code block labeled `skill` (```skill ... ```). Never mix prose inside that block - explanation goes outside it.
- The block must start with frontmatter exactly in this shape:
---
name: <short display name, shown in the skill dropdown>
description: <one sentence, shown as a tooltip in the dropdown>
---
- After the frontmatter, write clear, imperative system-prompt instructions for the target skill: what role the model should take, concrete output-format rules, hard constraints, and - if useful - one short worked example following a "request -> ideal output" shape.
- After the code block, tell the user in one line that they can click the "Save as new skill" button below the message to add it, or copy the block manually into a new skill.
"""
# Content hashes of built-in skills released before version tracking existed
# (v0.3.79 - v0.9.4). A user file matching one of these is an untouched copy
# and can be upgraded safely.
LEGACY_BUILTIN_HASHES = {
"svg-icon.md": {"f46b635abda182b26df38d4e49ec2a626642fcd98c94013cb67303c69aaf10c1"},
"skill-creator.md": {"2fb31273298b828c6f18c7fd010be44d31588f881d04757e5c0f5f18bbad2313"},
}
_FRONTMATTER_RE = re.compile(r"^---\r?\n(.*?)\r?\n---\r?\n?", re.DOTALL)
def _parse_frontmatter(content: str) -> dict:
"""Extract a shallow `key: value` frontmatter block, if present."""
m = _FRONTMATTER_RE.match(content)
if not m:
return {}
def _content_hash(content: str) -> str:
return hashlib.sha256(content.replace("\r\n", "\n").strip().encode("utf-8")).hexdigest()
def _parse_frontmatter_shallow(block: str) -> dict:
"""Fallback parser: top-level ``key: value`` plus one nested ``metadata:`` level."""
fields: dict = {}
for line in m.group(1).splitlines():
if ":" not in line:
current_map: dict | None = None
for line in block.splitlines():
if not line.strip() or ":" not in line:
continue
key, _, value = line.partition(":")
key = key.strip()
value = value.strip()
if key:
fields[key] = value
indented = line[:1] in (" ", "\t")
key, _, value = line.strip().partition(":")
key, value = key.strip(), value.strip()
if not key:
continue
if indented and current_map is not None:
current_map[key] = _coerce_scalar(value)
elif not indented:
if value == "":
current_map = {}
fields[key] = current_map
else:
current_map = None
fields[key] = value
return fields
class SkillService:
def __init__(self, skills_dir: Path):
self.skills_dir = skills_dir
self.skills_dir.mkdir(parents=True, exist_ok=True)
self._seed_default_skill()
def _coerce_scalar(value: str):
if value.startswith("[") and value.endswith("]"):
inner = value[1:-1].strip()
return [v.strip().strip("'\"") for v in inner.split(",") if v.strip()] if inner else []
low = value.lower()
if low in ("true", "false"):
return low == "true"
try:
return float(value) if "." in value else int(value)
except ValueError:
return value.strip("'\"")
def _seed_default_skill(self) -> None:
"""Seed a starter skill file the first time the directory is empty."""
def _parse_frontmatter(content: str) -> dict:
"""Extract the frontmatter block as a dict (empty dict if absent/invalid)."""
m = _FRONTMATTER_RE.match(content or "")
if not m:
return {}
block = m.group(1)
if yaml is not None:
try:
has_any = any(
p.is_file() and p.suffix.lstrip(".").lower() in ALLOWED_EXTS
for p in self.skills_dir.iterdir()
)
except FileNotFoundError:
has_any = False
if not has_any:
(self.skills_dir / DEFAULT_SKILL_FILENAME).write_text(
DEFAULT_SKILL_CONTENT, encoding="utf-8"
)
(self.skills_dir / SKILL_CREATOR_FILENAME).write_text(
SKILL_CREATOR_CONTENT, encoding="utf-8"
)
data = yaml.safe_load(block)
if isinstance(data, dict):
return data
except Exception:
pass # e.g. an unquoted ": " inside description -> shallow parse
return _parse_frontmatter_shallow(block)
def _json_safe(value):
"""Keep only JSON-serialisable metadata values (YAML can yield dates etc.)."""
if isinstance(value, dict):
return {str(k): _json_safe(v) for k, v in value.items()}
if isinstance(value, (list, tuple)):
return [_json_safe(v) for v in value]
if isinstance(value, (str, int, float, bool)) or value is None:
return value
return str(value)
def _skill_info(filename: str, content: str, size: int) -> dict:
meta = _parse_frontmatter(content)
extra = meta.get("metadata") if isinstance(meta.get("metadata"), dict) else {}
return {
"filename": filename,
"name": str(meta.get("name") or Path(filename).stem),
"description": str(meta.get("description") or ""),
"metadata": _json_safe(extra),
"size": size,
}
def _builtin_version(content: str) -> int:
meta = _parse_frontmatter(content).get("metadata") or {}
try:
return int(meta.get("wfs-version", 1))
except (TypeError, ValueError):
return 1
class SkillService:
def __init__(self, skills_dir: Path, builtin_dir: Path = BUILTIN_DIR):
self.skills_dir = skills_dir
self.builtin_dir = builtin_dir
self.skills_dir.mkdir(parents=True, exist_ok=True)
try:
self.sync_builtin_skills()
except Exception as e: # never block startup on a seeding problem
logger.warning("[WFS] Built-in skill sync failed: %s", e)
# ------------------------------------------------------------------
# Built-in skills
# ------------------------------------------------------------------
def _builtins(self) -> dict[str, str]:
if not self.builtin_dir.is_dir():
return {}
return {
p.name: p.read_text(encoding="utf-8")
for p in sorted(self.builtin_dir.glob("*.md"))
if p.is_file()
}
def _load_state(self) -> dict:
path = self.skills_dir / STATE_FILENAME
try:
data = json.loads(path.read_text(encoding="utf-8"))
return data if isinstance(data, dict) else {}
except Exception:
return {}
def _save_state(self, state: dict) -> None:
(self.skills_dir / STATE_FILENAME).write_text(
json.dumps(state, indent=2, ensure_ascii=False), encoding="utf-8"
)
def _install_builtin(self, filename: str, content: str, state: dict) -> None:
(self.skills_dir / filename).write_text(content, encoding="utf-8")
state[filename] = {"version": _builtin_version(content), "hash": _content_hash(content)}
def sync_builtin_skills(self) -> dict:
"""Install new built-ins and upgrade untouched ones.
Rules per built-in file:
- missing and never installed -> install
- missing but installed before -> the user deleted it, leave it deleted
- present, untouched (hash matches what we installed, or a known
pre-tracking release) and older -> overwrite with the new version
- present but edited by the user -> keep it (reported as update_available)
Returns ``{"installed": [...], "upgraded": [...]}``.
"""
state = self._load_state()
result = {"installed": [], "upgraded": []}
changed = False
for filename, content in self._builtins().items():
new_version = _builtin_version(content)
path = self.skills_dir / filename
entry = state.get(filename)
if not path.is_file():
if entry is None:
self._install_builtin(filename, content, state)
result["installed"].append(filename)
changed = True
continue
current_hash = _content_hash(path.read_text(encoding="utf-8"))
if entry is None:
if current_hash in LEGACY_BUILTIN_HASHES.get(filename, set()):
self._install_builtin(filename, content, state)
result["upgraded"].append(filename)
elif current_hash == _content_hash(content):
state[filename] = {"version": new_version, "hash": current_hash}
else:
# A user file with a built-in's name - never overwrite it.
state[filename] = {"version": 0, "hash": None}
changed = True
continue
if int(entry.get("version") or 0) < new_version and current_hash == entry.get("hash"):
self._install_builtin(filename, content, state)
result["upgraded"].append(filename)
changed = True
if changed:
self._save_state(state)
if result["installed"] or result["upgraded"]:
logger.info("[WFS] Built-in skills installed=%s upgraded=%s", result["installed"], result["upgraded"])
return result
def restore_builtin(self, filename: str) -> dict:
"""Overwrite a skill file with the shipped built-in version (explicit user action)."""
builtins = self._builtins()
if filename not in builtins:
raise ValueError(f"Not a built-in skill: {filename}")
state = self._load_state()
self._install_builtin(filename, builtins[filename], state)
self._save_state(state)
path = self.skills_dir / filename
return _skill_info(filename, builtins[filename], path.stat().st_size)
# ------------------------------------------------------------------
# File CRUD
# ------------------------------------------------------------------
def list_skills(self) -> list[dict]:
"""Return sorted list of skill files with parsed frontmatter metadata."""
"""Return sorted list of flat skill files and folder skills with parsed metadata."""
if not self.skills_dir.exists():
return []
builtins = self._builtins()
state = self._load_state()
files = []
for path in sorted(self.skills_dir.glob("*")):
if path.is_dir():
info = self._folder_skill_info(path)
if info:
files.append(info)
continue
if not (path.is_file() and path.suffix.lstrip(".").lower() in ALLOWED_EXTS):
continue
try:
content = path.read_text(encoding="utf-8")
except Exception:
content = ""
meta = _parse_frontmatter(content)
files.append({
"filename": path.name,
"name": meta.get("name") or path.stem,
"description": meta.get("description", ""),
"size": path.stat().st_size,
})
info = _skill_info(path.name, content, path.stat().st_size)
builtin_content = builtins.get(path.name)
info["builtin"] = builtin_content is not None
info["update_available"] = False
if builtin_content is not None:
current_hash = _content_hash(content)
if current_hash != _content_hash(builtin_content):
entry = state.get(path.name) or {}
installed_version = int(entry.get("version") or 0)
info["update_available"] = installed_version < _builtin_version(builtin_content)
info["modified"] = True
files.append(info)
return files
def _folder_skill_info(self, folder: Path) -> dict | None:
if folder.name.startswith(".") or not _FOLDER_RE.match(folder.name):
return None
skill_md = folder / SKILL_MD
if not skill_md.is_file():
return None
try:
content = skill_md.read_text(encoding="utf-8")
except Exception:
content = ""
info = _skill_info(f"{folder.name}/{SKILL_MD}", content, skill_md.stat().st_size)
if info["name"] == SKILL_MD.rsplit(".", 1)[0]:
info["name"] = folder.name
info["folder"] = folder.name
info["resources"] = self.list_resources(folder.name)
info["builtin"] = False
info["update_available"] = False
return info
def list_resources(self, folder: str) -> list[str]:
"""Readable reference files of a folder skill (relative POSIX paths, SKILL.md excluded)."""
base = self._folder_path(folder)
if base is None or not base.is_dir():
return []
out = []
for path in sorted(base.rglob("*")):
if len(out) >= MAX_RESOURCES:
break
if not path.is_file() or path.is_symlink():
continue
rel = path.relative_to(base).as_posix()
if rel == SKILL_MD or any(part.startswith(".") for part in rel.split("/")):
continue
if path.suffix.lstrip(".").lower() in RESOURCE_EXTS:
out.append(rel)
return out
def get_resource(self, folder: str, rel_path: str) -> str:
"""Read one reference file of a folder skill (used by the chat's read_skill_file tool)."""
base = self._folder_path(folder)
if base is None or not base.is_dir():
raise FileNotFoundError(f"Skill folder not found: {folder}")
rel = PurePosixPath(str(rel_path or "").replace("\\", "/"))
if rel.is_absolute() or ".." in rel.parts or not rel.parts or rel.as_posix() == SKILL_MD:
raise ValueError(f"Invalid resource path: {rel_path}")
if rel.suffix.lstrip(".").lower() not in RESOURCE_EXTS:
raise ValueError(f"Unsupported resource type: {rel_path}")
path = (base / rel).resolve()
if base.resolve() not in path.parents or not path.is_file():
raise FileNotFoundError(f"Resource not found: {rel_path}")
data = path.read_bytes()[:MAX_RESOURCE_BYTES]
return data.decode("utf-8", errors="replace")
def get_content(self, filename: str) -> str:
path = self._safe_path(filename)
if path is None:
@@ -199,30 +354,149 @@ class SkillService:
path = self._safe_path(filename)
if path is None:
raise ValueError(f"Invalid filename: {filename}")
if path.name == SKILL_MD and not path.parent.is_dir():
raise FileNotFoundError(f"Skill folder not found: {filename}")
path.write_text(content, encoding="utf-8")
meta = _parse_frontmatter(content)
return {
"filename": path.name,
"name": meta.get("name") or path.stem,
"description": meta.get("description", ""),
"size": path.stat().st_size,
}
rel = path.relative_to(self.skills_dir).as_posix()
return _skill_info(rel, content, path.stat().st_size)
def delete_file(self, filename: str) -> None:
path = self._safe_path(filename)
if path is None:
raise ValueError(f"Invalid filename: {filename}")
if path.name == SKILL_MD and path.parent != self.skills_dir:
# A folder skill is deleted as a whole (SKILL.md + its reference files).
if path.parent.is_dir():
shutil.rmtree(path.parent)
return
if path.is_file():
path.unlink()
# ------------------------------------------------------------------
# Import (Agent Skills zip or a single .md)
# ------------------------------------------------------------------
def import_skill(self, upload_name: str, data: bytes) -> dict:
"""Import an uploaded skill.
- ``*.md``: saved as a flat skill (``<slug>.md``; SKILL.md uploads are named after their
frontmatter name).
- ``*.zip``: an Agent Skills folder - SKILL.md at the zip root or inside exactly one top
folder. Only text resources are extracted; scripts and binaries are skipped.
Returns ``{"skill": info, "skipped": [paths]}``. Never overwrites: a numeric suffix is
added when the name is taken.
"""
name = (upload_name or "").strip()
lower = name.lower()
if lower.endswith(".md"):
text = data.decode("utf-8", errors="replace")
meta = _parse_frontmatter(text)
stem = Path(name).stem if Path(name).name != SKILL_MD else str(meta.get("name") or "imported-skill")
filename = self._unique_name(_slugify(stem), ".md")
(self.skills_dir / filename).write_text(text, encoding="utf-8")
return {"skill": _skill_info(filename, text, len(data)), "skipped": []}
if not lower.endswith(".zip"):
raise ValueError("Only .zip (Agent Skills folder) or .md files can be imported")
return self._import_zip(data)
def _import_zip(self, data: bytes) -> dict:
try:
zf = zipfile.ZipFile(io.BytesIO(data))
except zipfile.BadZipFile as e:
raise ValueError(f"Not a valid zip file: {e}") from e
infos = [i for i in zf.infolist() if not i.is_dir()]
if len(infos) > MAX_IMPORT_ENTRIES:
raise ValueError(f"Too many files in the zip ({len(infos)} > {MAX_IMPORT_ENTRIES})")
def parts_of(info):
p = PurePosixPath(info.filename.replace("\\", "/"))
if p.is_absolute() or ".." in p.parts or any(":" in part for part in p.parts):
raise ValueError(f"Unsafe path in zip: {info.filename}")
return p.parts
all_parts = [(i, parts_of(i)) for i in infos]
# Ignore OS junk (__MACOSX/, .DS_Store) when locating SKILL.md.
all_parts = [(i, ps) for i, ps in all_parts if ps and ps[0] != "__MACOSX" and not ps[-1].startswith(".")]
skill_md_parts = [ps for _, ps in all_parts if ps[-1] == SKILL_MD and len(ps) <= 2]
if len(skill_md_parts) != 1:
raise ValueError("The zip must contain exactly one SKILL.md at its root or in one top-level folder")
prefix = skill_md_parts[0][:-1] # () or (top_folder,)
skill_text = zf.read("/".join(skill_md_parts[0])).decode("utf-8", errors="replace")
meta = _parse_frontmatter(skill_text)
base_name = prefix[0] if prefix else str(meta.get("name") or "imported-skill")
folder = self._unique_name(_slugify(base_name), "")
target = self.skills_dir / folder
target.mkdir(parents=True)
written, skipped, total = 0, [], 0
try:
for info, ps in all_parts:
if tuple(ps[: len(prefix)]) != prefix:
skipped.append(info.filename)
continue
rel = PurePosixPath(*ps[len(prefix):])
is_skill_md = rel.as_posix() == SKILL_MD
ext = rel.suffix.lstrip(".").lower()
if not is_skill_md and ext not in RESOURCE_EXTS:
skipped.append(info.filename)
continue
if info.file_size > MAX_IMPORT_FILE_BYTES:
skipped.append(info.filename)
continue
total += info.file_size
if total > MAX_IMPORT_TOTAL_BYTES:
raise ValueError("The zip's text files exceed 5 MB in total")
content = zf.read(info)[:MAX_IMPORT_FILE_BYTES]
out = (target / rel).resolve()
if target.resolve() not in out.parents:
raise ValueError(f"Unsafe path in zip: {info.filename}")
out.parent.mkdir(parents=True, exist_ok=True)
out.write_bytes(content)
written += 1
except Exception:
shutil.rmtree(target, ignore_errors=True)
raise
logger.info("[WFS] Imported skill folder %s (%d files, %d skipped)", folder, written, len(skipped))
return {"skill": self._folder_skill_info(target), "skipped": skipped}
def _unique_name(self, stem: str, suffix: str) -> str:
candidate = f"{stem}{suffix}"
n = 2
while (self.skills_dir / candidate).exists():
candidate = f"{stem}-{n}{suffix}"
n += 1
return candidate
# ------------------------------------------------------------------
# Path safety
# ------------------------------------------------------------------
def _folder_path(self, folder: str) -> Path | None:
name = (folder or "").strip()
if not _FOLDER_RE.match(name) or name.startswith("."):
return None
return self.skills_dir / name
def _safe_path(self, filename: str) -> Path | None:
"""Flat ``name.md`` or a folder skill's ``<folder>/SKILL.md`` - nothing else."""
if not filename or not filename.strip():
return None
# Skills are a flat directory - reject any path separator (no subfolders).
name = filename.strip()
if "/" in name or "\\" in name or name in (".", ".."):
name = filename.strip().replace("\\", "/")
if "/" in name:
folder, _, leaf = name.partition("/")
if leaf != SKILL_MD:
return None
base = self._folder_path(folder)
return base / SKILL_MD if base is not None else None
if name in (".", "..") or name.startswith("."):
return None
ext = Path(name).suffix.lstrip(".").lower()
if ext not in ALLOWED_EXTS:
return None
return self.skills_dir / name
def _slugify(text: str) -> str:
slug = re.sub(r"[^A-Za-z0-9]+", "-", str(text)).strip("-").lower()[:48]
return slug or "imported-skill"
+8 -1
View File
@@ -12,6 +12,8 @@ import threading
import urllib.error
import urllib.request
from pathlib import Path
from ..config import resolve_untrusted
from typing import Optional
from .url_guard import HINT as _URL_HINT, is_allowed_backend_url, urlopen as _guarded_urlopen
@@ -456,7 +458,12 @@ class TaggerService:
_ALLOWED_WRITE_EXTS = {".jpg", ".jpeg", ".png", ".webp", ".bmp", ".gif"}
def write_meta_to_file(self, image_path: str, tags: str) -> dict:
path = Path(image_path).resolve()
try:
# UNC(\\host\share)は resolve() した時点で相手ホストへ資格情報付きで
# 接続してしまうため、文字列のまま先に拒否する
path = resolve_untrusted(image_path)
except ValueError:
return {"error": "Access denied"}
if path.suffix.lower() not in self._ALLOWED_WRITE_EXTS:
return {"error": "Unsupported file type"}
if not path.is_file():
+486
View File
@@ -0,0 +1,486 @@
"""Prompt translation service (native language -> English or another language) via Ollama.
PLaMo 3 Translate (pfnet/plamo-3-translate-*-GGUF) models are driven with a raw
PFML3 prompt on /api/generate, which is the route the model card recommends for
Ollama. Any other Ollama model is used through /api/chat with a short
"translate into <language>" system prompt, so a general LLM or another MT model
can be selected too.
Two entry points:
- translate_texts(): each string is translated as a whole.
- translate_prompt_texts(): prompt-aware. Only the pieces that contain non-ASCII
letters are sent to the model; prompt syntax such as commas, (weights:1.2),
[ ], {a|b}, <lora:...>, __wildcards__, embedding:name and BREAK/AND is kept,
and optionally the text inside 「」『』“”"" (text to be drawn in the image).
"""
import json
import re
import threading
import urllib.request
from collections import OrderedDict
from .settings_service import SettingsService
from .url_guard import require_backend_url, urlopen
DEFAULTS = {
"prompt_translate_enabled": False,
"prompt_translate_url": "http://localhost:11434",
"prompt_translate_model": "hf.co/pfnet/plamo-3-translate-2b-GGUF:Q4_K_M",
"prompt_translate_source_lang": "auto",
"prompt_translate_auto": False, # GenerateUI Generate
"prompt_translate_auto_lab": False, # GenerateUI Lab Run
"prompt_translate_auto_video": False, # Video Plan Run
"prompt_translate_unload": True,
# "gpu" (default) or "cpu". CPU mode keeps the model resident in system RAM:
# no VRAM use, so it never needs unloading and skips Ollama's ~4 s reload.
"prompt_translate_device": "gpu",
}
CPU_KEEP_ALIVE = -1 # stay loaded until Ollama restarts (about 2.7 GB RAM for 2B Q4_K_M)
# Version of the HTTP API offered to other front-ends (Comic Creator). Bump when the
# /api/wfm/translate/prompt contract changes; clients feature-detect with it.
API_VERSION = 1
# Suggested PLaMo 3 Translate builds (shown in Settings even before they are pulled).
PLAMO_PRESETS = [
"hf.co/pfnet/plamo-3-translate-0.8b-GGUF:Q4_K_M",
"hf.co/pfnet/plamo-3-translate-2b-GGUF:Q4_K_M",
"hf.co/pfnet/plamo-3-translate-8b-GGUF:Q4_K_M",
"hf.co/pfnet/plamo-3-translate-31b-GGUF:Q4_K_M",
]
_PLAMO_STOP = ["<|plamo:tag|>", "<|plamo:bos|>"]
_PLAMO_SPECIAL = re.compile(r"<\|plamo:[a-z_]+\|>")
_MAX_TEXTS = 200
# One model call gets at most this many characters; longer text is split at line
# breaks, then at sentence ends, and the translations are joined again.
_CHUNK_LEN = 1000
# Hard limit for one request (all texts together). Above it the request is rejected
# instead of being cut silently.
_MAX_TOTAL_LEN = 30000
# PLaMo 3 Translate languages (model card "Supported Languages"), code -> English name.
LANGUAGES = {
"en": "English", "ja": "Japanese", "zh-hans": "Simplified Chinese",
"zh-hant": "Traditional Chinese", "ko": "Korean", "ar": "Arabic", "az": "Azerbaijani",
"be": "Belarusian", "bg": "Bulgarian", "bn": "Bengali", "ca": "Catalan", "ceb": "Cebuano",
"de": "German", "es": "Spanish", "et": "Estonian", "eu": "Basque", "fa": "Persian",
"fr": "French", "gu": "Gujarati", "he": "Hebrew", "hi": "Hindi", "hr": "Croatian",
"hu": "Hungarian", "hy": "Armenian", "id": "Indonesian", "it": "Italian", "jv": "Javanese",
"ka": "Georgian", "kk": "Kazakh", "km": "Khmer", "lt": "Lithuanian", "lv": "Latvian",
"ml": "Malayalam", "mr": "Marathi", "ms": "Malay", "my": "Burmese", "ne": "Nepali",
"nl": "Dutch", "pa": "Punjabi", "pl": "Polish", "ru": "Russian", "si": "Sinhala",
"sk": "Slovak", "sl": "Slovenian", "sr": "Serbian", "sw": "Swahili", "ta": "Tamil",
"te": "Telugu", "th": "Thai", "tl": "Tagalog", "ur": "Urdu", "uz": "Uzbek", "vi": "Vietnamese",
}
_LANG_ALIASES = {
"zh": "zh-hans", "zh-cn": "zh-hans", "zh-sg": "zh-hans", "zh-tw": "zh-hant",
"zh-hk": "zh-hant", "zh-mo": "zh-hant",
}
# Targets whose script puts no space between sentences.
_NO_SPACE_LANGS = {"ja", "zh-hans", "zh-hant", "th", "km", "my"}
_cache: "OrderedDict[tuple, str]" = OrderedDict()
_CACHE_MAX = 1024
_cache_lock = threading.Lock()
_settings = SettingsService()
def get_config():
data = _settings.load()
cfg = {k: data.get(k, v) for k, v in DEFAULTS.items()}
cfg["prompt_translate_url"] = (cfg["prompt_translate_url"] or DEFAULTS["prompt_translate_url"]).rstrip("/")
cfg["prompt_translate_model"] = cfg["prompt_translate_model"] or DEFAULTS["prompt_translate_model"]
return cfg
def is_plamo(model: str) -> bool:
return "plamo" in (model or "").lower()
def normalize_lang(code, allow_auto=False, field="language"):
"""Canonical PLaMo language code ("zh" -> "zh-hans"). "" means auto-detect."""
c = str(code or "").strip().lower().replace("_", "-")
if not c or c == "auto":
if allow_auto:
return ""
raise ValueError(f"{field} is required")
c = _LANG_ALIASES.get(c, c)
if c not in LANGUAGES:
raise ValueError(f"unsupported {field}: {code}")
return c
def _chat_system(target_lang):
name = LANGUAGES.get(target_lang, "English")
return (
f"You translate text for image generation prompts into {name}. "
f"Output only the {name} translation, with no explanations, quotes or notes. "
"Keep proper nouns, numbers and any ASCII text unchanged."
)
def build_pfml3(text: str, target_lang: str = "en", source_lang: str = "") -> str:
"""Build a PFML3 translation prompt (BOS is added by llama.cpp/Ollama)."""
src = _PLAMO_SPECIAL.sub("", text)
src_attr = f"<|plamo:key|>lang<|plamo:val|>{source_lang}" if source_lang else ""
return (
"<|plamo:tag|>dataset<|plamo:msg|>translation"
f"<|plamo:tag|>input{src_attr}<|plamo:msg|>{src}"
f"<|plamo:tag|>output<|plamo:key|>lang<|plamo:val|>{target_lang}<|plamo:msg|>"
)
def _post_json(url: str, payload: dict, timeout: float):
req = urllib.request.Request(
url,
data=json.dumps(payload).encode("utf-8"),
headers={"Content-Type": "application/json"},
method="POST",
)
with urlopen(req, timeout=timeout) as resp:
return json.loads(resp.read().decode("utf-8"))
def _num_predict(text: str) -> int:
# CJK -> English roughly doubles-to-triples the token count; leave headroom.
# Chunks are at most _CHUNK_LEN characters, so the cap is not reached in practice.
return max(64, min(4096, len(text) * 4))
def _device_options(device):
return {"num_gpu": 0} if device == "cpu" else {}
def _translate_one(base_url, model, text, source_lang, keep_alive, device="gpu", target_lang="en"):
dev = _device_options(device)
if is_plamo(model):
data = _post_json(f"{base_url}/api/generate", {
"model": model,
"prompt": build_pfml3(text, target_lang, source_lang),
"raw": True,
"stream": False,
"keep_alive": keep_alive,
"options": {"temperature": 0, "num_predict": _num_predict(text), "stop": _PLAMO_STOP, **dev},
}, timeout=180)
out = data.get("response", "")
else:
data = _post_json(f"{base_url}/api/chat", {
"model": model,
"messages": [
{"role": "system", "content": _chat_system(target_lang)},
{"role": "user", "content": text},
],
"stream": False,
"think": False,
"keep_alive": keep_alive,
"options": {"temperature": 0, "num_predict": _num_predict(text), **dev},
}, timeout=180)
out = (data.get("message") or {}).get("content", "")
if data.get("done_reason") == "length":
# The output was cut at num_predict; half a translation would be silent data loss.
raise RuntimeError("translation output reached the token limit (text too long)")
out = _PLAMO_SPECIAL.sub("", out)
return out.strip()
def unload(base_url: str, model: str):
try:
_post_json(f"{base_url}/api/generate", {"model": model, "keep_alive": 0}, timeout=15)
except Exception:
pass
# ------------------------------------------------------------
# Translation session (settings, cache, chunking, unload)
# ------------------------------------------------------------
_SENTENCE_END = re.compile(r"(?<=[。.!?!?.])\s*")
def _chunks(text):
"""Split long text into [(chunk, separator_after)] of at most _CHUNK_LEN characters.
Splits at line breaks first, then at sentence ends. The separator is the line
break(s) that followed the chunk, "" when a chunk was closed only for length, or
" " for a sentence break (the caller applies the target language's spacing).
A single sentence longer than _CHUNK_LEN raises ValueError rather than being cut.
"""
result = []
parts = re.split(r"(\n+)", text)
buf, buf_brk = "", ""
for k in range(0, len(parts), 2):
line = parts[k]
brk = parts[k + 1] if k + 1 < len(parts) else ""
if len(line) > _CHUNK_LEN:
if buf:
result.append((buf, buf_brk))
buf, buf_brk = "", ""
cur = ""
for sent in (x for x in _SENTENCE_END.split(line) if x):
if len(sent) > _CHUNK_LEN:
raise ValueError(
f"a sentence is longer than {_CHUNK_LEN} characters; add line breaks to split it")
if cur and len(cur) + len(sent) > _CHUNK_LEN:
result.append((cur, " "))
cur = ""
cur += sent
if cur:
result.append((cur, brk))
continue
if buf and len(buf) + len(buf_brk) + len(line) > _CHUNK_LEN:
result.append((buf, buf_brk))
buf, buf_brk = "", ""
buf = buf + buf_brk + line if buf else line
buf_brk = brk
if buf or buf_brk:
result.append((buf, buf_brk))
return result
def _check_total(texts):
total = sum(len(str(t or "")) for t in texts)
if total > _MAX_TOTAL_LEN:
raise ValueError(f"text is too long ({total} characters, limit {_MAX_TOTAL_LEN})")
class _Session:
"""One translation request: resolved settings, cache lookups, chunking, and the
VRAM unload (GPU mode) after the last model call."""
def __init__(self, model=None, source_lang=None, target_lang="en"):
cfg = get_config()
self.cfg = cfg
self.base_url = require_backend_url(cfg["prompt_translate_url"])
self.model = (model or cfg["prompt_translate_model"]).strip()
src = source_lang if source_lang is not None else cfg["prompt_translate_source_lang"]
self.src = normalize_lang(src, allow_auto=True, field="source language")
self.tgt = normalize_lang(target_lang or "en", field="target language")
self.device = "cpu" if cfg.get("prompt_translate_device") == "cpu" else "gpu"
self.keep_alive = CPU_KEEP_ALIVE if self.device == "cpu" else "5m"
self.cached = 0
self.used_model = False
def _one(self, text):
key = (self.model, self.src, self.tgt, text)
with _cache_lock:
hit = _cache.get(key)
if hit is not None:
_cache.move_to_end(key)
if hit is not None:
self.cached += 1
return hit
out = _translate_one(self.base_url, self.model, text, self.src, self.keep_alive,
self.device, self.tgt)
self.used_model = True
with _cache_lock:
_cache[key] = out
_cache.move_to_end(key)
while len(_cache) > _CACHE_MAX:
_cache.popitem(last=False)
return out
def translate(self, text):
"""Translate one string; whitespace-only strings are returned unchanged."""
text = str(text or "")
if not text.strip():
return text
if len(text) <= _CHUNK_LEN:
return self._one(text)
sentence_sep = "" if self.tgt in _NO_SPACE_LANGS else " "
out = []
for chunk, sep in _chunks(text):
out.append(self._one(chunk) if chunk.strip() else chunk)
out.append(sentence_sep if sep == " " else sep)
return "".join(out)
def finish(self):
if self.used_model and self.device == "gpu" and self.cfg.get("prompt_translate_unload", True):
# Free VRAM for the image model that usually runs right after.
unload(self.base_url, self.model)
def _check_texts(texts):
if not isinstance(texts, list) or len(texts) > _MAX_TEXTS:
raise ValueError(f"texts must be a list of at most {_MAX_TEXTS} strings")
_check_total(texts)
def translate_texts(texts, model=None, source_lang=None, target_lang="en"):
"""Translate each string in ``texts`` as a whole (no prompt-syntax handling).
Blocking (run in a thread). Returns (translations, cached_count). Identical inputs
are served from a bounded cache keyed by (model, source_lang, target_lang, text).
"""
_check_texts(texts)
sess = _Session(model, source_lang, target_lang)
try:
return [sess.translate(t) for t in texts], sess.cached
finally:
sess.finish()
# ------------------------------------------------------------
# Prompt-aware translation
# ------------------------------------------------------------
# Spans that are never translated: prompt syntax and delimiters.
_PROTECTED_RE = re.compile(
r"(?<![A-Za-z0-9_])(?:BREAK|AND)(?![A-Za-z0-9_])"
r"|<[^<>\n]*>"
r"|__[^\s_]\S*?__"
r"|embedding:[^\s,()\[\]{}|]+"
r"|:\s*-?\d+(?:\.\d+)?"
r"|[,\n()\[\]{}|]"
)
# Text meant to be drawn in the image: 「」 『』 “” "" (one line, no nesting).
_QUOTE_RE = re.compile(r'「[^「」\n]*」|『[^『』\n]*』|“[^“”\n]*”|"[^"\n]*"')
# Placeholder for a quoted span while the prompt is split (private-use characters,
# which contain no delimiter and are not letters).
_PH_RE = re.compile("(\\d+)")
_PH_SPLIT_RE = re.compile("(\\d+)")
_TOKEN_RE = re.compile(r"QT(\d+)(?!\d)")
def needs_translation(text):
"""True when ``text`` contains a non-ASCII letter (CJK, Cyrillic, accented Latin, ...)."""
return any(ord(c) > 127 and c.isalpha() for c in text or "")
def split_prompt(text):
"""Split a prompt into [{"text", "translate"}]; joining every "text" gives back the input."""
pieces = []
last = 0
for m in _PROTECTED_RE.finditer(text):
if m.start() > last:
pieces.append((text[last:m.start()], False))
pieces.append((m.group(0), True))
last = m.end()
if last < len(text):
pieces.append((text[last:], False))
return [{"text": t, "translate": (not keep) and needs_translation(t)} for t, keep in pieces]
def _rebuild(source, translated):
"""Keep the surrounding whitespace of a piece and tidy the model output for prompt use."""
core = source.strip()
lead = source[:len(source) - len(source.lstrip())]
trail = source[len(source.rstrip()):]
out = re.sub(r"\s*\n+\s*", " ", translated or "").strip()
# A tag such as "赤いドレス" should not become "Red dress." — drop the final period
# unless the source itself was a full sentence.
if not re.search(r"[。..!?!?]$", core):
out = re.sub(r"[.。]+$", "", out)
# "少女、(" -> "girl, (" rather than "girl,(": an English comma needs a space after it.
if not trail and re.search(r"[,;:]$", out):
out += " "
return lead + out + trail
class _Quotes:
"""Swap quoted spans for placeholders so prompt splitting never cuts inside them."""
def __init__(self, text, enabled):
self.items = []
if not enabled:
self.text = text
return
def sub(m):
self.items.append(m.group(0))
return f"{len(self.items) - 1}"
self.text = _QUOTE_RE.sub(sub, text)
def restore(self, s):
return _PH_RE.sub(lambda m: self.items[int(m.group(1))], s) if self.items else s
def _translate_piece(sess, quotes, core):
"""Translate one prompt piece; quoted spans inside it go to the model as tokens."""
ids = [int(x) for x in _PH_RE.findall(core)]
if not ids:
return sess.translate(core)
# Send the sentence whole with each quote's content replaced by a token (『QT0』) so
# the words around it are translated naturally, then put the original content back.
def to_token(m):
q = quotes.items[int(m.group(1))]
return f"{q[0]}QT{m.group(1)}{q[-1]}"
out = sess.translate(_PH_RE.sub(to_token, core))
found = [int(x) for x in _TOKEN_RE.findall(out)]
if sorted(found) == sorted(ids):
return _TOKEN_RE.sub(lambda m: quotes.items[int(m.group(1))][1:-1], out)
# The model dropped or repeated a token: translate the text around each quote on its
# own and keep the quotes exactly as written.
res = []
for part in _PH_SPLIT_RE.split(core):
if _PH_RE.fullmatch(part):
res.append(quotes.restore(part))
elif needs_translation(part):
res.append(_rebuild(part, sess.translate(part.strip())))
else:
res.append(part)
return "".join(res)
def translate_prompt_texts(texts, model=None, source_lang=None, target_lang="en", protect_quotes=False):
"""Translate prompts, keeping prompt syntax (and with ``protect_quotes`` the text
inside 「」『』“”""). Blocking. Returns (translations, cached_count)."""
_check_texts(texts)
sess = _Session(model, source_lang, target_lang)
try:
results = []
for raw in texts:
text = str(raw or "")
if not needs_translation(text):
results.append(text)
continue
quotes = _Quotes(text, protect_quotes)
out = []
for p in split_prompt(quotes.text):
if not p["translate"] or not needs_translation(_PH_RE.sub("", p["text"])):
out.append(quotes.restore(p["text"]))
continue
translated = _translate_piece(sess, quotes, p["text"].strip())
out.append(_rebuild(p["text"], translated))
results.append("".join(out))
return results, sess.cached
finally:
sess.finish()
def warmup(ignore_enabled=False):
"""Load the translation model ahead of the first translation (CPU mode).
In CPU mode the model is kept resident, so loading it once in the background
when GenerateUI opens hides Ollama's ~4 s startup from the first translation.
``ignore_enabled`` is for other front-ends (Comic Creator) that keep their own
on/off switch. Returns False when there is nothing to do.
"""
cfg = get_config()
if cfg.get("prompt_translate_device") != "cpu":
return False
if not ignore_enabled and not cfg.get("prompt_translate_enabled"):
return False
base_url = require_backend_url(cfg["prompt_translate_url"])
model = cfg["prompt_translate_model"]
# A request without a prompt only loads the model; the options decide CPU placement.
_post_json(f"{base_url}/api/generate", {
"model": model,
"keep_alive": CPU_KEEP_ALIVE,
"options": _device_options("cpu"),
}, timeout=180)
return True
def list_models():
cfg = get_config()
base_url = require_backend_url(cfg["prompt_translate_url"])
req = urllib.request.Request(f"{base_url}/api/tags")
with urlopen(req, timeout=5) as resp:
data = json.loads(resp.read().decode("utf-8"))
return [m.get("name") for m in data.get("models", []) if m.get("name")]
+6
View File
@@ -12,6 +12,8 @@ import os
import sys
from pathlib import Path
from ..config import is_safe_rel
logger = logging.getLogger(__name__)
try:
@@ -209,6 +211,10 @@ class VideoService:
base_dir = folder_paths.get_directory_by_type(type_)
if not base_dir:
raise ValueError(f"Invalid type: {type_}")
# UNC・ドライブ指定・絶対パス・「..」は、結合・resolve() の前に文字列のまま拒否する
# (Windows では UNC を resolve() するだけで相手ホストへ資格情報付きで接続するため)
if not is_safe_rel(filename) or (subfolder and not is_safe_rel(subfolder)):
raise ValueError("Access denied: path outside allowed directory")
base = Path(base_dir).resolve()
target = (base / (subfolder or "") / filename).resolve()
try:
+3 -2
View File
@@ -83,10 +83,11 @@ class WildcardService:
return None
# Normalize to forward slashes and strip leading/trailing slashes
filename = filename.replace("\\", "/").strip("/")
# Validate each path component — block traversal and empty parts
# Validate each path component — block traversal, empty parts and drive-relative
# names ("C:name"; on Python <=3.11 joinpath would replace the base path with them)
parts = filename.split("/")
for p in parts:
if not p or p == ".." or p == ".":
if not p or p == ".." or p == "." or ":" in p:
return None
ext = Path(parts[-1]).suffix.lstrip(".").lower()
if ext not in ALLOWED_EXTS:
+2 -1
View File
@@ -99,7 +99,7 @@ class WorkflowStudio:
app.router.add_get("/wfm", serve_index_page)
# API routes
from .routes import workflow_routes, settings_routes, ollama_routes, unsloth_routes, eagle_routes, nodes_routes, prompts_routes, models_routes, gallery_routes, wildcard_routes, tagger_routes, gmic_routes, skill_routes, lab_routes, video_routes, vram_routes, partner_routes, tagspace_routes
from .routes import workflow_routes, settings_routes, ollama_routes, unsloth_routes, eagle_routes, nodes_routes, prompts_routes, models_routes, gallery_routes, wildcard_routes, tagger_routes, gmic_routes, skill_routes, lab_routes, video_routes, vram_routes, partner_routes, tagspace_routes, translate_routes
workflow_routes.setup_routes(app)
settings_routes.setup_routes(app)
@@ -119,5 +119,6 @@ class WorkflowStudio:
video_routes.setup_routes(app)
vram_routes.setup_routes(app)
tagspace_routes.setup_routes(app)
translate_routes.setup_routes(app)
logger.info("Workflow Studio: Routes registered successfully")
+1 -1
View File
@@ -1,7 +1,7 @@
[project]
name = "comfyui-workflow-studio"
description = "A comprehensive workflow, asset management, and generation UI plugin for ComfyUI. Manage workflows, models, images, and prompts; batch generation and Image Feeder in the GenerateUI tab; library side panel with canvas drag & drop and AI tools."
version = "0.9.2"
version = "0.10.0"
license = { file = "LICENSE" }
requires-python = ">= 3.10"
dependencies = ["jinja2"]
+81
View File
@@ -1155,3 +1155,84 @@
.wfm-sem-danger { margin-left: auto; color: #ef4444; }
.wfm-sem-row .wfm-select { width: auto; min-width: 90px; }
/* 3Dモデルビューア */
.wfm-gallery-thumb-video-badge.wfm-gallery-thumb-video-badge--corner {
top: auto;
left: auto;
right: 4px;
bottom: 4px;
width: auto;
height: auto;
padding: 1px 5px;
border-radius: 3px;
font-size: 10px;
line-height: 14px;
transform: none;
}
.wfm-g3d-box {
position: relative;
background: #181c26;
border-radius: 4px;
overflow: hidden;
}
.wfm-gallery-detail-img.wfm-g3d-box {
width: 100%;
height: 100%;
}
.wfm-gallery-lightbox-img.wfm-g3d-box {
width: 90vw;
height: 85vh;
}
.wfm-lightbox-compare-img.wfm-g3d-box {
width: calc(92vw / var(--compare-cols, 2) - 12px);
height: 78vh;
}
.wfm-g3d-canvas {
display: block;
width: 100%;
height: 100%;
outline: none;
}
.wfm-g3d-status {
position: absolute;
inset: 0;
display: flex;
align-items: center;
justify-content: center;
padding: 8px;
text-align: center;
color: var(--wfm-text-secondary);
font-size: 12px;
pointer-events: none;
}
.wfm-g3d-status--error {
color: #f87171;
}
.wfm-g3d-stats {
position: absolute;
left: 6px;
bottom: 4px;
color: #cbd5e1;
font-size: 10px;
text-shadow: 0 0 3px #000;
pointer-events: none;
}
.wfm-g3d-reset {
position: absolute;
top: 4px;
right: 4px;
width: 22px;
height: 22px;
padding: 0;
border: none;
border-radius: 4px;
background: rgba(0, 0, 0, 0.5);
color: #e2e8f0;
font-size: 13px;
line-height: 22px;
cursor: pointer;
}
.wfm-g3d-reset:hover {
background: rgba(0, 0, 0, 0.75);
}
+56
View File
@@ -0,0 +1,56 @@
/* Game タブ (実験的機能・ComfyUI-WFS-Games が必要) */
#wfm-tab-game.active { overflow: hidden; }
.wfm-game-layout { display: flex; height: 100%; min-height: 0; }
.wfm-game-layout [hidden] { display: none !important; }
.wfm-game-side,
.wfm-game-result { width: 290px; flex: none; display: flex; flex-direction: column; gap: 10px; padding: 10px; overflow: auto; }
.wfm-game-side { border-right: 1px solid var(--wfm-border, #444); }
.wfm-game-result { border-left: 1px solid var(--wfm-border, #444); width: 320px; }
.wfm-game-section { display: flex; flex-direction: column; gap: 8px; padding: 8px; border: 1px solid var(--wfm-border, #444); border-radius: var(--wfm-radius, 6px); background: var(--wfm-surface, transparent); }
.wfm-game-section-title { font-size: 12px; font-weight: 600; color: var(--wfm-text-secondary, #aaa); text-transform: uppercase; letter-spacing: 0.04em; }
.wfm-game-list { display: flex; flex-direction: column; gap: 6px; }
.wfm-game-card { display: flex; flex-direction: column; gap: 3px; padding: 8px; text-align: left; border-radius: var(--wfm-radius-sm, 4px); cursor: pointer; color: var(--wfm-text, #ddd); background: var(--wfm-bg-secondary, #222); border: 1px solid var(--wfm-border, #444); }
.wfm-game-card:hover { border-color: var(--wfm-primary, #4a9eff); }
.wfm-game-card.active { border-color: var(--wfm-primary, #4a9eff); box-shadow: 0 0 0 1px var(--wfm-primary, #4a9eff) inset; }
.wfm-game-card img { width: 100%; max-height: 90px; object-fit: cover; border-radius: 3px; }
.wfm-game-card-name { font-weight: 600; font-size: 13px; }
.wfm-game-card-desc { font-size: 11px; color: var(--wfm-text-secondary, #aaa); line-height: 1.4; }
.wfm-game-field { display: flex; flex-direction: column; gap: 4px; font-size: 12px; }
.wfm-game-field > span { color: var(--wfm-text-secondary, #aaa); }
.wfm-game-field textarea { width: 100%; resize: vertical; box-sizing: border-box; }
.wfm-game-check { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; cursor: pointer; }
.wfm-game-row { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.wfm-game-row select { flex: 1; min-width: 0; }
.wfm-game-note { font-size: 11px; color: var(--wfm-text-secondary, #aaa); line-height: 1.4; }
.wfm-game-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.wfm-game-toolbar { display: flex; align-items: center; gap: 8px; padding: 8px 12px; border-bottom: 1px solid var(--wfm-border, #444); }
.wfm-game-current { font-weight: 600; }
.wfm-game-spacer { flex: 1; }
.wfm-game-stage { flex: 1; min-height: 0; position: relative; background: #05060f; overflow: hidden; }
.wfm-game-stage canvas { display: block; }
.wfm-game-loading { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; padding: 24px; text-align: center; color: #94a3b8; }
.wfm-game-result-status { font-size: 13px; display: flex; flex-direction: column; gap: 4px; }
.wfm-game-result-head { font-size: 20px; font-weight: 700; letter-spacing: 0.05em; }
.wfm-game-result-head.cleared { color: var(--wfm-success, #2ed573); }
.wfm-game-result-head.failed { color: var(--wfm-danger, #ff4757); }
.wfm-game-rewards { display: flex; flex-direction: column; gap: 4px; }
.wfm-game-reward { display: flex; align-items: flex-start; gap: 6px; font-size: 12px; padding: 4px 6px; border-radius: var(--wfm-radius-sm, 4px); background: var(--wfm-bg-secondary, #222); cursor: pointer; }
.wfm-game-reward span { word-break: break-word; }
.wfm-game-reward-src { display: inline-block; margin-right: 6px; padding: 0 5px; border-radius: 3px; font-size: 10px; line-height: 16px; vertical-align: 1px; color: var(--wfm-text, #ddd); background: var(--wfm-bg-tertiary, #334); }
.wfm-game-progress { height: 6px; border-radius: 3px; overflow: hidden; background: var(--wfm-bg-secondary, #333); }
.wfm-game-progress-bar { height: 100%; width: 0; background: var(--wfm-primary, #4a9eff); transition: width 0.2s; }
.wfm-game-progress-text { font-size: 11px; color: var(--wfm-text-secondary, #aaa); word-break: break-all; min-height: 14px; }
.wfm-game-jobs { display: flex; flex-direction: column; gap: 8px; }
.wfm-game-job { display: flex; flex-direction: column; gap: 6px; padding: 8px; border: 1px solid var(--wfm-border, #444); border-radius: var(--wfm-radius, 6px); background: var(--wfm-surface, transparent); }
.wfm-game-job-gameover { border-color: var(--wfm-danger, #ff4757); }
.wfm-game-job-gameover .wfm-game-job-title { color: var(--wfm-danger, #ff4757); }
.wfm-game-job-head { display: flex; align-items: baseline; gap: 8px; }
.wfm-game-job-title { flex: 1; min-width: 0; font-weight: 600; font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.wfm-game-job-status { flex: none; font-size: 11px; color: var(--wfm-text-secondary, #aaa); }
.wfm-game-job-status[data-status="done"] { color: var(--wfm-success, #2ed573); }
.wfm-game-job-status[data-status="failed"] { color: var(--wfm-danger, #ff4757); white-space: normal; }
.wfm-game-job-img { width: 100%; border-radius: var(--wfm-radius-sm, 4px); background: #000; }
.wfm-game-job-details summary { cursor: pointer; font-size: 12px; color: var(--wfm-text-secondary, #aaa); }
.wfm-game-job-details[open] { display: flex; flex-direction: column; gap: 6px; }
.wfm-game-job-private { border-color: #f472b6; }
.wfm-game-job-private .wfm-game-job-title { color: #f472b6; }
+100
View File
@@ -466,3 +466,103 @@
background: var(--wfm-border);
border-radius: 2px;
}
/* Draw tool palette */
.ie-palette-content {
display: flex;
align-items: center;
flex-wrap: wrap;
gap: 6px 14px;
}
.ie-palette-wells {
gap: 6px;
}
.ie-palette-well,
.ie-palette-swatch {
padding: 0;
border-radius: 50%;
background: var(--swatch, transparent);
cursor: pointer;
}
.ie-palette-well {
width: 26px;
height: 26px;
border: 1px solid var(--wfm-text-secondary);
}
.ie-palette-well.is-active {
outline: 2px solid var(--wfm-primary);
outline-offset: 2px;
}
.ie-palette-grid {
display: grid;
grid-template-columns: repeat(10, 16px);
grid-auto-rows: 16px;
gap: 2px;
}
.ie-palette-swatch {
width: 16px;
height: 16px;
border: 1px solid rgba(128, 128, 128, 0.7);
}
.ie-palette-swatch.is-empty {
border-color: var(--wfm-text-secondary);
opacity: 0.6;
}
.ie-palette-swatch:hover,
.ie-palette-swatch:focus-visible,
.ie-palette-well:focus-visible {
outline: 1px solid var(--wfm-text);
outline-offset: 1px;
opacity: 1;
}
.ie-palette-swatch.is-current {
outline: 2px solid var(--wfm-primary);
outline-offset: 0;
}
.ie-palette-picker {
position: fixed;
width: 1px;
height: 1px;
padding: 0;
border: 0;
opacity: 0;
pointer-events: none;
}
.ie-palette-menu {
position: fixed;
z-index: 1000;
display: flex;
flex-direction: column;
min-width: 150px;
padding: 4px;
border: 1px solid var(--wfm-border);
border-radius: 4px;
background: var(--wfm-surface);
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
}
.ie-palette-menu button {
padding: 5px 10px;
border: 0;
border-radius: 3px;
background: transparent;
color: var(--wfm-text);
font-size: 12px;
text-align: left;
cursor: pointer;
}
.ie-palette-menu button:hover {
background: var(--wfm-surface-hover);
}
+241
View File
@@ -5990,6 +5990,90 @@ body {
flex-shrink: 0;
}
/* TOOLS: result actions, OCR options and text-position overlay (ocr-tools.js) */
.wfm-ai-vlm-result-actions {
display: flex;
justify-content: flex-end;
gap: 6px;
flex-shrink: 0;
}
.wfm-ai-ocr-options {
display: flex;
flex-direction: column;
gap: 6px;
flex-shrink: 0;
}
.wfm-ai-ocr-row {
display: flex;
align-items: center;
gap: 6px;
}
.wfm-ai-ocr-row .wfm-ai-label { flex-shrink: 0; margin: 0; }
.wfm-ai-ocr-row .wfm-select { flex: 1; min-width: 0; }
.wfm-ai-ocr-check {
display: flex;
align-items: center;
gap: 6px;
font-size: 12px;
color: var(--wfm-text-secondary);
cursor: pointer;
}
.wfm-ai-ocr-check.is-disabled { opacity: 0.45; cursor: default; }
.wfm-ai-ocr-hint { font-size: 11px; color: var(--wfm-text-secondary); opacity: 0.85; }
/* OCR: a taller preview so the numbered boxes are usable */
.wfm-ai-vlm-drop.is-ocr { height: 260px; }
.wfm-ai-ocr-overlay {
position: absolute;
inset: 0;
pointer-events: none;
}
.wfm-ai-ocr-box {
position: absolute;
border: 1.5px solid #4fd8ff;
background: rgba(79, 216, 255, 0.12);
box-sizing: border-box;
pointer-events: auto;
cursor: pointer;
}
.wfm-ai-ocr-box.is-active { border-color: #ff9f43; background: rgba(255, 159, 67, 0.2); }
.wfm-ai-ocr-box-tag {
position: absolute;
top: -1px;
left: -1px;
padding: 0 3px;
font-size: 9px;
line-height: 12px;
color: #000;
background: #4fd8ff;
}
/* Collapsible Translation / Settings panes */
.wfm-ai-pane-collapse-btn {
border: none;
background: transparent;
color: var(--wfm-text-secondary);
font-size: 10px;
line-height: 1;
padding: 2px 4px;
cursor: pointer;
border-radius: 3px;
}
.wfm-ai-pane-collapse-btn:hover { background: var(--wfm-bg); color: var(--wfm-text); }
.wfm-ai-pane.is-collapsed {
flex: 0 0 28px;
cursor: pointer;
}
.wfm-ai-pane.is-collapsed > :not(.wfm-ai-pane-header) { display: none !important; }
.wfm-ai-pane.is-collapsed .wfm-ai-pane-header {
writing-mode: vertical-rl;
flex: 1;
justify-content: flex-start;
gap: 8px;
padding: 8px 0;
border-bottom: none;
}
.wfm-ai-pane.is-collapsed .wfm-ai-pane-collapse-btn { writing-mode: horizontal-tb; }
/* Chat pane */
.wfm-ai-chat-container {
display: flex;
@@ -6050,6 +6134,118 @@ body {
object-fit: cover;
}
/* Markdown-rendered assistant replies (chat-markdown.js) */
.wfm-ai-chat-msg.wfm-ai-chat-md { white-space: normal; }
.wfm-ai-chat-md p { margin: 0 0 6px; }
.wfm-ai-chat-md p:last-child { margin-bottom: 0; }
.wfm-ai-chat-md ul, .wfm-ai-chat-md ol { margin: 2px 0 6px; padding-left: 20px; }
.wfm-ai-chat-md li { margin: 1px 0; }
.wfm-ai-chat-md .wfm-md-h { margin: 8px 0 4px; font-size: 13px; font-weight: 700; }
.wfm-ai-chat-md h3.wfm-md-h { font-size: 14px; }
.wfm-ai-chat-md code {
font-family: Consolas, "Courier New", monospace;
font-size: 12px;
background: rgba(127, 127, 127, 0.18);
padding: 0 3px;
border-radius: 3px;
}
.wfm-ai-chat-md .wfm-md-pre {
position: relative;
margin: 4px 0 6px;
padding: 8px 10px;
background: rgba(0, 0, 0, 0.25);
border: 1px solid var(--wfm-border);
border-radius: 4px;
overflow-x: auto;
white-space: pre;
}
.wfm-ai-chat-md .wfm-md-pre code { background: none; padding: 0; }
.wfm-ai-chat-md .wfm-md-code-lang {
position: absolute;
top: 2px;
right: 6px;
font-size: 10px;
opacity: 0.6;
}
.wfm-ai-chat-md blockquote {
margin: 4px 0;
padding-left: 8px;
border-left: 3px solid var(--wfm-border);
opacity: 0.9;
}
.wfm-ai-chat-md hr { border: none; border-top: 1px solid var(--wfm-border); margin: 6px 0; }
/* Skill auto-check notices (metadata.output) */
.wfm-ai-chat-msg-notice {
align-self: center;
max-width: 95%;
background: transparent;
border: 1px dashed var(--wfm-border);
color: var(--wfm-text-secondary, var(--wfm-text));
font-size: 11px;
opacity: 0.85;
}
/* Action buttons under a ```prompt block */
.wfm-ai-chat-msg-actions {
margin-top: 6px;
display: flex;
flex-wrap: wrap;
gap: 6px;
white-space: normal;
}
/* Image check result card (chat-image-check.js) */
.wfm-ai-chat-msg-check {
white-space: normal;
min-width: 260px;
}
.wfm-ai-check-head {
display: flex;
justify-content: space-between;
align-items: baseline;
gap: 8px;
font-weight: 600;
margin-bottom: 4px;
}
.wfm-ai-check-head.is-pass { color: #4caf50; }
.wfm-ai-check-head.is-fail { color: #e5a00d; }
.wfm-ai-check-meta {
font-weight: normal;
font-size: 11px;
opacity: 0.7;
color: var(--wfm-text-secondary);
}
.wfm-ai-check-list {
list-style: none;
margin: 0;
padding: 0;
}
.wfm-ai-check-item {
display: flex;
gap: 6px;
align-items: baseline;
padding: 1px 0;
font-size: 12px;
}
.wfm-ai-check-icon { width: 14px; text-align: center; font-weight: 700; }
.wfm-ai-check-item.is-pass .wfm-ai-check-icon { color: #4caf50; }
.wfm-ai-check-item.is-uncertain .wfm-ai-check-icon { color: #e5a00d; }
.wfm-ai-check-item.is-fail .wfm-ai-check-icon { color: #e05252; }
.wfm-ai-check-label { flex: 1; }
.wfm-ai-check-p { font-size: 11px; opacity: 0.7; font-variant-numeric: tabular-nums; }
.wfm-ai-check-quality { margin-top: 4px; font-size: 11px; opacity: 0.8; }
/* "Built-in" badge in the skill manager list */
.wfm-ai-skill-badge {
margin-left: 6px;
padding: 0 5px;
border-radius: 3px;
border: 1px solid var(--wfm-border);
font-size: 10px;
opacity: 0.75;
}
.wfm-ai-chat-svg-wrapper {
margin-top: 6px;
display: flex;
@@ -6255,3 +6451,48 @@ body {
max-width: none;
}
.wfm-compat-row .wfm-format-badge:empty { display: none; }
/* GenerateUI Settings tab: Switches column (true/false inputs) */
.wfm-settings-switches {
display: flex;
flex-direction: column;
gap: 4px;
max-height: 420px;
overflow-y: auto;
}
.wfm-settings-switch {
display: flex;
align-items: center;
gap: 8px;
padding: 4px 6px;
border: 1px solid var(--wfm-border);
border-radius: 4px;
cursor: pointer;
font-size: 12px;
}
.wfm-settings-switch:hover {
background: var(--wfm-surface);
}
.wfm-settings-switch-text {
display: flex;
flex-direction: column;
flex: 1;
min-width: 0;
}
.wfm-settings-switch-node {
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
.wfm-settings-switch-key {
color: var(--wfm-text-secondary);
font-size: 11px;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
.wfm-settings-switch-state {
font-family: monospace;
font-size: 11px;
color: var(--wfm-text-secondary);
}
+972 -31
View File
File diff suppressed because it is too large Load Diff
+48 -3
View File
@@ -112,7 +112,7 @@ function initTabs() {
function applyI18nToHtml() {
// Tab labels
const tabMap = { workflow: "tabWorkflow", nodes: "tabNodes", models: "tabModels", generate: "tabGenerate", prompt: "tabPrompt", gallery: "tabGallery", "image-edit": "tabImageEdit", video: "tabVideo", settings: "tabSettings", help: "tabHelp", ai: "tabAi", tagger: "tabTagger", tagspace: "tabTagSpace" };
const tabMap = { workflow: "tabWorkflow", nodes: "tabNodes", models: "tabModels", generate: "tabGenerate", prompt: "tabPrompt", gallery: "tabGallery", "image-edit": "tabImageEdit", video: "tabVideo", settings: "tabSettings", help: "tabHelp", ai: "tabAi", tagger: "tabTagger", tagspace: "tabTagSpace", game: "tabGame" };
document.querySelectorAll(".wfm-tab").forEach((tab) => {
const key = tabMap[tab.dataset.tab];
if (key) tab.textContent = t(key);
@@ -375,6 +375,7 @@ function applyI18nToHtml() {
aiVlmTask.querySelectorAll("option").forEach(opt => {
if (opt.value === "describe") opt.textContent = t("aiVlmDescribe");
if (opt.value === "prompt") opt.textContent = t("aiVlmPromptCreate");
if (opt.value === "ocr") opt.textContent = t("aiVlmOcr");
});
}
const aiVlmRunBtn = document.getElementById("wfm-ai-vlm-run");
@@ -383,6 +384,17 @@ function applyI18nToHtml() {
if (aiVlmResult) aiVlmResult.placeholder = t("aiVlmResultPlaceholder");
const aiVlmCopyBtn = document.getElementById("wfm-ai-vlm-copy");
if (aiVlmCopyBtn) aiVlmCopyBtn.textContent = t("aiCopyBtn");
const aiVlmToTrans = document.getElementById("wfm-ai-vlm-to-trans");
if (aiVlmToTrans) aiVlmToTrans.textContent = t("aiVlmToTranslation");
const aiVlmToChat = document.getElementById("wfm-ai-vlm-to-chat");
if (aiVlmToChat) aiVlmToChat.textContent = t("aiVlmToChat");
const aiOcrModelLabel = document.getElementById("wfm-ai-ocr-model-label");
if (aiOcrModelLabel) aiOcrModelLabel.textContent = t("aiOcrModelLabel");
const aiOcrBoxesLabel = document.getElementById("wfm-ai-ocr-boxes-label");
if (aiOcrBoxesLabel) aiOcrBoxesLabel.textContent = t("aiOcrShowBoxes");
const aiOcrRefresh = document.getElementById("wfm-ai-ocr-refresh");
if (aiOcrRefresh) aiOcrRefresh.title = t("aiOcrRefresh");
document.querySelectorAll(".wfm-ai-pane-collapse-btn").forEach((b) => { b.title = t("aiPaneCollapse"); });
const aiBackendTitle = document.getElementById("wfm-ai-settings-backend-title");
if (aiBackendTitle) aiBackendTitle.textContent = t("aiSettingsBackend");
const aiConnTitle = document.getElementById("wfm-ai-settings-conn-title");
@@ -416,6 +428,24 @@ function applyI18nToHtml() {
if (aiSaveBtn) aiSaveBtn.textContent = t("aiSettingsSaveBtn");
const aiChatImgGenLabel = document.getElementById("wfm-ai-chat-imggen-label-text");
if (aiChatImgGenLabel) aiChatImgGenLabel.textContent = t("aiChatImgGenToggle");
const aiChatCheckLabelText = document.getElementById("wfm-ai-chat-check-label-text");
if (aiChatCheckLabelText) aiChatCheckLabelText.textContent = t("aiChatCheckToggle");
const aiChatCheckLabel = document.getElementById("wfm-ai-chat-check-label");
if (aiChatCheckLabel) aiChatCheckLabel.title = t("aiChatCheckToggleTip");
const aiCheckTitle = document.getElementById("wfm-ai-settings-check-title");
if (aiCheckTitle) aiCheckTitle.textContent = t("aiSettingsCheckTitle");
const aiJudgeLabel = document.getElementById("wfm-ai-judge-model-label");
if (aiJudgeLabel) aiJudgeLabel.textContent = t("aiJudgeModelLabel");
const aiJudgeRefresh = document.getElementById("wfm-ai-judge-refresh-btn");
if (aiJudgeRefresh) aiJudgeRefresh.textContent = t("aiJudgeRefresh");
const aiRoundsLabel = document.getElementById("wfm-ai-check-rounds-label");
if (aiRoundsLabel) aiRoundsLabel.textContent = t("aiCheckRoundsLabel");
const aiRoundsManual = document.querySelector("#wfm-ai-check-rounds-select option[value='0']");
if (aiRoundsManual) aiRoundsManual.textContent = t("aiCheckRoundsManual");
const aiSkillImportText = document.getElementById("wfm-ai-skill-import-text");
if (aiSkillImportText) aiSkillImportText.textContent = t("aiSkillImportText");
const aiSkillImportLabel = document.getElementById("wfm-ai-skill-import-label");
if (aiSkillImportLabel) aiSkillImportLabel.title = t("aiSkillImportTip");
const aiChatGenTitle = document.getElementById("wfm-ai-settings-chatgen-title");
if (aiChatGenTitle) aiChatGenTitle.textContent = t("aiSettingsChatGenTitle");
const aiChatGenDedicatedLabel = document.getElementById("wfm-ai-chatgen-dedicated-label");
@@ -493,6 +523,7 @@ function applyI18nToHtml() {
"wfm-help-gen-30": "helpGen30",
"wfm-help-gen-31": "helpGen31",
"wfm-help-gen-32": "helpGen32",
"wfm-help-gen-33": "helpGen33",
"wfm-help-feeder-title": "helpFeederTitle",
"wfm-help-feeder-desc": "helpFeederDesc",
"wfm-help-feeder-imgloop-title": "helpFeederImgloopTitle",
@@ -526,7 +557,7 @@ function applyI18nToHtml() {
"wfm-help-lab-plan-5": "helpLabPlan5", "wfm-help-lab-plan-6": "helpLabPlan6",
"wfm-help-lab-plan-7": "helpLabPlan7", "wfm-help-lab-plan-8": "helpLabPlan8",
"wfm-help-lab-plan-9": "helpLabPlan9", "wfm-help-lab-plan-10": "helpLabPlan10",
"wfm-help-lab-plan-11": "helpLabPlan11",
"wfm-help-lab-plan-11": "helpLabPlan11", "wfm-help-lab-plan-12": "helpLabPlan12",
"wfm-help-lab-card-results-title": "helpLabCardResultsTitle",
"wfm-help-lab-results-1": "helpLabResults1", "wfm-help-lab-results-2": "helpLabResults2",
"wfm-help-lab-results-3": "helpLabResults3",
@@ -561,6 +592,7 @@ function applyI18nToHtml() {
"wfm-help-settings-20": "helpSettings20", "wfm-help-settings-21": "helpSettings21",
"wfm-help-settings-22": "helpSettings22",
"wfm-help-settings-23": "helpSettings23", "wfm-help-settings-24": "helpSettings24", "wfm-help-settings-25": "helpSettings25",
"wfm-help-settings-26": "helpSettings26",
"wfm-help-nodes-1": "helpNodes1", "wfm-help-nodes-2": "helpNodes2",
"wfm-help-nodes-3": "helpNodes3", "wfm-help-nodes-4": "helpNodes4",
"wfm-help-nodes-5": "helpNodes5", "wfm-help-nodes-6": "helpNodes6",
@@ -588,11 +620,12 @@ function applyI18nToHtml() {
"wfm-help-gallery-26": "helpGallery26",
"wfm-help-gallery-28": "helpGallery28", "wfm-help-gallery-29": "helpGallery29",
"wfm-help-gallery-30": "helpGallery30", "wfm-help-gallery-31": "helpGallery31",
"wfm-help-gallery-32": "helpGallery32", "wfm-help-gallery-33": "helpGallery33", "wfm-help-gallery-34": "helpGallery34", "wfm-help-gallery-35": "helpGallery35", "wfm-help-gallery-36": "helpGallery36", "wfm-help-gallery-37": "helpGallery37",
"wfm-help-gallery-32": "helpGallery32", "wfm-help-gallery-33": "helpGallery33", "wfm-help-gallery-34": "helpGallery34", "wfm-help-gallery-35": "helpGallery35", "wfm-help-gallery-36": "helpGallery36", "wfm-help-gallery-37": "helpGallery37", "wfm-help-gallery-38": "helpGallery38",
"wfm-help-gallery-card-styleprompt-title": "helpGalleryCardStyleprompt",
"wfm-help-gallery-card-stylecatalog-title": "helpGalleryCardStylecatalog",
"wfm-help-tagger-title": "helpTaggerTitle",
"wfm-help-tagspace-title": "helpTagSpaceTitle", "wfm-help-tagspace-card-overview-title": "helpTagSpaceCardOverview", "wfm-help-tagspace-card-use-title": "helpTagSpaceCardUse", "wfm-help-tagspace-1": "helpTagSpace1", "wfm-help-tagspace-2": "helpTagSpace2", "wfm-help-tagspace-3": "helpTagSpace3", "wfm-help-tagspace-4": "helpTagSpace4", "wfm-help-tagspace-5": "helpTagSpace5", "wfm-help-tagspace-6": "helpTagSpace6", "wfm-help-tagspace-7": "helpTagSpace7", "wfm-help-tagspace-8": "helpTagSpace8", "wfm-help-tagspace-9": "helpTagSpace9", "wfm-help-tagspace-10": "helpTagSpace10",
"wfm-help-game-title": "helpGameTitle", "wfm-help-game-card-overview-title": "helpGameCardOverview", "wfm-help-game-card-gen-title": "helpGameCardGen", "wfm-help-game-1": "helpGame1", "wfm-help-game-2": "helpGame2", "wfm-help-game-3": "helpGame3", "wfm-help-game-4": "helpGame4", "wfm-help-game-5": "helpGame5", "wfm-help-game-6": "helpGame6", "wfm-help-game-7": "helpGame7", "wfm-help-game-8": "helpGame8",
"wfm-help-tagger-1": "helpTagger1", "wfm-help-tagger-2": "helpTagger2",
"wfm-help-tagger-3": "helpTagger3", "wfm-help-tagger-4": "helpTagger4",
"wfm-help-tagger-5": "helpTagger5", "wfm-help-tagger-6": "helpTagger6",
@@ -615,6 +648,10 @@ function applyI18nToHtml() {
"wfm-help-ai-7": "helpAi7",
"wfm-help-ai-8": "helpAi8",
"wfm-help-ai-9": "helpAi9",
"wfm-help-ai-10": "helpAi10",
"wfm-help-ai-11": "helpAi11",
"wfm-help-ai-12": "helpAi12",
"wfm-help-ai-13": "helpAi13",
"wfm-help-ai-card-layout-title": "helpAiCardLayout",
"wfm-help-ai-card-translate-title": "helpAiCardTranslate",
"wfm-help-ai-card-chat-title": "helpAiCardChat",
@@ -623,6 +660,10 @@ function applyI18nToHtml() {
"wfm-help-ai-card-skilltips-title": "helpAiCardSkillTips",
"wfm-help-ai-card-tools-title": "helpAiCardTools",
"wfm-help-ai-card-settings-title": "helpAiCardSettings",
"wfm-help-ai-card-skilloptions-title": "helpAiCardSkillOptions",
"wfm-help-ai-card-skillsmore-title": "helpAiCardSkillsMore",
"wfm-help-ai-card-imagecheck-title": "helpAiCardImageCheck",
"wfm-help-ai-card-ocr-title": "helpAiCardOcr",
"wfm-help-imageedit-title": "helpImageEditTitle",
"wfm-help-imageedit-tools-title": "helpImageEditToolsTitle",
"wfm-help-imageedit-layer-title": "helpImageEditLayerTitle",
@@ -645,6 +686,8 @@ function applyI18nToHtml() {
"wfm-help-imageedit-26": "helpImageEdit26", "wfm-help-imageedit-27": "helpImageEdit27",
"wfm-help-imageedit-28": "helpImageEdit28", "wfm-help-imageedit-29": "helpImageEdit29",
"wfm-help-imageedit-30": "helpImageEdit30",
"wfm-help-imageedit-draw-palette": "helpImageEditDrawPalette", "wfm-help-imageedit-draw-kbd": "helpImageEditDrawKbd",
"wfm-help-imageedit-tabkbd-draw": "helpImageEditDrawKbd",
"wfm-help-imageedit-31": "helpImageEdit31", "wfm-help-imageedit-32": "helpImageEdit32",
"wfm-help-imageedit-33": "helpImageEdit33", "wfm-help-imageedit-34": "helpImageEdit34",
"wfm-help-imageedit-7b": "helpImageEdit7b", "wfm-help-imageedit-7c": "helpImageEdit7c",
@@ -847,6 +890,7 @@ import { initMetadataTab } from "./metadata-tab.js";
import { initAiTab } from "./ai-tab.js";
import { initTaggerTab } from "./tagger-tab.js";
import { initTagSpaceTab } from "./tagspace-tab.js";
import { initGameTab } from "./game-tab.js";
import { imageEditTab } from "./image-edit-tab.js";
import { initVideoTab } from "./video-tab.js";
@@ -900,6 +944,7 @@ document.addEventListener("DOMContentLoaded", () => {
initAiTab();
initTaggerTab();
initTagSpaceTab();
initGameTab(); // ゲームパック(ComfyUI-WFS-Games)があるときだけタブを表示
imageEditTab.init();
initVideoTab();
+203
View File
@@ -0,0 +1,203 @@
/**
* chat-context.js — facts injected into the AI TOOL Chat system prompt by a skill's
* `metadata.context` list ("workflow-detail", "logs"; "workflow" lives in ai-tab.js).
*
* Why: in the 2026-11-11 model check every local chat model answered a simple ComfyUI question
* ("SDXL vs Flux") with confident factual errors. Diagnosis skills therefore must not rely on what
* the model "knows" — they get verifiable data instead: the exact node graph, which node types
* ComfyUI does not know (not installed), which model/option values are not in ComfyUI's own
* lists (with the closest existing names), the last execution error from /history, and the tail
* of the ComfyUI log. Everything is plain text, size-capped, and built fresh on every message.
*/
import { comfyUI } from "./comfyui-client.js";
import { comfyWorkflow } from "./comfyui-workflow.js";
const MAX_NODES = 60;
const MAX_DETAIL_CHARS = 9000;
const MAX_LOG_CHARS = 3500;
function _trunc(v, n = 80) {
const s = String(v).replace(/\s+/g, " ");
return s.length > n ? `${s.slice(0, n)}…` : s;
}
// object_info input spec → the list of allowed values for a COMBO input, or null.
// Two shapes exist: [[...options], {...}] (classic) and ["COMBO", {options: [...]}] (V3 nodes).
function _comboOptions(spec) {
if (!Array.isArray(spec)) return null;
if (Array.isArray(spec[0])) return spec[0];
if (spec[0] === "COMBO" && Array.isArray(spec[1]?.options)) return spec[1].options;
return null;
}
// Core ComfyUI link-only types. Custom node packs also define UI widgets with their own
// upper-case type names (LOAD_3D viewport_state, COLOR, IMAGECOMPARE...), which an API-format
// workflow legitimately omits, so only these well-known connection types are checked.
const CONNECTION_TYPES = new Set([
"MODEL", "CLIP", "VAE", "CONDITIONING", "LATENT", "IMAGE", "MASK", "CONTROL_NET",
"CLIP_VISION", "CLIP_VISION_OUTPUT", "STYLE_MODEL", "UPSCALE_MODEL", "GLIGEN", "AUDIO",
"VIDEO", "SIGMAS", "NOISE", "GUIDER", "SAMPLER", "LORA_MODEL", "HOOKS", "MESH", "VOXEL",
]);
// A required input that can only be satisfied by a link (MODEL / CLIP / LATENT / IMAGE ...).
function _isConnectionType(spec) {
if (!Array.isArray(spec) || typeof spec[0] !== "string") return false;
return CONNECTION_TYPES.has(spec[0]);
}
function _inputSpec(info, name) {
return info?.input?.required?.[name] ?? info?.input?.optional?.[name] ?? null;
}
// Closest existing option names for a value that is not in the list (token overlap on the
// file name, ignoring folders and extensions). Good enough to point at "you have v2, not v3".
export function closestOptions(value, options, limit = 3) {
const tokens = (s) => new Set(String(s).toLowerCase().replace(/\\/g, "/").split("/").pop()
.replace(/\.(safetensors|ckpt|pt|pth|bin|gguf|sft)$/i, "")
.split(/[^a-z0-9]+/).filter((t) => t.length > 1));
const want = tokens(value);
if (!want.size) return [];
return options
.filter((o) => typeof o === "string")
.map((o) => {
const have = tokens(o);
let common = 0;
for (const t of want) if (have.has(t)) common++;
return { o, score: common / Math.max(want.size, have.size || 1) };
})
.filter((x) => x.score > 0)
.sort((a, b) => b.score - a.score)
.slice(0, limit)
.map((x) => x.o);
}
/**
* Detailed, checked description of the workflow loaded in GenerateUI (API format).
* Pure data → text; `objectInfo` is { classType: info } for the types used.
*/
export function describeWorkflowDetail(wf, objectInfo) {
const entries = Object.entries(wf || {}).filter(([, n]) => n && typeof n === "object" && n.class_type);
const lines = ["## Workflow facts (checked by Workflow Studio against this ComfyUI install)"];
lines.push(`- ${entries.length} nodes.`);
const types = [...new Set(entries.map(([, n]) => n.class_type))];
const missingTypes = types.filter((ty) => !objectInfo?.[ty]);
lines.push(missingTypes.length
? `- NOT INSTALLED node types (ComfyUI does not know them): ${missingTypes.join(", ")}`
: "- All node types are installed.");
const problems = [];
const nodeLines = [];
const ids = new Set(entries.map(([id]) => id));
for (const [id, node] of entries.slice(0, MAX_NODES)) {
const info = objectInfo?.[node.class_type];
const title = node._meta?.title && node._meta.title !== node.class_type ? ` "${_trunc(node._meta.title, 40)}"` : "";
const values = [];
const links = [];
for (const [k, v] of Object.entries(node.inputs || {})) {
if (Array.isArray(v) && v.length === 2 && (typeof v[0] === "string" || typeof v[0] === "number")) {
const src = String(v[0]);
links.push(`${k}<-#${src}`);
if (!ids.has(src)) problems.push(`#${id} ${node.class_type}: input "${k}" is linked to node #${src}, which does not exist.`);
continue;
}
if (v === null || typeof v === "object") continue;
values.push(`${k}=${_trunc(v, k === "text" || k === "prompt" ? 120 : 70)}`);
const options = info ? _comboOptions(_inputSpec(info, k)) : null;
if (options && typeof v === "string" && options.length && !options.includes(v)) {
const near = closestOptions(v, options);
problems.push(`#${id} ${node.class_type}: ${k}="${v}" is NOT in ComfyUI's list for this input${near.length ? ` (closest existing: ${near.map((o) => `"${o}"`).join(", ")})` : " (no similar name found)"}.`);
}
}
if (info) {
// Only unconnected required CONNECTION inputs (MODEL, CLIP, LATENT, IMAGE, ...) are
// reported: those make the run fail for sure. Missing widget values are usually filled
// with defaults or are UI-only, and dynamic inputs (Autogrow "COMFY_*") are stored
// under other keys - checking them produced false alarms on ~1/3 of real workflows.
for (const [name, spec] of Object.entries(info.input?.required || {})) {
if (name in (node.inputs || {}) || !_isConnectionType(spec)) continue;
problems.push(`#${id} ${node.class_type}: required ${spec[0]} input "${name}" is not connected.`);
}
}
nodeLines.push(`#${id} ${node.class_type}${title}${missingTypes.includes(node.class_type) ? " [NOT INSTALLED]" : ""}: ${[...values, ...links].join(", ") || "(no inputs)"}`);
}
if (entries.length > MAX_NODES) nodeLines.push(`… ${entries.length - MAX_NODES} more nodes not listed.`);
lines.push(problems.length ? `- Detected problems:\n${problems.slice(0, 30).map((p) => ` - ${p}`).join("\n")}` : "- No missing files, options or links detected.");
lines.push("- Nodes (#id ClassType: widget values, input<-#source node):");
let text = `${lines.join("\n")}\n${nodeLines.map((l) => ` ${l}`).join("\n")}`;
if (text.length > MAX_DETAIL_CHARS) text = `${text.slice(0, MAX_DETAIL_CHARS)}\n … (truncated)`;
return text;
}
export async function buildWorkflowDetailContext() {
const wf = comfyUI.currentWorkflow;
if (!wf) return "## Workflow facts\nNo workflow is loaded in GenerateUI. Ask the user to load the workflow they are asking about in the GenerateUI tab.";
const types = [...new Set(Object.values(wf).map((n) => n?.class_type).filter(Boolean))];
let objectInfo = {};
try {
objectInfo = await comfyWorkflow.getObjectInfoForTypes(types);
} catch (e) {
return `## Workflow facts\nCould not read node definitions from ComfyUI (${e.message}), so installed nodes and files could not be checked.`;
}
return describeWorkflowDetail(wf, objectInfo);
}
// ANSI colour codes from ComfyUI's coloured log lines
const ANSI_RE = /\u001b\[[0-9;]*m/g;
/** Keep the most recent error block of the log (from the last Traceback / error line), else the tail. */
export function extractLogTail(logText, maxChars = MAX_LOG_CHARS) {
const lines = String(logText || "").replace(ANSI_RE, "").split(/\r?\n/).filter((l) => l.trim());
let start = -1;
for (let i = lines.length - 1; i >= 0; i--) {
if (/Traceback \(most recent call last\)|!!! Exception|Error:|ERROR|Prompt outputs failed validation/.test(lines[i])) {
start = i;
// walk back to the beginning of a traceback block
while (start > 0 && /^\s|Traceback|File "/.test(lines[start - 1]) && i - start < 40) start--;
break;
}
}
const picked = start >= 0 ? lines.slice(Math.max(0, start - 3), start + 40) : lines.slice(-25);
let text = picked.join("\n");
if (text.length > maxChars) text = `…${text.slice(-maxChars)}`;
return { text, hasError: start >= 0 };
}
/** Last execution error recorded in ComfyUI's /history (most recent first). */
export function lastExecutionError(history) {
const runs = Object.values(history || {});
for (let i = runs.length - 1; i >= 0; i--) {
const msgs = runs[i]?.status?.messages || [];
const err = msgs.find((m) => m?.[0] === "execution_error")?.[1];
if (err) return err;
}
return null;
}
export async function buildLogsContext() {
const parts = ["## ComfyUI runtime facts"];
try {
const res = await fetch(`${comfyUI.baseUrl || ""}/history?max_items=5`);
const err = res.ok ? lastExecutionError(await res.json()) : null;
if (err) {
const tb = Array.isArray(err.traceback) ? err.traceback.join("").split("\n").filter(Boolean).slice(-8).join("\n") : "";
parts.push(`- Last execution error (from /history): node #${err.node_id} ${err.node_type}: ${err.exception_type}: ${_trunc(err.exception_message, 600)}${tb ? `\n Traceback tail:\n${tb}` : ""}`);
} else {
parts.push("- No execution error in the last 5 runs (/history).");
}
} catch (e) {
parts.push(`- Could not read /history: ${e.message}`);
}
try {
const res = await fetch(`${comfyUI.baseUrl || ""}/internal/logs`);
if (!res.ok) throw new Error(`HTTP ${res.status}`);
const raw = await res.json();
const { text, hasError } = extractLogTail(typeof raw === "string" ? raw : JSON.stringify(raw));
parts.push(`- ComfyUI log (${hasError ? "most recent error block" : "last lines, no error found"}):\n${text}`);
} catch (e) {
parts.push(`- Could not read the ComfyUI log: ${e.message}`);
}
return parts.join("\n");
}
+300
View File
@@ -0,0 +1,300 @@
/**
* chat-image-check.js — AI TOOL Chat: judge generated images (and rendered SVGs) with a
* vision-capable decision model, so the chat can fix only what is missing.
*
* Why a decision model instead of the chat VLM: a generator VLM answers pass/fail without a
* probability and was measured to say "yes" to things that are not in the image (2026-11-11:
* gemma4-uncensored e4b judged "holds a sword" = true). Ollama decision models with image input
* (d3:4b, clef-flash, clef) answered 18/18 checklist questions correctly on the same image with a
* clear gap between yes (0.75-1.0) and no (0.0-0.1), and return calibrated `noul` probabilities
* that code can threshold. Only one image was measured, so results are shown to the user and
* automatic fix rounds are off by default.
*
* Flow (driven by ai-tab.js):
* buildChecklist() chat LLM turns the user's request into 3-7 yes/no visual questions
* judgeImage() decision model answers them for the image (+ a quality score)
* renderCheckCard() shows ✔ / ? / ✘ per item; failed + uncertain items are what gets fixed
*/
import { t } from "./i18n.js";
import { escapeHtml } from "./util.js";
import { decide, noul, score } from "./decision-client.js";
const OLLAMA_DEFAULT_URL = "http://localhost:11434";
export const DEFAULT_JUDGE_MODEL = "d3:4b";
// Probability bands for a noul answer (after flipping "expect: no" items). In the 2026-11-11
// test runs with d3:4b, correct passes were >= 0.88 while wrong passes caused by attribute binding
// ("Is the boy wearing a green hat?" when the girl wore it) landed at 0.70-0.79, so 0.85 is the
// pass line and 0.3-0.85 counts as "uncertain" (fixed like a failure). clef answers yes a bit
// lower (0.75+), so it reports more "uncertain" items.
export const PASS_THRESHOLD = 0.85;
export const FAIL_THRESHOLD = 0.3;
/** Judge connection: the AI TOOL Ollama URL when the chat backend is Ollama, else the default. */
export function getJudgeConfig(aiSettings = {}) {
const baseUrl = aiSettings.backend === "ollama" && aiSettings.backendUrl
? aiSettings.backendUrl
: OLLAMA_DEFAULT_URL;
return {
baseUrl: baseUrl.replace(/\/+$/, ""),
model: aiSettings.chatJudgeModel || DEFAULT_JUDGE_MODEL,
autoRounds: Math.max(0, Math.min(3, parseInt(aiSettings.chatCheckAutoRounds, 10) || 0)),
};
}
/**
* Ollama decision models (capabilities include "decision"), vision-capable ones first.
* Returns [{ name, vision }]. Throws if Ollama can't be reached.
*/
export async function listJudgeModels(baseUrl) {
const url = (baseUrl || OLLAMA_DEFAULT_URL).replace(/\/+$/, "");
const res = await fetch(`${url}/api/tags`);
if (!res.ok) throw new Error(`HTTP ${res.status}`);
const data = await res.json();
const names = (data.models || [])
.filter((m) => Array.isArray(m.capabilities) && m.capabilities.includes("decision"))
.map((m) => m.name);
const out = await Promise.all(names.map(async (name) => {
try {
const r = await fetch(`${url}/api/show`, {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({ model: name }),
});
const d = r.ok ? await r.json() : {};
const vision = (Array.isArray(d.capabilities) && d.capabilities.includes("vision"))
|| !!(d.projector_info && Object.keys(d.projector_info).length);
return { name, vision };
} catch {
return { name, vision: false };
}
}));
return out.sort((a, b) => (b.vision - a.vision) || a.name.localeCompare(b.name));
}
// ---------------------------------------------------------------------------
// Checklist
// ---------------------------------------------------------------------------
const CHECKLIST_SCHEMA = {
type: "object",
properties: {
items: {
type: "array",
items: {
type: "object",
properties: {
question: { type: "string" },
label: { type: "string" },
expect: { type: "string", enum: ["yes", "no"] },
},
required: ["question", "label", "expect"],
},
},
},
required: ["items"],
};
const CHECKLIST_SYSTEM = `You turn an image request into a short visual checklist for an image-judging model.
Return JSON only: {"items":[{"question":"...","label":"...","expect":"yes"}]}
Rules:
- 3 to 8 items, one concrete requirement per item.
- "question": an English yes/no question that can be answered by looking at the image alone. Always name who or what it is about (e.g. "Is the girl wearing a white dress?", never "Is someone wearing a white dress?"). For positions, name both sides (e.g. "Is the white rabbit between the boy and the girl?").
- "expect": "yes" when YES means the requirement is met.
- The judging model often mixes up which person has which attribute. So when the request has two or more people or animals with different attributes, add up to 2 swap-check items with "expect": "no" that ask whether the attribute is on the WRONG one (e.g. the boy should wear the green hat -> "Is the girl wearing a green hat?" with "expect": "no").
- "label": the requirement as a very short phrase in the language of the user's request, including who it is about (e.g. "男の子の緑の帽子", "帽子は女の子ではない").
- Only check visible things the user actually asked for: subject and count, key attributes and colors, clothing, pose or action, setting, time of day or lighting, text that must appear.
- Never check image quality, art style quality, or details the user did not ask for.`;
/** Pull the first JSON object out of a model reply (code fences / prose tolerated). */
export function parseChecklist(text) {
if (!text) return [];
let data = null;
const start = text.indexOf("{");
const end = text.lastIndexOf("}");
if (start >= 0 && end > start) {
try { data = JSON.parse(text.slice(start, end + 1)); } catch { data = null; }
}
const items = Array.isArray(data?.items) ? data.items : [];
return items
.map((it) => (typeof it === "string" ? { question: it, label: it } : it))
.filter((it) => it && typeof it.question === "string" && it.question.trim())
.map((it) => ({
question: it.question.trim().slice(0, 300),
label: String(it.label || it.question).trim().slice(0, 80),
expect: String(it.expect || "yes").toLowerCase() === "no" ? "no" : "yes",
}))
.slice(0, 8);
}
/**
* Ask the chat LLM for the checklist. `chat(messages, extraSettings)` must return the reply text.
* Falls back to one whole-prompt question if the model returns nothing usable.
*/
export async function buildChecklist(chat, request, prompt) {
const user = `User request: ${request || "(none)"}\nPrompt used for generation: ${prompt || "(none)"}`;
let items = [];
try {
const text = await chat(
[{ role: "system", content: CHECKLIST_SYSTEM }, { role: "user", content: user }],
{ format: CHECKLIST_SCHEMA, temperature: 0.2, thinkingMode: false },
);
items = parseChecklist(text);
} catch { /* fall through to the fallback below */ }
if (items.length === 0) {
const desc = (request || prompt || "").replace(/\s+/g, " ").slice(0, 300);
items = [{ question: `Does the image match this description: "${desc}"?`, label: desc.slice(0, 40), expect: "yes" }];
}
return items;
}
// ---------------------------------------------------------------------------
// Judging
// ---------------------------------------------------------------------------
/** Image URL / data URL → JPEG base64 (no prefix), downscaled so the longest side is <= maxSide. */
export async function imageUrlToJpegBase64(src, maxSide = 768) {
const img = await new Promise((resolve, reject) => {
const el = new Image();
el.onload = () => resolve(el);
el.onerror = () => reject(new Error("image load failed"));
el.src = src;
});
const scale = Math.min(1, maxSide / Math.max(img.naturalWidth || 1, img.naturalHeight || 1));
const canvas = document.createElement("canvas");
canvas.width = Math.max(1, Math.round((img.naturalWidth || maxSide) * scale));
canvas.height = Math.max(1, Math.round((img.naturalHeight || maxSide) * scale));
const ctx = canvas.getContext("2d");
ctx.fillStyle = "#ffffff"; // transparent SVG/PNG areas → white, like a viewer would show
ctx.fillRect(0, 0, canvas.width, canvas.height);
ctx.drawImage(img, 0, 0, canvas.width, canvas.height);
return canvas.toDataURL("image/jpeg", 0.9).split(",")[1] || "";
}
/** SVG markup → JPEG base64 rendered at `size` px (white background, currentColor = black). */
export async function svgToJpegBase64(svgCode, size = 512) {
let markup = svgCode;
// Render at a fixed size even when the SVG has no width/height (viewBox only).
if (!/<svg[^>]*\swidth=/i.test(markup)) markup = markup.replace(/<svg\b/i, `<svg width="${size}" height="${size}"`);
const dataUrl = `data:image/svg+xml;base64,${btoa(unescape(encodeURIComponent(markup)))}`;
return imageUrlToJpegBase64(dataUrl, size);
}
const QUALITY_LEVELS = ["poor", "acceptable", "excellent"];
/**
* Judge one image against the checklist. The first request after ComfyUI generated an image can
* fail while VRAM is still held, so it retries once after 4 s.
* Returns { items: [{ question, label, p, status: "pass"|"uncertain"|"fail" }], quality, ms }.
*/
export async function judgeImage(imageBase64, items, cfg, { withQuality = true } = {}) {
const questions = {};
items.forEach((it, i) => { questions[`q${i + 1}`] = noul(it.question); });
if (withQuality) questions.quality = score("Overall visual quality of the image", QUALITY_LEVELS);
const opts = { backend: "ollama", baseUrl: cfg.baseUrl, model: cfg.model };
const started = performance.now();
let answers;
try {
answers = await decide("A generated image to be checked against the user's requirements.", questions, opts, [imageBase64]);
} catch (e) {
await new Promise((r) => setTimeout(r, 4000));
answers = await decide("A generated image to be checked against the user's requirements.", questions, opts, [imageBase64]);
}
const results = items.map((it, i) => {
const p = answers[`q${i + 1}`]?.noul;
const raw = typeof p === "number" ? p : 0;
// "expect: no" items (swap checks) are met when the answer is NO
const prob = it.expect === "no" ? 1 - raw : raw;
const status = prob >= PASS_THRESHOLD ? "pass" : prob < FAIL_THRESHOLD ? "fail" : "uncertain";
return { ...it, p: prob, status };
});
let quality = null;
if (withQuality && answers.quality) {
const probs = answers.quality.probabilities || {};
let best = null, bestP = -1;
for (const [k, v] of Object.entries(probs)) if (v > bestP) { best = Number(k); bestP = v; }
quality = { level: best, label: QUALITY_LEVELS[best] ?? null, value: answers.quality.score };
}
return { items: results, quality, ms: Math.round(performance.now() - started) };
}
export function failedItems(result) {
return (result?.items || []).filter((it) => it.status !== "pass");
}
// ---------------------------------------------------------------------------
// SVG part list ("Parts: body, head (circle), beak" line written by the SVG skill)
// ---------------------------------------------------------------------------
export function parseSvgParts(text) {
const m = (text || "").match(/^\s*\**parts?\**\s*:\s*(.+)$/im);
if (!m) return [];
// Split on commas outside parentheses, then drop "(how it is drawn)" notes.
const parts = [];
let depth = 0, cur = "";
for (const ch of m[1]) {
if (ch === "(") depth++;
if (ch === ")") depth = Math.max(0, depth - 1);
if ((ch === "," || ch === ";") && depth === 0) { parts.push(cur); cur = ""; } else cur += ch;
}
parts.push(cur);
return parts
.map((p) => p.replace(/\([^)]*\)/g, "").replace(/[.*_`]/g, "").replace(/\s+/g, " ").trim())
.filter((p) => p && p.length <= 40)
.slice(0, 7);
}
/** Checklist for a rendered SVG: one question per part plus "is it recognisable as <request>". */
export function svgChecklist(parts, request) {
const items = parts.map((p) => ({ question: `Does the drawing clearly show a ${p}?`, label: p, expect: "yes" }));
const subject = (request || "").replace(/\s+/g, " ").trim().slice(0, 200);
if (subject) items.unshift({ question: `Is this drawing recognizable as: "${subject}"?`, label: subject.slice(0, 40), expect: "yes" });
return items.slice(0, 8);
}
// ---------------------------------------------------------------------------
// Result card
// ---------------------------------------------------------------------------
const STATUS_ICON = { pass: "✔", uncertain: "?", fail: "✘" };
/**
* Render the judgement as a chat card. `actions` = [{ label, primary, onClick(btn) }].
* Returns the card element.
*/
export function renderCheckCard(result, { model, round = 0, actions = [] } = {}) {
const card = document.createElement("div");
card.className = "wfm-ai-check-card";
const failed = failedItems(result);
const head = failed.length === 0 ? t("aiChatCheckPassed") : t("aiChatCheckFailedCount", failed.length);
const roundText = round > 0 ? ` · ${t("aiChatCheckRound", round)}` : "";
card.innerHTML = `
<div class="wfm-ai-check-head ${failed.length ? "is-fail" : "is-pass"}">
<span>${escapeHtml(head)}</span>
<span class="wfm-ai-check-meta">${escapeHtml(t("aiChatCheckBy", model))}${escapeHtml(roundText)} · ${(result.ms / 1000).toFixed(1)}s</span>
</div>
<ul class="wfm-ai-check-list">
${result.items.map((it) => `
<li class="wfm-ai-check-item is-${it.status}" title="${escapeHtml(it.question)}">
<span class="wfm-ai-check-icon">${STATUS_ICON[it.status]}</span>
<span class="wfm-ai-check-label">${escapeHtml(it.label)}</span>
<span class="wfm-ai-check-p">${Math.round(it.p * 100)}%</span>
</li>`).join("")}
</ul>
${result.quality?.label ? `<div class="wfm-ai-check-quality">${escapeHtml(t("aiChatCheckQuality", t(`aiChatCheckQuality_${result.quality.label}`)))}</div>` : ""}
`;
if (actions.length) {
const row = document.createElement("div");
row.className = "wfm-ai-chat-msg-actions";
for (const a of actions) {
const btn = document.createElement("button");
btn.className = `wfm-btn wfm-btn-sm${a.primary ? " wfm-btn-primary" : ""}`;
btn.textContent = a.label;
btn.addEventListener("click", () => a.onClick(btn));
row.appendChild(btn);
}
card.appendChild(row);
}
return card;
}
+110
View File
@@ -0,0 +1,110 @@
/**
* chat-markdown.js — tiny, dependency-free Markdown renderer for AI TOOL Chat replies.
*
* Safety model: the whole input is HTML-escaped FIRST, then a small set of Markdown constructs is
* turned into tags. No raw HTML from the model ever reaches the DOM, links are not rendered as
* anchors (the model's URLs stay plain text), and images are never loaded. This keeps the
* existing guarantees of the chat (it showed replies with textContent before) while making long
* structured answers (lists, headings, code blocks) readable.
*
* Supported: fenced code blocks (```lang), inline `code`, **bold**, *italic*, # headings (h1-h4
* rendered as h4-h6-ish sizes), - / * / 1. lists (one level), > quotes, --- rules, paragraphs and
* line breaks. Anything else is left as escaped text.
*/
function escapeHtml(s) {
return String(s)
.replace(/&/g, "&amp;")
.replace(/</g, "&lt;")
.replace(/>/g, "&gt;")
.replace(/"/g, "&quot;")
.replace(/'/g, "&#39;");
}
// Inline formatting on already-escaped text. Code spans are cut out first so their content is
// not touched by the bold/italic rules.
function renderInline(escaped) {
const codes = [];
let s = escaped.replace(/`([^`\n]+)`/g, (_, c) => {
codes.push(c);
return `\u0000${codes.length - 1}\u0000`;
});
s = s.replace(/\*\*([^*\n]+)\*\*/g, "<strong>$1</strong>");
s = s.replace(/__([^_\n]+)__/g, "<strong>$1</strong>");
s = s.replace(/(^|[^*\w])\*(?=\S)([^*\n]*?\S)\*(?!\w)/g, "$1<em>$2</em>");
s = s.replace(/\u0000(\d+)\u0000/g, (_, i) => `<code>${codes[Number(i)]}</code>`);
return s;
}
/** Markdown text → safe HTML string. */
export function renderMarkdown(text) {
const lines = String(text || "").replace(/\r\n?/g, "\n").split("\n");
const out = [];
let para = [];
let list = null; // { tag: "ul"|"ol", items: [], start }
const flushPara = () => {
if (para.length) {
out.push(`<p>${para.map((l) => renderInline(escapeHtml(l))).join("<br>")}</p>`);
para = [];
}
};
const flushList = () => {
if (list) {
const start = list.tag === "ol" && list.start > 1 ? ` start="${list.start}"` : "";
out.push(`<${list.tag}${start}>${list.items.map((i) => `<li>${renderInline(escapeHtml(i))}</li>`).join("")}</${list.tag}>`);
list = null;
}
};
for (let i = 0; i < lines.length; i++) {
const line = lines[i];
const fence = line.match(/^\s*```\s*([\w+-]*)\s*$/);
if (fence) {
flushPara(); flushList();
const lang = fence[1] || "";
const body = [];
i++;
while (i < lines.length && !/^\s*```\s*$/.test(lines[i])) { body.push(lines[i]); i++; }
const label = lang ? `<span class="wfm-md-code-lang">${escapeHtml(lang)}</span>` : "";
out.push(`<pre class="wfm-md-pre">${label}<code>${escapeHtml(body.join("\n"))}</code></pre>`);
continue;
}
if (!line.trim()) { flushPara(); flushList(); continue; }
const heading = line.match(/^\s*(#{1,4})\s+(.+)$/);
if (heading) {
flushPara(); flushList();
const level = Math.min(6, heading[1].length + 2); // # -> h3 ... #### -> h6
out.push(`<h${level} class="wfm-md-h">${renderInline(escapeHtml(heading[2]))}</h${level}>`);
continue;
}
if (/^\s*(-{3,}|\*{3,}|_{3,})\s*$/.test(line)) { flushPara(); flushList(); out.push("<hr>"); continue; }
if (line.trim().startsWith(">")) {
flushPara(); flushList();
out.push(`<blockquote>${renderInline(escapeHtml(line.trim().replace(/^>\s?/, "")))}</blockquote>`);
continue;
}
const ul = line.match(/^\s*[-*+]\s+(.+)$/);
const ol = line.match(/^\s*(\d+)[.)]\s+(.+)$/);
if (ul || ol) {
flushPara();
const tag = ul ? "ul" : "ol";
if (list && list.tag !== tag) flushList();
// A numbered list interrupted by bullets keeps counting from the source number
if (!list) list = { tag, items: [], start: ol ? Math.min(Number(ol[1]) || 1, 9999) : 1 };
list.items.push(ul ? ul[1] : ol[2]);
continue;
}
flushList();
para.push(line);
}
flushPara(); flushList();
return out.join("");
}
+4 -4
View File
@@ -211,9 +211,9 @@ export const comfyUI = {
},
// Generation
async queuePrompt(workflow, extraData = null) {
async queuePrompt(workflow, extraData = null, { quietVram = false } = {}) {
// Settings tab "VRAM Management": unload Ollama models to free VRAM (no-op when off, never throws)
await prepareVramForGeneration();
await prepareVramForGeneration({ quiet: quietVram });
const body = {
prompt: workflow,
client_id: this.clientId,
@@ -349,7 +349,7 @@ export const comfyUI = {
// High-level generate
async generate(workflow, options = {}) {
const { seedMode = "random", seedValue = -1, onProgress, onComplete, onError, timeoutMs } = options;
const { seedMode = "random", seedValue = -1, onProgress, onComplete, onError, timeoutMs, quietVram = false } = options;
this.generating = true;
try {
@@ -379,7 +379,7 @@ export const comfyUI = {
}
// Queue prompt — pass workflow as extra_pnginfo so SaveImage embeds it in PNG metadata
const result = await this.queuePrompt(workflow, { extra_pnginfo: { workflow } });
const result = await this.queuePrompt(workflow, { extra_pnginfo: { workflow } }, { quietVram });
this.currentPromptId = result.prompt_id;
// Track progress
+112 -1
View File
@@ -3,10 +3,12 @@
*/
import { comfyUI } from "./comfyui-client.js";
import { comfyWorkflow } from "./comfyui-workflow.js";
import { syncJsonHighlight } from "./json-highlight.js";
import { t } from "./i18n.js";
import { escapeHtml, setupSearchClearBtn } from "./util.js";
import { showToast } from "./app.js";
import { translateButtonsHtml, attachTranslateButtons } from "./prompt-translate.js";
// ── Latent Image preset state ─────────────────────────────
const _LATENT_PRESET_KEY = "wfm_latent_presets";
@@ -315,6 +317,104 @@ function _syncStackToggleAll(stackModels) {
cb.indeterminate = !allOn && !allOff;
}
// Two-option combos that are really an on/off switch (KSamplerAdvanced add_noise, DWPreprocessor
// detect_*, ...): [on value, off value], compared case-insensitively.
const _TOGGLE_COMBO_PAIRS = [["enable", "disable"], ["enabled", "disabled"], ["on", "off"], ["true", "false"], ["yes", "no"]];
function _comboOptions(spec) {
if (Array.isArray(spec?.[0])) return spec[0];
if (spec?.[0] === "COMBO" && Array.isArray(spec[1]?.options)) return spec[1].options;
return null;
}
/** [onValue, offValue] in the node's own spelling when the combo is an on/off pair, else null */
function _toggleComboValues(spec) {
const opts = _comboOptions(spec);
if (!opts || opts.length !== 2 || !opts.every((o) => typeof o === "string")) return null;
const lower = opts.map((o) => o.toLowerCase());
for (const [on, off] of _TOGGLE_COMBO_PAIRS) {
const iOn = lower.indexOf(on), iOff = lower.indexOf(off);
if (iOn >= 0 && iOff >= 0) return [opts[iOn], opts[iOff]];
}
return null;
}
function _compareNodeIds(a, b) {
const x = String(a).split(":").map(Number), y = String(b).split(":").map(Number);
for (let i = 0; i < Math.max(x.length, y.length); i++) {
const d = (x[i] ?? -1) - (y[i] ?? -1);
if (d) return d;
}
return 0;
}
/**
* On/off items of the API workflow for the Settings tab's Switches column: every literal
* true/false input (ComfySwitchNode switch, PrimitiveBoolean value, TextGenerate thinking, ...)
* plus string combos whose only two options are an on/off pair (needs object_info). Linked
* inputs are arrays and never match; their source node shows up instead.
*/
function _collectSwitchInputs(workflow, objectInfo = {}) {
const out = [];
for (const [id, node] of Object.entries(workflow || {})) {
if (!node?.class_type || !node.inputs) continue;
const info = objectInfo[node.class_type]?.input || {};
for (const [key, value] of Object.entries(node.inputs)) {
const base = { id, type: node.class_type, title: node._meta?.title || node.class_type, key };
if (typeof value === "boolean") {
out.push({ ...base, on: value, onValue: true, offValue: false });
} else if (typeof value === "string") {
const pair = _toggleComboValues(info.required?.[key] || info.optional?.[key]);
if (pair && (value === pair[0] || value === pair[1])) {
out.push({ ...base, on: value === pair[0], onValue: pair[0], offValue: pair[1] });
}
}
}
}
return out.sort((a, b) => _compareNodeIds(a.id, b.id));
}
let _switchRenderSeq = 0;
/** Fill the Switches column. Booleans show at once; on/off combos follow once object_info is in. */
async function _renderSwitchColumn(col) {
if (!col) return;
const seq = ++_switchRenderSeq;
const workflow = comfyUI.currentWorkflow;
const draw = (items) => {
col.innerHTML = items.length ? `<div class="wfm-settings-switches">${items.map((s, i) => `
<label class="wfm-settings-switch" title="${escapeHtml(`#${s.id} ${s.type} › ${s.key}`)}">
<input type="checkbox" class="wfm-settings-switch-cb" data-index="${i}" ${s.on ? "checked" : ""}>
<span class="wfm-settings-switch-text">
<span class="wfm-settings-switch-node">${escapeHtml(s.title)}</span>
<span class="wfm-settings-switch-key">${escapeHtml(s.key)}</span>
</span>
<span class="wfm-settings-switch-state">${escapeHtml(String(s.on ? s.onValue : s.offValue))}</span>
</label>`).join("")}
</div>` : `<p class="wfm-placeholder">${t("genSwitchesNone")}</p>`;
// Applies immediately (no Apply button): written straight into the API workflow Generate sends
col.querySelectorAll(".wfm-settings-switch-cb").forEach((cb) => {
cb.addEventListener("change", () => {
const s = items[Number(cb.dataset.index)];
const node = comfyUI.currentWorkflow?.[s.id];
if (!node?.inputs || !(s.key in node.inputs) || Array.isArray(node.inputs[s.key])) return;
s.on = cb.checked;
node.inputs[s.key] = s.on ? s.onValue : s.offValue;
const state = cb.closest(".wfm-settings-switch")?.querySelector(".wfm-settings-switch-state");
if (state) state.textContent = String(node.inputs[s.key]);
_syncRawJson();
});
});
};
draw(_collectSwitchInputs(workflow));
const types = [...new Set(Object.values(workflow || {}).map((n) => n?.class_type).filter(Boolean))];
let objectInfo = {};
try { objectInfo = await comfyWorkflow.getObjectInfoForTypes(types); } catch {}
// A newer render (another workflow loaded meanwhile) owns the column now
if (seq !== _switchRenderSeq || workflow !== comfyUI.currentWorkflow || !col.isConnected) return;
draw(_collectSwitchInputs(workflow, objectInfo));
}
/** Sync comfyUI.currentWorkflow to Raw JSON textarea + highlight */
function _syncRawJson() {
const rawTextarea = document.getElementById("wfm-gen-raw-json");
@@ -546,6 +646,7 @@ export const comfyEditor = {
${nodeOpts}
</select>
<button class="wfm-btn wfm-btn-sm" id="wfm-prompt-pos-revert" title="${t("revertPromptTitle")}">↺</button>
${translateButtonsHtml("wfm-prompt-pos-text")}
<button class="wfm-btn wfm-btn-sm" id="wfm-prompt-pos-apply" title="Apply (Alt+Click: Apply &amp; Generate)">Apply</button>
</div>
<textarea class="wfm-textarea" id="wfm-prompt-pos-text" rows="6">${positiveNodes[0]?.text || ""}</textarea>
@@ -558,6 +659,7 @@ export const comfyEditor = {
${nodeOpts}
</select>
<button class="wfm-btn wfm-btn-sm" id="wfm-prompt-neg-revert" title="${t("revertPromptTitle")}">↺</button>
${translateButtonsHtml("wfm-prompt-neg-text")}
<button class="wfm-btn wfm-btn-sm" id="wfm-prompt-neg-apply">Apply</button>
</div>
<textarea class="wfm-textarea" id="wfm-prompt-neg-text" rows="6">${negativeNodes[0]?.text || ""}</textarea>
@@ -620,6 +722,9 @@ export const comfyEditor = {
ta.value = wfNode.inputs[textKey] ?? "";
});
// 🌐 native-language prompt translation (Settings → Prompt Translation)
attachTranslateButtons(el);
// Track last focused prompt textarea for Paste button
["wfm-prompt-pos-text", "wfm-prompt-neg-text"].forEach((taId) => {
const ta = document.getElementById(taId);
@@ -1514,7 +1619,7 @@ export const comfyEditor = {
<button class="wfm-btn wfm-btn-sm" id="wfm-settings-sampler-apply" title="Apply (Alt+Click: Apply &amp; Generate)">Apply</button>
` : "<p class='wfm-placeholder'>No KSampler node found</p>"}
</div>
<div style="flex:1;min-width:0;padding-left:14px;">
<div style="flex:1;min-width:0;padding:0 14px;border-right:1px solid var(--wfm-border);">
<h3 style="font-size:13px;font-weight:600;text-transform:uppercase;letter-spacing:0.5px;color:var(--wfm-text-secondary);margin:0 0 12px;">Latent Image</h3>
${latent ? `
<input type="hidden" id="wfm-settings-latent-id" value="${latent.id}">
@@ -1559,9 +1664,15 @@ export const comfyEditor = {
</div>
` : "<p class='wfm-placeholder'>No EmptyLatentImage node found</p>"}
</div>
<div style="flex:1;min-width:0;padding-left:14px;">
<h3 style="font-size:13px;font-weight:600;text-transform:uppercase;letter-spacing:0.5px;color:var(--wfm-text-secondary);margin:0 0 12px;">${t("genSwitchesTitle")}</h3>
<div id="wfm-settings-switches-col"></div>
</div>
</div>
`;
_renderSwitchColumn(document.getElementById("wfm-settings-switches-col"));
document.getElementById("wfm-settings-sampler-apply")?.addEventListener("click", (e) => {
const ds = document.getElementById("wfm-settings-sampler-id")?.dataset || {};
const write = (nodeId, key, value) => {
+47 -8
View File
@@ -125,6 +125,12 @@ function _collectNodeTypes(workflow) {
// frontend widgets that occupy a widgets_values slot; sent to the API as {"__value__": [...]}.
const _WIDGET_TYPE_SET = new Set(["INT", "FLOAT", "STRING", "BOOLEAN", "COMBO", "COMFY_DYNAMICCOMBO_V3", "BOUNDING_BOXES"]);
// Required inputs backed by display-only frontend widgets (serialize=false, so no widgets_values
// slot) -> the value the frontend sends for them in the API prompt.
const _DISPLAY_WIDGET_DEFAULTS = {
IMAGECOMPARE: () => ({ __value__: ["", ""] }),
};
/**
* Resolve a possibly-compound object_info type spec (e.g. LTXVEmptyLatentAudio's frame_rate:
* "FLOAT,INT", a MultiType declaration meaning "widget defaults to FLOAT but also accepts an INT
@@ -237,6 +243,13 @@ function _getDynamicComboSubNames(objectInfo, classType, widgetName, selectedKey
];
}
function _isDynamicComboKey(objectInfo, classType, widgetName, value) {
const info = objectInfo[classType];
const spec = info?.input?.required?.[widgetName] || info?.input?.optional?.[widgetName];
const options = spec?.[1]?.options;
return !Array.isArray(options) || options.some((o) => o.key === value);
}
/**
* Detect if a widget value is a frontend-only extra (like "control_after_generate").
* These values appear in widgets_values but are not in object_info inputs.
@@ -371,9 +384,15 @@ function _normalizeLinkedWidgetValues(objectInfo, nodeType, widgetsValues, isLin
const comboExpander = (name, selectedKey) => _getDynamicComboSubNames(objectInfo, nodeType, name, selectedKey);
// If skipping linked widgets already accounts for every entry, widgets_values is already in
// the modern (no dangling linked entries) format — nothing to strip.
// the modern (no dangling linked entries) format — nothing to strip. The count alone can match
// by accident: TextGenerateV2 ["", 1536, "off", true, true, "auto"] with prompt linked reads
// 1536 as sampling_mode, which falls back to the first option and swallows the rest. A selector
// that doesn't hold one of its option keys means this reading is misaligned.
const skipSim = _simulateWidgetValues(widgetNames, widgetTypes, widgetsValues, isLinkedName, true, comboExpander);
if (skipSim.consumed === widgetsValues.length) return widgetsValues;
const selectorsValid = widgetNames.every((name, i) => widgetTypes[i] !== "COMFY_DYNAMICCOMBO_V3"
|| skipSim.positions[name] < 0
|| _isDynamicComboKey(objectInfo, nodeType, name, widgetsValues[skipSim.positions[name]]));
if (skipSim.consumed === widgetsValues.length && selectorsValid) return widgetsValues;
// Otherwise it's "legacy full": recompute with every widget present to find exactly which
// indices the linked ones occupy — including any control_after_generate extra a linked
@@ -985,6 +1004,15 @@ export const comfyWorkflow = {
}
}
// Display-only frontend widgets (ImageCompare's socketless compare_view) are never
// stored in widgets_values, yet the backend requires them. The frontend sends the
// widget's initial value, so do the same.
for (const [k, spec] of Object.entries(objectInfo[node.type]?.input?.required || {})) {
if (!(k in inputs) && _DISPLAY_WIDGET_DEFAULTS[spec?.[0]]) {
inputs[k] = _DISPLAY_WIDGET_DEFAULTS[spec[0]]();
}
}
api[nodeId] = {
class_type: node.type,
inputs,
@@ -1271,8 +1299,10 @@ export const comfyWorkflow = {
// "prompt" (prompt-enhancer switch chain, Qwen Image 2.1 Turbo) is the positive text,
// a linked "negative_prompt" the negative.
// TextEncodeFibo2 (Fibo 2.0 Edit) has the same shape, its prompt arriving via a
// PreviewAny -> prompt-enhancer switch chain.
if (ct === "TextEncodeQwenImage21" || ct === "TextEncodeFibo2") {
// PreviewAny -> prompt-enhancer switch chain. PH3ImageConditioning (p-h3-image) and
// MiniMaxH3ImageConditioning (MiniMax-H3-Image) too, without a negative prompt.
if (ct === "TextEncodeQwenImage21" || ct === "TextEncodeFibo2" || ct === "PH3ImageConditioning"
|| ct === "MiniMaxH3ImageConditioning") {
if (Array.isArray(inputs.prompt)) samplerPositiveRef[inputs.prompt[0]] = true;
if (Array.isArray(inputs.negative_prompt)) samplerNegativeRef[inputs.negative_prompt[0]] = true;
}
@@ -1519,7 +1549,10 @@ export const comfyWorkflow = {
// nodes already picked up generically by the load_image_nodes pass below.
// TextEncodeFibo2 (Fibo 2.0) — same prompt/negative_prompt/images.image_N shape; its
// negative_prompt is a structured VGL JSON caption (edited as plain text here).
if (ct === "TextEncodeQwenImage21" || ct === "TextEncodeFibo2") {
// PH3ImageConditioning (p-h3-image) and MiniMaxH3ImageConditioning (MiniMax-H3-Image) have
// prompt and images.image_N, no negative_prompt.
if (ct === "TextEncodeQwenImage21" || ct === "TextEncodeFibo2" || ct === "PH3ImageConditioning"
|| ct === "MiniMaxH3ImageConditioning") {
if (typeof inputs.prompt === "string") {
result.prompt_nodes.push({
id, type: ct, title: `${title} [positive]`, role: "positive",
@@ -1701,8 +1734,11 @@ export const comfyWorkflow = {
// width/height are commonly wired to a ResolutionSelector-style helper node
// (array link ref) rather than a direct number — leave those as undefined so
// the settings-tab UI falls back to its default instead of rendering a link ref.
// TextEncodeFibo2 likewise (0 = Fibo 2.0's trained size for the first image's aspect).
if (ct === "TextEncodeMageFlowEdit" || ct === "TextEncodeFibo2") {
// TextEncodeFibo2 likewise (0 = Fibo 2.0's trained size for the first image's aspect),
// PH3ImageConditioning (0 = image_1's size, or 2912 without images) and
// MiniMaxH3ImageConditioning (0 = image_1's size, or 2048 without images).
if (ct === "TextEncodeMageFlowEdit" || ct === "TextEncodeFibo2" || ct === "PH3ImageConditioning"
|| ct === "MiniMaxH3ImageConditioning") {
result.latent_nodes.push({
id, type: ct, title,
width: typeof inputs.width === "number" ? inputs.width : undefined,
@@ -1927,7 +1963,8 @@ function _unifyPromptEnhancerText(api) {
const tgRef = sw.inputs.on_true;
if (!Array.isArray(tgRef)) continue;
const tg = api[String(tgRef[0])];
if (tg?.class_type !== "TextGenerate" || tg.inputs.prompt !== sw.inputs.on_false) continue;
if ((tg?.class_type !== "TextGenerate" && tg?.class_type !== "TextGenerateV2")
|| tg.inputs.prompt !== sw.inputs.on_false) continue;
const primId = `${swId}:wfs_prompt`;
api[primId] = {
class_type: "PrimitiveStringMultiline",
@@ -1976,6 +2013,8 @@ function _getWidgetMapping(nodeType) {
WFS_PromptText: ["positive", "negative"],
TextEncodeQwenImage21: ["prompt", "negative_prompt", "resolution"],
TextEncodeFibo2: ["prompt", "negative_prompt", "width", "height", "batch_size"],
PH3ImageConditioning: ["prompt", "width", "height"],
MiniMaxH3ImageConditioning: ["prompt", "width", "height"],
TextEncodeMingImageEdit: ["prompt"],
EmptyQwenImageLayeredLatentImage: ["width", "height", "layers", "batch_size"],
};
+431
View File
@@ -0,0 +1,431 @@
/**
* Gallery 3D viewer: glb / gltf / vrm / ply (mesh, point cloud, Gaussian splat) / spz.
*
* three.js is loaded the first time a 3D file is shown (static/lib/three-viewer).
* The server has no 3D renderer, so thumbnails are rendered here and uploaded
* (see ensureModelThumb); until then /thumb returns 404 and the card shows a placeholder.
*/
import { t } from "./i18n.js";
const LIB_URL = "/wfm_static/lib/three-viewer/three-viewer.js";
const DRACO_PATH = "/wfm_static/lib/three-viewer/draco/";
// Sentinel base for relative URIs in .gltf files; rewritten to the asset route on load.
const ASSET_BASE = "/__wfm3d__/";
const BACKGROUND = 0x181c26;
const THUMB_SIZE = 512;
const THUMB_TIMEOUT_MS = 60_000;
// Larger files only get a thumbnail when opened, not while scrolling the grid.
const AUTO_THUMB_MAX_BYTES = 128 * 1024 * 1024;
// Splats are sorted asynchronously and spring bones settle over time, so keep drawing
// for a while after each change instead of only once.
const SETTLE_FRAMES = 60;
const MODEL3D_EXTENSIONS = [".glb", ".gltf", ".vrm", ".ply", ".spz"];
export function isModel3dFile(img) {
const source = (img?.ext || img?.filename || img?.path || "").toLowerCase();
return MODEL3D_EXTENSIONS.some((ext) => source.endsWith(ext));
}
export function model3dExtLabel(img) {
const source = (img?.ext || img?.filename || img?.path || "").toLowerCase();
return (MODEL3D_EXTENSIONS.find((ext) => source.endsWith(ext)) || "").slice(1).toUpperCase();
}
let _libPromise = null;
function loadLib() {
if (!_libPromise) {
_libPromise = import(LIB_URL).catch((e) => {
_libPromise = null;
throw e;
});
}
return _libPromise;
}
const serveUrl = (path) => `/wfm/gallery/image/serve?path=${encodeURIComponent(path)}`;
const assetUrl = (path, uri) => `/wfm/gallery/model3d/asset?path=${encodeURIComponent(path)}&uri=${encodeURIComponent(uri)}`;
async function fetchBytes(url, signal, onProgress) {
const res = await fetch(url, { signal });
if (!res.ok) throw new Error(`HTTP ${res.status}`);
const total = Number(res.headers.get("Content-Length")) || 0;
if (!total || !res.body || !onProgress) return res.arrayBuffer();
const out = new Uint8Array(total);
const reader = res.body.getReader();
let received = 0;
for (;;) {
const { done, value } = await reader.read();
if (done) break;
out.set(value, received);
received += value.length;
onProgress(received / total);
}
return out.buffer.slice(0, received);
}
// 3DGS exports are .ply too; they are told apart by their per-splat properties.
function isSplatPly(buffer) {
const head = new TextDecoder("latin1").decode(new Uint8Array(buffer, 0, Math.min(buffer.byteLength, 8192)));
const end = head.indexOf("end_header");
const header = end >= 0 ? head.slice(0, end) : head;
return /property\s+\w+\s+f_dc_0\b/.test(header) || /property\s+\w+\s+scale_0\b/.test(header);
}
function countGeometry(root) {
let vertices = 0;
let triangles = 0;
root.traverse((o) => {
const g = o.geometry;
if (!g?.attributes?.position) return;
vertices += g.attributes.position.count;
if (o.isMesh) triangles += (g.index ? g.index.count : g.attributes.position.count) / 3;
});
return { vertices, triangles: Math.round(triangles) };
}
async function loadGltf(lib, img, buffer, isVrm) {
const manager = new lib.THREE.LoadingManager();
manager.setURLModifier((url) => (url.startsWith(ASSET_BASE) ? assetUrl(img.path, url.slice(ASSET_BASE.length)) : url));
const loader = new lib.GLTFLoader(manager);
const draco = new lib.DRACOLoader(manager).setDecoderPath(DRACO_PATH);
loader.setDRACOLoader(draco);
loader.setMeshoptDecoder(lib.MeshoptDecoder);
if (isVrm) loader.register((parser) => new lib.VRMLoaderPlugin(parser));
let gltf;
try {
gltf = await loader.parseAsync(buffer, ASSET_BASE);
} finally {
draco.dispose();
}
const vrm = gltf.userData?.vrm;
if (vrm) lib.VRMUtils.rotateVRM0(vrm); // VRM 0.x faces -Z
const object = vrm ? vrm.scene : gltf.scene;
const mixer = gltf.animations?.length ? new lib.THREE.AnimationMixer(object) : null;
if (mixer) mixer.clipAction(gltf.animations[0]).play();
return {
object,
animated: !!mixer,
settles: !!vrm,
update: (dt) => { mixer?.update(dt); vrm?.update(dt); },
stats: countGeometry(object),
};
}
function loadPlyGeometry(lib, buffer) {
const { THREE } = lib;
const geometry = new lib.PLYLoader().parse(buffer);
// "property double" (e.g. Open3D) comes back as a Float64Array, which WebGL rejects.
for (const [name, attr] of Object.entries(geometry.attributes)) {
if (attr.array instanceof Float64Array) {
geometry.setAttribute(name, new THREE.BufferAttribute(Float32Array.from(attr.array), attr.itemSize, attr.normalized));
}
}
const hasColor = !!geometry.attributes.color;
if (!geometry.index) {
geometry.computeBoundingSphere();
const material = new THREE.PointsMaterial({
size: geometry.boundingSphere.radius / 300,
vertexColors: hasColor,
color: hasColor ? 0xffffff : 0xb8c0cc,
});
const object = new THREE.Points(geometry, material);
return { object, stats: countGeometry(object) };
}
if (!geometry.attributes.normal) geometry.computeVertexNormals();
const material = new THREE.MeshStandardMaterial({
vertexColors: hasColor,
color: hasColor ? 0xffffff : 0xb8c0cc,
roughness: 0.7,
side: THREE.DoubleSide,
});
const object = new THREE.Mesh(geometry, material);
return { object, stats: countGeometry(object) };
}
async function loadSplat(lib, stage, img, buffer) {
const { SparkRenderer, SplatMesh } = await lib.loadSpark();
const spark = new SparkRenderer({ renderer: stage.renderer });
stage.scene.add(spark);
const mesh = new SplatMesh({ fileBytes: new Uint8Array(buffer), fileName: img.filename || img.path });
await mesh.initialized;
mesh.quaternion.set(1, 0, 0, 0); // splats are stored Y-down
return {
object: mesh,
splat: true,
settles: true,
box: mesh.getBoundingBox(true),
stats: { splats: mesh.packedSplats?.numSplats ?? mesh.numSplats ?? 0 },
dispose: () => { mesh.dispose(); spark.dispose(); },
};
}
async function loadInto(lib, stage, img, signal, onProgress) {
const buffer = await fetchBytes(serveUrl(img.path), signal, onProgress);
const name = (img.filename || img.path).toLowerCase();
if (name.endsWith(".spz")) return loadSplat(lib, stage, img, buffer);
if (name.endsWith(".ply")) {
return isSplatPly(buffer) ? loadSplat(lib, stage, img, buffer) : loadPlyGeometry(lib, buffer);
}
return loadGltf(lib, img, buffer, name.endsWith(".vrm"));
}
function createStage(lib, canvas) {
const { THREE } = lib;
const renderer = new THREE.WebGLRenderer({ canvas, antialias: true, preserveDrawingBuffer: false });
renderer.setPixelRatio(Math.min(window.devicePixelRatio || 1, 2));
const scene = new THREE.Scene();
scene.background = new THREE.Color(BACKGROUND);
const pmrem = new THREE.PMREMGenerator(renderer);
const envTarget = pmrem.fromScene(new lib.RoomEnvironment(), 0.04);
pmrem.dispose();
scene.environment = envTarget.texture;
scene.environmentIntensity = 0.8;
const sun = new THREE.DirectionalLight(0xffffff, 1.2);
sun.position.set(2, 4, 3);
scene.add(sun);
const camera = new THREE.PerspectiveCamera(35, 1, 0.01, 1000);
return { renderer, scene, camera, envTarget };
}
function frameObject(lib, stage, model) {
const { THREE } = lib;
const { camera, scene } = stage;
scene.add(model.object);
model.object.updateMatrixWorld(true);
const box = model.box
? model.box.clone().applyMatrix4(model.object.matrixWorld)
: new THREE.Box3().setFromObject(model.object);
if (box.isEmpty()) box.set(new THREE.Vector3(-1, -1, -1), new THREE.Vector3(1, 1, 1));
const center = box.getCenter(new THREE.Vector3());
const radius = Math.max(box.getSize(new THREE.Vector3()).length() / 2, 1e-4);
const distance = (radius / Math.sin(THREE.MathUtils.degToRad(camera.fov / 2))) * 1.05;
camera.near = distance / 500;
camera.far = distance * 50;
camera.position.copy(center).add(new THREE.Vector3(0.35, 0.2, 1).normalize().multiplyScalar(distance));
camera.lookAt(center);
camera.updateProjectionMatrix();
return center;
}
function disposeStage(stage, model) {
try { model?.dispose?.(); } catch { /* already gone */ }
model?.object?.traverse?.((o) => {
o.geometry?.dispose?.();
for (const m of [].concat(o.material || [])) {
for (const v of Object.values(m)) if (v?.isTexture) v.dispose();
m.dispose?.();
}
});
stage.envTarget.dispose();
stage.renderer.dispose();
stage.renderer.forceContextLoss(); // browsers only allow ~16 live contexts
}
function formatStats(stats) {
const n = (v) => Number(v).toLocaleString();
if (stats.splats != null) return t("gallery3dStatsSplats", n(stats.splats));
if (!stats.triangles) return t("gallery3dStatsPoints", n(stats.vertices));
return t("gallery3dStatsMesh", n(stats.vertices), n(stats.triangles));
}
// Center-crop the canvas to a square JPEG. Must run right after render() in the same task,
// because the drawing buffer is not preserved.
function captureJpeg(canvas) {
const out = document.createElement("canvas");
out.width = out.height = THUMB_SIZE;
const side = Math.min(canvas.width, canvas.height);
out.getContext("2d").drawImage(
canvas, (canvas.width - side) / 2, (canvas.height - side) / 2, side, side, 0, 0, THUMB_SIZE, THUMB_SIZE,
);
return out.toDataURL("image/jpeg", 0.85);
}
async function uploadThumb(path, image) {
const res = await fetch("/wfm/gallery/image/thumb3d", {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({ path, image }),
});
return res.ok;
}
/**
* Interactive viewer inside `container`. It disposes itself once `container` leaves the
* DOM, so callers can simply replace or remove the element.
* `onReady(capture)` fires after the model is drawn; capture() returns a thumbnail data URL.
*/
export function mountModelViewer(container, img, { onReady } = {}) {
container.classList.add("wfm-g3d");
container.innerHTML = `
<canvas class="wfm-g3d-canvas"></canvas>
<div class="wfm-g3d-status">${t("gallery3dLoading")}</div>
<div class="wfm-g3d-stats"></div>
<button type="button" class="wfm-g3d-reset" title="${t("gallery3dResetView")}">⟲</button>`;
const canvas = container.querySelector(".wfm-g3d-canvas");
const status = container.querySelector(".wfm-g3d-status");
const statsEl = container.querySelector(".wfm-g3d-stats");
const resetBtn = container.querySelector(".wfm-g3d-reset");
const abort = new AbortController();
let stage = null;
let model = null;
let controls = null;
let resizeObserver = null;
let frameId = 0;
let closed = false;
const close = () => {
if (closed) return;
closed = true;
abort.abort();
cancelAnimationFrame(frameId);
resizeObserver?.disconnect();
controls?.dispose();
if (stage) disposeStage(stage, model);
};
const fail = (e) => {
if (closed || e?.name === "AbortError") return;
console.error("[WFS] 3D viewer:", img.path, e);
status.textContent = t("gallery3dLoadFailed");
status.classList.add("wfm-g3d-status--error");
status.style.display = "";
close();
};
(async () => {
const lib = await loadLib();
if (closed) return;
stage = createStage(lib, canvas);
const { renderer, scene, camera } = stage;
model = await loadInto(lib, stage, img, abort.signal, (p) => {
status.textContent = `${t("gallery3dLoading")} ${Math.round(p * 100)}%`;
});
if (closed) {
disposeStage(stage, model);
return;
}
const center = frameObject(lib, stage, model);
const home = camera.position.clone();
controls = new lib.OrbitControls(camera, canvas);
controls.target.copy(center);
controls.enableDamping = true;
controls.update();
let dirty = SETTLE_FRAMES;
const invalidate = () => { dirty = SETTLE_FRAMES; };
controls.addEventListener("change", invalidate);
resetBtn.addEventListener("click", () => {
camera.position.copy(home);
controls.target.copy(center);
controls.update();
invalidate();
});
const resize = () => {
const w = container.clientWidth;
const h = container.clientHeight;
if (!w || !h) return;
renderer.setSize(w, h, false);
camera.aspect = w / h;
camera.updateProjectionMatrix();
invalidate();
};
resizeObserver = new ResizeObserver(resize);
resizeObserver.observe(container);
resize();
renderer.render(scene, camera); // surface a model that cannot be drawn as a load failure
status.style.display = "none";
statsEl.textContent = formatStats(model.stats);
onReady?.(() => {
renderer.render(scene, camera);
return captureJpeg(canvas);
});
let last = performance.now();
const tick = () => {
if (!container.isConnected) {
close();
return;
}
frameId = requestAnimationFrame(tick);
const now = performance.now();
const dt = (now - last) / 1000;
last = now;
if (!container.clientWidth) return; // hidden tab
controls.update();
if (!model.animated && dirty <= 0) return;
dirty -= 1;
try {
model.update?.(dt);
renderer.render(scene, camera);
} catch (e) {
fail(e);
}
};
tick();
})().catch(fail);
return { close };
}
async function renderThumb(img) {
const lib = await loadLib();
const canvas = document.createElement("canvas");
const stage = createStage(lib, canvas);
stage.renderer.setPixelRatio(1);
stage.renderer.setSize(THUMB_SIZE, THUMB_SIZE, false);
const abort = new AbortController();
const timer = setTimeout(() => abort.abort(), THUMB_TIMEOUT_MS);
let model = null;
try {
model = await loadInto(lib, stage, img, abort.signal);
frameObject(lib, stage, model);
model.update?.(0);
for (let i = 0; model.splat && i < SETTLE_FRAMES; i++) {
stage.renderer.render(stage.scene, stage.camera);
await new Promise((r) => requestAnimationFrame(r));
}
stage.renderer.render(stage.scene, stage.camera);
return captureJpeg(canvas);
} finally {
clearTimeout(timer);
disposeStage(stage, model);
}
}
const _thumbJobs = new Map(); // path -> Promise<boolean>, also remembers failures for this session
let _thumbQueue = Promise.resolve();
/**
* Render and store the thumbnail of a 3D file, one file at a time.
* `isWanted()` is checked when the job's turn comes, so cards scrolled away or replaced by
* a folder change cost nothing. Resolves true once the server has the thumbnail.
*/
export function ensureModelThumb(img, isWanted = () => true) {
if (_thumbJobs.has(img.path)) return _thumbJobs.get(img.path);
if (img.size > AUTO_THUMB_MAX_BYTES) return Promise.resolve(false);
const job = _thumbQueue.then(async () => {
if (!isWanted()) {
_thumbJobs.delete(img.path);
return false;
}
try {
return await uploadThumb(img.path, await renderThumb(img));
} catch (e) {
console.warn("[WFS] 3D thumbnail failed:", img.path, e);
return false;
}
});
_thumbJobs.set(img.path, job);
_thumbQueue = job;
return job;
}
/** Store a thumbnail captured from an open viewer (covers files too large for ensureModelThumb). */
export function saveModelThumb(img, capture) {
const job = uploadThumb(img.path, capture()).catch(() => false);
_thumbJobs.set(img.path, job);
return job;
}
+88 -6
View File
@@ -15,6 +15,7 @@ import { callLLM, loadAiSettings, isValidBackendUrl } from "./ai-tab.js";
import { initImagePromptTab, activateImagePromptTab } from "./image-prompt-tab.js";
import { initStyleCatalogTab, activateStyleCatalogTab } from "./style-catalog-tab.js";
import { applyStoredVideoVolume } from "./settings-tab.js";
import { isModel3dFile, model3dExtLabel, mountModelViewer, ensureModelThumb, saveModelThumb } from "./gallery-3d-viewer.js";
import { initSemantic, refreshSemanticDots, getSemanticMode, isSemanticOn, fetchSemanticImages, semanticCountLabel, setSemanticCountText, semanticErrorMessage, exitSimilarMode } from "./gallery-semantic.js";
// ── 定数 ─────────────────────────────────────────────────────
@@ -80,9 +81,11 @@ export function isAudioFile(img) {
}
// プレビュー/ライトボックス/比較用のメディア要素HTML。音声は波形画像+<audio controls>。
// 3Dは空の枠だけ返し、挿入後に mountModelViewers() がビューアを起動する。
function mediaElementHtml(img, { imgClass, videoAttrs = "controls", audioAttrs = "controls", title = "" }) {
const src = API.serveImage(img.path);
const titleAttr = title ? ` title="${title}"` : "";
if (isModel3dFile(img)) return `<div class="${imgClass} wfm-g3d-box" data-path="${escapeHtml(img.path)}"${titleAttr}></div>`;
if (isVideoFile(img)) return `<video src="${src}" class="${imgClass}" ${videoAttrs}${titleAttr}></video>`;
if (isAudioFile(img)) {
return `<div class="wfm-gallery-audio-box">
@@ -93,6 +96,56 @@ function mediaElementHtml(img, { imgClass, videoAttrs = "controls", audioAttrs =
return `<img src="${src}" class="${imgClass}" alt="${escapeHtml(img.filename)}"${titleAttr}>`;
}
// root内の3D枠でビューアを起動する。枠がDOMから外れるとビューアは自分で破棄される。
function mountModelViewers(root, imgs) {
root.querySelectorAll(".wfm-g3d-box").forEach((box) => {
const img = imgs.find((im) => im.path === box.dataset.path);
if (!img) return;
mountModelViewer(box, img, {
onReady: (capture) => {
// グリッドの自動描画はサイズ上限があるため、開いたときにも保存しておく
if (_modelThumbMissing.delete(img.path)) {
saveModelThumb(img, capture).then((ok) => { if (ok) refreshModelThumb(img.path); });
}
},
});
});
}
// サムネイルが無く、開いたときに保存する3Dファイルのパス
const _modelThumbMissing = new Set();
function refreshModelThumb(path) {
document.querySelectorAll(".wfm-gallery-thumb-img[data-model3d]").forEach((el) => {
if (el.dataset.model3d === path) el.dispatchEvent(new CustomEvent("wfm-model3d-thumb"));
});
}
// サムネイル未作成の3Dファイル: プレースホルダーを出し、描画できたら差し替える
function setupModelThumb(card, imgEl, img) {
imgEl.dataset.model3d = img.path;
const placeholder = document.createElement("div");
placeholder.className = "wfm-gallery-thumb-placeholder";
placeholder.textContent = model3dExtLabel(img);
const show = () => {
placeholder.remove();
imgEl.style.display = "";
imgEl.src = `${API.thumb(img.path)}&t=${Date.now()}`;
};
imgEl.addEventListener("wfm-model3d-thumb", show);
imgEl.onerror = () => {
if (placeholder.isConnected) return;
imgEl.style.display = "none";
card.insertBefore(placeholder, imgEl.nextSibling);
_modelThumbMissing.add(img.path);
ensureModelThumb(img, () => card.isConnected).then((ok) => {
if (!ok) return;
_modelThumbMissing.delete(img.path);
refreshModelThumb(img.path);
});
};
}
// ComfyUI Comic Creater からiframe越しに画像を受け取り、Generate UIのImage入力スロットへ直接セットする(I2I連携)。
// Comic Creater側の「I2Iへ送る」ボタンから
// iframe.contentWindow._wfmReceiveImageForI2I(blob, name, workflowData?, workflowFilename?) として呼ばれる。
@@ -740,13 +793,16 @@ function createThumbCard(img) {
placeholder.textContent = "?";
card.insertBefore(placeholder, imgEl.nextSibling);
};
const isModel3d = isModel3dFile(img);
if (isModel3d) setupModelThumb(card, imgEl, img);
card.appendChild(imgEl);
// 動画ファイルは再生アイコンバッジを重ねて表示(サムネイル自体は先頭フレームのJPEG)
if (isVideoFile(img) || isAudioFile(img)) {
if (isVideoFile(img) || isAudioFile(img) || isModel3d) {
const playBadge = document.createElement("div");
playBadge.className = "wfm-gallery-thumb-video-badge";
playBadge.textContent = isAudioFile(img) ? "♪" : "▶";
playBadge.textContent = isModel3d ? "3D" : isAudioFile(img) ? "♪" : "▶";
playBadge.classList.toggle("wfm-gallery-thumb-video-badge--corner", isModel3d);
card.appendChild(playBadge);
}
@@ -779,7 +835,7 @@ function createThumbCard(img) {
e.stopPropagation();
await toggleFeederGroupInPlace(img, feederBtn);
});
card.appendChild(feederBtn);
if (!isModel3d) card.appendChild(feederBtn); // Feederノードは画像しか読めない
// クリック: 詳細表示 / Ctrl+クリック: 複数選択 / Shift+クリック: 範囲選択 / Alt+クリック: Metadataタブで開く
card.addEventListener("click", (e) => {
@@ -869,6 +925,18 @@ function createTable(images) {
const tdThumb = document.createElement("td");
tdThumb.innerHTML = `<img src="${API.thumb(img.path, 128)}" class="wfm-gallery-table-thumb" loading="lazy" alt="">`;
if (isModel3dFile(img)) {
const thumbEl = tdThumb.firstElementChild;
thumbEl.onerror = () => {
thumbEl.style.visibility = "hidden";
ensureModelThumb(img, () => thumbEl.isConnected).then((ok) => {
if (!ok) return;
thumbEl.onerror = null;
thumbEl.style.visibility = "";
thumbEl.src = `${API.thumb(img.path, 128)}&t=${Date.now()}`;
});
};
}
const tdName = document.createElement("td");
tdName.className = "wfm-gallery-table-name";
@@ -1074,8 +1142,9 @@ async function loadImageDetail(img) {
${mediaElementHtml(img, { imgClass: "wfm-gallery-detail-img", title: "Double-click to enlarge" })}
</div>
`;
const previewMediaEl = preview.querySelector(isVideo ? "video" : "img");
const previewMediaEl = preview.querySelector(isModel3dFile(img) ? ".wfm-g3d-box" : isVideo ? "video" : "img");
previewMediaEl.addEventListener("dblclick", () => openLightbox(img));
mountModelViewers(preview, [img]);
if (isVideo) applyStoredVideoVolume(previewMediaEl);
if (isAudio) applyStoredVideoVolume(preview.querySelector("audio"));
@@ -1870,6 +1939,13 @@ function imageByPath(path) {
return map.get(path);
}
// 画像を前提とする送信先へ3Dファイルを渡さない
function rejectModel3d() {
if (!isModel3dFile(state.selectedImage)) return false;
showToast(t("gallery3dNotImage"), "info");
return true;
}
function isConvertible(img) {
return !!img && (isAudioFile(img) || isVideoFile(img));
}
@@ -2104,6 +2180,7 @@ function openLightbox(img) {
}
});
document.body.appendChild(overlay);
mountModelViewers(overlay, [img]);
if (isVideoFile(img)) applyStoredVideoVolume(overlay.querySelector("video"));
if (isAudioFile(img)) applyStoredVideoVolume(overlay.querySelector("audio"));
}
@@ -2118,7 +2195,7 @@ function openCompare(paths) {
overlay.className = "wfm-gallery-lightbox wfm-lightbox-compare";
const itemsHtml = imgs.map(img => {
const mediaHtml = isAudioFile(img)
const mediaHtml = isAudioFile(img) || isModel3dFile(img)
? mediaElementHtml(img, { imgClass: "wfm-lightbox-compare-img" })
: isVideoFile(img)
? `<video src="${API.serveImage(img.path)}" class="wfm-lightbox-compare-img" controls></video>`
@@ -2143,6 +2220,7 @@ function openCompare(paths) {
}
});
document.body.appendChild(overlay);
mountModelViewers(overlay, imgs);
overlay.querySelectorAll("video, audio").forEach(applyStoredVideoVolume);
}
@@ -2307,6 +2385,7 @@ function bindEvents() {
showToast("Please select an image first", "info");
return;
}
if (rejectModel3d()) return;
if (!window._wfmImageEditTab) return;
const path = state.selectedImage.path;
const name = (state.selectedImage.filename || "gallery-image").replace(/\.[^.]+$/, "");
@@ -2336,6 +2415,7 @@ function bindEvents() {
showToast(t("gallerySelectImageFirst"), "info");
return;
}
if (rejectModel3d()) return;
if (!comfyUI.currentAnalysis) {
showToast(t("noWorkflowLoaded"), "info");
return;
@@ -2373,6 +2453,7 @@ function bindEvents() {
showToast(t("gallerySelectImageFirst"), "info");
return;
}
if (rejectModel3d()) return;
if (!window.opener || typeof window.opener.wfmSendImageToSelectedNode !== "function") {
showToast(t("sendToLiNodeNoOpener"), "error");
return;
@@ -2685,7 +2766,7 @@ function bindEvents() {
if (!window._wfmImageEditTab) return;
const allPaths = [...state.selectedImages];
const paths = allPaths.filter(p => !isVideoFile({ path: p }) && !isAudioFile({ path: p }));
const paths = allPaths.filter(p => !isVideoFile({ path: p }) && !isAudioFile({ path: p }) && !isModel3dFile({ path: p }));
if (paths.length === 0) {
showToast(t("editLayersNoImages"), "error");
return;
@@ -2746,6 +2827,7 @@ function bindEvents() {
showToast(t("gallerySelectImageFirst"), "error");
return;
}
if (rejectModel3d()) return;
const { openImageInTaggerTab } = await import("./tagger-tab.js");
openImageInTaggerTab(state.selectedImage);
});
+622
View File
@@ -0,0 +1,622 @@
/**
* Game タブ (実験的機能)
*
* ゲーム本体は別パッケージ ComfyUI-WFS-Games が配信する。
* GET /wfs_games/manifest が応答したときだけタブを表示する (未インストールなら何もしない)。
* ゲームは manifest の entry を動的 import し、mount(container, host) で起動する。
* ゲームが host.finish(result) で返した報酬プロンプトから、WFS がワークフローを組み立てて生成する。
* ゲームは ComfyUI を直接操作しない。
*
* 契約の詳細は PLAN_GAME_TAB.md / ComfyUI-WFS-Games の README を参照。
*/
import { showToast } from "./app.js";
import { t, getLang } from "./i18n.js";
import { escapeHtml, readJsonStorage } from "./util.js";
import { comfyUI } from "./comfyui-client.js";
import { comfyWorkflow } from "./comfyui-workflow.js";
import { _expandWildcardsInWorkflow } from "./generate-tab.js";
const HOST_API_VERSION = 1;
const MANIFEST_URL = "/wfs_games/manifest";
const ENTRY_PREFIX = "/wfs_games/static/";
const LS_SETTINGS = "wfm_game_settings";
const DEFAULT_SETTINGS = {
gameId: "",
difficulty: "normal",
sound: true,
bgm: true,
workflow: "ws_game_sdxl_t2i.json",
// 画風・キャラ・シーンはゲームが報酬プロンプトとして渡すので、ここは品質タグだけ
basePrompt: "masterpiece, best quality",
negativePrompt: "",
generateEachStage: true, // ステージクリアごとに画像を生成する
autoGenerateEnding: true, // 全クリア時のエンディング画像も自動で生成する
autoGenerateGameover: true, // ゲームオーバー時の敗北画像も自動で生成する
};
const state = {
manifest: null,
opened: false,
handle: null, // mount() の戻り値
mountToken: 0,
jobs: [], // 画像1枚ごとのカード { id, kind, title, result, selected, el, status, apiWf, imageUrl }
jobSeq: 0,
queue: Promise.resolve(), // 生成は1枚ずつ順番に行う
};
const $ = (id) => document.getElementById(id);
// ---------------------------------------------------------------------------
// settings
// ---------------------------------------------------------------------------
// 以前の既定値。保存値がこれと同じなら新しい既定値に置き換える(ユーザーが編集した値は残す)
const OLD_DEFAULT_BASE_PROMPTS = ["masterpiece, best quality, outer space scenery"];
function loadSettings() {
const s = { ...DEFAULT_SETTINGS, ...readJsonStorage(LS_SETTINGS, {}) };
if (OLD_DEFAULT_BASE_PROMPTS.includes(s.basePrompt)) s.basePrompt = DEFAULT_SETTINGS.basePrompt;
return s;
}
function saveSettings(patch) {
const next = { ...loadSettings(), ...patch };
try { localStorage.setItem(LS_SETTINGS, JSON.stringify(next)); } catch { /* storage unavailable */ }
return next;
}
// ---------------------------------------------------------------------------
// detection
// ---------------------------------------------------------------------------
function isSafeGamePath(p) {
return typeof p === "string" && p.startsWith(ENTRY_PREFIX) && !p.includes("..") && !p.includes("//", 1) && !/[\\?#]/.test(p);
}
async function fetchManifest() {
const ctrl = new AbortController();
const timer = setTimeout(() => ctrl.abort(), 5000);
try {
const res = await fetch(MANIFEST_URL, { signal: ctrl.signal, cache: "no-store" });
if (!res.ok) return null;
const data = await res.json();
if (data?.api_version !== HOST_API_VERSION) {
console.warn(`[WFS Game] unsupported game pack api_version: ${data?.api_version} (expected ${HOST_API_VERSION})`);
return null;
}
const games = (Array.isArray(data.games) ? data.games : []).filter((g) => g && typeof g.id === "string" && isSafeGamePath(g.entry));
if (!games.length) return null;
games.forEach((g) => { if (g.thumbnail && !isSafeGamePath(g.thumbnail)) delete g.thumbnail; });
return { ...data, games };
} catch {
return null; // 未インストール (404) / 接続不可
} finally {
clearTimeout(timer);
}
}
function localized(obj, fallback = "") {
if (!obj) return fallback;
if (typeof obj === "string") return obj;
return obj[getLang()] || obj.en || Object.values(obj)[0] || fallback;
}
function currentGame() {
const s = loadSettings();
const games = state.manifest?.games || [];
return games.find((g) => g.id === s.gameId) || games[0] || null;
}
// ---------------------------------------------------------------------------
// shell
// ---------------------------------------------------------------------------
function renderShell() {
const root = $("wfm-tab-game");
const s = loadSettings();
const games = state.manifest.games;
root.innerHTML = `
<div class="wfm-game-layout">
<aside class="wfm-game-side">
<div class="wfm-game-section">
<div class="wfm-game-section-title">${escapeHtml(t("gameListTitle"))}</div>
<div class="wfm-game-list" id="wfm-game-list">
${games.map((g) => `
<button type="button" class="wfm-game-card" data-game-id="${escapeHtml(g.id)}">
${g.thumbnail ? `<img src="${escapeHtml(g.thumbnail)}" alt="">` : ""}
<span class="wfm-game-card-name">${escapeHtml(localized(g.name, g.id))}</span>
<span class="wfm-game-card-desc">${escapeHtml(localized(g.description))}</span>
</button>`).join("")}
</div>
</div>
<div class="wfm-game-section">
<div class="wfm-game-section-title">${escapeHtml(t("gamePlaySettings"))}</div>
<label class="wfm-game-field">
<span>${escapeHtml(t("gameDifficulty"))}</span>
<select id="wfm-game-difficulty" class="wfm-select">
<option value="easy">${escapeHtml(t("gameDifficultyEasy"))}</option>
<option value="normal">${escapeHtml(t("gameDifficultyNormal"))}</option>
<option value="hard">${escapeHtml(t("gameDifficultyHard"))}</option>
</select>
</label>
<label class="wfm-game-check"><input type="checkbox" id="wfm-game-bgm"> ${escapeHtml(t("gameBgm"))}</label>
<label class="wfm-game-check"><input type="checkbox" id="wfm-game-sound"> ${escapeHtml(t("gameSound"))}</label>
<div class="wfm-game-note">${escapeHtml(t("gamePlaySettingsNote"))}</div>
</div>
<div class="wfm-game-section">
<div class="wfm-game-section-title">${escapeHtml(t("gameGenSettings"))}</div>
<label class="wfm-game-field">
<span>${escapeHtml(t("gameWorkflow"))}</span>
<div class="wfm-game-row">
<select id="wfm-game-workflow" class="wfm-select"></select>
<button type="button" id="wfm-game-workflow-reload" class="wfm-btn wfm-btn-sm" title="${escapeHtml(t("gameWorkflowReload"))}">&#x21bb;</button>
</div>
</label>
<label class="wfm-game-field">
<span>${escapeHtml(t("gameBasePrompt"))}</span>
<textarea id="wfm-game-base-prompt" class="wfm-textarea" rows="3"></textarea>
</label>
<label class="wfm-game-field">
<span>${escapeHtml(t("gameNegativePrompt"))}</span>
<textarea id="wfm-game-negative-prompt" class="wfm-textarea" rows="2" placeholder="${escapeHtml(t("gameNegativePlaceholder"))}"></textarea>
</label>
<label class="wfm-game-check"><input type="checkbox" id="wfm-game-each-stage"> ${escapeHtml(t("gameEachStage"))}</label>
<label class="wfm-game-check"><input type="checkbox" id="wfm-game-auto-generate"> ${escapeHtml(t("gameAutoGenerate"))}</label>
<label class="wfm-game-check"><input type="checkbox" id="wfm-game-auto-gameover"> ${escapeHtml(t("gameAutoGameover"))}</label>
</div>
</aside>
<section class="wfm-game-main">
<div class="wfm-game-toolbar">
<span class="wfm-game-current" id="wfm-game-current"></span>
<span class="wfm-game-spacer"></span>
<button type="button" id="wfm-game-restart" class="wfm-btn wfm-btn-sm">${escapeHtml(t("gameRestart"))}</button>
</div>
<div class="wfm-game-stage" id="wfm-game-stage"></div>
</section>
<aside class="wfm-game-result" id="wfm-game-result">
<div class="wfm-game-section-title">${escapeHtml(t("gameResultTitle"))}</div>
<div class="wfm-game-result-status" id="wfm-game-result-status">${escapeHtml(t("gameResultEmpty"))}</div>
<div class="wfm-game-row" id="wfm-game-end-row" hidden>
<button type="button" id="wfm-game-play-again" class="wfm-btn wfm-btn-sm">${escapeHtml(t("gamePlayAgain"))}</button>
</div>
<div class="wfm-game-jobs" id="wfm-game-jobs"></div>
</aside>
</div>`;
$("wfm-game-difficulty").value = s.difficulty;
$("wfm-game-sound").checked = s.sound !== false;
$("wfm-game-bgm").checked = s.bgm !== false;
$("wfm-game-base-prompt").value = s.basePrompt;
$("wfm-game-negative-prompt").value = s.negativePrompt;
$("wfm-game-each-stage").checked = s.generateEachStage !== false;
$("wfm-game-auto-generate").checked = s.autoGenerateEnding !== false;
$("wfm-game-auto-gameover").checked = s.autoGenerateGameover !== false;
markSelectedGame();
}
function markSelectedGame() {
const g = currentGame();
document.querySelectorAll("#wfm-game-list .wfm-game-card").forEach((el) => {
el.classList.toggle("active", el.dataset.gameId === g?.id);
});
const cur = $("wfm-game-current");
if (cur) cur.textContent = g ? localized(g.name, g.id) : "";
}
async function loadWorkflowOptions() {
const sel = $("wfm-game-workflow");
if (!sel) return;
const s = loadSettings();
// 一覧の取得(全ワークフローの解析)は時間がかかるので、先に保存済みの選択だけ表示しておく
if (!sel.options.length && s.workflow) {
sel.innerHTML = `<option value="${escapeHtml(s.workflow)}">${escapeHtml(s.workflow)}</option>`;
sel.value = s.workflow;
}
let names = [];
try {
const res = await fetch("/api/wfm/workflows");
const list = await res.json();
names = (Array.isArray(list) ? list : [])
.filter((w) => ["api", "ui"].includes(w.analysis?.format) && (w.analysis?.inputs?.prompts ?? 1) > 0)
.map((w) => w.filename);
} catch { /* keep empty */ }
if (s.workflow && !names.includes(s.workflow)) names.unshift(s.workflow);
sel.innerHTML = names.map((n) => `<option value="${escapeHtml(n)}">${escapeHtml(n)}</option>`).join("");
sel.value = s.workflow;
}
function bindShell() {
$("wfm-game-list").addEventListener("click", (e) => {
const card = e.target.closest(".wfm-game-card");
if (!card) return;
if (card.dataset.gameId === currentGame()?.id && state.handle) { state.handle.focus?.(); return; }
saveSettings({ gameId: card.dataset.gameId });
markSelectedGame();
mountCurrentGame();
});
// プレイ設定はゲーム起動時に渡すので、変更したら再起動して反映する
$("wfm-game-difficulty").addEventListener("change", (e) => { saveSettings({ difficulty: e.target.value }); mountCurrentGame(); });
$("wfm-game-sound").addEventListener("change", (e) => { saveSettings({ sound: e.target.checked }); mountCurrentGame(); });
$("wfm-game-bgm").addEventListener("change", (e) => { saveSettings({ bgm: e.target.checked }); mountCurrentGame(); });
$("wfm-game-workflow").addEventListener("change", (e) => saveSettings({ workflow: e.target.value }));
$("wfm-game-workflow-reload").addEventListener("click", loadWorkflowOptions);
$("wfm-game-base-prompt").addEventListener("change", (e) => {
saveSettings({ basePrompt: e.target.value });
state.jobs.forEach((job) => { if (job.status === "idle" || job.status === "queued") refreshJobPrompt(job); });
});
$("wfm-game-negative-prompt").addEventListener("change", (e) => saveSettings({ negativePrompt: e.target.value }));
$("wfm-game-each-stage").addEventListener("change", (e) => saveSettings({ generateEachStage: e.target.checked }));
$("wfm-game-auto-generate").addEventListener("change", (e) => saveSettings({ autoGenerateEnding: e.target.checked }));
$("wfm-game-auto-gameover").addEventListener("change", (e) => saveSettings({ autoGenerateGameover: e.target.checked }));
$("wfm-game-restart").addEventListener("click", restartGame);
$("wfm-game-play-again").addEventListener("click", restartGame);
const jobs = $("wfm-game-jobs");
jobs.addEventListener("change", (e) => {
const cb = e.target.closest("input[data-reward-idx]");
const job = jobOf(e.target);
if (!cb || !job) return;
const idx = Number(cb.dataset.rewardIdx);
if (cb.checked) job.selected.add(idx); else job.selected.delete(idx);
refreshJobPrompt(job);
});
jobs.addEventListener("click", (e) => {
const btn = e.target.closest("button[data-act]");
const job = jobOf(e.target);
if (!btn || !job) return;
if (btn.dataset.act === "generate") enqueueJob(job);
else if (btn.dataset.act === "open") openInGenerateUI(job);
});
}
// ---------------------------------------------------------------------------
// game lifecycle
// ---------------------------------------------------------------------------
function unmountGame() {
if (state.handle) {
try { state.handle.unmount?.(); } catch (e) { console.error("[WFS Game] unmount failed", e); }
state.handle = null;
}
}
function resetResult() {
// 生成中・待機中のジョブはそのまま続く(カードだけ消える)。画像は出力フォルダに残る
state.jobs.forEach((job) => { job.removed = true; if (job.imageUrl) URL.revokeObjectURL(job.imageUrl); });
state.jobs = [];
const jobs = $("wfm-game-jobs");
if (jobs) jobs.innerHTML = "";
const st = $("wfm-game-result-status");
if (st) st.textContent = t("gameResultEmpty");
const end = $("wfm-game-end-row");
if (end) end.hidden = true;
}
async function mountCurrentGame() {
const game = currentGame();
const stage = $("wfm-game-stage");
if (!game || !stage) return;
const token = ++state.mountToken;
unmountGame();
resetResult();
stage.innerHTML = `<div class="wfm-game-loading">${escapeHtml(t("gameLoading"))}</div>`;
try {
// ゲームパック更新後に古いモジュールがキャッシュから読まれないよう、バージョンを付ける
const ver = encodeURIComponent(game.version || state.manifest.package_version || "0");
const mod = await import(`${game.entry}?v=${ver}`);
if (token !== state.mountToken) return; // 読み込み中に別ゲームへ切り替わった
if (typeof mod.mount !== "function") throw new Error("mount() not found");
const s = loadSettings();
const host = {
apiVersion: HOST_API_VERSION,
lang: getLang(),
settings: { difficulty: s.difficulty, sound: s.sound !== false, bgm: s.bgm !== false },
runStart: () => { if (token === state.mountToken) resetResult(); },
stageClear: (result) => { if (token === state.mountToken) onStageClear(result); },
finish: (result) => { if (token === state.mountToken) onGameFinished(result); },
};
const handle = await mod.mount(stage, host);
if (token !== state.mountToken) { try { handle?.unmount?.(); } catch { /* ignore */ } return; }
state.handle = handle || null;
if (!isGameTabActive()) state.handle?.pause?.();
} catch (e) {
console.error("[WFS Game] failed to load game", e);
stage.innerHTML = `<div class="wfm-game-loading">${escapeHtml(t("gameLoadFailed", e.message))}</div>`;
}
}
function restartGame() {
resetResult();
if (state.handle?.restart) state.handle.restart();
else mountCurrentGame();
}
function isGameTabActive() {
return $("wfm-tab-game")?.classList.contains("active");
}
// ---------------------------------------------------------------------------
// result & generation
// ---------------------------------------------------------------------------
function sanitizeResult(raw) {
const r = raw && typeof raw === "object" ? raw : {};
const rewards = (Array.isArray(r.rewards) ? r.rewards : [])
.filter((x) => x && x.type === "prompt" && typeof x.text === "string" && x.text.trim())
.slice(0, 50)
.map((x) => ({
text: x.text.trim().slice(0, 500),
weight: Number.isFinite(Number(x.weight)) ? Number(x.weight) : 1,
source: typeof x.source === "string" ? x.source : "clear",
}));
const kind = ["stage", "ending", "gameover"].includes(r.kind) ? r.kind : (r.cleared ? "ending" : "gameover");
const num = (v) => (Number.isFinite(Number(v)) ? Number(v) : 0);
return {
kind,
bonus: !!r.bonus, // アイテムを全部取ったステージ(プライベート写真)
negative: typeof r.negative === "string" ? r.negative.trim().slice(0, 500) : "",
cleared: !!r.cleared,
score: num(r.score),
stage: num(r.stage),
stagesTotal: num(r.stagesTotal),
stageName: typeof r.stageName === "string" ? r.stageName.slice(0, 100) : "",
rewards,
};
}
function onStageClear(raw) {
const result = sanitizeResult(raw);
const job = result.bonus
? addJob(result, t("gameJobStagePrivate", result.stage, result.stageName), "private")
: addJob(result, t("gameJobStage", result.stage, result.stageName));
if (loadSettings().generateEachStage !== false) enqueueJob(job);
}
function onGameFinished(raw) {
const result = sanitizeResult(raw);
const cleared = result.kind === "ending";
$("wfm-game-result-status").innerHTML = `
<div class="wfm-game-result-head ${cleared ? "cleared" : "failed"}">${escapeHtml(cleared ? t("gameCleared") : t("gameOverLabel"))}</div>
<div>${escapeHtml(t("gameScore", result.score))}</div>`;
$("wfm-game-end-row").hidden = false;
const s = loadSettings();
if (cleared) {
const job = addJob(result, t("gameJobEnding"));
if (s.autoGenerateEnding !== false) enqueueJob(job);
} else if (result.rewards.length) {
// ゲームオーバー: 負けたステージを背景にした敗北の場面(クリア済みステージの画像は残る)
const job = addJob(result, t("gameJobGameover", result.stage, result.stageName), "gameover");
if (s.autoGenerateGameover !== false) enqueueJob(job);
}
}
// ---- image cards ----
function jobOf(el) {
const card = el.closest?.(".wfm-game-job");
return card ? state.jobs.find((j) => String(j.id) === card.dataset.jobId) : null;
}
function addJob(result, title, variant = "") {
const job = {
id: ++state.jobSeq, kind: result.kind, title, result,
selected: new Set(result.rewards.map((_, i) => i)),
status: "idle", apiWf: null, imageUrl: null, el: null,
};
const el = document.createElement("div");
el.className = variant ? `wfm-game-job wfm-game-job-${variant}` : "wfm-game-job";
el.dataset.jobId = String(job.id);
el.innerHTML = `
<div class="wfm-game-job-head">
<span class="wfm-game-job-title">${escapeHtml(title)}</span>
<span class="wfm-game-job-status" data-role="status"></span>
</div>
<div class="wfm-game-progress" data-role="progress" hidden><div class="wfm-game-progress-bar" data-role="bar"></div></div>
<img class="wfm-game-job-img" data-role="img" alt="" hidden>
<details class="wfm-game-job-details">
<summary>${escapeHtml(t("gamePromptDetails"))}</summary>
<div class="wfm-game-rewards">
${result.rewards.map((r, i) => `
<label class="wfm-game-reward">
<input type="checkbox" data-reward-idx="${i}" checked>
<span><span class="wfm-game-reward-src">${escapeHtml(sourceLabel(r.source))}</span>${escapeHtml(r.text)}</span>
</label>`).join("")}
${result.negative ? `<div class="wfm-game-note">${escapeHtml(t("gameNegativeFromGame"))}: ${escapeHtml(result.negative)}</div>` : ""}
</div>
<label class="wfm-game-field">
<span>${escapeHtml(t("gameFinalPrompt"))}</span>
<textarea class="wfm-textarea" data-role="prompt" rows="4"></textarea>
</label>
</details>
<div class="wfm-game-row">
<button type="button" class="wfm-btn wfm-btn-sm wfm-btn-primary" data-act="generate">${escapeHtml(t("gameGenerate"))}</button>
<button type="button" class="wfm-btn wfm-btn-sm" data-act="open" hidden>${escapeHtml(t("gameOpenInGenerateUI"))}</button>
</div>`;
job.el = el;
state.jobs.push(job);
$("wfm-game-jobs")?.prepend(el); // 新しいものを上に
refreshJobPrompt(job);
setJobStatus(job, "idle");
return job;
}
const part = (job, role) => job.el.querySelector(`[data-role="${role}"]`);
function setJobStatus(job, status, text = "") {
job.status = status;
const label = { idle: "", queued: t("gameJobQueued"), running: t("gameGenerating"), done: t("gameJobDone"), failed: t("gameGenerateFailed", "") }[status] ?? "";
const st = part(job, "status");
st.textContent = text || label;
st.dataset.status = status;
part(job, "progress").hidden = status !== "running";
const gen = job.el.querySelector('button[data-act="generate"]');
gen.disabled = status === "queued" || status === "running";
gen.textContent = job.imageUrl || status === "failed" ? t("gameRegenerate") : t("gameGenerate");
}
function buildPrompt(job) {
const s = loadSettings();
const parts = [];
const seen = new Set();
const push = (txt) => {
const v = (txt || "").trim();
if (!v) return;
const key = v.toLowerCase().replace(/\s+/g, " ");
if (seen.has(key)) return;
seen.add(key);
parts.push(v);
};
push(s.basePrompt);
job.result.rewards.forEach((r, i) => { if (job.selected.has(i)) push(formatReward(r)); });
return parts.join(", ");
}
function refreshJobPrompt(job) {
part(job, "prompt").value = buildPrompt(job);
}
function enqueueJob(job) {
if (job.status === "queued" || job.status === "running") return;
setJobStatus(job, "queued");
state.queue = state.queue.then(() => runJob(job)).catch(() => {});
}
async function runJob(job) {
if (job.removed) return;
const prompt = (part(job, "prompt").value || buildPrompt(job)).trim();
if (!prompt) { setJobStatus(job, "failed", t("gameEmptyPrompt")); return; }
setJobStatus(job, "running");
const bar = part(job, "bar");
bar.style.width = "0%";
try {
const wf = await buildWorkflow(prompt, job.result.negative);
job.apiWf = wf;
const expanded = await _expandWildcardsInWorkflow(wf);
const { images } = await comfyUI.generate(expanded, {
seedMode: "random",
quietVram: true, // VRAM 調整のトーストでゲーム画面を隠さない
onProgress: (pct) => {
bar.style.width = `${(pct * 100).toFixed(1)}%`;
part(job, "status").textContent = `${t("gameGenerating")} ${(pct * 100).toFixed(0)}%`;
},
});
const img = images.filter((x) => x.type !== "temp")[0] || images[0];
if (!img) throw new Error(t("gameNoImage"));
const blob = await comfyUI.getImageBlob(img);
if (job.imageUrl) URL.revokeObjectURL(job.imageUrl);
job.imageUrl = URL.createObjectURL(blob);
if (job.removed) { URL.revokeObjectURL(job.imageUrl); return; }
const el = part(job, "img");
el.src = job.imageUrl;
el.title = t("gameGenerated", [img.subfolder, img.filename].filter(Boolean).join("/"));
el.hidden = false;
job.el.querySelector('button[data-act="open"]').hidden = false;
setJobStatus(job, "done");
} catch (e) {
console.error("[WFS Game] generation failed", e);
if (!job.removed) {
setJobStatus(job, "failed", t("gameGenerateFailed", e.message));
showToast(t("gameGenerateFailed", e.message), "error");
}
}
}
function sourceLabel(src) {
const key = { style: "gameSrcStyle", character: "gameSrcCharacter", scene: "gameSrcScene", clear: "gameSrcClear", enemy: "gameSrcEnemy", bonus: "gameSrcBonus" }[src];
return key ? t(key) : src;
}
function joinUnique(...parts) {
const seen = new Set();
const out = [];
for (const p of parts) {
for (const tag of (p || "").split(",")) {
const v = tag.trim();
const k = v.toLowerCase();
if (v && !seen.has(k)) { seen.add(k); out.push(v); }
}
}
return out.join(", ");
}
function formatReward(r) {
return r.weight !== 1 ? `(${r.text}:${r.weight})` : r.text;
}
async function buildWorkflow(prompt, gameNegative) {
const s = loadSettings();
if (!s.workflow) throw new Error(t("gameNoWorkflow"));
const res = await fetch(`/api/wfm/workflows/raw?filename=${encodeURIComponent(s.workflow)}`);
if (!res.ok) throw new Error(t("gameWorkflowLoadFailed", s.workflow));
const raw = await res.json();
const format = comfyWorkflow.detectFormat(raw, s.workflow);
let wf;
if (format === "ui") wf = await comfyWorkflow.convertUiToApi(raw);
else if (format === "api") wf = structuredClone(raw);
else throw new Error(t("unknownWorkflowFormat"));
const analysis = comfyWorkflow.analyzeWorkflow(wf);
const pos = analysis.prompt_nodes?.find((n) => n.role === "positive");
const neg = analysis.prompt_nodes?.find((n) => n.role === "negative");
if (!pos || !wf[pos.id]) throw new Error(t("gameNoPositiveNode"));
wf[pos.id].inputs[pos.textKey || "text"] = prompt;
if (neg && wf[neg.id]) {
// 設定のネガティブ(空ならワークフロー自身のもの)に、ゲームが渡したネガティブを足す
const key = neg.textKey || "text";
const base = s.negativePrompt.trim() || (typeof wf[neg.id].inputs[key] === "string" ? wf[neg.id].inputs[key] : "");
wf[neg.id].inputs[key] = joinUnique(base, gameNegative);
}
return wf;
}
async function openInGenerateUI(job) {
if (!job?.apiWf) return;
const { loadWorkflowIntoEditor } = await import("./generate-tab.js");
const ok = await loadWorkflowIntoEditor(structuredClone(job.apiWf), loadSettings().workflow);
if (ok !== false) document.querySelector('.wfm-tab[data-tab="generate"]')?.click();
}
// ---------------------------------------------------------------------------
// tab visibility
// ---------------------------------------------------------------------------
function onTabsClicked(e) {
const tab = e.target.closest(".wfm-tab");
if (!tab) return;
if (tab.dataset.tab === "game") {
// app.js の表示切替が終わってから初期化する
setTimeout(onOpen, 0);
} else {
state.handle?.pause?.();
}
}
async function onOpen() {
if (!state.opened) {
state.opened = true;
renderShell();
bindShell();
loadWorkflowOptions();
await mountCurrentGame();
return;
}
state.handle?.resume?.();
}
export async function initGameTab() {
const btn = document.querySelector('.wfm-tab[data-tab="game"]');
if (!btn || !$("wfm-tab-game")) return;
const manifest = await fetchManifest();
if (!manifest) return; // ゲームパック未インストール: タブは hidden のまま
state.manifest = manifest;
btn.hidden = false;
document.querySelector('.wfm-help-nav-item[data-help-page="game"]')?.removeAttribute("hidden");
document.querySelector(".wfm-tabs")?.addEventListener("click", onTabsClicked);
document.addEventListener("visibilitychange", () => {
if (document.hidden) state.handle?.pause?.();
else if (isGameTabActive()) state.handle?.resume?.();
});
// 動作確認用 (DevTools から window._wfmGameTab.handle.debugClear() など)
window._wfmGameTab = state;
}
+17
View File
@@ -12,6 +12,7 @@ import { initFeederTab, refreshFeederNodeList } from "./feeder-tab.js";
import { initLabTab, refreshLabLiveDefaults } from "./lab-tab.js";
import { getSettings, readJsonStorage, escapeHtml, getEagleSettings, saveToEagle } from "./util.js";
import { isVideoFilename } from "./video-utils.js";
import { autoTranslateBeforeGenerate } from "./prompt-translate.js";
// ============================================
// Gallery Metadata - ワークフロー保存
@@ -2032,6 +2033,22 @@ async function handleGenerate(workflowOverride = null, genOptions = {}) {
}
if (comfyUI.generating) return;
// 設定「プロンプト翻訳」で生成前の自動翻訳がオンなら、Positive/Negative欄の自国語部分を英語へ置き換えてから同期する。
// 失敗時は未翻訳のまま生成しないよう中断する。
if (!workflowOverride) {
const genBtnEl = document.getElementById("wfm-gen-generate-btn");
if (genBtnEl) genBtnEl.disabled = true;
try {
await autoTranslateBeforeGenerate();
} catch (err) {
if (genBtnEl) genBtnEl.disabled = false;
const progressText = document.getElementById("wfm-gen-progress-text");
if (progressText) progressText.textContent = "";
showToast(t("promptTranslateError", err.message), "error");
return;
}
}
// オーバーライド実行時は GenerateUI 側の表示中プロンプトを別ワークフローへ誤って書き込まないよう同期をスキップする
if (!workflowOverride) comfyEditor.syncToWorkflow();
+672 -33
View File
File diff suppressed because it is too large Load Diff
+140 -26
View File
@@ -6,6 +6,7 @@
import { LayerManager, Layer } from "./image-edit/LayerManager.js";
import { DrawTool } from "./image-edit/DrawTool.js";
import { DrawPalette } from "./image-edit/DrawPalette.js";
import { TextTool, TEXT_FONTS } from "./image-edit/TextTool.js";
import { SelectTool } from "./image-edit/SelectTool.js";
import { ShapeTool } from "./image-edit/ShapeTool.js";
@@ -20,10 +21,22 @@ import { MaskEditorOneBridge } from "./image-edit/MaskEditorOneBridge.js";
import { InpaintI2IActions } from "./image-edit/InpaintI2IActions.js";
import { FileExport } from "./image-edit/FileExport.js";
import { showToast } from "./app.js";
import { t as tr } from "./i18n.js";
import { comfyUI } from "./comfyui-client.js";
import { comfyEditor } from "./comfyui-editor.js";
import { comfyWorkflow } from "./comfyui-workflow.js";
// Draw Tool: スポイト(Eyedropper)アイコン。ボタンとカスタムカーソルの両方で使い回す。
const EYEDROPPER_ICON_PATH = "M20.71 5.63l-2.34-2.34a1 1 0 0 0-1.41 0L14.7 5.55 12 8.24 3 17.24V21h3.76l9-9 2.69-2.69 2.26-2.26a1 1 0 0 0 0-1.41zM6.34 19H5v-1.34l8.06-8.06 1.41 1.41L6.34 19z";
const EYEDROPPER_ICON_SVG =
`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="14" height="14" fill="currentColor"><path d="${EYEDROPPER_ICON_PATH}"/></svg>`;
function _eyedropperCursorCss() {
const svg = `<svg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24'>`
+ `<path d='${EYEDROPPER_ICON_PATH}' fill='%23ffffff' stroke='%23000000' stroke-width='1'/></svg>`;
return `url("data:image/svg+xml,${svg}") 2 22, crosshair`;
}
const TOOL_DEFS = [
{ id: "select", icon: "▲", label: "Select", ready: true },
{ id: "draw", icon: "✏", label: "Draw", ready: true },
@@ -49,6 +62,11 @@ class ImageEditTab {
this._layerMgr = null;
this._activeTool = "select";
this._drawTool = new DrawTool(null);
this._eyedropperActive = false; // Drawツールのスポイト(色抽出)モード
this._drawPalette = new DrawPalette({
onColorChange: hex => this._setDrawColor(hex),
toast: showToast,
});
this._textTool = new TextTool(null);
this._selectTool = new SelectTool();
this._zoom = 1.0;
@@ -196,6 +214,7 @@ class ImageEditTab {
_updateBrushCursor(e) {
const el = this._brushCursorEl;
if (!el) return;
this._lastBrushCursorEvent = e; // キー操作でサイズを変えたときに再描画するため保持
const tool = this._activeTool;
const size = tool === "draw"
? this._drawTool?.brushSize
@@ -226,6 +245,79 @@ class ImageEditTab {
if (this._brushCursorEl) this._brushCursorEl.style.display = "none";
}
// ── Draw: スポイト(Eyedropper) ─────────────────
_setEyedropperActive(active) {
this._eyedropperActive = active;
const drawCanvas = document.getElementById("ie-canvas-draw");
const overlay = document.getElementById("ie-canvas-overlay");
const cursor = active ? _eyedropperCursorCss() : "";
if (drawCanvas) drawCanvas.style.cursor = cursor;
if (overlay) overlay.style.cursor = cursor;
if (active) this._hideBrushCursor();
document.getElementById("ie-draw-eyedropper")?.classList.toggle("ie-opt-active", active);
}
_pickColorAt(x, y) {
const canvas = document.getElementById("ie-canvas-draw");
const px = Math.floor(x), py = Math.floor(y);
if (!canvas || px < 0 || py < 0 || px >= canvas.width || py >= canvas.height) {
this._setEyedropperActive(false);
return;
}
try {
// 見えている色を拾うため、アクティブレイヤーのみの表示なら合成し直す
if (!this._compositeMode) this._updateCompositeView();
const [r, g, b] = canvas.getContext("2d").getImageData(px, py, 1, 1).data;
const hex = "#" + [r, g, b].map(v => v.toString(16).padStart(2, "0")).join("");
this._setDrawColor(hex);
this._drawPalette.syncColor(hex);
} catch {
showToast(tr("imageEditPixelColorFail"), "error");
}
this._setEyedropperActive(false);
}
_setDrawMode(mode) {
this._drawTool.mode = mode;
this._drawTool._stamp = null;
this._renderDrawProps();
}
_setDrawBrushSize(size) {
this._drawTool.brushSize = size;
this._drawTool._stamp = null;
const slider = document.getElementById("ie-draw-size");
if (slider) slider.value = size;
const label = document.getElementById("ie-draw-size-lbl");
if (label) label.textContent = size + "px";
if (this._lastBrushCursorEvent && !this._eyedropperActive) {
this._updateBrushCursor(this._lastBrushCursorEvent);
}
}
/** [ / ] キー: サイズが大きいほど刻みを粗くする */
_stepDrawBrushSize(direction) {
const size = this._drawTool.brushSize;
const base = direction < 0 ? size - 1 : size;
const step = base < 10 ? 1 : base < 50 ? 5 : 10;
this._setDrawBrushSize(Math.min(200, Math.max(1, size + direction * step)));
}
/** Drawツール中のBキー: ブラシ選択モーダルを開閉する */
_toggleDrawBrushPicker() {
if (this._abrAvailable) this._openAbrBrushPickerForDraw();
else showToast(tr("imageEditNoAbrBrushes"), "info");
}
_setDrawColor(hex) {
this._drawTool.color = hex;
this._drawTool._stamp = null;
this._drawTool._imgStamp = null;
const input = document.getElementById("ie-draw-color");
if (input) input.value = hex;
}
// ── ツールボタン ──────────────────────────────
_setupToolButtons() {
@@ -240,6 +332,7 @@ class ImageEditTab {
_setActiveTool(toolId) {
this._hideBrushCursor();
if (this._eyedropperActive) this._setEyedropperActive(false);
if (this._activeTool === "draw") this._drawTool?.deactivate();
if (this._activeTool === "text") this._textTool?.deactivate();
if (this._activeTool === "select") this._selectTool?.deactivate();
@@ -306,6 +399,7 @@ class ImageEditTab {
_renderToolOptions(toolId) {
const el = document.getElementById("ie-tool-options");
if (!el) return;
this._drawPalette.closeMenu();
el.innerHTML = "";
if (toolId === "select" && this._selectTool) {
@@ -355,6 +449,7 @@ class ImageEditTab {
} else if (toolId === "draw" && this._drawTool) {
el.innerHTML = "";
this._drawPalette.render(el);
this._renderDrawProps();
} else if (toolId === "fill" && this._fillTool) {
@@ -873,18 +968,22 @@ class ImageEditTab {
<div class="ie-props-row">
<label>Mode</label>
<div style="display:flex;gap:4px;">
<button class="wfm-btn wfm-btn-sm${t.mode === "draw" ? " ie-opt-active" : ""}" id="ie-draw-mode-draw" style="flex:1;">Draw</button>
<button class="wfm-btn wfm-btn-sm${t.mode === "erase" ? " ie-opt-active" : ""}" id="ie-draw-mode-erase" style="flex:1;">Erase</button>
<button class="wfm-btn wfm-btn-sm${t.mode === "draw" ? " ie-opt-active" : ""}" id="ie-draw-mode-draw" title="Draw (D)" style="flex:1;">Draw</button>
<button class="wfm-btn wfm-btn-sm${t.mode === "erase" ? " ie-opt-active" : ""}" id="ie-draw-mode-erase" title="Erase (E)" style="flex:1;">Erase</button>
</div>
</div>
<div class="ie-props-row">
<label>Color</label>
<input type="color" id="ie-draw-color" value="${t.color}"
style="width:36px;height:24px;padding:0;border:1px solid var(--wfm-border);cursor:pointer;border-radius:3px;flex-shrink:0;">
<div style="display:flex;gap:4px;align-items:center;">
<input type="color" id="ie-draw-color" value="${t.color}"
style="width:36px;height:24px;padding:0;border:1px solid var(--wfm-border);cursor:pointer;border-radius:3px;flex-shrink:0;">
<button class="wfm-btn wfm-btn-sm${this._eyedropperActive ? " ie-opt-active" : ""}" id="ie-draw-eyedropper"
title="Eyedropper" style="flex-shrink:0;width:auto;height:24px;padding:2px 6px;display:flex;align-items:center;justify-content:center;">${EYEDROPPER_ICON_SVG}</button>
</div>
</div>
<div class="ie-props-row">
<label>Size</label>
<input type="range" id="ie-draw-size" min="1" max="200" value="${t.brushSize}">
<label title="[ / ]">Size</label>
<input type="range" id="ie-draw-size" min="1" max="200" value="${t.brushSize}" title="[ / ]">
<span id="ie-draw-size-lbl">${t.brushSize}px</span>
</div>
<div class="ie-props-row">
@@ -906,7 +1005,7 @@ class ImageEditTab {
<label>Brush</label>
<span style="font-size:11px;color:var(--wfm-text-secondary);flex:1;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;"
title="${t.brushName ?? "Circle"}">${t.brushName ?? "Circle"}</span>
<button class="wfm-btn wfm-btn-sm" id="ie-draw-select-brush" style="font-size:10px;padding:1px 6px;flex-shrink:0;" ${this._abrAvailable ? "" : "disabled"}>Select</button>
<button class="wfm-btn wfm-btn-sm" id="ie-draw-select-brush" title="B" style="font-size:10px;padding:1px 6px;flex-shrink:0;" ${this._abrAvailable ? "" : "disabled"}>Select</button>
${t.brushImage ? `<button class="wfm-btn wfm-btn-sm" id="ie-draw-clear-brush" style="font-size:10px;padding:1px 5px;flex-shrink:0;">✕</button>` : ""}
</div>
${t.brushImage ? `
@@ -933,25 +1032,17 @@ class ImageEditTab {
</div>` : ""}
`;
document.getElementById("ie-draw-mode-draw")?.addEventListener("click", () => {
this._drawTool.mode = "draw";
this._drawTool._stamp = null;
this._renderDrawProps();
});
document.getElementById("ie-draw-mode-erase")?.addEventListener("click", () => {
this._drawTool.mode = "erase";
this._drawTool._stamp = null;
this._renderDrawProps();
});
document.getElementById("ie-draw-mode-draw")?.addEventListener("click", () => this._setDrawMode("draw"));
document.getElementById("ie-draw-mode-erase")?.addEventListener("click", () => this._setDrawMode("erase"));
document.getElementById("ie-draw-color")?.addEventListener("input", e => {
this._drawTool.color = e.target.value;
this._drawTool._stamp = null;
this._drawTool._imgStamp = null;
this._setDrawColor(e.target.value);
this._drawPalette.syncColor(e.target.value);
});
document.getElementById("ie-draw-eyedropper")?.addEventListener("click", () => {
this._setEyedropperActive(!this._eyedropperActive);
});
document.getElementById("ie-draw-size")?.addEventListener("input", e => {
this._drawTool.brushSize = parseInt(e.target.value);
document.getElementById("ie-draw-size-lbl").textContent = e.target.value + "px";
this._drawTool._stamp = null;
this._setDrawBrushSize(parseInt(e.target.value));
});
document.getElementById("ie-draw-hard")?.addEventListener("input", e => {
this._drawTool.hardness = parseInt(e.target.value) / 100;
@@ -1461,7 +1552,9 @@ class ImageEditTab {
}
// Draw/Mask: update brush cursor and continue stroke outside canvas
const tool = this._activeTool;
if (tool === "draw" || tool === "mask") {
if (this._eyedropperActive) {
this._hideBrushCursor();
} else if (tool === "draw" || tool === "mask") {
this._updateBrushCursor(e);
const isDrawing = tool === "draw"
? this._drawTool?._drawing
@@ -1514,6 +1607,11 @@ class ImageEditTab {
// PointerEvent.pressure: pen -> actual pressure, mouse -> 0.5 while a button is held.
const pressure = e.pressure || 0.5;
if (this._eyedropperActive) {
this._pickColorAt(pos.x, pos.y);
return;
}
if (this._activeTool === "draw" && this._drawTool) {
const activeLayer = this._layerMgr.activeLayer;
if (!activeLayer) return;
@@ -1781,6 +1879,7 @@ class ImageEditTab {
// 現在のドキュメントを閉じ、未保存の変更を破棄してプレースホルダー表示に戻す
_closeDocument() {
if (this._eyedropperActive) this._setEyedropperActive(false);
if (!this._layerMgr) return;
if (!confirm("Close the current document? Unsaved changes will be lost.")) return;
@@ -1848,6 +1947,8 @@ class ImageEditTab {
this._layerMgr.on("change", () => this._refreshLayerList());
this._drawTool = new DrawTool(null);
// 新規ドキュメントでも選択中の色を引き継ぐ(パレットを色の正とする)
this._drawTool.color = this._drawPalette.currentColor;
this._drawTool.onChange(() => {
// layer.canvas に直接描くため sync 不要
this._updateCompositeView();
@@ -2458,6 +2559,9 @@ class ImageEditTab {
const wrap = document.getElementById("ie-canvas-wrap");
if (wrap && !this._panning) wrap.style.cursor = "grab";
}
if (e.key === "Escape" && this._eyedropperActive) this._setEyedropperActive(false);
const brushPicker = document.getElementById("wfm-abr-picker-overlay");
if (e.key === "Escape") brushPicker?.remove();
if (e.ctrlKey && e.key === "z") { e.preventDefault(); this._undo(); }
if (e.ctrlKey && e.key === "y") { e.preventDefault(); this._redo(); }
if (this._activeTool === "mask" && this._maskSubtool === "vector") {
@@ -2465,10 +2569,20 @@ class ImageEditTab {
}
if (!e.ctrlKey && !e.target.closest("input, textarea, select")) {
if (e.key === "v") this._setActiveTool("select");
if (e.key === "b") this._setActiveTool("draw");
if (e.key === "b") {
if (this._activeTool === "draw") this._toggleDrawBrushPicker();
else this._setActiveTool("draw");
}
if (e.key === "t") this._setActiveTool("text");
if (e.key === "s") this._setActiveTool("shape");
if (e.key === "g") this._setActiveTool("fill");
if (this._activeTool === "draw" && !brushPicker && !e.altKey && !e.metaKey) {
if (e.key === "d") this._setDrawMode("draw");
if (e.key === "e") this._setDrawMode("erase");
if (e.key === "x") this._drawPalette.toggleWell();
if (e.key === "[") this._stepDrawBrushSize(-1);
if (e.key === "]") this._stepDrawBrushSize(1);
}
// Delete/Backspaceで選択オブジェクト削除
if ((e.key === "Delete" || e.key === "Backspace") && this._activeTool === "select") {
const layer = this._selectTool?.getSelectedLayer();
@@ -2929,7 +3043,7 @@ class ImageEditTab {
return null;
};
const currentColor = this._drawTool?.color ?? "#ff0000";
const currentColor = this._drawTool?.color ?? "#000000";
const hex = currentColor.replace("#", "");
const cr = parseInt(hex.slice(0, 2), 16);
const cg = parseInt(hex.slice(2, 4), 16);
+235
View File
@@ -0,0 +1,235 @@
/**
* Image Edit Tab - Draw Tool color palette
* Drawツールの2段目(ie-tool-options)に並べるカラーパレット。
* 色1/色2の切替、基本色、カスタム色の登録を担当する。
* 基本色・カスタム色はユーザー設定として localStorage に保存する(作品データには含めない)。
*/
import { t } from "../i18n.js";
const STORAGE_KEY = "ie_draw_palette_v1";
const CUSTOM_SLOTS = 20;
const DEFAULT_BASE = [
"#000000", "#7f7f7f", "#880015", "#ed1c24", "#ff7f27", "#fff200", "#22b14c", "#00a2e8", "#3f48cc", "#a349a4",
"#ffffff", "#c3c3c3", "#b97a57", "#ffaec9", "#ffc90e", "#efe4b0", "#b5e61d", "#99d9ea", "#7092be", "#c8bfe7",
];
function normalizeHex(value) {
if (typeof value !== "string") return null;
const hex = value.toLowerCase();
return /^#[0-9a-f]{6}$/.test(hex) ? hex : null;
}
function loadPalette() {
let saved = null;
try { saved = JSON.parse(localStorage.getItem(STORAGE_KEY)); } catch { /* 破損時は初期値 */ }
return {
base: DEFAULT_BASE.map((c, i) => normalizeHex(saved?.base?.[i]) ?? c),
custom: Array.from({ length: CUSTOM_SLOTS }, (_, i) => normalizeHex(saved?.custom?.[i])),
};
}
export class DrawPalette {
/**
* @param {object} opts
* @param {(hex: string) => void} opts.onColorChange ブラシ色を変更する
* @param {(msg: string, type?: string) => void} opts.toast
*/
constructor({ onColorChange, toast }) {
this._onColorChange = onColorChange;
this._toast = toast;
this._wells = ["#000000", "#ffffff"];
this._activeWell = 0;
Object.assign(this, loadPalette());
this._content = null;
this._picker = null;
this._pickerTarget = null;
this._menu = null;
this._closeMenuOnOutside = e => { if (!this._menu?.contains(e.target)) this.closeMenu(); };
this._closeMenuOnEscape = e => { if (e.key === "Escape") this.closeMenu(); };
}
get currentColor() { return this._wells[this._activeWell]; }
/** ie-tool-options へパレットを描画する */
render(container) {
this.closeMenu();
const root = document.createElement("div");
root.className = "ie-palette";
this._content = document.createElement("div");
this._content.className = "ie-palette-content";
this._picker = document.createElement("input");
this._picker.type = "color";
this._picker.className = "ie-palette-picker";
this._picker.tabIndex = -1;
root.append(this._content, this._picker);
container.appendChild(root);
root.addEventListener("click", e => this._onClick(e));
root.addEventListener("contextmenu", e => this._onContextMenu(e));
this._picker.addEventListener("input", () => this._onPickerInput());
this._refresh();
}
/** スポイト・カラー入力などパレット外で変わった色を反映する */
syncColor(color) {
const hex = normalizeHex(color);
if (!hex) return;
this._wells[this._activeWell] = hex;
this._refresh();
}
/** 色1/色2を切り替える */
toggleWell() {
this._selectWell(1 - this._activeWell);
}
closeMenu() {
if (!this._menu) return;
this._menu.remove();
this._menu = null;
document.removeEventListener("pointerdown", this._closeMenuOnOutside, true);
document.removeEventListener("keydown", this._closeMenuOnEscape, true);
}
_refresh() {
if (!this._content?.isConnected) return;
const wells = this._wells.map((color, i) => {
const label = t(i === 0 ? "imageEditPaletteColor1" : "imageEditPaletteColor2");
return `<button type="button" class="ie-palette-well${i === this._activeWell ? " is-active" : ""}"
data-well="${i}" style="--swatch:${color}" title="${label} (X): ${color}" aria-label="${label}"></button>`;
}).join("");
this._content.innerHTML = `
<div class="ie-opt-group ie-palette-wells">${wells}</div>
<div class="ie-opt-group">
<label>${t("imageEditPaletteBase")}</label>
<div class="ie-palette-grid">${this._swatches("base")}</div>
</div>
<div class="ie-opt-group">
<label>${t("imageEditPaletteCustom")}</label>
<div class="ie-palette-grid">${this._swatches("custom")}</div>
<button type="button" class="wfm-btn wfm-btn-sm" data-palette-add
title="${t("imageEditPaletteAddTitle")}">+</button>
</div>`;
}
_swatches(kind) {
return this[kind].map((color, i) => {
const attrs = `data-kind="${kind}" data-index="${i}"`;
if (!color) {
const title = t("imageEditPaletteEmptyTitle");
return `<button type="button" class="ie-palette-swatch is-empty" ${attrs} title="${title}" aria-label="${title}"></button>`;
}
const current = color === this.currentColor ? " is-current" : "";
const title = `${color} — ${t("imageEditPaletteSwatchTitle")}`;
return `<button type="button" class="ie-palette-swatch${current}" ${attrs}
style="--swatch:${color}" title="${title}" aria-label="${color}"></button>`;
}).join("");
}
_onClick(e) {
const well = e.target.closest("[data-well]");
if (well) {
this._selectWell(Number(well.dataset.well));
return;
}
if (e.target.closest("[data-palette-add]")) {
this._addCurrent();
return;
}
const swatch = e.target.closest("[data-kind]");
if (!swatch) return;
const { kind, index } = swatch.dataset;
const color = this[kind][index];
if (color) this._applyColor(color);
else this._setSlot(kind, index, this.currentColor);
}
_onContextMenu(e) {
const swatch = e.target.closest("[data-kind]");
if (!swatch) return;
e.preventDefault();
this._openMenu(swatch, e.clientX, e.clientY);
}
_selectWell(index) {
this._activeWell = index;
this._applyColor(this.currentColor);
}
_applyColor(color) {
this._wells[this._activeWell] = color;
this._onColorChange(color);
this._refresh();
}
_addCurrent() {
const color = this.currentColor;
if (this.custom.includes(color)) {
this._toast(t("imageEditPaletteExists"), "info");
return;
}
const index = this.custom.indexOf(null);
if (index < 0) {
this._toast(t("imageEditPaletteFull"), "error");
return;
}
this._setSlot("custom", index, color);
}
_setSlot(kind, index, color) {
this[kind][index] = color;
try {
localStorage.setItem(STORAGE_KEY, JSON.stringify({ base: this.base, custom: this.custom }));
} catch { /* 保存できなくてもこのセッション中は使える */ }
this._refresh();
}
_openMenu(swatch, x, y) {
this.closeMenu();
const { kind, index } = swatch.dataset;
const color = this[kind][index];
const items = [
["imageEditPaletteRegisterCurrent", () => this._setSlot(kind, index, this.currentColor)],
[color ? "imageEditPaletteEditColor" : "imageEditPalettePickColor", () => this._openPicker(kind, index, x, y)],
];
if (kind === "custom" && color) {
items.push(["imageEditPaletteDelete", () => this._setSlot(kind, index, null)]);
}
if (kind === "base" && color !== DEFAULT_BASE[index]) {
items.push(["imageEditPaletteResetBase", () => this._setSlot(kind, index, DEFAULT_BASE[index])]);
}
const menu = document.createElement("div");
menu.className = "ie-palette-menu";
for (const [key, action] of items) {
const button = document.createElement("button");
button.type = "button";
button.textContent = t(key);
button.addEventListener("click", () => { this.closeMenu(); action(); });
menu.appendChild(button);
}
this._content.closest("#wfm-tab-image-edit").appendChild(menu);
menu.style.left = `${Math.min(x, window.innerWidth - menu.offsetWidth - 4)}px`;
menu.style.top = `${Math.min(y, window.innerHeight - menu.offsetHeight - 4)}px`;
this._menu = menu;
document.addEventListener("pointerdown", this._closeMenuOnOutside, true);
document.addEventListener("keydown", this._closeMenuOnEscape, true);
}
_openPicker(kind, index, x, y) {
this._pickerTarget = { kind, index };
this._picker.value = this[kind][index] ?? this.currentColor;
this._picker.style.left = `${x}px`;
this._picker.style.top = `${y}px`;
this._picker.click();
}
_onPickerInput() {
const { kind, index } = this._pickerTarget;
this._setSlot(kind, index, this._picker.value);
this._applyColor(this._picker.value);
}
}
+1 -1
View File
@@ -12,7 +12,7 @@ export class DrawTool {
this.brushSize = 20;
this.hardness = 0.8; // 0.0 = very soft, 1.0 = hard edge
this.opacity = 1.0;
this.color = "#ff0000";
this.color = "#000000";
this.mode = "draw"; // "draw" | "erase"
this.spacing = 0.25; // stamp interval as fraction of brushSize (image brush only)
this.angle = 0; // degrees [0, 359]
+47 -4
View File
@@ -19,6 +19,7 @@ import { syncJsonHighlight, syncScroll } from "./json-highlight.js";
import { _expandWildcardsInWorkflow } from "./generate-tab.js";
import { pmGroups, getPresetsInGroup } from "./prompt-presets.js";
import { isVideoFilename, extractLastFrameBlob } from "./video-utils.js";
import { translateButtonsHtml, attachTranslateButtons, isAutoTranslateOn, translateWorkflowPrompts } from "./prompt-translate.js";
// Checkpoint/LoRA/VAE are three fully independent keyframe timelines — same as
// Prompt/KSampler — each with its own +/-, its own atIteration sequence, its own
@@ -167,6 +168,15 @@ export function refreshLabLiveDefaults() {
_renderAllColumns();
}
// Loads plan data built elsewhere (AI TOOL Chat's ```labplan block → Storyboard) into the Lab
// tab as an unsaved plan, then switches to GenerateUI > Lab so the user can review and Run it.
// The user saves it with Lab's own Save button (which also builds the index thumbnail).
export function openLabPlanData(data) {
_applyPlanData(null, data);
document.querySelector('.wfm-tab[data-tab="generate"]')?.click();
document.querySelector('.wfm-gen-subtab-btn[data-subtab="lab"]')?.click();
}
function _initDropZone() {
const dropZone = document.getElementById("wfm-lab-drop-zone");
const fileInput = document.getElementById("wfm-lab-file-input");
@@ -679,12 +689,18 @@ function _cellLabel(col, kf) {
return `<span class="wfm-lab-cell-prompt-line">P: ${escapeHtml(p)}</span><span class="wfm-lab-cell-prompt-line">N: ${escapeHtml(n)}</span>`;
}
if (col === "ksampler") {
// Same six fields _isEmptyValue checks — a keyframe that only sets the seed (e.g. a
// Storyboard plan's fixed seed) or the sampler/scheduler used to read "(workflow
// default)" even though Run does apply it.
const v = kf.value || {};
if (v.steps == null && v.cfg == null && v.denoise == null) return t("labUseWorkflowDefault");
const parts = [];
if (v.steps != null) parts.push(`Step${v.steps}`);
if (v.cfg != null) parts.push(`CFG${v.cfg}`);
if (v.denoise != null) parts.push(`Denoise${v.denoise}`);
if (v.sampler_name) parts.push(v.sampler_name);
if (v.scheduler) parts.push(v.scheduler);
if (v.seed != null) parts.push(`Seed ${v.seed}`);
if (!parts.length) return t("labUseWorkflowDefault");
return escapeHtml(parts.join(" / "));
}
return "";
@@ -819,11 +835,17 @@ function _openCellModal(col, idx) {
<button type="button" id="wfm-lab-modal-clear" class="wfm-btn wfm-btn-sm">${t("labClearPrompt")}</button>
</div>
<div class="wfm-lab-modal-row">
<label>Positive</label>
<div style="display:flex;align-items:center;gap:6px;">
<label style="flex:1;">Positive</label>
${translateButtonsHtml("wfm-lab-modal-positive")}
</div>
<textarea id="wfm-lab-modal-positive" class="wfm-input" rows="3">${escapeHtml(v.positive || "")}</textarea>
</div>
<div class="wfm-lab-modal-row">
<label>Negative</label>
<div style="display:flex;align-items:center;gap:6px;">
<label style="flex:1;">Negative</label>
${translateButtonsHtml("wfm-lab-modal-negative")}
</div>
<textarea id="wfm-lab-modal-negative" class="wfm-input" rows="3">${escapeHtml(v.negative || "")}</textarea>
</div>
<div class="wfm-lab-modal-checkbox">
@@ -900,7 +922,10 @@ function _openCellModal(col, idx) {
<button id="wfm-lab-modal-save" class="wfm-btn wfm-btn-primary">${t("save")}</button>
</div>`;
openModal(`${col} #${idx + 1}`, html);
if (col === "prompt") _wireLabPromptModalExtras(idx);
if (col === "prompt") {
_wireLabPromptModalExtras(idx);
attachTranslateButtons(document.getElementById("wfm-lab-modal-fields") || document);
}
if (col === "checkpoint" || col === "vae") _wireLabValueFilter(col);
if (col === "lora") _wireLabLoraFilter();
@@ -1437,6 +1462,10 @@ async function _runLabBatch() {
// mid-batch (see comfyWorkflow.isVideoWorkflow and generate-tab.js's own use of this).
const isVideoWf = comfyWorkflow.isVideoWorkflow(comfyUI.currentAnalysis);
// Settings -> Prompt Translation -> "Lab Run": translate each iteration's prompts
// (the plan itself keeps the original text).
const autoTranslate = await isAutoTranslateOn("lab");
let completed = 0, failed = 0;
let prevLoraInjection = null;
try {
@@ -1450,6 +1479,20 @@ async function _runLabBatch() {
const { workflow, seed, loraInjection } = _buildWorkflowForIteration(i, chainRef, prevLoraInjection);
prevLoraInjection = loraInjection;
const workflowExpanded = await _expandWildcardsInWorkflow(workflow);
if (autoTranslate) {
try {
if (progressText) progressText.textContent = `[${i}/${_lab.batchCount}] ${t("promptTranslateRunning")}`;
await translateWorkflowPrompts(workflowExpanded, comfyUI.currentAnalysis.prompt_nodes);
} catch (err) {
// Do not send untranslated text - stop the batch like GenerateUI does.
// The end-of-batch "stopped" toast replaces this one, so also keep the
// reason in the progress line.
showToast(t("promptTranslateError", err.message), "error");
if (progressText) progressText.textContent = t("promptTranslateError", err.message);
_aborted = true;
break;
}
}
try {
const { images } = await comfyUI.generate(workflowExpanded, {
+2 -1
View File
@@ -672,7 +672,8 @@ function extractPromptsAPI(wf) {
const srcNode = wf[String(val[0])];
// TextEncodeFibo2(Fibo 2.0)も同形。promptはPreviewAny→プロンプト強化スイッチ経由でリンクされる。
if (srcNode?.class_type === "TextEncodeMageFlowEdit" || srcNode?.class_type === "TextEncodeBooguEdit"
|| srcNode?.class_type === "TextEncodeFibo2") {
|| srcNode?.class_type === "TextEncodeFibo2" || srcNode?.class_type === "PH3ImageConditioning"
|| srcNode?.class_type === "MiniMaxH3ImageConditioning") {
const raw = isPos ? srcNode.inputs?.prompt : srcNode.inputs?.negative_prompt;
const text = Array.isArray(raw) ? resolveLinkedText(wf, raw[0], raw[1] ?? 0) : raw;
if (text && typeof text === "string") { if (isPos) pos.add(text); else neg.add(text); }
+217
View File
@@ -0,0 +1,217 @@
/**
* ocr-tools.js — AI TOOL > TOOLS: OCR (text extraction) with Ollama OCR models.
*
* Ported from ComfyUI Comic Creator's OCR tab (static/js/ocr-core.js + main/29-ocr-tab.js),
* keeping only the general-purpose part: read the text of one image, optionally with boxes.
* What carried over from CC's measurements:
* - Send a JPEG whose long side is <= 1600 px with transparent areas filled white.
* - temperature 0; retry once on HTTP 500 (the runner can drop right after a model swap).
* - LightOnOCR sometimes returns nothing or loops on dense images; a grayscale copy often works,
* so an empty / repetitive result is retried once in grayscale.
* - Per-model prompts: PaddleOCR-VL "OCR:", GLM-OCR "Text Recognition:".
*
* Measured in WFS (2026-11-11, mixed JA/EN test page with a vertical column):
* LightOnOCR-3 4b text-only 1.1 s / boxes 7.9 s, 100 % PaddleOCR-VL-manga 3.9 s, 100 %
* unlimited-ocr (DeepSeek-OCR) 14 s, 100 %, always emits boxes
* PaddleOCR-VL 1.6 11 s and GLM-OCR 15 s missed the vertical column (94 %).
* Hence LightOnOCR is preferred, and boxes are only requested when the user asks for them.
*/
export const SEND_MAX_SIDE = 1600;
// Preference order when picking the default OCR model from what Ollama has installed.
const MODEL_PREFERENCE = [/lighton/i, /paddleocr.*manga/i, /paddleocr/i, /deepseek.*ocr|unlimited-ocr/i, /glm-ocr/i, /ocr/i];
export const BOX_PROMPT = "Detect all text regions and output each as text with bounding box [x1,y1,x2,y2] normalized to 0-1000.";
const PLAIN_PROMPT = "Extract all text from this image.";
/** Installed Ollama models that look like OCR models, best first. */
export async function listOcrModels(baseUrl) {
const res = await fetch(`${baseUrl.replace(/\/+$/, "")}/api/tags`);
if (!res.ok) throw new Error(`HTTP ${res.status}`);
const names = ((await res.json()).models || []).map((m) => m.name).filter((n) => /ocr/i.test(n));
const rank = (n) => { const i = MODEL_PREFERENCE.findIndex((re) => re.test(n)); return i < 0 ? 99 : i; };
return names.sort((a, b) => rank(a) - rank(b) || a.localeCompare(b));
}
/** Can this model return text positions? (LightOnOCR on request, DeepSeek-OCR always) */
export function supportsBoxes(model) {
return /lighton|unlimited-ocr|deepseek.*ocr/i.test(String(model || ""));
}
export function ocrPrompt(model, withBoxes) {
const m = String(model || "");
if (/lighton/i.test(m)) return withBoxes ? BOX_PROMPT : PLAIN_PROMPT;
if (/paddle/i.test(m)) return "OCR:";
if (/glm-ocr/i.test(m)) return "Text Recognition:";
if (/unlimited-ocr|deepseek.*ocr/i.test(m)) return "Free OCR.";
return PLAIN_PROMPT;
}
// ---------------------------------------------------------------------------
// Parsing
// ---------------------------------------------------------------------------
const clamp01 = (v) => Math.min(1, Math.max(0, v));
function makeBox(label, x1, y1, x2, y2, text) {
const a = clamp01(Math.min(x1, x2)), b = clamp01(Math.min(y1, y2));
const c = clamp01(Math.max(x1, x2)), d = clamp01(Math.max(y1, y2));
if (c - a < 0.004 || d - b < 0.004) return null;
return { label: label || "text", x1: a, y1: b, x2: c, y2: d, text: cleanLine(text) };
}
// Markdown decorations the OCR models add (headings, bold, rules)
function cleanLine(s) {
return String(s || "")
.replace(/^\s*#{1,6}\s*/gm, "")
.replace(/\*\*([^*]+)\*\*/g, "$1")
.replace(/^\s*(-{3,}|\*{3,}|_{3,})\s*$/gm, "")
.trim();
}
/**
* Boxes from either syntax (coordinates normalized 0-1000, x1,y1,x2,y2):
* LightOnOCR `![label](x1,y1,x2,y2) text`
* DeepSeek-OCR `label [x1, y1, x2, y2]text` (one per line)
* Returns [{ label, x1, y1, x2, y2, text }] with 0-1 coordinates.
*/
export function parseOcrBoxes(raw) {
const s = String(raw || "");
const out = [];
const md = s.split(/(?=!\[[^\]]*\]\(\s*\d+\s*,\s*\d+\s*,\s*\d+\s*,\s*\d+\s*\))/);
for (const chunk of md) {
const m = chunk.match(/^!\[([^\]]*)\]\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*\)([\s\S]*)$/);
if (!m) continue;
const box = makeBox(m[1], +m[2] / 1000, +m[3] / 1000, +m[4] / 1000, +m[5] / 1000, m[6]);
if (box) out.push(box);
}
if (out.length) return out;
for (const line of s.split(/\r?\n/)) {
const m = line.match(/^\s*([a-z_]+)?\s*\[\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*\]\s*(.*)$/i);
if (!m) continue;
const box = makeBox(m[1], +m[2] / 1000, +m[3] / 1000, +m[4] / 1000, +m[5] / 1000, m[6]);
if (box) out.push(box);
}
return out;
}
/** Plain text of an OCR reply: box tokens and Markdown decorations removed, blank runs collapsed. */
export function ocrPlainText(raw, boxes = null) {
const list = boxes || parseOcrBoxes(raw);
if (list.length) return list.map((b) => b.text).filter(Boolean).join("\n");
// Model special tokens (<|ref|> etc.) and Markdown decorations removed, line by line;
// blank lines between paragraphs are kept but never more than one in a row.
return String(raw || "").replace(/<\|[^|]*\|>/g, "")
.split(/\r?\n/).map((l) => cleanLine(l))
.join("\n").replace(/\n{3,}/g, "\n\n").trim();
}
// Empty, or the same line over and over (LightOnOCR's failure mode on dense images)
export function ocrLooksFailed(text) {
const lines = String(text || "").split(/\n/).map((l) => l.trim()).filter(Boolean);
if (!lines.length) return true;
return lines.length >= 30 && new Set(lines).size / lines.length < 0.5;
}
// ---------------------------------------------------------------------------
// Image + model call
// ---------------------------------------------------------------------------
/** base64 image → JPEG base64 (long side <= maxSide, white background, optional grayscale). */
export async function prepareOcrImage(base64, mimeType, { maxSide = SEND_MAX_SIDE, gray = false } = {}) {
const img = await new Promise((resolve, reject) => {
const el = new Image();
el.onload = () => resolve(el);
el.onerror = () => reject(new Error("image load failed"));
el.src = `data:${mimeType || "image/png"};base64,${base64}`;
});
const k = Math.min(1, maxSide / Math.max(img.naturalWidth || 1, img.naturalHeight || 1));
const cv = document.createElement("canvas");
cv.width = Math.max(1, Math.round(img.naturalWidth * k));
cv.height = Math.max(1, Math.round(img.naturalHeight * k));
const cx = cv.getContext("2d");
cx.fillStyle = "#fff";
cx.fillRect(0, 0, cv.width, cv.height);
cx.drawImage(img, 0, 0, cv.width, cv.height);
if (gray) {
const d = cx.getImageData(0, 0, cv.width, cv.height), p = d.data;
for (let i = 0; i < p.length; i += 4) {
const y = (p[i] * 299 + p[i + 1] * 587 + p[i + 2] * 114) / 1000;
p[i] = p[i + 1] = p[i + 2] = y;
}
cx.putImageData(d, 0, 0);
}
return cv.toDataURL("image/jpeg", 0.92).split(",")[1];
}
async function ollamaOcrChat(baseUrl, model, prompt, b64, retry = true) {
const res = await fetch(`${baseUrl.replace(/\/+$/, "")}/api/chat`, {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({
model, stream: false, think: false,
messages: [{ role: "user", content: prompt, images: [b64] }],
options: { temperature: 0, num_predict: 4096 },
}),
});
if (res.status === 500 && retry) {
await new Promise((r) => setTimeout(r, 800));
return ollamaOcrChat(baseUrl, model, prompt, b64, false);
}
if (!res.ok) throw new Error(`HTTP ${res.status} ${(await res.text().catch(() => "")).slice(0, 200)}`);
return (await res.json()).message?.content || "";
}
/**
* Read one image. Returns { text, boxes, retriedGray, ms }.
* withBoxes only takes effect for models that support positions (supportsBoxes).
*/
export async function runOcr({ baseUrl, model, base64, mimeType, withBoxes = false }) {
const started = performance.now();
const prompt = ocrPrompt(model, withBoxes && supportsBoxes(model));
const read = async (gray) => {
const raw = await ollamaOcrChat(baseUrl, model, prompt, await prepareOcrImage(base64, mimeType, { gray }));
// Only boxes with text: the result shows one line per box, so box #n == line #n
// (image regions without text would shift the numbering).
const all = parseOcrBoxes(raw);
const boxes = all.filter((b) => b.text);
return { boxes, text: all.length ? boxes.map((b) => b.text).join("\n") : ocrPlainText(raw) };
};
let r = await read(false);
let retriedGray = false;
if (ocrLooksFailed(r.text)) {
const g = await read(true);
if (!ocrLooksFailed(g.text) || g.text.length > r.text.length) { r = g; retriedGray = true; }
}
return { ...r, retriedGray, ms: Math.round(performance.now() - started) };
}
/**
* Draw boxes over an <img> shown with object-fit: contain inside `container`.
* Each box gets a small numbered tag; clicking it calls onPick(index).
*/
export function renderOcrOverlay(container, img, boxes, onPick) {
container.innerHTML = "";
if (!img || !boxes?.length || !img.naturalWidth) { container.style.display = "none"; return; }
const cw = img.clientWidth, ch = img.clientHeight;
const k = Math.min(cw / img.naturalWidth, ch / img.naturalHeight);
const w = img.naturalWidth * k, h = img.naturalHeight * k;
const ox = img.offsetLeft + (cw - w) / 2, oy = img.offsetTop + (ch - h) / 2;
boxes.forEach((b, i) => {
const el = document.createElement("div");
el.className = "wfm-ai-ocr-box";
el.style.left = `${ox + b.x1 * w}px`;
el.style.top = `${oy + b.y1 * h}px`;
el.style.width = `${(b.x2 - b.x1) * w}px`;
el.style.height = `${(b.y2 - b.y1) * h}px`;
el.title = b.text;
const tag = document.createElement("span");
tag.className = "wfm-ai-ocr-box-tag";
tag.textContent = String(i + 1);
el.appendChild(tag);
el.addEventListener("click", (e) => { e.stopPropagation(); onPick?.(i); });
container.appendChild(el);
});
container.style.display = "";
}
+74
View File
@@ -0,0 +1,74 @@
/**
* PLaMo Translate over a chat API (Ollama /api/chat, LM Studio, ...).
*
* PLaMo Translate is a translation-only model. Its chat template treats the user
* message as source text and a system message that does not start with
* "[plamo-translate]" as mere context, so instruction prompts are translated or
* ignored and the direction falls back to Japanese <-> English auto-switching.
* Per the model card, chat clients pass the languages in a leading
* "[plamo-translate]" system message and send the text alone.
*
* Keep in sync with the inline copy in web/comfyui/node_sets_menu.js (side panel A tab),
* which cannot import from static/.
*/
// Languages PLaMo 3 Translate supports.
export const PLAMO_LANGS = [
"ar", "az", "be", "bg", "bn", "ca", "ceb", "de", "en", "es", "et", "eu", "fa", "fr", "gu", "he",
"hi", "hr", "hu", "hy", "id", "it", "ja", "jv", "ka", "kk", "km", "ko", "lt", "lv", "ml", "mr",
"ms", "my", "ne", "nl", "pa", "pl", "ru", "si", "sk", "sl", "sr", "sw", "ta", "te", "th", "tl",
"ur", "uz", "vi", "zh",
];
export const PLAMO_STOP = ["<|plamo:tag|>", "<|plamo:bos|>"];
export function isPlamoModel(model) {
return /plamo/i.test(model || "");
}
let _nameMap = null;
function _buildNameMap() {
const map = new Map();
const locales = ["en", "ja", "zh", typeof navigator !== "undefined" ? navigator.language : "en"];
for (const code of PLAMO_LANGS) {
map.set(code, code);
for (const loc of [...locales, code]) { // `code` adds the endonym (français, 한국어, ...)
try {
const name = new Intl.DisplayNames([loc], { type: "language" }).of(code);
if (name) map.set(name.toLowerCase(), code);
} catch { /* Intl.DisplayNames unavailable */ }
}
}
// Common spellings Intl does not produce
[["chinese", "zh"], ["中文", "zh"], ["中国語", "zh"], ["filipino", "tl"], ["tagalog", "tl"], ["persian", "fa"], ["farsi", "fa"]]
.forEach(([k, v]) => map.set(k, v));
return map;
}
/** "ja" / "Japanese" / "日本語" / "French" -> PLaMo language code, or "" when unknown. */
export function plamoLangCode(nameOrCode) {
const key = (nameOrCode || "").trim().toLowerCase();
if (!key) return "";
if (!_nameMap) _nameMap = _buildNameMap();
return _nameMap.get(key) || _nameMap.get(key.split(/[-_]/)[0]) || "";
}
/**
* Chat messages for translating ``text`` with PLaMo. ``src``/``dst`` are codes or
* language names; an unknown source is left to auto-detection. Throws when the
* target language is not one PLaMo supports.
*/
export function buildPlamoMessages(text, src, dst) {
const dstCode = plamoLangCode(dst);
if (!dstCode) throw new Error(`PLaMo Translate does not support the target language "${dst}"`);
const srcCode = plamoLangCode(src);
const header = `[plamo-translate]\ntarget_lang=${dstCode}` + (srcCode && srcCode !== dstCode ? `\nsource_lang=${srcCode}` : "");
return [
{ role: "system", content: header },
{ role: "user", content: text },
];
}
export function cleanPlamoOutput(text) {
return (text || "").replace(/<\|plamo:[a-z_]+\|>/g, "").trim();
}
+57 -9
View File
@@ -46,30 +46,37 @@ function _stripThinkingTags(text) {
}
// Ollamaは `think` (bool) と `options.num_predict`、OpenAI互換は `max_tokens` で制御
function _applyGenOptions(body, backend, cfg) {
// extra: { temperature, stop, noThink } — 翻訳専用モデル(PLaMo)向けの追加指定
function _applyGenOptions(body, backend, cfg, extra = {}) {
if (backend === "ollama") {
body.think = !!cfg.thinkingMode;
if (cfg.maxTokens > 0) body.options = { ...(body.options || {}), num_predict: cfg.maxTokens };
} else if (cfg.maxTokens > 0) {
body.max_tokens = cfg.maxTokens;
if (!extra.noThink) body.think = !!cfg.thinkingMode;
const opts = { ...(body.options || {}) };
if (cfg.maxTokens > 0) opts.num_predict = cfg.maxTokens;
if (extra.temperature !== undefined) opts.temperature = extra.temperature;
if (extra.stop) opts.stop = extra.stop;
if (Object.keys(opts).length) body.options = opts;
} else {
if (cfg.maxTokens > 0) body.max_tokens = cfg.maxTokens;
if (extra.temperature !== undefined) body.temperature = extra.temperature;
if (extra.stop) body.stop = extra.stop;
}
return body;
}
async function chatWithAi(model, messages) {
async function chatWithAi(model, messages, extra = {}) {
const cfg = getPromptAiConfig();
const { backend, url } = cfg;
if (backend === "ollama") {
const res = await fetch(`${url}/api/chat`, {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify(_applyGenOptions({ model, messages, stream: false }, backend, cfg)),
body: JSON.stringify(_applyGenOptions({ model, messages, stream: false }, backend, cfg, extra)),
});
if (!res.ok) throw new Error(`HTTP ${res.status}`);
const text = (await res.json()).message?.content || "";
return cfg.thinkingMode ? text : _stripThinkingTags(text);
} else if (backend === "unsloth") {
const body = _applyGenOptions({ model, messages: _toOpenAiMessages(messages), stream: false }, backend, cfg);
const body = _applyGenOptions({ model, messages: _toOpenAiMessages(messages), stream: false }, backend, cfg, extra);
const data = await unslothProxy(url, "/v1/chat/completions", "POST", body);
const msg = data.choices?.[0]?.message;
// Unslothはreasoningを別フィールドで返すため<think>タグに畳んで表示に混ぜる
@@ -80,7 +87,7 @@ async function chatWithAi(model, messages) {
const res = await fetch(`${url}/v1/chat/completions`, {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify(_applyGenOptions({ model, messages: _toOpenAiMessages(messages), stream: false }, backend, cfg)),
body: JSON.stringify(_applyGenOptions({ model, messages: _toOpenAiMessages(messages), stream: false }, backend, cfg, extra)),
});
if (!res.ok) throw new Error(`HTTP ${res.status}`);
const text = (await res.json()).choices?.[0]?.message?.content || "";
@@ -141,6 +148,25 @@ function addChatMessage(role, content) {
chat.scrollTop = chat.scrollHeight;
}
// 応答待ちの間だけ表示するプレースホルダ(初回はモデル読み込みで十数秒かかることがある)
function _addPendingMessage(text) {
const chat = document.getElementById("wfm-ollama-chat");
if (!chat) return null;
const msg = document.createElement("div");
msg.className = "wfm-ollama-msg assistant wfm-ollama-pending";
const roleLabel = document.createElement("div");
roleLabel.className = "wfm-ollama-msg-role";
roleLabel.textContent = "AI";
const contentDiv = document.createElement("div");
contentDiv.className = "wfm-ollama-msg-content";
contentDiv.style.opacity = "0.6";
contentDiv.textContent = text;
msg.append(roleLabel, contentDiv);
chat.appendChild(msg);
chat.scrollTop = chat.scrollHeight;
return msg;
}
function clearChat() {
ollamaState.chatHistory = [];
ollamaState.attachedImage = null;
@@ -243,13 +269,16 @@ async function sendMessage() {
const sendBtn = document.getElementById("wfm-ollama-send-btn");
if (sendBtn) sendBtn.disabled = true;
const pending = _addPendingMessage("…");
try {
const reply = await chatWithAi(model, ollamaState.chatHistory);
pending?.remove();
addChatMessage("assistant", reply);
ollamaState.chatHistory.push({ role: "assistant", content: reply });
ollamaState.attachedImage = null;
updateAttachmentDisplay();
} catch (err) {
pending?.remove();
showToast(t("error") + ": " + err.message, "error");
} finally {
if (sendBtn) sendBtn.disabled = false;
@@ -281,7 +310,24 @@ async function sendTranslate(direction) {
.map((id) => document.getElementById(id));
btns.forEach((b) => { if (b) b.disabled = true; });
const pending = _addPendingMessage(t("aiTranslating"));
try {
// PLaMo Translate is a translation-only model: anything in the user message is
// treated as source text, so an instruction prompt gets translated too, and without
// an explicit target it only switches between Japanese and English (ZH→EN / EN→ZH
// came out in Japanese). Per its model card, Ollama/LM Studio clients pass the
// languages in a leading "[plamo-translate]" system message and send the text alone.
if (/plamo/i.test(model)) {
const [src, dst] = { ja2en: ["ja", "en"], en2ja: ["en", "ja"], zh2en: ["zh", "en"], en2zh: ["en", "zh"] }[direction];
const reply = await chatWithAi(model, [
{ role: "system", content: `[plamo-translate]\ntarget_lang=${dst}\nsource_lang=${src}` },
{ role: "user", content: text },
], { temperature: 0, stop: ["<|plamo:tag|>", "<|plamo:bos|>"], noThink: true });
pending?.remove();
addChatMessage("assistant", reply.replace(/<\|plamo:[a-z_]+\|>/g, "").trim());
return;
}
const prompts = {
ja2en: `Translate the following Japanese text into English. Output only the translated text, nothing else.\n\n${text}`,
en2ja: `以下の英語のテキストを日本語に翻訳してください。翻訳結果のみを出力し、他の説明は不要です。\n\n${text}`,
@@ -291,8 +337,10 @@ async function sendTranslate(direction) {
const prompt = prompts[direction];
const reply = await chatWithAi(model, [{ role: "user", content: prompt }]);
pending?.remove();
addChatMessage("assistant", reply);
} catch (err) {
pending?.remove();
showToast(t("error") + ": " + err.message, "error");
} finally {
btns.forEach((b) => { if (b) b.disabled = false; });
+279
View File
@@ -0,0 +1,279 @@
/**
* Settings tab section for Prompt Translate (see prompt-translate.js).
* Values live in the server settings.json so the backend can read them.
*/
import { showToast } from "./app.js";
import { t, getLang } from "./i18n.js";
import { escapeHtml } from "./util.js";
import { setTranslateConfig, translatePrompt } from "./prompt-translate.js";
const DEFAULT_URL = "http://localhost:11434";
const DEFAULT_MODEL = "hf.co/pfnet/plamo-3-translate-2b-GGUF:Q4_K_M";
// Languages PLaMo 3 Translate supports (English is the target, so it is left out).
const SOURCE_LANGS = [
"ja", "zh", "ko", "ar", "az", "be", "bg", "bn", "ca", "ceb", "de", "es", "et", "eu", "fa", "fr",
"gu", "he", "hi", "hr", "hu", "hy", "id", "it", "jv", "ka", "kk", "km", "lt", "lv", "ml", "mr",
"ms", "my", "ne", "nl", "pa", "pl", "ru", "si", "sk", "sl", "sr", "sw", "ta", "te", "th", "tl",
"ur", "uz", "vi",
];
const SAMPLE_TEXT = {
ja: "夕焼けの海辺に立つ少女、(長い黒髪:1.2), masterpiece",
zh: "站在夕阳海边的少女, (长长的黑发:1.2), masterpiece",
};
function _langName(code) {
try {
const dn = new Intl.DisplayNames([getLang() || "en"], { type: "language" });
return dn.of(code) || code;
} catch {
return code;
}
}
export function promptTranslateSettingsHtml(s) {
const enabled = !!s.prompt_translate_enabled;
const src = s.prompt_translate_source_lang || "auto";
const unload = s.prompt_translate_unload !== false;
const cpu = s.prompt_translate_device === "cpu";
return `
<details class="wfm-settings-section" id="wfm-pt-settings">
<summary class="wfm-settings-summary">${t("promptTranslateSection")}</summary>
<div class="wfm-form-group">
<label style="display:flex;align-items:center;gap:6px;cursor:pointer;">
<input type="checkbox" id="wfm-pt-enabled" ${enabled ? "checked" : ""}>
<span>${t("promptTranslateEnable")}</span>
</label>
<small style="color:var(--wfm-text-secondary);font-size:11px;display:block;margin-top:4px;">
${t("promptTranslateHint")}
</small>
</div>
<div id="wfm-pt-body" style="${enabled ? "" : "opacity:0.55;"}">
<div class="wfm-form-group">
<label>${t("promptTranslateAutoHeading")}</label>
<label style="display:flex;align-items:center;gap:6px;cursor:pointer;">
<input type="checkbox" id="wfm-pt-auto" ${s.prompt_translate_auto ? "checked" : ""}>
<span>${t("promptTranslateAuto")}</span>
</label>
<label style="display:flex;align-items:center;gap:6px;cursor:pointer;margin-top:2px;">
<input type="checkbox" id="wfm-pt-auto-lab" ${s.prompt_translate_auto_lab ? "checked" : ""}>
<span>${t("promptTranslateAutoLab")}</span>
</label>
<label style="display:flex;align-items:center;gap:6px;cursor:pointer;margin-top:2px;">
<input type="checkbox" id="wfm-pt-auto-video" ${s.prompt_translate_auto_video ? "checked" : ""}>
<span>${t("promptTranslateAutoVideo")}</span>
</label>
<small style="color:var(--wfm-text-secondary);font-size:11px;display:block;margin-top:4px;">
${t("promptTranslateAutoHint")}
</small>
</div>
<div class="wfm-form-group">
<label>${t("promptTranslateDevice")}</label>
<select class="wfm-select" id="wfm-pt-device" style="width:100%;">
<option value="gpu" ${cpu ? "" : "selected"}>${t("promptTranslateDeviceGpu")}</option>
<option value="cpu" ${cpu ? "selected" : ""}>${t("promptTranslateDeviceCpu")}</option>
</select>
<label id="wfm-pt-unload-label" style="display:flex;align-items:center;gap:6px;cursor:pointer;margin-top:6px;${cpu ? "opacity:0.5;" : ""}">
<input type="checkbox" id="wfm-pt-unload" ${unload ? "checked" : ""} ${cpu ? "disabled" : ""}>
<span>${t("promptTranslateUnload")}</span>
</label>
<small style="color:var(--wfm-text-secondary);font-size:11px;display:block;margin-top:4px;">
${t("promptTranslateDeviceHint")}
</small>
</div>
<div class="wfm-form-group">
<label>${t("promptTranslateSourceLang")}</label>
<select class="wfm-select" id="wfm-pt-source-lang" style="width:100%;">
<option value="auto" ${src === "auto" ? "selected" : ""}>${t("promptTranslateSourceAuto")}</option>
${SOURCE_LANGS.map((c) => `<option value="${c}" ${src === c ? "selected" : ""}>${escapeHtml(_langName(c))} (${c})</option>`).join("")}
</select>
</div>
<div class="wfm-form-group">
<label>${t("promptTranslateUrl")}</label>
<div style="display:flex;gap:8px;">
<input type="text" class="wfm-input" id="wfm-pt-url" value="${escapeHtml(s.prompt_translate_url || "")}" placeholder="${DEFAULT_URL}">
<button class="wfm-btn wfm-btn-sm" id="wfm-pt-url-save">${t("save")}</button>
</div>
</div>
<div class="wfm-form-group">
<label>${t("promptTranslateModel")}</label>
<div style="display:flex;gap:8px;">
<select class="wfm-select" id="wfm-pt-model" style="flex:1;min-width:0;">
<option value="${escapeHtml(s.prompt_translate_model || DEFAULT_MODEL)}" selected>${escapeHtml(s.prompt_translate_model || DEFAULT_MODEL)}</option>
</select>
<button class="wfm-btn wfm-btn-sm" id="wfm-pt-model-refresh">${t("refresh")}</button>
<button class="wfm-btn wfm-btn-sm" id="wfm-pt-model-pull" style="display:none;">${t("promptTranslatePull")}</button>
</div>
<small id="wfm-pt-model-hint" style="color:var(--wfm-text-secondary);font-size:11px;display:block;margin-top:4px;">
${t("promptTranslateModelHint")}
</small>
</div>
<div class="wfm-form-group">
<div style="display:flex;gap:8px;align-items:center;">
<button class="wfm-btn wfm-btn-sm" id="wfm-pt-test">${t("test")}</button>
<span id="wfm-pt-test-status" style="font-size:12px;word-break:break-all;"></span>
</div>
</div>
</div>
</details>`;
}
export function initPromptTranslateSettings(serverSettings, saveServerSettings) {
const $ = (id) => document.getElementById(id);
let installed = [];
let presets = [];
const save = async (patch, toast = true) => {
try {
const res = await saveServerSettings(patch);
if (res?.error) throw new Error(res.error);
Object.assign(serverSettings, patch);
setTranslateConfig(patch);
if (toast) showToast(t("promptTranslateSaved"), "success");
return true;
} catch (err) {
showToast(t("errorWithMsg", err.message), "error");
return false;
}
};
const currentModel = () => serverSettings.prompt_translate_model || DEFAULT_MODEL;
const renderModelOptions = () => {
const sel = $("wfm-pt-model");
if (!sel) return;
const cur = currentModel();
const plamoInstalled = installed.filter((m) => /plamo/i.test(m));
// Embedding-only models cannot generate text, so they are not offered.
const others = installed.filter((m) => !/plamo/i.test(m) && !/embed|minilm/i.test(m));
const missingPresets = presets.filter((p) => !installed.includes(p));
const opt = (v, label) => `<option value="${escapeHtml(v)}" ${v === cur ? "selected" : ""}>${escapeHtml(label || v)}</option>`;
let html = "";
if (plamoInstalled.length) html += `<optgroup label="PLaMo 3 Translate">${plamoInstalled.map((m) => opt(m)).join("")}</optgroup>`;
if (missingPresets.length) html += `<optgroup label="${escapeHtml(t("promptTranslateNotPulled"))}">${missingPresets.map((m) => opt(m, `${m} ${t("promptTranslateNotPulledMark")}`)).join("")}</optgroup>`;
if (others.length) html += `<optgroup label="${escapeHtml(t("promptTranslateOtherModels"))}">${others.map((m) => opt(m)).join("")}</optgroup>`;
if (![...installed, ...presets].includes(cur)) html = opt(cur) + html;
sel.innerHTML = html;
updatePullButton();
};
const updatePullButton = () => {
const btn = $("wfm-pt-model-pull");
if (!btn) return;
const m = currentModel();
btn.style.display = presets.includes(m) && !installed.includes(m) ? "" : "none";
};
const refreshModels = async (quiet = false) => {
try {
const res = await fetch("/api/wfm/translate/models");
const data = await res.json();
presets = data.presets || [];
if (data.status !== "success") throw new Error(data.message || `HTTP ${res.status}`);
installed = data.models || [];
} catch (err) {
installed = [];
if (!quiet) showToast(t("promptTranslateModelsError", err.message), "error");
}
renderModelOptions();
};
// CPU mode keeps the model resident: preload it now, and release it when leaving CPU mode
// or turning the feature off so it does not sit in RAM unused.
const postTranslate = (path) => fetch(`/api/wfm/translate/${path}`, { method: "POST" }).catch(() => {});
const isCpu = () => serverSettings.prompt_translate_device === "cpu";
$("wfm-pt-device")?.addEventListener("change", async (e) => {
const device = e.target.value === "cpu" ? "cpu" : "gpu";
const prev = isCpu() ? "cpu" : "gpu";
if (!(await save({ prompt_translate_device: device }))) { e.target.value = prev; return; }
const cpu = device === "cpu";
const cb = $("wfm-pt-unload");
if (cb) cb.disabled = cpu;
const lbl = $("wfm-pt-unload-label");
if (lbl) lbl.style.opacity = cpu ? "0.5" : "";
// Ollama reloads the model for the new placement; drop the old instance first.
await postTranslate("unload");
if (cpu) postTranslate("warmup");
});
$("wfm-pt-enabled")?.addEventListener("change", async (e) => {
const on = !!e.target.checked;
if (!(await save({ prompt_translate_enabled: on }))) { e.target.checked = !on; return; }
if (isCpu()) postTranslate(on ? "warmup" : "unload");
const body = $("wfm-pt-body");
if (body) body.style.opacity = on ? "" : "0.55";
});
[["wfm-pt-auto", "prompt_translate_auto"], ["wfm-pt-auto-lab", "prompt_translate_auto_lab"], ["wfm-pt-auto-video", "prompt_translate_auto_video"]]
.forEach(([id, key]) => {
$(id)?.addEventListener("change", async (e) => {
const on = !!e.target.checked;
if (!(await save({ [key]: on }))) e.target.checked = !on;
});
});
$("wfm-pt-unload")?.addEventListener("change", async (e) => {
const on = !!e.target.checked;
if (!(await save({ prompt_translate_unload: on }))) e.target.checked = !on;
});
$("wfm-pt-source-lang")?.addEventListener("change", (e) => save({ prompt_translate_source_lang: e.target.value }));
$("wfm-pt-url-save")?.addEventListener("click", async () => {
const url = ($("wfm-pt-url")?.value || "").trim();
if (await save({ prompt_translate_url: url })) refreshModels();
});
$("wfm-pt-model")?.addEventListener("change", async (e) => {
const cpu = isCpu() && serverSettings.prompt_translate_enabled;
if (cpu) await postTranslate("unload"); // release the previous resident model
await save({ prompt_translate_model: e.target.value });
if (cpu) postTranslate("warmup");
updatePullButton();
});
$("wfm-pt-model-refresh")?.addEventListener("click", () => refreshModels());
$("wfm-pt-model-pull")?.addEventListener("click", async (e) => {
const btn = e.currentTarget;
const model = currentModel();
btn.disabled = true;
const label = btn.textContent;
btn.textContent = t("promptTranslatePulling");
try {
const res = await fetch("/api/wfm/translate/pull", {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({ model }),
});
const data = await res.json();
if (data.status !== "success") throw new Error(data.message || `HTTP ${res.status}`);
showToast(t("promptTranslatePulled"), "success");
await refreshModels(true);
} catch (err) {
showToast(t("errorWithMsg", err.message), "error");
} finally {
btn.disabled = false;
btn.textContent = label;
}
});
$("wfm-pt-test")?.addEventListener("click", async (e) => {
const btn = e.currentTarget;
const status = $("wfm-pt-test-status");
const sample = SAMPLE_TEXT[getLang()] || SAMPLE_TEXT.ja;
btn.disabled = true;
if (status) { status.style.color = "var(--wfm-text-secondary)"; status.textContent = t("promptTranslateRunning"); }
const t0 = performance.now();
try {
const out = await translatePrompt(sample);
const sec = ((performance.now() - t0) / 1000).toFixed(1);
if (status) { status.style.color = "var(--wfm-success, #4caf50)"; status.textContent = `${sample} → ${out} (${sec}s)`; }
} catch (err) {
if (status) { status.style.color = "var(--wfm-danger, #f44336)"; status.textContent = err.message; }
} finally {
btn.disabled = false;
}
});
// Fill the model list when the section is first opened (avoids an Ollama call on every Settings visit).
const section = $("wfm-pt-settings");
section?.addEventListener("toggle", () => { if (section.open && !installed.length) refreshModels(true); });
}
+252
View File
@@ -0,0 +1,252 @@
/**
* Prompt Translate — type GenerateUI prompts in your own language and translate
* them into English with a local Ollama model (PLaMo 3 Translate by default).
*
* Works like the A1111 prompt-translator extensions (the splitting runs on the
* server, POST /api/wfm/translate/prompt): only the parts of a prompt
* that contain non-ASCII letters are sent to the model. Prompt syntax such as
* commas, (weights:1.2), [ ], {a|b}, <lora:...>, __wildcards__,
* embedding:name and BREAK/AND is kept as it is, so a mixed prompt like
* "masterpiece, (赤いドレスの女性:1.2), <lora:foo:0.8>" only translates the Japanese part.
*/
import { showToast } from "./app.js";
import { t } from "./i18n.js";
let _config = null;
let _configPromise = null;
// textarea -> { original, translated } for the "restore original" button
const _history = new WeakMap();
export async function loadTranslateConfig(force = false) {
if (_config && !force) return _config;
if (!_configPromise || force) {
_configPromise = fetch("/api/wfm/translate/config")
.then((r) => r.json())
.then((d) => { _config = d.config || {}; return _config; })
.catch(() => { _config = {}; return _config; })
.finally(() => { _configPromise = null; });
}
return _configPromise;
}
export function getTranslateConfig() {
return _config || {};
}
export function isTranslateEnabled() {
return !!_config?.prompt_translate_enabled;
}
/** Called by the Settings tab after saving, so open UIs update without a reload. */
export function setTranslateConfig(patch) {
_config = { ...(_config || {}), ...patch };
updateTranslateButtons();
}
// ------------------------------------------------------------
// Translation (prompt splitting lives on the server: translate_service.split_prompt)
// ------------------------------------------------------------
// Cheap client-side check before calling the server: any non-ASCII letter at all.
// The server decides which pieces really go to the model (prompt syntax is skipped).
const NON_ASCII_LETTER_RE = /(?![\x00-\x7F])\p{L}/u;
export function needsTranslation(text) {
return NON_ASCII_LETTER_RE.test(text || "");
}
async function _postPrompt(body) {
const res = await fetch("/api/wfm/translate/prompt", {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify(body),
});
const data = await res.json().catch(() => ({}));
if (!res.ok || data.status !== "success") {
throw new Error(data.message || `HTTP ${res.status}`);
}
return data;
}
/** Translate a whole prompt string, keeping prompt syntax. Throws on backend errors. */
export async function translatePrompt(text) {
if (!needsTranslation(text)) return text;
const data = await _postPrompt({ text });
return data.translated ?? text;
}
/** Translate several prompt strings in one request (same order). */
export async function translatePrompts(texts) {
const idx = [];
texts.forEach((x, i) => { if (needsTranslation(x)) idx.push(i); });
if (idx.length === 0) return texts.slice();
const data = await _postPrompt({ texts: idx.map((i) => texts[i]) });
const out = texts.slice();
idx.forEach((i, k) => { out[i] = data.translations?.[k] ?? texts[i]; });
return out;
}
// Replace textarea text while keeping the browser's Ctrl+Z history where possible.
function _setTextareaValue(ta, value) {
ta.focus();
ta.select();
let ok = false;
try { ok = document.execCommand("insertText", false, value); } catch { ok = false; }
if (!ok || ta.value !== value) ta.value = value;
ta.dispatchEvent(new Event("input", { bubbles: true }));
}
/**
* Translate one textarea in place. Returns true when the text changed.
* The original text is remembered for the restore button.
*/
export async function translateTextarea(ta) {
if (!ta || ta.disabled) return false;
const original = ta.value;
if (!needsTranslation(original)) return false;
const translated = await translatePrompt(original);
if (translated === original) return false;
_setTextareaValue(ta, translated);
_history.set(ta, { original, translated });
_updateRestoreButton(ta);
return true;
}
export function restoreTextarea(ta) {
const h = ta && _history.get(ta);
if (!h || ta.disabled) return;
_setTextareaValue(ta, h.original);
_history.delete(ta);
_updateRestoreButton(ta);
}
const PROMPT_TEXTAREAS = ["wfm-prompt-pos-text", "wfm-prompt-neg-text"];
/**
* GenerateUI hook: when translation and "translate before Generate" are both on,
* translate the Positive/Negative prompt textareas. Throws if translation fails so
* the caller can stop instead of sending untranslated text.
*/
export async function autoTranslateBeforeGenerate() {
if (!(await isAutoTranslateOn("generate"))) return false;
const targets = PROMPT_TEXTAREAS.map((id) => document.getElementById(id))
.filter((ta) => ta && needsTranslation(ta.value));
if (targets.length === 0) return false;
const progress = document.getElementById("wfm-gen-progress-text");
if (progress) progress.textContent = t("promptTranslateRunning");
for (const ta of targets) await translateTextarea(ta);
if (progress) progress.textContent = "";
return true;
}
// Settings key for each "translate automatically when running" checkbox.
const AUTO_KEYS = {
generate: "prompt_translate_auto",
lab: "prompt_translate_auto_lab",
video: "prompt_translate_auto_video",
};
/** True when translation is enabled and the auto checkbox for ``kind`` (generate/lab/video) is on. */
export async function isAutoTranslateOn(kind) {
await loadTranslateConfig();
return isTranslateEnabled() && !!_config[AUTO_KEYS[kind]];
}
/**
* Lab Run hook: translate the prompt texts inside one iteration's API-format workflow
* copy, in place. The Lab plan's own keyframe values stay in the user's language;
* repeated phrases come from the server-side cache, so later iterations cost ~nothing.
* Throws on translation failure so the caller can stop the batch.
*/
export async function translateWorkflowPrompts(workflow, promptNodes) {
const targets = [];
for (const n of promptNodes || []) {
const inputs = workflow?.[n.id]?.inputs;
const key = n.textKey || "text";
if (inputs && typeof inputs[key] === "string" && needsTranslation(inputs[key])) {
targets.push({ inputs, key });
}
}
if (targets.length === 0) return workflow;
const out = await translatePrompts(targets.map((x) => x.inputs[x.key]));
targets.forEach((x, i) => { x.inputs[x.key] = out[i]; });
return workflow;
}
// ------------------------------------------------------------
// Buttons in the GenerateUI Prompt tab
// ------------------------------------------------------------
function _updateRestoreButton(ta) {
const btn = document.querySelector(`.wfm-pt-restore[data-target="${ta.id}"]`);
if (!btn) return;
const h = _history.get(ta);
btn.style.display = isTranslateEnabled() && h && ta.value === h.translated ? "" : "none";
}
export function updateTranslateButtons() {
const on = isTranslateEnabled();
document.querySelectorAll(".wfm-pt-translate").forEach((b) => { b.style.display = on ? "" : "none"; });
document.querySelectorAll(".wfm-pt-restore").forEach((b) => {
const ta = document.getElementById(b.dataset.target);
if (ta) _updateRestoreButton(ta);
});
}
/**
* Wire the 🌐 / restore buttons produced by translateButtonsHtml() inside ``root``
* (GenerateUI prompt tab, Lab prompt modal, Video Plan block prompt, ...).
*/
export function attachTranslateButtons(root = document) {
root.querySelectorAll(".wfm-pt-translate").forEach((btn) => {
btn.addEventListener("click", async () => {
const ta = document.getElementById(btn.dataset.target);
if (!ta) return;
if (!needsTranslation(ta.value)) {
showToast(t("promptTranslateNothing"), "info");
return;
}
btn.disabled = true;
const label = btn.textContent;
btn.textContent = "…";
try {
// false = only prompt syntax / unchanged (e.g. a non-ASCII <lora:...> name)
if (!(await translateTextarea(ta))) showToast(t("promptTranslateNothing"), "info");
} catch (err) {
showToast(t("promptTranslateError", err.message), "error");
} finally {
btn.disabled = false;
btn.textContent = label;
}
});
});
root.querySelectorAll(".wfm-pt-restore").forEach((btn) => {
btn.addEventListener("click", () => restoreTextarea(document.getElementById(btn.dataset.target)));
});
root.querySelectorAll(".wfm-pt-restore").forEach((btn) => {
const ta = document.getElementById(btn.dataset.target);
ta?.addEventListener("input", () => _updateRestoreButton(ta));
});
loadTranslateConfig().then(() => {
updateTranslateButtons();
_warmupOnce();
});
}
// CPU-resident mode: load the model in the background once per page so the first 🌐
// does not pay Ollama's ~4 s startup. The server ignores this unless CPU mode is on.
let _warmedUp = false;
function _warmupOnce() {
if (_warmedUp || !isTranslateEnabled() || _config.prompt_translate_device !== "cpu") return;
_warmedUp = true;
fetch("/api/wfm/translate/warmup", { method: "POST" }).catch(() => {});
}
/** HTML for the two buttons placed next to a prompt textarea's Apply button. */
export function translateButtonsHtml(textareaId) {
const on = isTranslateEnabled();
return `<button class="wfm-btn wfm-btn-sm wfm-pt-translate" data-target="${textareaId}" title="${t("promptTranslateBtnTitle")}" style="${on ? "" : "display:none;"}">🌐</button>`
+ `<button class="wfm-btn wfm-btn-sm wfm-pt-restore" data-target="${textareaId}" title="${t("promptTranslateRestoreTitle")}" style="display:none;">${t("promptTranslateRestore")}</button>`;
}
+88 -15
View File
@@ -9,6 +9,7 @@ import { t, getLang, getSummaryLang, setLang, setSummaryLang, getLanguageOptions
import { getSettings, readJsonStorage, escapeHtml } from "./util.js";
import { DECISION_BACKENDS, getDecisionSettings, saveDecisionSettings, testDecisionConnection, listDecisionModels } from "./decision-client.js";
import { initVramSettings } from "./vram-prepare.js";
import { initPromptTranslateSettings, promptTranslateSettingsHtml } from "./prompt-translate-settings.js";
const SETTINGS_KEY = "wfm_settings";
@@ -429,6 +430,56 @@ export function getSavedTheme() {
return loadLocalSettings().theme || "";
}
// ---- Browser-side settings in backups ----
// Settings kept in localStorage (groups, badge palette, appearance, AI / decision / VRAM
// settings, presets, ...) travel with both the JSON export and the full backup. Same key
// rule as the server (_clean_browser_storage in settings_routes.py).
const BROWSER_STORAGE_KEY_RE = /^(?:wfm|ie)_[A-Za-z0-9_-]{1,100}$/;
const BROWSER_STORAGE_TRANSIENT = new Set(["wfm_pending_workflow", "wfm_library_filter_request"]);
function collectBrowserStorage() {
const out = {};
try {
for (let i = 0; i < localStorage.length; i++) {
const k = localStorage.key(i);
if (k && BROWSER_STORAGE_KEY_RE.test(k) && !BROWSER_STORAGE_TRANSIENT.has(k)) {
out[k] = localStorage.getItem(k);
}
}
} catch { /* storage unavailable: back up server data only */ }
return out;
}
/** Write restored keys into localStorage; returns how many were written. */
function restoreBrowserStorage(data) {
let n = 0;
for (const [k, v] of Object.entries(data || {})) {
if (typeof v !== "string" || !BROWSER_STORAGE_KEY_RE.test(k) || BROWSER_STORAGE_TRANSIENT.has(k)) continue;
try { localStorage.setItem(k, v); n++; } catch { /* quota: skip */ }
}
return n;
}
/** Append "N browser settings restored — Reload" to the data status line. */
function appendBrowserRestoreNote(statusEl, count) {
if (!count) return;
statusEl.append(" / " + t("browserStorageRestored", count) + " ");
const btn = document.createElement("button");
btn.className = "wfm-btn wfm-btn-sm";
btn.textContent = t("reloadPage");
btn.addEventListener("click", () => location.reload());
statusEl.append(btn);
}
function downloadBlob(blob, filename) {
const url = URL.createObjectURL(blob);
const a = document.createElement("a");
a.href = url;
a.download = filename;
a.click();
URL.revokeObjectURL(url);
}
export async function initSettingsTab() {
const container = document.querySelector("#wfm-tab-settings .wfm-settings-container");
if (!container) return;
@@ -772,6 +823,9 @@ export async function initSettingsTab() {
<button class="wfm-btn wfm-btn-primary wfm-btn-sm" id="wfm-settings-default-ckpt-save">${t("save")}</button>
</details>
<!-- Prompt Translation (native language -> English, PLaMo 3 Translate via Ollama) -->
${promptTranslateSettingsHtml(serverSettings)}
<!-- CivitAI Settings -->
<details class="wfm-settings-section">
<summary class="wfm-settings-summary">${t("civitaiApiKeySetting")}</summary>
@@ -948,6 +1002,14 @@ export async function initSettingsTab() {
<input type="checkbox" id="wfm-settings-backup-include-video-media">
${t("fullBackupIncludeVideoMedia")}
</label>
<label class="wfm-lab-checkbox-label" style="font-size:12px;">
<input type="checkbox" id="wfm-settings-backup-include-semantic" checked>
${t("fullBackupIncludeSemantic")}
</label>
<label class="wfm-lab-checkbox-label" style="font-size:12px;">
<input type="checkbox" id="wfm-settings-backup-include-tagspace">
${t("fullBackupIncludeTagspace")}
</label>
<span style="font-size:11px;color:var(--wfm-text-secondary);">${t("fullBackupExternalHint")}</span>
</div>
<div style="display:flex;gap:8px;flex-wrap:wrap;">
@@ -1228,6 +1290,9 @@ export async function initSettingsTab() {
}
});
// --- Prompt translation ---
initPromptTranslateSettings(serverSettings, saveServerSettings);
// --- Windows selector event loop (needs ComfyUI restart) ---
document.getElementById("wfm-settings-selector-loop")?.addEventListener("change", async (e) => {
const enabled = !!e.target.checked;
@@ -1671,13 +1736,10 @@ export async function initSettingsTab() {
try {
const res = await fetch("/api/wfm/settings/export");
if (!res.ok) throw new Error(await res.text());
const blob = await res.blob();
const url = URL.createObjectURL(blob);
const a = document.createElement("a");
a.href = url;
a.download = "wfm-data-export.json";
a.click();
URL.revokeObjectURL(url);
const bundle = await res.json();
bundle.__browser_storage = collectBrowserStorage();
downloadBlob(new Blob([JSON.stringify(bundle, null, 2)], { type: "application/json" }),
"wfm-data-export.json");
statusEl.textContent = t("exportSuccess");
statusEl.style.color = "var(--wfm-success, #4caf50)";
} catch (e) {
@@ -1704,6 +1766,7 @@ export async function initSettingsTab() {
const imported = result.imported?.join(", ") || "-";
statusEl.textContent = t("importSuccess") + ": " + imported;
statusEl.style.color = "var(--wfm-success, #4caf50)";
appendBrowserRestoreNote(statusEl, restoreBrowserStorage(result.browser_storage));
} catch (e) {
statusEl.textContent = t("importError") + ": " + e.message;
statusEl.style.color = "var(--wfm-error, #f44336)";
@@ -1717,15 +1780,24 @@ export async function initSettingsTab() {
const includeWorkflows = document.getElementById("wfm-settings-backup-include-workflows")?.checked ? "1" : "0";
const includeWildcard = document.getElementById("wfm-settings-backup-include-wildcard")?.checked ? "1" : "0";
const includeVideoMedia = document.getElementById("wfm-settings-backup-include-video-media")?.checked ? "1" : "0";
const res = await fetch(`/api/wfm/settings/export-full?include_workflows=${includeWorkflows}&include_wildcard=${includeWildcard}&include_video_media=${includeVideoMedia}`);
const includeSemantic = document.getElementById("wfm-settings-backup-include-semantic")?.checked ? "1" : "0";
const includeTagspace = document.getElementById("wfm-settings-backup-include-tagspace")?.checked ? "1" : "0";
statusEl.textContent = t("fullBackupBuilding");
statusEl.style.color = "var(--wfm-text-secondary)";
const res = await fetch("/api/wfm/settings/export-full", {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({
include_workflows: includeWorkflows,
include_wildcard: includeWildcard,
include_video_media: includeVideoMedia,
include_semantic_index: includeSemantic,
include_tagspace: includeTagspace,
browser_storage: collectBrowserStorage(),
}),
});
if (!res.ok) throw new Error(await res.text());
const blob = await res.blob();
const url = URL.createObjectURL(blob);
const a = document.createElement("a");
a.href = url;
a.download = "wfm-full-backup.zip";
a.click();
URL.revokeObjectURL(url);
downloadBlob(await res.blob(), "wfm-full-backup.zip");
statusEl.textContent = t("exportSuccess");
statusEl.style.color = "var(--wfm-success, #4caf50)";
} catch (e) {
@@ -1756,6 +1828,7 @@ export async function initSettingsTab() {
}
statusEl.textContent = msg;
statusEl.style.color = "var(--wfm-success, #4caf50)";
appendBrowserRestoreNote(statusEl, restoreBrowserStorage(result.browser_storage));
} catch (e) {
statusEl.textContent = t("importError") + ": " + e.message;
statusEl.style.color = "var(--wfm-error, #f44336)";
+28 -2
View File
@@ -25,6 +25,7 @@ import { isVideoFilename, extractLastFrameBlob } from "./video-utils.js";
import { locateVideoModelNodes, readTemplateDefaults, applyBlockToWorkflow } from "./video-workflow.js";
import { VTEMP_GROUP } from "./gallery-tab.js";
import { setResultPreview } from "./video-preview.js";
import { translateButtonsHtml, attachTranslateButtons, isAutoTranslateOn, translatePrompt, needsTranslation } from "./prompt-translate.js";
const VIDEO_BLOCK_COLORS = ["#4caf7d", "#3b4b8a", "#8e5cd9", "#e0c341", "#4ac0d9", "#9ad14b", "#e08a3c", "#d9527a"];
const VIDEO_PLAN_PREFIX = "ws_videoplan_";
@@ -277,7 +278,10 @@ function _blockEditorHtml(block, isFirstBlock) {
<span class="wfm-video-color-swatch" style="background:${escapeHtml(block.color)}"></span>
<span>color</span>
</div>
<label id="wfm-video-block-prompt-label">Prompt</label>
<div style="display:flex;align-items:center;gap:6px;">
<label id="wfm-video-block-prompt-label" style="flex:1;">Prompt</label>
${translateButtonsHtml("wfm-video-block-prompt")}
</div>
<textarea id="wfm-video-block-prompt" class="wfm-textarea" rows="8">${escapeHtml(block.prompt || "")}</textarea>
</div>
`;
@@ -385,6 +389,9 @@ function _renderBlockEditor() {
document.getElementById("wfm-video-block-last-clear")?.addEventListener("click", () => _clearBlockImage("last"));
document.getElementById("wfm-video-block-prompt")?.addEventListener("input", (e) => { block.prompt = e.target.value; });
// 🌐 native-language translation (Settings → Prompt Translation); translating fires
// "input", so block.prompt follows the translated text.
attachTranslateButtons(document.getElementById("wfm-video-block-prompt")?.closest(".wfm-video-block-prompt-col") || document);
// Durationの入力欄はtopbarのbasesettings行に固定配置されている(ブロックエディタの
// innerHTMLと違って再生成されない)ため、ここでは現在選択中ブロックの値を反映するだけ。
@@ -707,6 +714,10 @@ async function _runVideoPlanBatch() {
const progressBar = document.getElementById("wfm-video-plan-progress-bar");
const progressText = document.getElementById("wfm-video-plan-progress-text");
// Settings -> Prompt Translation -> "Video Plan Run": translate each block's prompt
// when sending it (the plan itself keeps the original text).
const autoTranslate = await isAutoTranslateOn("video");
let completed = 0, failed = 0;
let prevGeneratedLastFrameRef = null;
@@ -727,9 +738,24 @@ async function _runVideoPlanBatch() {
break;
}
let prompt = block.prompt;
if (autoTranslate && needsTranslation(prompt)) {
try {
if (progressText) progressText.textContent = `[${i + 1}/${total}] ${t("promptTranslateRunning")}`;
prompt = await translatePrompt(prompt);
} catch (err) {
// The end-of-batch "stopped" toast replaces this one, so also keep the
// reason in the progress line.
showToast(t("promptTranslateError", err.message), "error");
if (progressText) progressText.textContent = t("promptTranslateError", err.message);
_aborted = true;
break;
}
}
const firstImageFilename = await _resolveFirstImage(block, i, prevGeneratedLastFrameRef);
applyBlockToWorkflow(clone, nodes, {
prompt: block.prompt,
prompt,
duration: block.duration,
aspectRatio: _plan.base_settings.aspect_ratio,
megapixels: _plan.base_settings.megapixels,
+23
View File
@@ -397,4 +397,27 @@ export function applyBlockToWorkflow(clone, nodes, params) {
} else if (nodes.disconnectUnsetFrames && lastFrameSlot !== -1) {
_disconnectInput(clone, instanceNode, lastFrameSlot);
}
// Workflows saved by newer frontends also carry a name-keyed copy of a subgraph
// instance's widget values (widgets_values_named), and convertUiToApi() prefers that
// copy. Without mirroring the writes above into it, the template's own prompt /
// duration / turbo values were sent instead of the Plan's (e.g. minimax_turbo.json).
new Set([instanceNode, promptNode, durationNode]).forEach(_syncNamedWidgetValues);
}
function _syncNamedWidgetValues(node) {
const named = node?.widgets_values_named;
const values = node?.widgets_values;
if (!named || typeof named !== "object" || !Array.isArray(values)) return;
const keys = Object.keys(named);
if (keys.length === values.length) {
// The frontend writes both from the same widget list, so the orders line up.
keys.forEach((k, i) => { named[k] = values[i]; });
return;
}
// Lengths differ: fall back to the outer widget inputs' order, the same mapping
// convertUiToApi() uses when there is no named copy.
(node.inputs || []).filter((inp) => inp.widget).forEach((inp, i) => {
if (i < values.length && Object.prototype.hasOwnProperty.call(named, inp.name)) named[inp.name] = values[i];
});
}
+13 -1
View File
@@ -13,6 +13,8 @@
import { t } from "./i18n.js";
import { showToast } from "./app.js";
const _showToast = showToast;
import { readJsonStorage, getAiBackendDefaultUrl } from "./util.js";
import { getDecisionSettings } from "./decision-client.js";
@@ -68,6 +70,12 @@ const gb = (mb) => (mb / 1024).toFixed(1);
/** One-line summary of a result (Settings tab status and pre-generation toast) */
export function describeVramResult(d) {
const msg = _describeVramMain(d);
// CPU-resident models (size_vram 0, e.g. the prompt translator) are left loaded on purpose.
return d.kept_cpu?.length ? msg + " / " + t("vramKeptCpu", d.kept_cpu.join(", ")) : msg;
}
function _describeVramMain(d) {
if (d.unloaded.length) {
let msg = t("vramUnloaded", d.unloaded.map((u) => u.name).join(", "), gb(d.free_before_mb), gb(d.free_after_mb));
if (d.failed.length) msg += " / " + t("vramFailedModels", d.failed.join(", "));
@@ -141,10 +149,14 @@ let _lastShortNote = "";
* Call right before queuing a generation. Does nothing when the mode is off; never throws.
* Shows a toast only when something was unloaded, the target can't be reached, or it failed
* (the same "can't reach target" note isn't repeated across a batch).
* quiet: no toast, console only. Used for generation from the Game tab, and whenever the Game
* tab is open (the toast would cover the game screen).
*/
export async function prepareVramForGeneration() {
export async function prepareVramForGeneration({ quiet = false } = {}) {
const settings = getVramSettings();
if (settings.mode === "off") return null;
if (!quiet && document.getElementById("wfm-tab-game")?.classList.contains("active")) quiet = true;
const showToast = quiet ? (msg) => console.info("[WFS] vram:", msg) : _showToast;
try {
const d = await requestVramPrepare(settings.mode, settings.targetGb);
const short = d.mode === "auto" && !d.reached;
+70
View File
@@ -0,0 +1,70 @@
three.js r187 - MIT, Copyright 2010-2026 three.js authors
The MIT License
Copyright © 2010-2026 three.js authors
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
=== @pixiv/three-vrm 3.5.5 ===
Copyright (c) 2019-2026 pixiv Inc.
MIT License
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
=== @sparkjsdev/spark 2.4.0 ===
The MIT License
Copyright © 2025 WORLD LABS TECHNOLOGIES, INC.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
+8
View File
@@ -0,0 +1,8 @@
Gallery 3D viewer bundle (glb / gltf / vrm / ply / spz).
three 0.187.0, @pixiv/three-vrm 3.5.5, @sparkjsdev/spark 2.4.0 (see LICENSE)
Source entry: entry.js.txt (rename to entry.js to rebuild)
Built with:
esbuild entry.js --bundle --format=esm --splitting --minify --target=es2022 \
--outdir=out --entry-names=three-viewer --chunk-names=chunk-[hash]
Spark is a separate chunk, loaded only when a Gaussian splat is opened.
draco/ is copied from three/examples/jsm/libs/draco/gltf.
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
Binary file not shown.
@@ -0,0 +1,116 @@
var $jscomp=$jscomp||{};$jscomp.scope={};$jscomp.arrayIteratorImpl=function(h){var n=0;return function(){return n<h.length?{done:!1,value:h[n++]}:{done:!0}}};$jscomp.arrayIterator=function(h){return{next:$jscomp.arrayIteratorImpl(h)}};$jscomp.makeIterator=function(h){var n="undefined"!=typeof Symbol&&Symbol.iterator&&h[Symbol.iterator];return n?n.call(h):$jscomp.arrayIterator(h)};$jscomp.ASSUME_ES5=!1;$jscomp.ASSUME_NO_NATIVE_MAP=!1;$jscomp.ASSUME_NO_NATIVE_SET=!1;$jscomp.SIMPLE_FROUND_POLYFILL=!1;
$jscomp.ISOLATE_POLYFILLS=!1;$jscomp.FORCE_POLYFILL_PROMISE=!1;$jscomp.FORCE_POLYFILL_PROMISE_WHEN_NO_UNHANDLED_REJECTION=!1;$jscomp.getGlobal=function(h){h=["object"==typeof globalThis&&globalThis,h,"object"==typeof window&&window,"object"==typeof self&&self,"object"==typeof global&&global];for(var n=0;n<h.length;++n){var k=h[n];if(k&&k.Math==Math)return k}throw Error("Cannot find global object");};$jscomp.global=$jscomp.getGlobal(this);
$jscomp.defineProperty=$jscomp.ASSUME_ES5||"function"==typeof Object.defineProperties?Object.defineProperty:function(h,n,k){if(h==Array.prototype||h==Object.prototype)return h;h[n]=k.value;return h};$jscomp.IS_SYMBOL_NATIVE="function"===typeof Symbol&&"symbol"===typeof Symbol("x");$jscomp.TRUST_ES6_POLYFILLS=!$jscomp.ISOLATE_POLYFILLS||$jscomp.IS_SYMBOL_NATIVE;$jscomp.polyfills={};$jscomp.propertyToPolyfillSymbol={};$jscomp.POLYFILL_PREFIX="$jscp$";
var $jscomp$lookupPolyfilledValue=function(h,n){var k=$jscomp.propertyToPolyfillSymbol[n];if(null==k)return h[n];k=h[k];return void 0!==k?k:h[n]};$jscomp.polyfill=function(h,n,k,p){n&&($jscomp.ISOLATE_POLYFILLS?$jscomp.polyfillIsolated(h,n,k,p):$jscomp.polyfillUnisolated(h,n,k,p))};
$jscomp.polyfillUnisolated=function(h,n,k,p){k=$jscomp.global;h=h.split(".");for(p=0;p<h.length-1;p++){var l=h[p];if(!(l in k))return;k=k[l]}h=h[h.length-1];p=k[h];n=n(p);n!=p&&null!=n&&$jscomp.defineProperty(k,h,{configurable:!0,writable:!0,value:n})};
$jscomp.polyfillIsolated=function(h,n,k,p){var l=h.split(".");h=1===l.length;p=l[0];p=!h&&p in $jscomp.polyfills?$jscomp.polyfills:$jscomp.global;for(var y=0;y<l.length-1;y++){var f=l[y];if(!(f in p))return;p=p[f]}l=l[l.length-1];k=$jscomp.IS_SYMBOL_NATIVE&&"es6"===k?p[l]:null;n=n(k);null!=n&&(h?$jscomp.defineProperty($jscomp.polyfills,l,{configurable:!0,writable:!0,value:n}):n!==k&&(void 0===$jscomp.propertyToPolyfillSymbol[l]&&(k=1E9*Math.random()>>>0,$jscomp.propertyToPolyfillSymbol[l]=$jscomp.IS_SYMBOL_NATIVE?
$jscomp.global.Symbol(l):$jscomp.POLYFILL_PREFIX+k+"$"+l),$jscomp.defineProperty(p,$jscomp.propertyToPolyfillSymbol[l],{configurable:!0,writable:!0,value:n})))};
$jscomp.polyfill("Promise",function(h){function n(){this.batch_=null}function k(f){return f instanceof l?f:new l(function(q,u){q(f)})}if(h&&(!($jscomp.FORCE_POLYFILL_PROMISE||$jscomp.FORCE_POLYFILL_PROMISE_WHEN_NO_UNHANDLED_REJECTION&&"undefined"===typeof $jscomp.global.PromiseRejectionEvent)||!$jscomp.global.Promise||-1===$jscomp.global.Promise.toString().indexOf("[native code]")))return h;n.prototype.asyncExecute=function(f){if(null==this.batch_){this.batch_=[];var q=this;this.asyncExecuteFunction(function(){q.executeBatch_()})}this.batch_.push(f)};
var p=$jscomp.global.setTimeout;n.prototype.asyncExecuteFunction=function(f){p(f,0)};n.prototype.executeBatch_=function(){for(;this.batch_&&this.batch_.length;){var f=this.batch_;this.batch_=[];for(var q=0;q<f.length;++q){var u=f[q];f[q]=null;try{u()}catch(A){this.asyncThrow_(A)}}}this.batch_=null};n.prototype.asyncThrow_=function(f){this.asyncExecuteFunction(function(){throw f;})};var l=function(f){this.state_=0;this.result_=void 0;this.onSettledCallbacks_=[];this.isRejectionHandled_=!1;var q=this.createResolveAndReject_();
try{f(q.resolve,q.reject)}catch(u){q.reject(u)}};l.prototype.createResolveAndReject_=function(){function f(A){return function(F){u||(u=!0,A.call(q,F))}}var q=this,u=!1;return{resolve:f(this.resolveTo_),reject:f(this.reject_)}};l.prototype.resolveTo_=function(f){if(f===this)this.reject_(new TypeError("A Promise cannot resolve to itself"));else if(f instanceof l)this.settleSameAsPromise_(f);else{a:switch(typeof f){case "object":var q=null!=f;break a;case "function":q=!0;break a;default:q=!1}q?this.resolveToNonPromiseObj_(f):
this.fulfill_(f)}};l.prototype.resolveToNonPromiseObj_=function(f){var q=void 0;try{q=f.then}catch(u){this.reject_(u);return}"function"==typeof q?this.settleSameAsThenable_(q,f):this.fulfill_(f)};l.prototype.reject_=function(f){this.settle_(2,f)};l.prototype.fulfill_=function(f){this.settle_(1,f)};l.prototype.settle_=function(f,q){if(0!=this.state_)throw Error("Cannot settle("+f+", "+q+"): Promise already settled in state"+this.state_);this.state_=f;this.result_=q;2===this.state_&&this.scheduleUnhandledRejectionCheck_();
this.executeOnSettledCallbacks_()};l.prototype.scheduleUnhandledRejectionCheck_=function(){var f=this;p(function(){if(f.notifyUnhandledRejection_()){var q=$jscomp.global.console;"undefined"!==typeof q&&q.error(f.result_)}},1)};l.prototype.notifyUnhandledRejection_=function(){if(this.isRejectionHandled_)return!1;var f=$jscomp.global.CustomEvent,q=$jscomp.global.Event,u=$jscomp.global.dispatchEvent;if("undefined"===typeof u)return!0;"function"===typeof f?f=new f("unhandledrejection",{cancelable:!0}):
"function"===typeof q?f=new q("unhandledrejection",{cancelable:!0}):(f=$jscomp.global.document.createEvent("CustomEvent"),f.initCustomEvent("unhandledrejection",!1,!0,f));f.promise=this;f.reason=this.result_;return u(f)};l.prototype.executeOnSettledCallbacks_=function(){if(null!=this.onSettledCallbacks_){for(var f=0;f<this.onSettledCallbacks_.length;++f)y.asyncExecute(this.onSettledCallbacks_[f]);this.onSettledCallbacks_=null}};var y=new n;l.prototype.settleSameAsPromise_=function(f){var q=this.createResolveAndReject_();
f.callWhenSettled_(q.resolve,q.reject)};l.prototype.settleSameAsThenable_=function(f,q){var u=this.createResolveAndReject_();try{f.call(q,u.resolve,u.reject)}catch(A){u.reject(A)}};l.prototype.then=function(f,q){function u(w,B){return"function"==typeof w?function(R){try{A(w(R))}catch(Z){F(Z)}}:B}var A,F,v=new l(function(w,B){A=w;F=B});this.callWhenSettled_(u(f,A),u(q,F));return v};l.prototype.catch=function(f){return this.then(void 0,f)};l.prototype.callWhenSettled_=function(f,q){function u(){switch(A.state_){case 1:f(A.result_);
break;case 2:q(A.result_);break;default:throw Error("Unexpected state: "+A.state_);}}var A=this;null==this.onSettledCallbacks_?y.asyncExecute(u):this.onSettledCallbacks_.push(u);this.isRejectionHandled_=!0};l.resolve=k;l.reject=function(f){return new l(function(q,u){u(f)})};l.race=function(f){return new l(function(q,u){for(var A=$jscomp.makeIterator(f),F=A.next();!F.done;F=A.next())k(F.value).callWhenSettled_(q,u)})};l.all=function(f){var q=$jscomp.makeIterator(f),u=q.next();return u.done?k([]):new l(function(A,
F){function v(R){return function(Z){w[R]=Z;B--;0==B&&A(w)}}var w=[],B=0;do w.push(void 0),B++,k(u.value).callWhenSettled_(v(w.length-1),F),u=q.next();while(!u.done)})};return l},"es6","es3");$jscomp.owns=function(h,n){return Object.prototype.hasOwnProperty.call(h,n)};$jscomp.assign=$jscomp.TRUST_ES6_POLYFILLS&&"function"==typeof Object.assign?Object.assign:function(h,n){for(var k=1;k<arguments.length;k++){var p=arguments[k];if(p)for(var l in p)$jscomp.owns(p,l)&&(h[l]=p[l])}return h};
$jscomp.polyfill("Object.assign",function(h){return h||$jscomp.assign},"es6","es3");$jscomp.checkStringArgs=function(h,n,k){if(null==h)throw new TypeError("The 'this' value for String.prototype."+k+" must not be null or undefined");if(n instanceof RegExp)throw new TypeError("First argument to String.prototype."+k+" must not be a regular expression");return h+""};
$jscomp.polyfill("String.prototype.startsWith",function(h){return h?h:function(n,k){var p=$jscomp.checkStringArgs(this,n,"startsWith");n+="";var l=p.length,y=n.length;k=Math.max(0,Math.min(k|0,p.length));for(var f=0;f<y&&k<l;)if(p[k++]!=n[f++])return!1;return f>=y}},"es6","es3");
$jscomp.polyfill("Array.prototype.copyWithin",function(h){function n(k){k=Number(k);return Infinity===k||-Infinity===k?k:k|0}return h?h:function(k,p,l){var y=this.length;k=n(k);p=n(p);l=void 0===l?y:n(l);k=0>k?Math.max(y+k,0):Math.min(k,y);p=0>p?Math.max(y+p,0):Math.min(p,y);l=0>l?Math.max(y+l,0):Math.min(l,y);if(k<p)for(;p<l;)p in this?this[k++]=this[p++]:(delete this[k++],p++);else for(l=Math.min(l,y+p-k),k+=l-p;l>p;)--l in this?this[--k]=this[l]:delete this[--k];return this}},"es6","es3");
$jscomp.typedArrayCopyWithin=function(h){return h?h:Array.prototype.copyWithin};$jscomp.polyfill("Int8Array.prototype.copyWithin",$jscomp.typedArrayCopyWithin,"es6","es5");$jscomp.polyfill("Uint8Array.prototype.copyWithin",$jscomp.typedArrayCopyWithin,"es6","es5");$jscomp.polyfill("Uint8ClampedArray.prototype.copyWithin",$jscomp.typedArrayCopyWithin,"es6","es5");$jscomp.polyfill("Int16Array.prototype.copyWithin",$jscomp.typedArrayCopyWithin,"es6","es5");
$jscomp.polyfill("Uint16Array.prototype.copyWithin",$jscomp.typedArrayCopyWithin,"es6","es5");$jscomp.polyfill("Int32Array.prototype.copyWithin",$jscomp.typedArrayCopyWithin,"es6","es5");$jscomp.polyfill("Uint32Array.prototype.copyWithin",$jscomp.typedArrayCopyWithin,"es6","es5");$jscomp.polyfill("Float32Array.prototype.copyWithin",$jscomp.typedArrayCopyWithin,"es6","es5");$jscomp.polyfill("Float64Array.prototype.copyWithin",$jscomp.typedArrayCopyWithin,"es6","es5");
var DracoDecoderModule=function(){var h="undefined"!==typeof document&&document.currentScript?document.currentScript.src:void 0;"undefined"!==typeof __filename&&(h=h||__filename);return function(n){function k(e){return a.locateFile?a.locateFile(e,U):U+e}function p(e,b){if(e){var c=ia;var d=e+b;for(b=e;c[b]&&!(b>=d);)++b;if(16<b-e&&c.buffer&&ra)c=ra.decode(c.subarray(e,b));else{for(d="";e<b;){var g=c[e++];if(g&128){var t=c[e++]&63;if(192==(g&224))d+=String.fromCharCode((g&31)<<6|t);else{var aa=c[e++]&
63;g=224==(g&240)?(g&15)<<12|t<<6|aa:(g&7)<<18|t<<12|aa<<6|c[e++]&63;65536>g?d+=String.fromCharCode(g):(g-=65536,d+=String.fromCharCode(55296|g>>10,56320|g&1023))}}else d+=String.fromCharCode(g)}c=d}}else c="";return c}function l(){var e=ja.buffer;a.HEAP8=W=new Int8Array(e);a.HEAP16=new Int16Array(e);a.HEAP32=ca=new Int32Array(e);a.HEAPU8=ia=new Uint8Array(e);a.HEAPU16=new Uint16Array(e);a.HEAPU32=Y=new Uint32Array(e);a.HEAPF32=new Float32Array(e);a.HEAPF64=new Float64Array(e)}function y(e){if(a.onAbort)a.onAbort(e);
e="Aborted("+e+")";da(e);sa=!0;e=new WebAssembly.RuntimeError(e+". Build with -sASSERTIONS for more info.");ka(e);throw e;}function f(e){try{if(e==P&&ea)return new Uint8Array(ea);if(ma)return ma(e);throw"both async and sync fetching of the wasm failed";}catch(b){y(b)}}function q(){if(!ea&&(ta||fa)){if("function"==typeof fetch&&!P.startsWith("file://"))return fetch(P,{credentials:"same-origin"}).then(function(e){if(!e.ok)throw"failed to load wasm binary file at '"+P+"'";return e.arrayBuffer()}).catch(function(){return f(P)});
if(na)return new Promise(function(e,b){na(P,function(c){e(new Uint8Array(c))},b)})}return Promise.resolve().then(function(){return f(P)})}function u(e){for(;0<e.length;)e.shift()(a)}function A(e){this.excPtr=e;this.ptr=e-24;this.set_type=function(b){Y[this.ptr+4>>2]=b};this.get_type=function(){return Y[this.ptr+4>>2]};this.set_destructor=function(b){Y[this.ptr+8>>2]=b};this.get_destructor=function(){return Y[this.ptr+8>>2]};this.set_refcount=function(b){ca[this.ptr>>2]=b};this.set_caught=function(b){W[this.ptr+
12>>0]=b?1:0};this.get_caught=function(){return 0!=W[this.ptr+12>>0]};this.set_rethrown=function(b){W[this.ptr+13>>0]=b?1:0};this.get_rethrown=function(){return 0!=W[this.ptr+13>>0]};this.init=function(b,c){this.set_adjusted_ptr(0);this.set_type(b);this.set_destructor(c);this.set_refcount(0);this.set_caught(!1);this.set_rethrown(!1)};this.add_ref=function(){ca[this.ptr>>2]+=1};this.release_ref=function(){var b=ca[this.ptr>>2];ca[this.ptr>>2]=b-1;return 1===b};this.set_adjusted_ptr=function(b){Y[this.ptr+
16>>2]=b};this.get_adjusted_ptr=function(){return Y[this.ptr+16>>2]};this.get_exception_ptr=function(){if(ua(this.get_type()))return Y[this.excPtr>>2];var b=this.get_adjusted_ptr();return 0!==b?b:this.excPtr}}function F(){function e(){if(!la&&(la=!0,a.calledRun=!0,!sa)){va=!0;u(oa);wa(a);if(a.onRuntimeInitialized)a.onRuntimeInitialized();if(a.postRun)for("function"==typeof a.postRun&&(a.postRun=[a.postRun]);a.postRun.length;)xa.unshift(a.postRun.shift());u(xa)}}if(!(0<ba)){if(a.preRun)for("function"==
typeof a.preRun&&(a.preRun=[a.preRun]);a.preRun.length;)ya.unshift(a.preRun.shift());u(ya);0<ba||(a.setStatus?(a.setStatus("Running..."),setTimeout(function(){setTimeout(function(){a.setStatus("")},1);e()},1)):e())}}function v(){}function w(e){return(e||v).__cache__}function B(e,b){var c=w(b),d=c[e];if(d)return d;d=Object.create((b||v).prototype);d.ptr=e;return c[e]=d}function R(e){if("string"===typeof e){for(var b=0,c=0;c<e.length;++c){var d=e.charCodeAt(c);127>=d?b++:2047>=d?b+=2:55296<=d&&57343>=
d?(b+=4,++c):b+=3}b=Array(b+1);c=0;d=b.length;if(0<d){d=c+d-1;for(var g=0;g<e.length;++g){var t=e.charCodeAt(g);if(55296<=t&&57343>=t){var aa=e.charCodeAt(++g);t=65536+((t&1023)<<10)|aa&1023}if(127>=t){if(c>=d)break;b[c++]=t}else{if(2047>=t){if(c+1>=d)break;b[c++]=192|t>>6}else{if(65535>=t){if(c+2>=d)break;b[c++]=224|t>>12}else{if(c+3>=d)break;b[c++]=240|t>>18;b[c++]=128|t>>12&63}b[c++]=128|t>>6&63}b[c++]=128|t&63}}b[c]=0}e=r.alloc(b,W);r.copy(b,W,e);return e}return e}function Z(e){if("object"===
typeof e){var b=r.alloc(e,W);r.copy(e,W,b);return b}return e}function X(){throw"cannot construct a VoidPtr, no constructor in IDL";}function S(){this.ptr=za();w(S)[this.ptr]=this}function Q(){this.ptr=Aa();w(Q)[this.ptr]=this}function V(){this.ptr=Ba();w(V)[this.ptr]=this}function x(){this.ptr=Ca();w(x)[this.ptr]=this}function D(){this.ptr=Da();w(D)[this.ptr]=this}function G(){this.ptr=Ea();w(G)[this.ptr]=this}function H(){this.ptr=Fa();w(H)[this.ptr]=this}function E(){this.ptr=Ga();w(E)[this.ptr]=
this}function T(){this.ptr=Ha();w(T)[this.ptr]=this}function C(){throw"cannot construct a Status, no constructor in IDL";}function I(){this.ptr=Ia();w(I)[this.ptr]=this}function J(){this.ptr=Ja();w(J)[this.ptr]=this}function K(){this.ptr=Ka();w(K)[this.ptr]=this}function L(){this.ptr=La();w(L)[this.ptr]=this}function M(){this.ptr=Ma();w(M)[this.ptr]=this}function N(){this.ptr=Na();w(N)[this.ptr]=this}function O(){this.ptr=Oa();w(O)[this.ptr]=this}function z(){this.ptr=Pa();w(z)[this.ptr]=this}function m(){this.ptr=
Qa();w(m)[this.ptr]=this}n=void 0===n?{}:n;var a="undefined"!=typeof n?n:{},wa,ka;a.ready=new Promise(function(e,b){wa=e;ka=b});var Ra=!1,Sa=!1;a.onRuntimeInitialized=function(){Ra=!0;if(Sa&&"function"===typeof a.onModuleLoaded)a.onModuleLoaded(a)};a.onModuleParsed=function(){Sa=!0;if(Ra&&"function"===typeof a.onModuleLoaded)a.onModuleLoaded(a)};a.isVersionSupported=function(e){if("string"!==typeof e)return!1;e=e.split(".");return 2>e.length||3<e.length?!1:1==e[0]&&0<=e[1]&&5>=e[1]?!0:0!=e[0]||10<
e[1]?!1:!0};var Ta=Object.assign({},a),ta="object"==typeof window,fa="function"==typeof importScripts,Ua="object"==typeof process&&"object"==typeof process.versions&&"string"==typeof process.versions.node,U="";if(Ua){var Va=require("fs"),pa=require("path");U=fa?pa.dirname(U)+"/":__dirname+"/";var Wa=function(e,b){e=e.startsWith("file://")?new URL(e):pa.normalize(e);return Va.readFileSync(e,b?void 0:"utf8")};var ma=function(e){e=Wa(e,!0);e.buffer||(e=new Uint8Array(e));return e};var na=function(e,
b,c){e=e.startsWith("file://")?new URL(e):pa.normalize(e);Va.readFile(e,function(d,g){d?c(d):b(g.buffer)})};1<process.argv.length&&process.argv[1].replace(/\\/g,"/");process.argv.slice(2);a.inspect=function(){return"[Emscripten Module object]"}}else if(ta||fa)fa?U=self.location.href:"undefined"!=typeof document&&document.currentScript&&(U=document.currentScript.src),h&&(U=h),U=0!==U.indexOf("blob:")?U.substr(0,U.replace(/[?#].*/,"").lastIndexOf("/")+1):"",Wa=function(e){var b=new XMLHttpRequest;b.open("GET",
e,!1);b.send(null);return b.responseText},fa&&(ma=function(e){var b=new XMLHttpRequest;b.open("GET",e,!1);b.responseType="arraybuffer";b.send(null);return new Uint8Array(b.response)}),na=function(e,b,c){var d=new XMLHttpRequest;d.open("GET",e,!0);d.responseType="arraybuffer";d.onload=function(){200==d.status||0==d.status&&d.response?b(d.response):c()};d.onerror=c;d.send(null)};a.print||console.log.bind(console);var da=a.printErr||console.warn.bind(console);Object.assign(a,Ta);Ta=null;var ea;a.wasmBinary&&
(ea=a.wasmBinary);"object"!=typeof WebAssembly&&y("no native wasm support detected");var ja,sa=!1,ra="undefined"!=typeof TextDecoder?new TextDecoder("utf8"):void 0,W,ia,ca,Y,ya=[],oa=[],xa=[],va=!1,ba=0,qa=null,ha=null;var P="draco_decoder_gltf.wasm";P.startsWith("data:application/octet-stream;base64,")||(P=k(P));var pd=0,qd={b:function(e,b,c){(new A(e)).init(b,c);pd++;throw e;},a:function(){y("")},d:function(e,b,c){ia.copyWithin(e,b,b+c)},c:function(e){var b=ia.length;e>>>=0;if(2147483648<e)return!1;
for(var c=1;4>=c;c*=2){var d=b*(1+.2/c);d=Math.min(d,e+100663296);var g=Math;d=Math.max(e,d);g=g.min.call(g,2147483648,d+(65536-d%65536)%65536);a:{d=ja.buffer;try{ja.grow(g-d.byteLength+65535>>>16);l();var t=1;break a}catch(aa){}t=void 0}if(t)return!0}return!1}};(function(){function e(g,t){a.asm=g.exports;ja=a.asm.e;l();oa.unshift(a.asm.f);ba--;a.monitorRunDependencies&&a.monitorRunDependencies(ba);0==ba&&(null!==qa&&(clearInterval(qa),qa=null),ha&&(g=ha,ha=null,g()))}function b(g){e(g.instance)}
function c(g){return q().then(function(t){return WebAssembly.instantiate(t,d)}).then(function(t){return t}).then(g,function(t){da("failed to asynchronously prepare wasm: "+t);y(t)})}var d={a:qd};ba++;a.monitorRunDependencies&&a.monitorRunDependencies(ba);if(a.instantiateWasm)try{return a.instantiateWasm(d,e)}catch(g){da("Module.instantiateWasm callback failed with error: "+g),ka(g)}(function(){return ea||"function"!=typeof WebAssembly.instantiateStreaming||P.startsWith("data:application/octet-stream;base64,")||
P.startsWith("file://")||Ua||"function"!=typeof fetch?c(b):fetch(P,{credentials:"same-origin"}).then(function(g){return WebAssembly.instantiateStreaming(g,d).then(b,function(t){da("wasm streaming compile failed: "+t);da("falling back to ArrayBuffer instantiation");return c(b)})})})().catch(ka);return{}})();var Xa=a._emscripten_bind_VoidPtr___destroy___0=function(){return(Xa=a._emscripten_bind_VoidPtr___destroy___0=a.asm.h).apply(null,arguments)},za=a._emscripten_bind_DecoderBuffer_DecoderBuffer_0=
function(){return(za=a._emscripten_bind_DecoderBuffer_DecoderBuffer_0=a.asm.i).apply(null,arguments)},Ya=a._emscripten_bind_DecoderBuffer_Init_2=function(){return(Ya=a._emscripten_bind_DecoderBuffer_Init_2=a.asm.j).apply(null,arguments)},Za=a._emscripten_bind_DecoderBuffer___destroy___0=function(){return(Za=a._emscripten_bind_DecoderBuffer___destroy___0=a.asm.k).apply(null,arguments)},Aa=a._emscripten_bind_AttributeTransformData_AttributeTransformData_0=function(){return(Aa=a._emscripten_bind_AttributeTransformData_AttributeTransformData_0=
a.asm.l).apply(null,arguments)},$a=a._emscripten_bind_AttributeTransformData_transform_type_0=function(){return($a=a._emscripten_bind_AttributeTransformData_transform_type_0=a.asm.m).apply(null,arguments)},ab=a._emscripten_bind_AttributeTransformData___destroy___0=function(){return(ab=a._emscripten_bind_AttributeTransformData___destroy___0=a.asm.n).apply(null,arguments)},Ba=a._emscripten_bind_GeometryAttribute_GeometryAttribute_0=function(){return(Ba=a._emscripten_bind_GeometryAttribute_GeometryAttribute_0=
a.asm.o).apply(null,arguments)},bb=a._emscripten_bind_GeometryAttribute___destroy___0=function(){return(bb=a._emscripten_bind_GeometryAttribute___destroy___0=a.asm.p).apply(null,arguments)},Ca=a._emscripten_bind_PointAttribute_PointAttribute_0=function(){return(Ca=a._emscripten_bind_PointAttribute_PointAttribute_0=a.asm.q).apply(null,arguments)},cb=a._emscripten_bind_PointAttribute_size_0=function(){return(cb=a._emscripten_bind_PointAttribute_size_0=a.asm.r).apply(null,arguments)},db=a._emscripten_bind_PointAttribute_GetAttributeTransformData_0=
function(){return(db=a._emscripten_bind_PointAttribute_GetAttributeTransformData_0=a.asm.s).apply(null,arguments)},eb=a._emscripten_bind_PointAttribute_attribute_type_0=function(){return(eb=a._emscripten_bind_PointAttribute_attribute_type_0=a.asm.t).apply(null,arguments)},fb=a._emscripten_bind_PointAttribute_data_type_0=function(){return(fb=a._emscripten_bind_PointAttribute_data_type_0=a.asm.u).apply(null,arguments)},gb=a._emscripten_bind_PointAttribute_num_components_0=function(){return(gb=a._emscripten_bind_PointAttribute_num_components_0=
a.asm.v).apply(null,arguments)},hb=a._emscripten_bind_PointAttribute_normalized_0=function(){return(hb=a._emscripten_bind_PointAttribute_normalized_0=a.asm.w).apply(null,arguments)},ib=a._emscripten_bind_PointAttribute_byte_stride_0=function(){return(ib=a._emscripten_bind_PointAttribute_byte_stride_0=a.asm.x).apply(null,arguments)},jb=a._emscripten_bind_PointAttribute_byte_offset_0=function(){return(jb=a._emscripten_bind_PointAttribute_byte_offset_0=a.asm.y).apply(null,arguments)},kb=a._emscripten_bind_PointAttribute_unique_id_0=
function(){return(kb=a._emscripten_bind_PointAttribute_unique_id_0=a.asm.z).apply(null,arguments)},lb=a._emscripten_bind_PointAttribute___destroy___0=function(){return(lb=a._emscripten_bind_PointAttribute___destroy___0=a.asm.A).apply(null,arguments)},Da=a._emscripten_bind_AttributeQuantizationTransform_AttributeQuantizationTransform_0=function(){return(Da=a._emscripten_bind_AttributeQuantizationTransform_AttributeQuantizationTransform_0=a.asm.B).apply(null,arguments)},mb=a._emscripten_bind_AttributeQuantizationTransform_InitFromAttribute_1=
function(){return(mb=a._emscripten_bind_AttributeQuantizationTransform_InitFromAttribute_1=a.asm.C).apply(null,arguments)},nb=a._emscripten_bind_AttributeQuantizationTransform_quantization_bits_0=function(){return(nb=a._emscripten_bind_AttributeQuantizationTransform_quantization_bits_0=a.asm.D).apply(null,arguments)},ob=a._emscripten_bind_AttributeQuantizationTransform_min_value_1=function(){return(ob=a._emscripten_bind_AttributeQuantizationTransform_min_value_1=a.asm.E).apply(null,arguments)},pb=
a._emscripten_bind_AttributeQuantizationTransform_range_0=function(){return(pb=a._emscripten_bind_AttributeQuantizationTransform_range_0=a.asm.F).apply(null,arguments)},qb=a._emscripten_bind_AttributeQuantizationTransform___destroy___0=function(){return(qb=a._emscripten_bind_AttributeQuantizationTransform___destroy___0=a.asm.G).apply(null,arguments)},Ea=a._emscripten_bind_AttributeOctahedronTransform_AttributeOctahedronTransform_0=function(){return(Ea=a._emscripten_bind_AttributeOctahedronTransform_AttributeOctahedronTransform_0=
a.asm.H).apply(null,arguments)},rb=a._emscripten_bind_AttributeOctahedronTransform_InitFromAttribute_1=function(){return(rb=a._emscripten_bind_AttributeOctahedronTransform_InitFromAttribute_1=a.asm.I).apply(null,arguments)},sb=a._emscripten_bind_AttributeOctahedronTransform_quantization_bits_0=function(){return(sb=a._emscripten_bind_AttributeOctahedronTransform_quantization_bits_0=a.asm.J).apply(null,arguments)},tb=a._emscripten_bind_AttributeOctahedronTransform___destroy___0=function(){return(tb=
a._emscripten_bind_AttributeOctahedronTransform___destroy___0=a.asm.K).apply(null,arguments)},Fa=a._emscripten_bind_PointCloud_PointCloud_0=function(){return(Fa=a._emscripten_bind_PointCloud_PointCloud_0=a.asm.L).apply(null,arguments)},ub=a._emscripten_bind_PointCloud_num_attributes_0=function(){return(ub=a._emscripten_bind_PointCloud_num_attributes_0=a.asm.M).apply(null,arguments)},vb=a._emscripten_bind_PointCloud_num_points_0=function(){return(vb=a._emscripten_bind_PointCloud_num_points_0=a.asm.N).apply(null,
arguments)},wb=a._emscripten_bind_PointCloud___destroy___0=function(){return(wb=a._emscripten_bind_PointCloud___destroy___0=a.asm.O).apply(null,arguments)},Ga=a._emscripten_bind_Mesh_Mesh_0=function(){return(Ga=a._emscripten_bind_Mesh_Mesh_0=a.asm.P).apply(null,arguments)},xb=a._emscripten_bind_Mesh_num_faces_0=function(){return(xb=a._emscripten_bind_Mesh_num_faces_0=a.asm.Q).apply(null,arguments)},yb=a._emscripten_bind_Mesh_num_attributes_0=function(){return(yb=a._emscripten_bind_Mesh_num_attributes_0=
a.asm.R).apply(null,arguments)},zb=a._emscripten_bind_Mesh_num_points_0=function(){return(zb=a._emscripten_bind_Mesh_num_points_0=a.asm.S).apply(null,arguments)},Ab=a._emscripten_bind_Mesh___destroy___0=function(){return(Ab=a._emscripten_bind_Mesh___destroy___0=a.asm.T).apply(null,arguments)},Ha=a._emscripten_bind_Metadata_Metadata_0=function(){return(Ha=a._emscripten_bind_Metadata_Metadata_0=a.asm.U).apply(null,arguments)},Bb=a._emscripten_bind_Metadata___destroy___0=function(){return(Bb=a._emscripten_bind_Metadata___destroy___0=
a.asm.V).apply(null,arguments)},Cb=a._emscripten_bind_Status_code_0=function(){return(Cb=a._emscripten_bind_Status_code_0=a.asm.W).apply(null,arguments)},Db=a._emscripten_bind_Status_ok_0=function(){return(Db=a._emscripten_bind_Status_ok_0=a.asm.X).apply(null,arguments)},Eb=a._emscripten_bind_Status_error_msg_0=function(){return(Eb=a._emscripten_bind_Status_error_msg_0=a.asm.Y).apply(null,arguments)},Fb=a._emscripten_bind_Status___destroy___0=function(){return(Fb=a._emscripten_bind_Status___destroy___0=
a.asm.Z).apply(null,arguments)},Ia=a._emscripten_bind_DracoFloat32Array_DracoFloat32Array_0=function(){return(Ia=a._emscripten_bind_DracoFloat32Array_DracoFloat32Array_0=a.asm._).apply(null,arguments)},Gb=a._emscripten_bind_DracoFloat32Array_GetValue_1=function(){return(Gb=a._emscripten_bind_DracoFloat32Array_GetValue_1=a.asm.$).apply(null,arguments)},Hb=a._emscripten_bind_DracoFloat32Array_size_0=function(){return(Hb=a._emscripten_bind_DracoFloat32Array_size_0=a.asm.aa).apply(null,arguments)},Ib=
a._emscripten_bind_DracoFloat32Array___destroy___0=function(){return(Ib=a._emscripten_bind_DracoFloat32Array___destroy___0=a.asm.ba).apply(null,arguments)},Ja=a._emscripten_bind_DracoInt8Array_DracoInt8Array_0=function(){return(Ja=a._emscripten_bind_DracoInt8Array_DracoInt8Array_0=a.asm.ca).apply(null,arguments)},Jb=a._emscripten_bind_DracoInt8Array_GetValue_1=function(){return(Jb=a._emscripten_bind_DracoInt8Array_GetValue_1=a.asm.da).apply(null,arguments)},Kb=a._emscripten_bind_DracoInt8Array_size_0=
function(){return(Kb=a._emscripten_bind_DracoInt8Array_size_0=a.asm.ea).apply(null,arguments)},Lb=a._emscripten_bind_DracoInt8Array___destroy___0=function(){return(Lb=a._emscripten_bind_DracoInt8Array___destroy___0=a.asm.fa).apply(null,arguments)},Ka=a._emscripten_bind_DracoUInt8Array_DracoUInt8Array_0=function(){return(Ka=a._emscripten_bind_DracoUInt8Array_DracoUInt8Array_0=a.asm.ga).apply(null,arguments)},Mb=a._emscripten_bind_DracoUInt8Array_GetValue_1=function(){return(Mb=a._emscripten_bind_DracoUInt8Array_GetValue_1=
a.asm.ha).apply(null,arguments)},Nb=a._emscripten_bind_DracoUInt8Array_size_0=function(){return(Nb=a._emscripten_bind_DracoUInt8Array_size_0=a.asm.ia).apply(null,arguments)},Ob=a._emscripten_bind_DracoUInt8Array___destroy___0=function(){return(Ob=a._emscripten_bind_DracoUInt8Array___destroy___0=a.asm.ja).apply(null,arguments)},La=a._emscripten_bind_DracoInt16Array_DracoInt16Array_0=function(){return(La=a._emscripten_bind_DracoInt16Array_DracoInt16Array_0=a.asm.ka).apply(null,arguments)},Pb=a._emscripten_bind_DracoInt16Array_GetValue_1=
function(){return(Pb=a._emscripten_bind_DracoInt16Array_GetValue_1=a.asm.la).apply(null,arguments)},Qb=a._emscripten_bind_DracoInt16Array_size_0=function(){return(Qb=a._emscripten_bind_DracoInt16Array_size_0=a.asm.ma).apply(null,arguments)},Rb=a._emscripten_bind_DracoInt16Array___destroy___0=function(){return(Rb=a._emscripten_bind_DracoInt16Array___destroy___0=a.asm.na).apply(null,arguments)},Ma=a._emscripten_bind_DracoUInt16Array_DracoUInt16Array_0=function(){return(Ma=a._emscripten_bind_DracoUInt16Array_DracoUInt16Array_0=
a.asm.oa).apply(null,arguments)},Sb=a._emscripten_bind_DracoUInt16Array_GetValue_1=function(){return(Sb=a._emscripten_bind_DracoUInt16Array_GetValue_1=a.asm.pa).apply(null,arguments)},Tb=a._emscripten_bind_DracoUInt16Array_size_0=function(){return(Tb=a._emscripten_bind_DracoUInt16Array_size_0=a.asm.qa).apply(null,arguments)},Ub=a._emscripten_bind_DracoUInt16Array___destroy___0=function(){return(Ub=a._emscripten_bind_DracoUInt16Array___destroy___0=a.asm.ra).apply(null,arguments)},Na=a._emscripten_bind_DracoInt32Array_DracoInt32Array_0=
function(){return(Na=a._emscripten_bind_DracoInt32Array_DracoInt32Array_0=a.asm.sa).apply(null,arguments)},Vb=a._emscripten_bind_DracoInt32Array_GetValue_1=function(){return(Vb=a._emscripten_bind_DracoInt32Array_GetValue_1=a.asm.ta).apply(null,arguments)},Wb=a._emscripten_bind_DracoInt32Array_size_0=function(){return(Wb=a._emscripten_bind_DracoInt32Array_size_0=a.asm.ua).apply(null,arguments)},Xb=a._emscripten_bind_DracoInt32Array___destroy___0=function(){return(Xb=a._emscripten_bind_DracoInt32Array___destroy___0=
a.asm.va).apply(null,arguments)},Oa=a._emscripten_bind_DracoUInt32Array_DracoUInt32Array_0=function(){return(Oa=a._emscripten_bind_DracoUInt32Array_DracoUInt32Array_0=a.asm.wa).apply(null,arguments)},Yb=a._emscripten_bind_DracoUInt32Array_GetValue_1=function(){return(Yb=a._emscripten_bind_DracoUInt32Array_GetValue_1=a.asm.xa).apply(null,arguments)},Zb=a._emscripten_bind_DracoUInt32Array_size_0=function(){return(Zb=a._emscripten_bind_DracoUInt32Array_size_0=a.asm.ya).apply(null,arguments)},$b=a._emscripten_bind_DracoUInt32Array___destroy___0=
function(){return($b=a._emscripten_bind_DracoUInt32Array___destroy___0=a.asm.za).apply(null,arguments)},Pa=a._emscripten_bind_MetadataQuerier_MetadataQuerier_0=function(){return(Pa=a._emscripten_bind_MetadataQuerier_MetadataQuerier_0=a.asm.Aa).apply(null,arguments)},ac=a._emscripten_bind_MetadataQuerier_HasEntry_2=function(){return(ac=a._emscripten_bind_MetadataQuerier_HasEntry_2=a.asm.Ba).apply(null,arguments)},bc=a._emscripten_bind_MetadataQuerier_GetIntEntry_2=function(){return(bc=a._emscripten_bind_MetadataQuerier_GetIntEntry_2=
a.asm.Ca).apply(null,arguments)},cc=a._emscripten_bind_MetadataQuerier_GetIntEntryArray_3=function(){return(cc=a._emscripten_bind_MetadataQuerier_GetIntEntryArray_3=a.asm.Da).apply(null,arguments)},dc=a._emscripten_bind_MetadataQuerier_GetDoubleEntry_2=function(){return(dc=a._emscripten_bind_MetadataQuerier_GetDoubleEntry_2=a.asm.Ea).apply(null,arguments)},ec=a._emscripten_bind_MetadataQuerier_GetStringEntry_2=function(){return(ec=a._emscripten_bind_MetadataQuerier_GetStringEntry_2=a.asm.Fa).apply(null,
arguments)},fc=a._emscripten_bind_MetadataQuerier_NumEntries_1=function(){return(fc=a._emscripten_bind_MetadataQuerier_NumEntries_1=a.asm.Ga).apply(null,arguments)},gc=a._emscripten_bind_MetadataQuerier_GetEntryName_2=function(){return(gc=a._emscripten_bind_MetadataQuerier_GetEntryName_2=a.asm.Ha).apply(null,arguments)},hc=a._emscripten_bind_MetadataQuerier___destroy___0=function(){return(hc=a._emscripten_bind_MetadataQuerier___destroy___0=a.asm.Ia).apply(null,arguments)},Qa=a._emscripten_bind_Decoder_Decoder_0=
function(){return(Qa=a._emscripten_bind_Decoder_Decoder_0=a.asm.Ja).apply(null,arguments)},ic=a._emscripten_bind_Decoder_DecodeArrayToPointCloud_3=function(){return(ic=a._emscripten_bind_Decoder_DecodeArrayToPointCloud_3=a.asm.Ka).apply(null,arguments)},jc=a._emscripten_bind_Decoder_DecodeArrayToMesh_3=function(){return(jc=a._emscripten_bind_Decoder_DecodeArrayToMesh_3=a.asm.La).apply(null,arguments)},kc=a._emscripten_bind_Decoder_GetAttributeId_2=function(){return(kc=a._emscripten_bind_Decoder_GetAttributeId_2=
a.asm.Ma).apply(null,arguments)},lc=a._emscripten_bind_Decoder_GetAttributeIdByName_2=function(){return(lc=a._emscripten_bind_Decoder_GetAttributeIdByName_2=a.asm.Na).apply(null,arguments)},mc=a._emscripten_bind_Decoder_GetAttributeIdByMetadataEntry_3=function(){return(mc=a._emscripten_bind_Decoder_GetAttributeIdByMetadataEntry_3=a.asm.Oa).apply(null,arguments)},nc=a._emscripten_bind_Decoder_GetAttribute_2=function(){return(nc=a._emscripten_bind_Decoder_GetAttribute_2=a.asm.Pa).apply(null,arguments)},
oc=a._emscripten_bind_Decoder_GetAttributeByUniqueId_2=function(){return(oc=a._emscripten_bind_Decoder_GetAttributeByUniqueId_2=a.asm.Qa).apply(null,arguments)},pc=a._emscripten_bind_Decoder_GetMetadata_1=function(){return(pc=a._emscripten_bind_Decoder_GetMetadata_1=a.asm.Ra).apply(null,arguments)},qc=a._emscripten_bind_Decoder_GetAttributeMetadata_2=function(){return(qc=a._emscripten_bind_Decoder_GetAttributeMetadata_2=a.asm.Sa).apply(null,arguments)},rc=a._emscripten_bind_Decoder_GetFaceFromMesh_3=
function(){return(rc=a._emscripten_bind_Decoder_GetFaceFromMesh_3=a.asm.Ta).apply(null,arguments)},sc=a._emscripten_bind_Decoder_GetTriangleStripsFromMesh_2=function(){return(sc=a._emscripten_bind_Decoder_GetTriangleStripsFromMesh_2=a.asm.Ua).apply(null,arguments)},tc=a._emscripten_bind_Decoder_GetTrianglesUInt16Array_3=function(){return(tc=a._emscripten_bind_Decoder_GetTrianglesUInt16Array_3=a.asm.Va).apply(null,arguments)},uc=a._emscripten_bind_Decoder_GetTrianglesUInt32Array_3=function(){return(uc=
a._emscripten_bind_Decoder_GetTrianglesUInt32Array_3=a.asm.Wa).apply(null,arguments)},vc=a._emscripten_bind_Decoder_GetAttributeFloat_3=function(){return(vc=a._emscripten_bind_Decoder_GetAttributeFloat_3=a.asm.Xa).apply(null,arguments)},wc=a._emscripten_bind_Decoder_GetAttributeFloatForAllPoints_3=function(){return(wc=a._emscripten_bind_Decoder_GetAttributeFloatForAllPoints_3=a.asm.Ya).apply(null,arguments)},xc=a._emscripten_bind_Decoder_GetAttributeIntForAllPoints_3=function(){return(xc=a._emscripten_bind_Decoder_GetAttributeIntForAllPoints_3=
a.asm.Za).apply(null,arguments)},yc=a._emscripten_bind_Decoder_GetAttributeInt8ForAllPoints_3=function(){return(yc=a._emscripten_bind_Decoder_GetAttributeInt8ForAllPoints_3=a.asm._a).apply(null,arguments)},zc=a._emscripten_bind_Decoder_GetAttributeUInt8ForAllPoints_3=function(){return(zc=a._emscripten_bind_Decoder_GetAttributeUInt8ForAllPoints_3=a.asm.$a).apply(null,arguments)},Ac=a._emscripten_bind_Decoder_GetAttributeInt16ForAllPoints_3=function(){return(Ac=a._emscripten_bind_Decoder_GetAttributeInt16ForAllPoints_3=
a.asm.ab).apply(null,arguments)},Bc=a._emscripten_bind_Decoder_GetAttributeUInt16ForAllPoints_3=function(){return(Bc=a._emscripten_bind_Decoder_GetAttributeUInt16ForAllPoints_3=a.asm.bb).apply(null,arguments)},Cc=a._emscripten_bind_Decoder_GetAttributeInt32ForAllPoints_3=function(){return(Cc=a._emscripten_bind_Decoder_GetAttributeInt32ForAllPoints_3=a.asm.cb).apply(null,arguments)},Dc=a._emscripten_bind_Decoder_GetAttributeUInt32ForAllPoints_3=function(){return(Dc=a._emscripten_bind_Decoder_GetAttributeUInt32ForAllPoints_3=
a.asm.db).apply(null,arguments)},Ec=a._emscripten_bind_Decoder_GetAttributeDataArrayForAllPoints_5=function(){return(Ec=a._emscripten_bind_Decoder_GetAttributeDataArrayForAllPoints_5=a.asm.eb).apply(null,arguments)},Fc=a._emscripten_bind_Decoder_SkipAttributeTransform_1=function(){return(Fc=a._emscripten_bind_Decoder_SkipAttributeTransform_1=a.asm.fb).apply(null,arguments)},Gc=a._emscripten_bind_Decoder_GetEncodedGeometryType_Deprecated_1=function(){return(Gc=a._emscripten_bind_Decoder_GetEncodedGeometryType_Deprecated_1=
a.asm.gb).apply(null,arguments)},Hc=a._emscripten_bind_Decoder_DecodeBufferToPointCloud_2=function(){return(Hc=a._emscripten_bind_Decoder_DecodeBufferToPointCloud_2=a.asm.hb).apply(null,arguments)},Ic=a._emscripten_bind_Decoder_DecodeBufferToMesh_2=function(){return(Ic=a._emscripten_bind_Decoder_DecodeBufferToMesh_2=a.asm.ib).apply(null,arguments)},Jc=a._emscripten_bind_Decoder___destroy___0=function(){return(Jc=a._emscripten_bind_Decoder___destroy___0=a.asm.jb).apply(null,arguments)},Kc=a._emscripten_enum_draco_AttributeTransformType_ATTRIBUTE_INVALID_TRANSFORM=
function(){return(Kc=a._emscripten_enum_draco_AttributeTransformType_ATTRIBUTE_INVALID_TRANSFORM=a.asm.kb).apply(null,arguments)},Lc=a._emscripten_enum_draco_AttributeTransformType_ATTRIBUTE_NO_TRANSFORM=function(){return(Lc=a._emscripten_enum_draco_AttributeTransformType_ATTRIBUTE_NO_TRANSFORM=a.asm.lb).apply(null,arguments)},Mc=a._emscripten_enum_draco_AttributeTransformType_ATTRIBUTE_QUANTIZATION_TRANSFORM=function(){return(Mc=a._emscripten_enum_draco_AttributeTransformType_ATTRIBUTE_QUANTIZATION_TRANSFORM=
a.asm.mb).apply(null,arguments)},Nc=a._emscripten_enum_draco_AttributeTransformType_ATTRIBUTE_OCTAHEDRON_TRANSFORM=function(){return(Nc=a._emscripten_enum_draco_AttributeTransformType_ATTRIBUTE_OCTAHEDRON_TRANSFORM=a.asm.nb).apply(null,arguments)},Oc=a._emscripten_enum_draco_GeometryAttribute_Type_INVALID=function(){return(Oc=a._emscripten_enum_draco_GeometryAttribute_Type_INVALID=a.asm.ob).apply(null,arguments)},Pc=a._emscripten_enum_draco_GeometryAttribute_Type_POSITION=function(){return(Pc=a._emscripten_enum_draco_GeometryAttribute_Type_POSITION=
a.asm.pb).apply(null,arguments)},Qc=a._emscripten_enum_draco_GeometryAttribute_Type_NORMAL=function(){return(Qc=a._emscripten_enum_draco_GeometryAttribute_Type_NORMAL=a.asm.qb).apply(null,arguments)},Rc=a._emscripten_enum_draco_GeometryAttribute_Type_COLOR=function(){return(Rc=a._emscripten_enum_draco_GeometryAttribute_Type_COLOR=a.asm.rb).apply(null,arguments)},Sc=a._emscripten_enum_draco_GeometryAttribute_Type_TEX_COORD=function(){return(Sc=a._emscripten_enum_draco_GeometryAttribute_Type_TEX_COORD=
a.asm.sb).apply(null,arguments)},Tc=a._emscripten_enum_draco_GeometryAttribute_Type_GENERIC=function(){return(Tc=a._emscripten_enum_draco_GeometryAttribute_Type_GENERIC=a.asm.tb).apply(null,arguments)},Uc=a._emscripten_enum_draco_EncodedGeometryType_INVALID_GEOMETRY_TYPE=function(){return(Uc=a._emscripten_enum_draco_EncodedGeometryType_INVALID_GEOMETRY_TYPE=a.asm.ub).apply(null,arguments)},Vc=a._emscripten_enum_draco_EncodedGeometryType_POINT_CLOUD=function(){return(Vc=a._emscripten_enum_draco_EncodedGeometryType_POINT_CLOUD=
a.asm.vb).apply(null,arguments)},Wc=a._emscripten_enum_draco_EncodedGeometryType_TRIANGULAR_MESH=function(){return(Wc=a._emscripten_enum_draco_EncodedGeometryType_TRIANGULAR_MESH=a.asm.wb).apply(null,arguments)},Xc=a._emscripten_enum_draco_DataType_DT_INVALID=function(){return(Xc=a._emscripten_enum_draco_DataType_DT_INVALID=a.asm.xb).apply(null,arguments)},Yc=a._emscripten_enum_draco_DataType_DT_INT8=function(){return(Yc=a._emscripten_enum_draco_DataType_DT_INT8=a.asm.yb).apply(null,arguments)},Zc=
a._emscripten_enum_draco_DataType_DT_UINT8=function(){return(Zc=a._emscripten_enum_draco_DataType_DT_UINT8=a.asm.zb).apply(null,arguments)},$c=a._emscripten_enum_draco_DataType_DT_INT16=function(){return($c=a._emscripten_enum_draco_DataType_DT_INT16=a.asm.Ab).apply(null,arguments)},ad=a._emscripten_enum_draco_DataType_DT_UINT16=function(){return(ad=a._emscripten_enum_draco_DataType_DT_UINT16=a.asm.Bb).apply(null,arguments)},bd=a._emscripten_enum_draco_DataType_DT_INT32=function(){return(bd=a._emscripten_enum_draco_DataType_DT_INT32=
a.asm.Cb).apply(null,arguments)},cd=a._emscripten_enum_draco_DataType_DT_UINT32=function(){return(cd=a._emscripten_enum_draco_DataType_DT_UINT32=a.asm.Db).apply(null,arguments)},dd=a._emscripten_enum_draco_DataType_DT_INT64=function(){return(dd=a._emscripten_enum_draco_DataType_DT_INT64=a.asm.Eb).apply(null,arguments)},ed=a._emscripten_enum_draco_DataType_DT_UINT64=function(){return(ed=a._emscripten_enum_draco_DataType_DT_UINT64=a.asm.Fb).apply(null,arguments)},fd=a._emscripten_enum_draco_DataType_DT_FLOAT32=
function(){return(fd=a._emscripten_enum_draco_DataType_DT_FLOAT32=a.asm.Gb).apply(null,arguments)},gd=a._emscripten_enum_draco_DataType_DT_FLOAT64=function(){return(gd=a._emscripten_enum_draco_DataType_DT_FLOAT64=a.asm.Hb).apply(null,arguments)},hd=a._emscripten_enum_draco_DataType_DT_BOOL=function(){return(hd=a._emscripten_enum_draco_DataType_DT_BOOL=a.asm.Ib).apply(null,arguments)},id=a._emscripten_enum_draco_DataType_DT_TYPES_COUNT=function(){return(id=a._emscripten_enum_draco_DataType_DT_TYPES_COUNT=
a.asm.Jb).apply(null,arguments)},jd=a._emscripten_enum_draco_StatusCode_OK=function(){return(jd=a._emscripten_enum_draco_StatusCode_OK=a.asm.Kb).apply(null,arguments)},kd=a._emscripten_enum_draco_StatusCode_DRACO_ERROR=function(){return(kd=a._emscripten_enum_draco_StatusCode_DRACO_ERROR=a.asm.Lb).apply(null,arguments)},ld=a._emscripten_enum_draco_StatusCode_IO_ERROR=function(){return(ld=a._emscripten_enum_draco_StatusCode_IO_ERROR=a.asm.Mb).apply(null,arguments)},md=a._emscripten_enum_draco_StatusCode_INVALID_PARAMETER=
function(){return(md=a._emscripten_enum_draco_StatusCode_INVALID_PARAMETER=a.asm.Nb).apply(null,arguments)},nd=a._emscripten_enum_draco_StatusCode_UNSUPPORTED_VERSION=function(){return(nd=a._emscripten_enum_draco_StatusCode_UNSUPPORTED_VERSION=a.asm.Ob).apply(null,arguments)},od=a._emscripten_enum_draco_StatusCode_UNKNOWN_VERSION=function(){return(od=a._emscripten_enum_draco_StatusCode_UNKNOWN_VERSION=a.asm.Pb).apply(null,arguments)};a._malloc=function(){return(a._malloc=a.asm.Qb).apply(null,arguments)};
a._free=function(){return(a._free=a.asm.Rb).apply(null,arguments)};var ua=function(){return(ua=a.asm.Sb).apply(null,arguments)};a.___start_em_js=11660;a.___stop_em_js=11758;var la;ha=function b(){la||F();la||(ha=b)};if(a.preInit)for("function"==typeof a.preInit&&(a.preInit=[a.preInit]);0<a.preInit.length;)a.preInit.pop()();F();v.prototype=Object.create(v.prototype);v.prototype.constructor=v;v.prototype.__class__=v;v.__cache__={};a.WrapperObject=v;a.getCache=w;a.wrapPointer=B;a.castObject=function(b,
c){return B(b.ptr,c)};a.NULL=B(0);a.destroy=function(b){if(!b.__destroy__)throw"Error: Cannot destroy object. (Did you create it yourself?)";b.__destroy__();delete w(b.__class__)[b.ptr]};a.compare=function(b,c){return b.ptr===c.ptr};a.getPointer=function(b){return b.ptr};a.getClass=function(b){return b.__class__};var r={buffer:0,size:0,pos:0,temps:[],needed:0,prepare:function(){if(r.needed){for(var b=0;b<r.temps.length;b++)a._free(r.temps[b]);r.temps.length=0;a._free(r.buffer);r.buffer=0;r.size+=
r.needed;r.needed=0}r.buffer||(r.size+=128,r.buffer=a._malloc(r.size),r.buffer||y(void 0));r.pos=0},alloc:function(b,c){r.buffer||y(void 0);b=b.length*c.BYTES_PER_ELEMENT;b=b+7&-8;r.pos+b>=r.size?(0<b||y(void 0),r.needed+=b,c=a._malloc(b),r.temps.push(c)):(c=r.buffer+r.pos,r.pos+=b);return c},copy:function(b,c,d){d>>>=0;switch(c.BYTES_PER_ELEMENT){case 2:d>>>=1;break;case 4:d>>>=2;break;case 8:d>>>=3}for(var g=0;g<b.length;g++)c[d+g]=b[g]}};X.prototype=Object.create(v.prototype);X.prototype.constructor=
X;X.prototype.__class__=X;X.__cache__={};a.VoidPtr=X;X.prototype.__destroy__=X.prototype.__destroy__=function(){Xa(this.ptr)};S.prototype=Object.create(v.prototype);S.prototype.constructor=S;S.prototype.__class__=S;S.__cache__={};a.DecoderBuffer=S;S.prototype.Init=S.prototype.Init=function(b,c){var d=this.ptr;r.prepare();"object"==typeof b&&(b=Z(b));c&&"object"===typeof c&&(c=c.ptr);Ya(d,b,c)};S.prototype.__destroy__=S.prototype.__destroy__=function(){Za(this.ptr)};Q.prototype=Object.create(v.prototype);
Q.prototype.constructor=Q;Q.prototype.__class__=Q;Q.__cache__={};a.AttributeTransformData=Q;Q.prototype.transform_type=Q.prototype.transform_type=function(){return $a(this.ptr)};Q.prototype.__destroy__=Q.prototype.__destroy__=function(){ab(this.ptr)};V.prototype=Object.create(v.prototype);V.prototype.constructor=V;V.prototype.__class__=V;V.__cache__={};a.GeometryAttribute=V;V.prototype.__destroy__=V.prototype.__destroy__=function(){bb(this.ptr)};x.prototype=Object.create(v.prototype);x.prototype.constructor=
x;x.prototype.__class__=x;x.__cache__={};a.PointAttribute=x;x.prototype.size=x.prototype.size=function(){return cb(this.ptr)};x.prototype.GetAttributeTransformData=x.prototype.GetAttributeTransformData=function(){return B(db(this.ptr),Q)};x.prototype.attribute_type=x.prototype.attribute_type=function(){return eb(this.ptr)};x.prototype.data_type=x.prototype.data_type=function(){return fb(this.ptr)};x.prototype.num_components=x.prototype.num_components=function(){return gb(this.ptr)};x.prototype.normalized=
x.prototype.normalized=function(){return!!hb(this.ptr)};x.prototype.byte_stride=x.prototype.byte_stride=function(){return ib(this.ptr)};x.prototype.byte_offset=x.prototype.byte_offset=function(){return jb(this.ptr)};x.prototype.unique_id=x.prototype.unique_id=function(){return kb(this.ptr)};x.prototype.__destroy__=x.prototype.__destroy__=function(){lb(this.ptr)};D.prototype=Object.create(v.prototype);D.prototype.constructor=D;D.prototype.__class__=D;D.__cache__={};a.AttributeQuantizationTransform=
D;D.prototype.InitFromAttribute=D.prototype.InitFromAttribute=function(b){var c=this.ptr;b&&"object"===typeof b&&(b=b.ptr);return!!mb(c,b)};D.prototype.quantization_bits=D.prototype.quantization_bits=function(){return nb(this.ptr)};D.prototype.min_value=D.prototype.min_value=function(b){var c=this.ptr;b&&"object"===typeof b&&(b=b.ptr);return ob(c,b)};D.prototype.range=D.prototype.range=function(){return pb(this.ptr)};D.prototype.__destroy__=D.prototype.__destroy__=function(){qb(this.ptr)};G.prototype=
Object.create(v.prototype);G.prototype.constructor=G;G.prototype.__class__=G;G.__cache__={};a.AttributeOctahedronTransform=G;G.prototype.InitFromAttribute=G.prototype.InitFromAttribute=function(b){var c=this.ptr;b&&"object"===typeof b&&(b=b.ptr);return!!rb(c,b)};G.prototype.quantization_bits=G.prototype.quantization_bits=function(){return sb(this.ptr)};G.prototype.__destroy__=G.prototype.__destroy__=function(){tb(this.ptr)};H.prototype=Object.create(v.prototype);H.prototype.constructor=H;H.prototype.__class__=
H;H.__cache__={};a.PointCloud=H;H.prototype.num_attributes=H.prototype.num_attributes=function(){return ub(this.ptr)};H.prototype.num_points=H.prototype.num_points=function(){return vb(this.ptr)};H.prototype.__destroy__=H.prototype.__destroy__=function(){wb(this.ptr)};E.prototype=Object.create(v.prototype);E.prototype.constructor=E;E.prototype.__class__=E;E.__cache__={};a.Mesh=E;E.prototype.num_faces=E.prototype.num_faces=function(){return xb(this.ptr)};E.prototype.num_attributes=E.prototype.num_attributes=
function(){return yb(this.ptr)};E.prototype.num_points=E.prototype.num_points=function(){return zb(this.ptr)};E.prototype.__destroy__=E.prototype.__destroy__=function(){Ab(this.ptr)};T.prototype=Object.create(v.prototype);T.prototype.constructor=T;T.prototype.__class__=T;T.__cache__={};a.Metadata=T;T.prototype.__destroy__=T.prototype.__destroy__=function(){Bb(this.ptr)};C.prototype=Object.create(v.prototype);C.prototype.constructor=C;C.prototype.__class__=C;C.__cache__={};a.Status=C;C.prototype.code=
C.prototype.code=function(){return Cb(this.ptr)};C.prototype.ok=C.prototype.ok=function(){return!!Db(this.ptr)};C.prototype.error_msg=C.prototype.error_msg=function(){return p(Eb(this.ptr))};C.prototype.__destroy__=C.prototype.__destroy__=function(){Fb(this.ptr)};I.prototype=Object.create(v.prototype);I.prototype.constructor=I;I.prototype.__class__=I;I.__cache__={};a.DracoFloat32Array=I;I.prototype.GetValue=I.prototype.GetValue=function(b){var c=this.ptr;b&&"object"===typeof b&&(b=b.ptr);return Gb(c,
b)};I.prototype.size=I.prototype.size=function(){return Hb(this.ptr)};I.prototype.__destroy__=I.prototype.__destroy__=function(){Ib(this.ptr)};J.prototype=Object.create(v.prototype);J.prototype.constructor=J;J.prototype.__class__=J;J.__cache__={};a.DracoInt8Array=J;J.prototype.GetValue=J.prototype.GetValue=function(b){var c=this.ptr;b&&"object"===typeof b&&(b=b.ptr);return Jb(c,b)};J.prototype.size=J.prototype.size=function(){return Kb(this.ptr)};J.prototype.__destroy__=J.prototype.__destroy__=function(){Lb(this.ptr)};
K.prototype=Object.create(v.prototype);K.prototype.constructor=K;K.prototype.__class__=K;K.__cache__={};a.DracoUInt8Array=K;K.prototype.GetValue=K.prototype.GetValue=function(b){var c=this.ptr;b&&"object"===typeof b&&(b=b.ptr);return Mb(c,b)};K.prototype.size=K.prototype.size=function(){return Nb(this.ptr)};K.prototype.__destroy__=K.prototype.__destroy__=function(){Ob(this.ptr)};L.prototype=Object.create(v.prototype);L.prototype.constructor=L;L.prototype.__class__=L;L.__cache__={};a.DracoInt16Array=
L;L.prototype.GetValue=L.prototype.GetValue=function(b){var c=this.ptr;b&&"object"===typeof b&&(b=b.ptr);return Pb(c,b)};L.prototype.size=L.prototype.size=function(){return Qb(this.ptr)};L.prototype.__destroy__=L.prototype.__destroy__=function(){Rb(this.ptr)};M.prototype=Object.create(v.prototype);M.prototype.constructor=M;M.prototype.__class__=M;M.__cache__={};a.DracoUInt16Array=M;M.prototype.GetValue=M.prototype.GetValue=function(b){var c=this.ptr;b&&"object"===typeof b&&(b=b.ptr);return Sb(c,b)};
M.prototype.size=M.prototype.size=function(){return Tb(this.ptr)};M.prototype.__destroy__=M.prototype.__destroy__=function(){Ub(this.ptr)};N.prototype=Object.create(v.prototype);N.prototype.constructor=N;N.prototype.__class__=N;N.__cache__={};a.DracoInt32Array=N;N.prototype.GetValue=N.prototype.GetValue=function(b){var c=this.ptr;b&&"object"===typeof b&&(b=b.ptr);return Vb(c,b)};N.prototype.size=N.prototype.size=function(){return Wb(this.ptr)};N.prototype.__destroy__=N.prototype.__destroy__=function(){Xb(this.ptr)};
O.prototype=Object.create(v.prototype);O.prototype.constructor=O;O.prototype.__class__=O;O.__cache__={};a.DracoUInt32Array=O;O.prototype.GetValue=O.prototype.GetValue=function(b){var c=this.ptr;b&&"object"===typeof b&&(b=b.ptr);return Yb(c,b)};O.prototype.size=O.prototype.size=function(){return Zb(this.ptr)};O.prototype.__destroy__=O.prototype.__destroy__=function(){$b(this.ptr)};z.prototype=Object.create(v.prototype);z.prototype.constructor=z;z.prototype.__class__=z;z.__cache__={};a.MetadataQuerier=
z;z.prototype.HasEntry=z.prototype.HasEntry=function(b,c){var d=this.ptr;r.prepare();b&&"object"===typeof b&&(b=b.ptr);c=c&&"object"===typeof c?c.ptr:R(c);return!!ac(d,b,c)};z.prototype.GetIntEntry=z.prototype.GetIntEntry=function(b,c){var d=this.ptr;r.prepare();b&&"object"===typeof b&&(b=b.ptr);c=c&&"object"===typeof c?c.ptr:R(c);return bc(d,b,c)};z.prototype.GetIntEntryArray=z.prototype.GetIntEntryArray=function(b,c,d){var g=this.ptr;r.prepare();b&&"object"===typeof b&&(b=b.ptr);c=c&&"object"===
typeof c?c.ptr:R(c);d&&"object"===typeof d&&(d=d.ptr);cc(g,b,c,d)};z.prototype.GetDoubleEntry=z.prototype.GetDoubleEntry=function(b,c){var d=this.ptr;r.prepare();b&&"object"===typeof b&&(b=b.ptr);c=c&&"object"===typeof c?c.ptr:R(c);return dc(d,b,c)};z.prototype.GetStringEntry=z.prototype.GetStringEntry=function(b,c){var d=this.ptr;r.prepare();b&&"object"===typeof b&&(b=b.ptr);c=c&&"object"===typeof c?c.ptr:R(c);return p(ec(d,b,c))};z.prototype.NumEntries=z.prototype.NumEntries=function(b){var c=this.ptr;
b&&"object"===typeof b&&(b=b.ptr);return fc(c,b)};z.prototype.GetEntryName=z.prototype.GetEntryName=function(b,c){var d=this.ptr;b&&"object"===typeof b&&(b=b.ptr);c&&"object"===typeof c&&(c=c.ptr);return p(gc(d,b,c))};z.prototype.__destroy__=z.prototype.__destroy__=function(){hc(this.ptr)};m.prototype=Object.create(v.prototype);m.prototype.constructor=m;m.prototype.__class__=m;m.__cache__={};a.Decoder=m;m.prototype.DecodeArrayToPointCloud=m.prototype.DecodeArrayToPointCloud=function(b,c,d){var g=
this.ptr;r.prepare();"object"==typeof b&&(b=Z(b));c&&"object"===typeof c&&(c=c.ptr);d&&"object"===typeof d&&(d=d.ptr);return B(ic(g,b,c,d),C)};m.prototype.DecodeArrayToMesh=m.prototype.DecodeArrayToMesh=function(b,c,d){var g=this.ptr;r.prepare();"object"==typeof b&&(b=Z(b));c&&"object"===typeof c&&(c=c.ptr);d&&"object"===typeof d&&(d=d.ptr);return B(jc(g,b,c,d),C)};m.prototype.GetAttributeId=m.prototype.GetAttributeId=function(b,c){var d=this.ptr;b&&"object"===typeof b&&(b=b.ptr);c&&"object"===typeof c&&
(c=c.ptr);return kc(d,b,c)};m.prototype.GetAttributeIdByName=m.prototype.GetAttributeIdByName=function(b,c){var d=this.ptr;r.prepare();b&&"object"===typeof b&&(b=b.ptr);c=c&&"object"===typeof c?c.ptr:R(c);return lc(d,b,c)};m.prototype.GetAttributeIdByMetadataEntry=m.prototype.GetAttributeIdByMetadataEntry=function(b,c,d){var g=this.ptr;r.prepare();b&&"object"===typeof b&&(b=b.ptr);c=c&&"object"===typeof c?c.ptr:R(c);d=d&&"object"===typeof d?d.ptr:R(d);return mc(g,b,c,d)};m.prototype.GetAttribute=
m.prototype.GetAttribute=function(b,c){var d=this.ptr;b&&"object"===typeof b&&(b=b.ptr);c&&"object"===typeof c&&(c=c.ptr);return B(nc(d,b,c),x)};m.prototype.GetAttributeByUniqueId=m.prototype.GetAttributeByUniqueId=function(b,c){var d=this.ptr;b&&"object"===typeof b&&(b=b.ptr);c&&"object"===typeof c&&(c=c.ptr);return B(oc(d,b,c),x)};m.prototype.GetMetadata=m.prototype.GetMetadata=function(b){var c=this.ptr;b&&"object"===typeof b&&(b=b.ptr);return B(pc(c,b),T)};m.prototype.GetAttributeMetadata=m.prototype.GetAttributeMetadata=
function(b,c){var d=this.ptr;b&&"object"===typeof b&&(b=b.ptr);c&&"object"===typeof c&&(c=c.ptr);return B(qc(d,b,c),T)};m.prototype.GetFaceFromMesh=m.prototype.GetFaceFromMesh=function(b,c,d){var g=this.ptr;b&&"object"===typeof b&&(b=b.ptr);c&&"object"===typeof c&&(c=c.ptr);d&&"object"===typeof d&&(d=d.ptr);return!!rc(g,b,c,d)};m.prototype.GetTriangleStripsFromMesh=m.prototype.GetTriangleStripsFromMesh=function(b,c){var d=this.ptr;b&&"object"===typeof b&&(b=b.ptr);c&&"object"===typeof c&&(c=c.ptr);
return sc(d,b,c)};m.prototype.GetTrianglesUInt16Array=m.prototype.GetTrianglesUInt16Array=function(b,c,d){var g=this.ptr;b&&"object"===typeof b&&(b=b.ptr);c&&"object"===typeof c&&(c=c.ptr);d&&"object"===typeof d&&(d=d.ptr);return!!tc(g,b,c,d)};m.prototype.GetTrianglesUInt32Array=m.prototype.GetTrianglesUInt32Array=function(b,c,d){var g=this.ptr;b&&"object"===typeof b&&(b=b.ptr);c&&"object"===typeof c&&(c=c.ptr);d&&"object"===typeof d&&(d=d.ptr);return!!uc(g,b,c,d)};m.prototype.GetAttributeFloat=m.prototype.GetAttributeFloat=
function(b,c,d){var g=this.ptr;b&&"object"===typeof b&&(b=b.ptr);c&&"object"===typeof c&&(c=c.ptr);d&&"object"===typeof d&&(d=d.ptr);return!!vc(g,b,c,d)};m.prototype.GetAttributeFloatForAllPoints=m.prototype.GetAttributeFloatForAllPoints=function(b,c,d){var g=this.ptr;b&&"object"===typeof b&&(b=b.ptr);c&&"object"===typeof c&&(c=c.ptr);d&&"object"===typeof d&&(d=d.ptr);return!!wc(g,b,c,d)};m.prototype.GetAttributeIntForAllPoints=m.prototype.GetAttributeIntForAllPoints=function(b,c,d){var g=this.ptr;
b&&"object"===typeof b&&(b=b.ptr);c&&"object"===typeof c&&(c=c.ptr);d&&"object"===typeof d&&(d=d.ptr);return!!xc(g,b,c,d)};m.prototype.GetAttributeInt8ForAllPoints=m.prototype.GetAttributeInt8ForAllPoints=function(b,c,d){var g=this.ptr;b&&"object"===typeof b&&(b=b.ptr);c&&"object"===typeof c&&(c=c.ptr);d&&"object"===typeof d&&(d=d.ptr);return!!yc(g,b,c,d)};m.prototype.GetAttributeUInt8ForAllPoints=m.prototype.GetAttributeUInt8ForAllPoints=function(b,c,d){var g=this.ptr;b&&"object"===typeof b&&(b=
b.ptr);c&&"object"===typeof c&&(c=c.ptr);d&&"object"===typeof d&&(d=d.ptr);return!!zc(g,b,c,d)};m.prototype.GetAttributeInt16ForAllPoints=m.prototype.GetAttributeInt16ForAllPoints=function(b,c,d){var g=this.ptr;b&&"object"===typeof b&&(b=b.ptr);c&&"object"===typeof c&&(c=c.ptr);d&&"object"===typeof d&&(d=d.ptr);return!!Ac(g,b,c,d)};m.prototype.GetAttributeUInt16ForAllPoints=m.prototype.GetAttributeUInt16ForAllPoints=function(b,c,d){var g=this.ptr;b&&"object"===typeof b&&(b=b.ptr);c&&"object"===typeof c&&
(c=c.ptr);d&&"object"===typeof d&&(d=d.ptr);return!!Bc(g,b,c,d)};m.prototype.GetAttributeInt32ForAllPoints=m.prototype.GetAttributeInt32ForAllPoints=function(b,c,d){var g=this.ptr;b&&"object"===typeof b&&(b=b.ptr);c&&"object"===typeof c&&(c=c.ptr);d&&"object"===typeof d&&(d=d.ptr);return!!Cc(g,b,c,d)};m.prototype.GetAttributeUInt32ForAllPoints=m.prototype.GetAttributeUInt32ForAllPoints=function(b,c,d){var g=this.ptr;b&&"object"===typeof b&&(b=b.ptr);c&&"object"===typeof c&&(c=c.ptr);d&&"object"===
typeof d&&(d=d.ptr);return!!Dc(g,b,c,d)};m.prototype.GetAttributeDataArrayForAllPoints=m.prototype.GetAttributeDataArrayForAllPoints=function(b,c,d,g,t){var aa=this.ptr;b&&"object"===typeof b&&(b=b.ptr);c&&"object"===typeof c&&(c=c.ptr);d&&"object"===typeof d&&(d=d.ptr);g&&"object"===typeof g&&(g=g.ptr);t&&"object"===typeof t&&(t=t.ptr);return!!Ec(aa,b,c,d,g,t)};m.prototype.SkipAttributeTransform=m.prototype.SkipAttributeTransform=function(b){var c=this.ptr;b&&"object"===typeof b&&(b=b.ptr);Fc(c,
b)};m.prototype.GetEncodedGeometryType_Deprecated=m.prototype.GetEncodedGeometryType_Deprecated=function(b){var c=this.ptr;b&&"object"===typeof b&&(b=b.ptr);return Gc(c,b)};m.prototype.DecodeBufferToPointCloud=m.prototype.DecodeBufferToPointCloud=function(b,c){var d=this.ptr;b&&"object"===typeof b&&(b=b.ptr);c&&"object"===typeof c&&(c=c.ptr);return B(Hc(d,b,c),C)};m.prototype.DecodeBufferToMesh=m.prototype.DecodeBufferToMesh=function(b,c){var d=this.ptr;b&&"object"===typeof b&&(b=b.ptr);c&&"object"===
typeof c&&(c=c.ptr);return B(Ic(d,b,c),C)};m.prototype.__destroy__=m.prototype.__destroy__=function(){Jc(this.ptr)};(function(){function b(){a.ATTRIBUTE_INVALID_TRANSFORM=Kc();a.ATTRIBUTE_NO_TRANSFORM=Lc();a.ATTRIBUTE_QUANTIZATION_TRANSFORM=Mc();a.ATTRIBUTE_OCTAHEDRON_TRANSFORM=Nc();a.INVALID=Oc();a.POSITION=Pc();a.NORMAL=Qc();a.COLOR=Rc();a.TEX_COORD=Sc();a.GENERIC=Tc();a.INVALID_GEOMETRY_TYPE=Uc();a.POINT_CLOUD=Vc();a.TRIANGULAR_MESH=Wc();a.DT_INVALID=Xc();a.DT_INT8=Yc();a.DT_UINT8=Zc();a.DT_INT16=
$c();a.DT_UINT16=ad();a.DT_INT32=bd();a.DT_UINT32=cd();a.DT_INT64=dd();a.DT_UINT64=ed();a.DT_FLOAT32=fd();a.DT_FLOAT64=gd();a.DT_BOOL=hd();a.DT_TYPES_COUNT=id();a.OK=jd();a.DRACO_ERROR=kd();a.IO_ERROR=ld();a.INVALID_PARAMETER=md();a.UNSUPPORTED_VERSION=nd();a.UNKNOWN_VERSION=od()}va?b():oa.unshift(b)})();if("function"===typeof a.onModuleParsed)a.onModuleParsed();a.Decoder.prototype.GetEncodedGeometryType=function(b){if(b.__class__&&b.__class__===a.DecoderBuffer)return a.Decoder.prototype.GetEncodedGeometryType_Deprecated(b);
if(8>b.byteLength)return a.INVALID_GEOMETRY_TYPE;switch(b[7]){case 0:return a.POINT_CLOUD;case 1:return a.TRIANGULAR_MESH;default:return a.INVALID_GEOMETRY_TYPE}};return n.ready}}();"object"===typeof exports&&"object"===typeof module?module.exports=DracoDecoderModule:"function"===typeof define&&define.amd?define([],function(){return DracoDecoderModule}):"object"===typeof exports&&(exports.DracoDecoderModule=DracoDecoderModule);
+9
View File
@@ -0,0 +1,9 @@
export * as THREE from "three";
export { OrbitControls } from "three/examples/jsm/controls/OrbitControls.js";
export { RoomEnvironment } from "three/examples/jsm/environments/RoomEnvironment.js";
export { GLTFLoader } from "three/examples/jsm/loaders/GLTFLoader.js";
export { DRACOLoader } from "three/examples/jsm/loaders/DRACOLoader.js";
export { PLYLoader } from "three/examples/jsm/loaders/PLYLoader.js";
export { MeshoptDecoder } from "three/examples/jsm/libs/meshopt_decoder.module.js";
export { VRMLoaderPlugin, VRMUtils } from "@pixiv/three-vrm";
export const loadSpark = () => import("@sparkjsdev/spark");
File diff suppressed because one or more lines are too long
+123 -14
View File
@@ -12,6 +12,7 @@
<link rel="stylesheet" href="/wfm_static/css/lab-tab.css">
<link rel="stylesheet" href="/wfm_static/css/video-tab.css">
<link rel="stylesheet" href="/wfm_static/css/tagspace-tab.css">
<link rel="stylesheet" href="/wfm_static/css/game-tab.css">
</head>
<body>
<!-- Header -->
@@ -30,6 +31,8 @@
<button class="wfm-tab" data-tab="video">Video</button>
<button class="wfm-tab" data-tab="tagger">Tagger</button>
<button class="wfm-tab" data-tab="tagspace">TagSpace</button>
<!-- Game: ComfyUI-WFS-Games がインストールされているときだけ game-tab.js が表示する -->
<button class="wfm-tab" data-tab="game" hidden>Game</button>
<button class="wfm-tab" data-tab="settings">Settings</button>
<button class="wfm-tab" data-tab="help">Help</button>
<button class="wfm-tab" data-tab="ai">AI TOOL</button>
@@ -1359,6 +1362,7 @@
<button class="wfm-help-nav-item" data-help-page="tagspace">TagSpace Tab</button>
<button class="wfm-help-nav-item" data-help-page="imageedit">Image Edit Tab</button>
<button class="wfm-help-nav-item" data-help-page="video">Video Tab</button>
<button class="wfm-help-nav-item" data-help-page="game" hidden>Game Tab</button>
<button class="wfm-help-nav-item" data-help-page="shortcuts">Keyboard Shortcuts</button>
<button class="wfm-help-nav-item" data-help-page="trouble">Troubleshooting</button>
</div>
@@ -1435,11 +1439,12 @@
<li id="wfm-help-gen-4">Input tab: <b>Prompt</b> (left) and <b>Image</b> (right, about 3:2) are shown side by side on one screen (drag-and-drop upload); when the Prompt/Image area gets narrow (about 720px or less) Image wraps under Prompt, and the Raw JSON column can be collapsed to a slim strip at the right edge with its <b>»</b> button (Input tab only; remembered); the Prompt area has Positive Prompt, Negative Prompt, and an <b>Embeddings</b> selector at the bottom — select a model, set Weight (default 1.0), then click <b>Paste</b> to insert <code>(embedding:Name:weight)</code> at the cursor position of the last focused textarea (defaults to Positive if neither is focused); a <b>↺</b> button next to each Apply button reverts the textarea to the node's currently applied value; select text (or just place the cursor on a word/parenthesis block) and press <b>Ctrl+↑/↓</b> to adjust its emphasis weight in <code>(text:weight)</code> syntax by ±0.05 — the parentheses are removed automatically when the weight returns to 1.0</li>
<li id="wfm-help-gen-5">Model tab: Checkpoint, VAE, Diffusion Model (UNETLoader / UnetLoaderGGUF / LoaderGGUF), Text Encoder (CLIPLoader / DualCLIPLoader / ClipLoaderGGUF / DualClipLoaderGGUF — type and device selectors; DualCLIP shows two clip selectors) are always shown; ControlNet and Hypernetwork (with Strength field) are collapsed by default since they're used less often — click their header to expand; LoRA (Single/Stack tabs) has its own column to the right; all selectors have a filter; LoRA Stack — Apply writes all active LoRAs to the target node and simultaneously inserts LoRA syntax and CivitAI trigger words into the Positive prompt; re-applying updates the prompt by removing inactive LoRAs and re-adding active ones</li>
<li id="wfm-help-gen-28">Model tab — Highlight color: the label of each model type (Checkpoint, VAE, Diffusion Model, Text Encoder, ControlNet, Hypernetwork) and the LoRA column header turn a distinct color (default bright green) when the loaded workflow actually contains that type of node; this stays visible even while ControlNet/Hypernetwork are collapsed, so you can tell at a glance whether they're in use without expanding them; the color is customizable in the Settings tab</li>
<li id="wfm-help-gen-6">Settings tab: KSampler and Latent Image side by side, each at 50% width</li>
<li id="wfm-help-gen-6">Settings tab: KSampler, Latent Image and Switches side by side. Switches lists every true/false value in the workflow (e.g. the prompt enhancer on/off switch, TextGenerate thinking) and every two-choice enable/disable, on/off or yes/no option (e.g. KSamplerAdvanced add_noise, DWPreprocessor detect_hand) with its node name; clicking one toggles it immediately (no Apply needed) and the change shows up in Raw JSON</li>
<li id="wfm-help-gen-31">LTX-2.5 and Wan2.2 video workflows also work when loaded as regular workflows in this tab (not just the dedicated Video tab): Positive/Negative Prompt detection follows LTX-2.5's LTXVDualCFGGuider / LTXVConditioning nodes to find the actual prompt text, and the Settings tab's Latent Image section recognizes Wan2.2's EmptyHunyuanLatentVideo and LTX-2.5's EmptyLTXVLatentVideo nodes (with an added Length (frames) field) instead of showing "No EmptyLatentImage node found"; generating from these workflows also gets the same extended timeout as MiniMax H3 video generations</li>
<li id="wfm-help-gen-7">Raw JSON always visible in the right column of each tab — edit directly and Apply to reload the workflow; if the loaded workflow has Bypass or Mute nodes, a note listing them appears above the search bar (Bypass nodes are excluded with their wires reconnected around them; Mute nodes are excluded with no reconnection, matching ComfyUI itself); the search bar highlights matches and scrolls to them without moving the cursor into the editor, so typing right after a search can't accidentally overwrite the JSON — click into the editor first to actually edit</li>
<li id="wfm-help-gen-30">The <b>Save</b> button (right end of the subtab bar) is hidden while the <b>Batch</b> or <b>Lab</b> subtab is active, since those work on workflow copies / their own Plan files rather than the currently loaded workflow; it reappears on Input/Model/Settings/Feeder</li>
<li id="wfm-help-gen-32"><b>Partner API nodes</b> (Nano Banana / Gemini image nodes, etc.): GenerateUI can run workflows that contain ComfyUI's partner API nodes. These nodes need Comfy credentials in the /prompt request — ComfyUI's own screen adds them automatically, but a separate page cannot — so add <code>COMFY_API_KEY=...</code> (a Comfy API key issued at platform.comfy.org) to the plugin's .env file and restart ComfyUI. With the key set, GenerateUI sends the request through the plugin server, which adds the key only when the workflow contains a partner API node (the key never reaches the browser); usage is billed as Comfy credits. A Gemini image node's prompt appears in the Prompt tab, and its reference images go through LoadImage nodes in the Image tab. Sample: ws_nano_banana_2_1_t2i</li>
<li id="wfm-help-gen-33">🌐 prompt translation: when Settings → Prompt Translation is on, a 🌐 button sits next to the Positive/Negative prompts (Input tab), the Positive/Negative fields of the Lab prompt modal, and the Video Plan block prompt. It translates only the parts written in your own language into English and leaves prompt syntax as it is — commas, (word:1.2), [ ], {a|b}, &lt;lora:...&gt;, __wildcards__, embedding:name and BREAK; &quot;Original&quot; puts back the text from before translation (also Ctrl+Z) while that field stays open. Settings can also translate automatically when Generate, Lab Run or Video Plan Run is pressed</li>
</ul>
</div>
<div class="wfm-help-card">
@@ -1558,6 +1563,7 @@
<li id="wfm-help-lab-plan-2">Run / Pause / Cancel: Run starts the batch loop; Pause/Resume freezes it between iterations; Cancel interrupts the current generation and stops the loop</li>
<li id="wfm-help-lab-plan-3">Plan Save vs Save As: Plan Save silently overwrites the currently loaded plan (or asks for a name the first time); Save As always asks for a new name, even while a plan is already loaded</li>
<li id="wfm-help-lab-plan-4">Plan Load: drop a plan's .json file, or any of its index-image PNGs, onto the PLAN box (or click it to browse) — a dropped .json is read directly; a dropped .png is read directly too if it carries embedded plan data (every index image since v0.3.90 does, in a <code>wfm_lab_plan</code> chunk — see below), falling back to fetching a same-named .json from the server for older index images that predate this</li>
<li id="wfm-help-lab-plan-12">From a story: AI TOOL &gt; Chat's "Storyboard to Lab" skill writes one prompt per scene; its "Open in Lab" button loads that plan here as an unsaved plan (T2I mode, Batch = number of scenes, one Prompt keyframe per scene, the plan's fixed seed in KSampler keyframe #1 - shown as "Seed …" in the cell). Check it, press Run, and use Plan Save to keep it</li>
<li id="wfm-help-lab-plan-5">Plan Clear resets the Setting tab to an empty plan (asks for confirmation first)</li>
<li id="wfm-help-lab-plan-6">Plan files are stored in <code>user/default/Workflow-Studio/lab_plan/</code> as <code>ws_labplan_&lt;name&gt;.json</code> plus a <code>ws_labplan_&lt;name&gt;.png</code> index image — a contact sheet of up to 9 result thumbnails (3 per row) generated automatically whenever a plan with results is saved. The <code>ws_labplan_</code> prefix is added automatically by Plan Save/Save As (type just the plain name when prompted) so plan files are easy to pick out among other files in that folder</li>
<li id="wfm-help-lab-plan-7">Eagle auto-save (configured in the Settings tab) applies to every image Lab generates, the same as GenerateUI's own Generate button</li>
@@ -1693,6 +1699,7 @@
<li id="wfm-help-settings-22">G'MIC-Qt Integration: path to the G'MIC-Qt executable (gmic_qt.exe) used by the Image Edit tab's G'MIC filter (Edit with G'MIC); Save stores it — see the Image Edit help for installing G'MIC-Qt</li>
<li id="wfm-help-settings-17">Decision Model: its own section, independent of the AI TOOL / Tagger LLM/VLM backends so it can be used alongside them — backend, URL, model and a default probability threshold (answers below it are treated as suggestions to confirm). Unsloth: Laya models (laya / laya-multilingual / laya-english / laya-typed-decisions); requires Settings → API → Decision API → Serve requests in Unsloth Desktop (otherwise HTTP 404 "The Decision API is off") and either UNSLOTH_API_KEY in .env or Keyless API access → "Chat and inference". Ollama (0.35+): lists installed models whose capabilities include "decision" (tev1, tev1:0.8b, nimble — ollama pull first; ↻ refreshes the list); no key needed. Test sends one yes/no question with the unsaved form values; the first request loads the model.</li>
<li id="wfm-help-settings-25">VRAM Management (Ollama): right before every image generation from Workflow Studio, unload the models Ollama has loaded to free VRAM (off / only as much as needed to reach a target free VRAM / everything every time); free VRAM is measured with nvidia-smi; &quot;Unload all now&quot; unloads them immediately; the same "Unload all now" is also in the sidepanel A tab → Settings → VRAM (Ollama). Running a workflow from the ComfyUI canvas itself is not covered</li>
<li id="wfm-help-settings-26">Prompt Translation (native language → English): off by default. Translates prompts with a local Ollama model — PLaMo 3 Translate (0.8B / 2B / 8B / 31B; models not yet in Ollama can be fetched with the Download button) or any other Ollama model through a translation instruction. Options: source language (auto-detect or one of the 51 languages PLaMo supports), Ollama URL, where to run the model — GPU (about 0.1 s per phrase; with &quot;Unload after translating&quot; on, each translation first waits about 4 s for the model to reload) or CPU kept loaded (about 0.3 s per phrase, no VRAM, loaded in the background when a workflow is loaded into GenerateUI) — and &quot;Translate automatically when running&quot; for GenerateUI Generate (replaces the prompt text with the translation), Lab Run and Video Plan Run (translate only what is sent; the plan keeps your text). If translation fails, nothing is generated. Test translates a sample prompt. 2B translates sentences more accurately than 0.8B. PLaMo 3 Translate is free for personal and non-commercial use (PLaMo Community License). PLaMo models also work for the AI TOOL / Prompt tab AI Assistant / sidepanel A tab translation buttons (the languages are passed in the format PLaMo expects)</li>
</ul>
</div>
<div class="wfm-help-card">
@@ -1718,9 +1725,9 @@
<div class="wfm-help-card">
<h3 id="wfm-help-settings-card-misc-title">Data &amp; Misc</h3>
<ul>
<li id="wfm-help-settings-8">Data Management: export core settings, metadata, and prompts to a JSON file, or import to restore. After importing, restart ComfyUI.</li>
<li id="wfm-help-settings-15">Full Backup (ZIP): unlike the JSON export above, also includes folder-based data (AI Skills, Lab Plans, Video Plans, Video Edit projects, Style presets) and the Tagger database — everything the JSON export can't represent. Restoring overwrites existing files; restart ComfyUI afterward.</li>
<li id="wfm-help-settings-16">Two opt-in checkboxes above the Full Backup buttons additionally include ComfyUI's default workflows folder and the Impact Pack's wildcard folder in the export — both export-only, never restored automatically; copy the ZIP's _external/ folder back by hand if you want them. A third checkbox includes the clips, BGM, sounds and overlay clips referenced by saved Video Edit projects (projects only store references to files in ComfyUI's input folder) — unlike the other two, these are restored into the input folder, skipping any file that already exists there.</li>
<li id="wfm-help-settings-8">Data Management: export core settings, metadata, and prompts to a JSON file, or import to restore. The browser-side settings (workflow and preset groups, badge colors, appearance, AI / decision model / VRAM settings, presets) are included too and restored on import — reload the page afterward. Restart ComfyUI after importing.</li>
<li id="wfm-help-settings-15">Full Backup (ZIP): unlike the JSON export above, also includes folder-based data (AI Skills, Lab Plans, Video Plans, Video Edit projects, Style presets), the Tagger database, the Gallery semantic search settings, and the browser-side settings. Temporary files and the unused models/ folder of older versions are left out. Restoring overwrites existing files and writes the browser-side settings back (reload the page); restart ComfyUI afterward.</li>
<li id="wfm-help-settings-16">Checkboxes above the Full Backup buttons: ComfyUI's default workflows folder and the Impact Pack's wildcard folder (export-only, never restored automatically; copy the ZIP's _external/ folder back by hand if you want them); the clips, BGM, sounds and overlay clips referenced by saved Video Edit projects (projects only store references to files in ComfyUI's input folder — restored into the input folder, skipping files that already exist); the Gallery semantic search index (on by default: rebuilding it re-embeds every image, which costs API usage with Gemini); and the TagSpace cache (off by default: it can be rebuilt from the TagSpace tab).</li>
<li id="wfm-help-settings-13">CivitAI Host: choose between civitai.com (SFW only) and civitai.red (unrestricted) — determines which site opens when clicking a model link in the Models tab CivitAI panel</li>
<li id="wfm-help-settings-21">CivitAI API Key: optional key for authenticated CivitAI access from the Models tab (get it at civitai.com → Account Settings → API Keys); stored in settings.json but left out of the JSON export and Full Backup, and the CIVITAI_API_KEY environment variable takes priority when set</li>
<li id="wfm-help-settings-24">Windows Stability: "Use the Selector event loop on Windows" switches ComfyUI's asyncio loop from Proactor to Selector (applied at the next ComfyUI start). Turn it on if ComfyUI freezes entirely after switching Models lists that load many preview images; the trade-offs are no asyncio subprocess support and a connection limit of about 512. The same switch is available through the WFS_SELECTOR_LOOP=1 environment variable</li>
@@ -1832,6 +1839,7 @@
<li id="wfm-help-gallery-10">Workflow auto-save: images generated in the Generate UI tab automatically have their workflow saved to gallery metadata and shown in the JSON tab</li>
<li id="wfm-help-gallery-11">Supports PNG (tEXt/iTXt), JPEG, WebP, GIF, MP4, WebM, PSD, and audio (WAV, MP3, OGG, M4A, FLAC, Opus — waveform thumbnail, built-in player, prompt/workflow tags written by ComfyUI's SaveAudio nodes); workflow extraction reads ComfyUI prompt/workflow keys embedded in PNG metadata (including chunks appended after IEND by ComfyUI-Custom-Scripts), WebP EXIF, or MP4/WebM container tags (as written by SaveVideo, e.g. MiniMax H3 output); the Prompt tab also reads A1111 / Forge / Fooocus <code>parameters</code> text when no workflow is embedded. Audio waveform thumbnails are colored by format (MP3 blue, WAV green, FLAC amber, OGG/Opus purple, M4A rose) so formats can be told apart at a glance; the detail panel shows the waveform with the player below it.</li>
<li id="wfm-help-gallery-30">PSD files: thumbnails and full-size previews show all layers merged together (hidden layers excluded); the underlying PSD file itself is left untouched — only the preview shown in Gallery is a flattened rendering</li>
<li id="wfm-help-gallery-38">3D models: GLB, glTF, VRM, PLY (mesh, point cloud or Gaussian splat) and SPZ are listed with a "3D" badge and open in a built-in viewer (drag to rotate, right-drag to pan, wheel to zoom, ⟲ to reset; double-click to enlarge). Thumbnails are rendered by your browser the first time a file appears and are then kept on the server; files over 128 MB get one when opened. The workflow saved by ComfyUI's SaveGLB is read like an image's. A .gltf that uses separate .bin or texture files needs them to stay in place: Move and Delete only affect the .gltf itself. 3D files cannot be sent to Image Edit, GenerateUI, Tagger or Feeder.</li>
</ul>
</div>
</div>
@@ -1935,11 +1943,11 @@
</div>
<div class="wfm-help-card">
<h3 id="wfm-help-ai-card-layout-title">Layout</h3>
<p id="wfm-help-ai-1">4-pane layout — Translation | Chat | TOOLS | Settings — all panes are always visible simultaneously</p>
<p id="wfm-help-ai-1">4-pane layout — Translation | Chat | TOOLS | Settings; the Translation and Settings panes can be collapsed to a thin strip with the arrow (◀ / ▶) in their header, giving Chat and TOOLS more room — click the strip anywhere to open the pane again; the collapsed state is remembered</p>
</div>
<div class="wfm-help-card">
<h3 id="wfm-help-ai-card-translate-title">Translation pane</h3>
<p id="wfm-help-ai-2">Translation pane: translate text between Japanese, English, Chinese, or a custom Free language using Ollama, LM Studio, Lemonade, or Unsloth; ⇄ swap button swaps both language selectors and text content; selections are saved automatically</p>
<p id="wfm-help-ai-2">Translation pane: translate between Japanese, English, Chinese, or Free language using Ollama, LM Studio, Lemonade, or Unsloth; ⇄ swap button swaps both language selectors and text content; selections are saved automatically; text extracted in the TOOLS pane (e.g. by OCR) can be sent here with its "To Translation" button, which also opens this pane if it is collapsed</p>
</div>
<div class="wfm-help-card">
<h3 id="wfm-help-ai-card-chat-title">Chat pane</h3>
@@ -1951,19 +1959,35 @@
</div>
<div class="wfm-help-card">
<h3 id="wfm-help-ai-card-skills-title">Chat pane — Skills</h3>
<p id="wfm-help-ai-8">Chat pane — Skills: pick a skill from the dropdown above the message list to prepend its instructions to the conversation as a system prompt (not shown in the visible chat log); use the pencil button to open the skill manager and create, edit, or delete .md skill files, stored in user/default/Workflow-Studio/ai_skills/; a file's first line block between --- markers can define name/description shown in the dropdown; two starter skills are included by default: "SVG Icon Generator" (decomposes the subject into parts before drawing, for more recognizable SVG output) and "Skill Creator" (interviews you conversationally and drafts a new skill file, ready to save); when a reply contains a ```skill code block, a "Save as new skill" button appears below it that opens the manager with the draft pre-filled</p>
<p id="wfm-help-ai-8">Chat pane — Skills: pick a skill from the dropdown above the message list to prepend its instructions to the conversation as a system prompt (not shown in the visible chat log); use the pencil button to open the skill manager and create, edit, delete or import skills, stored in user/default/Workflow-Studio/ai_skills/; a file's first block between --- markers defines the name/description shown in the dropdown; six built-in skills are included (marked "built-in" in the manager): "T2I Prompt Enhancer" (rewrites a short idea into a prompt written for the model in your current GenerateUI workflow - natural sentences for Qwen-Image/FLUX/Z-Image, Danbooru tags for Illustrious/Pony), "Image to Prompt" (writes a prompt that recreates an image attached in the TOOLS pane; needs a vision chat model), "Storyboard to Lab" and "Workflow Doctor" (see their card below), "SVG Icon Generator" (decomposes the subject into parts before drawing; line/flat/duotone/mono styles) and "Skill Creator" (interviews you and drafts a new skill, or revises an existing one); built-in skills you have not edited are updated automatically when Workflow Studio is updated, and an edited one shows a ↻ button to replace it with the latest version; when a reply contains a ```skill code block, a "Save as new skill" button opens the manager with the draft pre-filled</p>
</div>
<div class="wfm-help-card">
<h3 id="wfm-help-ai-card-skilltips-title">Writing your own skills</h3>
<p id="wfm-help-ai-9">Tips for writing your own skills: give a clear frontmatter name/description so it reads well in the dropdown and tooltip; state the exact output format you want and, if there is a deliverable to extract later (like SVG or another skill file), wrap it in a distinctive fenced code block; write concrete, imperative instructions rather than vague ones - smaller local models follow explicit rules and a short worked example far better than general guidance; state hard constraints (forbidden content, security, length limits) explicitly rather than assuming they are implied; when in doubt, select the "Skill Creator" skill in the dropdown and describe what you want - it will interview you and draft the file for you</p>
</div>
<div class="wfm-help-card">
<h3 id="wfm-help-ai-card-skilloptions-title">Chat pane — Skill options &amp; action buttons</h3>
<p id="wfm-help-ai-10">under metadata: in a skill's frontmatter you can set output (prompt or svg - the reply is checked automatically, and if the model tried to output one but it is broken - an unclosed or invalid SVG, forbidden elements, prompt lines outside a ```prompt block - the model is asked once to fix it, shown as a dashed notice; replies with no attempt at all, e.g. when you only asked for an explanation, are left alone), tools ([] to never let the model start image generation by itself, [generate_image] to allow it when the image-generation toggle is on), temperature, think (force thinking mode on/off) and context ([workflow] sends a summary of the workflow loaded in GenerateUI - model files, prompt nodes, CFG, resolution - with every message; the prompt text currently in the workflow is added only when your message refers to it, e.g. "improve the current prompt", because small models otherwise copy it into new prompts; [current-prompt] always adds it); any reply containing a ```prompt block (positive:/negative: lines) gets "Apply to GenerateUI", "Generate with this prompt" and "Copy" buttons</p>
</div>
<div class="wfm-help-card">
<h3 id="wfm-help-ai-card-skillsmore-title">Chat pane — Workflow Doctor, Storyboard &amp; skill folders</h3>
<p id="wfm-help-ai-12">"Workflow Doctor" explains the workflow loaded in GenerateUI and diagnoses errors from facts Workflow Studio checks on every message - node types that are not installed, model files or options that are not in ComfyUI's lists (with the closest existing names), broken links, unconnected required inputs, the last execution error and the latest error block of the ComfyUI log - so answers rely on your install rather than on the model's possibly outdated knowledge; "Storyboard to Lab" turns a story into one prompt per scene with identical character descriptions and a fixed seed, and its "Open in Lab" button loads the plan into GenerateUI &gt; Lab (T2I mode) where you check it and press Run; "Import" in the skill manager adds an Agent Skills folder (.zip containing SKILL.md, the format shared by many AI tools) or a single .md - only text files are kept and scripts are never run; a folder skill's reference files are listed to the model, which reads one with the read_skill_file tool only when needed (needs a tool-capable chat model); assistant replies are shown with basic Markdown formatting (lists, headings, code blocks)</p>
</div>
<div class="wfm-help-card">
<h3 id="wfm-help-ai-card-imagecheck-title">Chat pane — Image check</h3>
<p id="wfm-help-ai-11">Image check ("Check images" toggle below the chat input): after an image is generated from the chat - by the model's generate_image tool or the "Generate with this prompt" button - the chat model turns your request into 3-7 yes/no requirements, and a vision decision model in Ollama (d3:4b recommended; set it under Settings &gt; Chat Image Check) judges the image and shows each one as ✔ met / ? unclear / ✘ not met with its probability, plus an overall quality rating; "Fix missing items and regenerate" sends only the unmet items back to the chat model, which rewrites the prompt and generates again, and "Automatic fix rounds" (0-3) repeats this without clicking; with the SVG Icon Generator skill the SVG is rendered and checked part by part (from its "Parts:" line) the same way; decision models return calibrated probabilities instead of the chat model's own yes/no, which tends to claim things that are not in the image; the fourth built-in skill "Image to Prompt" writes a prompt that recreates an image attached in the TOOLS pane (needs a vision chat model)</p>
</div>
<div class="wfm-help-card">
<h3 id="wfm-help-ai-card-tools-title">TOOLS pane</h3>
<p id="wfm-help-ai-4">TOOLS pane — VLM: drop an image (PNG/JPG/WebP) and select a task (Describe Image, Create Prompt, Create Tags), click Run; or select "Create wildcards", enter a category name and count to generate plain-text entries one per line; the dropped image is also shared with the Chat pane as its attachment (shown there and used for image-to-image generation) until cleared with the ✕ button</p>
<p id="wfm-help-ai-4">TOOLS pane — VLM: drop an image (PNG/JPG/WebP) and select a task (Describe Image, Create Prompt, Create Tags, OCR), click Run; or select "Create wildcards", enter a category name and count to generate plain-text entries one per line; the dropped image is also shared with the Chat pane as its attachment (shown there and used for image-to-image generation) until cleared with the ✕ button; below the result, "To Translation" and "To Chat" pass the result to those panes and "Copy" copies it</p>
</div>
<div class="wfm-help-card">
<h3 id="wfm-help-ai-card-ocr-title">TOOLS pane — OCR</h3>
<p id="wfm-help-ai-13">Choose "OCR (extract text)" in the TOOLS pane, drop an image and press Run to read its text with an OCR model installed in Ollama (the list shows models whose name contains "ocr", best first; LightOnOCR-3 is the default - on a mixed Japanese/English test page with a vertical column it read everything in about 1 s; PaddleOCR-VL-manga and DeepSeek-OCR also read it fully, while PaddleOCR-VL 1.6 and GLM-OCR missed the vertical text); the image is sent as a white-background JPEG with its long side at most 1600 px, and an empty or looping result is retried once in grayscale; "Show text positions" (LightOnOCR / DeepSeek-OCR only - the checkbox is disabled for other models) enlarges the preview and draws numbered boxes over the image; click a box to select its line in the result; the OCR model is separate from the chat model chosen in Settings</p>
</div>
<div class="wfm-help-card">
<h3 id="wfm-help-ai-card-settings-title">Settings pane</h3>
<p id="wfm-help-ai-6">Settings pane: choose backend (Ollama / LM Studio / Lemonade / Unsloth), set API URL, test connection, select model, and use the Unload Model button (next to Test connection) to free the loaded model from VRAM/memory &mdash; Ollama unloads every loaded Ollama model, decision models included (the same step as Settings &rarr; VRAM Management's &quot;Unload all now&quot;; the Prompt/Tagger settings button does the same), LM Studio uses /api/v1/models/unload, Lemonade uses /api/v1/unload; Unsloth has no unload API, so this shows an unsupported message for it; Unsloth needs either an API key or Keyless API access — set UNSLOTH_API_KEY in a .env file in the plugin folder (copy .env.example) and restart ComfyUI (the key is read server-side and never sent to the browser), or leave it unset and turn on Keyless API access → "Chat and inference" in Unsloth Desktop's Settings → API (requests are then sent without a key; note that setting also opens the API to your private LAN, and keep "Allow tools" off); Unsloth also requires "Auto model switching (OpenAI API)" to be turned ON in the Unsloth Desktop app itself (its own Settings screen) — without it, requests fail with HTTP 404 unless a model was already manually loaded in the Unsloth Studio UI; Unsloth reasoning models return their thinking in a separate reasoning_content field rather than inline &lt;think&gt; tags, so a low Max tokens can make the model spend its whole budget reasoning and return an empty reply — increase Max tokens (2048+) if replies come back blank; Generation section — Thinking mode toggle (off by default; Ollama receives a `think` flag, and regardless of backend any &lt;think&gt;...&lt;/think&gt; block is stripped from the output when off, so reasoning models don't clutter Translation/Chat/TOOLS results) and Max tokens (Ollama: num_predict, LM Studio/Lemonade/Unsloth: max_tokens; 0 = unlimited); configure Free language names; Chat Image Generation section lets you enable a dedicated workflow for Chat-triggered text-to-image generation instead of the one currently loaded in GenerateUI; Chat I2I Generation section is the same but for image-to-image generation when an image is attached; settings are shared with the Library panel's A tab via localStorage</p>
<p id="wfm-help-ai-6">Settings pane: choose backend (Ollama / LM Studio / Lemonade / Unsloth), set API URL, test connection, select model, and use the Unload Model button (next to Test connection) to free the loaded model from VRAM/memory — Ollama unloads every loaded Ollama model, decision models included (the same step as Settings → VRAM Management's "Unload all now"; the Prompt/Tagger settings button does the same), LM Studio uses /api/v1/models/unload, Lemonade uses /api/v1/unload; Unsloth has no unload API, so this shows an unsupported message for it; Unsloth needs either an API key or Keyless API access — set UNSLOTH_API_KEY in a .env file in the plugin folder (copy .env.example) and restart ComfyUI (the key is read server-side and never sent to the browser), or leave it unset and turn on Keyless API access → "Chat and inference" in Unsloth Desktop's Settings → API (requests are then sent without a key; note that setting also opens the API to your private LAN, and keep "Allow tools" off); Unsloth also requires "Auto model switching (OpenAI API)" to be turned ON in the Unsloth Desktop app itself (its own Settings screen) — without it, requests fail with HTTP 404 unless a model was already manually loaded in the Unsloth Studio UI; Unsloth reasoning models return their thinking in a separate reasoning_content field rather than inline &lt;think&gt; tags, so a low Max tokens can make the model spend its whole budget reasoning and return an empty reply — increase Max tokens (2048+) if replies come back blank; Generation section — Thinking mode toggle (off by default; Ollama receives a think flag, and regardless of backend any &lt;think&gt;...&lt;/think&gt; block is stripped from the output when off, so reasoning models don't clutter Translation/Chat/TOOLS results) and Max tokens (Ollama: num_predict, LM Studio/Lemonade/Unsloth: max_tokens; 0 = unlimited); configure Free language names; Chat Image Generation section lets you enable a dedicated workflow for Chat-triggered text-to-image generation instead of the one currently loaded in GenerateUI; Chat I2I Generation section is the same but for image-to-image generation when an image is attached; settings are shared with the Library panel's A tab via localStorage; Chat Image Check section picks the judge model used by the chat's "Check images" toggle (an Ollama decision model with image input, e.g. d3:4b) and how many automatic fix rounds to run (0 = fix only when you press the button)</p>
</div>
</div>
@@ -2030,6 +2054,31 @@
</div>
</div>
<div class="wfm-help-page" id="wfm-help-page-game">
<div class="wfm-help-article-header">
<h2 id="wfm-help-game-title">Game Tab (experimental)</h2>
<button type="button" class="wfm-btn wfm-btn-sm wfm-help-jump-btn" data-jump-tab="game">Open tab &rarr;</button>
</div>
<div class="wfm-help-card">
<h3 id="wfm-help-game-card-overview-title">Overview</h3>
<ul>
<li id="wfm-help-game-1"></li>
<li id="wfm-help-game-2"></li>
<li id="wfm-help-game-3"></li>
<li id="wfm-help-game-4"></li>
<li id="wfm-help-game-5"></li>
</ul>
</div>
<div class="wfm-help-card">
<h3 id="wfm-help-game-card-gen-title">Image Generation</h3>
<ul>
<li id="wfm-help-game-6"></li>
<li id="wfm-help-game-7"></li>
<li id="wfm-help-game-8"></li>
</ul>
</div>
</div>
<div class="wfm-help-page" id="wfm-help-page-imageedit">
<div class="wfm-help-article-header">
<h2 id="wfm-help-imageedit-title">Image Edit Tab</h2>
@@ -2050,6 +2099,7 @@
<ul>
<li id="wfm-help-imageedit-4">Select (V): click to select a layer; drag to move; drag corner handles to resize; drag the circle above the top edge to rotate; double-click a text layer to re-edit its content; Tool Options bar shows Flip H / Flip V / Rotate field</li>
<li id="wfm-help-imageedit-5">Draw (B): freehand brush drawing onto the active draw layer; Tool Options: color, brush size, blend mode; Properties pane includes a MASK EDITOR ONE (COLOR) section for ABR image brushes — always visible, header text is green when brushes are available, gray when none are imported yet; Select is disabled until at least one brush exists</li>
<li id="wfm-help-imageedit-draw-palette">Draw color palette (second row): Color 1/Color 2, 20 basic colors, and 20 custom slots. Click a color to paint with it. Use + or click an empty slot to register the current color; right-click a color to register, edit, or delete it (basic colors can be changed and restored). Registered colors are saved per browser. The eyedropper button next to Color picks a color from the canvas (Esc cancels)</li>
<li id="wfm-help-imageedit-6">Text (T): click on the canvas to place a text input overlay; configure font family, size, bold/italic, align, color in the Tool Options bar; click OK to place the text as an exact-size Text layer; double-click an existing text layer with the Select tool to re-edit</li>
<li id="wfm-help-imageedit-7">Shape (S): draw geometric shapes onto the canvas; each committed shape becomes an independent draw layer; Tool Options: Shape type (Rect / Ellipse / Line / FreeLine), Rounded checkbox (Rect / Ellipse only), Fill color + None toggle (hidden for Line / FreeLine), Stroke color + width + None toggle (None hidden for Line / FreeLine where stroke is always active), Opacity slider, ↩ Undo button; drag to draw — a blue dashed outline previews the shape; release to commit</li>
<li id="wfm-help-imageedit-7a2">Fill (G): bucket fill — click a contiguous same-color region on the active layer to flood-fill it with a solid color or a linear/radial gradient; Tool Options: Mode (Solid / Gradient), Color (solid) or Shape + Ramp (drag stops to reposition, click a stop then use the color swatch, +/- to add/remove) + Direction dial (drag to set angle/radius, gradient), Tolerance (color-match threshold), Opacity</li>
@@ -2156,6 +2206,7 @@
<li id="wfm-help-imageedit-24">T: Text tool</li>
<li id="wfm-help-imageedit-25">S: Shape tool</li>
<li id="wfm-help-imageedit-25b">G: Fill tool</li>
<li id="wfm-help-imageedit-draw-kbd">While Draw is active: D Draw / E Erase / X switch Color 1/2 / [ ] brush size / B open or close the brush picker (Esc also closes it)</li>
<li id="wfm-help-imageedit-26">Delete: Delete selected layer (requires 2+ layers)</li>
<li id="wfm-help-imageedit-27">Ctrl+Z / Ctrl+Y: Undo / Redo</li>
<li id="wfm-help-imageedit-28">Space + drag: Pan canvas</li>
@@ -2208,6 +2259,7 @@
<li id="wfm-help-imageedit-tabkbd-3">T: Text tool</li>
<li id="wfm-help-imageedit-tabkbd-4">S: Shape tool</li>
<li id="wfm-help-imageedit-tabkbd-4b">G: Fill tool</li>
<li id="wfm-help-imageedit-tabkbd-draw">While Draw is active: D Draw / E Erase / X switch Color 1/2 / [ ] brush size / B open or close the brush picker (Esc also closes it)</li>
<li id="wfm-help-imageedit-tabkbd-5">Delete: Delete selected layer (requires 2+ layers)</li>
<li id="wfm-help-imageedit-tabkbd-6">Ctrl+Z / Ctrl+Y: Undo / Redo</li>
<li id="wfm-help-imageedit-tabkbd-7">Space + drag: Pan canvas</li>
@@ -3428,11 +3480,17 @@
<!-- TagSpace Tab (内容は tagspace-tab.js が生成) -->
<section id="wfm-tab-tagspace" class="wfm-tab-content"></section>
<!-- Game Tab (内容は game-tab.js が生成。ゲームパック未インストール時は使われない) -->
<section id="wfm-tab-game" class="wfm-tab-content"></section>
<!-- AI Tab -->
<section id="wfm-tab-ai" class="wfm-tab-content">
<!-- Translation pane -->
<div class="wfm-ai-pane wfm-ai-pane-translate">
<div class="wfm-ai-pane-header">Translation</div>
<div class="wfm-ai-pane wfm-ai-pane-translate" data-collapse-pane="translate">
<div class="wfm-ai-pane-header">
<span class="wfm-ai-pane-title">Translation</span>
<button type="button" class="wfm-ai-pane-collapse-btn" data-collapse-btn="translate" data-dir="left" title="Collapse">&#9664;</button>
</div>
<div class="wfm-ai-trans-container">
<div class="wfm-ai-trans-lang-row">
<select id="wfm-ai-src-lang" class="wfm-select wfm-ai-lang-select">
@@ -3472,6 +3530,10 @@
<div class="wfm-ai-skill-panel-header">
<span class="wfm-ai-skill-panel-title">Skills</span>
<div style="display:flex;gap:4px;">
<label id="wfm-ai-skill-import-label" class="wfm-btn wfm-btn-sm" title="Import an Agent Skills folder (.zip with SKILL.md) or a .md skill">
<span id="wfm-ai-skill-import-text">Import</span>
<input type="file" id="wfm-ai-skill-import-input" accept=".zip,.md" style="display:none;">
</label>
<button id="wfm-ai-skill-new-btn" class="wfm-btn wfm-btn-sm wfm-btn-primary">+ New</button>
<button id="wfm-ai-skill-close-btn" class="wfm-btn wfm-btn-sm" title="Close">&#10005;</button>
</div>
@@ -3504,6 +3566,10 @@
<input type="checkbox" id="wfm-ai-chat-imggen-toggle" checked>
<span id="wfm-ai-chat-imggen-label-text">Allow image generation</span>
</label>
<label class="wfm-ai-chat-toggle-label" for="wfm-ai-chat-check-toggle" id="wfm-ai-chat-check-label" title="Check generated images and SVGs with a vision decision model">
<input type="checkbox" id="wfm-ai-chat-check-toggle">
<span id="wfm-ai-chat-check-label-text">Check images</span>
</label>
</div>
</div>
</div>
@@ -3517,6 +3583,7 @@
<img id="wfm-ai-vlm-preview" style="display:none;max-width:100%;max-height:100%;object-fit:contain;pointer-events:none;">
<span id="wfm-ai-vlm-label" class="wfm-ai-vlm-label">Drop or click PNG / JPG / WebP</span>
<input type="file" id="wfm-ai-vlm-file" accept="image/png,image/jpeg,image/webp" style="display:none;">
<div id="wfm-ai-ocr-overlay" class="wfm-ai-ocr-overlay" style="display:none;"></div>
<button id="wfm-ai-vlm-clear" class="wfm-ai-vlm-clear" style="display:none;" title="Close">✕</button>
</div>
<div class="wfm-ai-wc-inputs" id="wfm-ai-wc-inputs" style="display:none">
@@ -3535,18 +3602,38 @@
<option value="prompt">Create prompt</option>
<option value="tags">Create tags</option>
<option value="wildcard">Create wildcards</option>
<option value="ocr">OCR (extract text)</option>
</select>
<button id="wfm-ai-vlm-run" class="wfm-btn wfm-btn-primary">Run</button>
</div>
<div id="wfm-ai-ocr-options" class="wfm-ai-ocr-options" style="display:none;">
<div class="wfm-ai-ocr-row">
<label class="wfm-ai-label" id="wfm-ai-ocr-model-label">OCR model</label>
<select id="wfm-ai-ocr-model" class="wfm-select"></select>
<button type="button" id="wfm-ai-ocr-refresh" class="wfm-btn wfm-btn-sm">&#8635;</button>
</div>
<label class="wfm-ai-ocr-check" id="wfm-ai-ocr-boxes-wrap">
<input type="checkbox" id="wfm-ai-ocr-boxes">
<span id="wfm-ai-ocr-boxes-label">Show text positions</span>
</label>
<div id="wfm-ai-ocr-hint" class="wfm-ai-ocr-hint"></div>
</div>
<span id="wfm-ai-vlm-status" class="wfm-ai-trans-status"></span>
<textarea id="wfm-ai-vlm-result" class="wfm-ai-vlm-result" placeholder="Result..." readonly></textarea>
<button id="wfm-ai-vlm-copy" class="wfm-btn wfm-ai-vlm-copy-btn">Copy</button>
<div class="wfm-ai-vlm-result-actions">
<button id="wfm-ai-vlm-to-trans" class="wfm-btn wfm-btn-sm">To Translation</button>
<button id="wfm-ai-vlm-to-chat" class="wfm-btn wfm-btn-sm">To Chat</button>
<button id="wfm-ai-vlm-copy" class="wfm-btn wfm-ai-vlm-copy-btn">Copy</button>
</div>
</div>
</div>
<div class="wfm-ai-pane-divider"></div>
<!-- Settings pane -->
<div class="wfm-ai-pane wfm-ai-pane-settings">
<div class="wfm-ai-pane-header">Settings</div>
<div class="wfm-ai-pane wfm-ai-pane-settings" data-collapse-pane="settings">
<div class="wfm-ai-pane-header">
<span class="wfm-ai-pane-title">Settings</span>
<button type="button" class="wfm-ai-pane-collapse-btn" data-collapse-btn="settings" data-dir="right" title="Collapse">&#9654;</button>
</div>
<div class="wfm-ai-settings-container">
<div class="wfm-ai-settings-section">
<div class="wfm-ai-settings-title" id="wfm-ai-settings-backend-title">Backend</div>
@@ -3638,6 +3725,28 @@
</select>
</div>
</div>
<div class="wfm-ai-settings-section">
<div class="wfm-ai-settings-title" id="wfm-ai-settings-check-title">Chat Image Check</div>
<div class="wfm-ai-settings-row">
<label class="wfm-ai-label" id="wfm-ai-judge-model-label">Judge model</label>
</div>
<div class="wfm-ai-settings-row" style="display:flex;gap:6px;">
<select id="wfm-ai-judge-model-select" class="wfm-select" style="flex:1;min-width:0;">
<option value="d3:4b">d3:4b</option>
</select>
<button id="wfm-ai-judge-refresh-btn" class="wfm-btn wfm-btn-sm">Refresh</button>
</div>
<div class="wfm-ai-settings-row" id="wfm-ai-judge-hint" style="font-size:11px;opacity:0.75;"></div>
<div class="wfm-ai-settings-row">
<label class="wfm-ai-label" id="wfm-ai-check-rounds-label">Automatic fix rounds</label>
<select id="wfm-ai-check-rounds-select" class="wfm-select">
<option value="0">0</option>
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
</select>
</div>
</div>
<div class="wfm-ai-settings-section">
<button id="wfm-ai-settings-save-btn" class="wfm-btn wfm-btn-primary">Save</button>
</div>
+42 -4
View File
@@ -3603,7 +3603,8 @@ function _extractPromptsAPI(wf) {
const srcNode = wf[String(val[0])];
// TextEncodeFibo2(Fibo 2.0)も同形。promptはPreviewAny→プロンプト強化スイッチ経由でリンクされる。
if (srcNode?.class_type === "TextEncodeMageFlowEdit" || srcNode?.class_type === "TextEncodeBooguEdit"
|| srcNode?.class_type === "TextEncodeFibo2") {
|| srcNode?.class_type === "TextEncodeFibo2" || srcNode?.class_type === "PH3ImageConditioning"
|| srcNode?.class_type === "MiniMaxH3ImageConditioning") {
const raw = isPos ? srcNode.inputs?.prompt : srcNode.inputs?.negative_prompt;
const txt = Array.isArray(raw) ? _resolveLinkedText(wf, raw[0], raw[1] ?? 0) : raw;
if (txt && typeof txt === "string") { if (isPos) pos.add(txt); else neg.add(txt); }
@@ -4034,6 +4035,39 @@ const renderInfoTab = (container) => {
const AI_SETTINGS_KEY = "wfm_ai_settings";
const AI_LANG_NAMES = { ja: "Japanese", en: "English", zh: "Chinese" };
// PLaMo Translate over chat — inline copy of static/js/plamo-chat.js (this file cannot import
// from static/). PLaMo treats an instruction system prompt as context and the user text as the
// source, so the languages go in a leading "[plamo-translate]" system message instead.
const AI_PLAMO_LANGS = ["ar","az","be","bg","bn","ca","ceb","de","en","es","et","eu","fa","fr","gu","he","hi","hr","hu","hy","id","it","ja","jv","ka","kk","km","ko","lt","lv","ml","mr","ms","my","ne","nl","pa","pl","ru","si","sk","sl","sr","sw","ta","te","th","tl","ur","uz","vi","zh"];
let _aiPlamoNameMap = null;
function aiIsPlamoModel(model) { return /plamo/i.test(model || ""); }
function aiPlamoLangCode(nameOrCode) {
const key = (nameOrCode || "").trim().toLowerCase();
if (!key) return "";
if (!_aiPlamoNameMap) {
_aiPlamoNameMap = new Map();
for (const code of AI_PLAMO_LANGS) {
_aiPlamoNameMap.set(code, code);
for (const loc of ["en", "ja", "zh", navigator.language, code]) { // `code` adds the endonym
try {
const name = new Intl.DisplayNames([loc], { type: "language" }).of(code);
if (name) _aiPlamoNameMap.set(name.toLowerCase(), code);
} catch { /* Intl.DisplayNames unavailable */ }
}
}
[["chinese", "zh"], ["中文", "zh"], ["中国語", "zh"], ["filipino", "tl"], ["tagalog", "tl"], ["persian", "fa"], ["farsi", "fa"]]
.forEach(([k, v]) => _aiPlamoNameMap.set(k, v));
}
return _aiPlamoNameMap.get(key) || _aiPlamoNameMap.get(key.split(/[-_]/)[0]) || "";
}
function aiBuildPlamoMessages(text, src, dst) {
const dstCode = aiPlamoLangCode(dst);
if (!dstCode) throw new Error(`PLaMo Translate does not support the target language "${dst}"`);
const srcCode = aiPlamoLangCode(src);
const header = `[plamo-translate]\ntarget_lang=${dstCode}` + (srcCode && srcCode !== dstCode ? `\nsource_lang=${srcCode}` : "");
return [{ role: "system", content: header }, { role: "user", content: text }];
}
const AI_BACKEND_DEFAULT_URLS = {
ollama: "http://localhost:11434",
lmstudio: "http://localhost:1234",
@@ -4564,7 +4598,7 @@ const setupAiHandlers = (container) => {
const systemPrompt = `You are a professional translator. Translate the text the user sends${fromPart} into ${dstName}. `
+ `Reply with ONLY the translated text and nothing else: no explanations, no notes, no preamble like "Here is the translation:", `
+ `no surrounding quotes, and do not repeat or echo the original text.`;
const messages = [{ role: "system", content: systemPrompt }, { role: "user", content: text }];
const plamo = aiIsPlamoModel(model);
const transBtn = container.querySelector("#wfm-nlp-ai-trans-btn");
const statusEl = container.querySelector("#wfm-nlp-ai-status");
@@ -4575,8 +4609,12 @@ const setupAiHandlers = (container) => {
outputEl.value = "";
try {
const result = await aiCallChat(url, backend, model, messages, c);
const cleaned = cleanAiTranslationOutput(result);
const messages = plamo
? aiBuildPlamoMessages(text, srcName, dstName)
: [{ role: "system", content: systemPrompt }, { role: "user", content: text }];
const callCfg = plamo ? { ...c, thinkingMode: false } : c; // PLaMo has no thinking mode
const result = await aiCallChat(url, backend, model, messages, callCfg);
const cleaned = plamo ? result.replace(/<\|plamo:[a-z_]+\|>/g, "").trim() : cleanAiTranslationOutput(result);
outputEl.value = cleaned;
statusEl.textContent = "完了";
statusEl.className = "wfm-nlp-ai-status wfm-nlp-ai-ok";
-818
View File
@@ -1,818 +0,0 @@
/**
* Node Library Sidebar Panel
*
* Fixed sidebar panel injected into ComfyUI DOM.
* Three tabs: Favorites (single nodes), Node Sets (multi-node), Groups.
* Items are draggable onto the canvas or click-to-place.
*/
console.log("[WFM] node_sets_menu.js loading...");
import { app } from "../../scripts/app.js";
console.log("[WFM] node_sets_menu.js: app imported");
export const NODE_SETS_TOOLTIP = "Node Library – Browse & drag nodes onto canvas";
// ============================================
// State
// ============================================
const state = {
visible: false,
activeTab: "favorites", // favorites | sets | groups
favorites: [], // [{name, display_name}]
nodeSets: [],
groups: {}, // {groupName: [nodeName, ...]}
metadata: {},
searchText: "",
loaded: false,
};
// ============================================
// API
// ============================================
const fetchNodeSets = async () => {
try {
const res = await fetch("/api/wfm/node-sets");
return res.ok ? await res.json() : [];
} catch { return []; }
};
const fetchMetadata = async () => {
try {
const res = await fetch("/api/wfm/nodes/metadata");
return res.ok ? await res.json() : {};
} catch { return {}; }
};
const fetchGroups = async () => {
try {
const res = await fetch("/api/wfm/nodes/groups");
return res.ok ? await res.json() : {};
} catch { return {}; }
};
const loadData = async () => {
const [metadata, nodeSets, groups] = await Promise.all([
fetchMetadata(), fetchNodeSets(), fetchGroups(),
]);
state.metadata = metadata;
state.nodeSets = nodeSets;
state.groups = groups;
// Extract favorites from metadata
state.favorites = [];
for (const [name, meta] of Object.entries(metadata)) {
if (name === "_groups") continue;
if (meta.favorite) {
state.favorites.push({ name, display_name: name });
}
}
state.loaded = true;
};
// ============================================
// Canvas placement helpers
// ============================================
const getCanvasDropPos = (e) => {
const canvas = app.canvas;
if (!canvas) return [100, 100];
const rect = canvas.canvas.getBoundingClientRect();
const x = (e.clientX - rect.left) / canvas.ds.scale - canvas.ds.offset[0];
const y = (e.clientY - rect.top) / canvas.ds.scale - canvas.ds.offset[1];
return [x, y];
};
const placeSingleNode = (classType, pos) => {
const graph = app.graph;
if (!graph) return;
const node = LiteGraph.createNode(classType);
if (!node) {
showToast(`Unknown node: ${classType}`, "error");
return;
}
node.pos = pos || [100, 100];
graph.add(node);
app.canvas.setDirty(true, true);
showToast(`Placed: ${node.title || classType}`, "success");
};
const placeNodeSet = (nodeSet, pos) => {
const graph = app.graph;
const canvas = app.canvas;
if (!graph || !canvas) return;
const nodes = nodeSet.nodes || [];
if (nodes.length === 0) return;
const baseX = pos ? pos[0] : (-canvas.ds.offset[0] + canvas.canvas.width / 2 / canvas.ds.scale);
const baseY = pos ? pos[1] : (-canvas.ds.offset[1] + canvas.canvas.height / 2 / canvas.ds.scale);
const positions = nodes.map(n => n.rel_pos || [0, 0]);
const minX = Math.min(...positions.map(p => p[0]));
const minY = Math.min(...positions.map(p => p[1]));
const createdNodes = [];
for (const nodeDef of nodes) {
if (!nodeDef.class_type) { createdNodes.push(null); continue; }
const node = LiteGraph.createNode(nodeDef.class_type);
if (!node) { createdNodes.push(null); continue; }
const rp = nodeDef.rel_pos || [0, 0];
node.pos = [baseX + rp[0] - minX, baseY + rp[1] - minY];
if (nodeDef.title) node.title = nodeDef.title;
if (nodeDef.widget_values && node.widgets) {
for (const [k, v] of Object.entries(nodeDef.widget_values)) {
const w = node.widgets.find(ww => ww.name === k);
if (w) w.value = v;
}
}
graph.add(node);
createdNodes.push(node);
}
for (const link of (nodeSet.links || [])) {
const from = createdNodes[link.from_node];
const to = createdNodes[link.to_node];
if (from && to) {
try { from.connect(link.from_slot ?? 0, to, link.to_slot ?? 0); } catch {}
}
}
canvas.setDirty(true, true);
showToast(`Placed "${nodeSet.name}" (${createdNodes.filter(Boolean).length} nodes)`, "success");
};
// ============================================
// Drag & Drop onto canvas
// ============================================
let dropHandlerInstalled = false;
const installCanvasDropHandler = () => {
if (dropHandlerInstalled) return;
dropHandlerInstalled = true;
const canvasEl = document.getElementById("graph-canvas");
if (!canvasEl) return;
canvasEl.addEventListener("dragover", (e) => {
if (e.dataTransfer.types.includes("application/x-wfm-node")) {
e.preventDefault();
e.dataTransfer.dropEffect = "copy";
}
});
canvasEl.addEventListener("drop", (e) => {
const raw = e.dataTransfer.getData("application/x-wfm-node");
if (!raw) return;
e.preventDefault();
const data = JSON.parse(raw);
const pos = getCanvasDropPos(e);
if (data.type === "single") {
placeSingleNode(data.classType, pos);
} else if (data.type === "set") {
const set = state.nodeSets.find(s => s.id === data.setId);
if (set) placeNodeSet(set, pos);
}
});
};
// ============================================
// Sidebar Panel DOM
// ============================================
let panelEl = null;
const PANEL_ID = "wfm-node-library-panel";
const createPanel = () => {
if (panelEl) return panelEl;
const panel = document.createElement("div");
panel.id = PANEL_ID;
panel.innerHTML = `
<div class="wfm-nlp-header">
<span class="wfm-nlp-title">Node Library</span>
<button class="wfm-nlp-refresh" title="Refresh">&#8635;</button>
<button class="wfm-nlp-close" title="Close">&times;</button>
</div>
<div class="wfm-nlp-tabs">
<button class="wfm-nlp-tab active" data-tab="favorites">&#9733; Favorites</button>
<button class="wfm-nlp-tab" data-tab="sets">&#9776; Sets</button>
<button class="wfm-nlp-tab" data-tab="groups">&#128193; Groups</button>
</div>
<div class="wfm-nlp-search">
<input type="text" class="wfm-nlp-search-input" placeholder="Search...">
</div>
<div class="wfm-nlp-content"></div>
`;
document.body.appendChild(panel);
panelEl = panel;
// Tab switching
panel.querySelectorAll(".wfm-nlp-tab").forEach(btn => {
btn.addEventListener("click", () => {
state.activeTab = btn.dataset.tab;
panel.querySelectorAll(".wfm-nlp-tab").forEach(b => b.classList.remove("active"));
btn.classList.add("active");
renderContent();
});
});
// Close
panel.querySelector(".wfm-nlp-close").addEventListener("click", () => togglePanel());
// Search
panel.querySelector(".wfm-nlp-search-input").addEventListener("input", (e) => {
state.searchText = e.target.value.toLowerCase().trim();
renderContent();
});
// Refresh
panel.querySelector(".wfm-nlp-refresh").addEventListener("click", async () => {
await loadData();
renderContent();
showToast("Node Library refreshed", "success");
});
injectStyles();
return panel;
};
// ============================================
// Render content
// ============================================
const renderContent = () => {
const content = panelEl?.querySelector(".wfm-nlp-content");
if (!content) return;
if (!state.loaded) {
content.innerHTML = `<div class="wfm-nlp-empty">Loading...</div>`;
return;
}
switch (state.activeTab) {
case "favorites": renderFavorites(content); break;
case "sets": renderSets(content); break;
case "groups": renderGroups(content); break;
}
};
const renderFavorites = (container) => {
let items = state.favorites;
if (state.searchText) {
items = items.filter(n => n.name.toLowerCase().includes(state.searchText));
}
if (items.length === 0) {
container.innerHTML = `<div class="wfm-nlp-empty">
${state.favorites.length === 0 ? "No favorites yet.<br><small>Star nodes in Workflow Studio → Nodes tab</small>" : "No matches"}
</div>`;
return;
}
container.innerHTML = "";
for (const node of items) {
const el = createDraggableItem(node.display_name || node.name, "single", { classType: node.name });
el.addEventListener("dblclick", () => {
placeSingleNode(node.name);
});
container.appendChild(el);
}
};
const renderSets = (container) => {
let items = state.nodeSets;
if (state.searchText) {
items = items.filter(s =>
s.name.toLowerCase().includes(state.searchText) ||
(s.tags || []).some(t => t.toLowerCase().includes(state.searchText))
);
}
if (items.length === 0) {
container.innerHTML = `<div class="wfm-nlp-empty">
${state.nodeSets.length === 0 ? "No node sets.<br><small>Create sets in Workflow Studio → Nodes tab</small>" : "No matches"}
</div>`;
return;
}
container.innerHTML = "";
for (const set of items) {
const count = (set.nodes || []).length;
const el = createDraggableItem(
`${esc(set.name)} <span class="wfm-nlp-badge">${count} nodes</span>`,
"set",
{ setId: set.id },
set.description
);
el.addEventListener("dblclick", () => {
placeNodeSet(set);
});
container.appendChild(el);
}
};
const renderGroups = (container) => {
const groupNames = Object.keys(state.groups).sort();
if (groupNames.length === 0) {
container.innerHTML = `<div class="wfm-nlp-empty">
No groups.<br><small>Create groups in Workflow Studio → Nodes tab</small>
</div>`;
return;
}
let filtered = groupNames;
if (state.searchText) {
filtered = groupNames.filter(g =>
g.toLowerCase().includes(state.searchText) ||
(state.groups[g] || []).some(n => n.toLowerCase().includes(state.searchText))
);
}
container.innerHTML = "";
for (const groupName of filtered) {
const nodes = state.groups[groupName] || [];
const section = document.createElement("div");
section.className = "wfm-nlp-group-section";
const header = document.createElement("div");
header.className = "wfm-nlp-group-header";
header.innerHTML = `<span>${esc(groupName)}</span> <span class="wfm-nlp-badge">${nodes.length}</span>`;
header.addEventListener("click", () => {
const list = section.querySelector(".wfm-nlp-group-list");
list.style.display = list.style.display === "none" ? "block" : "none";
header.classList.toggle("collapsed");
});
section.appendChild(header);
const list = document.createElement("div");
list.className = "wfm-nlp-group-list";
for (const nodeName of nodes) {
const el = createDraggableItem(nodeName, "single", { classType: nodeName });
el.addEventListener("dblclick", () => placeSingleNode(nodeName));
list.appendChild(el);
}
section.appendChild(list);
container.appendChild(section);
}
};
// ============================================
// Draggable item factory
// ============================================
const createDraggableItem = (label, type, data, subtitle) => {
const el = document.createElement("div");
el.className = "wfm-nlp-item";
el.draggable = true;
el.innerHTML = `
<div class="wfm-nlp-item-label">${label}</div>
${subtitle ? `<div class="wfm-nlp-item-sub">${esc(subtitle)}</div>` : ""}
`;
el.addEventListener("dragstart", (e) => {
e.dataTransfer.effectAllowed = "copy";
e.dataTransfer.setData("application/x-wfm-node", JSON.stringify({ type, ...data }));
el.classList.add("dragging");
});
el.addEventListener("dragend", () => {
el.classList.remove("dragging");
});
return el;
};
// ============================================
// Toggle & exports
// ============================================
export const togglePanel = async () => {
const panel = createPanel();
state.visible = !state.visible;
panel.style.display = state.visible ? "flex" : "none";
if (state.visible && !state.loaded) {
await loadData();
renderContent();
}
installCanvasDropHandler();
};
export const getNodeSetsIcon = () => `
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2">
<rect x="3" y="3" width="7" height="7" rx="1"/>
<rect x="14" y="3" width="7" height="7" rx="1"/>
<rect x="3" y="14" width="7" height="7" rx="1"/>
<path d="M17.5 14v7M14 17.5h7"/>
</svg>
`;
// ============================================
// Toast
// ============================================
const showToast = (message, type = "info") => {
const existing = document.getElementById("wfm-ns-toast");
if (existing) existing.remove();
const toast = document.createElement("div");
toast.id = "wfm-ns-toast";
const colors = {
success: { bg: "rgba(46,213,115,0.95)" },
error: { bg: "rgba(255,71,87,0.95)" },
info: { bg: "rgba(74,158,255,0.95)" },
};
Object.assign(toast.style, {
position: "fixed", bottom: "24px", left: "50%", transform: "translateX(-50%)",
padding: "10px 24px", background: (colors[type] || colors.info).bg, color: "#fff",
borderRadius: "8px", fontSize: "14px", fontWeight: "500", zIndex: "99999",
boxShadow: "0 4px 16px rgba(0,0,0,0.3)", transition: "opacity 0.3s", whiteSpace: "nowrap",
});
toast.textContent = message;
document.body.appendChild(toast);
setTimeout(() => { toast.style.opacity = "0"; setTimeout(() => toast.remove(), 300); }, 3000);
};
const esc = (s) => s ? String(s).replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;") : "";
// ============================================
// Save selected nodes as Node Set (context menu)
// ============================================
const saveSelectedAsNodeSet = async () => {
const selectedNodes = Object.values(app.canvas.selected_nodes || {});
if (selectedNodes.length === 0) {
showToast("Select at least one node first", "error");
return;
}
// Prompt for name
const name = prompt("Node Set name:");
if (!name || !name.trim()) return;
// Build node list with relative positions
// Use the top-left of the bounding box as origin
const minX = Math.min(...selectedNodes.map(n => n.pos[0]));
const minY = Math.min(...selectedNodes.map(n => n.pos[1]));
const nodeIdToIndex = new Map();
const nodes = [];
selectedNodes.forEach((node, i) => {
nodeIdToIndex.set(node.id, i);
nodes.push({
class_type: node.type || node.comfyClass || "",
title: node.title || "",
rel_pos: [Math.round(node.pos[0] - minX), Math.round(node.pos[1] - minY)],
});
});
// Extract links between selected nodes
const links = [];
const graph = app.graph;
for (const node of selectedNodes) {
if (!node.inputs) continue;
for (let slotIdx = 0; slotIdx < node.inputs.length; slotIdx++) {
const input = node.inputs[slotIdx];
if (input.link == null) continue;
// Resolve link data
let linkData = null;
if (graph.links instanceof Map) {
linkData = graph.links.get(input.link);
} else if (graph.links) {
linkData = graph.links[input.link];
}
if (!linkData) continue;
// linkData: [id, origin_id, origin_slot, target_id, target_slot, type]
// or object with .origin_id, .origin_slot, etc.
const originId = linkData.origin_id ?? linkData[1];
const originSlot = linkData.origin_slot ?? linkData[2];
const targetSlot = linkData.target_slot ?? linkData[4];
// Only include if both source and target are in the selection
if (nodeIdToIndex.has(originId) && nodeIdToIndex.has(node.id)) {
links.push({
from_node: nodeIdToIndex.get(originId),
from_slot: originSlot,
to_node: nodeIdToIndex.get(node.id),
to_slot: targetSlot,
});
}
}
}
// Save via API
try {
const res = await fetch("/api/wfm/node-sets", {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({ name: name.trim(), description: "", tags: [], nodes, links }),
});
const result = await res.json();
if (result.status === "ok") {
showToast(`Node Set "${name.trim()}" saved (${nodes.length} nodes, ${links.length} links)`, "success");
// Refresh sidebar if open
if (state.loaded) {
await loadData();
renderContent();
}
} else {
showToast("Failed to save: " + (result.error || "Unknown error"), "error");
}
} catch (err) {
showToast("Failed to save: " + err.message, "error");
}
};
// Register context menu item on all nodes
app.registerExtension({
name: "WorkflowStudio.NodeSetContextMenu",
beforeRegisterNodeDef(nodeType, _nodeData, _app) {
const origGetExtraMenuOptions = nodeType.prototype.getExtraMenuOptions;
nodeType.prototype.getExtraMenuOptions = function(_, options) {
origGetExtraMenuOptions?.apply(this, arguments);
const selectedCount = Object.keys(app.canvas.selected_nodes || {}).length;
// Add separator + menu item
options.push(null);
options.push({
content: `Save as Node Set${selectedCount > 1 ? ` (${selectedCount} nodes)` : ""}`,
callback: saveSelectedAsNodeSet,
});
};
},
});
// ============================================
// Styles
// ============================================
const injectStyles = () => {
if (document.getElementById("wfm-nlp-styles")) return;
const style = document.createElement("style");
style.id = "wfm-nlp-styles";
style.textContent = `
#${PANEL_ID} {
position: fixed;
right: 0;
top: 0;
width: 280px;
height: 100vh;
background: var(--comfy-menu-bg, #1e1e1e);
border-left: 1px solid var(--border-color, #4e4e4e);
z-index: 9999;
display: none;
flex-direction: column;
font-family: sans-serif;
font-size: 13px;
color: var(--input-text, #ddd);
box-shadow: -4px 0 16px rgba(0,0,0,0.3);
}
.wfm-nlp-header {
display: flex;
align-items: center;
gap: 6px;
padding: 10px 12px;
border-bottom: 1px solid var(--border-color, #4e4e4e);
flex-shrink: 0;
}
.wfm-nlp-title {
font-weight: 600;
font-size: 14px;
flex: 1;
}
.wfm-nlp-close {
background: none;
border: none;
color: var(--input-text, #ddd);
font-size: 20px;
cursor: pointer;
padding: 0 4px;
opacity: 0.6;
}
.wfm-nlp-close:hover { opacity: 1; }
.wfm-nlp-tabs {
display: flex;
border-bottom: 1px solid var(--border-color, #4e4e4e);
flex-shrink: 0;
}
.wfm-nlp-tab {
flex: 1;
padding: 8px 4px;
background: none;
border: none;
border-bottom: 2px solid transparent;
color: var(--input-text, #ddd);
font-size: 11px;
cursor: pointer;
opacity: 0.6;
transition: all 0.15s;
white-space: nowrap;
}
.wfm-nlp-tab:hover { opacity: 0.9; }
.wfm-nlp-tab.active {
opacity: 1;
border-bottom-color: var(--p-button-background, #4a9eff);
}
.wfm-nlp-search {
padding: 8px;
border-bottom: 1px solid var(--border-color, #4e4e4e);
flex-shrink: 0;
}
.wfm-nlp-search-input {
width: 100%;
padding: 6px 8px;
background: var(--comfy-input-bg, #2a2a2a);
border: 1px solid var(--border-color, #4e4e4e);
border-radius: 4px;
color: var(--input-text, #ddd);
font-size: 12px;
outline: none;
box-sizing: border-box;
}
.wfm-nlp-search-input:focus {
border-color: var(--p-button-background, #4a9eff);
}
.wfm-nlp-content {
flex: 1;
overflow-y: auto;
padding: 4px 0;
}
.wfm-nlp-empty {
padding: 24px 16px;
text-align: center;
color: var(--descrip-text, #999);
font-size: 12px;
line-height: 1.6;
}
.wfm-nlp-item {
padding: 7px 12px;
cursor: grab;
border-bottom: 1px solid var(--border-color, #3a3a3a);
transition: background 0.12s;
user-select: none;
}
.wfm-nlp-item:hover {
background: var(--comfy-input-bg, #333);
}
.wfm-nlp-item.dragging {
opacity: 0.5;
background: var(--comfy-input-bg, #333);
}
.wfm-nlp-item-label {
font-size: 12px;
line-height: 1.3;
}
.wfm-nlp-item-sub {
font-size: 10px;
color: var(--descrip-text, #888);
margin-top: 2px;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
.wfm-nlp-badge {
display: inline-block;
font-size: 10px;
padding: 1px 5px;
background: var(--comfy-input-bg, #444);
border-radius: 3px;
color: var(--descrip-text, #aaa);
margin-left: 4px;
vertical-align: middle;
}
.wfm-nlp-group-section {
border-bottom: 1px solid var(--border-color, #3a3a3a);
}
.wfm-nlp-group-header {
padding: 8px 12px;
cursor: pointer;
font-weight: 500;
font-size: 12px;
display: flex;
align-items: center;
justify-content: space-between;
transition: background 0.12s;
}
.wfm-nlp-group-header:hover {
background: var(--comfy-input-bg, #333);
}
.wfm-nlp-group-header::before {
content: "\\25BC";
font-size: 8px;
margin-right: 6px;
transition: transform 0.15s;
}
.wfm-nlp-group-header.collapsed::before {
transform: rotate(-90deg);
}
.wfm-nlp-group-list {
padding-left: 8px;
}
.wfm-nlp-group-list .wfm-nlp-item {
padding: 5px 12px;
font-size: 11px;
}
.wfm-nlp-refresh {
background: none;
border: none;
color: var(--input-text, #ddd);
font-size: 16px;
cursor: pointer;
opacity: 0.7;
}
.wfm-nlp-refresh:hover { opacity: 1; }
`;
document.head.appendChild(style);
};
// ============================================
// Context Menu — Save selected nodes as Node Set
// ============================================
const saveSelectedAsNodeSet = async () => {
const selectedNodes = Object.values(app.canvas.selected_nodes || {});
if (selectedNodes.length === 0) {
showToast("Select at least one node first", "error");
return;
}
const name = prompt("Node Set name:");
if (!name || !name.trim()) return;
const minX = Math.min(...selectedNodes.map(n => n.pos[0]));
const minY = Math.min(...selectedNodes.map(n => n.pos[1]));
const nodeIdToIndex = new Map();
const nodes = [];
selectedNodes.forEach((node, i) => {
nodeIdToIndex.set(node.id, i);
nodes.push({
class_type: node.type || node.comfyClass || "",
title: node.title || "",
rel_pos: [Math.round(node.pos[0] - minX), Math.round(node.pos[1] - minY)],
});
});
const links = [];
const graph = app.graph;
for (const node of selectedNodes) {
if (!node.inputs) continue;
for (let slotIdx = 0; slotIdx < node.inputs.length; slotIdx++) {
const input = node.inputs[slotIdx];
if (input.link == null) continue;
let linkData = null;
if (graph.links instanceof Map) {
linkData = graph.links.get(input.link);
} else if (graph.links) {
linkData = graph.links[input.link];
}
if (!linkData) continue;
const originId = linkData.origin_id ?? linkData[1];
const originSlot = linkData.origin_slot ?? linkData[2];
const targetSlot = linkData.target_slot ?? linkData[4];
if (nodeIdToIndex.has(originId) && nodeIdToIndex.has(node.id)) {
links.push({
from_node: nodeIdToIndex.get(originId),
from_slot: originSlot,
to_node: nodeIdToIndex.get(node.id),
to_slot: targetSlot,
});
}
}
}
try {
const res = await fetch("/api/wfm/node-sets", {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({ name: name.trim(), description: "", tags: [], nodes, links }),
});
const result = await res.json();
if (result.status === "ok") {
showToast(`Node Set "${name.trim()}" saved (${nodes.length} nodes, ${links.length} links)`, "success");
if (state.loaded) { await loadData(); renderContent(); }
} else {
showToast("Failed to save: " + (result.error || "Unknown error"), "error");
}
} catch (err) {
showToast("Failed to save: " + err.message, "error");
}
};
export { saveSelectedAsNodeSet };
-117
View File
@@ -5,8 +5,6 @@ const BUTTON_TOOLTIP = "Launch Workflow Studio (Shift+Click opens in new window)
const SNAPSHOT_TOOLTIP = "Save workflow canvas image as thumbnail";
const WFM_PATH = "/wfm";
const NEW_WINDOW_FEATURES = "width=1400,height=900,resizable=yes,scrollbars=yes,status=yes";
const MAX_ATTACH_ATTEMPTS = 120;
const BUTTON_GROUP_CLASS = "wfm-top-menu-group";
const MIN_VERSION_FOR_ACTION_BAR = [1, 33, 9];
@@ -425,121 +423,6 @@ const getSnapshotIcon = () => {
`;
};
// ============================================
// Button Creation
// ============================================
const createTopMenuButton = async () => {
const { ComfyButton } = await import("../../scripts/ui/components/button.js");
const button = new ComfyButton({
icon: "wfm",
tooltip: BUTTON_TOOLTIP,
app,
enabled: true,
classList: "comfyui-button comfyui-menu-mobile-collapse primary",
});
button.element.setAttribute("aria-label", BUTTON_TOOLTIP);
button.element.title = BUTTON_TOOLTIP;
if (button.iconElement) {
button.iconElement.innerHTML = getWfmIcon();
button.iconElement.style.width = "1.2rem";
button.iconElement.style.height = "1.2rem";
}
button.element.addEventListener("click", openWorkflowStudio);
return button;
};
const createSnapshotButton = async () => {
const { ComfyButton } = await import("../../scripts/ui/components/button.js");
const button = new ComfyButton({
icon: "snapshot",
tooltip: SNAPSHOT_TOOLTIP,
app,
enabled: true,
classList: "comfyui-button comfyui-menu-mobile-collapse",
});
button.element.setAttribute("aria-label", SNAPSHOT_TOOLTIP);
button.element.title = SNAPSHOT_TOOLTIP;
if (button.iconElement) {
button.iconElement.innerHTML = getSnapshotIcon();
button.iconElement.style.width = "1.2rem";
button.iconElement.style.height = "1.2rem";
}
button.element.addEventListener("click", saveCanvasToWorkflowStudio);
return button;
};
const createNodeSetsButton = async () => {
const { ComfyButton } = await import("../../scripts/ui/components/button.js");
const button = new ComfyButton({
icon: "node-sets",
tooltip: NODE_SETS_TOOLTIP,
app,
enabled: true,
classList: "comfyui-button comfyui-menu-mobile-collapse wfm-node-sets-btn",
});
button.element.setAttribute("aria-label", NODE_SETS_TOOLTIP);
button.element.title = NODE_SETS_TOOLTIP;
if (button.iconElement) {
button.iconElement.innerHTML = getNodeSetsIcon();
button.iconElement.style.width = "1.2rem";
button.iconElement.style.height = "1.2rem";
}
button.element.addEventListener("click", (e) => {
e.stopPropagation();
togglePanel();
});
return button;
};
const attachTopMenuButton = async (attempt = 0) => {
if (document.querySelector(`.${BUTTON_GROUP_CLASS}`)) {
return;
}
// Try settingsGroup first (legacy ComfyUI)
const settingsGroup = app.menu?.settingsGroup;
// Fallback: find the legacy topbar container used by newer ComfyUI
const legacyContainer = document.querySelector('[data-testid="legacy-topbar-container"] .flex');
if (!settingsGroup?.element?.parentElement && !legacyContainer) {
if (attempt >= MAX_ATTACH_ATTEMPTS) {
console.warn("Workflow Studio: unable to locate the ComfyUI menu container.");
return;
}
requestAnimationFrame(() => attachTopMenuButton(attempt + 1));
return;
}
const wfmButton = await createTopMenuButton();
const snapshotButton = await createSnapshotButton();
const nodeSetsButton = await createNodeSetsButton();
const { ComfyButtonGroup } = await import("../../scripts/ui/components/buttonGroup.js");
const buttonGroup = new ComfyButtonGroup(wfmButton, snapshotButton, nodeSetsButton);
buttonGroup.element.classList.add(BUTTON_GROUP_CLASS);
if (settingsGroup?.element?.parentElement) {
settingsGroup.element.before(buttonGroup.element);
} else if (legacyContainer) {
legacyContainer.prepend(buttonGroup.element);
}
};
app.registerExtension({
name: "WorkflowStudio.TopMenu",
actionBarButtons: [

Some files were not shown because too many files have changed in this diff Show More