@hanzo/studio 0.1.11 → 0.1.13
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 +4 -7
- package/lib/app/director.js +278 -345
- package/lib/app/flow-run.d.ts +34 -0
- package/lib/app/flow-run.js +77 -0
- package/lib/app/flow.d.ts +5 -5
- package/lib/app/flow.js +577 -312
- package/lib/app/sections.d.ts +5 -0
- package/lib/app/sections.js +26 -0
- package/lib/attach.d.ts +2 -0
- package/lib/attach.js +7 -0
- package/lib/desk.d.ts +1 -1
- package/lib/desk.js +370 -14
- package/lib/download.d.ts +2 -0
- package/lib/download.js +11 -0
- package/lib/gpu.d.ts +13 -1
- package/lib/gpu.js +39 -16
- package/lib/handoff.d.ts +2 -0
- package/lib/handoff.js +2 -0
- package/lib/home.js +97 -8
- package/lib/index.d.ts +1 -0
- package/lib/index.js +1 -0
- package/lib/kinds/image.d.ts +1 -1
- package/lib/kinds/image.js +3 -3
- package/lib/kinds/video.js +1 -1
- package/lib/places.js +184 -30
- package/lib/route.d.ts +6 -0
- package/lib/route.js +6 -0
- package/lib/talk.js +98 -33
- package/lib/ui.d.ts +18 -4
- package/lib/ui.js +50 -22
- package/lib/wire.d.ts +17 -0
- package/lib/wire.js +20 -0
- package/package.json +1 -1
package/lib/app/flow.js
CHANGED
|
@@ -1,45 +1,92 @@
|
|
|
1
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,
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
}
|
|
2
|
+
import { SizableText, styled, XStack, YStack } from '@hanzo/gui';
|
|
3
|
+
import { ArrowLeft, Boxes, Check, ChevronDown, Code, Download, Layers, Maximize2, Minus, Play, Plus, Redo2, Terminal, Undo2, Upload, Wand2, Workflow, } from '@hanzogui/lucide-icons-2';
|
|
4
|
+
import { DropdownMenu } from '@hanzo/ui';
|
|
5
|
+
import { createElement, useCallback, useEffect, useMemo, useRef, useState } from 'react';
|
|
6
|
+
import { download } from '../download.js';
|
|
7
|
+
import { reducedMotion, RING } from '../ui.js';
|
|
8
|
+
import { parseFlowSection } from './sections.js';
|
|
9
|
+
import { BRAIN, useWire } from '../live.js';
|
|
10
|
+
import { complete, objectInfo } from '../wire.js';
|
|
11
|
+
import { graphEdit, run, runs } from './flow-run.js';
|
|
12
|
+
const FlowInput = styled(SizableText, {
|
|
13
|
+
name: 'FlowFieldInput',
|
|
14
|
+
render: 'input',
|
|
15
|
+
size: '$2',
|
|
16
|
+
width: '100%',
|
|
17
|
+
minW: 0,
|
|
18
|
+
minH: 44,
|
|
19
|
+
$md: { minH: 34, height: 34 },
|
|
20
|
+
px: '$2.5',
|
|
21
|
+
rounded: '$3',
|
|
22
|
+
borderWidth: 1,
|
|
23
|
+
borderColor: 'var(--border-strong)',
|
|
24
|
+
bg: 'var(--background)',
|
|
25
|
+
color: '$ink',
|
|
26
|
+
focusVisibleStyle: RING,
|
|
27
|
+
});
|
|
28
|
+
const FlowTextarea = styled(SizableText, {
|
|
29
|
+
name: 'FlowFieldTextarea',
|
|
30
|
+
render: 'textarea',
|
|
31
|
+
size: '$2',
|
|
32
|
+
fontFamily: '$mono',
|
|
33
|
+
width: '100%',
|
|
34
|
+
minW: 0,
|
|
35
|
+
p: '$3',
|
|
36
|
+
rounded: '$3',
|
|
37
|
+
borderWidth: 1,
|
|
38
|
+
borderColor: 'var(--border-strong)',
|
|
39
|
+
bg: 'var(--background)',
|
|
40
|
+
color: '$ink',
|
|
41
|
+
focusVisibleStyle: RING,
|
|
42
|
+
});
|
|
43
|
+
const FlowInspectorTextarea = styled(SizableText, {
|
|
44
|
+
name: 'FlowInspectorTextarea',
|
|
45
|
+
render: 'textarea',
|
|
46
|
+
size: '$2',
|
|
47
|
+
width: '100%',
|
|
48
|
+
minW: 0,
|
|
49
|
+
p: '$2.5',
|
|
50
|
+
rounded: '$3',
|
|
51
|
+
borderWidth: 1,
|
|
52
|
+
borderColor: 'var(--border-strong)',
|
|
53
|
+
bg: 'var(--pane-fill, var(--background))',
|
|
54
|
+
color: '$ink',
|
|
55
|
+
focusVisibleStyle: RING,
|
|
56
|
+
});
|
|
57
|
+
const MULTILINE_INPUT_KEYS = new Set(['input_value', 'system_prompt', 'text', 'instruction', 'prompt', 'lyrics', 'template', 'paths']);
|
|
58
|
+
export { parseFlowSection };
|
|
12
59
|
export function flowNav(host, go) {
|
|
13
60
|
const active = parseFlowSection(host.path);
|
|
14
61
|
return [
|
|
15
62
|
{
|
|
16
63
|
id: 'make',
|
|
17
|
-
label: 'Hanzo Flow
|
|
64
|
+
label: 'Hanzo Flow',
|
|
18
65
|
links: [
|
|
19
66
|
{
|
|
20
67
|
id: 'canvas',
|
|
21
|
-
label: 'Flow
|
|
68
|
+
label: 'Flow canvas & playground',
|
|
22
69
|
active: active === 'canvas',
|
|
23
70
|
icon: createElement(Workflow, { size: 16 }),
|
|
24
71
|
onPress: () => go(''),
|
|
25
72
|
},
|
|
26
73
|
{
|
|
27
74
|
id: 'comfy',
|
|
28
|
-
label: 'ComfyUI
|
|
75
|
+
label: 'ComfyUI node extensions',
|
|
29
76
|
active: active === 'comfy',
|
|
30
77
|
icon: createElement(Layers, { size: 16 }),
|
|
31
78
|
onPress: () => go('comfy'),
|
|
32
79
|
},
|
|
33
80
|
{
|
|
34
81
|
id: 'agents',
|
|
35
|
-
label: 'Langflow
|
|
82
|
+
label: 'Langflow agents, RAG & MCP',
|
|
36
83
|
active: active === 'agents',
|
|
37
84
|
icon: createElement(Boxes, { size: 16 }),
|
|
38
85
|
onPress: () => go('agents'),
|
|
39
86
|
},
|
|
40
87
|
{
|
|
41
88
|
id: 'code',
|
|
42
|
-
label: 'Python
|
|
89
|
+
label: 'Python node code editor',
|
|
43
90
|
active: active === 'code',
|
|
44
91
|
icon: createElement(Code, { size: 16 }),
|
|
45
92
|
onPress: () => go('code'),
|
|
@@ -132,7 +179,7 @@ export const FLOW_MODULE_CATALOG = [
|
|
|
132
179
|
category: 'loader',
|
|
133
180
|
inputPorts: [],
|
|
134
181
|
outputPorts: ['MODEL'],
|
|
135
|
-
defaultInputs: { unet_name: '
|
|
182
|
+
defaultInputs: { unet_name: 'koma2_ti2v_5B_fp16.safetensors', weight_dtype: 'fp16' },
|
|
136
183
|
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
184
|
},
|
|
138
185
|
{
|
|
@@ -170,13 +217,13 @@ export const FLOW_MODULE_CATALOG = [
|
|
|
170
217
|
},
|
|
171
218
|
{
|
|
172
219
|
type: 'ImageOnlyCheckpointLoader',
|
|
173
|
-
title: 'Load
|
|
220
|
+
title: 'Load Mori 3D 2.1 Checkpoint',
|
|
174
221
|
family: 'comfy',
|
|
175
222
|
pack: 'studio-core 3D (ComfyUI)',
|
|
176
223
|
category: 'loader',
|
|
177
224
|
inputPorts: [],
|
|
178
225
|
outputPorts: ['MODEL', 'CLIP_VISION', 'VAE'],
|
|
179
|
-
defaultInputs: { ckpt_name: '
|
|
226
|
+
defaultInputs: { ckpt_name: 'mori_3d_v2.1.safetensors' },
|
|
180
227
|
pythonSource: `class ImageOnlyCheckpointLoader:\n RETURN_TYPES = ("MODEL", "CLIP_VISION", "VAE")\n FUNCTION = "load_checkpoint"`,
|
|
181
228
|
},
|
|
182
229
|
{
|
|
@@ -202,15 +249,15 @@ export const FLOW_MODULE_CATALOG = [
|
|
|
202
249
|
pythonSource: `class CLIPTextEncode:\n RETURN_TYPES = ("CONDITIONING",)\n FUNCTION = "encode"`,
|
|
203
250
|
},
|
|
204
251
|
{
|
|
205
|
-
type: '
|
|
206
|
-
title: '
|
|
252
|
+
type: 'KomaImageToVideo',
|
|
253
|
+
title: 'Koma 2.0 TI2V Latent Video Grid',
|
|
207
254
|
family: 'comfy',
|
|
208
|
-
pack: 'ComfyUI-
|
|
255
|
+
pack: 'ComfyUI-KomaVideoWrapper (Apache-2.0)',
|
|
209
256
|
category: 'conditioning',
|
|
210
257
|
inputPorts: ['positive'],
|
|
211
258
|
outputPorts: ['CONDITIONING', 'LATENT'],
|
|
212
259
|
defaultInputs: { width: 1280, height: 544, length: 81, fps: 24 },
|
|
213
|
-
pythonSource: `class
|
|
260
|
+
pythonSource: `class KomaImageToVideo:\n RETURN_TYPES = ("CONDITIONING", "LATENT")\n FUNCTION = "encode"`,
|
|
214
261
|
},
|
|
215
262
|
{
|
|
216
263
|
type: 'LTXVConditioning',
|
|
@@ -224,15 +271,15 @@ export const FLOW_MODULE_CATALOG = [
|
|
|
224
271
|
pythonSource: `class LTXVConditioning:\n RETURN_TYPES = ("CONDITIONING", "CONDITIONING")\n FUNCTION = "append"`,
|
|
225
272
|
},
|
|
226
273
|
{
|
|
227
|
-
type: '
|
|
228
|
-
title: '
|
|
274
|
+
type: 'TextEncodeIroImageEdit',
|
|
275
|
+
title: 'Iro-Image-Edit 2511 Instruction',
|
|
229
276
|
family: 'comfy',
|
|
230
277
|
pack: 'studio-core (ComfyUI)',
|
|
231
278
|
category: 'conditioning',
|
|
232
279
|
inputPorts: ['clip', 'image'],
|
|
233
280
|
outputPorts: ['CONDITIONING'],
|
|
234
281
|
defaultInputs: { instruction: 'Swap jacket to brushed obsidian leather, preserve face and rim lighting' },
|
|
235
|
-
pythonSource: `class
|
|
282
|
+
pythonSource: `class TextEncodeIroImageEdit:\n RETURN_TYPES = ("CONDITIONING",)\n FUNCTION = "encode"`,
|
|
236
283
|
},
|
|
237
284
|
{
|
|
238
285
|
type: 'TextEncodeAceStepAudio',
|
|
@@ -335,7 +382,7 @@ export const FLOW_MODULE_CATALOG = [
|
|
|
335
382
|
},
|
|
336
383
|
{
|
|
337
384
|
type: 'VoxelToMesh',
|
|
338
|
-
title: '
|
|
385
|
+
title: 'VAEDecodeMori 3D → .GLB Mesh',
|
|
339
386
|
family: 'comfy',
|
|
340
387
|
pack: 'studio-core 3D (ComfyUI)',
|
|
341
388
|
category: 'decode',
|
|
@@ -363,7 +410,7 @@ export const FLOW_MODULE_CATALOG = [
|
|
|
363
410
|
category: 'output',
|
|
364
411
|
inputPorts: ['images'],
|
|
365
412
|
outputPorts: [],
|
|
366
|
-
defaultInputs: { filename_prefix: 'video/
|
|
413
|
+
defaultInputs: { filename_prefix: 'video/koma2_cinema', codec: 'vp9', fps: 24, crf: 18 },
|
|
367
414
|
pythonSource: `class SaveWEBM:\n RETURN_TYPES = ()\n OUTPUT_NODE = True\n FUNCTION = "save_video"`,
|
|
368
415
|
},
|
|
369
416
|
{
|
|
@@ -396,53 +443,53 @@ export const FLOW_MODULE_CATALOG = [
|
|
|
396
443
|
category: 'output',
|
|
397
444
|
inputPorts: ['mesh'],
|
|
398
445
|
outputPorts: [],
|
|
399
|
-
defaultInputs: { filename_prefix: 'mesh/
|
|
446
|
+
defaultInputs: { filename_prefix: 'mesh/mori3d_asset' },
|
|
400
447
|
pythonSource: `class SaveGLB:\n RETURN_TYPES = ()\n OUTPUT_NODE = True\n FUNCTION = "save_glb"`,
|
|
401
448
|
},
|
|
402
449
|
];
|
|
403
450
|
export const FLOW_BLUEPRINTS = [
|
|
404
451
|
{
|
|
405
|
-
id: 'hybrid-agent-
|
|
406
|
-
name: 'Langflow Director Agent →
|
|
452
|
+
id: 'hybrid-agent-koma2',
|
|
453
|
+
name: 'Langflow Director Agent → Koma 2.0 Cinema + MMAudio Foley',
|
|
407
454
|
kind: 'Hybrid Langflow + ComfyUI',
|
|
408
|
-
engine: 'zen5 +
|
|
409
|
-
description: 'ChatInput & ZenAgent expand a rough creative brief with Vector RAG lore, then drive ComfyUI
|
|
455
|
+
engine: 'zen5 + koma2_ti2v_5B + mmaudio',
|
|
456
|
+
description: 'ChatInput & ZenAgent expand a rough creative brief with Vector RAG lore, then drive ComfyUI Koma 2.0 video + MMAudio Foley.',
|
|
410
457
|
nodes: [
|
|
411
458
|
{ 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
459
|
{ 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
|
|
414
|
-
{ id: '4', type: 'UNETLoader', title: 'Load
|
|
460
|
+
{ 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 Koma 2.0', temperature: 0.25 }, wiresFrom: ['1', '2'] },
|
|
461
|
+
{ id: '4', type: 'UNETLoader', title: 'Load Koma 2.0 UNet', family: 'comfy', category: 'loader', x: 520, y: 25, inputs: { unet_name: 'koma2_ti2v_5B_fp16.safetensors', weight_dtype: 'fp16' }, wiresFrom: [] },
|
|
415
462
|
{ 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: '
|
|
463
|
+
{ id: '6', type: 'KSampler', title: 'Koma 2.0 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
464
|
{ 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/
|
|
465
|
+
{ id: '8', type: 'SaveWEBM', title: 'Save Master Cut (/v1/library)', family: 'comfy', category: 'output', x: 1020, y: 130, inputs: { filename_prefix: 'video/hybrid_agent_koma2', codec: 'vp9', fps: 24 }, wiresFrom: ['6', '7'] },
|
|
419
466
|
],
|
|
420
467
|
},
|
|
421
468
|
{
|
|
422
469
|
id: 'cad-to-lookbook',
|
|
423
|
-
name: 'CAD Flat Sketch → Ghost Mannequin & Lookbook (
|
|
470
|
+
name: 'CAD Flat Sketch → Ghost Mannequin & Lookbook (Iro 2511)',
|
|
424
471
|
kind: 'ComfyUI Image & CAD',
|
|
425
|
-
engine: '
|
|
472
|
+
engine: 'iro-image-edit-2511.safetensors',
|
|
426
473
|
description: 'Antje’s production garment conversion graph: CAD drawing → photoreal ghost mannequin (0.92 denoise) → lifestyle lookbook (0.25 denoise).',
|
|
427
474
|
nodes: [
|
|
428
475
|
{ 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
|
|
430
|
-
{ id: '3', type: '
|
|
476
|
+
{ id: '2', type: 'UNETLoader', title: 'Load Iro-Image-Edit 2511', family: 'comfy', category: 'loader', x: 30, y: 195, inputs: { unet_name: 'iro-image-edit-2511.safetensors', clip_name: 'iro-vl-7b.safetensors' }, wiresFrom: [] },
|
|
477
|
+
{ id: '3', type: 'TextEncodeIroImageEdit', 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
478
|
{ 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
479
|
{ 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
480
|
],
|
|
434
481
|
},
|
|
435
482
|
{
|
|
436
|
-
id: '
|
|
437
|
-
name: '
|
|
483
|
+
id: 'mori3d-mesh',
|
|
484
|
+
name: 'Mori 3D 2.1 Image-to-GLB Watertight Mesh',
|
|
438
485
|
kind: 'ComfyUI 3D Mesh',
|
|
439
|
-
engine: '
|
|
486
|
+
engine: 'mori_3d_v2.1.safetensors',
|
|
440
487
|
description: 'Single ghost-mannequin or product reference image → AuraFlow 3D latent → marching cubes .glb asset.',
|
|
441
488
|
nodes: [
|
|
442
|
-
{ id: '1', type: 'ImageOnlyCheckpointLoader', title: 'Load
|
|
489
|
+
{ id: '1', type: 'ImageOnlyCheckpointLoader', title: 'Load Mori 3D 2.1', family: 'comfy', category: 'loader', x: 30, y: 45, inputs: { ckpt_name: 'mori_3d_v2.1.safetensors' }, wiresFrom: [] },
|
|
443
490
|
{ 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: '
|
|
445
|
-
{ id: '4', type: 'SaveGLB', title: 'Export .GLB 3D Asset', family: 'comfy', category: 'output', x: 860, y: 45, inputs: { filename_prefix: 'mesh/
|
|
491
|
+
{ id: '3', type: 'VoxelToMesh', title: 'VAEDecodeMori 3D → Mesh', family: 'comfy', category: 'decode', x: 590, y: 45, inputs: { algorithm: 'surface_net', threshold: 0.0, octree_resolution: 384 }, wiresFrom: ['2'] },
|
|
492
|
+
{ id: '4', type: 'SaveGLB', title: 'Export .GLB 3D Asset', family: 'comfy', category: 'output', x: 860, y: 45, inputs: { filename_prefix: 'mesh/mori3d_asset' }, wiresFrom: ['3'] },
|
|
446
493
|
],
|
|
447
494
|
},
|
|
448
495
|
{
|
|
@@ -459,7 +506,23 @@ export const FLOW_BLUEPRINTS = [
|
|
|
459
506
|
],
|
|
460
507
|
},
|
|
461
508
|
];
|
|
509
|
+
const MAX_HISTORY = 30;
|
|
510
|
+
const MIN_ZOOM = 0.6;
|
|
511
|
+
const MAX_ZOOM = 1.4;
|
|
512
|
+
const NODE_W = 224;
|
|
513
|
+
const NODE_H = 136;
|
|
514
|
+
function cloneNodes(nodes) {
|
|
515
|
+
return nodes.map((n) => ({ ...n, inputs: { ...n.inputs }, wiresFrom: [...n.wiresFrom] }));
|
|
516
|
+
}
|
|
517
|
+
function formatClock(d = new Date()) {
|
|
518
|
+
const hh = String(d.getHours()).padStart(2, '0');
|
|
519
|
+
const mm = String(d.getMinutes()).padStart(2, '0');
|
|
520
|
+
const ss = String(d.getSeconds()).padStart(2, '0');
|
|
521
|
+
const ms = String(d.getMilliseconds()).padStart(3, '0');
|
|
522
|
+
return `${hh}:${mm}:${ss}.${ms}`;
|
|
523
|
+
}
|
|
462
524
|
export function FlowStudio({ host }) {
|
|
525
|
+
const wire = useWire(host);
|
|
463
526
|
const [section, setSection] = useState(() => parseFlowSection(host.path));
|
|
464
527
|
useEffect(() => {
|
|
465
528
|
setSection(parseFlowSection(host.path));
|
|
@@ -470,36 +533,214 @@ export function FlowStudio({ host }) {
|
|
|
470
533
|
};
|
|
471
534
|
const [blueprints, setBlueprints] = useState(() => FLOW_BLUEPRINTS.map((b) => ({
|
|
472
535
|
...b,
|
|
473
|
-
nodes: b.nodes
|
|
536
|
+
nodes: cloneNodes(b.nodes),
|
|
474
537
|
})));
|
|
475
538
|
const [activeBlueprintId, setActiveBlueprintId] = useState(FLOW_BLUEPRINTS[0].id);
|
|
476
539
|
const activeBlueprint = blueprints.find((b) => b.id === activeBlueprintId) ?? blueprints[0];
|
|
477
540
|
const [selectedNodeId, setSelectedNodeId] = useState(activeBlueprint.nodes[0]?.id ?? '1');
|
|
478
541
|
const selectedNode = activeBlueprint.nodes.find((n) => n.id === selectedNodeId) ?? activeBlueprint.nodes[0];
|
|
542
|
+
// Per-blueprint undo/redo stacks (up to 30 snapshots)
|
|
543
|
+
const [historyByBp, setHistoryByBp] = useState({});
|
|
544
|
+
const lastEditKeyRef = useRef(null);
|
|
545
|
+
const activeHistory = historyByBp[activeBlueprint.id] ?? { past: [], future: [] };
|
|
546
|
+
const canUndo = activeHistory.past.length > 0;
|
|
547
|
+
const canRedo = activeHistory.future.length > 0;
|
|
548
|
+
// Canvas pan & zoom state
|
|
549
|
+
const [zoom, setZoom] = useState(1);
|
|
550
|
+
const [pan, setPan] = useState({ x: 0, y: 0 });
|
|
551
|
+
const [isPanning, setIsPanning] = useState(false);
|
|
552
|
+
const [draggingNodeId, setDraggingNodeId] = useState(null);
|
|
553
|
+
const [catalogExpanded, setCatalogExpanded] = useState(false);
|
|
554
|
+
const canvasViewportRef = useRef(null);
|
|
555
|
+
const panDragRef = useRef(null);
|
|
556
|
+
const nodeDragRef = useRef(null);
|
|
479
557
|
const [moduleCatalog, setModuleCatalog] = useState(() => [...FLOW_MODULE_CATALOG]);
|
|
480
558
|
const [familyFilter, setFamilyFilter] = useState('all');
|
|
481
559
|
const [searchQuery, setSearchQuery] = useState('');
|
|
482
560
|
const [connectingFromId, setConnectingFromId] = useState(null);
|
|
483
|
-
const [
|
|
561
|
+
const [runningFlow, setRunningFlow] = useState(false);
|
|
562
|
+
const [nodeRunStatus, setNodeRunStatus] = useState({});
|
|
484
563
|
const [copilotInput, setCopilotInput] = useState('');
|
|
485
|
-
const [statusMessage, setStatusMessage] = useState('Hanzo Flow · Langflow
|
|
564
|
+
const [statusMessage, setStatusMessage] = useState('Hanzo Flow · Langflow agent nodes + ComfyUI native engine (/v1/object_info & /v1/prompt)');
|
|
486
565
|
const [playgroundOutput, setPlaygroundOutput] = useState([
|
|
487
|
-
|
|
566
|
+
`[${formatClock()}] Ready · ${FLOW_BLUEPRINTS[0].nodes.length} nodes loaded (${FLOW_BLUEPRINTS[0].engine})`,
|
|
488
567
|
]);
|
|
568
|
+
const pushSnapshot = useCallback((bpId, snapshot) => {
|
|
569
|
+
setHistoryByBp((prev) => {
|
|
570
|
+
const cur = prev[bpId] ?? { past: [], future: [] };
|
|
571
|
+
const nextPast = [...cur.past, cloneNodes(snapshot)].slice(-MAX_HISTORY);
|
|
572
|
+
return { ...prev, [bpId]: { past: nextPast, future: [] } };
|
|
573
|
+
});
|
|
574
|
+
}, []);
|
|
575
|
+
const commitGraph = useCallback((updater, opts) => {
|
|
576
|
+
const bpId = activeBlueprint.id;
|
|
577
|
+
const now = Date.now();
|
|
578
|
+
const shouldCoalesce = Boolean(opts?.coalesceKey) &&
|
|
579
|
+
lastEditKeyRef.current?.key === opts?.coalesceKey &&
|
|
580
|
+
now - (lastEditKeyRef.current?.at ?? 0) < 800;
|
|
581
|
+
setBlueprints((prev) => prev.map((b) => {
|
|
582
|
+
if (b.id !== bpId)
|
|
583
|
+
return b;
|
|
584
|
+
if (!shouldCoalesce) {
|
|
585
|
+
pushSnapshot(bpId, b.nodes);
|
|
586
|
+
}
|
|
587
|
+
lastEditKeyRef.current = opts?.coalesceKey ? { key: opts.coalesceKey, at: now } : null;
|
|
588
|
+
return { ...b, nodes: updater(b.nodes) };
|
|
589
|
+
}));
|
|
590
|
+
}, [activeBlueprint.id, pushSnapshot]);
|
|
591
|
+
const undo = useCallback(() => {
|
|
592
|
+
const bpId = activeBlueprint.id;
|
|
593
|
+
const cur = historyByBp[bpId];
|
|
594
|
+
if (!cur || cur.past.length === 0)
|
|
595
|
+
return;
|
|
596
|
+
const previous = cur.past[cur.past.length - 1];
|
|
597
|
+
const currentSnapshot = cloneNodes(activeBlueprint.nodes);
|
|
598
|
+
setHistoryByBp((prev) => {
|
|
599
|
+
const h = prev[bpId] ?? { past: [], future: [] };
|
|
600
|
+
return {
|
|
601
|
+
...prev,
|
|
602
|
+
[bpId]: {
|
|
603
|
+
past: h.past.slice(0, -1),
|
|
604
|
+
future: [currentSnapshot, ...h.future].slice(0, MAX_HISTORY),
|
|
605
|
+
},
|
|
606
|
+
};
|
|
607
|
+
});
|
|
608
|
+
setBlueprints((prev) => prev.map((b) => (b.id === bpId ? { ...b, nodes: cloneNodes(previous) } : b)));
|
|
609
|
+
if (!previous.some((n) => n.id === selectedNodeId) && previous[0]) {
|
|
610
|
+
setSelectedNodeId(previous[0].id);
|
|
611
|
+
}
|
|
612
|
+
setStatusMessage('Undid last Flow graph change');
|
|
613
|
+
}, [activeBlueprint.id, activeBlueprint.nodes, historyByBp, selectedNodeId]);
|
|
614
|
+
const redo = useCallback(() => {
|
|
615
|
+
const bpId = activeBlueprint.id;
|
|
616
|
+
const cur = historyByBp[bpId];
|
|
617
|
+
if (!cur || cur.future.length === 0)
|
|
618
|
+
return;
|
|
619
|
+
const nextNodes = cur.future[0];
|
|
620
|
+
const currentSnapshot = cloneNodes(activeBlueprint.nodes);
|
|
621
|
+
setHistoryByBp((prev) => {
|
|
622
|
+
const h = prev[bpId] ?? { past: [], future: [] };
|
|
623
|
+
return {
|
|
624
|
+
...prev,
|
|
625
|
+
[bpId]: {
|
|
626
|
+
past: [...h.past, currentSnapshot].slice(-MAX_HISTORY),
|
|
627
|
+
future: h.future.slice(1),
|
|
628
|
+
},
|
|
629
|
+
};
|
|
630
|
+
});
|
|
631
|
+
setBlueprints((prev) => prev.map((b) => (b.id === bpId ? { ...b, nodes: cloneNodes(nextNodes) } : b)));
|
|
632
|
+
if (!nextNodes.some((n) => n.id === selectedNodeId) && nextNodes[0]) {
|
|
633
|
+
setSelectedNodeId(nextNodes[0].id);
|
|
634
|
+
}
|
|
635
|
+
setStatusMessage('Redid Flow graph change');
|
|
636
|
+
}, [activeBlueprint.id, activeBlueprint.nodes, historyByBp, selectedNodeId]);
|
|
637
|
+
const clampZoom = (z) => Math.round(Math.min(MAX_ZOOM, Math.max(MIN_ZOOM, z)) * 100) / 100;
|
|
638
|
+
const fitCanvas = useCallback(() => {
|
|
639
|
+
const el = canvasViewportRef.current;
|
|
640
|
+
const nodes = activeBlueprint.nodes;
|
|
641
|
+
if (!el || !nodes.length) {
|
|
642
|
+
setZoom(1);
|
|
643
|
+
setPan({ x: 0, y: 0 });
|
|
644
|
+
return;
|
|
645
|
+
}
|
|
646
|
+
const pad = 32;
|
|
647
|
+
const minX = Math.min(...nodes.map((n) => n.x));
|
|
648
|
+
const minY = Math.min(...nodes.map((n) => n.y));
|
|
649
|
+
const maxX = Math.max(...nodes.map((n) => n.x + NODE_W));
|
|
650
|
+
const maxY = Math.max(...nodes.map((n) => n.y + NODE_H));
|
|
651
|
+
const graphW = Math.max(1, maxX - minX);
|
|
652
|
+
const graphH = Math.max(1, maxY - minY);
|
|
653
|
+
const viewW = Math.max(240, el.clientWidth - pad * 2);
|
|
654
|
+
const viewH = Math.max(200, el.clientHeight - pad * 2);
|
|
655
|
+
const fittedZoom = clampZoom(Math.min(viewW / graphW, viewH / graphH, 1));
|
|
656
|
+
const panX = Math.round((el.clientWidth - graphW * fittedZoom) / 2 - minX * fittedZoom);
|
|
657
|
+
const panY = Math.round((el.clientHeight - graphH * fittedZoom) / 2 - minY * fittedZoom);
|
|
658
|
+
setZoom(fittedZoom);
|
|
659
|
+
setPan({ x: panX, y: Math.max(16, panY) });
|
|
660
|
+
}, [activeBlueprint.nodes]);
|
|
661
|
+
const handleCanvasPointerDown = (e) => {
|
|
662
|
+
const target = e.target;
|
|
663
|
+
if (target?.closest('[data-flow-node]') ||
|
|
664
|
+
target?.closest('[data-flow-toolbar]') ||
|
|
665
|
+
target?.closest('[role="toolbar"]') ||
|
|
666
|
+
target?.closest('button')) {
|
|
667
|
+
return;
|
|
668
|
+
}
|
|
669
|
+
e.currentTarget.setPointerCapture(e.pointerId);
|
|
670
|
+
setIsPanning(true);
|
|
671
|
+
panDragRef.current = { startX: e.clientX, startY: e.clientY, originX: pan.x, originY: pan.y };
|
|
672
|
+
};
|
|
673
|
+
const handleCanvasPointerMove = (e) => {
|
|
674
|
+
if (nodeDragRef.current) {
|
|
675
|
+
const drag = nodeDragRef.current;
|
|
676
|
+
const dx = (e.clientX - drag.startX) / zoom;
|
|
677
|
+
const dy = (e.clientY - drag.startY) / zoom;
|
|
678
|
+
if (!drag.moved && Math.hypot(e.clientX - drag.startX, e.clientY - drag.startY) > 4) {
|
|
679
|
+
drag.moved = true;
|
|
680
|
+
setDraggingNodeId(drag.id);
|
|
681
|
+
}
|
|
682
|
+
if (drag.moved) {
|
|
683
|
+
const nx = Math.max(8, Math.round(drag.originX + dx));
|
|
684
|
+
const ny = Math.max(8, Math.round(drag.originY + dy));
|
|
685
|
+
setBlueprints((prev) => prev.map((b) => b.id === activeBlueprint.id ? { ...b, nodes: b.nodes.map((n) => (n.id === drag.id ? { ...n, x: nx, y: ny } : n)) } : b));
|
|
686
|
+
}
|
|
687
|
+
return;
|
|
688
|
+
}
|
|
689
|
+
if (!isPanning || !panDragRef.current)
|
|
690
|
+
return;
|
|
691
|
+
const dx = e.clientX - panDragRef.current.startX;
|
|
692
|
+
const dy = e.clientY - panDragRef.current.startY;
|
|
693
|
+
setPan({ x: Math.round(panDragRef.current.originX + dx), y: Math.round(panDragRef.current.originY + dy) });
|
|
694
|
+
};
|
|
695
|
+
const handleCanvasPointerUp = (e) => {
|
|
696
|
+
if (nodeDragRef.current) {
|
|
697
|
+
const drag = nodeDragRef.current;
|
|
698
|
+
nodeDragRef.current = null;
|
|
699
|
+
setDraggingNodeId(null);
|
|
700
|
+
if (drag.moved) {
|
|
701
|
+
pushSnapshot(activeBlueprint.id, drag.snapshot);
|
|
702
|
+
setStatusMessage(`Moved node #${drag.id}`);
|
|
703
|
+
}
|
|
704
|
+
}
|
|
705
|
+
if (isPanning) {
|
|
706
|
+
try {
|
|
707
|
+
e.currentTarget.releasePointerCapture(e.pointerId);
|
|
708
|
+
}
|
|
709
|
+
catch {
|
|
710
|
+
// Ignore
|
|
711
|
+
}
|
|
712
|
+
setIsPanning(false);
|
|
713
|
+
panDragRef.current = null;
|
|
714
|
+
}
|
|
715
|
+
};
|
|
716
|
+
const handleNodePointerDown = (node, e) => {
|
|
717
|
+
const target = e.target;
|
|
718
|
+
if (target?.closest('button'))
|
|
719
|
+
return;
|
|
720
|
+
e.stopPropagation();
|
|
721
|
+
setSelectedNodeId(node.id);
|
|
722
|
+
nodeDragRef.current = {
|
|
723
|
+
id: node.id,
|
|
724
|
+
startX: e.clientX,
|
|
725
|
+
startY: e.clientY,
|
|
726
|
+
originX: node.x,
|
|
727
|
+
originY: node.y,
|
|
728
|
+
moved: false,
|
|
729
|
+
snapshot: cloneNodes(activeBlueprint.nodes),
|
|
730
|
+
};
|
|
731
|
+
try {
|
|
732
|
+
canvasViewportRef.current?.setPointerCapture(e.pointerId);
|
|
733
|
+
}
|
|
734
|
+
catch {
|
|
735
|
+
// Ignore
|
|
736
|
+
}
|
|
737
|
+
};
|
|
489
738
|
// Discover live ComfyUI modules from /v1/object_info when backend is available
|
|
490
739
|
useEffect(() => {
|
|
491
740
|
let alive = true;
|
|
492
|
-
|
|
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))
|
|
741
|
+
objectInfo(wire)
|
|
501
742
|
.then((info) => {
|
|
502
|
-
if (!alive
|
|
743
|
+
if (!alive)
|
|
503
744
|
return;
|
|
504
745
|
const existing = new Set(FLOW_MODULE_CATALOG.map((m) => m.type));
|
|
505
746
|
const extra = [];
|
|
@@ -525,7 +766,7 @@ export function FlowStudio({ host }) {
|
|
|
525
766
|
return () => {
|
|
526
767
|
alive = false;
|
|
527
768
|
};
|
|
528
|
-
}, [
|
|
769
|
+
}, [wire]);
|
|
529
770
|
const selectedSpec = moduleCatalog.find((m) => m.type === selectedNode.type);
|
|
530
771
|
const [pythonDraft, setPythonDraft] = useState(() => selectedNode.pythonCode || selectedSpec?.pythonSource || '');
|
|
531
772
|
useEffect(() => {
|
|
@@ -533,20 +774,10 @@ export function FlowStudio({ host }) {
|
|
|
533
774
|
setPythonDraft(selectedNode.pythonCode || spec?.pythonSource || '');
|
|
534
775
|
}, [selectedNode, moduleCatalog]);
|
|
535
776
|
const updateNodeInput = (key, val) => {
|
|
536
|
-
|
|
537
|
-
? {
|
|
538
|
-
...b,
|
|
539
|
-
nodes: b.nodes.map((n) => (n.id === selectedNode.id ? { ...n, inputs: { ...n.inputs, [key]: val } } : n)),
|
|
540
|
-
}
|
|
541
|
-
: b));
|
|
777
|
+
commitGraph((nodes) => nodes.map((n) => (n.id === selectedNode.id ? { ...n, inputs: { ...n.inputs, [key]: val } } : n)), { coalesceKey: `${selectedNode.id}:${key}` });
|
|
542
778
|
};
|
|
543
779
|
const saveNodePythonCode = () => {
|
|
544
|
-
|
|
545
|
-
? {
|
|
546
|
-
...b,
|
|
547
|
-
nodes: b.nodes.map((n) => (n.id === selectedNode.id ? { ...n, pythonCode: pythonDraft } : n)),
|
|
548
|
-
}
|
|
549
|
-
: b));
|
|
780
|
+
commitGraph((nodes) => nodes.map((n) => (n.id === selectedNode.id ? { ...n, pythonCode: pythonDraft } : n)));
|
|
550
781
|
setStatusMessage(`Saved live Python component class for #${selectedNode.id} ${selectedNode.type}`);
|
|
551
782
|
};
|
|
552
783
|
const addModuleToCanvas = (spec) => {
|
|
@@ -574,49 +805,64 @@ export function FlowStudio({ host }) {
|
|
|
574
805
|
wiresFrom: selectedNode ? [selectedNode.id] : [],
|
|
575
806
|
pythonCode: spec.pythonSource,
|
|
576
807
|
};
|
|
577
|
-
|
|
808
|
+
commitGraph((nodes) => [...nodes, created]);
|
|
578
809
|
setSelectedNodeId(nextId);
|
|
579
810
|
setStatusMessage(`Added ${spec.family === 'langflow' ? 'Langflow' : 'ComfyUI'} node #${nextId} ${spec.type} to Flow canvas`);
|
|
580
811
|
};
|
|
581
812
|
const toggleWire = (fromId, toId) => {
|
|
582
813
|
if (fromId === toId)
|
|
583
814
|
return;
|
|
584
|
-
|
|
585
|
-
if (
|
|
586
|
-
return
|
|
815
|
+
commitGraph((nodes) => nodes.map((n) => {
|
|
816
|
+
if (n.id !== toId)
|
|
817
|
+
return n;
|
|
818
|
+
const exists = n.wiresFrom.includes(fromId);
|
|
587
819
|
return {
|
|
588
|
-
...
|
|
589
|
-
|
|
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
|
-
}),
|
|
820
|
+
...n,
|
|
821
|
+
wiresFrom: exists ? n.wiresFrom.filter((w) => w !== fromId) : [...n.wiresFrom, fromId],
|
|
598
822
|
};
|
|
599
823
|
}));
|
|
600
824
|
setConnectingFromId(null);
|
|
601
825
|
setStatusMessage(`Wired #${fromId} → #${toId}`);
|
|
602
826
|
};
|
|
603
|
-
const deleteNode = (nodeId) => {
|
|
827
|
+
const deleteNode = useCallback((nodeId) => {
|
|
604
828
|
if (activeBlueprint.nodes.length <= 1)
|
|
605
829
|
return;
|
|
606
|
-
|
|
607
|
-
|
|
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
|
-
}));
|
|
830
|
+
const target = activeBlueprint.nodes.find((n) => n.id === nodeId);
|
|
831
|
+
commitGraph((nodes) => nodes.filter((n) => n.id !== nodeId).map((n) => ({ ...n, wiresFrom: n.wiresFrom.filter((w) => w !== nodeId) })));
|
|
616
832
|
const fallback = activeBlueprint.nodes.find((n) => n.id !== nodeId);
|
|
617
833
|
if (fallback)
|
|
618
834
|
setSelectedNodeId(fallback.id);
|
|
619
|
-
|
|
835
|
+
setStatusMessage(`Deleted node #${nodeId}${target ? ` (${target.type})` : ''}`);
|
|
836
|
+
}, [activeBlueprint.nodes, commitGraph]);
|
|
837
|
+
// Keyboard shortcuts: Cmd/Ctrl+Z undo, Cmd/Ctrl+Shift+Z or Ctrl+Y redo, Delete/Backspace delete node
|
|
838
|
+
useEffect(() => {
|
|
839
|
+
if (section !== 'canvas' && section !== 'comfy' && section !== 'agents')
|
|
840
|
+
return;
|
|
841
|
+
const onKeyDown = (e) => {
|
|
842
|
+
const target = e.target;
|
|
843
|
+
const tag = target?.tagName;
|
|
844
|
+
if (tag === 'INPUT' || tag === 'TEXTAREA' || tag === 'SELECT' || target?.isContentEditable)
|
|
845
|
+
return;
|
|
846
|
+
const mod = e.metaKey || e.ctrlKey;
|
|
847
|
+
if (mod && !e.shiftKey && e.key.toLowerCase() === 'z') {
|
|
848
|
+
e.preventDefault();
|
|
849
|
+
undo();
|
|
850
|
+
}
|
|
851
|
+
else if ((mod && e.shiftKey && e.key.toLowerCase() === 'z') || (e.ctrlKey && e.key.toLowerCase() === 'y')) {
|
|
852
|
+
e.preventDefault();
|
|
853
|
+
redo();
|
|
854
|
+
}
|
|
855
|
+
else if (e.key === 'Delete' || e.key === 'Backspace') {
|
|
856
|
+
// Only with focus on the canvas: a Backspace elsewhere must not delete a node.
|
|
857
|
+
if (selectedNode && activeBlueprint.nodes.length > 1 && target && canvasViewportRef.current?.contains(target)) {
|
|
858
|
+
e.preventDefault();
|
|
859
|
+
deleteNode(selectedNode.id);
|
|
860
|
+
}
|
|
861
|
+
}
|
|
862
|
+
};
|
|
863
|
+
window.addEventListener('keydown', onKeyDown);
|
|
864
|
+
return () => window.removeEventListener('keydown', onKeyDown);
|
|
865
|
+
}, [section, undo, redo, deleteNode, selectedNode, activeBlueprint.nodes.length]);
|
|
620
866
|
const autoLayout = () => {
|
|
621
867
|
const order = {
|
|
622
868
|
agent: 0,
|
|
@@ -626,21 +872,17 @@ export function FlowStudio({ host }) {
|
|
|
626
872
|
decode: 3,
|
|
627
873
|
output: 4,
|
|
628
874
|
};
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
return { ...n, x: 25 + col * 245, y: 30 + row * 155 };
|
|
641
|
-
}),
|
|
642
|
-
};
|
|
643
|
-
}));
|
|
875
|
+
commitGraph((nodes) => {
|
|
876
|
+
const counts = {};
|
|
877
|
+
const sorted = [...nodes].sort((x, y) => order[x.category] - order[y.category] || Number(x.id) - Number(y.id));
|
|
878
|
+
return sorted.map((n) => {
|
|
879
|
+
const col = order[n.category];
|
|
880
|
+
const row = counts[col] ?? 0;
|
|
881
|
+
counts[col] = row + 1;
|
|
882
|
+
return { ...n, x: 25 + col * 245, y: 30 + row * 155 };
|
|
883
|
+
});
|
|
884
|
+
});
|
|
885
|
+
setPan({ x: 0, y: 0 });
|
|
644
886
|
setStatusMessage(`Auto-aligned ${activeBlueprint.nodes.length} Langflow + ComfyUI nodes`);
|
|
645
887
|
};
|
|
646
888
|
const compiledComfyPrompt = useMemo(() => {
|
|
@@ -660,110 +902,110 @@ export function FlowStudio({ host }) {
|
|
|
660
902
|
}
|
|
661
903
|
return out;
|
|
662
904
|
}, [activeBlueprint, moduleCatalog]);
|
|
905
|
+
// /v1/prompt only queues the graph. Nodes show what the engine's work-log says: Queued, Running, and Done only when it closes the run.
|
|
906
|
+
// Only the run in flight may write state; a new run, another template or leaving the page ends the one before.
|
|
907
|
+
const followed = useRef(runs());
|
|
908
|
+
useEffect(() => {
|
|
909
|
+
const f = followed.current;
|
|
910
|
+
f.stop();
|
|
911
|
+
setRunningFlow(false);
|
|
912
|
+
setNodeRunStatus({});
|
|
913
|
+
return () => f.stop();
|
|
914
|
+
}, [activeBlueprint.id]);
|
|
663
915
|
const runFlowPlayground = async () => {
|
|
916
|
+
if (runningFlow)
|
|
917
|
+
return;
|
|
918
|
+
const mine = followed.current.start();
|
|
919
|
+
setRunningFlow(true);
|
|
920
|
+
const nodes = activeBlueprint.nodes;
|
|
921
|
+
const mark = (state) => setNodeRunStatus(state ? Object.fromEntries(nodes.map((n) => [n.id, state])) : {});
|
|
664
922
|
const logs = [];
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
setExecutingNodeId(node.id);
|
|
668
|
-
logs.push(`[Step #${node.id} · ${node.family.toUpperCase()}] ${node.type} (${node.title}) → OK`);
|
|
923
|
+
const say = (line, status) => {
|
|
924
|
+
logs.push(`[${formatClock()}] ${line}`);
|
|
669
925
|
setPlaygroundOutput([...logs]);
|
|
670
|
-
|
|
671
|
-
}
|
|
926
|
+
setStatusMessage(status);
|
|
927
|
+
};
|
|
928
|
+
say(`Sending ${nodes.length} nodes of ${activeBlueprint.name} to /v1/prompt`, `Sending "${activeBlueprint.name}" to /v1/prompt…`);
|
|
672
929
|
try {
|
|
673
|
-
const
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
930
|
+
const end = await run(wire, compiledComfyPrompt, (state, note) => {
|
|
931
|
+
if (!mine.current())
|
|
932
|
+
return;
|
|
933
|
+
setRunningFlow(false);
|
|
934
|
+
mark(state);
|
|
935
|
+
say(`${state[0].toUpperCase()}${state.slice(1)}${note ? ` · ${note}` : ''}`, `"${activeBlueprint.name}" is ${state}${note ? `: ${note}` : ''}`);
|
|
936
|
+
}, { signal: mine.signal });
|
|
937
|
+
if (mine.current() && (end === 'queued' || end === 'running'))
|
|
938
|
+
say(`Still ${end}; no result yet`, `"${activeBlueprint.name}" is still ${end}; no result yet`);
|
|
939
|
+
}
|
|
940
|
+
catch (e) {
|
|
941
|
+
if (!mine.current())
|
|
942
|
+
return;
|
|
943
|
+
mark(null);
|
|
944
|
+
const why = e instanceof Error ? e.message : String(e);
|
|
945
|
+
say(`Not run · ${why}`, `"${activeBlueprint.name}" did not run: ${why}`);
|
|
685
946
|
}
|
|
686
947
|
finally {
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
setPlaygroundOutput([...logs]);
|
|
690
|
-
setStatusMessage(`✓ Completed Flow run "${activeBlueprint.name}" (${activeBlueprint.nodes.length} nodes)`);
|
|
948
|
+
if (mine.current())
|
|
949
|
+
setRunningFlow(false);
|
|
691
950
|
}
|
|
692
951
|
};
|
|
952
|
+
// Copilot asks the model to edit the graph and applies exactly the edit it answers with.
|
|
953
|
+
const [copilotBusy, setCopilotBusy] = useState(false);
|
|
693
954
|
const runCopilot = async () => {
|
|
694
955
|
const text = copilotInput.trim();
|
|
695
|
-
if (!text)
|
|
956
|
+
if (!text || copilotBusy)
|
|
696
957
|
return;
|
|
697
|
-
|
|
958
|
+
setCopilotBusy(true);
|
|
959
|
+
setStatusMessage(`Asking Flow Copilot: "${text}"…`);
|
|
698
960
|
try {
|
|
699
|
-
const
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
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
|
-
},
|
|
961
|
+
const said = await complete(wire, {
|
|
962
|
+
model: BRAIN,
|
|
963
|
+
messages: [
|
|
964
|
+
{ role: 'system', content: 'Mutate the Hanzo Flow (Langflow + ComfyUI) graph using the flow_mutate_graph MCP tool.' },
|
|
965
|
+
{ role: 'user', content: JSON.stringify({ instruction: text, graph: compiledComfyPrompt }) },
|
|
966
|
+
],
|
|
967
|
+
tools: [
|
|
968
|
+
{
|
|
969
|
+
type: 'function',
|
|
970
|
+
function: {
|
|
971
|
+
name: 'flow_mutate_graph',
|
|
972
|
+
description: 'Pure function: (Graph, Instruction) -> Graph',
|
|
973
|
+
parameters: {
|
|
974
|
+
type: 'object',
|
|
975
|
+
properties: {
|
|
976
|
+
add_node_type: { type: 'string' },
|
|
977
|
+
auto_layout: { type: 'boolean' },
|
|
727
978
|
},
|
|
728
979
|
},
|
|
729
980
|
},
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
981
|
+
},
|
|
982
|
+
],
|
|
983
|
+
}, () => { });
|
|
984
|
+
const got = graphEdit(said.calls);
|
|
985
|
+
const named = 'edit' in got && got.edit.addNodeType ? moduleCatalog.find((m) => m.type === got.edit.addNodeType) : undefined;
|
|
986
|
+
if (named) {
|
|
987
|
+
addModuleToCanvas(named);
|
|
988
|
+
setStatusMessage(`Copilot added ${named.type}`);
|
|
989
|
+
}
|
|
990
|
+
else if ('edit' in got && got.edit.autoLayout) {
|
|
991
|
+
autoLayout();
|
|
992
|
+
}
|
|
993
|
+
else {
|
|
994
|
+
setStatusMessage(`Copilot made no change: ${'why' in got ? got.why : 'it named a node this canvas does not have'}`);
|
|
995
|
+
return;
|
|
996
|
+
}
|
|
997
|
+
setCopilotInput('');
|
|
737
998
|
}
|
|
738
|
-
|
|
739
|
-
|
|
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);
|
|
999
|
+
catch (e) {
|
|
1000
|
+
setStatusMessage(`Copilot made no change: ${e instanceof Error ? e.message : String(e)}`);
|
|
755
1001
|
}
|
|
756
|
-
|
|
757
|
-
|
|
1002
|
+
finally {
|
|
1003
|
+
setCopilotBusy(false);
|
|
758
1004
|
}
|
|
759
|
-
setCopilotInput('');
|
|
760
1005
|
};
|
|
761
1006
|
const exportJson = () => {
|
|
762
1007
|
const blob = new Blob([JSON.stringify(compiledComfyPrompt, null, 2)], { type: 'application/json' });
|
|
763
|
-
|
|
764
|
-
a.href = URL.createObjectURL(blob);
|
|
765
|
-
a.download = `${activeBlueprint.id}.flow.json`;
|
|
766
|
-
a.click();
|
|
1008
|
+
download(`${activeBlueprint.id}.flow.json`, blob);
|
|
767
1009
|
};
|
|
768
1010
|
const importJson = () => {
|
|
769
1011
|
const input = document.createElement('input');
|
|
@@ -826,123 +1068,146 @@ export function FlowStudio({ host }) {
|
|
|
826
1068
|
input.click();
|
|
827
1069
|
};
|
|
828
1070
|
const TABS = [
|
|
829
|
-
{ id: 'canvas', label: '
|
|
830
|
-
{ id: 'comfy', label: 'ComfyUI
|
|
831
|
-
{ id: 'agents', label: '
|
|
832
|
-
{ id: 'code', label: 'Python
|
|
833
|
-
{ id: 'publish', label: 'Publish
|
|
1071
|
+
{ id: 'canvas', label: 'Canvas' },
|
|
1072
|
+
{ id: 'comfy', label: 'ComfyUI' },
|
|
1073
|
+
{ id: 'agents', label: 'Agents & MCP' },
|
|
1074
|
+
{ id: 'code', label: 'Python' },
|
|
1075
|
+
{ id: 'publish', label: 'Publish' },
|
|
834
1076
|
];
|
|
835
|
-
|
|
1077
|
+
const langflowCount = activeBlueprint.nodes.filter((n) => n.family === 'langflow').length;
|
|
1078
|
+
const comfyCount = activeBlueprint.nodes.filter((n) => n.family === 'comfy').length;
|
|
1079
|
+
const filteredCatalog = useMemo(() => moduleCatalog
|
|
1080
|
+
.filter((m) => {
|
|
1081
|
+
if (section === 'comfy')
|
|
1082
|
+
return m.family === 'comfy';
|
|
1083
|
+
if (section === 'agents')
|
|
1084
|
+
return m.family === 'langflow';
|
|
1085
|
+
return familyFilter === 'all' ? true : m.family === familyFilter;
|
|
1086
|
+
})
|
|
1087
|
+
.filter((m) => {
|
|
1088
|
+
const q = searchQuery.trim().toLowerCase();
|
|
1089
|
+
if (!q)
|
|
1090
|
+
return true;
|
|
1091
|
+
return m.type.toLowerCase().includes(q) || m.title.toLowerCase().includes(q) || m.pack.toLowerCase().includes(q);
|
|
1092
|
+
}), [moduleCatalog, section, familyFilter, searchQuery]);
|
|
1093
|
+
const visibleCatalog = catalogExpanded || searchQuery.trim().length > 0 ? filteredCatalog : filteredCatalog.slice(0, 5);
|
|
1094
|
+
return (_jsxs(YStack, { flex: 1, minH: 0, minW: 0, width: "100%", bg: "var(--background)", p: "$3", $md: { p: '$4' }, gap: "$3", overflowY: "auto", overflowX: "hidden", "data-slot": "flow-studio", children: [_jsxs(YStack, { gap: "$2.5", p: "$3", rounded: "$4", borderWidth: 1, borderColor: "var(--border)", bg: "var(--surface-card)", minW: 0, children: [_jsxs(XStack, { items: "center", justify: "space-between", flexWrap: "wrap", gap: "$2.5", minW: 0, children: [_jsxs(YStack, { gap: 2, flex: 1, minW: 200, children: [_jsxs(XStack, { items: "center", gap: "$2", children: [_jsx(Workflow, { size: 16, color: "$ink" }), _jsx(SizableText, { render: "h1", size: "$4", fontWeight: "600", color: "$ink", letterSpacing: -0.25, numberOfLines: 1, children: "Hanzo Flow \u2014 Visual workflow builder" })] }), _jsx(SizableText, { size: "$1", color: "$soft", numberOfLines: 2, children: statusMessage })] }), _jsxs(XStack, { items: "center", gap: "$1.5", flexWrap: "wrap", shrink: 0, maxW: "100%", children: [_jsx(DropdownMenu, { minWidth: 210, trigger: _jsxs(XStack, { render: _jsx("button", { type: "button" }), "aria-label": "Import or export flow JSON", items: "center", gap: "$1.5", px: "$3", minH: 44, "$max-sm": { minH: 44 }, $md: { minH: 32, height: 32 }, rounded: 999, borderWidth: 1, borderColor: "var(--border-strong)", bg: "transparent", cursor: "pointer", hoverStyle: { bg: '$hover' }, focusVisibleStyle: RING, shrink: 0, children: [_jsx(Download, { size: 13, color: "$ink" }), _jsx(SizableText, { size: "$1", fontWeight: "500", color: "$ink", children: "JSON" }), _jsx(ChevronDown, { size: 12, color: "$soft" })] }), items: [
|
|
1095
|
+
{ key: 'import', label: 'Import JSON', description: 'Load Langflow or ComfyUI graph', icon: _jsx(Upload, { size: 13, color: "$soft" }), onSelect: importJson },
|
|
1096
|
+
{ key: 'export', label: 'Export JSON', description: 'Download compiled /v1/prompt graph', icon: _jsx(Download, { size: 13, color: "$soft" }), onSelect: exportJson },
|
|
1097
|
+
{ type: 'separator', key: 's' },
|
|
1098
|
+
{ key: 'publish', label: 'Publish API / MCP', description: 'Inspect REST & MCP payload', icon: _jsx(Terminal, { size: 13, color: "$soft" }), onSelect: () => switchSection('publish') },
|
|
1099
|
+
] }), _jsxs(XStack, { render: _jsx("button", { type: "button" }), "aria-label": "Back to Hanzo Studio", onClick: () => host.open('/studio'), items: "center", gap: "$1.5", px: "$3", minH: 44, "$max-sm": { minH: 44 }, $md: { minH: 32, height: 32 }, rounded: 999, borderWidth: 1, borderColor: "var(--border-strong)", bg: "transparent", cursor: "pointer", hoverStyle: { bg: '$hover' }, focusVisibleStyle: RING, shrink: 0, children: [_jsx(ArrowLeft, { size: 13, color: "$ink" }), _jsx(SizableText, { size: "$1", fontWeight: "500", color: "$ink", children: "Back to Studio" })] })] })] }), _jsx(XStack, { role: "tablist", "aria-label": "Flow sections", gap: "$1.5", pt: "$1", pb: "$0.5", overflowX: "auto", flexWrap: "nowrap", width: "100%", display: "flex", $md: { display: 'none' }, style: { scrollbarWidth: 'none' }, children: TABS.map((t) => {
|
|
836
1100
|
const on = section === t.id;
|
|
837
|
-
return (
|
|
838
|
-
}) })] }), section === 'canvas' || section === 'comfy' || section === 'agents' ? (_jsxs(
|
|
1101
|
+
return (_jsx(XStack, { render: _jsx("button", { type: "button" }), role: "tab", "aria-selected": on, onClick: () => switchSection(t.id), px: "$3", minH: 44, "$max-sm": { minH: 44 }, items: "center", rounded: 999, borderWidth: 1, borderColor: on ? '$ink' : 'var(--border-strong)', bg: on ? 'var(--surface-card-emphasis)' : 'transparent', cursor: "pointer", hoverStyle: { bg: '$hover' }, focusVisibleStyle: RING, shrink: 0, children: _jsx(SizableText, { size: "$1", fontWeight: on ? '600' : '500', color: on ? '$ink' : '$soft', children: t.label }) }, t.id));
|
|
1102
|
+
}) })] }), section === 'canvas' || section === 'comfy' || section === 'agents' ? (_jsxs(YStack, { gap: "$3", flex: 1, minW: 0, width: "100%", $xl: { flexDirection: 'row', items: 'flex-start' }, children: [_jsxs(YStack, { width: "100%", minW: 0, $xl: { width: 276, shrink: 0 }, $xxl: { width: 288 }, gap: "$3", p: "$3", rounded: "$4", borderWidth: 1, borderColor: "var(--border)", bg: "var(--surface-card)", children: [_jsxs(YStack, { gap: "$2", minW: 0, children: [_jsx(SizableText, { render: "h2", size: "$3", fontWeight: "600", color: "$ink", children: "1. Flow templates" }), _jsx(YStack, { gap: "$1.5", role: "list", "aria-label": "Flow templates", minW: 0, children: blueprints.map((b) => {
|
|
839
1103
|
const on = b.id === activeBlueprint.id;
|
|
840
|
-
return (_jsxs(YStack, { render: "button",
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
{ id: '
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
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: {
|
|
1104
|
+
return (_jsx(YStack, { role: "listitem", width: "100%", minW: 0, children: _jsxs(YStack, { render: _jsx("button", { type: "button" }), onClick: () => {
|
|
1105
|
+
setActiveBlueprintId(b.id);
|
|
1106
|
+
setSelectedNodeId(b.nodes[0]?.id ?? '1');
|
|
1107
|
+
setConnectingFromId(null);
|
|
1108
|
+
setNodeRunStatus({});
|
|
1109
|
+
setZoom(1);
|
|
1110
|
+
setPan({ x: 0, y: 0 });
|
|
1111
|
+
}, width: "100%", minW: 0, minH: 44, "$max-sm": { minH: 44 }, p: "$2.5", rounded: "$3", borderWidth: 1, borderColor: on ? '$ink' : 'var(--border-strong)', bg: on ? 'var(--surface-card-emphasis)' : 'var(--background)', hoverStyle: { bg: '$hover' }, focusVisibleStyle: RING, gap: 3, items: "flex-start", cursor: "pointer", children: [_jsx(SizableText, { size: "$2", fontWeight: "600", color: "$ink", text: "left", numberOfLines: 2, children: b.name }), _jsx(SizableText, { size: "$1", color: "$soft", fontFamily: "$mono", text: "left", numberOfLines: 1, children: `${b.kind} · ${b.nodes.length} nodes` })] }) }, b.id));
|
|
1112
|
+
}) })] }), _jsxs(YStack, { gap: "$2", pt: "$2.5", borderTopWidth: 1, borderColor: "var(--border)", minW: 0, children: [_jsxs(XStack, { justify: "space-between", items: "center", gap: "$2", children: [_jsx(SizableText, { render: "h2", size: "$3", fontWeight: "600", color: "$ink", children: "2. Component library" }), _jsx(SizableText, { size: "$1", color: "$soft", fontFamily: "$mono", children: `${filteredCatalog.length} nodes` })] }), _jsx(FlowInput, { "aria-label": "Search Langflow and ComfyUI components", ...{
|
|
1113
|
+
placeholder: 'Search ZenAgent, RAG, MCP, Koma…',
|
|
1114
|
+
value: searchQuery,
|
|
1115
|
+
}, onChange: (e) => setSearchQuery(e.currentTarget.value) }), section !== 'comfy' && section !== 'agents' ? (_jsx(XStack, { gap: "$1.5", flexWrap: "wrap", children: [
|
|
1116
|
+
{ id: 'all', label: 'All' },
|
|
1117
|
+
{ id: 'langflow', label: 'Agents' },
|
|
1118
|
+
{ id: 'comfy', label: 'ComfyUI' },
|
|
1119
|
+
].map((f) => {
|
|
1120
|
+
const on = familyFilter === f.id;
|
|
1121
|
+
return (_jsx(XStack, { render: _jsx("button", { type: "button" }), "aria-pressed": on, onClick: () => setFamilyFilter(f.id), px: "$2.5", minH: 44, "$max-sm": { minH: 44 }, $md: { minH: 28, height: 28 }, items: "center", rounded: 999, borderWidth: 1, borderColor: on ? '$ink' : 'var(--border-strong)', bg: on ? 'var(--surface-card-emphasis)' : 'transparent', hoverStyle: { bg: '$hover' }, focusVisibleStyle: RING, cursor: "pointer", children: _jsx(SizableText, { size: "$1", fontWeight: on ? '600' : '500', color: on ? '$ink' : '$soft', children: f.label }) }, f.id));
|
|
1122
|
+
}) })) : null, _jsxs(YStack, { gap: "$1.5", maxH: 280, overflowY: "auto", pt: "$1", minW: 0, children: [visibleCatalog.map((spec) => (_jsxs(XStack, { render: _jsx("button", { type: "button" }), onClick: () => addModuleToCanvas(spec), width: "100%", minW: 0, minH: 44, "$max-sm": { minH: 44 }, p: "$2.5", rounded: "$3", borderWidth: 1, borderColor: "var(--border)", bg: "var(--background)", justify: "space-between", items: "center", gap: "$2", cursor: "pointer", hoverStyle: { bg: '$hover', borderColor: 'var(--border-strong)' }, focusVisibleStyle: RING, children: [_jsxs(YStack, { gap: 2, flex: 1, minW: 0, items: "flex-start", children: [_jsxs(XStack, { items: "center", gap: "$1.5", maxW: "100%", children: [_jsx(XStack, { width: 7, height: 7, rounded: 99, bg: spec.family === 'langflow' ? '$ink' : 'transparent', borderWidth: spec.family === 'langflow' ? 0 : 1.5, borderColor: "$soft", shrink: 0 }), _jsx(SizableText, { size: "$2", fontWeight: "600", color: "$ink", text: "left", numberOfLines: 1, children: `+ ${spec.type}` })] }), _jsx(SizableText, { size: "$1", color: "$soft", text: "left", numberOfLines: 1, children: `${spec.title} · ${spec.pack}` })] }), _jsx(SizableText, { size: "$1", color: "$soft", fontFamily: "$mono", shrink: 0, children: spec.outputPorts[0] || 'OUT' })] }, spec.type))), !searchQuery.trim() && filteredCatalog.length > 5 ? (_jsx(XStack, { render: _jsx("button", { type: "button" }), "aria-expanded": catalogExpanded, onClick: () => setCatalogExpanded((v) => !v), width: "100%", minH: 44, "$max-sm": { minH: 44 }, $md: { minH: 30, height: 30 }, px: "$2.5", rounded: "$3", borderWidth: 1, borderColor: "var(--border-strong)", bg: "transparent", items: "center", justify: "center", cursor: "pointer", hoverStyle: { bg: '$hover' }, focusVisibleStyle: RING, children: _jsx(SizableText, { size: "$1", fontWeight: "500", color: "$soft", children: catalogExpanded ? 'Show fewer nodes' : `Show all ${filteredCatalog.length} nodes` }) })) : null] })] })] }), _jsxs(YStack, { width: "100%", minW: 0, $xl: { flex: 1 }, gap: "$3", p: "$3.5", rounded: "$4", borderWidth: 1, borderColor: "var(--border)", bg: "var(--surface-card)", children: [_jsxs(XStack, { items: "flex-start", justify: "space-between", flexWrap: "wrap", gap: "$2.5", minW: 0, children: [_jsxs(YStack, { gap: 2, flex: 1, minW: 200, children: [_jsx(SizableText, { render: "h2", size: "$3", fontWeight: "600", color: "$ink", children: activeBlueprint.name }), _jsx(SizableText, { size: "$1", color: "$soft", fontFamily: "$mono", children: `${activeBlueprint.nodes.length} nodes (${langflowCount} Langflow · ${comfyCount} ComfyUI) · ${activeBlueprint.engine}` })] }), _jsxs(XStack, { gap: "$1.5", items: "center", flexWrap: "wrap", shrink: 0, children: [_jsx(XStack, { render: _jsx("button", { type: "button" }), onClick: autoLayout, px: "$2.5", minH: 44, "$max-sm": { minH: 44 }, $md: { minH: 32, height: 32 }, items: "center", rounded: 999, borderWidth: 1, borderColor: "var(--border-strong)", bg: "transparent", cursor: "pointer", hoverStyle: { bg: '$hover' }, focusVisibleStyle: RING, shrink: 0, children: _jsx(SizableText, { size: "$1", color: "$ink", children: "Auto-layout" }) }), _jsxs(XStack, { render: _jsx("button", { type: "button" }), onClick: () => switchSection('code'), px: "$2.5", minH: 44, "$max-sm": { minH: 44 }, $md: { minH: 32, height: 32 }, items: "center", gap: "$1", rounded: 999, borderWidth: 1, borderColor: "var(--border-strong)", bg: "transparent", cursor: "pointer", hoverStyle: { bg: '$hover' }, focusVisibleStyle: RING, shrink: 0, children: [_jsx(Code, { size: 12, color: "$ink" }), _jsx(SizableText, { size: "$1", color: "$ink", children: "Edit Python" })] }), _jsxs(XStack, { render: _jsx("button", { type: "button" }), "aria-label": "Run flow (/v1/prompt)", disabled: runningFlow, onClick: () => void runFlowPlayground(), px: "$4", minH: 44, "$max-sm": { minH: 44 }, $md: { minH: 32, height: 32 }, items: "center", gap: "$1.5", rounded: 999, bg: "$ink", opacity: runningFlow ? 0.65 : 1, cursor: runningFlow ? 'default' : 'pointer', hoverStyle: runningFlow ? undefined : { opacity: 0.9 }, focusVisibleStyle: RING, shrink: 0, children: [_jsx(Play, { size: 12, color: "$background" }), _jsx(SizableText, { size: "$2", color: "$background", fontWeight: "600", children: runningFlow ? 'Running…' : 'Run flow' })] })] })] }), _jsxs(XStack, { gap: "$2", items: "center", flexWrap: "wrap", minW: 0, children: [_jsx(FlowInput, { "aria-label": "Flow Copilot instruction", flex: 1, minW: 180, rounded: 999, px: "$3.5", ...{
|
|
1123
|
+
placeholder: 'Ask Copilot to add a node or tidy the layout…',
|
|
1124
|
+
value: copilotInput,
|
|
1125
|
+
onKeyDown: (e) => {
|
|
1126
|
+
if (e.key === 'Enter')
|
|
1127
|
+
void runCopilot();
|
|
1128
|
+
},
|
|
1129
|
+
}, onChange: (e) => setCopilotInput(e.currentTarget.value) }), _jsxs(XStack, { render: _jsx("button", { type: "button" }), onClick: () => void runCopilot(), disabled: copilotBusy, opacity: copilotBusy ? 0.6 : 1, px: "$3", minH: 44, "$max-sm": { minH: 44 }, $md: { minH: 34, height: 34 }, items: "center", gap: "$1.5", rounded: 999, borderWidth: 1, borderColor: "var(--border-strong)", bg: "transparent", cursor: "pointer", hoverStyle: { bg: '$hover' }, focusVisibleStyle: RING, shrink: 0, children: [_jsx(Wand2, { size: 13, color: "$ink" }), _jsx(SizableText, { size: "$1", fontWeight: "600", color: "$ink", children: copilotBusy ? 'Asking…' : 'Mutate flow' })] })] }), _jsxs("div", { ref: canvasViewportRef, onPointerDown: handleCanvasPointerDown, onPointerMove: handleCanvasPointerMove, onPointerUp: handleCanvasPointerUp, onPointerCancel: handleCanvasPointerUp, style: {
|
|
893
1130
|
position: 'relative',
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
1131
|
+
width: '100%',
|
|
1132
|
+
minHeight: 460,
|
|
1133
|
+
height: 480,
|
|
1134
|
+
borderRadius: 12,
|
|
1135
|
+
border: '1px solid var(--border-strong)',
|
|
1136
|
+
backgroundColor: 'var(--background)',
|
|
1137
|
+
backgroundImage: 'radial-gradient(color-mix(in srgb, var(--foreground) 12%, transparent) 1px, transparent 1px)',
|
|
1138
|
+
backgroundSize: `${Math.round(20 * zoom)}px ${Math.round(20 * zoom)}px`,
|
|
1139
|
+
backgroundPosition: `${pan.x}px ${pan.y}px`,
|
|
1140
|
+
overflow: 'hidden',
|
|
1141
|
+
cursor: isPanning ? 'grabbing' : 'grab',
|
|
1142
|
+
userSelect: 'none',
|
|
1143
|
+
touchAction: 'none',
|
|
1144
|
+
}, children: [_jsxs("div", { style: {
|
|
1145
|
+
position: 'absolute',
|
|
1146
|
+
inset: 0,
|
|
1147
|
+
transform: `translate(${pan.x}px, ${pan.y}px) scale(${zoom})`,
|
|
1148
|
+
transformOrigin: '0 0',
|
|
1149
|
+
transition: isPanning || draggingNodeId || reducedMotion() ? 'none' : 'transform 140ms ease-out',
|
|
1150
|
+
}, children: [_jsx("svg", { width: 1400, height: 560, style: { position: 'absolute', inset: 0, pointerEvents: 'none', overflow: 'visible' }, children: activeBlueprint.nodes.flatMap((targetNode) => targetNode.wiresFrom.map((sourceId, wireIdx) => {
|
|
1151
|
+
const sourceNode = activeBlueprint.nodes.find((n) => n.id === sourceId);
|
|
1152
|
+
if (!sourceNode)
|
|
1153
|
+
return null;
|
|
1154
|
+
const x1 = sourceNode.x + NODE_W;
|
|
1155
|
+
const y1 = sourceNode.y + 52;
|
|
1156
|
+
const x2 = targetNode.x;
|
|
1157
|
+
const y2 = targetNode.y + 38 + wireIdx * 18;
|
|
1158
|
+
const cx1 = x1 + Math.max(45, (x2 - x1) * 0.5);
|
|
1159
|
+
const cx2 = x2 - Math.max(45, (x2 - x1) * 0.5);
|
|
1160
|
+
const isRunningWire = nodeRunStatus[targetNode.id] === 'running' || nodeRunStatus[sourceId] === 'running';
|
|
1161
|
+
const isDoneWire = nodeRunStatus[sourceId] === 'done' && nodeRunStatus[targetNode.id] === 'done';
|
|
1162
|
+
const stroke = isRunningWire
|
|
1163
|
+
? 'var(--foreground)'
|
|
1164
|
+
: isDoneWire
|
|
1165
|
+
? 'var(--state-success)'
|
|
1166
|
+
: sourceNode.family === 'langflow'
|
|
1167
|
+
? 'color-mix(in srgb, var(--foreground) 52%, transparent)'
|
|
1168
|
+
: 'color-mix(in srgb, var(--foreground) 30%, transparent)';
|
|
1169
|
+
return (_jsxs("g", { children: [_jsx("path", { d: `M ${x1} ${y1} C ${cx1} ${y1}, ${cx2} ${y2}, ${x2} ${y2}`, fill: "none", stroke: stroke, strokeWidth: isRunningWire ? 2.6 : isDoneWire ? 2.1 : 1.6, strokeDasharray: sourceNode.family === 'comfy' && !isRunningWire && !isDoneWire ? '4 3' : undefined }), _jsx("circle", { cx: x1, cy: y1, r: 3.5, fill: stroke }), _jsx("circle", { cx: x2, cy: y2, r: 3.5, fill: stroke })] }, `${sourceId}->${targetNode.id}-${wireIdx}`));
|
|
1170
|
+
})) }), activeBlueprint.nodes.map((node) => {
|
|
1171
|
+
const selected = node.id === selectedNode.id;
|
|
1172
|
+
const runState = nodeRunStatus[node.id];
|
|
1173
|
+
const isRunning = runState === 'running';
|
|
1174
|
+
const isDone = runState === 'done';
|
|
1175
|
+
const pill = runState === 'queued' ? 'Queued' : runState === 'failed' ? 'Failed' : isRunning ? 'Running' : '';
|
|
1176
|
+
const spec = moduleCatalog.find((m) => m.type === node.type);
|
|
1177
|
+
const familyLabel = node.family === 'langflow' ? 'Langflow' : 'ComfyUI';
|
|
1178
|
+
return (_jsx("div", { "data-flow-node": "1", role: "group", tabIndex: 0, "aria-label": `Node ${node.id}: ${node.title}`, onPointerDown: (e) => handleNodePointerDown(node, e), onFocus: () => setSelectedNodeId(node.id), onKeyDown: (e) => {
|
|
1179
|
+
if (e.key === 'Enter' || e.key === ' ') {
|
|
1180
|
+
setSelectedNodeId(node.id);
|
|
1181
|
+
}
|
|
1182
|
+
}, style: {
|
|
1183
|
+
position: 'absolute',
|
|
1184
|
+
left: node.x,
|
|
1185
|
+
top: node.y,
|
|
1186
|
+
width: NODE_W,
|
|
1187
|
+
cursor: draggingNodeId === node.id ? 'grabbing' : 'grab',
|
|
1188
|
+
outline: 'none',
|
|
1189
|
+
}, children: _jsxs(YStack, { width: "100%", p: "$2.5", rounded: "$3", borderWidth: isRunning || selected ? 2 : 1, borderColor: isRunning
|
|
1190
|
+
? 'var(--foreground)'
|
|
1191
|
+
: isDone
|
|
1192
|
+
? 'var(--state-success)'
|
|
1193
|
+
: selected
|
|
1194
|
+
? 'var(--foreground)'
|
|
1195
|
+
: 'var(--border-strong)', bg: selected || isRunning ? 'var(--surface-card-emphasis)' : 'var(--surface-card)', boxShadow: isRunning ? '0 0 0 3px var(--ring-halo), var(--shadow-sheet-2)' : 'var(--shadow-sheet-2)', items: "flex-start", gap: "$1", children: [_jsxs(XStack, { justify: "space-between", items: "center", width: "100%", gap: "$1.5", children: [_jsxs(XStack, { items: "center", gap: "$1.5", flex: 1, minW: 0, children: [_jsx(XStack, { width: 7, height: 7, rounded: 99, bg: isDone ? 'var(--state-success)' : isRunning || node.family === 'langflow' ? 'var(--foreground)' : 'transparent', borderWidth: !isDone && !isRunning && node.family === 'comfy' ? 1.5 : 0, borderColor: "$soft", shrink: 0 }), _jsx(SizableText, { size: "$2", fontWeight: "600", color: "$ink", text: "left", numberOfLines: 1, flex: 1, minW: 0, children: `#${node.id} ${node.title}` })] }), pill ? (_jsx(XStack, { px: "$1.5", height: 20, rounded: 999, bg: "var(--surface-card-emphasis)", borderWidth: 1, borderColor: "$ink", items: "center", shrink: 0, children: _jsx(SizableText, { size: "$1", fontFamily: "$mono", color: "$ink", fontWeight: "600", children: pill }) })) : isDone ? (_jsx(XStack, { width: 18, height: 18, rounded: 999, bg: "var(--state-success-bg)", borderWidth: 1, borderColor: "var(--state-success)", items: "center", justify: "center", shrink: 0, "aria-label": "Done", ...{ title: 'Done' }, children: _jsx(Check, { size: 11, color: "var(--state-success)", "aria-hidden": true }) })) : null] }), _jsx(SizableText, { size: "$1", color: "$soft", fontFamily: "$mono", text: "left", numberOfLines: 1, children: `${familyLabel} · ${node.type} → ${(spec?.outputPorts ?? ['OUT']).join(',')}` }), _jsx(YStack, { gap: 1, pt: 2, width: "100%", items: "flex-start", children: Object.entries(node.inputs)
|
|
1196
|
+
.slice(0, 2)
|
|
1197
|
+
.map(([k, v]) => (_jsx(SizableText, { size: "$1", color: "$soft", text: "left", numberOfLines: 1, children: `${k}: ${String(v)}` }, k))) }), _jsxs(XStack, { justify: "space-between", items: "center", pt: "$1", width: "100%", gap: "$1", children: [connectingFromId && connectingFromId !== node.id ? (_jsx(XStack, { render: _jsx("button", { type: "button" }), onClick: () => toggleWire(connectingFromId, node.id), px: "$2", height: 24, "$max-sm": { minH: 44, height: 'auto' }, items: "center", rounded: 999, bg: "var(--state-success-bg)", borderWidth: 1, borderColor: "var(--state-success)", cursor: "pointer", focusVisibleStyle: RING, children: _jsx(SizableText, { size: "$1", color: "var(--state-success)", children: node.wiresFrom.includes(connectingFromId) ? 'Unlink' : 'Connect input' }) })) : (_jsx(SizableText, { size: "$1", color: "$soft", fontFamily: "$mono", children: node.wiresFrom.length > 0 ? `← [${node.wiresFrom.map((w) => `#${w}`).join(', ')}]` : 'Entry' })), _jsx(XStack, { render: _jsx("button", { type: "button" }), "aria-pressed": connectingFromId === node.id, onClick: () => setConnectingFromId(connectingFromId === node.id ? null : node.id), px: "$2", height: 24, "$max-sm": { minH: 44, height: 'auto' }, items: "center", rounded: 999, bg: connectingFromId === node.id ? 'var(--surface-card-emphasis)' : 'transparent', borderWidth: 1, borderColor: connectingFromId === node.id ? '$ink' : 'var(--border-strong)', cursor: "pointer", hoverStyle: { bg: '$hover' }, focusVisibleStyle: RING, children: _jsx(SizableText, { size: "$1", fontWeight: connectingFromId === node.id ? '600' : '400', color: connectingFromId === node.id ? '$ink' : '$soft', children: connectingFromId === node.id ? 'Wiring…' : 'Wire out' }) })] })] }) }, node.id));
|
|
1198
|
+
})] }), _jsxs(XStack, { "data-flow-toolbar": "1", role: "toolbar", "aria-label": "Canvas viewport and history controls", position: "absolute", b: 12, l: 12, p: "$1", gap: "$1", items: "center", rounded: "$3", borderWidth: 1, borderColor: "var(--border-strong)", bg: "var(--popover)", boxShadow: "var(--shadow-sheet-2)", z: 10, children: [_jsx(XStack, { render: _jsx("button", { type: "button" }), "aria-label": "Zoom out", disabled: zoom <= MIN_ZOOM, onClick: () => setZoom((z) => clampZoom(z - 0.1)), minW: 44, minH: 44, "$max-sm": { minW: 44, minH: 44 }, $md: { minW: 28, minH: 28, width: 28, height: 28 }, rounded: "$2", items: "center", justify: "center", opacity: zoom <= MIN_ZOOM ? 0.4 : 1, cursor: zoom <= MIN_ZOOM ? 'default' : 'pointer', hoverStyle: zoom <= MIN_ZOOM ? undefined : { bg: '$hover' }, focusVisibleStyle: RING, children: _jsx(Minus, { size: 13, color: "$ink" }) }), _jsx(XStack, { render: _jsx("button", { type: "button" }), "aria-label": `Zoom ${Math.round(zoom * 100)}%, reset to 100%`, onClick: () => {
|
|
1199
|
+
setZoom(1);
|
|
1200
|
+
setPan({ x: 0, y: 0 });
|
|
1201
|
+
}, minH: 44, "$max-sm": { minH: 44 }, $md: { minH: 28, height: 28 }, px: "$1.5", rounded: "$2", items: "center", justify: "center", cursor: "pointer", hoverStyle: { bg: '$hover' }, focusVisibleStyle: RING, children: _jsx(SizableText, { size: "$1", fontFamily: "$mono", color: "$ink", children: `${Math.round(zoom * 100)}%` }) }), _jsx(XStack, { render: _jsx("button", { type: "button" }), "aria-label": "Zoom in", disabled: zoom >= MAX_ZOOM, onClick: () => setZoom((z) => clampZoom(z + 0.1)), minW: 44, minH: 44, "$max-sm": { minW: 44, minH: 44 }, $md: { minW: 28, minH: 28, width: 28, height: 28 }, rounded: "$2", items: "center", justify: "center", opacity: zoom >= MAX_ZOOM ? 0.4 : 1, cursor: zoom >= MAX_ZOOM ? 'default' : 'pointer', hoverStyle: zoom >= MAX_ZOOM ? undefined : { bg: '$hover' }, focusVisibleStyle: RING, children: _jsx(Plus, { size: 13, color: "$ink" }) }), _jsxs(XStack, { render: _jsx("button", { type: "button" }), "aria-label": "Fit flow to canvas", onClick: fitCanvas, minH: 44, "$max-sm": { minH: 44 }, $md: { minH: 28, height: 28 }, px: "$2", gap: "$1", rounded: "$2", items: "center", justify: "center", cursor: "pointer", hoverStyle: { bg: '$hover' }, focusVisibleStyle: RING, children: [_jsx(Maximize2, { size: 12, color: "$soft" }), _jsx(SizableText, { size: "$1", color: "$ink", children: "Fit" })] }), _jsx(XStack, { width: 1, height: 16, bg: "var(--border)", mx: "$0.5" }), _jsxs(XStack, { render: _jsx("button", { type: "button" }), "aria-label": "Undo", disabled: !canUndo, onClick: undo, minH: 44, "$max-sm": { minH: 44 }, $md: { minH: 28, height: 28 }, px: "$2", gap: "$1", rounded: "$2", items: "center", justify: "center", opacity: canUndo ? 1 : 0.4, cursor: canUndo ? 'pointer' : 'default', hoverStyle: canUndo ? { bg: '$hover' } : undefined, focusVisibleStyle: RING, children: [_jsx(Undo2, { size: 12, color: "$ink" }), _jsx(SizableText, { size: "$1", color: "$ink", children: "Undo" })] }), _jsxs(XStack, { render: _jsx("button", { type: "button" }), "aria-label": "Redo", disabled: !canRedo, onClick: redo, minH: 44, "$max-sm": { minH: 44 }, $md: { minH: 28, height: 28 }, px: "$2", gap: "$1", rounded: "$2", items: "center", justify: "center", opacity: canRedo ? 1 : 0.4, cursor: canRedo ? 'pointer' : 'default', hoverStyle: canRedo ? { bg: '$hover' } : undefined, focusVisibleStyle: RING, children: [_jsx(Redo2, { size: 12, color: "$ink" }), _jsx(SizableText, { size: "$1", color: "$ink", children: "Redo" })] })] })] }), _jsxs(YStack, { p: "$2.5", pb: "$3", rounded: "$3", borderWidth: 1, borderColor: "var(--border-strong)", bg: "var(--background)", gap: "$1", minW: 0, children: [_jsxs(XStack, { items: "center", justify: "space-between", gap: "$2", children: [_jsx(SizableText, { size: "$2", fontWeight: "600", color: "$ink", children: "Step-through execution log" }), _jsx(SizableText, { size: "$1", fontFamily: "$mono", color: "$soft", children: "Drag canvas to pan \u00B7 \u2318Z undo \u00B7 Del remove node" })] }), playgroundOutput.slice(-5).map((line, i) => (_jsx(SizableText, { size: "$1", color: /\] Done/.test(line) ? 'var(--state-success)' : '$soft', fontFamily: "$mono", children: line }, i)))] })] }), _jsxs(YStack, { width: "100%", minW: 0, $xl: { width: 268, shrink: 0 }, $xxl: { width: 280 }, gap: "$2.5", p: "$3", rounded: "$4", borderWidth: 1, borderColor: "var(--border)", bg: "var(--surface-card)", children: [_jsxs(XStack, { justify: "space-between", items: "center", gap: "$2", minW: 0, children: [_jsx(SizableText, { render: "h2", size: "$3", fontWeight: "600", color: "$ink", numberOfLines: 1, flex: 1, minW: 0, children: `#${selectedNode.id} ${selectedNode.title}` }), activeBlueprint.nodes.length > 1 ? (_jsx(XStack, { render: _jsx("button", { type: "button" }), onClick: () => deleteNode(selectedNode.id), px: "$2.5", minH: 44, "$max-sm": { minH: 44 }, $md: { minH: 28, height: 28 }, items: "center", rounded: 999, borderWidth: 1, borderColor: "var(--border-strong)", cursor: "pointer", hoverStyle: { bg: '$hover' }, focusVisibleStyle: RING, shrink: 0, children: _jsx(SizableText, { size: "$1", color: "$soft", children: "Delete" }) })) : null] }), _jsx(SizableText, { size: "$1", color: "$soft", fontFamily: "$mono", children: `${selectedNode.family === 'langflow' ? 'Langflow' : 'ComfyUI'} · class_type: ${selectedNode.type}` }), _jsx(YStack, { gap: "$2.5", pt: "$1", minW: 0, children: Object.entries(selectedNode.inputs).map(([key, val]) => {
|
|
1202
|
+
const isMultiline = typeof val === 'string' && MULTILINE_INPUT_KEYS.has(key);
|
|
1203
|
+
return (_jsxs(YStack, { gap: "$1", minW: 0, children: [_jsx(SizableText, { size: "$1", color: "$soft", fontFamily: "$mono", children: key }), isMultiline ? (_jsx(FlowInspectorTextarea, { "aria-label": `Node input ${key}`, lineHeight: 19, style: { resize: 'none' }, ...{ value: String(val), rows: 3 }, onChange: (e) => {
|
|
1204
|
+
updateNodeInput(key, e.currentTarget.value);
|
|
1205
|
+
} })) : (_jsx(FlowInput, { "aria-label": `Node input ${key}`, ...{
|
|
1206
|
+
type: typeof val === 'number' ? 'number' : 'text',
|
|
1207
|
+
value: String(val),
|
|
1208
|
+
}, onChange: (e) => {
|
|
1209
|
+
const raw = e.currentTarget.value;
|
|
1210
|
+
updateNodeInput(key, typeof val === 'number' ? Number(raw) : raw);
|
|
1211
|
+
} }))] }, key));
|
|
1212
|
+
}) })] })] })) : null, section === 'code' ? (_jsxs(YStack, { gap: "$3", p: "$3", rounded: "$4", borderWidth: 1, borderColor: "var(--border)", bg: "var(--surface-card)", minW: 0, children: [_jsxs(XStack, { justify: "space-between", items: "center", flexWrap: "wrap", gap: "$2", children: [_jsxs(YStack, { gap: 2, flex: 1, minW: 200, children: [_jsx(SizableText, { render: "h2", size: "$3", fontWeight: "600", color: "$ink", 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: _jsx("button", { type: "button" }), onClick: saveNodePythonCode, px: "$4", minH: 44, "$max-sm": { minH: 44 }, $md: { minH: 32, height: 32 }, items: "center", rounded: 999, bg: "$ink", cursor: "pointer", hoverStyle: { opacity: 0.9 }, focusVisibleStyle: RING, shrink: 0, children: _jsx(SizableText, { size: "$2", color: "$background", fontWeight: "600", children: "Save Python component" }) })] }), _jsx(FlowTextarea, { "aria-label": "Python node class source code", lineHeight: 20, ...{ value: pythonDraft, rows: 16 }, onChange: (e) => setPythonDraft(e.currentTarget.value) })] })) : null, section === 'publish' ? (_jsxs(YStack, { gap: "$3", p: "$3", rounded: "$4", borderWidth: 1, borderColor: "var(--border)", bg: "var(--surface-card)", minW: 0, children: [_jsx(SizableText, { render: "h2", size: "$3", fontWeight: "600", color: "$ink", 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: "var(--border-strong)", bg: "var(--background)", maxH: 460, overflow: "scroll", minW: 0, children: _jsx(SizableText, { fontFamily: "$mono", size: "$1", color: "$ink", whiteSpace: "pre", children: JSON.stringify(compiledComfyPrompt, null, 2) }) })] })) : null] }));
|
|
948
1213
|
}
|