@hanzo/studio 0.1.21 → 0.1.23

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.
@@ -12,6 +12,7 @@
12
12
  import type { Host } from '@hanzo/build';
13
13
  import type { RailLink } from '@hanzo/ui/chat';
14
14
  import { parseStudioSection, type StudioSection } from './sections.ts';
15
+ import { type Hosted } from '../host.tsx';
15
16
  export { parseStudioSection, type StudioSection };
16
17
  export declare function directorNav(host: Host, go: (path: string) => void): {
17
18
  id: 'make';
@@ -130,5 +131,5 @@ export interface CinemaShot {
130
131
  videoUrl?: string;
131
132
  }
132
133
  export declare function DirectorStudio({ host }: {
133
- host: Host;
134
+ host: Hosted;
134
135
  }): import("react").JSX.Element;
@@ -9,7 +9,9 @@ import { parseStudioSection } from './sections.js';
9
9
  import { useWire } from '../live.js';
10
10
  import { render } from '../gpu.js';
11
11
  import { runs } from './flow-run.js';
12
- import { ask, documents, gpus } from '../wire.js';
12
+ import { ask, documents, gpus, speak } from '../wire.js';
13
+ import { useSpend } from '../host.js';
14
+ import { VOICE } from '../kinds/sound.js';
13
15
  const StudioInput = styled(SizableText, {
14
16
  name: 'DirectorFieldInput',
15
17
  render: 'input',
@@ -320,6 +322,7 @@ const INITIAL_LIBRARY = [
320
322
  ];
321
323
  export function DirectorStudio({ host }) {
322
324
  const wire = useWire(host);
325
+ const { spend: confirm, dialog } = useSpend(host);
323
326
  const [section, setSection] = useState(() => parseStudioSection(host.path));
324
327
  useEffect(() => {
325
328
  setSection(parseStudioSection(host.path));
@@ -382,7 +385,7 @@ export function DirectorStudio({ host }) {
382
385
  const [musicBpm, setMusicBpm] = useState(122);
383
386
  const [musicKey, setMusicKey] = useState('F Minor');
384
387
  const [voiceLine, setVoiceLine] = useState('Every node in the cluster is resonating at forty-two hertz. Watch the phase lock.');
385
- const [voicePreset, setVoicePreset] = useState('koe-baritone');
388
+ const [voicePreset, setVoicePreset] = useState('onyx');
386
389
  const [dawPlaying, setDawPlaying] = useState(false);
387
390
  const [stems, setStems] = useState([
388
391
  { id: 'stem-drums', name: 'Drums & Percussion', role: 'ACE-Step Rhythm Stem', freq: 110, volume: 85, muted: false, solo: false, color: '#38bdf8' },
@@ -424,6 +427,7 @@ export function DirectorStudio({ host }) {
424
427
  const [showAllLenses, setShowAllLenses] = useState(false);
425
428
  const [creatingAsset, setCreatingAsset] = useState(false);
426
429
  const [generatingDoc, setGeneratingDoc] = useState(false);
430
+ const [reading, setReading] = useState(false);
427
431
  // The pictures made here are object addresses; they and any render in flight end with the page.
428
432
  const madeUrls = useRef([]);
429
433
  // A render gets its own controller when it starts, so a StrictMode remount cannot leave a spent one behind.
@@ -439,12 +443,15 @@ export function DirectorStudio({ host }) {
439
443
  if (creatingAsset)
440
444
  return;
441
445
  setCreatingAsset(true);
442
- triggerCinemaAudio();
443
446
  const newId = `lib-${Date.now().toString(36)}`;
444
447
  const compiled = `${createPrompt} — [${selectedLane.label}, brand=${selectedBrand.name}: ${selectedBrand.directives}]`;
445
448
  setStatusNote(`Sending ${selectedLane.label} to your GPU from words only: the lane and brand kit are written into the prompt, and no reference picture is sent.`);
446
- const ctl = rendering.current.start();
447
449
  try {
450
+ if (!(await confirm('design-gpu', { title: 'Make this picture?', what: "This renders one picture on your organization's GPU, where it keeps going if you leave this page." }))) {
451
+ setStatusNote('Not started.');
452
+ return;
453
+ }
454
+ const ctl = rendering.current.start();
448
455
  const [first] = await render(wire, 'image', { prompt: `${compiled}. ${selectedLane.promptSuffix}`, width: 1024, height: 1024 }, (line) => setStatusNote(`${selectedLane.label}: ${line}`), ctl.signal);
449
456
  if (!first)
450
457
  throw new Error('The render finished with no image.');
@@ -478,9 +485,12 @@ export function DirectorStudio({ host }) {
478
485
  if (generatingDoc)
479
486
  return;
480
487
  setGeneratingDoc(true);
481
- triggerCinemaAudio();
482
- setStatusNote(`Generating ${tpl.title} (${tpl.format}) with ${selectedBrand.name} design system → ${tpl.endpoint}…`);
483
488
  try {
489
+ if (!(await confirm('document', { what: `This makes one ${tpl.title} (${tpl.format}) from your brief.` }))) {
490
+ setStatusNote('Not started.');
491
+ return;
492
+ }
493
+ setStatusNote(`Generating ${tpl.title} (${tpl.format}) with ${selectedBrand.name} design system → ${tpl.endpoint}…`);
484
494
  const fields = { category: tpl.category, format: tpl.format, brand_system: selectedBrand.id };
485
495
  const body = tpl.endpoint === '/v1/documents/generate'
486
496
  ? await documents.generate(wire, { templateId: tpl.id, description: docBrief, fields })
@@ -908,35 +918,10 @@ export function DirectorStudio({ host }) {
908
918
  raf = requestAnimationFrame(draw3D);
909
919
  return () => cancelAnimationFrame(raf);
910
920
  }, [section, activeMesh, meshShader, meshAutoRotate, meshLightAngle, meshOctree]);
911
- const triggerCinemaAudio = () => {
912
- try {
913
- const Ctx = window.AudioContext || window.webkitAudioContext;
914
- const ctx = audioCtxRef.current ?? new Ctx();
915
- audioCtxRef.current = ctx;
916
- if (ctx.state === 'suspended')
917
- void ctx.resume();
918
- const now = ctx.currentTime;
919
- const osc = ctx.createOscillator();
920
- const gain = ctx.createGain();
921
- osc.type = 'sawtooth';
922
- osc.frequency.setValueAtTime(55, now);
923
- osc.frequency.exponentialRampToValueAtTime(110, now + 1.2);
924
- gain.gain.setValueAtTime(0.001, now);
925
- gain.gain.exponentialRampToValueAtTime(0.12, now + 0.15);
926
- gain.gain.exponentialRampToValueAtTime(0.001, now + 1.6);
927
- osc.connect(gain);
928
- gain.connect(ctx.destination);
929
- osc.start(now);
930
- osc.stop(now + 1.65);
931
- }
932
- catch {
933
- // Ignore if audio is blocked
934
- }
935
- };
936
921
  const renderShotOnCloud = async (shot) => {
922
+ if (renderingId)
923
+ return;
937
924
  setRenderingId(shot.id);
938
- updateShot({ status: 'rendering' });
939
- triggerCinemaAudio();
940
925
  const compiledPrompt = [
941
926
  `[CINEMA SHOT ${shot.number}: ${shot.title}]`,
942
927
  `Subject & Cast Lock: ${activeCharacter.name} (${activeCharacter.wardrobe}, seed ${activeCharacter.seed}).`,
@@ -945,8 +930,13 @@ export function DirectorStudio({ host }) {
945
930
  `Optics: ${activeLens.label}, aperture ${shot.aperture}, aspect ${activeLens.aspect}.`,
946
931
  `Lighting: ${activeLighting.label}.`,
947
932
  ].join(' ');
948
- setStatusNote(`Dispatching Shot ${shot.number} (${activeCamera.code}) to Hanzo Studio Koma 2.0 lane…`);
949
933
  try {
934
+ if (!(await confirm('design-gpu', { title: 'Render this shot?', what: `This renders Shot ${shot.number} on your organization's GPU, where it keeps going if you leave this page.` }))) {
935
+ setStatusNote('Not started.');
936
+ return;
937
+ }
938
+ updateShot({ status: 'rendering' });
939
+ setStatusNote(`Dispatching Shot ${shot.number} (${activeCamera.code}) to Hanzo Studio Koma 2.0 lane…`);
950
940
  const body = await ask(wire, 'api', '/v1/videos', {
951
941
  body: {
952
942
  model: 'koma-cinema-v2',
@@ -974,6 +964,29 @@ export function DirectorStudio({ host }) {
974
964
  setRenderingId(null);
975
965
  }
976
966
  };
967
+ // The platform's voice reads the script, asked first; what is made plays, and nothing stands in for it.
968
+ const readAloud = async () => {
969
+ if (reading)
970
+ return;
971
+ setReading(true);
972
+ try {
973
+ if (!(await confirm('voice'))) {
974
+ setStatusNote('Not started.');
975
+ return;
976
+ }
977
+ setStatusNote(`Reading it aloud (${voicePreset})…`);
978
+ const url = URL.createObjectURL(await speak(wire, voiceLine.slice(0, 4000), voicePreset, VOICE));
979
+ madeUrls.current.push(url);
980
+ void new Audio(url).play().catch(() => setStatusNote('Made, but this browser would not play it.'));
981
+ setStatusNote(`Read aloud in ${voicePreset}`);
982
+ }
983
+ catch (e) {
984
+ setStatusNote(`Could not read it aloud: ${e instanceof Error ? e.message : String(e)}`);
985
+ }
986
+ finally {
987
+ setReading(false);
988
+ }
989
+ };
977
990
  const exportSequenceJson = () => {
978
991
  const payload = {
979
992
  project: 'Hanzo Studio Cinema Production',
@@ -1145,10 +1158,7 @@ export function DirectorStudio({ host }) {
1145
1158
  }, height: 36, rounded: 999, bg: "$ink", items: "center", justify: "center", gap: "$1.5", cursor: "pointer", children: [_jsx(Sparkles, { size: 14 }), _jsx(SizableText, { size: "$2", color: "$background", fontWeight: "600", children: "Generate Song & Stems (ACE-Step)" })] })] }), _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: "center", justify: "space-between", flexWrap: "wrap", gap: "$2", children: [_jsxs(YStack, { gap: 2, minW: 0, children: [_jsx(SizableText, { render: "h2", size: "$3", fontWeight: "600", color: "$ink", children: "Multi-stem DAW & waveform sequencer" }), _jsx(SizableText, { size: "$1", color: "$soft", fontFamily: "$mono", children: `${musicBpm} BPM · ${musicKey} · 48kHz 24-bit stems` })] }), _jsx(XStack, { gap: "$2", children: _jsxs(XStack, { render: _jsx("button", { type: "button" }), "aria-pressed": dawPlaying, onClick: () => setDawPlaying((p) => !p), px: "$3.5", minH: 44, "$max-sm": { minH: 44 }, $md: { minH: 32, height: 32 }, rounded: 999, bg: dawPlaying ? 'var(--surface-card-emphasis)' : 'transparent', borderWidth: 1, borderColor: dawPlaying ? '$ink' : 'var(--border-strong)', hoverStyle: { bg: '$hover' }, focusVisibleStyle: RING, items: "center", gap: "$1.5", cursor: "pointer", children: [_jsx(Play, { size: 13, color: "$ink" }), _jsx(SizableText, { size: "$1", color: "$ink", fontWeight: "600", children: dawPlaying ? 'Stop synth engine' : 'Play live stems' })] }) })] }), _jsx(YStack, { rounded: "$4", overflow: "hidden", borderWidth: 1, borderColor: "var(--border-strong)", bg: "var(--surface-card)", children: _jsx("canvas", { ref: audioWaveCanvasRef, width: 780, height: 220, style: { width: '100%', height: 'auto', display: 'block' } }) }), _jsx(YStack, { gap: "$2", role: "list", "aria-label": "Audio stems", minW: 0, children: stems.map((stem) => (_jsxs(XStack, { role: "listitem", items: "center", justify: "space-between", flexWrap: "wrap", gap: "$2.5", p: "$2.5", rounded: "$3", borderWidth: 1, borderColor: "var(--border-strong)", bg: "var(--background)", minW: 0, children: [_jsxs(XStack, { items: "center", gap: "$2", width: 180, minW: 0, children: [_jsx(XStack, { width: 9, height: 9, rounded: 99, shrink: 0, borderWidth: 1, borderColor: "var(--border-strong)", style: { backgroundColor: stem.color, border: '1px solid var(--border-strong)' } }), _jsxs(YStack, { minW: 0, children: [_jsx(SizableText, { size: "$2", fontWeight: "600", color: "$ink", numberOfLines: 1, children: stem.name }), _jsx(SizableText, { size: "$1", color: "$soft", numberOfLines: 1, children: stem.role })] })] }), _jsx("input", { "aria-label": `${stem.name} volume`, type: "range", min: 0, max: 100, value: stem.volume, onChange: (e) => {
1146
1159
  const v = Number(e.currentTarget.value);
1147
1160
  setStems((prev) => prev.map((s) => (s.id === stem.id ? { ...s, volume: v } : s)));
1148
- }, style: { flex: 1, minWidth: 100 } }), _jsxs(XStack, { gap: "$1.5", shrink: 0, children: [_jsx(XStack, { render: _jsx("button", { type: "button" }), "aria-label": `Mute ${stem.name}`, "aria-pressed": stem.muted, onClick: () => setStems((prev) => prev.map((s) => (s.id === stem.id ? { ...s, muted: !s.muted } : s))), px: "$2.5", minW: 44, minH: 44, "$max-sm": { minW: 44, minH: 44 }, $md: { minW: 30, minH: 26, height: 26 }, items: "center", justify: "center", rounded: "$2", borderWidth: 1, borderColor: stem.muted ? '$ink' : 'var(--border-strong)', bg: stem.muted ? 'var(--surface-card-emphasis)' : 'transparent', hoverStyle: { bg: '$hover' }, focusVisibleStyle: RING, cursor: "pointer", children: _jsx(SizableText, { size: "$1", fontWeight: stem.muted ? '600' : '500', color: stem.muted ? '$ink' : '$soft', children: "M" }) }), _jsx(XStack, { render: _jsx("button", { type: "button" }), "aria-label": `Solo ${stem.name}`, "aria-pressed": stem.solo, onClick: () => setStems((prev) => prev.map((s) => (s.id === stem.id ? { ...s, solo: !s.solo } : s))), px: "$2.5", minW: 44, minH: 44, "$max-sm": { minW: 44, minH: 44 }, $md: { minW: 30, minH: 26, height: 26 }, items: "center", justify: "center", rounded: "$2", borderWidth: 1, borderColor: stem.solo ? '$ink' : 'var(--border-strong)', bg: stem.solo ? 'var(--surface-card-emphasis)' : 'transparent', hoverStyle: { bg: '$hover' }, focusVisibleStyle: RING, cursor: "pointer", children: _jsx(SizableText, { size: "$1", fontWeight: stem.solo ? '600' : '500', color: stem.solo ? '$ink' : '$soft', children: "S" }) })] })] }, stem.id))) })] }), _jsxs(YStack, { width: "100%", minW: 0, $xl: { width: 268, shrink: 0 }, $xxl: { width: 280 }, gap: "$3", p: "$3", rounded: "$4", borderWidth: 1, borderColor: "var(--border)", bg: "var(--surface-card)", children: [_jsx(SizableText, { render: "h2", size: "$3", fontWeight: "600", color: "$ink", children: "Koe voice & dialogue studio" }), _jsx(SizableText, { size: "$1", color: "$soft", children: "Zero-shot voice cloning & emotional speech synthesis (/v1/audio/speech)." }), _jsx(YStack, { gap: "$1.5", children: ['koe-baritone', 'koe-alto', 'koe-narrator', 'oto-cyber'].map((vp) => (_jsxs(XStack, { render: _jsx("button", { type: "button" }), onClick: () => setVoicePreset(vp), px: "$2.5", minH: 44, "$max-sm": { minH: 44 }, $md: { minH: 32 }, py: "$1.5", rounded: "$3", "aria-pressed": voicePreset === vp, borderWidth: voicePreset === vp ? 1.5 : 1, borderColor: voicePreset === vp ? 'var(--foreground)' : 'var(--border-strong)', bg: voicePreset === vp ? 'var(--surface-card)' : 'var(--background)', boxShadow: voicePreset === vp ? 'var(--shadow-sheet-2)' : undefined, hoverStyle: { bg: voicePreset === vp ? 'var(--surface-card)' : '$hover', borderColor: voicePreset === vp ? 'var(--foreground)' : 'var(--border-strong)' }, focusVisibleStyle: RING, justify: "space-between", items: "center", cursor: "pointer", children: [_jsx(SizableText, { size: "$2", fontWeight: "600", fontFamily: "$mono", color: "$ink", children: vp }), _jsx(SizableText, { size: "$1", color: "$soft", children: "24kHz neural" })] }, vp))) }), _jsx(StudioTextarea, { "aria-label": "Voice narration script", ...{ value: voiceLine, rows: 4 }, onChange: (e) => setVoiceLine(e.currentTarget.value) }), _jsxs(XStack, { render: "button", onPress: () => {
1149
- triggerCinemaAudio();
1150
- setStatusNote(`Synthesized Koe voice stem (${voicePreset}) → added to Vocal Stem`);
1151
- }, height: 34, rounded: 999, borderWidth: 1, borderColor: "$borderColor", items: "center", justify: "center", gap: "$1.5", cursor: "pointer", hoverStyle: { bg: '$hover' }, children: [_jsx(Wand2, { size: 13 }), _jsx(SizableText, { size: "$1", fontWeight: "600", children: "Synthesize Voice Stem" })] })] })] })) : null, section === 'model3d' ? (_jsxs(YStack, { gap: "$3", flex: 1, width: "100%", minW: 0, $lg: { flexDirection: 'row', items: 'flex-start' }, children: [_jsxs(YStack, { width: "100%", minW: 0, $lg: { width: 276, shrink: 0 }, $xl: { width: 288 }, gap: "$3", p: "$3", rounded: "$4", borderWidth: 1, borderColor: "var(--border)", bg: "var(--surface-card)", children: [_jsx(SizableText, { render: "h2", size: "$3", fontWeight: "600", color: "$ink", children: "Mori 3D 2.1 mesh generator" }), _jsx(SizableText, { size: "$1", color: "$soft", children: "Convert a reference photo or prompt into a watertight textured .glb mesh on GB10 / H100 GPUs." }), _jsx(YStack, { gap: "$2", role: "list", "aria-label": "3D mesh presets", children: MESH_PRESETS.map((m) => {
1161
+ }, style: { flex: 1, minWidth: 100 } }), _jsxs(XStack, { gap: "$1.5", shrink: 0, children: [_jsx(XStack, { render: _jsx("button", { type: "button" }), "aria-label": `Mute ${stem.name}`, "aria-pressed": stem.muted, onClick: () => setStems((prev) => prev.map((s) => (s.id === stem.id ? { ...s, muted: !s.muted } : s))), px: "$2.5", minW: 44, minH: 44, "$max-sm": { minW: 44, minH: 44 }, $md: { minW: 30, minH: 26, height: 26 }, items: "center", justify: "center", rounded: "$2", borderWidth: 1, borderColor: stem.muted ? '$ink' : 'var(--border-strong)', bg: stem.muted ? 'var(--surface-card-emphasis)' : 'transparent', hoverStyle: { bg: '$hover' }, focusVisibleStyle: RING, cursor: "pointer", children: _jsx(SizableText, { size: "$1", fontWeight: stem.muted ? '600' : '500', color: stem.muted ? '$ink' : '$soft', children: "M" }) }), _jsx(XStack, { render: _jsx("button", { type: "button" }), "aria-label": `Solo ${stem.name}`, "aria-pressed": stem.solo, onClick: () => setStems((prev) => prev.map((s) => (s.id === stem.id ? { ...s, solo: !s.solo } : s))), px: "$2.5", minW: 44, minH: 44, "$max-sm": { minW: 44, minH: 44 }, $md: { minW: 30, minH: 26, height: 26 }, items: "center", justify: "center", rounded: "$2", borderWidth: 1, borderColor: stem.solo ? '$ink' : 'var(--border-strong)', bg: stem.solo ? 'var(--surface-card-emphasis)' : 'transparent', hoverStyle: { bg: '$hover' }, focusVisibleStyle: RING, cursor: "pointer", children: _jsx(SizableText, { size: "$1", fontWeight: stem.solo ? '600' : '500', color: stem.solo ? '$ink' : '$soft', children: "S" }) })] })] }, stem.id))) })] }), _jsxs(YStack, { width: "100%", minW: 0, $xl: { width: 268, shrink: 0 }, $xxl: { width: 280 }, gap: "$3", p: "$3", rounded: "$4", borderWidth: 1, borderColor: "var(--border)", bg: "var(--surface-card)", children: [_jsx(SizableText, { render: "h2", size: "$3", fontWeight: "600", color: "$ink", children: "Voice: read a script aloud" }), _jsx(SizableText, { size: "$1", color: "$soft", children: "The platform's voice reads your script (/v1/audio/speech). It asks first and counts against your plan." }), _jsx(YStack, { gap: "$1.5", children: ['onyx', 'nova', 'fable', 'echo'].map((vp) => (_jsx(XStack, { render: _jsx("button", { type: "button" }), onClick: () => setVoicePreset(vp), px: "$2.5", minH: 44, "$max-sm": { minH: 44 }, $md: { minH: 32 }, py: "$1.5", rounded: "$3", "aria-pressed": voicePreset === vp, borderWidth: voicePreset === vp ? 1.5 : 1, borderColor: voicePreset === vp ? 'var(--foreground)' : 'var(--border-strong)', bg: voicePreset === vp ? 'var(--surface-card)' : 'var(--background)', boxShadow: voicePreset === vp ? 'var(--shadow-sheet-2)' : undefined, hoverStyle: { bg: voicePreset === vp ? 'var(--surface-card)' : '$hover', borderColor: voicePreset === vp ? 'var(--foreground)' : 'var(--border-strong)' }, focusVisibleStyle: RING, justify: "space-between", items: "center", cursor: "pointer", children: _jsx(SizableText, { size: "$2", fontWeight: "600", fontFamily: "$mono", color: "$ink", children: vp }) }, vp))) }), _jsx(StudioTextarea, { "aria-label": "Voice narration script", ...{ value: voiceLine, rows: 4 }, onChange: (e) => setVoiceLine(e.currentTarget.value) }), _jsxs(XStack, { render: "button", onPress: () => void readAloud(), height: 34, rounded: 999, borderWidth: 1, borderColor: "$borderColor", items: "center", justify: "center", gap: "$1.5", cursor: "pointer", hoverStyle: { bg: '$hover' }, children: [_jsx(Wand2, { size: 13 }), _jsx(SizableText, { size: "$1", fontWeight: "600", children: reading ? 'Reading…' : 'Read it aloud' })] })] })] })) : null, section === 'model3d' ? (_jsxs(YStack, { gap: "$3", flex: 1, width: "100%", minW: 0, $lg: { flexDirection: 'row', items: 'flex-start' }, children: [_jsxs(YStack, { width: "100%", minW: 0, $lg: { width: 276, shrink: 0 }, $xl: { width: 288 }, gap: "$3", p: "$3", rounded: "$4", borderWidth: 1, borderColor: "var(--border)", bg: "var(--surface-card)", children: [_jsx(SizableText, { render: "h2", size: "$3", fontWeight: "600", color: "$ink", children: "Mori 3D 2.1 mesh generator" }), _jsx(SizableText, { size: "$1", color: "$soft", children: "Convert a reference photo or prompt into a watertight textured .glb mesh on GB10 / H100 GPUs." }), _jsx(YStack, { gap: "$2", role: "list", "aria-label": "3D mesh presets", children: MESH_PRESETS.map((m) => {
1152
1162
  const on = m.id === activeMesh.id;
1153
1163
  return (_jsx(YStack, { role: "listitem", width: "100%", minW: 0, children: _jsxs(YStack, { render: _jsx("button", { type: "button" }), onClick: () => {
1154
1164
  setActiveMeshId(m.id);
@@ -1158,10 +1168,7 @@ export function DirectorStudio({ host }) {
1158
1168
  }) }), _jsxs(YStack, { gap: "$1.5", children: [_jsx(SizableText, { size: "$1", color: "$soft", children: "Octree marching-cubes resolution" }), _jsx(XStack, { gap: "$2", children: [256, 384, 512].map((res) => {
1159
1169
  const on = meshOctree === res;
1160
1170
  return (_jsx(XStack, { render: _jsx("button", { type: "button" }), "aria-pressed": on, onClick: () => setMeshOctree(res), px: "$3", 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", fontFamily: "$mono", fontWeight: on ? '600' : '500', color: on ? '$ink' : '$soft', children: `${res}³` }) }, res));
1161
- }) })] }), _jsx(StudioTextarea, { "aria-label": "3D mesh conditioning prompt", style: { resize: 'none' }, ...{ value: meshPrompt, rows: 3 }, onChange: (e) => setMeshPrompt(e.currentTarget.value) }), _jsxs(XStack, { render: "button", onPress: () => {
1162
- triggerCinemaAudio();
1163
- setStatusNote(`Dispatched Mori 3D 2.1 mesh job (${meshOctree}³ octree) → /v1/library/model3d`);
1164
- }, height: 36, rounded: 999, bg: "$ink", items: "center", justify: "center", gap: "$1.5", cursor: "pointer", children: [_jsx(Box, { size: 14 }), _jsx(SizableText, { size: "$2", color: "$background", fontWeight: "600", children: "Generate 3D Mesh (.GLB)" })] })] }), _jsxs(YStack, { width: "100%", minW: 0, $lg: { flex: 1 }, gap: "$3", p: "$3.5", rounded: "$4", borderWidth: 1, borderColor: "var(--border)", bg: "var(--surface-card)", children: [_jsxs(YStack, { gap: "$2", minW: 0, children: [_jsxs(YStack, { gap: 2, minW: 0, children: [_jsx(SizableText, { render: "h2", size: "$3", fontWeight: "600", color: "$ink", children: activeMesh.name }), _jsx(SizableText, { size: "$1", color: "$soft", fontFamily: "$mono", children: `${activeMesh.vertices.toLocaleString()} vertices · ${activeMesh.faces.toLocaleString()} triangles · Watertight PBR GLB` })] }), _jsxs(XStack, { gap: "$1.5", flexWrap: "wrap", items: "center", children: [[
1171
+ }) })] }), _jsx(StudioTextarea, { "aria-label": "3D mesh conditioning prompt", style: { resize: 'none' }, ...{ value: meshPrompt, rows: 3 }, onChange: (e) => setMeshPrompt(e.currentTarget.value) }), _jsx(SizableText, { size: "$1", color: "$soft", children: "Making a 3D mesh from here is not connected yet, so nothing is sent. The preview above is a sample shape, not a result." })] }), _jsxs(YStack, { width: "100%", minW: 0, $lg: { flex: 1 }, gap: "$3", p: "$3.5", rounded: "$4", borderWidth: 1, borderColor: "var(--border)", bg: "var(--surface-card)", children: [_jsxs(YStack, { gap: "$2", minW: 0, children: [_jsxs(YStack, { gap: 2, minW: 0, children: [_jsx(SizableText, { render: "h2", size: "$3", fontWeight: "600", color: "$ink", children: activeMesh.name }), _jsx(SizableText, { size: "$1", color: "$soft", fontFamily: "$mono", children: `${activeMesh.vertices.toLocaleString()} vertices · ${activeMesh.faces.toLocaleString()} triangles · Watertight PBR GLB` })] }), _jsxs(XStack, { gap: "$1.5", flexWrap: "wrap", items: "center", children: [[
1165
1172
  { id: 'pbr', label: 'PBR' },
1166
1173
  { id: 'wireframe', label: 'Wireframe' },
1167
1174
  { id: 'normal', label: 'Normal' },
@@ -1183,14 +1190,11 @@ export function DirectorStudio({ host }) {
1183
1190
  .map((it) => (_jsxs(YStack, { role: "listitem", width: "100%", $sm: { width: 'calc(50% - 5px)' }, minW: 0, p: "$3", rounded: "$3", borderWidth: 1, borderColor: "var(--border-strong)", bg: "var(--background)", gap: "$2", children: [_jsxs(XStack, { justify: "space-between", items: "center", gap: "$2", children: [_jsxs(XStack, { items: "center", gap: "$1.5", flex: 1, minW: 0, children: [_jsx(Folder, { size: 12, color: "$soft" }), _jsx(SizableText, { size: "$1", color: "$soft", numberOfLines: 1, children: it.stack })] }), _jsx(SizableText, { size: "$1", fontFamily: "$mono", color: it.status === 'published' || it.status === 'approved' ? 'var(--state-success)' : '$soft', shrink: 0, children: it.status === 'published' ? 'Published' : it.status === 'approved' ? 'Approved' : 'Draft' })] }), _jsx(SizableText, { size: "$2", fontWeight: "600", color: "$ink", children: it.title }), it.modality === 'image' && /^(blob:|data:image\/|https?:)/.test(it.path) ? (_jsx("img", { src: it.path, alt: it.title, style: { width: '100%', borderRadius: 8, display: 'block' } })) : null, _jsx(SizableText, { size: "$1", color: "$soft", fontFamily: "$mono", numberOfLines: 2, children: `${/^(blob|data):/.test(it.path) ? 'Generated image' : it.path} · graph: ${it.workflow}` }), it.critique ? (_jsx(SizableText, { size: "$1", color: "$soft", children: `Conditioning note: “${it.critique}”` })) : null, _jsxs(XStack, { justify: "space-between", items: "center", flexWrap: "wrap", gap: "$1.5", pt: "$1", children: [_jsxs(XStack, { gap: "$1.5", children: [_jsxs(XStack, { render: _jsx("button", { type: "button" }), "aria-pressed": it.vote === 1, onClick: () => setLibraryItems((prev) => prev.map((x) => (x.id === it.id ? { ...x, vote: x.vote === 1 ? 0 : 1 } : x))), px: "$2", minH: 44, "$max-sm": { minH: 44 }, $md: { minH: 26, height: 26 }, items: "center", gap: "$1", rounded: "$2", borderWidth: 1, borderColor: it.vote === 1 ? 'var(--state-success)' : 'var(--border-strong)', bg: it.vote === 1 ? 'var(--state-success-bg)' : 'transparent', hoverStyle: { bg: '$hover' }, focusVisibleStyle: RING, cursor: "pointer", children: [_jsx(ThumbsUp, { size: 12, color: it.vote === 1 ? 'var(--state-success)' : '$ink' }), _jsx(SizableText, { size: "$1", color: it.vote === 1 ? 'var(--state-success)' : '$ink', children: "Good" })] }), _jsxs(XStack, { render: _jsx("button", { type: "button" }), "aria-pressed": it.vote === -1, onClick: () => setLibraryItems((prev) => prev.map((x) => (x.id === it.id ? { ...x, vote: x.vote === -1 ? 0 : -1 } : x))), px: "$2", minH: 44, "$max-sm": { minH: 44 }, $md: { minH: 26, height: 26 }, items: "center", gap: "$1", rounded: "$2", borderWidth: 1, borderColor: it.vote === -1 ? 'var(--state-error)' : 'var(--border-strong)', bg: it.vote === -1 ? 'var(--state-error-bg)' : 'transparent', hoverStyle: { bg: '$hover' }, focusVisibleStyle: RING, cursor: "pointer", children: [_jsx(ThumbsDown, { size: 12, color: it.vote === -1 ? 'var(--state-error)' : '$ink' }), _jsx(SizableText, { size: "$1", color: it.vote === -1 ? 'var(--state-error)' : '$ink', children: "Fix" })] })] }), _jsx(XStack, { render: "button", onPress: () => {
1184
1191
  setLibraryItems((prev) => prev.map((x) => (x.id === it.id ? { ...x, status: 'published' } : x)));
1185
1192
  setStatusNote(`Published "${it.title}" to Gallery & cms.hanzo.ai`);
1186
- }, px: "$2.5", height: 26, items: "center", rounded: "$2", borderWidth: 1, borderColor: "$borderColor", cursor: "pointer", children: _jsx(SizableText, { size: "$1", children: "\u2601 Publish CMS" }) })] })] }, it.id))) })] }), _jsxs(YStack, { width: "100%", minW: 0, $lg: { width: 272, shrink: 0 }, $xl: { width: 280 }, gap: "$3", p: "$3", rounded: "$4", borderWidth: 1, borderColor: "var(--border)", bg: "var(--surface-card)", children: [_jsx(SizableText, { render: "h2", size: "$3", fontWeight: "600", color: "$ink", children: "Iro-Image-Edit 2511 mask inpaint" }), _jsx(SizableText, { size: "$1", color: "$soft", children: "Paint a mask region or attach 2\u20135 references to edit only the selected area while preserving subject identity and lighting (/v1/library/fix)." }), _jsxs(YStack, { gap: "$1", children: [_jsx(SizableText, { size: "$1", color: "$soft", children: "Edit instruction" }), _jsx(StudioTextarea, { "aria-label": "Inpaint edit instruction", style: { resize: 'none' }, ...{ value: inpaintInstruction, rows: 3 }, onChange: (e) => setInpaintInstruction(e.currentTarget.value) })] }), _jsxs(YStack, { gap: "$1", children: [_jsx(SizableText, { size: "$1", color: "$soft", fontFamily: "$mono", children: `Denoise / edit strength: ${inpaintStrength}%` }), _jsx("input", { "aria-label": "Edit strength percentage", type: "range", min: 10, max: 95, step: 5, value: inpaintStrength, onChange: (e) => setInpaintStrength(Number(e.currentTarget.value)) })] }), _jsx("canvas", { ref: inpaintCanvasRef, width: 280, height: 4, style: { display: 'none' } }), _jsxs(XStack, { render: "button", onPress: () => {
1187
- triggerCinemaAudio();
1188
- setStatusNote(`Queued Iro-Image-Edit 2511 pass (${inpaintStrength}% denoise) → /v1/library/fix`);
1189
- }, height: 34, rounded: 999, bg: "$ink", items: "center", justify: "center", gap: "$1.5", cursor: "pointer", children: [_jsx(Wand2, { size: 13 }), _jsx(SizableText, { size: "$1", color: "$background", fontWeight: "600", children: "Run Region Edit (/v1/library/fix)" })] })] })] })) : null, section === 'queue' ? (_jsxs(YStack, { gap: "$3", p: "$3.5", 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", children: [_jsxs(YStack, { gap: 2, flex: 1, minW: 200, children: [_jsx(SizableText, { render: "h2", size: "$3", fontWeight: "600", color: "$ink", children: "GPU federation fleet & durable render queue (tasks.hanzo.ai)" }), _jsx(SizableText, { size: "$1", color: "$soft", children: "Select a target GPU node (X-Target-GPU) or route jobs across the shared gpu-jobs cluster." })] }), _jsxs(XStack, { render: "button", onPress: () => setStatusNote('Refreshed /v1/gpu-status & /v1/queue/status'), px: "$3", height: 30, items: "center", gap: "$1.5", rounded: 999, borderWidth: 1, borderColor: "$borderColor", cursor: "pointer", children: [_jsx(RefreshCw, { size: 12 }), _jsx(SizableText, { size: "$1", children: "Refresh Fleet" })] })] }), _jsx(XStack, { gap: "$2.5", flexWrap: "wrap", role: "list", "aria-label": "GPU nodes", width: "100%", minW: 0, children: gpuNodes.map((n) => {
1193
+ }, px: "$2.5", height: 26, items: "center", rounded: "$2", borderWidth: 1, borderColor: "$borderColor", cursor: "pointer", children: _jsx(SizableText, { size: "$1", children: "\u2601 Publish CMS" }) })] })] }, it.id))) })] }), _jsxs(YStack, { width: "100%", minW: 0, $lg: { width: 272, shrink: 0 }, $xl: { width: 280 }, gap: "$3", p: "$3", rounded: "$4", borderWidth: 1, borderColor: "var(--border)", bg: "var(--surface-card)", children: [_jsx(SizableText, { render: "h2", size: "$3", fontWeight: "600", color: "$ink", children: "Iro-Image-Edit 2511 mask inpaint" }), _jsx(SizableText, { size: "$1", color: "$soft", children: "Paint a mask region or attach 2\u20135 references to edit only the selected area while preserving subject identity and lighting (/v1/library/fix)." }), _jsxs(YStack, { gap: "$1", children: [_jsx(SizableText, { size: "$1", color: "$soft", children: "Edit instruction" }), _jsx(StudioTextarea, { "aria-label": "Inpaint edit instruction", style: { resize: 'none' }, ...{ value: inpaintInstruction, rows: 3 }, onChange: (e) => setInpaintInstruction(e.currentTarget.value) })] }), _jsxs(YStack, { gap: "$1", children: [_jsx(SizableText, { size: "$1", color: "$soft", fontFamily: "$mono", children: `Denoise / edit strength: ${inpaintStrength}%` }), _jsx("input", { "aria-label": "Edit strength percentage", type: "range", min: 10, max: 95, step: 5, value: inpaintStrength, onChange: (e) => setInpaintStrength(Number(e.currentTarget.value)) })] }), _jsx("canvas", { ref: inpaintCanvasRef, width: 280, height: 4, style: { display: 'none' } }), _jsx(SizableText, { size: "$1", color: "$soft", children: "Region edit is not connected yet, so nothing is sent and no edited picture is made from here." })] })] })) : null, section === 'queue' ? (_jsxs(YStack, { gap: "$3", p: "$3.5", 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", children: [_jsxs(YStack, { gap: 2, flex: 1, minW: 200, children: [_jsx(SizableText, { render: "h2", size: "$3", fontWeight: "600", color: "$ink", children: "GPU federation fleet & durable render queue (tasks.hanzo.ai)" }), _jsx(SizableText, { size: "$1", color: "$soft", children: "Select a target GPU node (X-Target-GPU) or route jobs across the shared gpu-jobs cluster." })] }), _jsxs(XStack, { render: "button", onPress: () => setStatusNote('Refreshed /v1/gpu-status & /v1/queue/status'), px: "$3", height: 30, items: "center", gap: "$1.5", rounded: 999, borderWidth: 1, borderColor: "$borderColor", cursor: "pointer", children: [_jsx(RefreshCw, { size: 12 }), _jsx(SizableText, { size: "$1", children: "Refresh Fleet" })] })] }), _jsx(XStack, { gap: "$2.5", flexWrap: "wrap", role: "list", "aria-label": "GPU nodes", width: "100%", minW: 0, children: gpuNodes.map((n) => {
1190
1194
  const selected = targetGpu === n.name;
1191
1195
  return (_jsx(YStack, { role: "listitem", width: "100%", $sm: { width: 'calc(50% - 5px)' }, minW: 0, children: _jsxs(YStack, { render: _jsx("button", { type: "button" }), onClick: () => {
1192
1196
  setTargetGpu(selected ? 'any' : n.name);
1193
1197
  setStatusNote(selected ? 'Routing renders to any available GPU' : `Pinned next render to GPU node: ${n.name}`);
1194
1198
  }, width: "100%", minW: 0, minH: 44, "$max-sm": { minH: 44 }, p: "$3", rounded: "$3", "aria-pressed": selected, borderWidth: selected ? 1.5 : 1, borderColor: selected ? 'var(--foreground)' : 'var(--border-strong)', bg: selected ? 'var(--surface-card)' : 'var(--background)', boxShadow: selected ? 'var(--shadow-sheet-2)' : undefined, hoverStyle: { bg: selected ? 'var(--surface-card)' : '$hover', borderColor: selected ? 'var(--foreground)' : 'var(--border-strong)' }, focusVisibleStyle: RING, gap: "$1.5", items: "flex-start", cursor: "pointer", children: [_jsxs(XStack, { justify: "space-between", items: "center", width: "100%", gap: "$2", children: [_jsxs(XStack, { items: "center", gap: "$2", minW: 0, children: [_jsx(Cpu, { size: 15, color: "$ink" }), _jsx(SizableText, { size: "$2", fontWeight: "600", color: "$ink", fontFamily: "$mono", numberOfLines: 1, children: n.name })] }), _jsxs(XStack, { items: "center", gap: "$1.5", shrink: 0, children: [_jsx(XStack, { width: 7, height: 7, rounded: 99, bg: n.online ? 'var(--state-success)' : 'var(--state-error)' }), _jsx(SizableText, { size: "$1", fontFamily: "$mono", color: n.online ? 'var(--state-success)' : 'var(--state-error)', children: n.online ? `Online · ${n.depth} queued` : 'Offline' })] })] }), _jsx(SizableText, { size: "$1", color: "$soft", children: `Memory: ${n.vram}` }), _jsx(SizableText, { size: "$1", color: "$soft", fontFamily: "$mono", text: "left", children: `Lanes: ${n.lanes.join(' · ')}` })] }) }, n.name));
1195
- }) })] })) : null] }));
1199
+ }) })] })) : null, dialog] }));
1196
1200
  }
