@hanzo/studio 0.1.5 → 0.1.6

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/chat/turn.js CHANGED
@@ -15,6 +15,7 @@
15
15
  */
16
16
  import { complete, put, read } from '../wire.js';
17
17
  import { ALL, called, kind } from '../kinds/index.js';
18
+ import { UNDRAWN } from '../kinds/image.js';
18
19
  import { settle } from '../kinds/type/system.js';
19
20
  import { current, dir } from '../made.js';
20
21
  import { data } from '../raster.js';
@@ -125,6 +126,8 @@ export async function turn(start, asked, ctx) {
125
126
  put_({ ...chat, turns: chat.turns.map((t) => (t.id === you.id ? { ...t, ...patch } : t)) });
126
127
  };
127
128
  const mine = () => chat.turns.find((t) => t.id === you.id);
129
+ // A picture the gateway did not draw: the turn ends on one plain sentence and a retry.
130
+ let missed = false;
128
131
  const open = ALL.filter((k) => !k.needs(ctx));
129
132
  const closed = ALL.filter((k) => k.needs(ctx));
130
133
  const tools = [...open.map((k) => ({ type: 'function', function: k.tool })), REVISE, BRAND];
@@ -156,7 +159,7 @@ export async function turn(start, asked, ctx) {
156
159
  messages.push({ role: 'tool', tool_call_id: c.id, content: JSON.stringify(answer) });
157
160
  }
158
161
  }
159
- set({ doing: undefined });
162
+ set({ doing: undefined, ...(missed ? { failed: `${UNDRAWN} Try again?` } : {}) });
160
163
  }
