@hanzo/build 0.2.117 → 0.2.119
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/README.md +25 -4
- package/lib/api/agents.d.ts +4 -2
- package/lib/api/agents.js +5 -3
- package/lib/api/chat.d.ts +1 -1
- package/lib/api/chat.js +2 -2
- package/lib/api/draft.d.ts +33 -0
- package/lib/api/draft.js +81 -0
- package/lib/api/gallery.d.ts +32 -0
- package/lib/api/gallery.js +85 -0
- package/lib/api/github.d.ts +12 -1
- package/lib/api/github.js +27 -2
- package/lib/customize/agents.js +35 -8
- package/lib/customize/drafted.d.ts +4 -0
- package/lib/customize/drafted.js +79 -0
- package/lib/customize/inventory.d.ts +11 -0
- package/lib/customize/inventory.js +78 -0
- package/lib/customize/ocean.d.ts +41 -0
- package/lib/customize/ocean.js +332 -0
- package/lib/customize/ui.d.ts +9 -2
- package/lib/customize/ui.js +33 -4
- package/lib/host.d.ts +7 -0
- package/lib/index.d.ts +2 -0
- package/lib/index.js +2 -0
- package/lib/landing.js +1 -1
- package/lib/library.js +7 -7
- package/lib/make.d.ts +10 -0
- package/lib/make.js +113 -0
- package/lib/marks.d.ts +15 -0
- package/lib/marks.js +18 -0
- package/lib/mind.d.ts +29 -3
- package/lib/mind.js +73 -6
- package/lib/nav.d.ts +1 -1
- package/lib/nav.js +16 -8
- package/lib/route.d.ts +3 -2
- package/lib/route.js +2 -2
- package/lib/sync.js +8 -4
- package/package.json +5 -5
package/lib/index.d.ts
CHANGED
|
@@ -26,6 +26,8 @@ export { SOURCE, type Item, type Kind as ItemKind, type Source } from './api/lib
|
|
|
26
26
|
export { Scheduled, schedule } from './scheduled.tsx';
|
|
27
27
|
export { Editor } from './automations.tsx';
|
|
28
28
|
export { library, nav, NEW, own, sections, tabs, useScheduled, type Group } from './nav.tsx';
|
|
29
|
+
export { MARKS, type Icon, type Mark } from './marks.tsx';
|
|
30
|
+
export { useFunds, type Funds } from './mind.ts';
|
|
29
31
|
export { DevSection, DOTS, useSessions } from './section.tsx';
|
|
30
32
|
export { HostProvider } from './host.tsx';
|
|
31
33
|
export { Slack, useWho, Who } from './foot.tsx';
|
package/lib/index.js
CHANGED
|
@@ -26,6 +26,8 @@ export { SOURCE } from './api/library.js';
|
|
|
26
26
|
export { Scheduled, schedule } from './scheduled.js';
|
|
27
27
|
export { Editor } from './automations.js';
|
|
28
28
|
export { library, nav, NEW, own, sections, tabs, useScheduled } from './nav.js';
|
|
29
|
+
export { MARKS } from './marks.js';
|
|
30
|
+
export { useFunds } from './mind.js';
|
|
29
31
|
export { DevSection, DOTS, useSessions } from './section.js';
|
|
30
32
|
export { HostProvider } from './host.js';
|
|
31
33
|
export { Slack, useWho, Who } from './foot.js';
|
package/lib/landing.js
CHANGED
|
@@ -133,7 +133,7 @@ export function Landing({ onStarted }) {
|
|
|
133
133
|
const places = usePlaces(target, signed);
|
|
134
134
|
// The model and effort Chat shares, and dictation into the ask.
|
|
135
135
|
const { limits } = useLimits(signed ? (signal) => readLimits(target, signal) : null, target);
|
|
136
|
-
const mind = useMind(target, limits?.plan);
|
|
136
|
+
const mind = useMind(target, limits?.plan, host.topUp);
|
|
137
137
|
const voice = useVoice({ speech: useEar(target), language: useSpoken(), ...useDictation(draft, setDraft) });
|
|
138
138
|
const talk = useTalk({ baseUrl: target.api, token: () => target.token(), ...(target.org ? { org: target.org } : {}) });
|
|
139
139
|
// What the run carries beside the ask: skills, memory and the mode, as Chat's turns do.
|
package/lib/library.js
CHANGED
|
@@ -4,6 +4,7 @@ import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-run
|
|
|
4
4
|
* workflows — in one place, newest first (api/library.ts).
|
|
5
5
|
*
|
|
6
6
|
* -/artifacts the Library; `?item=<id>` opens one item's preview
|
|
7
|
+
* -/artifacts/new the Library under Make something new (make.tsx)
|
|
7
8
|
*
|
|
8
9
|
* A tile opens its item in the side panel (panel.tsx), one tab per item, so a
|
|
9
10
|
* few can be read side by side; on a phone the panel is a sheet. Each item
|
|
@@ -16,7 +17,7 @@ import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-run
|
|
|
16
17
|
* colleague's, a project's and what an item holds are drawn as given.
|
|
17
18
|
*/
|
|
18
19
|
import { SizableText, useMedia, XStack, YStack } from '@hanzo/gui';
|
|
19
|
-
import { AudioLines, Box, Code2, Copy, Download, ExternalLink, FileText, FolderInput, Image as Picture, LayoutGrid, List, MessageSquare, MoreHorizontal, Pencil, Presentation, Search, Share2, Sparkles, Trash2, Type, Video, } from '@hanzogui/lucide-icons-2';
|
|
20
|
+
import { AudioLines, Box, Code2, Copy, Download, ExternalLink, FileText, FolderInput, Image as Picture, LayoutGrid, List, MessageSquare, MoreHorizontal, Pencil, Plus, Presentation, Search, Share2, Sparkles, Trash2, Type, Video, } from '@hanzogui/lucide-icons-2';
|
|
20
21
|
import { phrase } from '@hanzo/i18n';
|
|
21
22
|
import { useI18n } from '@hanzo/i18n/react';
|
|
22
23
|
import { Button, Dialog, DialogContent, DialogTitle, DropdownMenu, Input } from '@hanzo/ui';
|
|
@@ -28,6 +29,7 @@ import { change, days, get, items as list, KINDS, remove, size, SOURCE } from '.
|
|
|
28
29
|
import { Confirm, Rename } from './ask.js';
|
|
29
30
|
import { useKept, useProjects, useRead } from './data.js';
|
|
30
31
|
import { useHost, useTarget } from './host.js';
|
|
32
|
+
import { Chip, Make } from './make.js';
|
|
31
33
|
import { KEPT } from './nav.js';
|
|
32
34
|
import { path, route } from './route.js';
|
|
33
35
|
import { Panel } from './panel.js';
|
|
@@ -250,10 +252,6 @@ function Row({ x, onOpen, rows }) {
|
|
|
250
252
|
const { t } = useI18n();
|
|
251
253
|
return (_jsxs(XStack, { role: "listitem", items: "center", gap: "$3", px: "$2", py: "$2", rounded: "$3", hoverStyle: { bg: '$hover' }, minW: 0, children: [_jsxs(XStack, { render: "button", "aria-label": t('Open {name}', { name: x.name }), onPress: onOpen, flex: 1, minW: 0, items: "center", gap: "$3", cursor: "pointer", "$platform-web": { textAlign: 'start' }, children: [_jsx(Thumb, { x: x, size: 40 }), _jsxs(YStack, { flex: 1, minW: 0, gap: "$0.5", children: [_jsx(SizableText, { size: "$2", color: "$ink", numberOfLines: 1, children: x.name }), _jsx(SizableText, { size: "$1", color: "$soft", numberOfLines: 1, children: meta(x, t) })] }), _jsx(SizableText, { size: "$1", color: "$soft", width: 72, text: "end", "$max-md": { display: 'none' }, children: size(x.bytes) })] }), _jsx(Acts, { x: x, rows: rows })] }));
|
|
252
254
|
}
|
|
253
|
-
/** A chip: one choice among a few, lit when chosen. */
|
|
254
|
-
function Chip({ label, on, onPress }) {
|
|
255
|
-
return (_jsx(XStack, { render: "button", role: "radio", "aria-checked": on, "aria-label": label, onPress: onPress, height: 32, px: "$3", items: "center", rounded: "$10", shrink: 0, borderWidth: 1, borderColor: on ? '$ink' : '$borderColor', bg: on ? '$ink' : 'transparent', hoverStyle: { bg: on ? '$ink' : '$hover' }, cursor: "pointer", focusVisibleStyle: { outlineWidth: 2, outlineStyle: 'solid', outlineColor: '$outlineColor' }, children: _jsx(SizableText, { size: "$2", color: on ? '$background' : '$ink', children: label }) }));
|
|
256
|
-
}
|
|
257
255
|
/** One item, read fresh so its signed URLs are live: the thing itself, then what it is. */
|
|
258
256
|
export function Preview({ id, rows }) {
|
|
259
257
|
const { t } = useI18n();
|
|
@@ -392,8 +390,10 @@ export function Library() {
|
|
|
392
390
|
// The kind is the address's (-/artifacts/<kind>), so the sidebar, a link and Back all name it.
|
|
393
391
|
const at = route(host.path);
|
|
394
392
|
const sitesOnly = at.kind === 'screen' && at.of === 'sites';
|
|
395
|
-
const
|
|
393
|
+
const making = at.kind === 'screen' && at.of === 'new';
|
|
394
|
+
const kind = at.kind === 'screen' && at.of && at.of !== 'sites' && at.of !== 'new' ? at.of : '';
|
|
396
395
|
const setKind = (k) => host.go(path({ kind: 'screen', screen: 'artifacts', ...(k ? { of: k } : {}) }));
|
|
396
|
+
const make = (_jsxs(Button, { size: "sm", onPress: () => setKind('new'), children: [_jsx(Plus, { size: 14 }), t('Make something new')] }));
|
|
397
397
|
const [source, setSource] = useState('');
|
|
398
398
|
const [scope, setScope] = useState('all');
|
|
399
399
|
const [typed, setTyped] = useState('');
|
|
@@ -447,7 +447,7 @@ export function Library() {
|
|
|
447
447
|
// The choices in the reader's words; Chat, Dev and Studio stay their names.
|
|
448
448
|
const from = FROM.map((f) => ({ ...f, label: t(f.label) }));
|
|
449
449
|
const whose = WHOSE.map((w) => ({ ...w, label: t(w.label) }));
|
|
450
|
-
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] }));
|
|
450
|
+
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') }), host.sections ? null : make, 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.'), children: narrowed ? null : make })) : (_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, _jsx(Make, { open: making, onClose: () => host.go(path({ kind: 'screen', screen: 'artifacts' }), { replace: true }) })] }));
|
|
451
451
|
}
|
|
452
452
|
function ViewMark({ label, on, onPress, children }) {
|
|
453
453
|
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/make.d.ts
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/** A chip: one choice among a few, lit when chosen. */
|
|
2
|
+
export declare function Chip({ label, on, onPress }: {
|
|
3
|
+
label: string;
|
|
4
|
+
on: boolean;
|
|
5
|
+
onPress: () => void;
|
|
6
|
+
}): import("react").JSX.Element;
|
|
7
|
+
export declare function Make({ open, onClose }: {
|
|
8
|
+
open: boolean;
|
|
9
|
+
onClose: () => void;
|
|
10
|
+
}): import("react").JSX.Element;
|
package/lib/make.js
ADDED
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
/**
|
|
3
|
+
* Make something new: the Library's template picker (-/artifacts/new), fed live
|
|
4
|
+
* by gallery.hanzo.ai (api/gallery.ts). Each template shows its capture, its
|
|
5
|
+
* name and its kind; search and the kinds narrow them.
|
|
6
|
+
*
|
|
7
|
+
* Picking one makes it where its kind is made: a site is copied into a project
|
|
8
|
+
* of this org and opens in Dev (`fork`), an agent becomes the org's own and
|
|
9
|
+
* opens in Customize › Agents (`use`).
|
|
10
|
+
*
|
|
11
|
+
* The keyboard: Down (or Enter) from the search goes into the grid, the arrows
|
|
12
|
+
* move across and down it, Up from its first row goes back, Enter picks, and
|
|
13
|
+
* Escape closes. On a phone the picker is the whole screen.
|
|
14
|
+
*/
|
|
15
|
+
import { SizableText, useMedia, XStack, YStack } from '@hanzo/gui';
|
|
16
|
+
import { useI18n } from '@hanzo/i18n/react';
|
|
17
|
+
import { Bot, Globe, Search, X } from '@hanzogui/lucide-icons-2';
|
|
18
|
+
import { Button, Dialog, DialogContent, DialogTitle, Input } from '@hanzo/ui';
|
|
19
|
+
import { useEffect, useMemo, useRef, useState } from 'react';
|
|
20
|
+
import { use } from './api/agents.js';
|
|
21
|
+
import { told } from './api/call.js';
|
|
22
|
+
import { APP, catalogue, KIND, KINDS, narrow } from './api/gallery.js';
|
|
23
|
+
import { fork } from './api/projects.js';
|
|
24
|
+
import { useRead } from './data.js';
|
|
25
|
+
import { useHost, useTarget } from './host.js';
|
|
26
|
+
import { path } from './route.js';
|
|
27
|
+
/** A chip: one choice among a few, lit when chosen. */
|
|
28
|
+
export function Chip({ label, on, onPress }) {
|
|
29
|
+
return (_jsx(XStack, { render: "button", role: "radio", "aria-checked": on, "aria-label": label, onPress: onPress, height: 32, px: "$3", items: "center", rounded: "$10", shrink: 0, borderWidth: 1, borderColor: on ? '$ink' : '$borderColor', bg: on ? '$ink' : 'transparent', hoverStyle: { bg: on ? '$ink' : '$hover' }, cursor: "pointer", focusVisibleStyle: { outlineWidth: 2, outlineStyle: 'solid', outlineColor: '$outlineColor' }, children: _jsx(SizableText, { size: "$2", color: on ? '$background' : '$ink', children: label }) }));
|
|
30
|
+
}
|
|
31
|
+
/** A template's capture, 16:10 from the top of its page, or its kind's mark. */
|
|
32
|
+
function Still({ x }) {
|
|
33
|
+
const [broken, setBroken] = useState(false);
|
|
34
|
+
return (_jsx(YStack, { width: "100%", aspectRatio: 16 / 10, bg: "$raised", items: "center", justify: "center", overflow: "hidden", "aria-hidden": true, children: x.preview && !broken ? (_jsx("img", { src: x.preview, alt: "", loading: "lazy", onError: () => setBroken(true), style: { width: '100%', height: '100%', objectFit: 'cover', objectPosition: 'top', display: 'block' } })) : (_jsx(YStack, { opacity: 0.6, children: x.kind === 'agent' ? _jsx(Bot, { size: 24 }) : _jsx(Globe, { size: 24 }) })) }));
|
|
35
|
+
}
|
|
36
|
+
/** Where a key moves from cell `i` of `n` laid out `cols` wide: a cell, -1 for Up out of the first row, or null for a key the grid does not take. */
|
|
37
|
+
function step(key, i, n, cols) {
|
|
38
|
+
const to = { ArrowRight: i + 1, ArrowLeft: i - 1, ArrowDown: i + cols, ArrowUp: i - cols, Home: 0, End: n - 1 };
|
|
39
|
+
if (!(key in to))
|
|
40
|
+
return null;
|
|
41
|
+
const v = to[key];
|
|
42
|
+
return v < 0 ? (key === 'ArrowUp' ? -1 : 0) : Math.min(v, n - 1);
|
|
43
|
+
}
|
|
44
|
+
export function Make({ open, onClose }) {
|
|
45
|
+
const { t } = useI18n();
|
|
46
|
+
const host = useHost();
|
|
47
|
+
const target = useTarget();
|
|
48
|
+
const wide = useMedia().md;
|
|
49
|
+
const read = useRead(open ? () => catalogue() : null, [], [open]);
|
|
50
|
+
const [q, setQ] = useState('');
|
|
51
|
+
const [kind, setKind] = useState('');
|
|
52
|
+
const [at, setAt] = useState(0);
|
|
53
|
+
const [busy, setBusy] = useState('');
|
|
54
|
+
const [note, setNote] = useState('');
|
|
55
|
+
const search = useRef(null);
|
|
56
|
+
const cells = useRef([]);
|
|
57
|
+
useEffect(() => {
|
|
58
|
+
if (open)
|
|
59
|
+
setNote('');
|
|
60
|
+
}, [open]);
|
|
61
|
+
const kinds = useMemo(() => KINDS.filter((k) => read.value.some((x) => x.kind === k)), [read.value]);
|
|
62
|
+
const hits = useMemo(() => narrow(read.value, kind, q), [read.value, kind, q]);
|
|
63
|
+
useEffect(() => setAt(0), [kind, q]);
|
|
64
|
+
const pick = async (x) => {
|
|
65
|
+
if (busy)
|
|
66
|
+
return;
|
|
67
|
+
if (!host.person)
|
|
68
|
+
return host.signIn?.();
|
|
69
|
+
setBusy(x.slug);
|
|
70
|
+
setNote('');
|
|
71
|
+
try {
|
|
72
|
+
if (APP[x.kind] === 'dev') {
|
|
73
|
+
const made = await fork(target, x.slug);
|
|
74
|
+
host.go(made.slug || x.slug);
|
|
75
|
+
}
|
|
76
|
+
else {
|
|
77
|
+
const made = await use(target, { name: x.slug, title: x.name, description: x.description, category: x.category, model: x.model, instructions: x.instructions, avatar: x.preview }, window.location.href);
|
|
78
|
+
host.go(path({ kind: 'agent', name: made.name }));
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
catch (e) {
|
|
82
|
+
setNote(told(e, t));
|
|
83
|
+
}
|
|
84
|
+
finally {
|
|
85
|
+
setBusy('');
|
|
86
|
+
}
|
|
87
|
+
};
|
|
88
|
+
const into = (e) => {
|
|
89
|
+
if ((e.key !== 'ArrowDown' && e.key !== 'Enter') || !hits.length)
|
|
90
|
+
return;
|
|
91
|
+
e.preventDefault?.();
|
|
92
|
+
cells.current[0]?.focus();
|
|
93
|
+
};
|
|
94
|
+
const across = (e) => {
|
|
95
|
+
const els = cells.current.slice(0, hits.length);
|
|
96
|
+
const i = els.findIndex((el) => el === document.activeElement);
|
|
97
|
+
if (i < 0)
|
|
98
|
+
return;
|
|
99
|
+
const top = els[0]?.getBoundingClientRect().top;
|
|
100
|
+
const cols = Math.max(1, els.filter((el) => el?.getBoundingClientRect().top === top).length);
|
|
101
|
+
const to = step(e.key ?? '', i, hits.length, cols);
|
|
102
|
+
if (to === null)
|
|
103
|
+
return;
|
|
104
|
+
e.preventDefault?.();
|
|
105
|
+
if (to < 0)
|
|
106
|
+
search.current?.focus();
|
|
107
|
+
else
|
|
108
|
+
els[to]?.focus();
|
|
109
|
+
};
|
|
110
|
+
return (_jsx(Dialog, { open: open, onOpenChange: (o) => !o && onClose(), children: _jsxs(DialogContent, { "data-slot": "make", showCloseButton: false, p: "$4", gap: "$3", ...(wide ? { width: '100%', maxW: 960, maxH: '88vh' } : { position: 'fixed', t: 0, r: 0, b: 0, l: 0, maxW: '100%', maxH: '100%', rounded: 0, borderWidth: 0 }), children: [_jsx(DialogTitle, { numberOfLines: 1, paddingInlineEnd: 40, children: t('Make something new') }), _jsxs(XStack, { items: "center", gap: "$2", children: [_jsx(Search, { size: 16, opacity: 0.6 }), _jsx(YStack, { flex: 1, minW: 0, children: _jsx(Input, { ref: search, value: q, onChangeText: setQ, placeholder: t('Search templates'), "aria-label": t('Search templates'), onKeyDown: into }) })] }), kinds.length > 1 ? (_jsxs(XStack, { role: "radiogroup", "aria-label": t('Kind'), gap: "$2", overflowX: "auto", overflowY: "hidden", pb: "$1", "$platform-web": { scrollbarWidth: 'none' }, children: [_jsx(Chip, { label: t('All'), on: kind === '', onPress: () => setKind('') }), kinds.map((k) => (_jsx(Chip, { label: t(KIND[k]), on: kind === k, onPress: () => setKind(k) }, k)))] })) : null, note ? (_jsx(SizableText, { size: "$2", color: "$soft", role: "status", children: note })) : null, _jsx(YStack, { shrink: 1, minH: 0, overflowY: "auto", overflowX: "hidden", children: read.error ? (_jsxs(YStack, { gap: "$3", items: "flex-start", py: "$4", children: [_jsx(SizableText, { size: "$2", color: "$soft", children: told(read.error, t) }), _jsx(Button, { size: "sm", variant: "outline", onPress: read.reload, children: t('Try again') })] })) : read.loading && !read.value.length ? (_jsx(SizableText, { size: "$2", color: "$soft", py: "$4", children: t('Reading templates…') })) : !hits.length ? (_jsx(SizableText, { size: "$2", color: "$soft", py: "$4", children: t('Nothing matches.') })) : (_jsx(YStack, { role: "list", "aria-label": t('Templates'), onKeyDown: across, gap: 16, "$platform-web": { display: 'grid', gridTemplateColumns: 'repeat(auto-fill, minmax(min(46%, 200px), 1fr))' }, children: hits.map((x, i) => (_jsx(YStack, { role: "listitem", minW: 0, children: _jsxs(YStack, { ref: (el) => {
|
|
111
|
+
cells.current[i] = el instanceof HTMLElement ? el : null;
|
|
112
|
+
}, render: "button", tabIndex: i === at ? 0 : -1, onFocus: () => setAt(i), "aria-label": t('Start from {template}', { template: x.name }), disabled: Boolean(busy), onPress: () => void pick(x), rounded: "$4", borderWidth: 1, borderColor: "$borderColor", overflow: "hidden", cursor: "pointer", hoverStyle: { bg: '$hover' }, focusVisibleStyle: { outlineWidth: 2, outlineStyle: 'solid', outlineColor: '$outlineColor' }, "$platform-web": { textAlign: 'start' }, children: [_jsx(Still, { x: x }), _jsxs(YStack, { px: "$2.5", py: "$2", gap: "$0.5", minW: 0, children: [_jsx(SizableText, { size: "$2", color: "$ink", numberOfLines: 1, children: x.name }), _jsx(SizableText, { size: "$1", color: "$soft", numberOfLines: 1, children: busy === x.slug ? t('Starting…') : [t(KIND[x.kind]), x.category].filter(Boolean).join(' · ') })] })] }) }, x.slug))) })) }), _jsx(XStack, { render: "button", "aria-label": t('Close'), position: "absolute", t: 14, insetInlineEnd: 14, width: 32, height: 32, items: "center", justify: "center", rounded: "$2", hoverStyle: { bg: '$hover' }, cursor: "pointer", onPress: onClose, children: _jsx(X, { size: 16 }) })] }) }));
|
|
113
|
+
}
|
package/lib/marks.d.ts
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The mark of each product and place, once. The rail, a phone's bar, the sidebars,
|
|
3
|
+
* the palette and every landing page draw these and no other, so the same thing
|
|
4
|
+
* wears the same icon everywhere. `icon` is the place; `make` is its New: Chat
|
|
5
|
+
* starts a conversation (the pen), Dev a task (`</>`), Tabs a terminal; a place
|
|
6
|
+
* with nothing of its own to start draws its own icon.
|
|
7
|
+
*/
|
|
8
|
+
import { SquarePen } from '@hanzogui/lucide-icons-2';
|
|
9
|
+
export type Mark = 'chat' | 'dev' | 'design' | 'studio' | 'tabs' | 'library' | 'scheduled' | 'customize';
|
|
10
|
+
/** An icon as the rail and the sidebars draw it. */
|
|
11
|
+
export type Icon = typeof SquarePen;
|
|
12
|
+
export declare const MARKS: Record<Mark, {
|
|
13
|
+
icon: Icon;
|
|
14
|
+
make: Icon;
|
|
15
|
+
}>;
|
package/lib/marks.js
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The mark of each product and place, once. The rail, a phone's bar, the sidebars,
|
|
3
|
+
* the palette and every landing page draw these and no other, so the same thing
|
|
4
|
+
* wears the same icon everywhere. `icon` is the place; `make` is its New: Chat
|
|
5
|
+
* starts a conversation (the pen), Dev a task (`</>`), Tabs a terminal; a place
|
|
6
|
+
* with nothing of its own to start draws its own icon.
|
|
7
|
+
*/
|
|
8
|
+
import { Clapperboard, Clock, CodeXml, Library, MessageSquare, Puzzle, SquarePen, SquareTerminal, WandSparkles } from '@hanzogui/lucide-icons-2';
|
|
9
|
+
export const MARKS = {
|
|
10
|
+
chat: { icon: MessageSquare, make: SquarePen },
|
|
11
|
+
dev: { icon: CodeXml, make: CodeXml },
|
|
12
|
+
design: { icon: WandSparkles, make: WandSparkles },
|
|
13
|
+
studio: { icon: Clapperboard, make: Clapperboard },
|
|
14
|
+
tabs: { icon: SquareTerminal, make: SquareTerminal },
|
|
15
|
+
library: { icon: Library, make: Library },
|
|
16
|
+
scheduled: { icon: Clock, make: Clock },
|
|
17
|
+
customize: { icon: Puzzle, make: Puzzle },
|
|
18
|
+
};
|
package/lib/mind.d.ts
CHANGED
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
* picked for the screen it was picked on (`usePick`) and never kept, so the next
|
|
13
13
|
* conversation or run opens on what was kept, Enso until something else is.
|
|
14
14
|
*
|
|
15
|
-
* The efforts are Auto, High
|
|
15
|
+
* The efforts are Auto, High and Max, Chat's words (Hanzo's
|
|
16
16
|
* ThinkingEffort), Auto until another is chosen. A coding run takes low, medium
|
|
17
17
|
* or high (apps/coding `efforts`), so `level` is what a run names: medium for
|
|
18
18
|
* Auto, what a run took before anyone chose, and high for the rest, the most it
|
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
import type { Modes } from '@hanzo/ui/chat';
|
|
24
24
|
import { type Target } from './api/call.ts';
|
|
25
25
|
import { type Model } from './api/models.ts';
|
|
26
|
-
export type Effort = 'auto' | 'high' | '
|
|
26
|
+
export type Effort = 'auto' | 'high' | 'max';
|
|
27
27
|
/** The efforts a Dev run offers, in order: the composer's own list (Chat offers every one), less Low and Medium. Marked English, drawn through `t`. */
|
|
28
28
|
export declare const EFFORTS: (import("@hanzo/ui/chat").Way<import("@hanzo/ui/chat").Effort> & {
|
|
29
29
|
id: Effort;
|
|
@@ -74,6 +74,12 @@ export interface Catalog {
|
|
|
74
74
|
export declare function useCatalog(t: Target): Catalog;
|
|
75
75
|
/** Whether `model` is one this plan may send: on Free, Enso Auto alone (commerce's `allowedModels`). */
|
|
76
76
|
export declare function grants(free: boolean, model: string): boolean;
|
|
77
|
+
/**
|
|
78
|
+
* Whether the plan and the prepaid balance (cents, null where unknown) let `id` be
|
|
79
|
+
* sent: Hanzo's own models follow the plan; another maker's are paid from the balance
|
|
80
|
+
* on any plan, Free included.
|
|
81
|
+
*/
|
|
82
|
+
export declare function sendable(free: boolean, models: readonly Model[], cents: number | null, id: string): boolean;
|
|
77
83
|
/** The effort as the composer reads it: the one in force, its list, and the way to change it. */
|
|
78
84
|
export declare const pacing: (m: Pick<Mind, 'effort' | 'pace'>) => Modes<Effort>;
|
|
79
85
|
/** The chip's whole state: the catalog, what answers next, and how to change either. */
|
|
@@ -90,10 +96,30 @@ export interface Mind {
|
|
|
90
96
|
/** A premium pick holds for this screen; any other is kept. */
|
|
91
97
|
pick: (id: string) => void;
|
|
92
98
|
pace: (effort: Effort) => void;
|
|
99
|
+
/**
|
|
100
|
+
* Another maker's models are paid from the prepaid balance on any plan, so on Free
|
|
101
|
+
* they are not an upgrade. Present where the host can send a person to the top-up
|
|
102
|
+
* and the balance was read: whether the balance can pay for a model.
|
|
103
|
+
*/
|
|
104
|
+
funded?: (id: string) => boolean;
|
|
105
|
+
/** The balance, as the billing API states it, whole cents written as dollars. */
|
|
106
|
+
balance?: string;
|
|
107
|
+
/** The way to the top-up, given the model that was chosen if one was. */
|
|
108
|
+
topUp?: (id?: string) => void;
|
|
109
|
+
}
|
|
110
|
+
/** What a picker needs to sell another maker's models from the balance: whether it can pay, what it holds, and the way to top it up. */
|
|
111
|
+
export interface Funds {
|
|
112
|
+
/** The balance in cents; null until read, and where it could not be. */
|
|
113
|
+
cents: number | null;
|
|
114
|
+
funded?: (id: string) => boolean;
|
|
115
|
+
balance?: string;
|
|
116
|
+
topUp?: (id?: string) => void;
|
|
93
117
|
}
|
|
118
|
+
/** The prepaid balance for a picker, where the host offers a top-up (`Host.topUp`); with none, no funds are claimed. */
|
|
119
|
+
export declare function useFunds(t: Target, topUp?: (id?: string) => void): Funds;
|
|
94
120
|
/**
|
|
95
121
|
* The model and effort for the plan `plan` names (`GET /v1/ai/limits` `plan`).
|
|
96
122
|
* On Free the model is Enso Auto, and a kept pick of any other is set aside
|
|
97
123
|
* rather than sent — it comes back once the plan grants it.
|
|
98
124
|
*/
|
|
99
|
-
export declare function useMind(t: Target, plan?: string | null): Mind;
|
|
125
|
+
export declare function useMind(t: Target, plan?: string | null, topUp?: (id?: string) => void): Mind;
|
package/lib/mind.js
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import { EFFORTS as EVERY } from '@hanzo/ui/chat/pure';
|
|
2
|
-
import { parseModels } from '@hanzo/ui/models/catalog';
|
|
2
|
+
import { parseModels, thirdParty } from '@hanzo/ui/models/catalog';
|
|
3
3
|
import { useEffect, useState, useSyncExternalStore } from 'react';
|
|
4
|
+
import { balance as readBalance } from './api/billing.js';
|
|
4
5
|
import { Refusal } from './api/call.js';
|
|
5
6
|
import { ENSO, models as read } from './api/models.js';
|
|
6
7
|
import { usePick } from './pick.js';
|
|
7
8
|
/** The efforts a Dev run offers, in order: the composer's own list (Chat offers every one), less Low and Medium. Marked English, drawn through `t`. */
|
|
8
|
-
export const EFFORTS = EVERY.filter((e) => ['auto', 'high', '
|
|
9
|
+
export const EFFORTS = EVERY.filter((e) => ['auto', 'high', 'max'].includes(e.id));
|
|
9
10
|
/** The effort a coding run names (apps/coding takes low, medium or high): medium for Auto, high for the rest. */
|
|
10
11
|
export const level = (effort) => (effort === 'auto' ? 'medium' : 'high');
|
|
11
12
|
export const FIRST = { model: ENSO, effort: 'auto' };
|
|
@@ -13,7 +14,8 @@ export const FIRST = { model: ENSO, effort: 'auto' };
|
|
|
13
14
|
export const isFree = (plan) => plan === 'free';
|
|
14
15
|
const KEY = 'hanzo.mind';
|
|
15
16
|
const CHANGE = 'hanzo:mind';
|
|
16
|
-
|
|
17
|
+
/** An effort kept, read back: one the ladder still offers, XHigh (which Max replaced) as Max, else Auto. */
|
|
18
|
+
const effortOf = (v) => (v === 'xhigh' ? 'max' : EFFORTS.some((e) => e.id === v) ? v : FIRST.effort);
|
|
17
19
|
/** The store, or null where the browser gives none (a server render, blocked site data). */
|
|
18
20
|
function store() {
|
|
19
21
|
try {
|
|
@@ -172,19 +174,83 @@ export function useCatalog(t) {
|
|
|
172
174
|
export function grants(free, model) {
|
|
173
175
|
return !free || model === ENSO;
|
|
174
176
|
}
|
|
177
|
+
/** Whole cents as dollars. */
|
|
178
|
+
const dollars = (cents) => `$${(cents / 100).toFixed(2)}`;
|
|
179
|
+
/**
|
|
180
|
+
* Whether the plan and the prepaid balance (cents, null where unknown) let `id` be
|
|
181
|
+
* sent: Hanzo's own models follow the plan; another maker's are paid from the balance
|
|
182
|
+
* on any plan, Free included.
|
|
183
|
+
*/
|
|
184
|
+
export function sendable(free, models, cents, id) {
|
|
185
|
+
const row = models.find((m) => m.id === id);
|
|
186
|
+
return grants(free, id) || Boolean(row && thirdParty(row) && cents !== null && cents > 0);
|
|
187
|
+
}
|
|
175
188
|
/** The effort as the composer reads it: the one in force, its list, and the way to change it. */
|
|
176
189
|
export const pacing = (m) => ({ value: m.effort, set: m.pace, items: EFFORTS });
|
|
190
|
+
/** The prepaid balance in cents for a signed-in target, read once; null until it is, and where it could not be read. */
|
|
191
|
+
function useBalance(t, on) {
|
|
192
|
+
const [cents, set] = useState(null);
|
|
193
|
+
useEffect(() => {
|
|
194
|
+
if (!on || !t.token())
|
|
195
|
+
return;
|
|
196
|
+
let live = true;
|
|
197
|
+
readBalance(t).then((n) => live && set(n), () => live && set(null));
|
|
198
|
+
return () => {
|
|
199
|
+
live = false;
|
|
200
|
+
};
|
|
201
|
+
// The target is rebuilt each render; what it names is the key.
|
|
202
|
+
}, [on, t.api, t.org]); // eslint-disable-line react-hooks/exhaustive-deps
|
|
203
|
+
return cents;
|
|
204
|
+
}
|
|
205
|
+
/** The prepaid balance for a picker, where the host offers a top-up (`Host.topUp`); with none, no funds are claimed. */
|
|
206
|
+
export function useFunds(t, topUp) {
|
|
207
|
+
const cents = useBalance(t, topUp !== undefined);
|
|
208
|
+
if (topUp === undefined || cents === null)
|
|
209
|
+
return { cents };
|
|
210
|
+
return { cents, funded: (_id) => cents > 0, balance: dollars(cents), topUp };
|
|
211
|
+
}
|
|
212
|
+
/** The model a top-up returned to, named in the address (`?model=`); read once, and left out of the address. */
|
|
213
|
+
function returned() {
|
|
214
|
+
if (typeof window === 'undefined' || !window.location)
|
|
215
|
+
return '';
|
|
216
|
+
const url = new URL(window.location.href);
|
|
217
|
+
return url.searchParams.get('model') ?? '';
|
|
218
|
+
}
|
|
219
|
+
function settleReturn() {
|
|
220
|
+
if (typeof window === 'undefined' || !window.location)
|
|
221
|
+
return;
|
|
222
|
+
const url = new URL(window.location.href);
|
|
223
|
+
if (!url.searchParams.has('model'))
|
|
224
|
+
return;
|
|
225
|
+
url.searchParams.delete('model');
|
|
226
|
+
window.history.replaceState(window.history.state, '', `${url.pathname}${url.search}${url.hash}`);
|
|
227
|
+
}
|
|
177
228
|
/**
|
|
178
229
|
* The model and effort for the plan `plan` names (`GET /v1/ai/limits` `plan`).
|
|
179
230
|
* On Free the model is Enso Auto, and a kept pick of any other is set aside
|
|
180
231
|
* rather than sent — it comes back once the plan grants it.
|
|
181
232
|
*/
|
|
182
|
-
export function useMind(t, plan) {
|
|
233
|
+
export function useMind(t, plan, topUp) {
|
|
183
234
|
const [choice, change] = useChoice();
|
|
184
235
|
const { models, list, loading, error, note } = useCatalog(t);
|
|
185
236
|
const free = isFree(plan);
|
|
186
237
|
const [picked, pick] = usePick(choice.model, (id) => change({ model: id }), list);
|
|
187
|
-
|
|
238
|
+
// Another maker's model is paid from the balance on any plan; Hanzo's own follow the plan.
|
|
239
|
+
const funds = useFunds(t, topUp);
|
|
240
|
+
const cents = funds.cents;
|
|
241
|
+
const may = (id) => sendable(free, models, cents, id);
|
|
242
|
+
const model = may(picked) ? picked : ENSO;
|
|
243
|
+
// A top-up returns to this address with the model it was for: pick it once the balance can pay.
|
|
244
|
+
const [back] = useState(returned);
|
|
245
|
+
useEffect(() => {
|
|
246
|
+
if (!back || !models.length || cents === null)
|
|
247
|
+
return;
|
|
248
|
+
if (may(back))
|
|
249
|
+
pick(back);
|
|
250
|
+
settleReturn();
|
|
251
|
+
// Once, when the catalog and the balance are both here.
|
|
252
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
253
|
+
}, [models.length, cents]);
|
|
188
254
|
return {
|
|
189
255
|
model,
|
|
190
256
|
effort: choice.effort,
|
|
@@ -194,9 +260,10 @@ export function useMind(t, plan) {
|
|
|
194
260
|
note,
|
|
195
261
|
free,
|
|
196
262
|
pick: (id) => {
|
|
197
|
-
if (
|
|
263
|
+
if (may(id))
|
|
198
264
|
pick(id);
|
|
199
265
|
},
|
|
200
266
|
pace: (effort) => change({ effort }),
|
|
267
|
+
...(funds.funded ? { funded: funds.funded, balance: funds.balance, topUp: funds.topUp } : {}),
|
|
201
268
|
};
|
|
202
269
|
}
|
package/lib/nav.d.ts
CHANGED
|
@@ -22,7 +22,7 @@ export declare function sections(host: Host, go: (path: string) => void, t?: Say
|
|
|
22
22
|
export declare function tabs(host: Host, go: (path: string) => void, t?: Say): Group[];
|
|
23
23
|
/** Fired on `window` once the sidebar's Upload has kept its files, for the Library to read again. */
|
|
24
24
|
export declare const KEPT = "hanzo:library:kept";
|
|
25
|
-
/** The Library's sidebar: Upload, then every kind it narrows to, the one in the address lit. */
|
|
25
|
+
/** The Library's sidebar: Make something new and Upload, then every kind it narrows to, the one in the address lit. */
|
|
26
26
|
export declare function library(host: Host, go: (path: string) => void, t?: Say): Group[];
|
|
27
27
|
/** Scheduled tasks' sidebar: New task, then each of the person's tasks, the one open lit. Read only while `on`. */
|
|
28
28
|
export declare function useScheduled(host: Host, go: (path: string) => void, on: boolean): Group[];
|
package/lib/nav.js
CHANGED
|
@@ -12,7 +12,8 @@ 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,
|
|
15
|
+
import { AudioLines, Bell, BookOpen, Bot, Box, Brain, CircleDot, Code, Container, Cpu, CreditCard, File, FileText, FolderGit2, Gauge, Globe, Image, Key, LayoutTemplate, Library, Plug, Plus, Presentation, Puzzle, Settings, Shield, Sparkles, Upload, User, Users, Video } from '@hanzogui/lucide-icons-2';
|
|
16
|
+
import { MARKS } from './marks.js';
|
|
16
17
|
import { phrase } from '@hanzo/i18n';
|
|
17
18
|
import { useI18n } from '@hanzo/i18n/react';
|
|
18
19
|
import { useMemo } from 'react';
|
|
@@ -36,7 +37,7 @@ export function nav(host, go, t = english) {
|
|
|
36
37
|
id: 'work',
|
|
37
38
|
label: t('Work'),
|
|
38
39
|
links: [
|
|
39
|
-
{ id: NEW, label: t('New run'), icon: _jsx(
|
|
40
|
+
{ id: NEW, label: t('New run'), icon: _jsx(MARKS.dev.make, { size: 16 }), onPress: to(''), active: r.kind === 'new' },
|
|
40
41
|
// A project is a repository: its list, linking one from GitHub, and one's workspace.
|
|
41
42
|
{
|
|
42
43
|
id: 'projects',
|
|
@@ -62,8 +63,8 @@ export function nav(host, go, t = english) {
|
|
|
62
63
|
id: 'make',
|
|
63
64
|
label: t('Make'),
|
|
64
65
|
links: [
|
|
65
|
-
{ id: 'artifacts', label: t('Library'), icon: _jsx(
|
|
66
|
-
{ id: 'automations', label: t('Scheduled tasks'), icon: _jsx(
|
|
66
|
+
{ id: 'artifacts', label: t('Library'), icon: _jsx(MARKS.library.icon, { size: 16 }), onPress: to(path({ kind: 'screen', screen: 'artifacts' })), active: screen === 'artifacts' },
|
|
67
|
+
{ id: 'automations', label: t('Scheduled tasks'), icon: _jsx(MARKS.scheduled.icon, { size: 16 }), onPress: to(path({ kind: 'screen', screen: 'automations' })), active: screen === 'automations' || r.kind === 'automation' },
|
|
67
68
|
],
|
|
68
69
|
},
|
|
69
70
|
{
|
|
@@ -78,7 +79,7 @@ export function nav(host, go, t = english) {
|
|
|
78
79
|
id: 'setup',
|
|
79
80
|
label: t('Setup'),
|
|
80
81
|
links: [
|
|
81
|
-
{ id: 'customize', label: t('Customize'), icon: _jsx(
|
|
82
|
+
{ id: 'customize', label: t('Customize'), icon: _jsx(MARKS.customize.icon, { size: 16 }), onPress: to(path({ kind: 'customize', tab: 'agents' })), active: r.kind === 'customize' || r.kind === 'agent' || screen === 'mcp' },
|
|
82
83
|
{ id: 'docs', label: t('Docs'), icon: _jsx(BookOpen, { size: 16 }), onPress: () => window.open(DOCS, '_blank', 'noopener,noreferrer') },
|
|
83
84
|
],
|
|
84
85
|
},
|
|
@@ -160,12 +161,19 @@ function keep(host, say) {
|
|
|
160
161
|
};
|
|
161
162
|
input.click();
|
|
162
163
|
}
|
|
163
|
-
/** The Library's sidebar: Upload, then every kind it narrows to, the one in the address lit. */
|
|
164
|
+
/** The Library's sidebar: Make something new and Upload, then every kind it narrows to, the one in the address lit. */
|
|
164
165
|
export function library(host, go, t = english) {
|
|
165
166
|
const r = route(host.path);
|
|
166
167
|
const at = r.kind === 'screen' && r.screen === 'artifacts' ? (r.of ?? '') : null;
|
|
167
168
|
return [
|
|
168
|
-
{
|
|
169
|
+
{
|
|
170
|
+
id: 'library-do',
|
|
171
|
+
label: '',
|
|
172
|
+
links: [
|
|
173
|
+
{ id: 'make', label: t('Make something new'), icon: _jsx(Plus, { size: 16 }), onPress: () => go(path({ kind: 'screen', screen: 'artifacts', of: 'new' })), active: at === 'new' },
|
|
174
|
+
{ id: 'upload', label: t('Upload'), icon: _jsx(Upload, { size: 16 }), onPress: () => keep(host, t) },
|
|
175
|
+
],
|
|
176
|
+
},
|
|
169
177
|
{
|
|
170
178
|
id: 'library-kinds',
|
|
171
179
|
label: '',
|
|
@@ -204,7 +212,7 @@ export function useScheduled(host, go, on) {
|
|
|
204
212
|
{
|
|
205
213
|
id: 'scheduled-tasks',
|
|
206
214
|
label: list.value.length ? say('Tasks') : '',
|
|
207
|
-
links: list.value.map((a) => ({ id: a.id, label: a.name || say('Untitled task'), icon: _jsx(
|
|
215
|
+
links: list.value.map((a) => ({ id: a.id, label: a.name || say('Untitled task'), icon: _jsx(MARKS.scheduled.icon, { size: 16 }), onPress: () => go(path({ kind: 'automation', id: a.id })), active: at === a.id })),
|
|
208
216
|
},
|
|
209
217
|
];
|
|
210
218
|
}
|
package/lib/route.d.ts
CHANGED
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
* sess_<32 hex> one run
|
|
6
6
|
* -/<screen> a builder screen
|
|
7
7
|
* -/artifacts/<kind> the Library narrowed to one kind (image, video, document, …)
|
|
8
|
+
* -/artifacts/new the Library, making something new from a gallery template
|
|
8
9
|
* -/automations/<id> one automation's editor and runs; `new` writes one
|
|
9
10
|
* -/settings[/<section>] a section of Settings
|
|
10
11
|
* -/customize[/<tab>] agents, skills, connectors and plugins: what the agent brings to a run
|
|
@@ -64,8 +65,8 @@ export type Route = {
|
|
|
64
65
|
kind: 'automation';
|
|
65
66
|
id: string;
|
|
66
67
|
};
|
|
67
|
-
/**
|
|
68
|
-
export declare const OF: readonly ['image', 'video', 'audio', 'document', 'slides', 'type', 'model', 'code', 'file', 'sites'];
|
|
68
|
+
/** What the Library's address names: a kind it narrows to (api/library.ts KIND_IDS, plus `sites`), or `new`, its template picker. */
|
|
69
|
+
export declare const OF: readonly ['image', 'video', 'audio', 'document', 'slides', 'type', 'model', 'code', 'file', 'sites', 'new'];
|
|
69
70
|
export type Of = (typeof OF)[number];
|
|
70
71
|
export declare const SESSION: RegExp;
|
|
71
72
|
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, then Bots. */
|
|
19
19
|
export const TABS = ['agents', 'bots', 'skills', 'connectors', 'plugins'];
|
|
20
|
-
/**
|
|
21
|
-
export const OF = ['image', 'video', 'audio', 'document', 'slides', 'type', 'model', 'code', 'file', 'sites'];
|
|
20
|
+
/** What the Library's address names: a kind it narrows to (api/library.ts KIND_IDS, plus `sites`), or `new`, its template picker. */
|
|
21
|
+
export const OF = ['image', 'video', 'audio', 'document', 'slides', 'type', 'model', 'code', 'file', 'sites', 'new'];
|
|
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`). */
|