@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/talk.js CHANGED
@@ -9,14 +9,16 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
9
9
  * A new conversation has no id in the address until its first message is sent;
10
10
  * then the address names it, and the conversation in hand is the one shown.
11
11
  */
12
+ import { RING } from './ui.js';
12
13
  import { Gutter, Panel, PanelToggle, Reply, SideProvider, useDeck, useKey, usePanel, useSplit } from '@hanzo/build';
13
14
  import { SizableText, useMedia, XStack, YStack } from '@hanzo/gui';
14
- import { Check, ChevronDown, Clapperboard, Ellipsis, FileText, Image as ImageIcon, LoaderCircle, Music, Palette, Sparkles, X } from '@hanzogui/lucide-icons-2';
15
- import { DropdownMenu } from '@hanzo/ui';
15
+ import { Check, ChevronDown, Clapperboard, FileText, Image as ImageIcon, LoaderCircle, Music, Palette, SlidersHorizontal, Sparkles, X } from '@hanzogui/lucide-icons-2';
16
+ import { DropdownMenu, Tooltip, TooltipContent, TooltipProvider, TooltipTrigger } from '@hanzo/ui';
16
17
  import { Chat as Thread, Failure } from '@hanzo/ui/chat';
17
18
  import { useCallback, useEffect, useMemo, useRef, useState } from 'react';
18
19
  import { edit as editInPlace, turn } from './chat/turn.js';
19
20
  import { keep, listed, open } from './chat/store.js';
21
+ import { uploadFailure } from './attach.js';
20
22
  import { Desk } from './desk.js';
21
23
  import { Home } from './home.js';
22
24
  import { useHost } from './host.js';
@@ -37,10 +39,16 @@ const pane = {
37
39
  bg: 'var(--pane-fill, var(--sheet-1))',
38
40
  rounded: 'var(--pane-round, var(--radius-xl))',
39
41
  borderWidth: 1,
40
- borderColor: 'var(--pane-edge, var(--white-08))',
42
+ borderColor: 'var(--pane-edge, var(--border))',
41
43
  boxShadow: 'var(--shadow-sheet-2)',
42
44
  };
43
45
  const gap = 'var(--pane-gap, var(--space-2))';
46
+ const REFINEMENT_CHIPS = [
47
+ { id: 'mono', label: 'Minimal monochrome', snippet: 'minimal monochrome palette, clean negative space' },
48
+ { id: 'editorial', label: 'Editorial poster', snippet: 'editorial poster composition, crisp typographic hierarchy' },
49
+ { id: 'contrast', label: 'High contrast', snippet: 'high-contrast lighting, deep shadows, sharp detail' },
50
+ { id: 'wide', label: '16:9 widescreen', snippet: '16:9 widescreen framing', aspect: '16:9' },
51
+ ];
44
52
  export function Talk({ id }) {
45
53
  const host = useHost();
46
54
  const wire = useWire(host);
@@ -74,7 +82,7 @@ export function Talk({ id }) {
74
82
  };
75
83
  }, [id, wire]);
76
84
  if (failed) {
77
- return (_jsxs(YStack, { flex: 1, items: "center", justify: "center", gap: "$3", p: "$5", children: [_jsx(SizableText, { color: "$soft", children: failed }), _jsx(XStack, { render: "button", onPress: () => host.go(''), px: "$3", height: 34, items: "center", rounded: "$3", borderWidth: 1, borderColor: "$borderColor", cursor: "pointer", children: _jsx(SizableText, { size: "$2", children: "Start a new one" }) })] }));
85
+ return (_jsxs(YStack, { flex: 1, items: "center", justify: "center", gap: "$3", p: "$5", children: [_jsx(SizableText, { color: "$soft", children: failed }), _jsx(XStack, { render: _jsx("button", { type: "button" }), onClick: () => host.go(''), px: "$3", minH: 44, "$max-sm": { minH: 44 }, $md: { minH: 34, height: 34 }, items: "center", rounded: "$3", borderWidth: 1, borderColor: "var(--border-strong)", cursor: "pointer", hoverStyle: { bg: '$hover' }, focusVisibleStyle: RING, children: _jsx(SizableText, { size: "$2", color: "$ink", children: "Start a new one" }) })] }));
78
86
  }