161
164
  catch (e) {
162
165
  if (e?.name === 'AbortError')
@@ -232,6 +235,9 @@ export async function turn(start, asked, ctx) {
232
235
  wire: ctx.wire,
233
236
  signal: ctx.signal,
234
237
  doing: (line) => set({ doing: line }),
238
+ missed: () => {
239
+ missed = true;
240
+ },
235
241
  keep: async (name, blob, extra) => {
236
242
  const key = await put(ctx.wire, `${dir(chat.id, m, vid)}/${name}`, blob);
237
243
  return { key, mime: blob.type || 'application/octet-stream', name, ...extra };
@@ -257,6 +263,7 @@ export async function edit(start, m, patch, note, ctx) {
257
263
  wire: ctx.wire,
258
264
  signal: ctx.signal,
259
265
  doing: () => undefined,
266
+ missed: () => undefined,
260
267
  keep: async (name, blob, extra) => ({ key: await put(ctx.wire, `${dir(start.id, m, vid)}/${name}`, blob), mime: blob.type || 'application/octet-stream', name, ...extra }),
261
268
  picture: async (f) => data(await read(ctx.wire, f.key)),
262
269
  find: (ref) => start.made.find((x) => x.id === (typeof ref === 'number' ? ctx.order()[ref - 1] : ref)) ?? null,
package/lib/kinds/ad.js CHANGED
@@ -98,7 +98,7 @@ export const ad = {
98
98
  }
99
99
  }
100
100
  const files = await draw(w, s);
101
- return { title: str(args.title, s.headline), draft: { spec: s, files, note: why ? `Set in type alone: ${why}` : s.headline, by: 'Studio layout' } };
101
+ return { title: str(args.title, s.headline), draft: { spec: s, files, note: why ? `Set in type alone. ${why}` : s.headline, by: 'Studio layout' } };
102
102
  },
103
103
  revise: async (w, made, change) => {
104
104
  const s = spec({ ...current(made).spec, ...(change.patch ?? {}), system: w.brand ?? current(made).spec.system });
@@ -24,11 +24,8 @@ export declare const ASPECTS: readonly ['1:1', '4:5', '3:4', '2:3', '9:16', '16:
24
24
  export declare function lane(model: string, fleet: Fleet | null): string;
25
25
  /** Which lane an edit takes: the one asked for, else Qwen Edit on a GPU that can run it, else the gateway. */
26
26
  export declare function editing(model: string, fleet: Fleet | null): string;
27
- /** Why the gateway's image models are not answering now, or null. */
28
- export declare function useImageLane(): {
29
- model: string;
30
- reason: string;
31
- } | null;
27
+ /** What a person reads when the gateway draws no picture: never a model, a provider or the plumbing between. */
28
+ export declare const UNDRAWN = "Couldn't draw the picture this time.";
32
29
  /** Make pictures from words (and, for an edit, the pictures they start from), and keep them. */
33
30
  export declare function picture(w: Work, o: {
34
31
  prompt: string;
@@ -11,7 +11,7 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
11
11
  */
12
12
  import { SizableText, XStack, YStack } from '@hanzo/gui';
13
13
  import { Image as Picture } from '@hanzogui/lucide-icons-2';
14
- import { useState, useSyncExternalStore } from 'react';
14
+ import { useState } from 'react';
15
15
  import { render } from '../gpu.js';
16
16
  import { current, filename } from '../made.js';
17
17
  import { useUrl } from '../use.js';
@@ -67,23 +67,8 @@ async function size(blob) {
67
67
  return {};
68
68
  }
69
69
  }
70
- /*
71
- * Whether the gateway's image lane is answering, as the last call found it: a lane
72
- * that refused at the source says why, in the composer, until a call succeeds.
73
- */
74
- let down = null;
75
- const watchers = new Set();
76
- const note = (next) => {
77
- down = next;
78
- watchers.forEach((w) => w());
79
- };
80
- /** Why the gateway's image models are not answering now, or null. */
81
- export function useImageLane() {
82
- return useSyncExternalStore((l) => {
83
- watchers.add(l);
84
- return () => watchers.delete(l);
85
- }, () => down, () => down);
86
- }
70
+ /** What a person reads when the gateway draws no picture: never a model, a provider or the plumbing between. */
71
+ export const UNDRAWN = "Couldn't draw the picture this time.";
87
72
  /** Make pictures from words (and, for an edit, the pictures they start from), and keep them. */
88
73
  export async function picture(w, o) {
89
74
  const use = o.from?.length ? editing(o.model, w.fleet) : lane(o.model, w.fleet);
@@ -116,11 +101,12 @@ export async function picture(w, o) {
116
101
  got = await draw(w.wire, use, ask, { from, aspect: o.aspect, signal: w.signal });
117
102
  }
118
103
  catch (e) {
119
- if (e instanceof Refusal && (e.status >= 500 || e.status === 402))
120
- note({ model: use, reason: e.message });
121
- throw e;
104
+ // A plan's refusal says what lifts it; anything else is the one plain sentence, and the turn offers to try again.
105
+ if ((e instanceof Refusal && e.status === 402) || w.signal.aborted)
106
+ throw e;
107
+ w.missed();
108
+ throw new Error(UNDRAWN, { cause: e });
122
109
  }
123
- note(null);
124
110
  for (const g of got)
125
111
  files.push(await w.keep(`image-${files.length + 1}.${ext(g.mime)}`, g.blob, await size(g.blob)));
126
112
  }
@@ -28,6 +28,8 @@ export interface Work {
28
28
  signal: AbortSignal;
29
29
  /** Say what is happening now: drawn under the turn while it works. */
30
30
  doing: (line: string) => void;
31
+ /** A picture could not be drawn: the turn ends offering to try again. */
32
+ missed: () => void;
31
33
  /** Keep bytes as one of this version's files. */
32
34
  keep: (name: string, blob: Blob, extra?: {
33
35
  width?: number;
@@ -118,7 +118,7 @@ export const poster = {
118
118
  const got = await art(w, s, num(args.image_tab, 0));
119
119
  s.picture = got.key;
120
120
  const files = await draw(w, s);
121
- const note = got.why ? `Set in type alone: the picture could not be drawn (${got.why})` : s.headline;
121
+ const note = got.why ? `Set in type alone. ${got.why}` : s.headline;
122
122
  return { title: str(args.title, s.headline), draft: { spec: s, files, note, by: 'Studio layout' } };
123
123
  },
124
124
  revise: async (w, made, change) => {
@@ -149,7 +149,7 @@ export const poster = {
149
149
  }
150
150
  }
151
151
  const files = await draw(w, next);
152
- return { spec: next, files, note: why ? `${change.instruction} (the picture is unchanged: ${why})` : (change.instruction ?? 'Edited'), by: 'Studio layout' };
152
+ return { spec: next, files, note: why ? `${change.instruction}. The picture is unchanged: ${why}` : (change.instruction ?? 'Edited'), by: 'Studio layout' };
153
153
  },
154
154
  View: Sheet,
155
155
  exports: [
package/lib/nav.d.ts CHANGED
@@ -6,9 +6,9 @@
6
6
  */
7
7
  import type { Host } from '@hanzo/build';
8
8
  import type { RailLink } from '@hanzo/ui/chat';
9
- /** A run of places under one quiet label. */
9
+ /** Studio's places, as one run: a host draws no heading over its first group. */
10
10
  export interface Group {
11
- id: 'make' | 'made' | 'run';
11
+ id: 'make';
12
12
  label: string;
13
13
  links: RailLink[];
14
14
  }
package/lib/nav.js CHANGED
@@ -13,17 +13,9 @@ export function nav(host, go) {
13
13
  links: [
14
14
  { id: NEW, label: 'New creation', icon: _jsx(SquarePen, { size: 16 }), onPress: to(''), active: r.kind === 'new' },
15
15
  { id: 'explore', label: 'Explore', icon: _jsx(LayoutTemplate, { size: 16 }), onPress: to(path({ kind: 'explore' })), active: r.kind === 'explore' },
16
+ { id: 'library', label: 'Library', icon: _jsx(Library, { size: 16 }), onPress: to(path({ kind: 'library' })), active: r.kind === 'library' },
17
+ { id: 'activity', label: 'Activity', icon: _jsx(Activity, { size: 16 }), onPress: to(path({ kind: 'activity' })), active: r.kind === 'activity' },
16
18
  ],
17
19
  },
18
- {
19
- id: 'made',
20
- label: 'Made',
21
- links: [{ id: 'library', label: 'Library', icon: _jsx(Library, { size: 16 }), onPress: to(path({ kind: 'library' })), active: r.kind === 'library' }],
22
- },
23
- {
24
- id: 'run',
25
- label: 'Run',
26
- links: [{ id: 'activity', label: 'Activity', icon: _jsx(Activity, { size: 16 }), onPress: to(path({ kind: 'activity' })), active: r.kind === 'activity' }],
27
- },
28
20
  ];
29
21
  }
package/lib/talk.js CHANGED
@@ -9,7 +9,7 @@ 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 { Grip, Panel, PanelToggle, prompt, Reply, useDeck, useKey, usePanel } from '@hanzo/build';
12
+ import { Gutter, Panel, PanelToggle, prompt, Reply, SideProvider, useDeck, useKey, usePanel, useSplit } from '@hanzo/build';
13
13
  import { SizableText, useMedia, XStack, YStack } from '@hanzo/gui';
14
14
  import { Check, ChevronDown, Ellipsis, Image as ImageIcon, LoaderCircle, Palette, Sparkles, X } from '@hanzogui/lucide-icons-2';
15
15
  import { DropdownMenu } from '@hanzo/ui';
@@ -20,7 +20,7 @@ import { keep, listed, open } from './chat/store.js';
20
20
  import { Desk } from './desk.js';
21
21
  import { Home } from './home.js';
22
22
  import { useHost } from './host.js';
23
- import { MODELS, useImageLane, ZEN } from './kinds/image.js';
23
+ import { MODELS, ZEN } from './kinds/image.js';
24
24
  import { ALL, kind } from './kinds/index.js';
25
25
  import { lit } from './kinds/kind.js';
26
26
  import { PRESETS } from './kinds/type/system.js';
@@ -41,9 +41,6 @@ const pane = {
41
41
  boxShadow: 'var(--shadow-sheet-2)',
42
42
  };
43
43
  const gap = 'var(--pane-gap, var(--space-2))';
44
- const DESK = 560;
45
- const DESK_FLOOR = 320;
46
- const TALK_FLOOR = 320;
47
44
  export function Talk({ id }) {
48
45
  const host = useHost();
49
46
  const wire = useWire(host);
@@ -97,14 +94,13 @@ function Conversation({ start, host, wire, available }) {
97
94
  const [editFailed, setEditFailed] = useState({});
98
95
  const wide = useMedia().md;
99
96
  useLibrary(wire);
100
- const imaging = useImageLane();
101
97
  const [desk, setDesk] = usePanel('studio', true, wide);
102
98
  useKey(() => setDesk(!desk));
99
+ // The tabs' column, as Chat's and a Dev run's: the person's width, the chat hidden behind it, full screen.
100
+ const split = useSplit(desk && wide && chat.made.length > 0, 'chat', () => setDesk(false));
103
101
  const deck = useDeck(`studio.${chat.id}`, { tabs: chat.made.map((m) => ({ id: m.id, kind: m.id, title: m.title })), at: chat.made.at(-1)?.id ?? null });
104
102
  const order = useRef([]);
105
103
  order.current = [...deck.tabs.map((t) => t.kind).filter((k) => chat.made.some((m) => m.id === k)), ...chat.made.map((m) => m.id).filter((m) => !deck.tabs.some((t) => t.kind === m))];
106
- const [span, setSpan] = useState(DESK);
107
- const deskBox = useRef(null);
108
104
  // Saved after every change, at most once a second and a half; at once when a turn ends.
109
105
  const saving = useRef(null);
110
106
  const persist = useCallback((c, now = false) => {
@@ -313,7 +309,7 @@ function Conversation({ start, host, wire, available }) {
313
309
  { type: 'label', key: 'm', label: 'Image model' },
314
310
  { key: 'auto', label: `${options.model === 'auto' ? '✓ ' : ''}Auto`, description: zen ? 'Zen Image on your GPU' : MODELS[0].label, onSelect: () => setOptions({ ...options, model: 'auto' }) },
315
311
  ...(zen ? [{ key: ZEN, label: `${options.model === ZEN ? '✓ ' : ''}Zen Image`, description: 'On your GPU', onSelect: () => setOptions({ ...options, model: ZEN }) }] : []),
316
- ...MODELS.map((m) => ({ key: m.id, label: `${options.model === m.id ? '✓ ' : ''}${m.label}`, description: m.id, onSelect: () => setOptions({ ...options, model: m.id }) })),
312
+ ...MODELS.map((m) => ({ key: m.id, label: `${options.model === m.id ? '✓ ' : ''}${m.label}`, onSelect: () => setOptions({ ...options, model: m.id }) })),
317
313
  { type: 'separator', key: 's' },
318
314
  { type: 'label', key: 'a', label: 'Aspect' },
319
315
  ...['', '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 }) })),
@@ -333,16 +329,13 @@ function Conversation({ start, host, wire, available }) {
333
329
  placeholder: empty ? 'What should we create?' : 'Ask for a change, or something new',
334
330
  label: 'What should we create?',
335
331
  head,
336
- onAttach: attach,
337
- tools,
332
+ plus: { upload: attach },
333
+ where: tools,
338
334
  mind: null,
339
335
  narrow: !wide,
340
- note: imaging ? `Image models are not answering (${imaging.reason}). Posters and ads are set in type until they are back.` : undefined,
341
336
  });
342
337
  const deskPane = (sheet) => (_jsx(Panel, { side: deck, kinds: tabs, onHide: () => setDesk(false), sheet: sheet, label: "What this conversation made" }));
343
- return (_jsxs(XStack, { "data-slot": "studio-split", flex: 1, minH: 0, minW: 0, width: "100%", children: [_jsxs(YStack, { "data-slot": "studio-talk", ...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 ? 'Studio' : 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, foot: empty ? _jsx(Home, { available: available, onStart: begin }) : undefined } })] }), desk && chat.made.length && !wide ? deskPane(true) : null, desk && chat.made.length && wide ? (_jsxs(YStack, { "data-slot": "studio-desk", ref: (el) => {
344
- deskBox.current = el instanceof HTMLElement ? el : null;
345
- }, ...pane, ml: gap, position: "relative", shrink: 0, minH: 0, overflow: "hidden", style: { width: span, maxWidth: `calc(100% - ${TALK_FLOOR}px)`, minWidth: DESK_FLOOR }, children: [_jsx(Grip, { side: "right", span: span, floor: DESK_FLOOR, ceil: 1400, reset: DESK, onSpan: (n) => deskBox.current?.style.setProperty('width', `${n}px`), onKeep: setSpan, onShut: () => setDesk(false), label: "Resize the tabs", l: `calc(-1 * ${gap} - 1px)`, width: gap }), deskPane(false)] })) : null] }));
338
+ 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 ? 'Studio' : 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, foot: empty ? _jsx(Home, { available: available, onStart: begin }) : undefined } })] }), 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] }));
346
339
  }