@@ -0,0 +1,22 @@
1
+ /**
2
+ * Where Flow keeps the person's flows: this browser, per organization, so an
3
+ * edit outlives leaving the page. The page says so; nothing here is sent
4
+ * anywhere or shared.
5
+ */
6
+ /** The browser key a person's flows are kept under in `org`. */
7
+ export declare const keptAt: (org: string | null | undefined) => string;
8
+ /** The shape a kept flow must have to be drawn: an id and at least one node, each drawable. */
9
+ interface Shaped {
10
+ id: string;
11
+ nodes: readonly {
12
+ id: string;
13
+ type: string;
14
+ inputs: object;
15
+ wiresFrom: readonly string[];
16
+ }[];
17
+ }
18
+ /** The flows this browser kept for `org`, or null when it kept none it can read (the templates are drawn instead). */
19
+ export declare function keptFlows<T extends Shaped>(org: string | null | undefined): T[] | null;
20
+ /** Keep `flows` for `org`. Answers whether this browser kept them. */
21
+ export declare function keepFlows(org: string | null | undefined, flows: readonly Shaped[]): boolean;
22
+ export {};
@@ -0,0 +1,32 @@
1
+ /**
2
+ * Where Flow keeps the person's flows: this browser, per organization, so an
3
+ * edit outlives leaving the page. The page says so; nothing here is sent
4
+ * anywhere or shared.
5
+ */
6
+ /** The browser key a person's flows are kept under in `org`. */
7
+ export const keptAt = (org) => `hanzo.flow.${org ?? '-'}`;
8
+ const isObject = (v) => typeof v === 'object' && v !== null && !Array.isArray(v);
9
+ /** Whether a node can be drawn and run: Flow reads its id, type, inputs and wires on every render. */
10
+ const drawable = (n) => isObject(n) && typeof n.id === 'string' && typeof n.type === 'string' && isObject(n.inputs) && Array.isArray(n.wiresFrom) && n.wiresFrom.every((x) => typeof x === 'string');
11
+ /** The flows this browser kept for `org`, or null when it kept none it can read (the templates are drawn instead). */
12
+ export function keptFlows(org) {
13
+ try {
14
+ const raw = JSON.parse(localStorage.getItem(keptAt(org)) ?? 'null');
15
+ if (Array.isArray(raw) && raw.length && raw.every((b) => isObject(b) && typeof b.id === 'string' && Array.isArray(b.nodes) && b.nodes.length && b.nodes.every(drawable)))
16
+ return raw;
17
+ }
18
+ catch {
19
+ // No store, or nothing readable in it: the templates.
20
+ }
21
+ return null;
22
+ }
23
+ /** Keep `flows` for `org`. Answers whether this browser kept them. */
24
+ export function keepFlows(org, flows) {
25
+ try {
26
+ localStorage.setItem(keptAt(org), JSON.stringify(flows));
27
+ return true;
28
+ }
29
+ catch {
30
+ return false;
31
+ }
32
+ }
package/lib/app/flow.d.ts CHANGED
@@ -2,19 +2,18 @@
2
2
  * Hanzo Flow (/flow) — Langflow + ComfyUI Native-Compat Visual Workflow & Node Graph UI.