79
87
  if (!chat) {
80
88
  return (_jsx(YStack, { flex: 1, items: "center", justify: "center", children: _jsx(SizableText, { color: "$soft", children: "Opening\u2026" }) }));
@@ -85,10 +93,14 @@ function Conversation({ start, host, wire, available }) {
85
93
  const [chat, setChat] = useState(start);
86
94
  const latest = useRef(chat);
87
95
  const [draft, setDraft] = useState('');
96
+ const [activeStarter, setActiveStarter] = useState(null);
97
+ const [appliedChips, setAppliedChips] = useState([]);
88
98
  const [attached, setAttached] = useState([]);
89
99
  const [uploading, setUploading] = useState(0);
100
+ const [uploadError, setUploadError] = useState('');
90
101
  const [picked, setPicked] = useState(null);
91
102
  const [options, setOptions] = useState({ model: 'auto', aspect: '', count: 1 });
103
+ const [openMenu, setOpenMenu] = useState(null);
92
104
  const [working, setWorking] = useState(null);
93
105
  const [editing, setEditing] = useState({});
94
106
  const [editFailed, setEditFailed] = useState({});
@@ -146,7 +158,9 @@ function Conversation({ start, host, wire, available }) {
146
158
  setWorking(ctl);
147
159
  const files = attached;
148
160
  setDraft('');
161
+ setAppliedChips([]);
149
162
  setAttached([]);
163
+ setUploadError('');
150
164
  // The address names the conversation from its first message on.
151
165
  if (!latest.current.turns.length)
152
166
  host.go(path({ kind: 'chat', id: latest.current.id }), { replace: true });
@@ -179,7 +193,7 @@ function Conversation({ start, host, wire, available }) {
179
193
  setWorking(null);
180
194
  }
181
195
  };
182
- // A starter chosen in Explore, or named in the address, starts this conversation.
196
+ // A starter chosen in Explore, or named in the address, fills the composer for this conversation.
183
197
  useEffect(() => {
184
198
  const s = take();
185
199
  if (s)
@@ -188,12 +202,41 @@ function Conversation({ start, host, wire, available }) {
188
202
  }, []);
189
203
  const begin = (s) => {
190
204
  setPicked(s.kind);
205
+ setActiveStarter(s);
206
+ setAppliedChips([]);
207
+ // Fill the composer, but never overwrite words someone typed (another starter's text is fine to replace).
208
+ setDraft((prev) => (prev.trim() && prev !== activeStarter?.prompt ? prev : s.prompt));
191
209
  if (s.picture && !attached.length) {
192
- setDraft(s.prompt);
193
210
  attach();
211
+ }
212
+ // Words are in the composer: put the cursor there so the person can edit and send.
213
+ if (typeof window !== 'undefined') {
214
+ window.requestAnimationFrame(() => document.querySelector('[data-slot="composer"] textarea')?.focus());
215
+ }
216
+ };
217
+ const toggleRefinementChip = (chip) => {
218
+ const isOn = appliedChips.includes(chip.id);
219
+ if (isOn) {
220
+ setAppliedChips((prev) => prev.filter((id) => id !== chip.id));
221
+ setDraft((prev) => prev
222
+ .replace(new RegExp(`(?:,\\s*|\\s+)?${chip.snippet.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')}`, 'i'), '')
223
+ .replace(/^,\s*/, '')
224
+ .trim());
225
+ if (chip.aspect && options.aspect === chip.aspect) {
226
+ setOptions((o) => ({ ...o, aspect: '' }));
227
+ }
194
228
  return;
195
229
  }
196
- void send(s.prompt, { kind: s.kind });
230
+ setAppliedChips((prev) => [...prev, chip.id]);
231
+ setDraft((prev) => {
232
+ const clean = prev.trim();
233
+ if (!clean)
234
+ return chip.snippet.charAt(0).toUpperCase() + chip.snippet.slice(1);
235
+ return clean.toLowerCase().includes(chip.snippet.toLowerCase()) ? clean : `${clean.replace(/[.,;]+$/, '')}, ${chip.snippet}`;
236
+ });
237
+ if (chip.aspect) {
238
+ setOptions((o) => ({ ...o, aspect: chip.aspect }));
239
+ }
197
240
  };
198
241
  const attachWith = (accept, promptText, kindId) => {
199
242
  const input = document.createElement('input');
@@ -231,7 +274,10 @@ function Conversation({ start, host, wire, available }) {
231
274
  const batch = files.slice(0, 6);
232
275
  if (!batch.length)
233
276
  return;
277
+ setUploadError('');
234
278
  setUploading((n) => n + batch.length);
279
+ const failedNames = [];
280
+ let lastReason = '';
235
281
  for (const f of batch) {
236
282
  try {
237
283
  const mime = inferMime(f);
@@ -243,13 +289,15 @@ function Conversation({ start, host, wire, available }) {
243
289
  setAttached((a) => [...a, { key, mime, name, width: bmp?.width, height: bmp?.height }]);
244
290
  bmp?.close();
245
291
  }
246
- catch {
247
- // The chip never appears; the person sees the file did not attach.
292
+ catch (e) {
293
+ failedNames.push(f.name || 'file');
294
+ lastReason = e instanceof Error ? e.message : String(e);
248
295
  }
249
296
  finally {
250
297
  setUploading((n) => n - 1);
251
298
  }
252
299
  }
300
+ setUploadError(uploadFailure(failedNames, lastReason));
253
301
  };
254
302
  const pick = (m, at) => changed({ ...latest.current, made: latest.current.made.map((x) => (x.id === m.id ? { ...x, at } : x)) });
255
303
  const editOne = async (m, patch, note) => {
@@ -281,7 +329,7 @@ function Conversation({ start, host, wire, available }) {
281
329
  label: m.title,
282
330
  icon: _jsx(Icon, { size: 14 }),
283
331
  bleed: true,
284
- render: () => (_jsx(Desk, { made: chat.made.find((x) => x.id === m.id) ?? m, wire: wire, others: chat.made.filter((x) => x.id !== m.id), onPick: (at) => pick(m, at), onEdit: (patch, note) => void editOne(m, patch, note), busy: Boolean(editing[m.id]), failed: editFailed[m.id] })),
332
+ render: () => (_jsx(Desk, { made: chat.made.find((x) => x.id === m.id) ?? m, wire: wire, others: chat.made.filter((x) => x.id !== m.id), onPick: (at) => pick(m, at), onEdit: (patch, note) => void editOne(m, patch, note), busy: Boolean(editing[m.id]), failed: editFailed[m.id] }, m.id)),
285
333
  };
286
334
  }),
287
335
  // eslint-disable-next-line react-hooks/exhaustive-deps
@@ -309,19 +357,19 @@ function Conversation({ start, host, wire, available }) {
309
357
  void send(q.text);
310
358
  };
311
359
  const kindItems = [
312
- { key: 'auto', label: 'Auto', description: 'Design picks from what you ask', onSelect: () => setPicked(null) },
360
+ { key: 'auto', label: 'Auto', description: 'Design picks from what you ask', selected: picked === null, onSelect: () => setPicked(null) },
313
361
  ...ALL.map((k) => {
314
362
  const why = k.needs(available);
315
- return { key: k.id, label: k.label, description: why ? 'Needs a GPU' : k.blurb, disabled: Boolean(why), onSelect: () => setPicked(k.id) };
363
+ return { key: k.id, label: k.label, description: why ? 'Needs a GPU' : k.blurb, selected: picked === k.id, disabled: Boolean(why), onSelect: () => setPicked(k.id) };
316
364
  }),
317
365
  ];
318
366
  const brandName = brandOf(chat);
319
367
  const brandItems = [
320
368
  { type: 'label', key: 'h', label: 'Draw in' },
321
- { key: 'none', label: 'Hanzo (default)', onSelect: () => changed({ ...latest.current, brand: undefined }) },
369
+ { key: 'none', label: 'Hanzo (default)', selected: !chat.brand, onSelect: () => changed({ ...latest.current, brand: undefined }) },
322
370
  ...chat.made
323
371
  .filter((m) => m.kind === 'type')
324
- .map((m) => ({ key: m.id, label: m.title, description: 'From this conversation', onSelect: () => changed({ ...latest.current, brand: m.id }) })),
372
+ .map((m) => ({ key: m.id, label: m.title, description: 'From this conversation', selected: chat.brand === m.id, onSelect: () => changed({ ...latest.current, brand: m.id }) })),
325
373
  { type: 'separator', key: 's' },
326
374
  ...PRESETS.map((p) => ({
327
375
  key: `preset-${p.name}`,
@@ -339,18 +387,30 @@ function Conversation({ start, host, wire, available }) {
339
387
  const zen = lit(available.fleet, 'image.zen');
340
388
  const optionItems = [
341
389
  { type: 'label', key: 'm', label: 'Image model' },
342
- { key: 'auto', label: `${options.model === 'auto' ? '✓ ' : ''}Auto`, description: zen ? 'Zen Image on your GPU' : MODELS[0].label, onSelect: () => setOptions({ ...options, model: 'auto' }) },
343
- ...(zen ? [{ key: ZEN, label: `${options.model === ZEN ? '✓ ' : ''}Zen Image`, description: 'On your GPU', onSelect: () => setOptions({ ...options, model: ZEN }) }] : []),
344
- ...MODELS.map((m) => ({ key: m.id, label: `${options.model === m.id ? '✓ ' : ''}${m.label}`, onSelect: () => setOptions({ ...options, model: m.id }) })),
390
+ { key: 'auto', label: 'Auto', description: zen ? 'Zen Image on your GPU' : MODELS[0].label, selected: options.model === 'auto', onSelect: () => setOptions({ ...options, model: 'auto' }) },
391
+ ...(zen ? [{ key: ZEN, label: 'Zen Image', description: 'On your GPU', selected: options.model === ZEN, onSelect: () => setOptions({ ...options, model: ZEN }) }] : []),
392
+ ...MODELS.map((m) => ({ key: m.id, label: m.label, selected: options.model === m.id, onSelect: () => setOptions({ ...options, model: m.id }) })),
345
393
  { type: 'separator', key: 's' },
346
394
  { type: 'label', key: 'a', label: 'Aspect' },
347
- ...['', '1:1', '4:5', '9:16', '16:9', '3:2'].map((a) => ({ key: `a${a}`, label: `${options.aspect === a ? '✓ ' : ''}${a || 'As asked'}`, onSelect: () => setOptions({ ...options, aspect: a }) })),
395
+ ...['', '1:1', '4:5', '9:16', '16:9', '3:2'].map((a) => ({ key: `a${a}`, label: a || 'As asked', selected: options.aspect === a, onSelect: () => setOptions({ ...options, aspect: a }) })),
348
396
  { type: 'separator', key: 's2' },
349
397
  { type: 'label', key: 'c', label: 'How many' },
350
- ...[1, 2, 4].map((n) => ({ key: `c${n}`, label: `${options.count === n ? '✓ ' : ''}${n}`, onSelect: () => setOptions({ ...options, count: n }) })),
398
+ ...[1, 2, 4].map((n) => ({ key: `c${n}`, label: String(n), selected: options.count === n, onSelect: () => setOptions({ ...options, count: n }) })),
351
399
  ];
352
- const tools = (_jsxs(XStack, { items: "center", gap: 2, children: [_jsx(DropdownMenu, { trigger: _jsx(Pillish, { label: "Kind", icon: _jsx(Sparkles, { size: 13 }), value: picked ? kind(picked).label : 'Auto' }), items: kindItems }), _jsx(DropdownMenu, { trigger: _jsx(Pillish, { label: "Brand", icon: _jsx(Palette, { size: 13 }), value: brandName }), items: brandItems }), _jsx(DropdownMenu, { trigger: _jsx(XStack, { render: "button", "aria-label": "More options: model, aspect, count", width: 32, height: 32, items: "center", justify: "center", rounded: 999, cursor: "pointer", hoverStyle: { bg: '$hover' }, children: _jsx(Ellipsis, { size: 16 }) }), items: optionItems })] }));
353
- const head = attached.length || uploading ? (_jsxs(XStack, { gap: "$2", flexWrap: "wrap", "data-slot": "attached", children: [attached.map((f) => (_jsxs(XStack, { position: "relative", children: [_jsx(Thumb, { wire: wire, file: f }), _jsx(XStack, { render: "button", "aria-label": `Remove ${f.name}`, onPress: () => setAttached((a) => a.filter((x) => x.key !== f.key)), position: "absolute", t: -6, r: -6, width: 20, height: 20, rounded: 99, bg: "$background", borderWidth: 1, borderColor: "$borderColor", items: "center", justify: "center", cursor: "pointer", children: _jsx(X, { size: 11 }) })] }, f.key))), uploading ? (_jsx(XStack, { width: 56, height: 56, rounded: "$3", bg: "$hover", items: "center", justify: "center", children: _jsx(LoaderCircle, { size: 16 }) })) : null] })) : undefined;
400
+ const formatValue = picked ? kind(picked).label : 'Auto';
401
+ const activeModelLabel = options.model === 'auto'
402
+ ? null
403
+ : options.model === ZEN
404
+ ? 'Zen Image'
405
+ : (MODELS.find((m) => m.id === options.model)?.label ?? options.model);
406
+ const optionParts = [activeModelLabel, options.aspect || null, options.count > 1 ? `${options.count}×` : null].filter(Boolean);
407
+ const optionsValue = optionParts.length ? optionParts.join(' · ') : 'Auto';
408
+ const tools = (_jsx(TooltipProvider, { delay: 200, children: _jsxs(XStack, { items: "center", gap: "$2", flexWrap: "wrap", maxW: "100%", children: [_jsxs(Tooltip, { placement: "top", offset: 6, open: openMenu === 'format' ? false : undefined, children: [_jsx(TooltipTrigger, { asChild: true, children: _jsx(XStack, { items: "center", children: _jsx(DropdownMenu, { onOpenChange: (o) => setOpenMenu(o ? 'format' : null), trigger: _jsx(Pillish, { label: "Format", icon: _jsx(Sparkles, { size: 12, color: "$soft" }), value: formatValue, open: openMenu === 'format' }), items: kindItems }) }) }), _jsx(TooltipContent, { children: _jsx(SizableText, { size: "$1", color: "$ink", children: "Output format \u2014 Auto picks from what you ask" }) })] }), _jsxs(Tooltip, { placement: "top", offset: 6, open: openMenu === 'brand' ? false : undefined, children: [_jsx(TooltipTrigger, { asChild: true, children: _jsx(XStack, { items: "center", children: _jsx(DropdownMenu, { onOpenChange: (o) => setOpenMenu(o ? 'brand' : null), trigger: _jsx(Pillish, { label: "Brand", icon: _jsx(Palette, { size: 12, color: "$soft" }), value: brandName, open: openMenu === 'brand' }), items: brandItems }) }) }), _jsx(TooltipContent, { children: _jsx(SizableText, { size: "$1", color: "$ink", children: "Brand & type system used for typography and palette" }) })] }), _jsxs(Tooltip, { placement: "top", offset: 6, open: openMenu === 'options' ? false : undefined, children: [_jsx(TooltipTrigger, { asChild: true, children: _jsx(XStack, { items: "center", children: _jsx(DropdownMenu, { onOpenChange: (o) => setOpenMenu(o ? 'options' : null), trigger: _jsx(Pillish, { label: "Options", "aria-label": `Options: ${optionsValue} (image model, aspect ratio, count)`, icon: _jsx(SlidersHorizontal, { size: 12, color: "$soft" }), value: optionsValue, open: openMenu === 'options' }), items: optionItems }) }) }), _jsx(TooltipContent, { children: _jsx(SizableText, { size: "$1", color: "$ink", children: "Image model, aspect ratio, and variant count" }) })] })] }) }));
409
+ const showRefinementChips = Boolean(activeStarter || draft.trim().length > 0);
410
+ const head = attached.length || uploading || uploadError || showRefinementChips ? (_jsxs(YStack, { gap: "$2", width: "100%", minW: 0, children: [uploadError ? (_jsxs(XStack, { role: "alert", items: "center", justify: "space-between", gap: "$2", px: "$2.5", py: "$1.5", rounded: "$3", bg: "var(--state-error-bg)", borderWidth: 1, borderColor: "var(--state-error)", children: [_jsx(SizableText, { size: "$1", color: "var(--state-error)", flex: 1, minW: 0, children: uploadError }), _jsx(XStack, { render: _jsx("button", { type: "button" }), "aria-label": "Dismiss upload error", onClick: () => setUploadError(''), width: 20, height: 20, rounded: 99, items: "center", justify: "center", cursor: "pointer", hoverStyle: { bg: '$hover' }, focusVisibleStyle: RING, shrink: 0, children: _jsx(X, { size: 11, color: "var(--state-error)" }) })] })) : null, attached.length || uploading ? (_jsxs(XStack, { gap: "$2", flexWrap: "wrap", "data-slot": "attached", children: [attached.map((f) => (_jsxs(XStack, { position: "relative", children: [_jsx(Thumb, { wire: wire, file: f }), _jsx(XStack, { render: _jsx("button", { type: "button" }), "aria-label": `Remove ${f.name}`, onClick: () => setAttached((a) => a.filter((x) => x.key !== f.key)), position: "absolute", t: -6, r: -6, width: 22, height: 22, "$max-sm": { minW: 44, minH: 44, t: -14, r: -14 }, rounded: 99, bg: "$background", borderWidth: 1, borderColor: "var(--border-strong)", items: "center", justify: "center", cursor: "pointer", hoverStyle: { bg: '$hover' }, focusVisibleStyle: RING, children: _jsx(X, { size: 11, color: "$ink" }) })] }, f.key))), uploading ? (_jsx(XStack, { width: 56, height: 56, rounded: "$3", bg: "$hover", items: "center", justify: "center", children: _jsx(LoaderCircle, { size: 16 }) })) : null] })) : null, showRefinementChips ? (_jsxs(XStack, { role: "group", "aria-label": "Prompt refinements", gap: "$1.5", width: "100%", minW: 0, overflowX: "auto", flexWrap: "nowrap", items: "center", style: { scrollbarWidth: 'none' }, children: [activeStarter && empty ? (_jsxs(XStack, { items: "center", gap: "$1", px: "$2", height: 26, rounded: 999, borderWidth: 1, borderColor: "var(--border)", bg: "var(--surface-card)", shrink: 0, children: [_jsx(SizableText, { size: "$1", color: "$soft", numberOfLines: 1, children: activeStarter.title }), _jsx(XStack, { render: _jsx("button", { type: "button" }), "aria-label": "Clear starter selection", onClick: () => setActiveStarter(null), width: 18, height: 18, "$max-sm": { minW: 44, minH: 44 }, rounded: 99, items: "center", justify: "center", cursor: "pointer", hoverStyle: { bg: '$hover' }, focusVisibleStyle: RING, children: _jsx(X, { size: 10, color: "$soft" }) })] })) : null, REFINEMENT_CHIPS.map((chip) => {
411
+ const on = appliedChips.includes(chip.id);
412
+ return (_jsx(XStack, { render: _jsx("button", { type: "button" }), "aria-pressed": on, onClick: () => toggleRefinementChip(chip), items: "center", gap: "$1", px: "$2.5", minH: 44, "$max-sm": { minH: 44 }, $md: { minH: 28, height: 28 }, rounded: 999, borderWidth: 1, borderColor: on ? '$ink' : 'var(--border-strong)', bg: on ? '$ink' : 'transparent', cursor: "pointer", hoverStyle: { bg: on ? '$ink' : '$hover' }, focusVisibleStyle: RING, shrink: 0, children: _jsx(SizableText, { size: "$1", fontWeight: on ? '500' : '400', color: on ? '$background' : '$soft', whiteSpace: "nowrap", children: chip.label }) }, chip.id));
413
+ })] })) : null] })) : undefined;
354
414
  const composer = {
355
415
  value: draft,
356
416
  onChange: setDraft,
@@ -362,28 +422,33 @@ function Conversation({ start, host, wire, available }) {
362
422
  label: 'What should we create?',
363
423
  head,
364
424
  plus: { upload: attach },
365
- // Kind, Brand and the image options are the pills above the field.
425
+ // Format, Brand, and image options align with the composer's inner text left edge.
366
426
  pills: tools,
367
427
  column: true,
368
428
  narrow: !wide,
369
- // While nothing has been made: where to start, in a box of its own that scrolls,
370
- // so the composer under it stays in the window however many starters there are.
371
- starters: empty ? (_jsx(YStack, { "data-slot": "studio-starters", maxH: "40dvh", overflowY: "auto", width: "100%", children: _jsx(Home, { available: available, onStart: begin, onUpload: attachWith }) })) : undefined,
429
+ maxW: 720,
430
+ pb: empty ? '$6' : '$3',
372
431
  };
373
432
  const deskPane = (sheet) => (_jsx(Panel, { side: deck, kinds: tabs, onHide: () => setDesk(false), sheet: sheet, label: "What this conversation made" }));
374
- return (_jsxs(XStack, { "data-slot": "studio-split", flex: 1, minH: 0, minW: 0, width: "100%", children: [_jsxs(YStack, { "data-slot": "studio-talk", ref: split.main, style: split.mainStyle, ...pane, flex: 1, minH: 0, minW: 0, width: "100%", overflow: "hidden", children: [_jsxs(XStack, { px: "$4", pt: "$3", pb: "$2", gap: "$2", items: "center", minH: 44, children: [_jsx(SizableText, { render: "h1", size: "$5", color: "$ink", numberOfLines: 1, flex: 1, minW: 0, children: empty ? 'Design' : chat.title }), chat.made.length ? _jsx(PanelToggle, { open: desk, onToggle: () => setDesk(!desk) }) : null] }), _jsx(Thread, { messages: messages, streaming: busy, send: (text) => void send(text), stop: working ? () => working.abort() : undefined, body: body, center: true, onFiles: (files) => void upload(files), empty: _jsx(Opening, {}), composer: composer })] }), desk && chat.made.length && !wide ? deskPane(true) : null, desk && chat.made.length && wide ? (_jsxs(YStack, { "data-slot": "studio-desk", ref: split.aside, ...pane, ml: gap, position: "relative", shrink: 0, minH: 0, style: split.asideStyle, children: [split.grip ? (_jsx(Gutter, { ...split.grip, label: "Resize the tabs", inset: pane.borderWidth })) : null, _jsx(SideProvider, { value: split.side, children: deskPane(false) })] })) : null] }));
433
+ return (_jsxs(XStack, { "data-slot": "studio-split", flex: 1, minH: 0, minW: 0, width: "100%", children: [_jsxs(YStack, { "data-slot": "studio-talk", ref: split.main, style: split.mainStyle, ...pane, flex: 1, minH: 0, minW: 0, width: "100%", overflowY: empty ? 'auto' : 'hidden', overflowX: "hidden", children: [_jsxs(XStack, { px: "$4", pt: "$3", pb: "$2", gap: "$2", items: "center", minH: 44, shrink: 0, children: [empty ? (_jsx(SizableText, { size: "$3", fontWeight: "500", color: "$soft", numberOfLines: 1, flex: 1, minW: 0, children: "Design" })) : (_jsx(SizableText, { render: "h1", size: "$4", fontWeight: "600", color: "$ink", numberOfLines: 1, flex: 1, minW: 0, children: chat.title })), chat.made.length ? _jsx(PanelToggle, { open: desk, onToggle: () => setDesk(!desk) }) : null] }), _jsx(Thread, { messages: messages, streaming: busy, send: (text) => void send(text), stop: working ? () => working.abort() : undefined, body: body, center: true, onFiles: (files) => void upload(files), empty: _jsxs(YStack, { "data-slot": "studio-opening", width: "100%", maxW: 1040, mx: "auto", items: "center", px: "$3", $md: { px: '$4' }, pt: "$3", pb: "$5", gap: "$4", minW: 0, children: [_jsx(Opening, {}), _jsx(Home, { available: available, onStart: begin, onUpload: attachWith })] }), composer: composer })] }), desk && chat.made.length && !wide ? deskPane(true) : null, desk && chat.made.length && wide ? (_jsxs(YStack, { "data-slot": "studio-desk", ref: split.aside, ...pane, ml: gap, position: "relative", shrink: 0, minH: 0, style: split.asideStyle, children: [split.grip ? (_jsx(Gutter, { ...split.grip, label: "Resize the tabs", inset: pane.borderWidth })) : null, _jsx(SideProvider, { value: split.side, children: deskPane(false) })] })) : null] }));
375
434
  }
376
435
  function brandOf(chat) {
377
436
  const m = chat.brand ? chat.made.find((x) => x.id === chat.brand) : null;
378
437
  return m ? m.title : 'Hanzo';
379
438
  }
380
439
  function Opening() {
381
- return (_jsxs(YStack, { items: "center", width: "100%", pt: "$6", pb: "$2", gap: "$2", children: [_jsx(SizableText, { render: "h2", size: "$9", fontWeight: "600", color: "$ink", text: "center", children: "What should we create?" }), _jsx(SizableText, { size: "$3", color: "$soft", text: "center", children: "Visuals, images, posters, presentations, documents, ads, 3D, video, music & interactive apps. Upload any file \u2014 everything opens in a tab." })] }));
440
+ return (_jsxs(YStack, { items: "center", width: "100%", pt: "$2", pb: "$1", px: "$3", gap: "$2", children: [_jsx(SizableText, { render: "h1", size: "$7", fontWeight: "600", color: "$ink", text: "center", letterSpacing: -0.6, children: "What should we create?" }), _jsx(SizableText, { size: "$2", color: "$soft", text: "center", maxW: 520, lineHeight: 20, children: "Visuals, images, posters, presentations, documents, ads, 3D, video, music & interactive apps. Upload any file \u2014 everything opens in a tab." })] }));
382
441
  }
383
- /** A composer chip: what it sets, and its value. */
384
- /** A menu's trigger: the menu hands it its state and handlers, and they land on the button itself. */
385
- function Pillish({ label, icon, value, ...trigger }) {
386
- return (_jsxs(XStack, { ...trigger, render: "button", "aria-label": `${label}: ${value}`, items: "center", gap: "$1.5", height: 32, px: "$2.5", rounded: 999, borderWidth: 1, borderColor: "$borderColor", cursor: "pointer", hoverStyle: { bg: '$hover' }, children: [icon, _jsx(SizableText, { size: "$2", numberOfLines: 1, maxW: 120, children: value }), _jsx(ChevronDown, { size: 12 })] }));
442
+ /** A composer picker aligned to the composer's inner text left edge (11px composer-foot + 1px border + 4px px = 16px). */
443
+ function Pillish({ label, icon, value, open = false, ...trigger }) {
444
+ const compact = !useMedia().sm;
445
+ const { onPress: triggerOnPress, onClick: triggerOnClick, ...rest } = trigger;
446
+ return (_jsx(XStack, { ...rest, render: _jsx("button", { type: "button" }), onClick: (e) => {
447
+ if (triggerOnClick)
448
+ triggerOnClick(e);
449
+ else
450
+ triggerOnPress?.(e);
451
+ }, "aria-label": rest['aria-label'] ?? `${label}: ${value}`, "aria-expanded": open, items: "center", minH: compact ? 44 : 38, "$max-sm": { minH: 44 }, px: compact ? '$2' : 4, py: compact ? 0 : 4, rounded: "$3", borderWidth: 1, borderColor: open ? 'var(--border-strong)' : 'transparent', bg: open ? '$hover' : 'transparent', cursor: "pointer", hoverStyle: { bg: '$hover', borderColor: 'var(--border-strong)' }, focusVisibleStyle: RING, shrink: 0, children: compact ? (_jsxs(XStack, { items: "center", gap: "$1", minW: 0, children: [icon, _jsx(SizableText, { size: "$1", lineHeight: 14, color: "$hint", numberOfLines: 1, children: label }), _jsx(SizableText, { size: "$2", lineHeight: 16, fontWeight: "500", color: "$ink", numberOfLines: 1, maxW: 84, children: value }), _jsx(ChevronDown, { size: 11, color: "$soft" })] })) : (_jsxs(YStack, { items: "flex-start", gap: 1, minW: 0, children: [_jsx(SizableText, { size: "$1", lineHeight: 14, color: "$hint", numberOfLines: 1, children: label }), _jsxs(XStack, { items: "center", gap: "$1", minW: 0, children: [icon, _jsx(SizableText, { size: "$2", lineHeight: 18, fontWeight: "500", color: "$ink", numberOfLines: 1, maxW: 116, children: value }), _jsx(ChevronDown, { size: 11, color: "$soft" })] })] })) }));
387
452
  }
388
453
  /** What a turn made, as a chip that opens its tab. */
389
454
  function Chip({ made, wire, n, onPress }) {
@@ -391,7 +456,7 @@ function Chip({ made, wire, n, onPress }) {
391
456
  const Icon = k.icon;
392
457
  const pic = current(made).files.find((f) => f.mime.startsWith('image/'));
393
458
  const { src } = useUrl(wire, pic?.key);
394
- return (_jsxs(XStack, { render: "button", "aria-label": `Open tab ${n}: ${made.title}`, onPress: onPress, items: "center", gap: "$2", p: "$1.5", pr: "$3", rounded: "$4", borderWidth: 1, borderColor: "$borderColor", cursor: "pointer", hoverStyle: { bg: '$hover' }, maxW: 280, children: [src ? (_jsx("img", { src: src, alt: "", width: 40, height: 40, style: { borderRadius: 8, objectFit: 'cover' } })) : (_jsx(XStack, { width: 40, height: 40, rounded: "$3", bg: "$hover", items: "center", justify: "center", children: _jsx(Icon, { size: 16 }) })), _jsxs(YStack, { minW: 0, children: [_jsx(SizableText, { size: "$2", numberOfLines: 1, children: made.title }), _jsx(SizableText, { size: "$1", color: "$soft", children: `Tab ${n} · ${k.label} · v${made.at + 1}` })] }), _jsx(Check, { size: 13 })] }));
459
+ return (_jsxs(XStack, { render: _jsx("button", { type: "button" }), "aria-label": `Open tab ${n}: ${made.title}`, onClick: onPress, items: "center", gap: "$2", p: "$1.5", pr: "$3", minH: 44, "$max-sm": { minH: 44 }, rounded: "$4", borderWidth: 1, borderColor: "var(--border-strong)", bg: "var(--surface-card)", cursor: "pointer", hoverStyle: { bg: '$hover' }, focusVisibleStyle: RING, maxW: 280, children: [src ? (_jsx("img", { src: src, alt: "", width: 40, height: 40, style: { borderRadius: 8, objectFit: 'cover' } })) : (_jsx(XStack, { width: 40, height: 40, rounded: "$3", bg: "$hover", items: "center", justify: "center", "$platform-web": { color: 'var(--foreground)' }, children: _jsx(Icon, { size: 16 }) })), _jsxs(YStack, { minW: 0, children: [_jsx(SizableText, { size: "$2", fontWeight: "600", color: "$ink", numberOfLines: 1, children: made.title }), _jsx(SizableText, { size: "$1", color: "$soft", children: `Tab ${n} · ${k.label} · v${made.at + 1}` })] }), _jsx(Check, { size: 13, color: "$ink" })] }));
395
460
  }
396
461
  function Thumb({ wire, file }) {
397
462
  const isImage = file.mime.startsWith('image/');
@@ -400,5 +465,5 @@ function Thumb({ wire, file }) {
400
465
  return _jsx("img", { src: src, alt: file.name, width: 56, height: 56, style: { borderRadius: 8, objectFit: 'cover' } });
401
466
  }
402
467
  const Icon = file.mime.startsWith('audio/') ? Music : file.mime.startsWith('video/') ? Clapperboard : isImage ? ImageIcon : FileText;
403
- return (_jsxs(XStack, { height: 56, px: "$2.5", gap: "$2", rounded: "$3", bg: "$hover", items: "center", justify: "center", maxW: 180, children: [_jsx(Icon, { size: 16 }), _jsx(SizableText, { size: "$1", numberOfLines: 2, children: file.name })] }));
468
+ return (_jsxs(XStack, { height: 56, px: "$2.5", gap: "$2", rounded: "$3", bg: "var(--surface-card)", borderWidth: 1, borderColor: "var(--border)", items: "center", justify: "center", maxW: 180, children: [_jsx(Icon, { size: 16, color: "$ink" }), _jsx(SizableText, { size: "$1", color: "$ink", numberOfLines: 2, children: file.name })] }));
404
469
  }
package/lib/ui.d.ts CHANGED
@@ -1,4 +1,17 @@
1
1
  import type { ReactNode } from 'react';
2
+ /** The focus ring every Studio control draws: one definition. */
3
+ export declare const RING: {
4
+ readonly outlineWidth: 2;
5
+ readonly outlineStyle: 'solid';
6
+ readonly outlineColor: 'var(--ring)';
7
+ };
8
+ /** The same ring drawn inside the edge, for a control that fills its clipped parent. */
9
+ export declare const RING_INSET: {
10
+ readonly outlineWidth: 2;
11
+ readonly outlineStyle: 'solid';
12
+ readonly outlineColor: 'var(--ring)';
13
+ readonly outlineOffset: -2;
14
+ };
2
15
  export interface Option {
3
16
  value: string;
4
17
  label?: string;
@@ -32,19 +45,20 @@ export declare function Row({ label, children }: {
32
45
  children: ReactNode;
33
46
  }): import("react").JSX.Element;
34
47
  /** A pill that is on or off: a category, a filter. */
35
- export declare function Pill({ on, onPress, children, label }: {
48
+ export declare function Pill({ on, onPress, children, label, count, }: {
36
49
  on: boolean;
37
50
  onPress: () => void;
38
51
  children: ReactNode;
39
52
  label?: string;
53
+ count?: number;
40
54
  }): import("react").JSX.Element;
41
55
  /** A small press with an icon and a word: the tab bar's controls. */
42
- export declare function Act({ onPress, children, label, on, disabled }: {
56
+ export declare function Act({ onPress, children, label, on, disabled, }: {
43
57
  onPress: () => void;
44
58
  children: ReactNode;
45
59
  label: string;
46
60
  on?: boolean;
47
61
  disabled?: boolean;
48
62
  }): import("react").JSX.Element;
49
- /** Save bytes as a file the person keeps. */
50
- export declare function download(name: string, blob: Blob): void;
63
+ /** Whether the user has asked the OS for reduced motion. */
64
+ export declare function reducedMotion(): boolean;
package/lib/ui.js CHANGED
@@ -6,19 +6,44 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
6
6
  * or @hanzo/build's.
7
7
  */
8
8
  import { SizableText, styled, XStack, YStack } from '@hanzo/gui';
9
+ /** The focus ring every Studio control draws: one definition. */
10
+ export const RING = { outlineWidth: 2, outlineStyle: 'solid', outlineColor: 'var(--ring)' };
11
+ /** The same ring drawn inside the edge, for a control that fills its clipped parent. */
12
+ export const RING_INSET = { ...RING, outlineOffset: -2 };
9
13
  const field = {
10
14
  size: '$2',
11
15
  minW: 0,
12
16
  rounded: '$3',
13
17
  borderWidth: 1,
14
- borderColor: '$borderColor',
15
- bg: 'transparent',
18
+ borderColor: 'var(--border-strong)',
19
+ bg: 'var(--background)',
16
20
  color: '$ink',
17
- focusVisibleStyle: { outlineWidth: 2, outlineStyle: 'solid', outlineColor: '$outlineColor' },
21
+ focusVisibleStyle: RING,
18
22
  };
19
- const Select = styled(SizableText, { name: 'StudioChoice', render: 'select', height: 32, px: '$2', cursor: 'pointer', ...field });
20
- const Line = styled(SizableText, { name: 'StudioLine', render: 'input', height: 32, px: '$2.5', ...field });
21
- const Lines = styled(SizableText, { name: 'StudioLines', render: 'textarea', p: '$2.5', minH: 72, ...field });
23
+ const Select = styled(SizableText, {
24
+ name: 'StudioChoice',
25
+ render: 'select',
26
+ minH: 44,
27
+ $md: { minH: 32, height: 32 },
28
+ px: '$2',
29
+ cursor: 'pointer',
30
+ ...field,
31
+ });
32
+ const Line = styled(SizableText, {
33
+ name: 'StudioLine',
34
+ render: 'input',
35
+ minH: 44,
36
+ $md: { minH: 32, height: 32 },
37
+ px: '$2.5',
38
+ ...field,
39
+ });
40
+ const Lines = styled(SizableText, {
41
+ name: 'StudioLines',
42
+ render: 'textarea',
43
+ p: '$2.5',
44
+ minH: 76,
45
+ ...field,
46
+ });
22
47
  export function Choice({ value, options, onChange, label }) {
23
48
  const all = value === '' || options.some((o) => o.value === value) ? options : [{ value }, ...options];
24
49
  return (_jsx(Select, { ...{ value }, onChange: (e) => onChange(e.currentTarget.value), "aria-label": label, children: all.map((o) => (_jsx("option", { value: o.value, children: o.label ?? o.value }, o.value))) }));
@@ -30,28 +55,31 @@ export function TextN({ value, onChange, label, rows = 3 }) {
30
55
  return _jsx(Lines, { ...{ value, rows }, onChange: (e) => onChange(e.currentTarget.value), "aria-label": label });
31
56
  }
32
57
  export function Color({ value, onChange, label }) {
33
- return (_jsx("input", { type: "color", value: value, "aria-label": label, onChange: (e) => onChange(e.currentTarget.value), style: { width: 32, height: 32, padding: 0, border: '1px solid var(--borderColor)', borderRadius: 8, background: 'transparent', cursor: 'pointer' } }));
58
+ return (_jsx("input", { type: "color", value: value, "aria-label": label, onChange: (e) => onChange(e.currentTarget.value), style: {
59
+ width: 40,
60
+ height: 40,
61
+ padding: 2,
62
+ border: '1px solid var(--border-strong)',
63
+ borderRadius: 8,
64
+ background: 'var(--background)',
65
+ cursor: 'pointer',
66
+ } }));
34
67
  }
35
68
  /** A label above a control. */
36
69
  export function Row({ label, children }) {
37
70
  return (_jsxs(YStack, { gap: "$1", minW: 0, children: [_jsx(SizableText, { size: "$1", color: "$soft", children: label }), children] }));
38
71
  }
39
72
  /** A pill that is on or off: a category, a filter. */
40
- export function Pill({ on, onPress, children, label }) {
41
- return (_jsx(XStack, { render: "button", role: "button", "aria-pressed": on, "aria-label": label, onPress: onPress, items: "center", gap: "$1.5", height: 32, px: "$3", rounded: 999, borderWidth: 1, borderColor: on ? '$ink' : '$borderColor', bg: on ? '$ink' : 'transparent', cursor: "pointer", hoverStyle: { bg: on ? '$ink' : '$hover' }, focusVisibleStyle: { outlineWidth: 2, outlineStyle: 'solid', outlineColor: '$outlineColor' }, shrink: 0, children: _jsx(SizableText, { size: "$2", color: on ? '$background' : '$ink', children: children }) }));
73
+ export function Pill({ on, onPress, children, label, count, }) {
74
+ return (_jsxs(XStack, { render: _jsx("button", { type: "button" }), "aria-pressed": on, "aria-label": label, onClick: onPress, items: "center", justify: "center", gap: "$1.5", minH: 44, "$max-sm": { minH: 44 }, $md: { minH: 32, height: 32 }, px: "$3", rounded: 999, borderWidth: 1, borderColor: on ? '$ink' : 'var(--border-strong)', bg: on ? '$ink' : 'transparent', cursor: "pointer", hoverStyle: { bg: on ? '$ink' : '$hover', borderColor: on ? '$ink' : 'var(--border-strong)' }, focusVisibleStyle: RING, shrink: 0, children: [_jsx(SizableText, { size: "$2", fontWeight: on ? '600' : '500', color: on ? '$background' : '$ink', whiteSpace: "nowrap", children: children }), count !== undefined ? (_jsx(SizableText, { "aria-hidden": true, size: "$1", fontFamily: "$mono", color: on ? '$background' : '$soft', opacity: on ? 0.72 : 0.85, whiteSpace: "nowrap", children: count })) : null] }));
42
75
  }
43
76
  /** A small press with an icon and a word: the tab bar's controls. */
44
- export function Act({ onPress, children, label, on = false, disabled = false }) {
45
- return (_jsx(XStack, { render: "button", role: "button", "aria-label": label, "aria-pressed": on || undefined, disabled: disabled, onPress: disabled ? undefined : onPress, items: "center", gap: "$1.5", height: 30, px: "$2.5", rounded: "$3", bg: on ? '$hover' : 'transparent', opacity: disabled ? 0.4 : 1, cursor: disabled ? 'default' : 'pointer', hoverStyle: disabled ? undefined : { bg: '$hover' }, focusVisibleStyle: { outlineWidth: 2, outlineStyle: 'solid', outlineColor: '$outlineColor' }, shrink: 0, children: children }));
46
- }
47
- /** Save bytes as a file the person keeps. */
48
- export function download(name, blob) {
49
- const url = URL.createObjectURL(blob);
50
- const a = document.createElement('a');
51
- a.href = url;
52
- a.download = name;
53
- document.body.appendChild(a);
54
- a.click();
55
- a.remove();
56
- setTimeout(() => URL.revokeObjectURL(url), 10_000);
77
+ export function Act({ onPress, children, label, on = false, disabled = false, }) {
78
+ return (_jsx(XStack, { render: _jsx("button", { type: "button" }), "aria-label": label, "aria-pressed": on || undefined, disabled: disabled, onClick: disabled ? undefined : onPress, items: "center", justify: "center", gap: "$1.5", minH: 44, minW: 44, "$max-sm": { minH: 44, minW: 44 }, $md: { minH: 30, minW: 30, height: 30 }, px: "$2.5", rounded: "$3", borderWidth: 1, borderColor: on ? 'var(--border-strong)' : 'transparent', bg: on ? '$hover' : 'transparent', opacity: disabled ? 0.4 : 1, cursor: disabled ? 'default' : 'pointer', hoverStyle: disabled ? undefined : { bg: '$hover', borderColor: 'var(--border-strong)' }, focusVisibleStyle: RING, shrink: 0, children: children }));
79
+ }
80
+ /** Whether the user has asked the OS for reduced motion. */
81
+ export function reducedMotion() {
82
+ if (typeof window === 'undefined' || typeof window.matchMedia !== 'function')
83
+ return false;
84
+ return window.matchMedia('(prefers-reduced-motion: reduce)').matches;
57
85
  }
package/lib/wire.d.ts CHANGED
@@ -128,6 +128,13 @@ export declare function speak(w: Wire, input: string, voice: string, model: stri
128
128
  export declare function libraryLive(w: Wire): Promise<boolean>;
129
129
  /** What each kind makes, as the Library files it (`POST /v1/library` `kind`). */
130
130
  export declare const LIBRARY: Record<string, string>;
131
+ /**
132
+ * Save one made file to the Library because the person asked. Unlike `put`,
133
+ * which holds the file here when the Library cannot take it, this says why.
134
+ */
135
+ export declare function saveToLibrary(w: Wire, key: string, blob: Blob): Promise<string>;
136
+ /** The bytes at an address a Library item gave, or the reason they did not come. */
137
+ export declare function fileAt(href: string): Promise<Blob>;
131
138
  /** Keep bytes at a key: a made file in the Library, anything else in this browser. Answers the key. */
132
139
  export declare function put(w: Wire, key: string, blob: Blob): Promise<string>;
133
140
  /**
@@ -175,6 +182,8 @@ export interface Node {
175
182
  identity: string;
176
183
  name?: string;
177
184
  online?: boolean;
185
+ /** Jobs waiting on this GPU, when the engine says. */
186
+ depth?: number;
178
187
  /** The lanes this GPU can run now: every file its graph loads is present. */
179
188
  lanes?: string[];
180
189
  }
@@ -204,6 +213,14 @@ export interface Row {
204
213
  error?: string;
205
214
  prompt_id?: string;
206
215
  }
216
+ /** Queue a ComfyUI graph on `/v1/prompt`. It is only queued: its `prompt_id` is followed through the work-log. */
217
+ export declare const queuePrompt: (w: Wire, prompt: object, signal?: AbortSignal) => Promise<Submitted>;
218
+ /** The node types the platform's ComfyUI serves. */
219
+ export declare const objectInfo: (w: Wire, signal?: AbortSignal) => Promise<Record<string, {
220
+ display_name?: string;
221
+ category?: string;
222
+ output?: string[];
223
+ }>>;
207
224
  /** The engine's record of what was dispatched and what landed. */
208
225
  export declare const worklog: (w: Wire, signal?: AbortSignal) => Promise<Row[]>;
209
226
  /** A landed file of the engine library, as bytes. */
package/lib/wire.js CHANGED
@@ -360,6 +360,22 @@ async function shelve(w, key, blob) {
360
360
  throw new Refusal(502, 'The Library took the file and named no item.');
361
361
  return item.id;
362
362
  }
363
+ /**
364
+ * Save one made file to the Library because the person asked. Unlike `put`,
365
+ * which holds the file here when the Library cannot take it, this says why.
366
+ */
367
+ export async function saveToLibrary(w, key, blob) {
368
+ if (blob.size > INLINE)
369
+ throw new Refusal(413, 'This file is over the Library\'s 10 MiB browser limit.');
370
+ return shelve(w, key, blob);
371
+ }
372
+ /** The bytes at an address a Library item gave, or the reason they did not come. */
373
+ export async function fileAt(href) {
374
+ const r = await fetch(href, { credentials: 'omit' });
375
+ if (!r.ok)
376
+ throw new Error(`Download failed (HTTP ${r.status})`);
377
+ return r.blob();
378
+ }
363
379
  /** What this page made or read, held for its life: a file is never fetched twice. */
364
380
  const held = new Map();
365
381
  /** Keep bytes at a key: a made file in the Library, anything else in this browser. Answers the key. */
@@ -493,6 +509,10 @@ export async function discard(w, id) {
493
509
  export const gpus = (w, signal) => ask(w, 'engine', '/v1/gpu-status', { signal });
494
510
  /** Dispatch a lane to the org's GPUs (the engine's one funnel). */
495
511
  export const dispatch = (w, lane, body, signal) => ask(w, 'engine', `/v1/library/${lane}`, { body, signal });
512
+ /** Queue a ComfyUI graph on `/v1/prompt`. It is only queued: its `prompt_id` is followed through the work-log. */
513
+ export const queuePrompt = (w, prompt, signal) => ask(w, 'api', '/v1/prompt', { body: { prompt }, signal });
514
+ /** The node types the platform's ComfyUI serves. */
515
+ export const objectInfo = (w, signal) => ask(w, 'api', '/v1/object_info', { signal });
496
516
  /** The engine's record of what was dispatched and what landed. */
497
517
  export const worklog = (w, signal) => ask(w, 'engine', '/v1/worklog', { signal }).then((r) => r.items ?? []);
498
518
  /** A landed file of the engine library, as bytes. */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hanzo/studio",
3
- "version": "0.1.11",
3
+ "version": "0.1.13",
4
4
  "type": "module",
5
5
  "license": "BSD-3-Clause",
6
6
  "description": "Hanzo Studio: a chat that makes images, posters, documents, slides, type systems, 3D, video and sound, with every result open in a tab beside it. Mounted by the Hanzo app at hanzo.ai/studio and served whole at studio.hanzo.ai.",