@hanzo/studio 0.1.4 → 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/live.d.ts CHANGED
@@ -34,11 +34,9 @@ export declare function useChats(w: Wire): {
34
34
  rows: Listed[];
35
35
  error: string;
36
36
  };
37
- /** The words that say where work is kept, while the Library does not answer. */
38
- export declare const KEPT = "Kept in this browser \u00B7 Saving to Library when it\u2019s available";
39
37
  /**
40
38
  * Whether the person's Library answers: asked once, and on the first yes
41
- * whatever was kept only in this browser is carried up to it.
39
+ * every made file this browser still holds is carried up to it and dropped here.
42
40
  */
43
41
  export declare function useLibrary(w: Wire): boolean | null;
44
42
  export type { Fleet };
package/lib/live.js CHANGED
@@ -100,13 +100,11 @@ export function useChats(w) {
100
100
  }, [w]);
101
101
  return { rows, error: rowsError };
102
102
  }
103
- /** The words that say where work is kept, while the Library does not answer. */
104
- export const KEPT = 'Kept in this browser · Saving to Library when it’s available';
105
103
  let shelf = null;
106
104
  const shelfListeners = new Set();
107
105
  /**
108
106
  * Whether the person's Library answers: asked once, and on the first yes
109
- * whatever was kept only in this browser is carried up to it.
107
+ * every made file this browser still holds is carried up to it and dropped here.
110
108
  */