3
3
  *
4
4
  * Clean BSD-3-Clause / MIT visual workflow builder that unifies:
5
- * 1. Langflow Agent, LLM, Prompt Template, RAG Vector Store, MCP Tool, and inline
6
- * editable Python Component nodes (`flow` backend).
5
+ * 1. Langflow Agent, LLM, Prompt Template, RAG Vector Store and MCP Tool nodes (`flow` backend).
7
6
  * 2. Native ComfyUI / `studio_compat` media generation node extensions (`/v1/object_info`,
8
7
  * `/v1/prompt`, `/v1/chat/completions` + MCP tools) for Koma 2.0 Video, LTX 2.0, Iro-Image-Edit 2511,
9
8
  * Z-Image-Turbo, Mori 3D 2.1 (.glb), ACE-Step 3.5B Music, Demucs Stems, MMAudio Foley,
10
9
  * and Koe TTS.
11
- * 3. Publish any hybrid Agent+ComfyUI graph as a REST endpoint, ComfyUI API JSON,
12
- * Langflow JSON, or an MCP Server tool.
10
+ *
11
+ * A graph is run on the engine (/v1/prompt) and taken away as JSON. Edits are kept
12
+ * in this browser (flow-kept.ts), and the page says so.
13
13
  */
14
14
  import type { Host } from '@hanzo/build';
