@hanzo/studio 0.1.7 → 0.1.11

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
@@ -65,8 +65,9 @@ function system(chat, ctx, open, closed) {
65
65
  .filter(Boolean);
66
66
  const brand = brandOf(chat);
67
67
  return [
68
- 'You are Hanzo Studio: a creative studio in a chat. You make things by calling tools, and everything you make opens in a numbered tab beside this conversation.',
68
+ 'You are Hanzo Design: an AI creative and visual design workspace in a chat. You make visuals, images, posters, presentations (slides), documents, ads, short videos, music, voice, type systems, 3D meshes, and full interactive web apps (including full-blown music player & visualizer apps from uploaded audio files) by calling tools, and everything you make opens in a numbered tab beside this conversation.',
69
69
  'When the person asks for something, call the tool that makes it at once, with complete, specific, well-written arguments: real words, not placeholders. Ask a question only when you cannot make anything sensible without the answer.',
70
+ 'When the person attaches an audio/music file or asks to build a music app, visualizer, or interactive experience, call make_app (passing audio_tab with the tab number of the attached audio and image_tab if an image was attached).',
70
71
  'To change something already made, call revise with its tab number. "The poster in tab 2" is tab 2.',
71
72
  'After the tools have run, answer in one or two short sentences: what you made, and one useful next step. Never paste file contents, links or JSON. If a tool answers with an error, say plainly what went wrong.',
72
73
  brand ? `Brand: ${brand.name} (${brand.display} / ${brand.text}; ${brand.blurb}). Posters, documents, slides and ads are drawn in it.` : 'No brand is chosen: things are drawn in the Hanzo type system unless the person asks for a type system.',
@@ -84,7 +85,7 @@ function history(chat, ctx) {
84
85
  .filter((t) => t.text || t.made?.length)
85
86
  .map((t) => {
86
87
  if (t.role === 'user') {
87
- const pics = t.attached?.length ? `\n[Attached ${t.attached.length} picture${t.attached.length > 1 ? 's' : ''}, now in tab ${t.made?.map((m) => order.indexOf(m) + 1).join(', ')}]` : '';
88
+ const pics = t.attached?.length ? `\n[Attached ${t.attached.map((a) => `${a.name} (${a.mime})`).join(', ')}, now in tab ${t.made?.map((m) => order.indexOf(m) + 1).join(', ')}]` : '';
88
89
  return { role: 'user', content: t.text + pics };
89
90
  }
90
91
  const made = (t.made ?? [])
@@ -105,14 +106,18 @@ export async function turn(start, asked, ctx) {
105
106
  };
106
107
  const me = { id: id(), role: 'user', text: asked.text, at: Date.now(), attached: asked.attached.length ? asked.attached : undefined };
107
108
  const you = { id: id(), role: 'assistant', text: '', at: Date.now(), doing: 'Thinking', made: [] };
108
- // An attached picture is a thing in the conversation: its own tab, so it can be named.
109
- const uploads = asked.attached.map((f) => ({
110
- id: id(),
111
- kind: 'image',
112
- title: f.name.replace(/\.[a-z0-9]+$/i, '') || 'Picture',
113
- at: 0,
114
- versions: [{ id: id(), at: Date.now(), spec: { prompt: '', uploaded: true }, files: [f], note: 'Attached', by: 'you' }],
115
- }));
109
+ // An attached file is a thing in the conversation: its own tab, so it can be named and wired into tools.
110
+ const uploadKind = (mime) => mime.startsWith('audio/') ? 'music' : mime.startsWith('video/') ? 'video' : mime.startsWith('image/') ? 'image' : 'document';
111
+ const uploads = asked.attached.map((f) => {
112
+ const k = uploadKind(f.mime);
113
+ return {
114
+ id: id(),
115
+ kind: k,
116
+ title: f.name.replace(/\.[a-z0-9]+$/i, '') || (k === 'music' ? 'Track' : k === 'video' ? 'Clip' : k === 'image' ? 'Picture' : 'File'),
117
+ at: 0,
118
+ versions: [{ id: id(), at: Date.now(), spec: { prompt: '', uploaded: true }, files: [f], note: 'Attached', by: 'you' }],
119
+ };
120
+ });
116
121
  me.made = uploads.map((u) => u.id);
117
122
  put_({
118
123
  ...chat,
@@ -131,7 +136,10 @@ export async function turn(start, asked, ctx) {
131
136
  const open = ALL.filter((k) => !k.needs(ctx));
132
137
  const closed = ALL.filter((k) => k.needs(ctx));
133
138
  const tools = [...open.map((k) => ({ type: 'function', function: k.tool })), REVISE, BRAND];
134
- const messages = [{ role: 'system', content: system(chat, ctx, open, closed) }, ...history(start, ctx), { role: 'user', content: me.text + (uploads.length ? `\n[Attached: tab ${uploads.map((u) => ctx.order().indexOf(u.id) + 1).join(', ')}]` : '') }];
139
+ const attachedSummary = uploads.length
140
+ ? `\n[Attached: ${uploads.map((u, idx) => `tab ${ctx.order().indexOf(u.id) + 1} (${u.kind} "${asked.attached[idx]?.name ?? u.title}")`).join(', ')}]`
141
+ : '';
142
+ const messages = [{ role: 'system', content: system(chat, ctx, open, closed) }, ...history(start, ctx), { role: 'user', content: me.text + attachedSummary }];
135
143
  const picked = asked.kind ? kind(asked.kind) : null;
136
144
  if (picked && picked.needs(ctx)) {
137
145
  set({ doing: undefined, text: `${picked.label} can't run right now. ${picked.needs(ctx)}` });
package/lib/home.d.ts CHANGED
@@ -1,6 +1,8 @@
1
1
  import type { Available } from './kinds/kind.ts';
2
+ import type { KindId } from './made.ts';
2
3
  import { type Starter } from './starters.ts';
3
- export declare function Home({ available, onStart }: {
4
+ export declare function Home({ available, onStart, onUpload, }: {
4
5
  available: Available;
5
6
  onStart: (s: Starter) => void;
7
+ onUpload?: (accept?: string, prompt?: string, kind?: KindId) => void;
6
8
  }): import("react").JSX.Element;
package/lib/home.js CHANGED
@@ -6,7 +6,7 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
6
6
  * picture puts its words in the composer and asks for the picture.
7
7
  */
8
8
  import { SizableText, XStack, YStack } from '@hanzo/gui';
9
- import { ArrowRight } from '@hanzogui/lucide-icons-2';
9
+ import { ArrowRight, Clapperboard, FileText, Image as ImageIcon, Music, Sparkles } from '@hanzogui/lucide-icons-2';
10
10
  import { useState } from 'react';
11
11
  import { useHost } from './host.js';
12
12
  import { kind } from './kinds/index.js';
@@ -17,12 +17,12 @@ import { path } from './route.js';
17
17
  import { CATEGORIES, RUNTIME, STARTERS } from './starters.js';
18
18
  import { Pill } from './ui.js';
19
19
  import { useUrl } from './use.js';
20
- export function Home({ available, onStart }) {
20
+ export function Home({ available, onStart, onUpload, }) {
21
21
  const [cat, setCat] = useState('all');
22
22
  const runs = STARTERS.filter((s) => !kind(s.kind).needs(available));
23
23
  const shown = runs.filter((s) => cat === 'all' || s.category === cat);
24
24
  const cats = CATEGORIES.filter((c) => c.id === 'all' || runs.some((s) => s.category === c.id));
25
- return (_jsxs(YStack, { "data-slot": "studio-home", width: "100%", maxW: 1080, mx: "auto", gap: "$4", pt: "$4", pb: "$6", px: "$1", children: [_jsx(XStack, { role: "toolbar", "aria-label": "Categories", gap: "$2", flexWrap: "wrap", justify: "center", children: cats.map((c) => (_jsx(Pill, { on: cat === c.id, onPress: () => setCat(c.id), children: c.label }, c.id))) }), _jsx(XStack, { role: "list", "aria-label": "Starters", flexWrap: "wrap", gap: 12, children: shown.map((s, i) => (_jsx(Card, { s: s, i: i, onPress: () => onStart(s) }, s.id))) }), _jsx(Recent, {})] }));
25
+ return (_jsxs(YStack, { "data-slot": "studio-home", width: "100%", maxW: 1080, mx: "auto", gap: "$4", pt: "$4", pb: "$6", px: "$1", children: [onUpload ? (_jsxs(XStack, { role: "region", "aria-label": "Upload content to create", gap: "$2", flexWrap: "wrap", justify: "center", children: [_jsxs(XStack, { render: "button", onPress: () => onUpload('audio/*,.mp3,.wav,.flac,.m4a,.ogg,.aac', 'Build a full-blown interactive music player and 60fps audio visualizer app with EQ, waveform scrubber, and live synth pads around this track.', 'app'), items: "center", gap: "$2", px: "$3", height: 34, rounded: 999, borderWidth: 1, borderColor: "$borderColor", bg: "$hover", cursor: "pointer", hoverStyle: { opacity: 0.9 }, children: [_jsx(Music, { size: 14 }), _jsx(SizableText, { size: "$2", fontWeight: "600", children: "Upload Music \u2192 Build Music App" })] }), _jsxs(XStack, { render: "button", onPress: () => onUpload('image/*,.png,.jpg,.jpeg,.webp,.svg', 'Create a brand poster, multi-format ad campaign, and presentation slide deck featuring this visual.'), items: "center", gap: "$2", px: "$3", height: 34, rounded: 999, borderWidth: 1, borderColor: "$borderColor", cursor: "pointer", hoverStyle: { bg: '$hover' }, children: [_jsx(ImageIcon, { size: 14 }), _jsx(SizableText, { size: "$2", children: "Upload Image \u2192 Poster, Ad or Visual" })] }), _jsxs(XStack, { render: "button", onPress: () => onUpload('.pdf,.docx,.pptx,.xlsx,.csv,.json,.txt,.md', 'Turn this document into an executive presentation slide deck and styled PDF report.', 'slides'), items: "center", gap: "$2", px: "$3", height: 34, rounded: 999, borderWidth: 1, borderColor: "$borderColor", cursor: "pointer", hoverStyle: { bg: '$hover' }, children: [_jsx(FileText, { size: 14 }), _jsx(SizableText, { size: "$2", children: "Upload Doc / Data \u2192 Slides & PDF" })] }), _jsxs(XStack, { render: "button", onPress: () => onUpload('video/*,.mp4,.webm,.mov,image/*', 'Create a motion video clip and social ad cut from this media.', 'video'), items: "center", gap: "$2", px: "$3", height: 34, rounded: 999, borderWidth: 1, borderColor: "$borderColor", cursor: "pointer", hoverStyle: { bg: '$hover' }, children: [_jsx(Clapperboard, { size: 14 }), _jsx(SizableText, { size: "$2", children: "Upload Media \u2192 Video & Ad" })] }), _jsxs(XStack, { render: "button", onPress: () => onUpload(undefined, 'Build an interactive creative app around this uploaded file.', 'app'), items: "center", gap: "$2", px: "$3", height: 34, rounded: 999, borderWidth: 1, borderColor: "$borderColor", cursor: "pointer", hoverStyle: { bg: '$hover' }, children: [_jsx(Sparkles, { size: 14 }), _jsx(SizableText, { size: "$2", children: "Upload Any File" })] })] })) : null, _jsx(XStack, { role: "toolbar", "aria-label": "Categories", gap: "$2", flexWrap: "wrap", justify: "center", children: cats.map((c) => (_jsx(Pill, { on: cat === c.id, onPress: () => setCat(c.id), children: c.label }, c.id))) }), _jsx(XStack, { role: "list", "aria-label": "Starters", flexWrap: "wrap", gap: 12, children: shown.map((s, i) => (_jsx(Card, { s: s, i: i, onPress: () => onStart(s) }, s.id))) }), _jsx(Recent, {})] }));
26
26
  }
27
27
  /** A starter's card: 4:5, its picture, or its title set in type; its words under it. */
28
28
  function Card({ s, i, onPress }) {
package/lib/index.d.ts CHANGED
@@ -5,8 +5,14 @@
5
5
  * go)` for a host that draws Studio's places in a rail of its own (the Hanzo
6
6
  * app at hanzo.ai/studio). `host` is @hanzo/build's `Host`, the value Dev
7
7
  * takes, and `host.path` is Studio's address under its mount (`route`).
8
+ * `useRecent(host)` for a host that lists the conversations beside it.
8
9
  */
9
10
  export { Studio } from './studio.tsx';
11
+ export { DirectorStudio, directorNav, parseStudioSection, type StudioSection } from './app/director.tsx';
12
+ export { FlowStudio, flowNav, parseFlowSection, type FlowSection } from './app/flow.tsx';
10
13
  export { nav, NEW, type Group } from './nav.tsx';
11
14
  export { path, route, type Route } from './route.ts';
15
+ export { starters, type Offer } from './starters.ts';
16
+ export { useRecent } from './live.ts';
17
+ export type { Listed } from './chat/store.ts';
12
18
  export type { Host } from '@hanzo/build';
package/lib/index.js CHANGED
@@ -5,7 +5,12 @@
5
5
  * go)` for a host that draws Studio's places in a rail of its own (the Hanzo
6
6
  * app at hanzo.ai/studio). `host` is @hanzo/build's `Host`, the value Dev
7
7
  * takes, and `host.path` is Studio's address under its mount (`route`).
8
+ * `useRecent(host)` for a host that lists the conversations beside it.
8
9
  */
9
10
  export { Studio } from './studio.js';
11
+ export { DirectorStudio, directorNav, parseStudioSection } from './app/director.js';
12
+ export { FlowStudio, flowNav, parseFlowSection } from './app/flow.js';
10
13
  export { nav, NEW } from './nav.js';
11
14
  export { path, route } from './route.js';
15
+ export { starters } from './starters.js';
16
+ export { useRecent } from './live.js';
@@ -0,0 +1,40 @@
1
+ import { type Kind } from './kind.ts';
2
+ import { type TypeSystem } from './type/system.ts';
3
+ export type AppPreset = 'music-app' | 'visualizer' | 'interactive-visual' | 'synth-studio';
4
+ export interface AppSpec {
5
+ preset: AppPreset;
6
+ title: string;
7
+ subtitle: string;
8
+ artist: string;
9
+ prompt: string;
10
+ accent: string;
11
+ secondary: string;
12
+ /** Stored key of the audio file (uploaded MP3/WAV/FLAC or generated track), or ''. */
13
+ audio: string;
14
+ audioName: string;
15
+ /** Stored key of the cover/background image file, or ''. */
16
+ image: string;
17
+ /** Custom tracks / sections or interactive controls JSON. */
18
+ tracks: {
19
+ title: string;
20
+ duration: string;
21
+ bpm: number;
22
+ key: string;
23
+ }[];
24
+ /** Optional custom HTML generated by the writer model. */
25
+ customHtml?: string;
26
+ system: TypeSystem;
27
+ [k: string]: unknown;
28
+ }
29
+ /**
30
+ * Build the self-contained HTML5 application with embedded audio/image data URLs.
31
+ * Supports:
32
+ * - Real uploaded audio playback via HTML5 `<audio>` + WebAudio `AudioContext` + `AnalyserNode`
33
+ * - Built-in procedural WebAudio polyphonic synth + drum engine when no external audio file is playing
34
+ * - 3-Band EQ (Low / Mid / High BiquadFilterNodes)
35
+ * - Playback speed / pitch control (0.5x – 1.5x)
36
+ * - Real-time 60fps Canvas visualizer (4 modes: Spectrum Bars, Radial Orb, Oscilloscope Wave, Particle Nebula)
37
+ * - Interactive waveform scrubber + playlist + downloadable audio/HTML
38
+ */
39
+ export declare function buildAppHtml(s: AppSpec, audioUrl: string, imageUrl: string): string;
40
+ export declare const app: Kind;