111
109
  export function useLibrary(w) {
112
110
  const [, bump] = useState(0);
package/lib/made.d.ts CHANGED
@@ -1,5 +1,4 @@
1
1
  export type KindId = 'image' | 'poster' | 'document' | 'slides' | 'type' | 'mesh' | 'video' | 'voice' | 'music' | 'ad';
2
- export declare const KINDS: readonly KindId[];
3
2
  export interface Stored {
4
3
  /** The full key in the bucket. */
5
4
  key: string;
@@ -61,15 +60,3 @@ export declare const current: (m: Made) => Version;
61
60
  export declare const dir: (chat: string, m: Pick<Made, 'id' | 'kind'>, version: string) => string;
62
61
  /** A file name a person reads: the title, slugged, and the extension. */
63
62
  export declare function filename(title: string, ext: string): string;
64
- /** A library entry, read from a key under files/. */
65
- export interface Shelved {
66
- kind: KindId;
67
- chat: string;
68
- made: string;
69
- version: string;
70
- name: string;
71
- key: string;
72
- modified: number;
73
- size: number;
74
- }
75
- export declare function shelved(key: string, modified: number, size: number): Shelved | null;
package/lib/made.js CHANGED
@@ -12,7 +12,6 @@
12
12
  * the conversation that made it.
13
13
  */
14
14
  import { fresh } from './route.js';
15
- export const KINDS = ['image', 'poster', 'document', 'slides', 'type', 'mesh', 'video', 'voice', 'music', 'ad'];
16
15
  export const blank = (id = fresh()) => ({ id, title: 'New creation', created: Date.now(), updated: Date.now(), turns: [], made: [] });
17
16
  /** The version a made thing shows. */
18
17
  export const current = (m) => m.versions[Math.min(Math.max(0, m.at), m.versions.length - 1)];
@@ -27,10 +26,3 @@ export function filename(title, ext) {
27
26
  .slice(0, 60);
28
27
  return `${base || 'untitled'}.${ext}`;
29
28
  }
30
- export function shelved(key, modified, size) {
31
- const [kind, chat, made, version, ...rest] = key.split('/');
32
- const name = rest.join('/');
33
- if (!kind || !chat || !made || !version || !name || !KINDS.includes(kind))
34
- return null;
35
- return { kind: kind, chat, made, version, name, key: `files/${key}`, modified, size };
36
- }
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/places.js CHANGED
@@ -9,13 +9,11 @@ import { Download, Search, Trash2 } from '@hanzogui/lucide-icons-2';
9
9
  import { useEffect, useMemo, useState } from 'react';
10
10
  import { useHost } from './host.js';
11
11
  import { ALL, kind } from './kinds/index.js';
12
- import { KEPT, useAvailable, useChats, useLibrary, useWire } from './live.js';
13
- import { shelved } from './made.js';
12
+ import { useAvailable, useChats, useLibrary, useWire } from './live.js';
14
13
  import { path } from './route.js';
15
14
  import { CATEGORIES, RUNTIME, STARTERS } from './starters.js';
16
15
  import { Act, download, Pill } from './ui.js';
17
- import { useUrl } from './use.js';
18
- import { ask, list, read, remove } from './wire.js';
16
+ import { ask, discard, shelf } from './wire.js';
19
17
  /** A starter handed from Explore to the conversation it starts. */
20
18
  let queued = null;
21
19
  export const queue = (s) => {
@@ -29,6 +27,9 @@ export const take = () => {
29
27
  function Page({ title, children, right }) {
30
28
  return (_jsx(YStack, { flex: 1, minH: 0, overflow: "scroll", bg: "var(--pane-fill, var(--sheet-1))", rounded: "var(--pane-round, var(--radius-xl))", borderWidth: 1, borderColor: "var(--pane-edge, var(--white-08))", children: _jsxs(YStack, { width: "100%", maxW: 1160, mx: "auto", p: "$4", gap: "$4", children: [_jsxs(XStack, { items: "center", gap: "$3", flexWrap: "wrap", children: [_jsx(SizableText, { render: "h1", size: "$7", fontWeight: "600", flex: 1, children: title }), right] }), children] }) }));
31
29
  }
30
+ /* ----------------------------------------------------------------- library */
31
+ /** The Studio kind whose mark a Library kind wears. */
32
+ const MARK = { image: 'image', video: 'video', audio: 'voice', document: 'document', slides: 'slides', type: 'type', model: 'mesh' };
32
33
  export function Library() {
33
34
  const host = useHost();
34
35
  const wire = useWire(host);
@@ -36,48 +37,29 @@ export function Library() {
36
37
  const [error, setError] = useState('');
37
38
  const [only, setOnly] = useState('all');
38
39
  const [q, setQ] = useState('');
39
- const shelf = useLibrary(wire);
40
+ useLibrary(wire);
40
41
  const reload = () => {
41
42
  setError('');
42
- list(wire, 'files/').then((entries) => {
43
- const by = new Map();
44
- for (const e of entries) {
45
- const s = shelved(e.key, e.modified, e.size);
46
- if (!s || s.made === 'attached')
47
- continue;
48
- const id = `${s.chat}/${s.made}`;
49
- const it = by.get(id) ?? { kind: s.kind, chat: s.chat, made: s.made, files: [], modified: 0 };
50
- // The newest version's files stand for the thing.
51
- const newest = it.files[0]?.version;
52
- if (!newest || s.version > newest)
53
- it.files = [s, ...it.files.filter((f) => f.version === s.version)];
54
- else if (s.version === newest)
55
- it.files.push(s);
56
- it.modified = Math.max(it.modified, s.modified);
57
- by.set(id, it);
58
- }
59
- setItems([...by.values()].sort((a, b) => b.modified - a.modified));
60
- }, (e) => setError(e instanceof Error ? e.message : String(e)));
43
+ shelf(wire).then(setItems, (e) => setError(e instanceof Error ? e.message : String(e)));
61
44
  };
62
45
  useEffect(reload, [wire]);
63
46
  const kinds = useMemo(() => [...new Set((items ?? []).map((i) => i.kind))], [items]);
64
- const shown = (items ?? []).filter((i) => (only === 'all' || i.kind === only) && (!q || i.files.some((f) => f.name.toLowerCase().includes(q.toLowerCase()))));
65
- return (_jsxs(Page, { title: "Library", right: _jsxs(XStack, { items: "center", gap: "$2", height: 34, px: "$3", rounded: 999, borderWidth: 1, borderColor: "$borderColor", minW: 220, children: [_jsx(Search, { size: 14 }), _jsx("input", { "aria-label": "Search the library", placeholder: "Search", value: q, onChange: (e) => setQ(e.currentTarget.value), style: { flex: 1, border: 0, background: 'transparent', color: 'inherit', font: 'inherit', outline: 'none' } })] }), children: [_jsx(SizableText, { size: "$2", color: "$soft", children: shelf ? 'Saved to your Library, private to you until you share it.' : KEPT }), _jsxs(XStack, { gap: "$2", flexWrap: "wrap", role: "toolbar", "aria-label": "Kinds", children: [_jsx(Pill, { on: only === 'all', onPress: () => setOnly('all'), children: "All" }), kinds.map((k) => (_jsx(Pill, { on: only === k, onPress: () => setOnly(k), children: kind(k).label }, k)))] }), error ? _jsx(SizableText, { color: "$red10", children: error }) : null, items === null && !error ? _jsx(SizableText, { color: "$soft", children: "Reading\u2026" }) : null, items && !shown.length ? _jsx(SizableText, { color: "$soft", children: items.length ? 'Nothing matches.' : 'Nothing made yet. Start on the home page.' }) : null, _jsx(XStack, { flexWrap: "wrap", gap: 12, role: "list", "aria-label": "Made", children: shown.map((i) => (_jsx(Thing, { wire: wire, item: i, onOpen: () => host.go(path({ kind: 'chat', id: i.chat })), onGone: reload }, `${i.chat}/${i.made}`))) })] }));
47
+ const shown = (items ?? []).filter((i) => (only === 'all' || i.kind === only) && (!q || i.name.toLowerCase().includes(q.toLowerCase())));
48
+ return (_jsxs(Page, { title: "Library", right: _jsxs(XStack, { items: "center", gap: "$2", height: 34, px: "$3", rounded: 999, borderWidth: 1, borderColor: "$borderColor", minW: 220, children: [_jsx(Search, { size: 14 }), _jsx("input", { "aria-label": "Search the library", placeholder: "Search", value: q, onChange: (e) => setQ(e.currentTarget.value), style: { flex: 1, border: 0, background: 'transparent', color: 'inherit', font: 'inherit', outline: 'none' } })] }), children: [_jsx(SizableText, { size: "$2", color: "$soft", children: "Saved to your Library, private to you until you share it." }), _jsxs(XStack, { gap: "$2", flexWrap: "wrap", role: "toolbar", "aria-label": "Kinds", children: [_jsx(Pill, { on: only === 'all', onPress: () => setOnly('all'), children: "All" }), kinds.map((k) => (_jsx(Pill, { on: only === k, onPress: () => setOnly(k), children: MARK[k] ? kind(MARK[k]).label : k }, k)))] }), error ? _jsx(SizableText, { color: "$red10", children: error }) : null, items === null && !error ? _jsx(SizableText, { color: "$soft", children: "Reading\u2026" }) : null, items && !shown.length ? _jsx(SizableText, { color: "$soft", children: items.length ? 'Nothing matches.' : 'Nothing made yet. Start on the home page.' }) : null, _jsx(XStack, { flexWrap: "wrap", gap: 12, role: "list", "aria-label": "Made", children: shown.map((i) => (_jsx(Thing, { wire: wire, item: i, onOpen: () => host.go(path({ kind: 'chat', id: i.ref })), onGone: reload }, i.id))) })] }));
66
49
  }
67
50
  function Thing({ wire, item, onOpen, onGone }) {
68
- const k = kind(item.kind);
69
- const Icon = k.icon;
70
- const pic = item.files.find((f) => /\.(png|jpe?g|webp)$/i.test(f.name));
71
- const { src } = useUrl(wire, pic?.key);
51
+ const Icon = kind(MARK[item.kind] ?? 'image').icon;
52
+ const pic = item.mime.startsWith('image/') ? item.url : '';
72
53
  const [busy, setBusy] = useState(false);
73
- const first = item.files.find((f) => !f.name.endsWith('.json')) ?? item.files[0];
74
- const name = first.name;
75
- return (_jsxs(YStack, { role: "listitem", width: "calc(50% - 6px)", $sm: { width: 'calc(25% - 9px)' }, gap: "$1.5", children: [_jsxs(YStack, { render: "button", "aria-label": `Open ${name} in its conversation`, onPress: onOpen, rounded: 16, overflow: "hidden", bg: "$hover", cursor: "pointer", style: { aspectRatio: '4 / 5' }, items: "center", justify: "center", position: "relative", children: [src ? _jsx("img", { src: src, alt: "", style: { position: 'absolute', inset: 0, width: '100%', height: '100%', objectFit: 'cover' } }) : _jsx(Icon, { size: 28 }), _jsx(XStack, { position: "absolute", t: 8, l: 8, width: 26, height: 26, rounded: 99, bg: "rgba(0,0,0,0.55)", items: "center", justify: "center", children: _jsx(Icon, { size: 13 }) })] }), _jsxs(XStack, { items: "center", gap: "$1", children: [_jsx(SizableText, { size: "$2", fontWeight: "600", numberOfLines: 1, flex: 1, children: name.replace(/\.[a-z0-9.]+$/i, '').replace(/-/g, ' ') }), _jsx(Act, { label: `Download ${name}`, onPress: () => void read(wire, first.key).then((b) => download(name, b)), children: _jsx(Download, { size: 13 }) }), _jsx(Act, { label: `Delete ${name}`, disabled: busy, onPress: () => {
76
- if (!window.confirm(`Delete ${name} from the library? Its conversation keeps the record.`))
54
+ const name = item.name;
55
+ return (_jsxs(YStack, { role: "listitem", width: "calc(50% - 6px)", $sm: { width: 'calc(25% - 9px)' }, gap: "$1.5", children: [_jsxs(YStack, { render: "button", "aria-label": `Open ${name} in its conversation`, onPress: onOpen, rounded: 16, overflow: "hidden", bg: "$hover", cursor: "pointer", style: { aspectRatio: '4 / 5' }, items: "center", justify: "center", position: "relative", children: [pic ? _jsx("img", { src: pic, alt: "", style: { position: 'absolute', inset: 0, width: '100%', height: '100%', objectFit: 'cover' } }) : _jsx(Icon, { size: 28 }), _jsx(XStack, { position: "absolute", t: 8, l: 8, width: 26, height: 26, rounded: 99, bg: "rgba(0,0,0,0.55)", items: "center", justify: "center", children: _jsx(Icon, { size: 13 }) })] }), _jsxs(XStack, { items: "center", gap: "$1", children: [_jsx(SizableText, { size: "$2", fontWeight: "600", numberOfLines: 1, flex: 1, children: name.replace(/\.[a-z0-9.]+$/i, '').replace(/-/g, ' ') }), _jsx(Act, { label: `Download ${name}`, onPress: () => void fetch(item.download || item.url, { credentials: 'omit' })
56
+ .then((r) => r.blob())
57
+ .then((b) => download(name, b)), children: _jsx(Download, { size: 13 }) }), _jsx(Act, { label: `Delete ${name}`, disabled: busy, onPress: () => {
58
+ if (!window.confirm(`Delete ${name} from your Library? Its conversation keeps the record.`))
77
59
  return;
78
60
  setBusy(true);
79
- void Promise.all(item.files.map((f) => remove(wire, f.key))).finally(onGone);
80
- }, children: _jsx(Trash2, { size: 13 }) })] }), _jsx(SizableText, { size: "$1", color: "$soft", mt: -4, children: `${k.label} · ${new Date(item.modified).toLocaleDateString()}` })] }));
61
+ void discard(wire, item.id).finally(onGone);
62
+ }, children: _jsx(Trash2, { size: 13 }) })] }), _jsx(SizableText, { size: "$1", color: "$soft", mt: -4, children: `${MARK[item.kind] ? kind(MARK[item.kind]).label : item.kind} · ${new Date(item.created).toLocaleDateString()}` })] }));
81
63
  }
82
64
  /* ----------------------------------------------------------------- explore */
83
65
  export function Explore() {
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,11 +20,11 @@ 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';
27
- import { BRAIN, KEPT, touch, useAvailable, useLibrary, useWire, WRITER } from './live.js';
27
+ import { BRAIN, touch, useAvailable, useLibrary, useWire, WRITER } from './live.js';
28
28
  import { blank, current } from './made.js';
29
29
  import { take } from './places.js';
30
30
  import { path } from './route.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);
@@ -96,15 +93,14 @@ function Conversation({ start, host, wire, available }) {
96
93
  const [editing, setEditing] = useState({});
97
94
  const [editFailed, setEditFailed] = useState({});
98
95
  const wide = useMedia().md;
99
- const shelf = useLibrary(wire);
100
- const imaging = useImageLane();
96
+ useLibrary(wire);
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.` : shelf === false ? KEPT : 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.d.ts CHANGED
@@ -132,13 +132,16 @@ export declare function draw(w: Wire, model: string, prompt: string, o?: {
132
132
  export declare function speak(w: Wire, input: string, voice: string, model: string, signal?: AbortSignal): Promise<Blob>;
133
133
  /** Whether api.hanzo.ai/v1/library answers for this person. */
134
134
  export declare function libraryLive(w: Wire): Promise<boolean>;
135
- /** Keep bytes at a key. Answers the key. */
135
+ /** Keep bytes at a key: a made file in the Library, anything else in this browser. Answers the key. */
136
136
  export declare function put(w: Wire, key: string, blob: Blob): Promise<string>;
137
- /** Carry up to the Library whatever is kept only here. Answers how many went. */
137
+ /**
138
+ * Carry up to the Library every made file this browser still holds the bytes
139
+ * of, and drop them here once the Library has them. Answers how many went.
140
+ */
138
141
  export declare function sync(w: Wire): Promise<number>;
139
142
  /** An address a page can draw a kept file at. */
140
143
  export declare function url(w: Wire, key: string): Promise<string>;
141
- /** A kept file's bytes. */
144
+ /** A kept file's bytes: from this page, this browser, or the Library. */
142
145
  export declare function read(w: Wire, key: string): Promise<Blob>;
143
146
  export interface Entry {
144
147
  /** Relative to the prefix listed. */
@@ -146,15 +149,32 @@ export interface Entry {
146
149
  size: number;
147
150
  /** Unix milliseconds. */
148
151
  modified: number;
149
- /** Whether it is saved in the Library too. */
150
- shelved: boolean;
151
152
  }
152
153
  /** What is kept under a prefix (one that ends in '/'), keys relative to it. */
153
154
  export declare function list(w: Wire, prefix: string): Promise<Entry[]>;
155
+ /** Delete a kept file: its Library item and bytes first, then this browser's record. */
154
156
  export declare function remove(w: Wire, key: string): Promise<void>;
155
157
  /** A kept JSON document, or null when there is none. */
156
158
  export declare function load<T>(w: Wire, key: string): Promise<T | null>;
157
159
  export declare const save: (w: Wire, key: string, value: unknown) => Promise<string>;
160
+ export interface Shelf {
161
+ id: string;
162
+ kind: string;
163
+ name: string;
164
+ mime: string;
165
+ bytes: number;
166
+ ref: string;
167
+ origin: string;
168
+ url: string;
169
+ download: string;
170
+ preview: string;
171
+ created: string;
172
+ shared: boolean;
173
+ }
174
+ /** Every Studio item in the person's Library, read a page at a time. */
175
+ export declare function shelf(w: Wire, signal?: AbortSignal): Promise<Shelf[]>;
176
+ /** Delete one item from the Library, and this browser's record of it. */
177
+ export declare function discard(w: Wire, id: string): Promise<void>;
158
178
  export interface Node {
159
179
  identity: string;
160
180
  name?: string;
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) {
@@ -304,6 +304,8 @@ function tx(d, mode, run) {
304
304
  });
305
305
  }
306
306
  const get = async (w, key) => (await tx(await db(w), 'readonly', (s) => s.get(key))) ?? null;
307
+ const keep = async (w, r) => void (await tx(await db(w), 'readwrite', (s) => s.put(r)));
308
+ const all = async (w) => tx(await db(w), 'readonly', (s) => s.getAll());
307
309
  /* The Library: answered or not, asked once per page. */
308
310
  let library = null;
309
311
  /** Whether api.hanzo.ai/v1/library answers for this person. */
@@ -314,7 +316,11 @@ export function libraryLive(w) {
314
316
  });
315
317
  return library.catch(() => false);
316
318
  }
319
+ /** The most a browser may send the Library in one save (its inline limit). */
320
+ const INLINE = 10 * 1024 * 1024;
317
321
  const KINDS_LIB = { image: 'image', poster: 'image', ad: 'image', video: 'video', voice: 'audio', music: 'audio', document: 'document', slides: 'slides', type: 'type', mesh: 'model' };
322
+ /** Whether a key and its bytes belong in the Library: a made file the Library can take from a browser. */
323
+ const shelvable = (key, blob) => key.startsWith('files/') && key.split('/').length > 3 && blob.size <= INLINE;
318
324
  const base64 = async (b) => {
319
325
  const buf = new Uint8Array(await b.arrayBuffer());
320
326
  let bin = '';
@@ -322,97 +328,127 @@ const base64 = async (b) => {
322
328
  bin += String.fromCharCode(...buf.subarray(i, i + 0x8000));
323
329
  return btoa(bin);
324
330
  };
325
- /** Save one kept file to the Library, idempotently (its key is the idempotency key). */
326
- async function shelve(w, r) {
327
- const [, kind, chat] = r.key.split('/');
328
- if (!r.key.startsWith('files/') || !kind || !chat || r.blob.size > 10 * 1024 * 1024)
329
- return undefined;
331
+ /** Save one made file to the Library. Answers its item; the key makes a repeat the same item. */
332
+ async function shelve(w, key, blob) {
333
+ const [, kind, chat] = key.split('/');
330
334
  const item = await ask(w, 'api', '/v1/library', {
331
335
  body: {
332
- name: r.key.split('/').pop(),
333
- mime: r.mime,
334
- data: await base64(r.blob),
336
+ name: key.split('/').pop(),
337
+ mime: blob.type || 'application/octet-stream',
338
+ data: await base64(blob),
335
339
  source: 'studio',
336
340
  kind: KINDS_LIB[kind] ?? 'file',
337
341
  ref: chat,
338
342
  origin: `/studio/c/${chat}`,
339
- key: r.key,
343
+ key,
340
344
  },
341
345
  });
346
+ if (!item.id)
347
+ throw new Refusal(502, 'The Library took the file and named no item.');
342
348
  return item.id;
343
349
  }
344
- /** Keep bytes at a key. Answers the key. */
350
+ /** What this page made or read, held for its life: a file is never fetched twice. */
351
+ const held = new Map();
352
+ /** Keep bytes at a key: a made file in the Library, anything else in this browser. Answers the key. */
345
353
  export async function put(w, key, blob) {
346
- const r = { key, blob, mime: blob.type || 'application/octet-stream', modified: Date.now() };
347
- if (key.startsWith('files/') && (await libraryLive(w)))
348
- r.lib = await shelve(w, r).catch(() => undefined);
349
- await tx(await db(w), 'readwrite', (s) => s.put(r));
350
- shown.delete(key);
354
+ const r = { key, mime: blob.type || 'application/octet-stream', size: blob.size, modified: Date.now() };
355
+ const lib = shelvable(key, blob) && (await libraryLive(w)) ? await shelve(w, key, blob).catch(() => undefined) : undefined;
356
+ await keep(w, lib ? { ...r, lib } : { ...r, blob });
357
+ held.set(key, blob);
358
+ forget(key);
351
359
  return key;
352
360
  }
353
- /** Carry up to the Library whatever is kept only here. Answers how many went. */
361
+ /**
362
+ * Carry up to the Library every made file this browser still holds the bytes
363
+ * of, and drop them here once the Library has them. Answers how many went.
364
+ */
354
365
  export async function sync(w) {
355
366
  if (!(await libraryLive(w)))
356
367
  return 0;
357
- const all = await tx(await db(w), 'readonly', (s) => s.getAll());
358
368
  let n = 0;
359
- for (const r of all.filter((x) => x.key.startsWith('files/') && !x.lib)) {
360
- const lib = await shelve(w, r).catch(() => undefined);
369
+ for (const r of await all(w)) {
370
+ if (!r.blob || !shelvable(r.key, r.blob))
371
+ continue;
372
+ const lib = r.lib ?? (await shelve(w, r.key, r.blob).catch(() => undefined));
361
373
  if (!lib)
362
374
  continue;
363
- await tx(await db(w), 'readwrite', (s) => s.put({ ...r, lib }));
375
+ const { blob, ...rest } = r;
376
+ await keep(w, { ...rest, size: blob.size, lib });
364
377
  n++;
365
378
  }
366
379
  return n;
367
380
  }
368
381
  /** Addresses handed out, kept while they work: an object URL for the page's life, a Library URL until it expires. */
369
382
  const shown = new Map();
383
+ function forget(key) {
384
+ const hit = shown.get(key);
385
+ if (hit?.url.startsWith('blob:'))
386
+ URL.revokeObjectURL(hit.url);
387
+ shown.delete(key);
388
+ }
370
389
  /** An address a page can draw a kept file at. */
371
390
  export async function url(w, key) {
372
391
  const hit = shown.get(key);
373
392
  if (hit && hit.until > Date.now())
374
393
  return hit.url;
375
- const r = await get(w, key);
376
- if (!r)
377
- throw new Refusal(404, 'This file is not kept in this browser.');
378
- if (r.lib) {
379
- const item = await ask(w, 'api', `/v1/library/${enc(r.lib)}`).catch(() => null);
380
- if (item?.url) {
381
- shown.set(key, { url: item.url, until: item.expires ? Date.parse(item.expires) - 60_000 : Date.now() + 240_000 });
382
- return item.url;
383
- }
394
+ const local = held.get(key) ?? (await get(w, key))?.blob;
395
+ if (local) {
396
+ const made = URL.createObjectURL(local);
397
+ shown.set(key, { url: made, until: Number.POSITIVE_INFINITY });
398
+ return made;
384
399
  }
385
- const made = URL.createObjectURL(r.blob);
386
- shown.set(key, { url: made, until: Number.POSITIVE_INFINITY });
387
- return made;
400
+ const r = await get(w, key);
401
+ if (!r?.lib)
402
+ throw new Refusal(404, 'This file is not in your Library.');
403
+ const item = await ask(w, 'api', `/v1/library/${enc(r.lib)}`);
404
+ if (!item.url)
405
+ throw new Refusal(502, 'The Library named no address for the file.');
406
+ shown.set(key, { url: item.url, until: item.expires ? Date.parse(item.expires) - 60_000 : Date.now() + 240_000 });
407
+ return item.url;
388
408
  }
389
- /** A kept file's bytes. */
409
+ /** A kept file's bytes: from this page, this browser, or the Library. */
390
410
  export async function read(w, key) {
411
+ const hit = held.get(key);
412
+ if (hit)
413
+ return hit;
391
414
  const r = await get(w, key);
392
415
  if (!r)
393
- throw new Refusal(404, 'This file is not kept in this browser.');
394
- return r.blob;
416
+ throw new Refusal(404, 'This file is not in your Library.');
417
+ if (r.blob)
418
+ return r.blob;
419
+ const res = await fetch(await url(w, key), { cache: 'no-store', credentials: 'omit' });
420
+ if (!res.ok)
421
+ throw new Refusal(res.status, 'The Library would not hand the file back.');
422
+ const b = await res.blob();
423
+ held.set(key, b);
424
+ return b;
395
425
  }
396
426
  /** What is kept under a prefix (one that ends in '/'), keys relative to it. */
397
427
  export async function list(w, prefix) {
398
428
  const range = IDBKeyRange.bound(prefix, `${prefix}￿`);
399
- const all = await tx(await db(w), 'readonly', (s) => s.getAll(range));
400
- return all.map((r) => ({ key: r.key.slice(prefix.length), size: r.blob.size, modified: r.modified, shelved: Boolean(r.lib) }));
429
+ const rows = await tx(await db(w), 'readonly', (s) => s.getAll(range));
430
+ return rows.map((r) => ({ key: r.key.slice(prefix.length), size: r.size ?? r.blob?.size ?? 0, modified: r.modified }));
401
431
  }
432
+ /** Delete a kept file: its Library item and bytes first, then this browser's record. */
402
433
  export async function remove(w, key) {
403
434
  const r = await get(w, key);
404
435
  if (r?.lib)
405
- await ask(w, 'api', `/v1/library/${enc(r.lib)}`, { method: 'DELETE' }).catch(() => undefined);
436
+ await unshelve(w, r.lib);
406
437
  await tx(await db(w), 'readwrite', (s) => s.delete(key));
407
- const hit = shown.get(key);
408
- if (hit?.url.startsWith('blob:'))
409
- URL.revokeObjectURL(hit.url);
410
- shown.delete(key);
438
+ held.delete(key);
439
+ forget(key);
440
+ }
441
+ /** Delete one Library item. One already gone is gone. */
442
+ async function unshelve(w, id) {
443
+ await ask(w, 'api', `/v1/library/${enc(id)}`, { method: 'DELETE' }).catch((e) => {
444
+ if (!(e instanceof Refusal && e.status === 404))
445
+ throw e;
446
+ });
411
447
  }
412
448
  /** A kept JSON document, or null when there is none. */
413
449
  export async function load(w, key) {
414
450
  const r = await get(w, key);
415
- if (!r)
451
+ if (!r?.blob)
416
452
  return null;
417
453
  try {
418
454
  return JSON.parse(await r.blob.text());
@@ -422,6 +458,24 @@ export async function load(w, key) {
422
458
  }
423
459
  }
424
460
  export const save = (w, key, value) => put(w, key, new Blob([JSON.stringify(value)], { type: 'application/json' }));
461
+ /** Every Studio item in the person's Library, read a page at a time. */
462
+ export async function shelf(w, signal) {
463
+ const out = [];
464
+ let cursor = '';
465
+ do {
466
+ const page = await ask(w, 'api', `/v1/library${query({ source: 'studio', scope: 'mine', limit: 200, cursor })}`, { signal });
467
+ out.push(...(page.data ?? []));
468
+ cursor = page.next ?? '';
469
+ } while (cursor);
470
+ return out;
471
+ }
472
+ /** Delete one item from the Library, and this browser's record of it. */
473
+ export async function discard(w, id) {
474
+ await unshelve(w, id);
475
+ for (const r of await all(w))
476
+ if (r.lib === id)
477
+ await tx(await db(w), 'readwrite', (s) => s.delete(r.key));
478
+ }
425
479
  /** The org's GPUs and what each can run. A fleet the engine cannot read is an error, never an empty fleet. */
426
480
  export const gpus = (w, signal) => ask(w, 'engine', '/v1/gpu-status', { signal });
427
481
  /** Dispatch a lane to the org's GPUs (the engine's one funnel). */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hanzo/studio",
3
- "version": "0.1.4",
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
  },