@hanzo/build 0.2.99 → 0.2.111
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/api/agents.d.ts +25 -11
- package/lib/api/agents.js +54 -19
- package/lib/api/coding.d.ts +8 -0
- package/lib/api/coding.js +27 -3
- package/lib/api/library.d.ts +6 -2
- package/lib/api/library.js +50 -6
- package/lib/api/sessions.js +16 -1
- package/lib/api/turn.d.ts +2 -0
- package/lib/api/turn.js +12 -0
- package/lib/carry.js +79 -7
- package/lib/customize/agents.d.ts +1 -1
- package/lib/customize/agents.js +78 -13
- package/lib/desk.d.ts +7 -1
- package/lib/desk.js +56 -11
- package/lib/files.js +6 -2
- package/lib/landing.js +38 -34
- package/lib/library.js +36 -8
- package/lib/nav.js +19 -9
- package/lib/panel.js +2 -2
- package/lib/plugins/index.js +1 -1
- package/lib/reply.d.ts +13 -4
- package/lib/reply.js +74 -14
- package/lib/route.d.ts +2 -2
- package/lib/route.js +2 -2
- package/lib/run.js +185 -13
- package/lib/summary.d.ts +11 -1
- package/lib/summary.js +17 -3
- package/lib/transcript.d.ts +12 -1
- package/lib/transcript.js +16 -8
- package/package.json +1 -1
package/lib/library.js
CHANGED
|
@@ -78,13 +78,32 @@ function glyph(kind, n = 18) {
|
|
|
78
78
|
return _jsx(FileText, { size: n });
|
|
79
79
|
}
|
|
80
80
|
}
|
|
81
|
+
/** Known same-origin agent and bot stills shelved by Dev, used if the signed store URL is unreachable. */
|
|
82
|
+
const AGENT_STILLS = new Set(['antje.jpg', 'creative.png', 'des.png', 'dev.png', 'einstein.png', 'feynman.png', 'leo.png', 'maya.png', 'nora.png', 'vi.png', 'zach.jpg']);
|
|
83
|
+
const BOT_STILLS = new Set(['chief.png', 'expense-manager.png', 'inbox-manager.png', 'offsite-crew.png', 'sales-outbound.png', 'talent-scout.png']);
|
|
84
|
+
function localStill(x) {
|
|
85
|
+
const name = x.name.trim().toLowerCase();
|
|
86
|
+
if (AGENT_STILLS.has(name))
|
|
87
|
+
return `/agents/${name}`;
|
|
88
|
+
if (BOT_STILLS.has(name))
|
|
89
|
+
return `/bots/${name}`;
|
|
90
|
+
return '';
|
|
91
|
+
}
|
|
81
92
|
/** The still a tile shows: the item's preview, or an image's own bytes. */
|
|
82
|
-
const still = (x) => x.preview || (x.kind === 'image' && x.mime !== 'image/svg+xml' ? x.url : '');
|
|
93
|
+
const still = (x) => x.preview || (x.kind === 'image' && x.mime !== 'image/svg+xml' ? x.url : '') || localStill(x);
|
|
83
94
|
/** One square: the still, or the kind's mark on a quiet ground. */
|
|
84
95
|
export function Thumb({ x, size: n }) {
|
|
96
|
+
const [fallback, setFallback] = useState(false);
|
|
85
97
|
const [broken, setBroken] = useState(false);
|
|
86
|
-
const
|
|
87
|
-
|
|
98
|
+
const primary = still(x);
|
|
99
|
+
const backup = localStill(x);
|
|
100
|
+
const src = fallback && backup ? backup : primary;
|
|
101
|
+
return (_jsx(YStack, { width: n ?? '100%', height: n, style: n ? undefined : { aspectRatio: '1 / 1' }, rounded: "$3", overflow: "hidden", bg: "$raised", items: "center", justify: "center", shrink: 0, "aria-hidden": true, children: src && !broken ? (_jsx("img", { src: src, alt: "", loading: "lazy", onError: () => {
|
|
102
|
+
if (!fallback && backup && backup !== primary)
|
|
103
|
+
setFallback(true);
|
|
104
|
+
else
|
|
105
|
+
setBroken(true);
|
|
106
|
+
}, style: { width: '100%', height: '100%', objectFit: 'cover', display: 'block' } })) : (_jsx(YStack, { opacity: 0.7, children: glyph(x.kind, n ? Math.max(14, Math.round(n / 2.6)) : 28) })) }));
|
|
88
107
|
}
|
|
89
108
|
/** What a tile says under its name: where it came from, whose, and when. */
|
|
90
109
|
function meta(x, t) {
|
|
@@ -249,11 +268,19 @@ export function Preview({ id, rows }) {
|
|
|
249
268
|
}
|
|
250
269
|
/** The thing itself, drawn the way its kind is read. */
|
|
251
270
|
function Shown({ x }) {
|
|
271
|
+
const [fallback, setFallback] = useState(false);
|
|
252
272
|
const box = { width: '100%', maxHeight: '60vh', borderRadius: 12, display: 'block' };
|
|
253
|
-
|
|
273
|
+
const backup = localStill(x);
|
|
274
|
+
const imgSrc = fallback && backup ? backup : x.url || backup;
|
|
275
|
+
if (!x.url && !backup)
|
|
254
276
|
return _jsx(Thumb, { x: x });
|
|
255
277
|
if (x.kind === 'image' && x.mime !== 'image/svg+xml')
|
|
256
|
-
return _jsx("img", { src:
|
|
278
|
+
return (_jsx("img", { src: imgSrc, alt: x.name, onError: () => {
|
|
279
|
+
if (!fallback && backup && backup !== x.url)
|
|
280
|
+
setFallback(true);
|
|
281
|
+
}, style: { ...box, objectFit: 'contain' } }));
|
|
282
|
+
if (!x.url)
|
|
283
|
+
return _jsx(Thumb, { x: x });
|
|
257
284
|
if (x.kind === 'video')
|
|
258
285
|
return _jsx("video", { src: x.url, poster: x.preview || undefined, controls: true, preload: "metadata", style: box, "aria-label": x.name });
|
|
259
286
|
if (x.kind === 'audio')
|
|
@@ -362,7 +389,8 @@ export function Library() {
|
|
|
362
389
|
const wide = useMedia().md;
|
|
363
390
|
// The kind is the address's (-/artifacts/<kind>), so the sidebar, a link and Back all name it.
|
|
364
391
|
const at = route(host.path);
|
|
365
|
-
const
|
|
392
|
+
const sitesOnly = at.kind === 'screen' && at.of === 'sites';
|
|
393
|
+
const kind = at.kind === 'screen' && at.of && at.of !== 'sites' ? at.of : '';
|
|
366
394
|
const setKind = (k) => host.go(path({ kind: 'screen', screen: 'artifacts', ...(k ? { of: k } : {}) }));
|
|
367
395
|
const [source, setSource] = useState('');
|
|
368
396
|
const [scope, setScope] = useState('all');
|
|
@@ -377,7 +405,7 @@ export function Library() {
|
|
|
377
405
|
const id = setTimeout(() => setQ(typed.trim()), 250);
|
|
378
406
|
return () => clearTimeout(id);
|
|
379
407
|
}, [typed]);
|
|
380
|
-
const load = useMemo(() => (signed ? (cursor, signal) => list(target, { kind, source, scope, q, limit: PAGE, cursor }, { signal }) : null), [signed, target, kind, source, scope, q]);
|
|
408
|
+
const load = useMemo(() => (signed && !sitesOnly ? (cursor, signal) => list(target, { kind, source, scope, q, limit: PAGE, cursor }, { signal }) : null), [signed, sitesOnly, target, kind, source, scope, q]);
|
|
381
409
|
const pages = usePages(load, `${kind}|${source}|${scope}|${q}|${target.org}`);
|
|
382
410
|
const end = useEnd(pages.more);
|
|
383
411
|
const reload = pages.reload;
|
|
@@ -417,7 +445,7 @@ export function Library() {
|
|
|
417
445
|
// The choices in the reader's words; Chat, Dev and Studio stay their names.
|
|
418
446
|
const from = FROM.map((f) => ({ ...f, label: t(f.label) }));
|
|
419
447
|
const whose = WHOSE.map((w) => ({ ...w, label: t(w.label) }));
|
|
420
|
-
return (_jsxs(XStack, { flex: 1, minH: 0, minW: 0, width: "100%", children: [_jsx(YStack, { flex: 1, minH: 0, minW: 0, overflow: "scroll", px: "$6", py: "$6", "$max-md": { px: '$4', py: '$4' }, children: _jsxs(YStack, { width: "100%", maxW: 1120, mx: "auto", gap: "$4", children: [_jsxs(XStack, { items: "center", gap: "$3", children: [_jsx(SizableText, { render: "h1", size: "$7", fontWeight: "600", color: "$ink", flex: 1, children: KINDS.find((k) => k.id === kind)?.id ? t(KINDS.find((k) => k.id === kind).label) : t('Library') }), _jsxs(XStack, { role: "radiogroup", "aria-label": t('View'), gap: "$1", children: [_jsx(ViewMark, { label: t('Grid'), on: view === 'grid', onPress: () => setView('grid'), children: _jsx(LayoutGrid, { size: 16 }) }), _jsx(ViewMark, { label: t('List'), on: view === 'list', onPress: () => setView('list'), children: _jsx(List, { size: 16 }) })] })] }), _jsxs(XStack, { items: "center", gap: "$2", maxW: 480, children: [_jsx(Search, { size: 16, opacity: 0.6 }), _jsx(YStack, { flex: 1, minW: 0, children: _jsx(Input, { value: typed, onChangeText: setTyped, placeholder: t('Search your library'), "aria-label": t('Search your library'), disabled: !signed }) })] }), _jsxs(YStack, { gap: "$2", children: [host.sections ? null : (
|
|
448
|
+
return (_jsxs(XStack, { flex: 1, minH: 0, minW: 0, width: "100%", children: [_jsx(YStack, { flex: 1, minH: 0, minW: 0, overflow: "scroll", px: "$6", py: "$6", "$max-md": { px: '$4', py: '$4' }, children: _jsxs(YStack, { width: "100%", maxW: 1120, mx: "auto", gap: "$4", children: [_jsxs(XStack, { items: "center", gap: "$3", children: [_jsx(SizableText, { render: "h1", size: "$7", fontWeight: "600", color: "$ink", flex: 1, children: sitesOnly ? t('Sites') : KINDS.find((k) => k.id === kind)?.id ? t(KINDS.find((k) => k.id === kind).label) : t('Library') }), sitesOnly ? null : (_jsxs(XStack, { role: "radiogroup", "aria-label": t('View'), gap: "$1", children: [_jsx(ViewMark, { label: t('Grid'), on: view === 'grid', onPress: () => setView('grid'), children: _jsx(LayoutGrid, { size: 16 }) }), _jsx(ViewMark, { label: t('List'), on: view === 'list', onPress: () => setView('list'), children: _jsx(List, { size: 16 }) })] }))] }), sitesOnly ? null : (_jsxs(XStack, { items: "center", gap: "$2", maxW: 480, children: [_jsx(Search, { size: 16, opacity: 0.6 }), _jsx(YStack, { flex: 1, minW: 0, children: _jsx(Input, { value: typed, onChangeText: setTyped, placeholder: t('Search your library'), "aria-label": t('Search your library'), disabled: !signed }) })] })), _jsxs(YStack, { gap: "$2", children: [host.sections ? null : (_jsxs(XStack, { role: "radiogroup", "aria-label": t('Kind'), gap: "$2", overflowX: "auto", pb: "$1", "$platform-web": { scrollbarWidth: 'none' }, children: [KINDS.map((k) => (_jsx(Chip, { label: t(k.label), on: !sitesOnly && kind === k.id, onPress: () => setKind(k.id) }, k.id || 'all'))), _jsx(Chip, { label: t('Sites'), on: sitesOnly, onPress: () => setKind('sites') }, "sites")] })), sitesOnly ? null : (_jsxs(XStack, { gap: "$2", flexWrap: "wrap", rowGap: "$2", children: [_jsx(ChipSelect, { name: t('From'), label: from.find((f) => f.id === source).label, chosen: from.find((f) => f.id === source), items: from, onChange: (f) => setSource(f.id), placement: "bottom-start", width: 200 }), _jsx(ChipSelect, { name: t('Whose'), label: whose.find((w) => w.id === scope).label, chosen: whose.find((w) => w.id === scope), items: whose, onChange: (w) => setScope(w.id), placement: "bottom-start", width: 220 })] }))] }), acts.note ? (_jsx(SizableText, { size: "$2", color: "$soft", role: "status", children: acts.note })) : null, sitesOnly ? (_jsx(Sites, {})) : !signed ? (_jsx(Said, { says: t('Sign in to see your library.'), children: _jsx(Button, { size: "sm", onPress: () => host.signIn?.(), children: t('Sign in') }) })) : pages.error && !pages.rows.length ? (_jsx(Said, { says: told(pages.error, t), children: _jsx(Button, { size: "sm", variant: "outline", onPress: pages.reload, children: t('Try again') }) })) : pages.loading && !pages.rows.length ? (_jsx(Said, { says: t('Reading…') })) : !pages.rows.length ? (_jsx(Said, { says: narrowed ? t('Nothing matches.') : t('Nothing here yet. What you make in Chat, Dev and Studio lands here.') })) : (_jsxs(YStack, { gap: "$5", children: [!q && !kind && (source === '' || source === 'dev') && scope !== 'shared' ? (_jsx(YStack, { pb: "$4", borderBottomWidth: 1, borderColor: "$borderColor", children: _jsx(Sites, {}) })) : null, groups.map((g) => (_jsxs(YStack, { gap: "$3", role: "group", "aria-label": t(g.label), children: [_jsx(SizableText, { size: "$2", color: "$soft", fontWeight: "500", children: t(g.label) }), view === 'grid' ? (_jsx(YStack, { role: "list", "aria-label": made(g.label, t), gap: 16, "$platform-web": { display: 'grid', gridTemplateColumns: 'repeat(auto-fill, minmax(min(46%, 168px), 1fr))' }, children: g.rows.map((x) => (_jsx(Tile, { x: x, onOpen: () => look(x), rows: acts.rows(x) }, x.id))) })) : (_jsx(YStack, { role: "list", "aria-label": made(g.label, t), gap: "$0.5", children: g.rows.map((x) => (_jsx(Row, { x: x, onOpen: () => look(x), rows: acts.rows(x) }, x.id))) }))] }, g.label))), _jsx(YStack, { ref: end, height: 1 }), pages.loading ? (_jsx(SizableText, { size: "$1", color: "$soft", children: t('Reading more…') })) : pages.error ? (_jsx(SizableText, { size: "$1", color: "$soft", role: "status", children: told(pages.error, t) })) : null] })), !sitesOnly && signed && !pages.rows.length && !pages.loading && !q && !kind && (source === '' || source === 'dev') && scope !== 'shared' ? (_jsx(YStack, { pt: "$6", borderTopWidth: 1, borderColor: "$borderColor", children: _jsx(Sites, {}) })) : null] }) }), open && !wide ? panel(true) : null, open && wide ? (_jsx(YStack, { "data-slot": "library-side", ...pane, ml: gap, shrink: 0, minH: 0, width: 440, maxW: "45%", children: panel(false) })) : null, acts.dialogs] }));
|
|
421
449
|
}
|
|
422
450
|
function ViewMark({ label, on, onPress, children }) {
|
|
423
451
|
return (_jsx(XStack, { render: "button", role: "radio", "aria-checked": on, "aria-label": label, onPress: onPress, width: 32, height: 32, items: "center", justify: "center", rounded: "$3", bg: on ? '$hover' : 'transparent', hoverStyle: { bg: '$hover' }, cursor: "pointer", opacity: on ? 1 : 0.6, children: children }));
|
package/lib/nav.js
CHANGED
|
@@ -12,7 +12,7 @@ import { jsx as _jsx } from "react/jsx-runtime";
|
|
|
12
12
|
* The rows' words are the reader's language when the caller hands in its
|
|
13
13
|
* @hanzo/i18n `t` (English without one); a task's name is the person's own.
|
|
14
14
|
*/
|
|
15
|
-
import { AudioLines, Bell, BookOpen, Bot, Box, Brain, CircleDot, Clock, Code, Container, Cpu, CreditCard, File, FileText, FolderGit2, Gauge, Image, Key, LayoutTemplate, Library, Plug, Plus, Presentation, Puzzle, Settings, Shield, SlidersHorizontal, Sparkles, SquarePen, Upload, User, Users, Video } from '@hanzogui/lucide-icons-2';
|
|
15
|
+
import { AudioLines, Bell, BookOpen, Bot, Box, Brain, CircleDot, Clock, Code, Container, Cpu, CreditCard, File, FileText, FolderGit2, Gauge, Globe, Image, Key, LayoutTemplate, Library, Plug, Plus, Presentation, Puzzle, Settings, Shield, SlidersHorizontal, Sparkles, SquarePen, Upload, User, Users, Video } from '@hanzogui/lucide-icons-2';
|
|
16
16
|
import { phrase } from '@hanzo/i18n';
|
|
17
17
|
import { useI18n } from '@hanzo/i18n/react';
|
|
18
18
|
import { useMemo } from 'react';
|
|
@@ -137,6 +137,7 @@ const KIND_ICON = {
|
|
|
137
137
|
model: _jsx(Box, { size: 16 }),
|
|
138
138
|
code: _jsx(Code, { size: 16 }),
|
|
139
139
|
file: _jsx(File, { size: 16 }),
|
|
140
|
+
sites: _jsx(Globe, { size: 16 }),
|
|
140
141
|
};
|
|
141
142
|
/** Fired on `window` once the sidebar's Upload has kept its files, for the Library to read again. */
|
|
142
143
|
export const KEPT = 'hanzo:library:kept';
|
|
@@ -149,7 +150,7 @@ function keep(host, say) {
|
|
|
149
150
|
const t = { api: host.api, token: host.token, org: host.org };
|
|
150
151
|
for (const f of Array.from(input.files ?? [])) {
|
|
151
152
|
try {
|
|
152
|
-
await upload(t, { name: f.name, type: f.type,
|
|
153
|
+
await upload(t, { name: f.name, type: f.type, blob: f }, { source: 'chat' });
|
|
153
154
|
}
|
|
154
155
|
catch (e) {
|
|
155
156
|
window.alert(e instanceof Error ? e.message : say('{file} was not kept', { file: f.name }));
|
|
@@ -168,13 +169,22 @@ export function library(host, go, t = english) {
|
|
|
168
169
|
{
|
|
169
170
|
id: 'library-kinds',
|
|
170
171
|
label: '',
|
|
171
|
-
links:
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
172
|
+
links: [
|
|
173
|
+
...KINDS.map((k) => ({
|
|
174
|
+
id: `kind-${k.id || 'all'}`,
|
|
175
|
+
label: t(k.label),
|
|
176
|
+
icon: KIND_ICON[k.id],
|
|
177
|
+
onPress: () => go(path({ kind: 'screen', screen: 'artifacts', ...(k.id ? { of: k.id } : {}) })),
|
|
178
|
+
active: at === k.id,
|
|
179
|
+
})),
|
|
180
|
+
{
|
|
181
|
+
id: 'kind-sites',
|
|
182
|
+
label: t('Sites'),
|
|
183
|
+
icon: KIND_ICON.sites,
|
|
184
|
+
onPress: () => go(path({ kind: 'screen', screen: 'artifacts', of: 'sites' })),
|
|
185
|
+
active: at === 'sites',
|
|
186
|
+
},
|
|
187
|
+
],
|
|
178
188
|
},
|
|
179
189
|
];
|
|
180
190
|
}
|
package/lib/panel.js
CHANGED
|
@@ -25,7 +25,7 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
25
25
|
import { SizableText, XStack, YStack } from '@hanzo/gui';
|
|
26
26
|
import { phrase } from '@hanzo/i18n';
|
|
27
27
|
import { useI18n } from '@hanzo/i18n/react';
|
|
28
|
-
import { ArrowLeft, ArrowRight, ChevronRight, Columns2, ExternalLink, Globe, Maximize2, Minimize2, Minus, MoreHorizontal, PanelLeftOpen, Pin, Plus, RotateCcw, RotateCw,
|
|
28
|
+
import { ArrowLeft, ArrowRight, ChevronRight, Columns2, ExternalLink, Globe, Maximize2, Minimize2, Minus, MoreHorizontal, PanelLeftOpen, Pin, Plus, RotateCcw, RotateCw, X } from '@hanzogui/lucide-icons-2';
|
|
29
29
|
import { ContextMenu, ContextMenuContent, ContextMenuItem, ContextMenuSeparator, ContextMenuTrigger, DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuSeparator, DropdownMenuSub, DropdownMenuSubContent, DropdownMenuSubTrigger, DropdownMenuTrigger, } from '@hanzo/ui';
|
|
30
30
|
import { useEffect, useMemo, useRef, useState } from 'react';
|
|
31
31
|
import { createPortal } from 'react-dom';
|
|
@@ -68,7 +68,7 @@ export function PanelToggle({ open, onToggle }) {
|
|
|
68
68
|
const { t } = useI18n();
|
|
69
69
|
if (open)
|
|
70
70
|
return null;
|
|
71
|
-
return (_jsx(XStack, { render: "button", role: "button", "data-slot": "side-toggle", "aria-label": t('Show tabs'), "aria-expanded": false, "aria-keyshortcuts": SHORTCUTS, ...{ title: t('Show tabs ({keys})', { keys: KEYS }) }, onPress: onToggle, width: 32, height: 32, ...quiet(), children: _jsx(
|
|
71
|
+
return (_jsx(XStack, { render: "button", role: "button", "data-slot": "side-toggle", "aria-label": t('Show tabs'), "aria-expanded": false, "aria-keyshortcuts": SHORTCUTS, ...{ title: t('Show tabs ({keys})', { keys: KEYS }) }, onPress: onToggle, width: 32, height: 32, ...quiet(), children: _jsx(Plus, { size: 16 }) }));
|
|
72
72
|
}
|
|
73
73
|
/** Our own hosts: a page of theirs answers a frame on any of our pages. */
|
|
74
74
|
const OURS = ['hanzo.ai', 'hanzo.app', 'hanzo.bot'];
|
package/lib/plugins/index.js
CHANGED
|
@@ -20,7 +20,7 @@ const seen = new Map();
|
|
|
20
20
|
/** What runs for this person, in the menu's order. */
|
|
21
21
|
export async function probe(t) {
|
|
22
22
|
if (!t.token())
|
|
23
|
-
return [sketch];
|
|
23
|
+
return [deep, sketch];
|
|
24
24
|
const [built, studio] = await Promise.allSettled([projects(t), templates(t)]);
|
|
25
25
|
if (built.status === 'rejected' && studio.status === 'rejected')
|
|
26
26
|
throw built.reason;
|
package/lib/reply.d.ts
CHANGED
|
@@ -8,6 +8,10 @@ export interface Artifact {
|
|
|
8
8
|
/** What a browser should take it as. */
|
|
9
9
|
mime: string;
|
|
10
10
|
}
|
|
11
|
+
export interface RedoAction {
|
|
12
|
+
mode: 'retry' | 'think' | 'web' | 'prompt';
|
|
13
|
+
prompt?: string;
|
|
14
|
+
}
|
|
11
15
|
/** Every fenced block in `text`, in order. */
|
|
12
16
|
export declare function artifacts(text: string): Artifact[];
|
|
13
17
|
/** Whether a browser draws it as a page or a picture rather than as source. */
|
|
@@ -22,15 +26,20 @@ export declare function speakable(raw: string): string;
|
|
|
22
26
|
export type Listen = (text: string, done: () => void) => () => void;
|
|
23
27
|
/** A reader on the platform's voice (`/v1/audio/speech`), one reply at a time on the page. */
|
|
24
28
|
export declare function speaker(t: Target): Listen;
|
|
25
|
-
/** Copy, Listen and Open under an answer; `children` follow them. */
|
|
26
|
-
export declare function Reply({ text, listen, onOpen, children }: {
|
|
29
|
+
/** Copy, Rate/Vote, Listen, Share, Redo, Branch and Open under an answer; `children` follow them. */
|
|
30
|
+
export declare function Reply({ text, title, listen, onOpen, onRedo, onBranch, onRate, timestamp, children, }: {
|
|
27
31
|
text: string;
|
|
32
|
+
title?: string;
|
|
28
33
|
listen?: Listen;
|
|
29
34
|
onOpen?: () => void;
|
|
35
|
+
onRedo?: (action: RedoAction) => void;
|
|
36
|
+
onBranch?: () => void;
|
|
37
|
+
onRate?: (vote: 'up' | 'down') => void;
|
|
38
|
+
timestamp?: string;
|
|
30
39
|
children?: ReactNode;
|
|
31
40
|
}): import("react").JSX.Element;
|
|
32
41
|
/** Which model answered, where the gateway says it was not the one asked for or a router. */
|
|
33
|
-
export declare function Served(
|
|
42
|
+
export declare function Served(_props: {
|
|
34
43
|
served: string;
|
|
35
44
|
asked?: string;
|
|
36
|
-
}):
|
|
45
|
+
}): null;
|
package/lib/reply.js
CHANGED
|
@@ -1,18 +1,19 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
/**
|
|
3
3
|
* What sits under an answer, the same in Chat and Dev: copy what was written,
|
|
4
|
-
* listen to it,
|
|
5
|
-
*
|
|
4
|
+
* rate/vote, listen to it, share it, regenerate/redo it, branch in a new chat,
|
|
5
|
+
* and open what it made in the side panel. A surface adds its own after these.
|
|
6
6
|
*
|
|
7
7
|
* An answer's artifacts are its fenced blocks (`artifacts`): a page, a picture,
|
|
8
8
|
* a file it wrote out whole. One opens as a page tab in the side panel, rendered
|
|
9
9
|
* from its own bytes (`blob`).
|
|
10
10
|
*/
|
|
11
|
-
import { SizableText, XStack } from '@hanzo/gui';
|
|
11
|
+
import { SizableText, XStack, YStack } from '@hanzo/gui';
|
|
12
12
|
import { useI18n } from '@hanzo/i18n/react';
|
|
13
|
-
import {
|
|
13
|
+
import { Dialog, DialogContent, DialogTitle, DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuSeparator, DropdownMenuTrigger, Input, } from '@hanzo/ui';
|
|
14
|
+
import { ArrowUp, Check, Copy, Globe, Lightbulb, Link2, PanelRight, RefreshCw, Share, Square, ThumbsDown, ThumbsUp, Volume2, } from '@hanzogui/lucide-icons-2';
|
|
14
15
|
import { mouth, speech } from '@hanzo/voice';
|
|
15
|
-
import { useEffect, useRef, useState } from 'react';
|
|
16
|
+
import { useEffect, useMemo, useRef, useState } from 'react';
|
|
16
17
|
const FENCE = /```([^\n`]*)\n([\s\S]*?)```/g;
|
|
17
18
|
const MIME = {
|
|
18
19
|
html: 'text/html',
|
|
@@ -93,23 +94,66 @@ export function speaker(t) {
|
|
|
93
94
|
};
|
|
94
95
|
}
|
|
95
96
|
/** One quiet control in the row. It rests dim and comes up under a pointer or focus. */
|
|
96
|
-
function Act({ label, onPress, children, lit = false }) {
|
|
97
|
-
return (_jsx(XStack, { render: "button", role: "button", "aria-label": label, onPress: onPress, items: "center", gap: "$1", px: "$1", height:
|
|
97
|
+
function Act({ label, onPress, children, lit = false, slot, }) {
|
|
98
|
+
return (_jsx(XStack, { render: "button", role: "button", "aria-label": label, "data-slot": slot, onPress: onPress, items: "center", justify: "center", gap: "$1", px: "$1.5", height: 28, minW: 28, rounded: "$2", cursor: "pointer", bg: lit ? '$hover' : 'transparent', opacity: lit ? 1 : 0.65, hoverStyle: { opacity: 1, bg: '$hover' }, focusStyle: { opacity: 1 }, children: children }));
|
|
98
99
|
}
|
|
99
|
-
/** Copy, Listen and Open under an answer; `children` follow them. */
|
|
100
|
-
export function Reply({ text, listen, onOpen, children }) {
|
|
100
|
+
/** Copy, Rate/Vote, Listen, Share, Redo, Branch and Open under an answer; `children` follow them. */
|
|
101
|
+
export function Reply({ text, title, listen, onOpen, onRedo, onBranch, onRate, timestamp, children, }) {
|
|
101
102
|
const { t: say } = useI18n();
|
|
102
103
|
const [took, setTook] = useState(false);
|
|
103
104
|
const [speaking, setSpeaking] = useState(false);
|
|
105
|
+
const [vote, setVote] = useState(null);
|
|
106
|
+
const [redoOpen, setRedoOpen] = useState(false);
|
|
107
|
+
const [shareOpen, setShareOpen] = useState(false);
|
|
108
|
+
const [shareCopied, setShareCopied] = useState(false);
|
|
109
|
+
const [redoPrompt, setRedoPrompt] = useState('');
|
|
104
110
|
const stop = useRef(null);
|
|
111
|
+
const stamp = useMemo(() => {
|
|
112
|
+
if (timestamp)
|
|
113
|
+
return timestamp;
|
|
114
|
+
try {
|
|
115
|
+
return new Intl.DateTimeFormat(undefined, {
|
|
116
|
+
month: 'short',
|
|
117
|
+
day: 'numeric',
|
|
118
|
+
year: 'numeric',
|
|
119
|
+
hour: 'numeric',
|
|
120
|
+
minute: '2-digit',
|
|
121
|
+
}).format(new Date());
|
|
122
|
+
}
|
|
123
|
+
catch {
|
|
124
|
+
return 'Just now';
|
|
125
|
+
}
|
|
126
|
+
}, [timestamp]);
|
|
105
127
|
useEffect(() => {
|
|
106
128
|
if (!took)
|
|
107
129
|
return;
|
|
108
130
|
const t = setTimeout(() => setTook(false), 1400);
|
|
109
131
|
return () => clearTimeout(t);
|
|
110
132
|
}, [took]);
|
|
133
|
+
useEffect(() => {
|
|
134
|
+
if (!shareCopied)
|
|
135
|
+
return;
|
|
136
|
+
const t = setTimeout(() => setShareCopied(false), 1600);
|
|
137
|
+
return () => clearTimeout(t);
|
|
138
|
+
}, [shareCopied]);
|
|
111
139
|
useEffect(() => () => stop.current?.(), []);
|
|
112
|
-
|
|
140
|
+
const shareUrl = useMemo(() => {
|
|
141
|
+
if (typeof window === 'undefined')
|
|
142
|
+
return 'https://hanzo.ai/chat';
|
|
143
|
+
return window.location.href;
|
|
144
|
+
}, [shareOpen]);
|
|
145
|
+
const triggerRedo = (payload) => {
|
|
146
|
+
setRedoOpen(false);
|
|
147
|
+
setRedoPrompt('');
|
|
148
|
+
onRedo?.(payload);
|
|
149
|
+
};
|
|
150
|
+
return (_jsxs(XStack, { "data-slot": "reply", ml: "$-1", items: "center", gap: "$1", flexWrap: "wrap", children: [_jsx(Act, { slot: "reply-copy", label: took ? say('Copied') : say('Copy this answer'), lit: took, onPress: () => void navigator.clipboard?.writeText(text).then(() => setTook(true), () => { }), children: took ? _jsx(Check, { size: 15 }) : _jsx(Copy, { size: 15 }) }), _jsxs(DropdownMenu, { children: [_jsx(DropdownMenuTrigger, { asChild: true, children: _jsx(Act, { slot: "reply-rate", label: say('Rate this response'), lit: vote !== null, children: vote === 'down' ? _jsx(ThumbsDown, { size: 15 }) : _jsx(ThumbsUp, { size: 15 }) }) }), _jsxs(DropdownMenuContent, { align: "start", minW: 176, "data-slot": "reply-rate-menu", children: [_jsx(DropdownMenuItem, { "data-slot": "reply-rate-up", onSelect: () => {
|
|
151
|
+
setVote('up');
|
|
152
|
+
onRate?.('up');
|
|
153
|
+
}, children: _jsxs(XStack, { items: "center", gap: "$2", children: [_jsx(ThumbsUp, { size: 15 }), _jsx(SizableText, { size: "$2", color: "$ink", children: say('Good response') })] }) }), _jsx(DropdownMenuItem, { "data-slot": "reply-rate-down", onSelect: () => {
|
|
154
|
+
setVote('down');
|
|
155
|
+
onRate?.('down');
|
|
156
|
+
}, children: _jsxs(XStack, { items: "center", gap: "$2", children: [_jsx(ThumbsDown, { size: 15 }), _jsx(SizableText, { size: "$2", color: "$ink", children: say('Bad response') })] }) })] })] }), listen ? (_jsx(Act, { slot: "reply-listen", label: speaking ? say('Stop reading') : say('Listen to this answer'), lit: speaking, onPress: () => {
|
|
113
157
|
if (speaking) {
|
|
114
158
|
stop.current?.();
|
|
115
159
|
setSpeaking(false);
|
|
@@ -117,10 +161,26 @@ export function Reply({ text, listen, onOpen, children }) {
|
|
|
117
161
|
}
|
|
118
162
|
setSpeaking(true);
|
|
119
163
|
stop.current = listen(text, () => setSpeaking(false));
|
|
120
|
-
}, children:
|
|
164
|
+
}, children: speaking ? _jsx(Square, { size: 14 }) : _jsx(Volume2, { size: 15 }) })) : null, _jsx(Act, { slot: "reply-share", label: say('Share message'), lit: shareOpen, onPress: () => setShareOpen(true), children: _jsx(Share, { size: 15 }) }), _jsxs(DropdownMenu, { open: redoOpen, onOpenChange: setRedoOpen, children: [_jsx(DropdownMenuTrigger, { asChild: true, children: _jsx(Act, { slot: "reply-redo", label: say('Regenerate response'), lit: redoOpen, children: _jsx(RefreshCw, { size: 15 }) }) }), _jsxs(DropdownMenuContent, { align: "start", minW: 232, "data-slot": "reply-redo-menu", children: [_jsxs(XStack, { items: "center", gap: "$1.5", px: "$2", py: "$1.5", children: [_jsx(Input, { "data-slot": "reply-redo-input", placeholder: say('Ask to change response'), value: redoPrompt, onChangeText: setRedoPrompt, onKeyDown: (e) => {
|
|
165
|
+
e.stopPropagation?.();
|
|
166
|
+
if (e.key === 'Enter' && redoPrompt.trim()) {
|
|
167
|
+
e.preventDefault?.();
|
|
168
|
+
triggerRedo({ mode: 'prompt', prompt: redoPrompt.trim() });
|
|
169
|
+
}
|
|
170
|
+
}, flex: 1, size: "sm" }), _jsx(Act, { label: say('Submit change'), lit: Boolean(redoPrompt.trim()), onPress: () => {
|
|
171
|
+
if (redoPrompt.trim()) {
|
|
172
|
+
triggerRedo({ mode: 'prompt', prompt: redoPrompt.trim() });
|
|
173
|
+
}
|
|
174
|
+
}, children: _jsx(ArrowUp, { size: 14 }) })] }), _jsx(DropdownMenuSeparator, {}), _jsx(DropdownMenuItem, { "data-slot": "redo-retry", onSelect: () => triggerRedo({ mode: 'retry' }), children: _jsxs(XStack, { items: "center", gap: "$2", children: [_jsx(RefreshCw, { size: 15 }), _jsx(SizableText, { size: "$2", color: "$ink", children: say('Try again') }), _jsx(SizableText, { size: "$2", color: "$hint", children: "\u00B7 Auto" })] }) }), _jsx(DropdownMenuItem, { "data-slot": "redo-think", onSelect: () => triggerRedo({ mode: 'think' }), children: _jsxs(XStack, { items: "center", gap: "$2", children: [_jsx(Lightbulb, { size: 15 }), _jsx(SizableText, { size: "$2", color: "$ink", children: say('Think longer') })] }) }), _jsx(DropdownMenuItem, { "data-slot": "redo-web", onSelect: () => triggerRedo({ mode: 'web' }), children: _jsxs(XStack, { items: "center", gap: "$2", children: [_jsx(Globe, { size: 15 }), _jsx(SizableText, { size: "$2", color: "$ink", children: say('Search the web') })] }) })] })] }), onOpen ? (_jsxs(Act, { slot: "reply-open", label: say('Open in the side panel'), onPress: onOpen, children: [_jsx(PanelRight, { size: 14 }), _jsx(SizableText, { size: "$1", color: "$ink", children: say('Open') })] })) : null, children, _jsx(Dialog, { open: shareOpen, onOpenChange: setShareOpen, children: _jsxs(DialogContent, { maxW: 540, width: "100%", gap: "$3.5", "data-slot": "reply-share-modal", children: [_jsx(DialogTitle, { children: title || say('Conversation') }), _jsx(YStack, { p: "$3.5", rounded: "$4", bg: "$panel", borderWidth: 1, borderColor: "$borderColor", maxH: 220, overflow: "scroll", children: _jsx(SizableText, { size: "$2", color: "$ink", lineHeight: "$4", children: text }) }), _jsxs(XStack, { items: "flex-start", gap: "$2.5", children: [_jsx(Globe, { size: 16 }), _jsxs(YStack, { gap: "$0.5", flex: 1, children: [_jsx(SizableText, { size: "$2", fontWeight: "600", color: "$ink", children: say('Share a public link to this message') }), _jsx(SizableText, { size: "$1", color: "$soft", children: say('Anyone with this link can access this message.') })] })] }), _jsxs(XStack, { items: "center", justify: "center", gap: "$5", pt: "$1", children: [_jsxs(YStack, { render: "button", role: "button", "data-slot": "share-copy-link", items: "center", gap: "$1.5", cursor: "pointer", onPress: () => void navigator.clipboard?.writeText(shareUrl).then(() => setShareCopied(true), () => { }), children: [_jsx(XStack, { width: 44, height: 44, rounded: 999, bg: "$hover", items: "center", justify: "center", children: shareCopied ? _jsx(Check, { size: 17 }) : _jsx(Link2, { size: 17 }) }), _jsx(SizableText, { size: "$1", color: "$soft", children: shareCopied ? say('Copied!') : say('Copy link') })] }), _jsxs(YStack, { render: "button", role: "button", "data-slot": "share-x", items: "center", gap: "$1.5", cursor: "pointer", onPress: () => {
|
|
175
|
+
const snippet = text.length > 200 ? `${text.slice(0, 197)}...` : text;
|
|
176
|
+
window.open(`https://x.com/intent/tweet?text=${encodeURIComponent(snippet)}&url=${encodeURIComponent(shareUrl)}`, '_blank', 'noopener,noreferrer');
|
|
177
|
+
}, children: [_jsx(XStack, { width: 44, height: 44, rounded: 999, bg: "$hover", items: "center", justify: "center", children: _jsx(SizableText, { size: "$3", fontWeight: "700", color: "$ink", children: "\uD835\uDD4F" }) }), _jsx(SizableText, { size: "$1", color: "$soft", children: "X" })] }), _jsxs(YStack, { render: "button", role: "button", "data-slot": "share-linkedin", items: "center", gap: "$1.5", cursor: "pointer", onPress: () => {
|
|
178
|
+
window.open(`https://www.linkedin.com/sharing/share-offsite/?url=${encodeURIComponent(shareUrl)}`, '_blank', 'noopener,noreferrer');
|
|
179
|
+
}, children: [_jsx(XStack, { width: 44, height: 44, rounded: 999, bg: "$hover", items: "center", justify: "center", children: _jsx(SizableText, { size: "$3", fontWeight: "700", color: "$ink", children: "in" }) }), _jsx(SizableText, { size: "$1", color: "$soft", children: "LinkedIn" })] }), _jsxs(YStack, { render: "button", role: "button", "data-slot": "share-reddit", items: "center", gap: "$1.5", cursor: "pointer", onPress: () => {
|
|
180
|
+
window.open(`https://www.reddit.com/submit?url=${encodeURIComponent(shareUrl)}&title=${encodeURIComponent(title || 'Hanzo Chat')}`, '_blank', 'noopener,noreferrer');
|
|
181
|
+
}, children: [_jsx(XStack, { width: 44, height: 44, rounded: 999, bg: "$hover", items: "center", justify: "center", children: _jsx(SizableText, { size: "$3", fontWeight: "700", color: "$ink", children: "r/" }) }), _jsx(SizableText, { size: "$1", color: "$soft", children: "Reddit" })] })] })] }) })] }));
|
|
121
182
|
}
|
|
122
183
|
/** Which model answered, where the gateway says it was not the one asked for or a router. */
|
|
123
|
-
export function Served(
|
|
124
|
-
|
|
125
|
-
return (_jsx(SizableText, { size: "$1", color: "$soft", "data-slot": "served", children: asked && asked !== served ? t('answered by {model} · {asked} was unavailable', { model: served, asked }) : t('answered by {model}', { model: served }) }));
|
|
184
|
+
export function Served(_props) {
|
|
185
|
+
return null;
|
|
126
186
|
}
|
package/lib/route.d.ts
CHANGED
|
@@ -64,8 +64,8 @@ export type Route = {
|
|
|
64
64
|
kind: 'automation';
|
|
65
65
|
id: string;
|
|
66
66
|
};
|
|
67
|
-
/** The kinds the Library narrows to by address (api/library.ts KIND_IDS). */
|
|
68
|
-
export declare const OF: readonly ['image', 'video', 'audio', 'document', 'slides', 'type', 'model', 'code', 'file'];
|
|
67
|
+
/** The kinds the Library narrows to by address (api/library.ts KIND_IDS, plus `sites`). */
|
|
68
|
+
export declare const OF: readonly ['image', 'video', 'audio', 'document', 'slides', 'type', 'model', 'code', 'file', 'sites'];
|
|
69
69
|
export type Of = (typeof OF)[number];
|
|
70
70
|
export declare const SESSION: RegExp;
|
|
71
71
|
export declare const SLUG: RegExp;
|
package/lib/route.js
CHANGED
|
@@ -17,8 +17,8 @@ export const SECTIONS = [
|
|
|
17
17
|
];
|
|
18
18
|
/** Customize, one tab each: what the agent brings to a run, yours and to discover. Agents first. */
|
|
19
19
|
export const TABS = ['agents', 'skills', 'connectors', 'plugins'];
|
|
20
|
-
/** The kinds the Library narrows to by address (api/library.ts KIND_IDS). */
|
|
21
|
-
export const OF = ['image', 'video', 'audio', 'document', 'slides', 'type', 'model', 'code', 'file'];
|
|
20
|
+
/** The kinds the Library narrows to by address (api/library.ts KIND_IDS, plus `sites`). */
|
|
21
|
+
export const OF = ['image', 'video', 'audio', 'document', 'slides', 'type', 'model', 'code', 'file', 'sites'];
|
|
22
22
|
export const SESSION = /^sess_[0-9a-f]{32}$/;
|
|
23
23
|
export const SLUG = /^[a-z0-9]([a-z0-9-]{0,38}[a-z0-9])?$/;
|
|
24
24
|
/** An organization or a repository name on the forge (api/codebases.ts `NAME`). */
|