15
15
  import type { RailLink } from '@hanzo/ui/chat';
16
- import { parseFlowSection, type FlowSection } from './sections.ts';
17
- export { parseFlowSection, type FlowSection };
16
+ import { type Hosted } from '../host.tsx';
18
17
  export declare function flowNav(host: Host, go: (path: string) => void): {
19
18
  id: 'make';
20
19
  label: string;
@@ -29,7 +28,6 @@ export interface FlowModuleSpec {
29
28
  inputPorts: string[];
30
29
  outputPorts: string[];
31
30
  defaultInputs: Record<string, string | number>;
32
- pythonSource: string;
33
31
  }
34
32
  export declare const FLOW_MODULE_CATALOG: readonly FlowModuleSpec[];
35
33
  export interface FlowGraphNode {
@@ -42,7 +40,6 @@ export interface FlowGraphNode {
42
40
  y: number;
43
41
  inputs: Record<string, string | number>;
44
42
  wiresFrom: string[];
45
- pythonCode?: string;
46
43
  }
47
44
  export interface FlowBlueprint {
48
45
  id: string;
@@ -54,5 +51,5 @@ export interface FlowBlueprint {
54
51
  }
55
52
  export declare const FLOW_BLUEPRINTS: readonly FlowBlueprint[];
56
53
  export declare function FlowStudio({ host }: {
57
- host: Host;
54
+ host: Hosted;
58
55
  }): import("react").JSX.Element;