347
340
  function brandOf(chat) {
348
341
  const m = chat.brand ? chat.made.find((x) => x.id === chat.brand) : null;
package/lib/wire.js CHANGED
@@ -256,7 +256,7 @@ function withheld(model, h) {
256
256
  if (!why)
257
257
  return new Refusal(502, `${model} answered with no picture.`);
258
258
  const fix = h?.get('X-Hanzo-Upgrade-Url') || h?.get('X-Hanzo-Topup-Url') || '';
259
- return new Refusal(402, `${WITHHELD[why] ?? `Pictures are withheld (${why})`}${fix ? `: ${fix}` : '.'}`, why);
259
+ return new Refusal(402, `${WITHHELD[why] ?? 'Pictures are not available on this plan'}${fix ? `: ${fix}` : '.'}`, why);
260
260
  }
261
261
  /** Speech from words: the platform's voice. */
262
262
  export async function speak(w, input, voice, model, signal) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hanzo/studio",
3
- "version": "0.1.5",
3
+ "version": "0.1.6",
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.",
@@ -13,13 +13,13 @@
13
13
  },
14
14
  "devDependencies": {
15
15
  "@axe-core/playwright": "4.14.0",
16
- "@hanzo/build": "0.2.60",
16
+ "@hanzo/build": "0.2.77",
17
17
  "@hanzo/composer": "0.2.0",
18
18
  "@hanzo/font": "1.9.3",
19
19
  "@hanzo/gui": "8.3.5",
20
- "@hanzo/ui": "8.27.91",
20
+ "@hanzo/ui": "8.29.5",
21
21
  "@hanzo/vite": "0.1.4",
22
- "@hanzo/voice": "0.1.18",
22
+ "@hanzo/voice": "0.1.19",
23
23
  "@hanzogui/lucide-icons-2": "8.3.5",
24
24
  "@hanzogui/next-theme": "8.3.5",
25
25
  "@playwright/test": "1.63.0",
@@ -61,8 +61,8 @@
61
61
  "@hanzo/build": ">=0.2.60",
62
62
  "@hanzo/composer": ">=0.2.0",
63
63
  "@hanzo/gui": ">=8.3.5",
64
- "@hanzo/ui": ">=8.27.77",
65
- "@hanzo/voice": ">=0.1.16",
64
+ "@hanzo/ui": ">=8.29.0",
65
+ "@hanzo/voice": ">=0.1.19",
66
66
  "@hanzogui/lucide-icons-2": ">=8.3.5",
67
67
  "react": ">=19.2.8"
68
68
  },