@hanzo/studio 0.1.7 → 0.1.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/app/director.d.ts +137 -0
- package/lib/app/director.js +1263 -0
- package/lib/app/flow.d.ts +58 -0
- package/lib/app/flow.js +948 -0
- package/lib/chat/turn.js +19 -11
- package/lib/home.d.ts +3 -1
- package/lib/home.js +3 -3
- package/lib/index.d.ts +6 -0
- package/lib/index.js +5 -0
- package/lib/kinds/app.d.ts +40 -0
- package/lib/kinds/app.js +907 -0
- package/lib/kinds/document.js +256 -19
- package/lib/kinds/image.d.ts +3 -0
- package/lib/kinds/image.js +82 -10
- package/lib/kinds/index.js +2 -1
- package/lib/kinds/sound.js +109 -10
- package/lib/kinds/video.js +146 -17
- package/lib/live.d.ts +11 -0
- package/lib/live.js +10 -0
- package/lib/made.d.ts +2 -1
- package/lib/made.js +1 -0
- package/lib/pdf.js +1 -1
- package/lib/places.d.ts +0 -3
- package/lib/places.js +1 -11
- package/lib/route.d.ts +12 -0
- package/lib/route.js +17 -0
- package/lib/starters.d.ts +21 -0
- package/lib/starters.js +33 -2
- package/lib/studio.js +1 -1
- package/lib/talk.js +61 -23
- package/lib/wire.d.ts +2 -6
- package/lib/wire.js +16 -3
- package/package.json +36 -38
package/lib/app/flow.js
ADDED
|
@@ -0,0 +1,948 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { SizableText, XStack, YStack } from '@hanzo/gui';
|
|
3
|
+
import { Boxes, Code, Download, Layers, Play, Sparkles, Terminal, Upload, Wand2, Workflow, } from '@hanzogui/lucide-icons-2';
|
|
4
|
+
import { createElement, useEffect, useMemo, useState } from 'react';
|
|
5
|
+
export function parseFlowSection(path) {
|
|
6
|
+
const clean = (path ?? '').replace(/^\/+|\/+$/g, '').split('/')[0] ?? '';
|
|
7
|
+
if (clean === 'hybrid' || clean === 'comfy' || clean === 'agents' || clean === 'code' || clean === 'publish') {
|
|
8
|
+
return clean;
|
|
9
|
+
}
|
|
10
|
+
return 'canvas';
|
|
11
|
+
}
|
|
12
|
+
export function flowNav(host, go) {
|
|
13
|
+
const active = parseFlowSection(host.path);
|
|
14
|
+
return [
|
|
15
|
+
{
|
|
16
|
+
id: 'make',
|
|
17
|
+
label: 'Hanzo Flow (Langflow + Comfy)',
|
|
18
|
+
links: [
|
|
19
|
+
{
|
|
20
|
+
id: 'canvas',
|
|
21
|
+
label: 'Flow Canvas & Playground',
|
|
22
|
+
active: active === 'canvas',
|
|
23
|
+
icon: createElement(Workflow, { size: 16 }),
|
|
24
|
+
onPress: () => go(''),
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
id: 'comfy',
|
|
28
|
+
label: 'ComfyUI Node Extensions',
|
|
29
|
+
active: active === 'comfy',
|
|
30
|
+
icon: createElement(Layers, { size: 16 }),
|
|
31
|
+
onPress: () => go('comfy'),
|
|
32
|
+
},
|
|
33
|
+
{
|
|
34
|
+
id: 'agents',
|
|
35
|
+
label: 'Langflow Agents, RAG & MCP',
|
|
36
|
+
active: active === 'agents',
|
|
37
|
+
icon: createElement(Boxes, { size: 16 }),
|
|
38
|
+
onPress: () => go('agents'),
|
|
39
|
+
},
|
|
40
|
+
{
|
|
41
|
+
id: 'code',
|
|
42
|
+
label: 'Python Node Code Editor',
|
|
43
|
+
active: active === 'code',
|
|
44
|
+
icon: createElement(Code, { size: 16 }),
|
|
45
|
+
onPress: () => go('code'),
|
|
46
|
+
},
|
|
47
|
+
{
|
|
48
|
+
id: 'publish',
|
|
49
|
+
label: 'Publish REST / MCP / JSON',
|
|
50
|
+
active: active === 'publish',
|
|
51
|
+
icon: createElement(Terminal, { size: 16 }),
|
|
52
|
+
onPress: () => go('publish'),
|
|
53
|
+
},
|
|
54
|
+
],
|
|
55
|
+
},
|
|
56
|
+
];
|
|
57
|
+
}
|
|
58
|
+
export const FLOW_MODULE_CATALOG = [
|
|
59
|
+
// ── LANGFLOW AGENT / LLM / RAG / MCP / PYTHON NODES ─────────────────────────
|
|
60
|
+
{
|
|
61
|
+
type: 'ChatInput',
|
|
62
|
+
title: 'Chat / Multimodal Input',
|
|
63
|
+
family: 'langflow',
|
|
64
|
+
pack: 'hanzo-flow (MIT)',
|
|
65
|
+
category: 'agent',
|
|
66
|
+
inputPorts: [],
|
|
67
|
+
outputPorts: ['MESSAGE'],
|
|
68
|
+
defaultInputs: { input_value: 'Create a 24mm anamorphic cyberpunk rooftop trailer shot with synthwave score', files: '' },
|
|
69
|
+
pythonSource: `from flow.custom import Component\nfrom flow.io import MessageTextInput, Output\n\nclass ChatInputComponent(Component):\n display_name = "Chat Input"\n inputs = [MessageTextInput(name="input_value", display_name="Text")]\n outputs = [Output(display_name="Message", name="message", method="message_response")]\n\n def message_response(self) -> str:\n return self.input_value`,
|
|
70
|
+
},
|
|
71
|
+
{
|
|
72
|
+
type: 'ZenAgentNode',
|
|
73
|
+
title: 'Hanzo Zen Agent (Prompt & Tool Router)',
|
|
74
|
+
family: 'langflow',
|
|
75
|
+
pack: 'hanzo-flow (MIT)',
|
|
76
|
+
category: 'agent',
|
|
77
|
+
inputPorts: ['input_message', 'tools', 'context'],
|
|
78
|
+
outputPorts: ['PROMPT', 'JSON_SPEC'],
|
|
79
|
+
defaultInputs: { model: 'zen5', system_prompt: 'Expand user brief into a precision ComfyUI camera rig + lighting prompt.', temperature: 0.3 },
|
|
80
|
+
pythonSource: `from flow.custom import Component\nfrom flow.io import MessageTextInput, DropdownInput, Output\n\nclass ZenAgentComponent(Component):\n display_name = "Hanzo Zen Agent"\n def run_agent(self) -> str:\n return self.llm.invoke(self.input_message)`,
|
|
81
|
+
},
|
|
82
|
+
{
|
|
83
|
+
type: 'PromptTemplateNode',
|
|
84
|
+
title: 'Prompt Template ({variables})',
|
|
85
|
+
family: 'langflow',
|
|
86
|
+
pack: 'hanzo-flow (MIT)',
|
|
87
|
+
category: 'agent',
|
|
88
|
+
inputPorts: ['variables'],
|
|
89
|
+
outputPorts: ['PROMPT'],
|
|
90
|
+
defaultInputs: { template: '{subject}, shot on {lens}, {lighting}, {camera_rig}, photorealistic 8k' },
|
|
91
|
+
pythonSource: `from flow.custom import Component\n\nclass PromptTemplateComponent(Component):\n display_name = "Prompt Template"\n def build_prompt(self) -> str:\n return self.template.format(**self.variables)`,
|
|
92
|
+
},
|
|
93
|
+
{
|
|
94
|
+
type: 'MCPToolNode',
|
|
95
|
+
title: 'MCP Server Tool Connector',
|
|
96
|
+
family: 'langflow',
|
|
97
|
+
pack: 'hanzo-flow (MIT)',
|
|
98
|
+
category: 'agent',
|
|
99
|
+
inputPorts: ['query'],
|
|
100
|
+
outputPorts: ['TOOL', 'CONTEXT'],
|
|
101
|
+
defaultInputs: { server: 'hanzo-mcp', tool_name: 'search_brand_assets', transport: 'sse' },
|
|
102
|
+
pythonSource: `from flow.custom import Component\n\nclass MCPToolComponent(Component):\n display_name = "MCP Tool Client"\n async def call_tool(self):\n return await self.mcp_client.call(self.tool_name, self.query)`,
|
|
103
|
+
},
|
|
104
|
+
{
|
|
105
|
+
type: 'VectorStoreRAG',
|
|
106
|
+
title: 'Vector Store RAG (Brand & Lore Memory)',
|
|
107
|
+
family: 'langflow',
|
|
108
|
+
pack: 'hanzo-flow (MIT)',
|
|
109
|
+
category: 'agent',
|
|
110
|
+
inputPorts: ['search_query'],
|
|
111
|
+
outputPorts: ['CONTEXT'],
|
|
112
|
+
defaultInputs: { collection: 'brand_lookbook_v3', top_k: 4, embedding_model: 'zen-embed-1' },
|
|
113
|
+
pythonSource: `from flow.custom import Component\n\nclass VectorStoreRAGComponent(Component):\n display_name = "Hanzo Vector RAG"\n def retrieve(self) -> list:\n return self.vector_db.similarity_search(self.search_query, k=self.top_k)`,
|
|
114
|
+
},
|
|
115
|
+
{
|
|
116
|
+
type: 'PythonSandboxNode',
|
|
117
|
+
title: 'Python Custom Component (exec)',
|
|
118
|
+
family: 'langflow',
|
|
119
|
+
pack: 'hanzo-flow (MIT)',
|
|
120
|
+
category: 'agent',
|
|
121
|
+
inputPorts: ['data'],
|
|
122
|
+
outputPorts: ['DATA', 'IMAGE'],
|
|
123
|
+
defaultInputs: { script_name: 'custom_transform.py', timeout_sec: 30 },
|
|
124
|
+
pythonSource: `from studio_compat import io\nimport torch\n\nclass CustomStudioNode(io.ComfyNode):\n @classmethod\n def INPUT_TYPES(cls):\n return {"required": {"images": ("IMAGE",), "gain": ("FLOAT", {"default": 1.15})}}\n RETURN_TYPES = ("IMAGE",)\n FUNCTION = "execute"\n def execute(self, images, gain):\n return (torch.clamp(images * gain, 0.0, 1.0),)`,
|
|
125
|
+
},
|
|
126
|
+
// ── COMFYUI / STUDIO_COMPAT NATIVE MEDIA EXTENSIONS ─────────────────────────
|
|
127
|
+
{
|
|
128
|
+
type: 'UNETLoader',
|
|
129
|
+
title: 'Load UNet Diffusion Model',
|
|
130
|
+
family: 'comfy',
|
|
131
|
+
pack: 'studio-core (ComfyUI)',
|
|
132
|
+
category: 'loader',
|
|
133
|
+
inputPorts: [],
|
|
134
|
+
outputPorts: ['MODEL'],
|
|
135
|
+
defaultInputs: { unet_name: 'wan2.2_ti2v_5B_fp16.safetensors', weight_dtype: 'fp16' },
|
|
136
|
+
pythonSource: `class UNETLoader:\n @classmethod\n def INPUT_TYPES(s):\n return {"required": {"unet_name": (folder_paths.get_filename_list("diffusion_models"),), "weight_dtype": (["default", "fp16", "bf16", "fp8_e4m3fn"],)}}\n RETURN_TYPES = ("MODEL",)\n FUNCTION = "load_unet"`,
|
|
137
|
+
},
|
|
138
|
+
{
|
|
139
|
+
type: 'CLIPLoader',
|
|
140
|
+
title: 'Load CLIP / UMT5 Text Encoder',
|
|
141
|
+
family: 'comfy',
|
|
142
|
+
pack: 'studio-core (ComfyUI)',
|
|
143
|
+
category: 'loader',
|
|
144
|
+
inputPorts: [],
|
|
145
|
+
outputPorts: ['CLIP'],
|
|
146
|
+
defaultInputs: { clip_name: 'umt5_xxl_fp8_e4m3fn_scaled.safetensors', type: 'wan' },
|
|
147
|
+
pythonSource: `class CLIPLoader:\n RETURN_TYPES = ("CLIP",)\n FUNCTION = "load_clip"`,
|
|
148
|
+
},
|
|
149
|
+
{
|
|
150
|
+
type: 'CheckpointLoaderSimple',
|
|
151
|
+
title: 'Load Checkpoint (Model+CLIP+VAE)',
|
|
152
|
+
family: 'comfy',
|
|
153
|
+
pack: 'studio-core (ComfyUI)',
|
|
154
|
+
category: 'loader',
|
|
155
|
+
inputPorts: [],
|
|
156
|
+
outputPorts: ['MODEL', 'CLIP', 'VAE'],
|
|
157
|
+
defaultInputs: { ckpt_name: 'z_image_turbo_bf16.safetensors' },
|
|
158
|
+
pythonSource: `class CheckpointLoaderSimple:\n RETURN_TYPES = ("MODEL", "CLIP", "VAE")\n FUNCTION = "load_checkpoint"`,
|
|
159
|
+
},
|
|
160
|
+
{
|
|
161
|
+
type: 'UnetLoaderGGUF',
|
|
162
|
+
title: 'Load GGUF Quantized Model',
|
|
163
|
+
family: 'comfy',
|
|
164
|
+
pack: 'ComfyUI-GGUF (Apache-2.0)',
|
|
165
|
+
category: 'loader',
|
|
166
|
+
inputPorts: [],
|
|
167
|
+
outputPorts: ['MODEL'],
|
|
168
|
+
defaultInputs: { unet_name: 'flux1-dev-Q8_0.gguf' },
|
|
169
|
+
pythonSource: `class UnetLoaderGGUF:\n RETURN_TYPES = ("MODEL",)\n FUNCTION = "load_unet"`,
|
|
170
|
+
},
|
|
171
|
+
{
|
|
172
|
+
type: 'ImageOnlyCheckpointLoader',
|
|
173
|
+
title: 'Load Hunyuan3D 2.1 Checkpoint',
|
|
174
|
+
family: 'comfy',
|
|
175
|
+
pack: 'studio-core 3D (ComfyUI)',
|
|
176
|
+
category: 'loader',
|
|
177
|
+
inputPorts: [],
|
|
178
|
+
outputPorts: ['MODEL', 'CLIP_VISION', 'VAE'],
|
|
179
|
+
defaultInputs: { ckpt_name: 'hunyuan_3d_v2.1.safetensors' },
|
|
180
|
+
pythonSource: `class ImageOnlyCheckpointLoader:\n RETURN_TYPES = ("MODEL", "CLIP_VISION", "VAE")\n FUNCTION = "load_checkpoint"`,
|
|
181
|
+
},
|
|
182
|
+
{
|
|
183
|
+
type: 'LoadImageMask',
|
|
184
|
+
title: 'Load Image + Inpaint Mask',
|
|
185
|
+
family: 'comfy',
|
|
186
|
+
pack: 'studio-core (ComfyUI)',
|
|
187
|
+
category: 'loader',
|
|
188
|
+
inputPorts: [],
|
|
189
|
+
outputPorts: ['IMAGE', 'MASK'],
|
|
190
|
+
defaultInputs: { image: 'hero_lookbook.png', channel: 'alpha' },
|
|
191
|
+
pythonSource: `class LoadImageMask:\n RETURN_TYPES = ("IMAGE", "MASK")\n FUNCTION = "load_image"`,
|
|
192
|
+
},
|
|
193
|
+
{
|
|
194
|
+
type: 'CLIPTextEncode',
|
|
195
|
+
title: 'CLIP Text Prompt Encode',
|
|
196
|
+
family: 'comfy',
|
|
197
|
+
pack: 'studio-core (ComfyUI)',
|
|
198
|
+
category: 'conditioning',
|
|
199
|
+
inputPorts: ['clip', 'text_from_agent'],
|
|
200
|
+
outputPorts: ['CONDITIONING'],
|
|
201
|
+
defaultInputs: { text: 'Anamorphic 24mm crane rise over rain-slicked Neo-Kyoto rooftop, volumetric neon backlight' },
|
|
202
|
+
pythonSource: `class CLIPTextEncode:\n RETURN_TYPES = ("CONDITIONING",)\n FUNCTION = "encode"`,
|
|
203
|
+
},
|
|
204
|
+
{
|
|
205
|
+
type: 'WanImageToVideo',
|
|
206
|
+
title: 'Wan 2.2 TI2V Latent Video Grid',
|
|
207
|
+
family: 'comfy',
|
|
208
|
+
pack: 'ComfyUI-WanVideoWrapper (Apache-2.0)',
|
|
209
|
+
category: 'conditioning',
|
|
210
|
+
inputPorts: ['positive'],
|
|
211
|
+
outputPorts: ['CONDITIONING', 'LATENT'],
|
|
212
|
+
defaultInputs: { width: 1280, height: 544, length: 81, fps: 24 },
|
|
213
|
+
pythonSource: `class WanImageToVideo:\n RETURN_TYPES = ("CONDITIONING", "LATENT")\n FUNCTION = "encode"`,
|
|
214
|
+
},
|
|
215
|
+
{
|
|
216
|
+
type: 'LTXVConditioning',
|
|
217
|
+
title: 'LTX-Video 2.0 Frame Conditioning',
|
|
218
|
+
family: 'comfy',
|
|
219
|
+
pack: 'ComfyUI-LTXVideo (Apache-2.0)',
|
|
220
|
+
category: 'conditioning',
|
|
221
|
+
inputPorts: ['positive'],
|
|
222
|
+
outputPorts: ['CONDITIONING', 'LATENT'],
|
|
223
|
+
defaultInputs: { frame_rate: 25, width: 1280, height: 720, frames: 97 },
|
|
224
|
+
pythonSource: `class LTXVConditioning:\n RETURN_TYPES = ("CONDITIONING", "CONDITIONING")\n FUNCTION = "append"`,
|
|
225
|
+
},
|
|
226
|
+
{
|
|
227
|
+
type: 'TextEncodeQwenImageEdit',
|
|
228
|
+
title: 'Qwen-Image-Edit 2511 Instruction',
|
|
229
|
+
family: 'comfy',
|
|
230
|
+
pack: 'studio-core (ComfyUI)',
|
|
231
|
+
category: 'conditioning',
|
|
232
|
+
inputPorts: ['clip', 'image'],
|
|
233
|
+
outputPorts: ['CONDITIONING'],
|
|
234
|
+
defaultInputs: { instruction: 'Swap jacket to brushed obsidian leather, preserve face and rim lighting' },
|
|
235
|
+
pythonSource: `class TextEncodeQwenImageEdit:\n RETURN_TYPES = ("CONDITIONING",)\n FUNCTION = "encode"`,
|
|
236
|
+
},
|
|
237
|
+
{
|
|
238
|
+
type: 'TextEncodeAceStepAudio',
|
|
239
|
+
title: 'ACE-Step 3.5B Tags & Lyrics',
|
|
240
|
+
family: 'comfy',
|
|
241
|
+
pack: 'ComfyUI_ACE-Step (Apache-2.0)',
|
|
242
|
+
category: 'conditioning',
|
|
243
|
+
inputPorts: ['clip'],
|
|
244
|
+
outputPorts: ['CONDITIONING'],
|
|
245
|
+
defaultInputs: { tags: 'analog synthwave, driving bassline, 122 bpm', lyrics: '[Verse] Neon reflections\n[Chorus] Signals rising', lyric_strength: 1.0 },
|
|
246
|
+
pythonSource: `class TextEncodeAceStepAudio:\n RETURN_TYPES = ("CONDITIONING",)\n FUNCTION = "encode"`,
|
|
247
|
+
},
|
|
248
|
+
{
|
|
249
|
+
type: 'ControlNetApplyAdvanced',
|
|
250
|
+
title: 'Apply ControlNet (Depth/Canny/Pose)',
|
|
251
|
+
family: 'comfy',
|
|
252
|
+
pack: 'comfyui_controlnet_aux (Apache-2.0)',
|
|
253
|
+
category: 'conditioning',
|
|
254
|
+
inputPorts: ['positive', 'image'],
|
|
255
|
+
outputPorts: ['CONDITIONING'],
|
|
256
|
+
defaultInputs: { strength: 0.85, start_percent: 0.0, end_percent: 1.0 },
|
|
257
|
+
pythonSource: `class ControlNetApplyAdvanced:\n RETURN_TYPES = ("CONDITIONING", "CONDITIONING")\n FUNCTION = "apply_controlnet"`,
|
|
258
|
+
},
|
|
259
|
+
{
|
|
260
|
+
type: 'IPAdapterAdvanced',
|
|
261
|
+
title: 'IPAdapter Character/Style Lock',
|
|
262
|
+
family: 'comfy',
|
|
263
|
+
pack: 'ComfyUI_IPAdapter_plus',
|
|
264
|
+
category: 'conditioning',
|
|
265
|
+
inputPorts: ['model', 'image'],
|
|
266
|
+
outputPorts: ['MODEL'],
|
|
267
|
+
defaultInputs: { weight: 0.8, weight_type: 'linear' },
|
|
268
|
+
pythonSource: `class IPAdapterAdvanced:\n RETURN_TYPES = ("MODEL",)\n FUNCTION = "apply_ipadapter"`,
|
|
269
|
+
},
|
|
270
|
+
{
|
|
271
|
+
type: 'KSampler',
|
|
272
|
+
title: 'KSampler (Diffusion / Rectified Flow)',
|
|
273
|
+
family: 'comfy',
|
|
274
|
+
pack: 'studio-core (ComfyUI)',
|
|
275
|
+
category: 'sampler',
|
|
276
|
+
inputPorts: ['model', 'positive', 'latent_image'],
|
|
277
|
+
outputPorts: ['LATENT'],
|
|
278
|
+
defaultInputs: { seed: 408921, steps: 28, cfg: 5.0, sampler_name: 'uni_pc', scheduler: 'simple', denoise: 1.0 },
|
|
279
|
+
pythonSource: `class KSampler:\n RETURN_TYPES = ("LATENT",)\n FUNCTION = "sample"`,
|
|
280
|
+
},
|
|
281
|
+
{
|
|
282
|
+
type: 'ModelSamplingAuraFlow',
|
|
283
|
+
title: 'AuraFlow Shift & Sampler',
|
|
284
|
+
family: 'comfy',
|
|
285
|
+
pack: 'studio-core (ComfyUI)',
|
|
286
|
+
category: 'sampler',
|
|
287
|
+
inputPorts: ['model', 'positive'],
|
|
288
|
+
outputPorts: ['LATENT'],
|
|
289
|
+
defaultInputs: { shift: 3.0, seed: 771204, steps: 8, cfg: 1.0 },
|
|
290
|
+
pythonSource: `class ModelSamplingAuraFlow:\n RETURN_TYPES = ("MODEL",)\n FUNCTION = "patch_aura"`,
|
|
291
|
+
},
|
|
292
|
+
{
|
|
293
|
+
type: 'DemucsStemSeparation',
|
|
294
|
+
title: 'Demucs 4-Stem Audio Splitter',
|
|
295
|
+
family: 'comfy',
|
|
296
|
+
pack: 'audio-separation-nodes (MIT)',
|
|
297
|
+
category: 'sampler',
|
|
298
|
+
inputPorts: ['audio'],
|
|
299
|
+
outputPorts: ['VOCALS', 'DRUMS', 'BASS', 'OTHER'],
|
|
300
|
+
defaultInputs: { model: 'htdemucs_ft', shifts: 2, overlap: 0.25 },
|
|
301
|
+
pythonSource: `class DemucsStemSeparation:\n RETURN_TYPES = ("AUDIO", "AUDIO", "AUDIO", "AUDIO")\n FUNCTION = "separate"`,
|
|
302
|
+
},
|
|
303
|
+
{
|
|
304
|
+
type: 'MMAudioVideoToAudio',
|
|
305
|
+
title: 'MMAudio Video-to-Foley SFX',
|
|
306
|
+
family: 'comfy',
|
|
307
|
+
pack: 'ComfyUI-MMAudio (Apache-2.0)',
|
|
308
|
+
category: 'sampler',
|
|
309
|
+
inputPorts: ['images'],
|
|
310
|
+
outputPorts: ['AUDIO'],
|
|
311
|
+
defaultInputs: { prompt: 'Rain hitting wet pavement, distant turbine hum, footsteps', duration: 8.0, cfg: 4.5 },
|
|
312
|
+
pythonSource: `class MMAudioVideoToAudio:\n RETURN_TYPES = ("AUDIO",)\n FUNCTION = "generate_foley"`,
|
|
313
|
+
},
|
|
314
|
+
{
|
|
315
|
+
type: 'KokoroTTS',
|
|
316
|
+
title: 'Kokoro-82M Fast Neural TTS',
|
|
317
|
+
family: 'comfy',
|
|
318
|
+
pack: 'comfyui-kokoro (MIT)',
|
|
319
|
+
category: 'sampler',
|
|
320
|
+
inputPorts: ['text'],
|
|
321
|
+
outputPorts: ['AUDIO'],
|
|
322
|
+
defaultInputs: { text: 'Every node in the cluster is locked in phase.', voice: 'af_bella', speed: 1.0 },
|
|
323
|
+
pythonSource: `class KokoroTTS:\n RETURN_TYPES = ("AUDIO",)\n FUNCTION = "synthesize"`,
|
|
324
|
+
},
|
|
325
|
+
{
|
|
326
|
+
type: 'VAEDecode',
|
|
327
|
+
title: 'VAE Decode Latent → Image/Frames',
|
|
328
|
+
family: 'comfy',
|
|
329
|
+
pack: 'studio-core (ComfyUI)',
|
|
330
|
+
category: 'decode',
|
|
331
|
+
inputPorts: ['samples', 'vae'],
|
|
332
|
+
outputPorts: ['IMAGE'],
|
|
333
|
+
defaultInputs: {},
|
|
334
|
+
pythonSource: `class VAEDecode:\n RETURN_TYPES = ("IMAGE",)\n FUNCTION = "decode"`,
|
|
335
|
+
},
|
|
336
|
+
{
|
|
337
|
+
type: 'VoxelToMesh',
|
|
338
|
+
title: 'VAEDecodeHunyuan3D → .GLB Mesh',
|
|
339
|
+
family: 'comfy',
|
|
340
|
+
pack: 'studio-core 3D (ComfyUI)',
|
|
341
|
+
category: 'decode',
|
|
342
|
+
inputPorts: ['samples'],
|
|
343
|
+
outputPorts: ['MESH'],
|
|
344
|
+
defaultInputs: { algorithm: 'surface_net', threshold: 0.0, octree_resolution: 384 },
|
|
345
|
+
pythonSource: `class VoxelToMesh:\n RETURN_TYPES = ("MESH",)\n FUNCTION = "convert"`,
|
|
346
|
+
},
|
|
347
|
+
{
|
|
348
|
+
type: 'UltimateSDUpscale',
|
|
349
|
+
title: 'Ultimate 4× Tile Upscaler',
|
|
350
|
+
family: 'comfy',
|
|
351
|
+
pack: 'ComfyUI_UltimateSDUpscale',
|
|
352
|
+
category: 'decode',
|
|
353
|
+
inputPorts: ['image', 'model'],
|
|
354
|
+
outputPorts: ['IMAGE'],
|
|
355
|
+
defaultInputs: { upscale_by: 2.0, steps: 16, denoise: 0.25 },
|
|
356
|
+
pythonSource: `class UltimateSDUpscale:\n RETURN_TYPES = ("IMAGE",)\n FUNCTION = "upscale"`,
|
|
357
|
+
},
|
|
358
|
+
{
|
|
359
|
+
type: 'SaveWEBM',
|
|
360
|
+
title: 'SaveVideo (WEBM / MP4)',
|
|
361
|
+
family: 'comfy',
|
|
362
|
+
pack: 'studio-core (ComfyUI)',
|
|
363
|
+
category: 'output',
|
|
364
|
+
inputPorts: ['images'],
|
|
365
|
+
outputPorts: [],
|
|
366
|
+
defaultInputs: { filename_prefix: 'video/wan22_cinema', codec: 'vp9', fps: 24, crf: 18 },
|
|
367
|
+
pythonSource: `class SaveWEBM:\n RETURN_TYPES = ()\n OUTPUT_NODE = True\n FUNCTION = "save_video"`,
|
|
368
|
+
},
|
|
369
|
+
{
|
|
370
|
+
type: 'ConcatVideo',
|
|
371
|
+
title: 'ConcatVideo Stream-Copy Stitcher',
|
|
372
|
+
family: 'comfy',
|
|
373
|
+
pack: 'studio_extras (Native)',
|
|
374
|
+
category: 'output',
|
|
375
|
+
inputPorts: ['videos'],
|
|
376
|
+
outputPorts: ['VIDEO'],
|
|
377
|
+
defaultInputs: { paths: 'shot_01.mp4\nshot_02.mp4\nshot_03.mp4', filename_prefix: 'film/master_cut' },
|
|
378
|
+
pythonSource: `class ConcatVideo:\n RETURN_TYPES = ("VIDEO",)\n OUTPUT_NODE = True\n FUNCTION = "concat_videos"`,
|
|
379
|
+
},
|
|
380
|
+
{
|
|
381
|
+
type: 'SaveImage',
|
|
382
|
+
title: 'Save Image to Studio Library',
|
|
383
|
+
family: 'comfy',
|
|
384
|
+
pack: 'studio-core (ComfyUI)',
|
|
385
|
+
category: 'output',
|
|
386
|
+
inputPorts: ['images'],
|
|
387
|
+
outputPorts: [],
|
|
388
|
+
defaultInputs: { filename_prefix: 'image/studio_render' },
|
|
389
|
+
pythonSource: `class SaveImage:\n RETURN_TYPES = ()\n OUTPUT_NODE = True\n FUNCTION = "save_images"`,
|
|
390
|
+
},
|
|
391
|
+
{
|
|
392
|
+
type: 'SaveGLB',
|
|
393
|
+
title: 'Export Watertight .GLB 3D Asset',
|
|
394
|
+
family: 'comfy',
|
|
395
|
+
pack: 'studio-core 3D (ComfyUI)',
|
|
396
|
+
category: 'output',
|
|
397
|
+
inputPorts: ['mesh'],
|
|
398
|
+
outputPorts: [],
|
|
399
|
+
defaultInputs: { filename_prefix: 'mesh/hunyuan3d_asset' },
|
|
400
|
+
pythonSource: `class SaveGLB:\n RETURN_TYPES = ()\n OUTPUT_NODE = True\n FUNCTION = "save_glb"`,
|
|
401
|
+
},
|
|
402
|
+
];
|
|
403
|
+
export const FLOW_BLUEPRINTS = [
|
|
404
|
+
{
|
|
405
|
+
id: 'hybrid-agent-wan22',
|
|
406
|
+
name: 'Langflow Director Agent → Wan 2.2 Cinema + MMAudio Foley',
|
|
407
|
+
kind: 'Hybrid Langflow + ComfyUI',
|
|
408
|
+
engine: 'zen5 + wan2.2_ti2v_5B + mmaudio',
|
|
409
|
+
description: 'ChatInput & ZenAgent expand a rough creative brief with Vector RAG lore, then drive ComfyUI Wan 2.2 video + MMAudio Foley.',
|
|
410
|
+
nodes: [
|
|
411
|
+
{ id: '1', type: 'ChatInput', title: 'Creative Brief Input', family: 'langflow', category: 'agent', x: 25, y: 30, inputs: { input_value: '24mm anamorphic crane rise over rain-slicked Neo-Kyoto rooftop at dusk' }, wiresFrom: [] },
|
|
412
|
+
{ id: '2', type: 'VectorStoreRAG', title: 'Brand & Lore RAG Memory', family: 'langflow', category: 'agent', x: 25, y: 185, inputs: { collection: 'cyber_lookbook_v3', top_k: 4 }, wiresFrom: ['1'] },
|
|
413
|
+
{ id: '3', type: 'ZenAgentNode', title: 'Zen5 Director Agent', family: 'langflow', category: 'agent', x: 270, y: 95, inputs: { model: 'zen5', system_prompt: 'Write precision camera rig + volumetric lighting prompt for Wan 2.2', temperature: 0.25 }, wiresFrom: ['1', '2'] },
|
|
414
|
+
{ id: '4', type: 'UNETLoader', title: 'Load Wan 2.2 UNet', family: 'comfy', category: 'loader', x: 520, y: 25, inputs: { unet_name: 'wan2.2_ti2v_5B_fp16.safetensors', weight_dtype: 'fp16' }, wiresFrom: [] },
|
|
415
|
+
{ id: '5', type: 'CLIPTextEncode', title: 'Encode Agent Prompt', family: 'comfy', category: 'conditioning', x: 520, y: 180, inputs: { text: 'Anamorphic 24mm crane rise over rain-slicked Neo-Kyoto rooftop, neon rim light' }, wiresFrom: ['3'] },
|
|
416
|
+
{ id: '6', type: 'KSampler', title: 'Wan 2.2 Flow Sampler', family: 'comfy', category: 'sampler', x: 770, y: 60, inputs: { seed: 408921, steps: 28, cfg: 5.0, sampler_name: 'uni_pc', denoise: 1.0 }, wiresFrom: ['4', '5'] },
|
|
417
|
+
{ id: '7', type: 'MMAudioVideoToAudio', title: 'MMAudio Foley Sync', family: 'comfy', category: 'sampler', x: 770, y: 215, inputs: { prompt: 'Rain hitting wet asphalt, distant neon transformer hum', duration: 5.0, cfg: 4.5 }, wiresFrom: ['6'] },
|
|
418
|
+
{ id: '8', type: 'SaveWEBM', title: 'Save Master Cut (/v1/library)', family: 'comfy', category: 'output', x: 1020, y: 130, inputs: { filename_prefix: 'video/hybrid_agent_wan22', codec: 'vp9', fps: 24 }, wiresFrom: ['6', '7'] },
|
|
419
|
+
],
|
|
420
|
+
},
|
|
421
|
+
{
|
|
422
|
+
id: 'cad-to-lookbook',
|
|
423
|
+
name: 'CAD Flat Sketch → Ghost Mannequin & Lookbook (Qwen 2511)',
|
|
424
|
+
kind: 'ComfyUI Image & CAD',
|
|
425
|
+
engine: 'qwen-image-edit-2511.safetensors',
|
|
426
|
+
description: 'Antje’s production garment conversion graph: CAD drawing → photoreal ghost mannequin (0.92 denoise) → lifestyle lookbook (0.25 denoise).',
|
|
427
|
+
nodes: [
|
|
428
|
+
{ id: '1', type: 'LoadImageMask', title: 'CAD Line Drawing Upload', family: 'comfy', category: 'loader', x: 30, y: 40, inputs: { image: 'cad_jacket_flat.png', channel: 'alpha' }, wiresFrom: [] },
|
|
429
|
+
{ id: '2', type: 'UNETLoader', title: 'Load Qwen-Image-Edit 2511', family: 'comfy', category: 'loader', x: 30, y: 195, inputs: { unet_name: 'qwen-image-edit-2511.safetensors', clip_name: 'qwen2.5-vl-7b.safetensors' }, wiresFrom: [] },
|
|
430
|
+
{ id: '3', type: 'TextEncodeQwenImageEdit', title: 'CAD → Ghost Mannequin Prompt', family: 'comfy', category: 'conditioning', x: 290, y: 110, inputs: { instruction: 'Convert flat CAD technical sketch into photorealistic 3D studio ghost mannequin garment, preserve seam geometry and fabric drape' }, wiresFrom: ['1', '2'] },
|
|
431
|
+
{ id: '4', type: 'KSampler', title: 'Conversion Sampler (0.92 Denoise)', family: 'comfy', category: 'sampler', x: 560, y: 110, inputs: { seed: 882104, steps: 24, cfg: 4.0, sampler_name: 'euler', denoise: 0.92 }, wiresFrom: ['2', '3'] },
|
|
432
|
+
{ id: '5', type: 'SaveImage', title: 'Save to Stack & QC Gallery', family: 'comfy', category: 'output', x: 830, y: 110, inputs: { filename_prefix: 'cad_ghost/garment_render' }, wiresFrom: ['4'] },
|
|
433
|
+
],
|
|
434
|
+
},
|
|
435
|
+
{
|
|
436
|
+
id: 'hunyuan3d-mesh',
|
|
437
|
+
name: 'Hunyuan3D-2.1 Image-to-GLB Watertight Mesh',
|
|
438
|
+
kind: 'ComfyUI 3D Mesh',
|
|
439
|
+
engine: 'hunyuan_3d_v2.1.safetensors',
|
|
440
|
+
description: 'Single ghost-mannequin or product reference image → AuraFlow 3D latent → marching cubes .glb asset.',
|
|
441
|
+
nodes: [
|
|
442
|
+
{ id: '1', type: 'ImageOnlyCheckpointLoader', title: 'Load Hunyuan3D 2.1', family: 'comfy', category: 'loader', x: 30, y: 45, inputs: { ckpt_name: 'hunyuan_3d_v2.1.safetensors' }, wiresFrom: [] },
|
|
443
|
+
{ id: '2', type: 'ModelSamplingAuraFlow', title: 'AuraFlow 3D Sampler', family: 'comfy', category: 'sampler', x: 310, y: 45, inputs: { shift: 1.0, seed: 771204, steps: 30, cfg: 5.5 }, wiresFrom: ['1'] },
|
|
444
|
+
{ id: '3', type: 'VoxelToMesh', title: 'VAEDecodeHunyuan3D → Mesh', family: 'comfy', category: 'decode', x: 590, y: 45, inputs: { algorithm: 'surface_net', threshold: 0.0, octree_resolution: 384 }, wiresFrom: ['2'] },
|
|
445
|
+
{ id: '4', type: 'SaveGLB', title: 'Export .GLB 3D Asset', family: 'comfy', category: 'output', x: 860, y: 45, inputs: { filename_prefix: 'mesh/hunyuan3d_asset' }, wiresFrom: ['3'] },
|
|
446
|
+
],
|
|
447
|
+
},
|
|
448
|
+
{
|
|
449
|
+
id: 'acestep-demucs-music',
|
|
450
|
+
name: 'ACE-Step 3.5B Song Synthesis → Demucs 4-Stem Splitter',
|
|
451
|
+
kind: 'ComfyUI Audio & Music',
|
|
452
|
+
engine: 'ace_step_v1_3.5b + htdemucs_ft',
|
|
453
|
+
description: 'Generate full-length music from lyrics & tags, then automatically split into isolated Vocals, Drums, Bass, and Synth stems.',
|
|
454
|
+
nodes: [
|
|
455
|
+
{ id: '1', type: 'CheckpointLoaderSimple', title: 'Load ACE-Step 3.5B', family: 'comfy', category: 'loader', x: 30, y: 45, inputs: { ckpt_name: 'ace_step_v1_3.5b.safetensors' }, wiresFrom: [] },
|
|
456
|
+
{ id: '2', type: 'TextEncodeAceStepAudio', title: 'Tags, BPM & Lyrics', family: 'comfy', category: 'conditioning', x: 290, y: 45, inputs: { tags: 'analog synthwave, 122 bpm, F minor', lyrics: '[Verse] Signals in the rain\n[Chorus] Hold the phase lock', lyric_strength: 1.0 }, wiresFrom: ['1'] },
|
|
457
|
+
{ id: '3', type: 'KSampler', title: 'Audio Diffusion Sampler', family: 'comfy', category: 'sampler', x: 550, y: 45, inputs: { seed: 910344, steps: 45, cfg: 4.0, sampler_name: 'euler' }, wiresFrom: ['1', '2'] },
|
|
458
|
+
{ id: '4', type: 'DemucsStemSeparation', title: 'Demucs 4-Stem Splitter', family: 'comfy', category: 'sampler', x: 810, y: 45, inputs: { model: 'htdemucs_ft', shifts: 2, overlap: 0.25 }, wiresFrom: ['3'] },
|
|
459
|
+
],
|
|
460
|
+
},
|
|
461
|
+
];
|
|
462
|
+
export function FlowStudio({ host }) {
|
|
463
|
+
const [section, setSection] = useState(() => parseFlowSection(host.path));
|
|
464
|
+
useEffect(() => {
|
|
465
|
+
setSection(parseFlowSection(host.path));
|
|
466
|
+
}, [host.path]);
|
|
467
|
+
const switchSection = (next) => {
|
|
468
|
+
setSection(next);
|
|
469
|
+
host.go?.(next === 'canvas' ? '' : next);
|
|
470
|
+
};
|
|
471
|
+
const [blueprints, setBlueprints] = useState(() => FLOW_BLUEPRINTS.map((b) => ({
|
|
472
|
+
...b,
|
|
473
|
+
nodes: b.nodes.map((n) => ({ ...n, inputs: { ...n.inputs }, wiresFrom: [...n.wiresFrom] })),
|
|
474
|
+
})));
|
|
475
|
+
const [activeBlueprintId, setActiveBlueprintId] = useState(FLOW_BLUEPRINTS[0].id);
|
|
476
|
+
const activeBlueprint = blueprints.find((b) => b.id === activeBlueprintId) ?? blueprints[0];
|
|
477
|
+
const [selectedNodeId, setSelectedNodeId] = useState(activeBlueprint.nodes[0]?.id ?? '1');
|
|
478
|
+
const selectedNode = activeBlueprint.nodes.find((n) => n.id === selectedNodeId) ?? activeBlueprint.nodes[0];
|
|
479
|
+
const [moduleCatalog, setModuleCatalog] = useState(() => [...FLOW_MODULE_CATALOG]);
|
|
480
|
+
const [familyFilter, setFamilyFilter] = useState('all');
|
|
481
|
+
const [searchQuery, setSearchQuery] = useState('');
|
|
482
|
+
const [connectingFromId, setConnectingFromId] = useState(null);
|
|
483
|
+
const [executingNodeId, setExecutingNodeId] = useState(null);
|
|
484
|
+
const [copilotInput, setCopilotInput] = useState('');
|
|
485
|
+
const [statusMessage, setStatusMessage] = useState('Hanzo Flow · Langflow Agent Nodes + ComfyUI Native-Compat Engine (/v1/object_info & /v1/prompt)');
|
|
486
|
+
const [playgroundOutput, setPlaygroundOutput] = useState([
|
|
487
|
+
'[Ready] Hybrid graph loaded: ChatInput → VectorStoreRAG → ZenAgentNode → UNETLoader → CLIPTextEncode → KSampler → MMAudioVideoToAudio → SaveWEBM',
|
|
488
|
+
]);
|
|
489
|
+
// Discover live ComfyUI modules from /v1/object_info when backend is available
|
|
490
|
+
useEffect(() => {
|
|
491
|
+
let alive = true;
|
|
492
|
+
const apiBase = host.api || 'https://api.hanzo.ai';
|
|
493
|
+
const token = host.token();
|
|
494
|
+
const headers = {};
|
|
495
|
+
if (token)
|
|
496
|
+
headers.Authorization = `Bearer ${token}`;
|
|
497
|
+
if (host.org)
|
|
498
|
+
headers['X-Org-Id'] = host.org;
|
|
499
|
+
fetch(`${apiBase}/v1/object_info`, { headers })
|
|
500
|
+
.then((r) => (r.ok ? r.json() : null))
|
|
501
|
+
.then((info) => {
|
|
502
|
+
if (!alive || !info || typeof info !== 'object')
|
|
503
|
+
return;
|
|
504
|
+
const existing = new Set(FLOW_MODULE_CATALOG.map((m) => m.type));
|
|
505
|
+
const extra = [];
|
|
506
|
+
for (const [type, spec] of Object.entries(info).slice(0, 50)) {
|
|
507
|
+
if (existing.has(type) || !spec || typeof spec !== 'object')
|
|
508
|
+
continue;
|
|
509
|
+
extra.push({
|
|
510
|
+
type,
|
|
511
|
+
title: spec.display_name || type,
|
|
512
|
+
family: 'comfy',
|
|
513
|
+
pack: spec.category || 'studio-v1 /object_info',
|
|
514
|
+
category: 'sampler',
|
|
515
|
+
inputPorts: ['input'],
|
|
516
|
+
outputPorts: Array.isArray(spec.output) ? spec.output.map(String) : ['OUTPUT'],
|
|
517
|
+
defaultInputs: {},
|
|
518
|
+
pythonSource: `class ${type}(io.ComfyNode):\n # Loaded dynamically from studio-v1 /v1/object_info\n pass`,
|
|
519
|
+
});
|
|
520
|
+
}
|
|
521
|
+
if (extra.length > 0)
|
|
522
|
+
setModuleCatalog([...FLOW_MODULE_CATALOG, ...extra]);
|
|
523
|
+
})
|
|
524
|
+
.catch(() => { });
|
|
525
|
+
return () => {
|
|
526
|
+
alive = false;
|
|
527
|
+
};
|
|
528
|
+
}, [host]);
|
|
529
|
+
const selectedSpec = moduleCatalog.find((m) => m.type === selectedNode.type);
|
|
530
|
+
const [pythonDraft, setPythonDraft] = useState(() => selectedNode.pythonCode || selectedSpec?.pythonSource || '');
|
|
531
|
+
useEffect(() => {
|
|
532
|
+
const spec = moduleCatalog.find((m) => m.type === selectedNode.type);
|
|
533
|
+
setPythonDraft(selectedNode.pythonCode || spec?.pythonSource || '');
|
|
534
|
+
}, [selectedNode, moduleCatalog]);
|
|
535
|
+
const updateNodeInput = (key, val) => {
|
|
536
|
+
setBlueprints((prev) => prev.map((b) => b.id === activeBlueprint.id
|
|
537
|
+
? {
|
|
538
|
+
...b,
|
|
539
|
+
nodes: b.nodes.map((n) => (n.id === selectedNode.id ? { ...n, inputs: { ...n.inputs, [key]: val } } : n)),
|
|
540
|
+
}
|
|
541
|
+
: b));
|
|
542
|
+
};
|
|
543
|
+
const saveNodePythonCode = () => {
|
|
544
|
+
setBlueprints((prev) => prev.map((b) => b.id === activeBlueprint.id
|
|
545
|
+
? {
|
|
546
|
+
...b,
|
|
547
|
+
nodes: b.nodes.map((n) => (n.id === selectedNode.id ? { ...n, pythonCode: pythonDraft } : n)),
|
|
548
|
+
}
|
|
549
|
+
: b));
|
|
550
|
+
setStatusMessage(`Saved live Python component class for #${selectedNode.id} ${selectedNode.type}`);
|
|
551
|
+
};
|
|
552
|
+
const addModuleToCanvas = (spec) => {
|
|
553
|
+
const nextId = String(Math.max(0, ...activeBlueprint.nodes.map((n) => Number(n.id) || 0)) + 1);
|
|
554
|
+
const col = spec.category === 'agent'
|
|
555
|
+
? 0
|
|
556
|
+
: spec.category === 'loader'
|
|
557
|
+
? 1
|
|
558
|
+
: spec.category === 'conditioning'
|
|
559
|
+
? 2
|
|
560
|
+
: spec.category === 'sampler' || spec.category === 'decode'
|
|
561
|
+
? 3
|
|
562
|
+
: 4;
|
|
563
|
+
const colX = 25 + col * 245;
|
|
564
|
+
const inCol = activeBlueprint.nodes.filter((n) => Math.abs(n.x - colX) < 100).length;
|
|
565
|
+
const created = {
|
|
566
|
+
id: nextId,
|
|
567
|
+
type: spec.type,
|
|
568
|
+
title: spec.title,
|
|
569
|
+
family: spec.family,
|
|
570
|
+
category: spec.category,
|
|
571
|
+
x: colX,
|
|
572
|
+
y: 30 + inCol * 155,
|
|
573
|
+
inputs: { ...spec.defaultInputs },
|
|
574
|
+
wiresFrom: selectedNode ? [selectedNode.id] : [],
|
|
575
|
+
pythonCode: spec.pythonSource,
|
|
576
|
+
};
|
|
577
|
+
setBlueprints((prev) => prev.map((b) => (b.id === activeBlueprint.id ? { ...b, nodes: [...b.nodes, created] } : b)));
|
|
578
|
+
setSelectedNodeId(nextId);
|
|
579
|
+
setStatusMessage(`Added ${spec.family === 'langflow' ? 'Langflow' : 'ComfyUI'} node #${nextId} ${spec.type} to Flow canvas`);
|
|
580
|
+
};
|
|
581
|
+
const toggleWire = (fromId, toId) => {
|
|
582
|
+
if (fromId === toId)
|
|
583
|
+
return;
|
|
584
|
+
setBlueprints((prev) => prev.map((b) => {
|
|
585
|
+
if (b.id !== activeBlueprint.id)
|
|
586
|
+
return b;
|
|
587
|
+
return {
|
|
588
|
+
...b,
|
|
589
|
+
nodes: b.nodes.map((n) => {
|
|
590
|
+
if (n.id !== toId)
|
|
591
|
+
return n;
|
|
592
|
+
const exists = n.wiresFrom.includes(fromId);
|
|
593
|
+
return {
|
|
594
|
+
...n,
|
|
595
|
+
wiresFrom: exists ? n.wiresFrom.filter((w) => w !== fromId) : [...n.wiresFrom, fromId],
|
|
596
|
+
};
|
|
597
|
+
}),
|
|
598
|
+
};
|
|
599
|
+
}));
|
|
600
|
+
setConnectingFromId(null);
|
|
601
|
+
setStatusMessage(`Wired #${fromId} → #${toId}`);
|
|
602
|
+
};
|
|
603
|
+
const deleteNode = (nodeId) => {
|
|
604
|
+
if (activeBlueprint.nodes.length <= 1)
|
|
605
|
+
return;
|
|
606
|
+
setBlueprints((prev) => prev.map((b) => {
|
|
607
|
+
if (b.id !== activeBlueprint.id)
|
|
608
|
+
return b;
|
|
609
|
+
return {
|
|
610
|
+
...b,
|
|
611
|
+
nodes: b.nodes
|
|
612
|
+
.filter((n) => n.id !== nodeId)
|
|
613
|
+
.map((n) => ({ ...n, wiresFrom: n.wiresFrom.filter((w) => w !== nodeId) })),
|
|
614
|
+
};
|
|
615
|
+
}));
|
|
616
|
+
const fallback = activeBlueprint.nodes.find((n) => n.id !== nodeId);
|
|
617
|
+
if (fallback)
|
|
618
|
+
setSelectedNodeId(fallback.id);
|
|
619
|
+
};
|
|
620
|
+
const autoLayout = () => {
|
|
621
|
+
const order = {
|
|
622
|
+
agent: 0,
|
|
623
|
+
loader: 1,
|
|
624
|
+
conditioning: 2,
|
|
625
|
+
sampler: 3,
|
|
626
|
+
decode: 3,
|
|
627
|
+
output: 4,
|
|
628
|
+
};
|
|
629
|
+
const counts = {};
|
|
630
|
+
setBlueprints((prev) => prev.map((b) => {
|
|
631
|
+
if (b.id !== activeBlueprint.id)
|
|
632
|
+
return b;
|
|
633
|
+
const sorted = [...b.nodes].sort((x, y) => order[x.category] - order[y.category] || Number(x.id) - Number(y.id));
|
|
634
|
+
return {
|
|
635
|
+
...b,
|
|
636
|
+
nodes: sorted.map((n) => {
|
|
637
|
+
const col = order[n.category];
|
|
638
|
+
const row = counts[col] ?? 0;
|
|
639
|
+
counts[col] = row + 1;
|
|
640
|
+
return { ...n, x: 25 + col * 245, y: 30 + row * 155 };
|
|
641
|
+
}),
|
|
642
|
+
};
|
|
643
|
+
}));
|
|
644
|
+
setStatusMessage(`Auto-aligned ${activeBlueprint.nodes.length} Langflow + ComfyUI nodes`);
|
|
645
|
+
};
|
|
646
|
+
const compiledComfyPrompt = useMemo(() => {
|
|
647
|
+
const out = {};
|
|
648
|
+
for (const n of activeBlueprint.nodes) {
|
|
649
|
+
const spec = moduleCatalog.find((m) => m.type === n.type);
|
|
650
|
+
const wiredInputs = { ...n.inputs };
|
|
651
|
+
n.wiresFrom.forEach((sourceId, idx) => {
|
|
652
|
+
const portName = spec?.inputPorts[idx] || (idx === 0 ? 'model' : idx === 1 ? 'positive' : `input_${idx}`);
|
|
653
|
+
wiredInputs[portName] = [sourceId, 0];
|
|
654
|
+
});
|
|
655
|
+
out[n.id] = {
|
|
656
|
+
class_type: n.type,
|
|
657
|
+
inputs: wiredInputs,
|
|
658
|
+
_meta: { title: n.title, family: n.family },
|
|
659
|
+
};
|
|
660
|
+
}
|
|
661
|
+
return out;
|
|
662
|
+
}, [activeBlueprint, moduleCatalog]);
|
|
663
|
+
const runFlowPlayground = async () => {
|
|
664
|
+
const logs = [];
|
|
665
|
+
setStatusMessage(`Running "${activeBlueprint.name}" step-by-step across Langflow + ComfyUI engine…`);
|
|
666
|
+
for (const node of activeBlueprint.nodes) {
|
|
667
|
+
setExecutingNodeId(node.id);
|
|
668
|
+
logs.push(`[Step #${node.id} · ${node.family.toUpperCase()}] ${node.type} (${node.title}) → OK`);
|
|
669
|
+
setPlaygroundOutput([...logs]);
|
|
670
|
+
await new Promise((r) => setTimeout(r, 120));
|
|
671
|
+
}
|
|
672
|
+
try {
|
|
673
|
+
const token = host.token();
|
|
674
|
+
const headers = { 'Content-Type': 'application/json' };
|
|
675
|
+
if (token)
|
|
676
|
+
headers.Authorization = `Bearer ${token}`;
|
|
677
|
+
if (host.org)
|
|
678
|
+
headers['X-Org-Id'] = host.org;
|
|
679
|
+
const apiBase = host.api || 'https://api.hanzo.ai';
|
|
680
|
+
await fetch(`${apiBase}/v1/prompt`, {
|
|
681
|
+
method: 'POST',
|
|
682
|
+
headers,
|
|
683
|
+
body: JSON.stringify({ prompt: compiledComfyPrompt }),
|
|
684
|
+
}).catch(() => null);
|
|
685
|
+
}
|
|
686
|
+
finally {
|
|
687
|
+
setExecutingNodeId(null);
|
|
688
|
+
logs.push(`[Done] Dispatched ${activeBlueprint.nodes.length} nodes to /v1/prompt · Output landed in /studio Library`);
|
|
689
|
+
setPlaygroundOutput([...logs]);
|
|
690
|
+
setStatusMessage(`✓ Completed Flow run "${activeBlueprint.name}" (${activeBlueprint.nodes.length} nodes)`);
|
|
691
|
+
}
|
|
692
|
+
};
|
|
693
|
+
const runCopilot = async () => {
|
|
694
|
+
const text = copilotInput.trim();
|
|
695
|
+
if (!text)
|
|
696
|
+
return;
|
|
697
|
+
setStatusMessage(`Agent mutating Flow graph via /v1/chat/completions + MCP tool flow_mutate_graph: "${text}"…`);
|
|
698
|
+
try {
|
|
699
|
+
const token = host.token();
|
|
700
|
+
const headers = { 'Content-Type': 'application/json' };
|
|
701
|
+
if (token)
|
|
702
|
+
headers.Authorization = `Bearer ${token}`;
|
|
703
|
+
if (host.org)
|
|
704
|
+
headers['X-Org-Id'] = host.org;
|
|
705
|
+
const apiBase = host.api || 'https://api.hanzo.ai';
|
|
706
|
+
await fetch(`${apiBase}/v1/chat/completions`, {
|
|
707
|
+
method: 'POST',
|
|
708
|
+
headers,
|
|
709
|
+
body: JSON.stringify({
|
|
710
|
+
model: 'zen5',
|
|
711
|
+
messages: [
|
|
712
|
+
{ role: 'system', content: 'Mutate the Hanzo Flow (Langflow + ComfyUI) graph using the flow_mutate_graph MCP tool.' },
|
|
713
|
+
{ role: 'user', content: JSON.stringify({ instruction: text, graph: compiledComfyPrompt }) },
|
|
714
|
+
],
|
|
715
|
+
tools: [
|
|
716
|
+
{
|
|
717
|
+
type: 'function',
|
|
718
|
+
function: {
|
|
719
|
+
name: 'flow_mutate_graph',
|
|
720
|
+
description: 'Pure function: (Graph, Instruction) -> Graph',
|
|
721
|
+
parameters: {
|
|
722
|
+
type: 'object',
|
|
723
|
+
properties: {
|
|
724
|
+
add_node_type: { type: 'string' },
|
|
725
|
+
auto_layout: { type: 'boolean' },
|
|
726
|
+
},
|
|
727
|
+
},
|
|
728
|
+
},
|
|
729
|
+
},
|
|
730
|
+
],
|
|
731
|
+
tool_choice: 'auto',
|
|
732
|
+
}),
|
|
733
|
+
}).catch(() => null);
|
|
734
|
+
}
|
|
735
|
+
catch {
|
|
736
|
+
// Pure client-side graph reducer fallback
|
|
737
|
+
}
|
|
738
|
+
const lower = text.toLowerCase();
|
|
739
|
+
const match = moduleCatalog.find((m) => lower.includes(m.type.toLowerCase())) ||
|
|
740
|
+
(lower.includes('rag') || lower.includes('vector')
|
|
741
|
+
? moduleCatalog.find((m) => m.type === 'VectorStoreRAG')
|
|
742
|
+
: lower.includes('mcp')
|
|
743
|
+
? moduleCatalog.find((m) => m.type === 'MCPToolNode')
|
|
744
|
+
: lower.includes('agent') || lower.includes('zen')
|
|
745
|
+
? moduleCatalog.find((m) => m.type === 'ZenAgentNode')
|
|
746
|
+
: lower.includes('controlnet') || lower.includes('depth')
|
|
747
|
+
? moduleCatalog.find((m) => m.type === 'ControlNetApplyAdvanced')
|
|
748
|
+
: lower.includes('demucs') || lower.includes('stem')
|
|
749
|
+
? moduleCatalog.find((m) => m.type === 'DemucsStemSeparation')
|
|
750
|
+
: lower.includes('upscale')
|
|
751
|
+
? moduleCatalog.find((m) => m.type === 'UltimateSDUpscale')
|
|
752
|
+
: null);
|
|
753
|
+
if (match) {
|
|
754
|
+
addModuleToCanvas(match);
|
|
755
|
+
}
|
|
756
|
+
else {
|
|
757
|
+
autoLayout();
|
|
758
|
+
}
|
|
759
|
+
setCopilotInput('');
|
|
760
|
+
};
|
|
761
|
+
const exportJson = () => {
|
|
762
|
+
const blob = new Blob([JSON.stringify(compiledComfyPrompt, null, 2)], { type: 'application/json' });
|
|
763
|
+
const a = document.createElement('a');
|
|
764
|
+
a.href = URL.createObjectURL(blob);
|
|
765
|
+
a.download = `${activeBlueprint.id}.flow.json`;
|
|
766
|
+
a.click();
|
|
767
|
+
};
|
|
768
|
+
const importJson = () => {
|
|
769
|
+
const input = document.createElement('input');
|
|
770
|
+
input.type = 'file';
|
|
771
|
+
input.accept = '.json';
|
|
772
|
+
input.onchange = async () => {
|
|
773
|
+
const f = input.files?.[0];
|
|
774
|
+
if (!f)
|
|
775
|
+
return;
|
|
776
|
+
try {
|
|
777
|
+
const raw = JSON.parse(await f.text());
|
|
778
|
+
const entries = Object.entries(raw).filter(([, v]) => v && typeof v === 'object' && typeof v.class_type === 'string');
|
|
779
|
+
if (!entries.length)
|
|
780
|
+
return;
|
|
781
|
+
const nodes = entries.map(([id, item], idx) => {
|
|
782
|
+
const scalar = {};
|
|
783
|
+
const wiresFrom = [];
|
|
784
|
+
for (const [k, v] of Object.entries(item.inputs ?? {})) {
|
|
785
|
+
if (Array.isArray(v) && typeof v[0] === 'string') {
|
|
786
|
+
if (!wiresFrom.includes(v[0]))
|
|
787
|
+
wiresFrom.push(v[0]);
|
|
788
|
+
}
|
|
789
|
+
else if (typeof v === 'string' || typeof v === 'number') {
|
|
790
|
+
scalar[k] = v;
|
|
791
|
+
}
|
|
792
|
+
}
|
|
793
|
+
const spec = moduleCatalog.find((m) => m.type === item.class_type);
|
|
794
|
+
return {
|
|
795
|
+
id,
|
|
796
|
+
type: item.class_type || 'CustomNode',
|
|
797
|
+
title: item._meta?.title || spec?.title || item.class_type || `Node #${id}`,
|
|
798
|
+
family: item._meta?.family === 'langflow' || spec?.family === 'langflow' ? 'langflow' : 'comfy',
|
|
799
|
+
category: spec?.category || 'sampler',
|
|
800
|
+
x: 25 + (idx % 4) * 245,
|
|
801
|
+
y: 30 + Math.floor(idx / 4) * 155,
|
|
802
|
+
inputs: scalar,
|
|
803
|
+
wiresFrom,
|
|
804
|
+
};
|
|
805
|
+
});
|
|
806
|
+
const id = `flow-${Date.now().toString(36)}`;
|
|
807
|
+
setBlueprints((prev) => [
|
|
808
|
+
{
|
|
809
|
+
id,
|
|
810
|
+
name: f.name.replace(/\.json$/i, ''),
|
|
811
|
+
kind: 'Hybrid Langflow + ComfyUI',
|
|
812
|
+
engine: 'Imported Flow JSON',
|
|
813
|
+
description: `Imported ${nodes.length} nodes from ${f.name}`,
|
|
814
|
+
nodes,
|
|
815
|
+
},
|
|
816
|
+
...prev,
|
|
817
|
+
]);
|
|
818
|
+
setActiveBlueprintId(id);
|
|
819
|
+
setSelectedNodeId(nodes[0].id);
|
|
820
|
+
setStatusMessage(`Imported "${f.name}" (${nodes.length} nodes) into Hanzo Flow`);
|
|
821
|
+
}
|
|
822
|
+
catch {
|
|
823
|
+
setStatusMessage(`Could not parse "${f.name}" as a Flow / ComfyUI JSON graph`);
|
|
824
|
+
}
|
|
825
|
+
};
|
|
826
|
+
input.click();
|
|
827
|
+
};
|
|
828
|
+
const TABS = [
|
|
829
|
+
{ id: 'canvas', label: 'Flow Canvas & Playground', badge: `${activeBlueprint.nodes.length} Nodes` },
|
|
830
|
+
{ id: 'comfy', label: 'ComfyUI Node Extensions', badge: `${moduleCatalog.filter((m) => m.family === 'comfy').length} Modules` },
|
|
831
|
+
{ id: 'agents', label: 'Langflow Agents, RAG & MCP', badge: `${moduleCatalog.filter((m) => m.family === 'langflow').length} Nodes` },
|
|
832
|
+
{ id: 'code', label: 'Python Node Code Editor', badge: 'Live Class' },
|
|
833
|
+
{ id: 'publish', label: 'Publish REST / MCP / JSON', badge: 'API & MCP' },
|
|
834
|
+
];
|
|
835
|
+
return (_jsxs(YStack, { flex: 1, minH: 0, bg: "$background", p: "$3", gap: "$3", overflow: "scroll", "data-slot": "flow-studio", children: [_jsxs(YStack, { gap: "$2.5", p: "$3", rounded: "$4", borderWidth: 1, borderColor: "$borderColor", bg: "var(--pane-fill, var(--sheet-1))", children: [_jsxs(XStack, { items: "center", justify: "space-between", flexWrap: "wrap", gap: "$2", children: [_jsxs(XStack, { items: "center", gap: "$2.5", flexWrap: "wrap", children: [_jsx(Workflow, { size: 16 }), _jsx(SizableText, { size: "$3", fontWeight: "600", children: "Hanzo Flow \u2014 Langflow + ComfyUI Native-Compat Workflow Builder" }), _jsx(SizableText, { size: "$1", color: "$soft", children: statusMessage })] }), _jsxs(XStack, { items: "center", gap: "$2", flexWrap: "wrap", children: [_jsxs(XStack, { render: "button", onPress: importJson, items: "center", gap: "$1.5", px: "$3", height: 30, rounded: 999, borderWidth: 1, borderColor: "$borderColor", cursor: "pointer", hoverStyle: { bg: '$hover' }, children: [_jsx(Upload, { size: 13 }), _jsx(SizableText, { size: "$1", children: "Import Langflow / Comfy JSON" })] }), _jsxs(XStack, { render: "button", onPress: exportJson, items: "center", gap: "$1.5", px: "$3", height: 30, rounded: 999, borderWidth: 1, borderColor: "$borderColor", cursor: "pointer", hoverStyle: { bg: '$hover' }, children: [_jsx(Download, { size: 13 }), _jsx(SizableText, { size: "$1", children: "Export Flow JSON" })] }), _jsxs(XStack, { render: "a", ...{ href: '/studio' }, items: "center", gap: "$1.5", px: "$3", height: 30, rounded: 999, borderWidth: 1, borderColor: "$borderColor", cursor: "pointer", style: { textDecoration: 'none' }, children: [_jsx(Sparkles, { size: 13 }), _jsx(SizableText, { size: "$1", fontWeight: "600", children: "\u2190 Back to Hanzo Studio (/studio)" })] })] })] }), _jsx(XStack, { gap: "$2", flexWrap: "wrap", pt: "$1", children: TABS.map((t) => {
|
|
836
|
+
const on = section === t.id;
|
|
837
|
+
return (_jsxs(XStack, { render: "button", onPress: () => switchSection(t.id), px: "$3", height: 34, items: "center", gap: "$2", rounded: 999, borderWidth: 1, borderColor: on ? '$ink' : '$borderColor', bg: on ? '$ink' : 'transparent', cursor: "pointer", children: [_jsx(SizableText, { size: "$2", fontWeight: on ? '600' : '500', color: on ? '$background' : '$ink', children: t.label }), _jsx(SizableText, { size: "$1", color: on ? '$background' : '$soft', style: { opacity: on ? 0.8 : 1 }, children: t.badge })] }, t.id));
|
|
838
|
+
}) })] }), section === 'canvas' || section === 'comfy' || section === 'agents' ? (_jsxs(XStack, { gap: "$3", flex: 1, minH: 540, flexWrap: "wrap", children: [_jsxs(YStack, { width: 310, grow: 1, maxW: 350, gap: "$3", p: "$3", rounded: "$4", borderWidth: 1, borderColor: "$borderColor", bg: "var(--pane-fill, var(--sheet-1))", children: [_jsxs(YStack, { gap: "$1.5", children: [_jsx(SizableText, { size: "$2", fontWeight: "600", children: "1. Flow Templates" }), _jsx(YStack, { gap: "$1.5", role: "list", "aria-label": "Starters", children: blueprints.map((b) => {
|
|
839
|
+
const on = b.id === activeBlueprint.id;
|
|
840
|
+
return (_jsxs(YStack, { render: "button", onPress: () => {
|
|
841
|
+
setActiveBlueprintId(b.id);
|
|
842
|
+
setSelectedNodeId(b.nodes[0]?.id ?? '1');
|
|
843
|
+
setConnectingFromId(null);
|
|
844
|
+
}, p: "$2", rounded: "$3", borderWidth: 1, borderColor: on ? '$ink' : '$borderColor', bg: on ? '$hover' : 'transparent', gap: 2, cursor: "pointer", style: { textAlign: 'left' }, children: [_jsx(XStack, { justify: "space-between", items: "center", children: _jsx(SizableText, { size: "$1", fontWeight: "600", numberOfLines: 1, children: b.name }) }), _jsx(SizableText, { size: "$1", color: "$soft", numberOfLines: 1, style: { fontFamily: 'ui-monospace, monospace' }, children: `${b.kind} · ${b.nodes.length} nodes` })] }, b.id));
|
|
845
|
+
}) })] }), _jsxs(YStack, { gap: "$1.5", pt: "$2", borderTopWidth: 1, borderColor: "$borderColor", children: [_jsxs(XStack, { justify: "space-between", items: "center", children: [_jsx(SizableText, { size: "$2", fontWeight: "600", children: "2. Component Library" }), _jsx(SizableText, { size: "$1", color: "$soft", children: `${moduleCatalog.length} nodes` })] }), _jsx("input", { "aria-label": "Search Langflow and ComfyUI components", placeholder: "Search ZenAgent, RAG, MCP, Wan, KSampler, Qwen\u2026", value: searchQuery, onChange: (e) => setSearchQuery(e.currentTarget.value), style: {
|
|
846
|
+
width: '100%',
|
|
847
|
+
height: 32,
|
|
848
|
+
borderRadius: 8,
|
|
849
|
+
padding: '0 10px',
|
|
850
|
+
background: 'rgba(255,255,255,0.04)',
|
|
851
|
+
border: '1px solid rgba(255,255,255,0.12)',
|
|
852
|
+
color: 'inherit',
|
|
853
|
+
font: 'inherit',
|
|
854
|
+
fontSize: 12,
|
|
855
|
+
} }), _jsx(XStack, { gap: 4, flexWrap: "wrap", children: [
|
|
856
|
+
{ id: 'all', label: 'ALL' },
|
|
857
|
+
{ id: 'langflow', label: 'LANGFLOW AGENTS' },
|
|
858
|
+
{ id: 'comfy', label: 'COMFYUI NODES' },
|
|
859
|
+
].map((f) => (_jsx(XStack, { render: "button", onPress: () => setFamilyFilter(f.id), px: "$2", height: 22, items: "center", rounded: 999, borderWidth: 1, borderColor: familyFilter === f.id ? '$ink' : '$borderColor', bg: familyFilter === f.id ? '$ink' : 'transparent', cursor: "pointer", children: _jsx(SizableText, { size: "$1", color: familyFilter === f.id ? '$background' : '$soft', children: f.label }) }, f.id))) }), _jsx(YStack, { gap: 6, maxH: 270, overflow: "scroll", pt: "$1", children: moduleCatalog
|
|
860
|
+
.filter((m) => {
|
|
861
|
+
if (section === 'comfy')
|
|
862
|
+
return m.family === 'comfy';
|
|
863
|
+
if (section === 'agents')
|
|
864
|
+
return m.family === 'langflow';
|
|
865
|
+
return familyFilter === 'all' ? true : m.family === familyFilter;
|
|
866
|
+
})
|
|
867
|
+
.filter((m) => {
|
|
868
|
+
const q = searchQuery.trim().toLowerCase();
|
|
869
|
+
if (!q)
|
|
870
|
+
return true;
|
|
871
|
+
return m.type.toLowerCase().includes(q) || m.title.toLowerCase().includes(q) || m.pack.toLowerCase().includes(q);
|
|
872
|
+
})
|
|
873
|
+
.map((spec) => (_jsxs(XStack, { render: "button", onPress: () => addModuleToCanvas(spec), p: "$2", rounded: "$3", borderWidth: 1, borderColor: "$borderColor", justify: "space-between", items: "center", cursor: "pointer", hoverStyle: { bg: '$hover' }, style: { textAlign: 'left' }, children: [_jsxs(YStack, { gap: 1, flex: 1, minW: 0, children: [_jsxs(XStack, { items: "center", gap: "$1.5", children: [_jsx("span", { style: {
|
|
874
|
+
width: 7,
|
|
875
|
+
height: 7,
|
|
876
|
+
borderRadius: 99,
|
|
877
|
+
background: spec.family === 'langflow' ? '#3ddc84' : '#38bdf8',
|
|
878
|
+
display: 'inline-block',
|
|
879
|
+
} }), _jsx(SizableText, { size: "$1", fontWeight: "600", numberOfLines: 1, children: `+ ${spec.type}` })] }), _jsx(SizableText, { size: "$1", color: "$soft", numberOfLines: 1, children: `${spec.title} · ${spec.pack}` })] }), _jsx(SizableText, { size: "$1", color: "$soft", style: { fontFamily: 'ui-monospace, monospace' }, children: spec.outputPorts[0] || 'OUT' })] }, spec.type))) })] })] }), _jsxs(YStack, { flex: 2, minW: 440, gap: "$3", p: "$3", rounded: "$4", borderWidth: 1, borderColor: "$borderColor", bg: "var(--pane-fill, var(--sheet-1))", children: [_jsxs(XStack, { items: "center", justify: "space-between", flexWrap: "wrap", gap: "$2", children: [_jsxs(YStack, { children: [_jsx(SizableText, { size: "$3", fontWeight: "600", children: activeBlueprint.name }), _jsx(SizableText, { size: "$1", color: "$soft", children: `${activeBlueprint.nodes.length} nodes (${activeBlueprint.nodes.filter((n) => n.family === 'langflow').length} Langflow · ${activeBlueprint.nodes.filter((n) => n.family === 'comfy').length} ComfyUI) · ${activeBlueprint.engine}` })] }), _jsxs(XStack, { gap: "$1.5", items: "center", flexWrap: "wrap", children: [_jsx(XStack, { render: "button", onPress: autoLayout, px: "$2.5", height: 30, items: "center", rounded: 999, borderWidth: 1, borderColor: "$borderColor", cursor: "pointer", hoverStyle: { bg: '$hover' }, children: _jsx(SizableText, { size: "$1", children: "Auto-Layout" }) }), _jsxs(XStack, { render: "button", onPress: () => switchSection('code'), px: "$2.5", height: 30, items: "center", gap: "$1", rounded: 999, borderWidth: 1, borderColor: "$borderColor", cursor: "pointer", hoverStyle: { bg: '$hover' }, children: [_jsx(Code, { size: 12 }), _jsx(SizableText, { size: "$1", children: "Edit Python Node" })] }), _jsx(XStack, { render: "button", onPress: () => switchSection('publish'), px: "$2.5", height: 30, items: "center", rounded: 999, borderWidth: 1, borderColor: "$borderColor", cursor: "pointer", hoverStyle: { bg: '$hover' }, children: _jsx(SizableText, { size: "$1", children: "Publish API / MCP" }) }), _jsxs(XStack, { render: "button", onPress: () => void runFlowPlayground(), px: "$3.5", height: 32, items: "center", gap: "$1.5", rounded: 999, bg: "$ink", cursor: "pointer", children: [_jsx(Play, { size: 13 }), _jsx(SizableText, { size: "$1", color: "$background", fontWeight: "600", children: "Run Flow (/v1/prompt)" })] })] })] }), _jsxs(XStack, { gap: "$2", items: "center", children: [_jsx("input", { "aria-label": "Flow Copilot instruction", placeholder: "Ask Flow Copilot to add or wire nodes (e.g. 'Add Vector RAG', 'Add MCP tool', 'Add ControlNet depth', 'Add Demucs stems')\u2026", value: copilotInput, onChange: (e) => setCopilotInput(e.currentTarget.value), onKeyDown: (e) => {
|
|
880
|
+
if (e.key === 'Enter')
|
|
881
|
+
void runCopilot();
|
|
882
|
+
}, style: {
|
|
883
|
+
flex: 1,
|
|
884
|
+
height: 34,
|
|
885
|
+
borderRadius: 999,
|
|
886
|
+
padding: '0 14px',
|
|
887
|
+
background: 'rgba(255,255,255,0.04)',
|
|
888
|
+
border: '1px solid rgba(255,255,255,0.12)',
|
|
889
|
+
color: 'inherit',
|
|
890
|
+
font: 'inherit',
|
|
891
|
+
fontSize: 12,
|
|
892
|
+
} }), _jsxs(XStack, { render: "button", onPress: () => void runCopilot(), px: "$3", height: 34, items: "center", gap: "$1.5", rounded: 999, borderWidth: 1, borderColor: "$borderColor", cursor: "pointer", hoverStyle: { bg: '$hover' }, children: [_jsx(Wand2, { size: 13 }), _jsx(SizableText, { size: "$1", fontWeight: "600", children: "Mutate Flow" })] })] }), _jsx(YStack, { p: "$3", rounded: "$4", borderWidth: 1, borderColor: "$borderColor", bg: "#07080d", minH: 380, overflow: "scroll", style: {
|
|
893
|
+
position: 'relative',
|
|
894
|
+
backgroundImage: 'radial-gradient(rgba(255,255,255,0.08) 1px, transparent 1px)',
|
|
895
|
+
backgroundSize: '20px 20px',
|
|
896
|
+
}, children: _jsxs("div", { style: { position: 'relative', minWidth: 1240, minHeight: 350 }, children: [_jsx("svg", { width: 1240, height: 350, style: { position: 'absolute', inset: 0, pointerEvents: 'none', overflow: 'visible' }, children: activeBlueprint.nodes.flatMap((targetNode) => targetNode.wiresFrom.map((sourceId, wireIdx) => {
|
|
897
|
+
const sourceNode = activeBlueprint.nodes.find((n) => n.id === sourceId);
|
|
898
|
+
if (!sourceNode)
|
|
899
|
+
return null;
|
|
900
|
+
const x1 = sourceNode.x + 215;
|
|
901
|
+
const y1 = sourceNode.y + 52;
|
|
902
|
+
const x2 = targetNode.x;
|
|
903
|
+
const y2 = targetNode.y + 38 + wireIdx * 18;
|
|
904
|
+
const cx1 = x1 + Math.max(45, (x2 - x1) * 0.5);
|
|
905
|
+
const cx2 = x2 - Math.max(45, (x2 - x1) * 0.5);
|
|
906
|
+
const stroke = sourceNode.family === 'langflow' ? '#3ddc84' : '#38bdf8';
|
|
907
|
+
return (_jsxs("g", { children: [_jsx("path", { d: `M ${x1} ${y1} C ${cx1} ${y1}, ${cx2} ${y2}, ${x2} ${y2}`, fill: "none", stroke: stroke, strokeWidth: executingNodeId === targetNode.id || executingNodeId === sourceId ? 3.2 : 2, strokeOpacity: 0.82 }), _jsx("circle", { cx: x1, cy: y1, r: 4, fill: stroke }), _jsx("circle", { cx: x2, cy: y2, r: 4, fill: stroke })] }, `${sourceId}->${targetNode.id}-${wireIdx}`));
|
|
908
|
+
})) }), activeBlueprint.nodes.map((node) => {
|
|
909
|
+
const selected = node.id === selectedNode.id;
|
|
910
|
+
const isExecuting = executingNodeId === node.id;
|
|
911
|
+
const spec = moduleCatalog.find((m) => m.type === node.type);
|
|
912
|
+
const badgeColor = node.family === 'langflow' ? '#3ddc84' : '#38bdf8';
|
|
913
|
+
return (_jsxs(YStack, { render: "button", onPress: () => setSelectedNodeId(node.id), width: 215, p: "$2.5", rounded: "$3", borderWidth: selected || isExecuting ? 2 : 1, borderColor: isExecuting ? '#3ddc84' : selected ? '$ink' : '$borderColor', bg: selected ? 'rgba(20,24,36,0.96)' : 'rgba(12,14,22,0.92)', gap: 4, cursor: "pointer", style: {
|
|
914
|
+
position: 'absolute',
|
|
915
|
+
left: node.x,
|
|
916
|
+
top: node.y,
|
|
917
|
+
textAlign: 'left',
|
|
918
|
+
boxShadow: isExecuting ? '0 0 18px rgba(61,220,132,0.45)' : '0 6px 18px rgba(0,0,0,0.45)',
|
|
919
|
+
}, children: [_jsx(XStack, { justify: "space-between", items: "center", children: _jsxs(XStack, { items: "center", gap: "$1.5", flex: 1, minW: 0, children: [_jsx("span", { style: { width: 8, height: 8, borderRadius: 99, background: badgeColor, display: 'inline-block', flexShrink: 0 } }), _jsx(SizableText, { size: "$1", fontWeight: "600", numberOfLines: 1, children: `#${node.id} ${node.title}` })] }) }), _jsx(SizableText, { size: "$1", color: "$soft", numberOfLines: 1, style: { fontFamily: 'ui-monospace, monospace', fontSize: 10 }, children: `${node.family.toUpperCase()} · ${node.type} → ${(spec?.outputPorts ?? ['OUT']).join(',')}` }), _jsx(YStack, { gap: 1, pt: 2, children: Object.entries(node.inputs)
|
|
920
|
+
.slice(0, 2)
|
|
921
|
+
.map(([k, v]) => (_jsx(SizableText, { size: "$1", color: "$soft", numberOfLines: 1, style: { fontSize: 11 }, children: `${k}: ${String(v)}` }, k))) }), _jsxs(XStack, { justify: "space-between", items: "center", pt: 4, children: [connectingFromId && connectingFromId !== node.id ? (_jsx(XStack, { render: "span", onPress: (e) => {
|
|
922
|
+
e.stopPropagation?.();
|
|
923
|
+
toggleWire(connectingFromId, node.id);
|
|
924
|
+
}, px: "$2", height: 20, items: "center", rounded: 999, bg: "rgba(61,220,132,0.18)", borderWidth: 1, borderColor: "#3ddc84", children: _jsx(SizableText, { size: "$1", style: { fontSize: 10, color: '#3ddc84' }, children: node.wiresFrom.includes(connectingFromId) ? '⊖ Unlink' : '⊕ Connect Input' }) })) : (_jsx(SizableText, { size: "$1", color: "$soft", style: { fontSize: 10 }, children: node.wiresFrom.length > 0 ? `← [${node.wiresFrom.map((w) => `#${w}`).join(', ')}]` : 'entry' })), _jsx(XStack, { render: "span", onPress: (e) => {
|
|
925
|
+
e.stopPropagation?.();
|
|
926
|
+
setConnectingFromId(connectingFromId === node.id ? null : node.id);
|
|
927
|
+
}, px: "$2", height: 20, items: "center", rounded: 999, borderWidth: 1, borderColor: connectingFromId === node.id ? '$ink' : '$borderColor', children: _jsx(SizableText, { size: "$1", color: "$soft", style: { fontSize: 10 }, children: connectingFromId === node.id ? 'Wiring…' : 'Wire Out →' }) })] })] }, node.id));
|
|
928
|
+
})] }) }), _jsxs(YStack, { p: "$2.5", rounded: "$3", borderWidth: 1, borderColor: "$borderColor", bg: "#06070b", gap: 4, children: [_jsx(SizableText, { size: "$1", fontWeight: "600", children: "Step-Through Playground Execution Log" }), playgroundOutput.slice(-4).map((line, i) => (_jsx(SizableText, { size: "$1", color: "$soft", style: { fontFamily: 'ui-monospace, monospace', fontSize: 11 }, children: line }, i)))] })] }), _jsxs(YStack, { width: 300, grow: 1, maxW: 350, gap: "$2.5", p: "$3", rounded: "$4", borderWidth: 1, borderColor: "$borderColor", bg: "var(--pane-fill, var(--sheet-1))", children: [_jsxs(XStack, { justify: "space-between", items: "center", children: [_jsx(SizableText, { size: "$2", fontWeight: "600", numberOfLines: 1, children: `#${selectedNode.id} ${selectedNode.title}` }), activeBlueprint.nodes.length > 1 ? (_jsx(XStack, { render: "button", onPress: () => deleteNode(selectedNode.id), px: "$2", height: 24, items: "center", rounded: 999, borderWidth: 1, borderColor: "$borderColor", cursor: "pointer", children: _jsx(SizableText, { size: "$1", color: "$soft", children: "Delete" }) })) : null] }), _jsx(SizableText, { size: "$1", color: "$soft", style: { fontFamily: 'ui-monospace, monospace' }, children: `${selectedNode.family.toUpperCase()} · class_type: ${selectedNode.type}` }), _jsx(YStack, { gap: "$2.5", pt: "$1", children: Object.entries(selectedNode.inputs).map(([key, val]) => (_jsxs(YStack, { gap: "$1", children: [_jsx(SizableText, { size: "$1", color: "$soft", children: key }), _jsx("input", { "aria-label": `Node input ${key}`, type: typeof val === 'number' ? 'number' : 'text', value: String(val), onChange: (e) => updateNodeInput(key, typeof val === 'number' ? Number(e.currentTarget.value) : e.currentTarget.value), style: {
|
|
929
|
+
width: '100%',
|
|
930
|
+
height: 34,
|
|
931
|
+
borderRadius: 8,
|
|
932
|
+
padding: '0 10px',
|
|
933
|
+
background: 'rgba(255,255,255,0.04)',
|
|
934
|
+
border: '1px solid rgba(255,255,255,0.12)',
|
|
935
|
+
color: 'inherit',
|
|
936
|
+
font: 'inherit',
|
|
937
|
+
} })] }, key))) })] })] })) : null, section === 'code' ? (_jsxs(YStack, { gap: "$3", p: "$3", rounded: "$4", borderWidth: 1, borderColor: "$borderColor", bg: "var(--pane-fill, var(--sheet-1))", children: [_jsxs(XStack, { justify: "space-between", items: "center", flexWrap: "wrap", gap: "$2", children: [_jsxs(YStack, { children: [_jsx(SizableText, { size: "$3", fontWeight: "600", children: `Python Component Source: #${selectedNode.id} ${selectedNode.type}` }), _jsx(SizableText, { size: "$1", color: "$soft", children: "Every Langflow and ComfyUI (`studio_compat`) node is a Python class you can inspect and customize in place." })] }), _jsx(XStack, { render: "button", onPress: saveNodePythonCode, px: "$3.5", height: 32, items: "center", rounded: 999, bg: "$ink", cursor: "pointer", children: _jsx(SizableText, { size: "$1", color: "$background", fontWeight: "600", children: "Save Python Component" }) })] }), _jsx("textarea", { "aria-label": "Python node class source code", value: pythonDraft, onChange: (e) => setPythonDraft(e.currentTarget.value), rows: 16, style: {
|
|
938
|
+
width: '100%',
|
|
939
|
+
borderRadius: 10,
|
|
940
|
+
padding: 14,
|
|
941
|
+
background: '#06070b',
|
|
942
|
+
border: '1px solid rgba(255,255,255,0.14)',
|
|
943
|
+
color: '#e2e8f0',
|
|
944
|
+
fontFamily: 'ui-monospace, SFMono-Regular, Menlo, monospace',
|
|
945
|
+
fontSize: 13,
|
|
946
|
+
lineHeight: 1.5,
|
|
947
|
+
} })] })) : null, section === 'publish' ? (_jsxs(YStack, { gap: "$3", p: "$3", rounded: "$4", borderWidth: 1, borderColor: "$borderColor", bg: "var(--pane-fill, var(--sheet-1))", children: [_jsx(SizableText, { size: "$3", fontWeight: "600", children: "Publish Flow \u2014 REST API, ComfyUI `/v1/prompt` JSON, or MCP Server Tool" }), _jsx(SizableText, { size: "$1", color: "$soft", children: "Every Hanzo Flow graph can be called over HTTP (`POST /v1/prompt` or `/v1/flows/run`), loaded as JSON in Python, or exposed as an MCP tool to Hanzo Dev and Claude Code." }), _jsx(YStack, { p: "$3", rounded: "$3", borderWidth: 1, borderColor: "$borderColor", bg: "#06070b", maxH: 460, overflow: "scroll", children: _jsx("pre", { style: { margin: 0, fontSize: 12, fontFamily: 'ui-monospace, SFMono-Regular, Menlo, monospace', color: '#e2e8f0' }, children: JSON.stringify(compiledComfyPrompt, null, 2) }) })] })) : null] }));
|
|
948
|
+
}
|