@hanzo/app 0.3.73 → 0.3.74
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/dist/PreferencesDialog.d.ts +5 -0
- package/dist/PreferencesDialog.js +25 -0
- package/dist/bots/Bots.js +1 -1
- package/dist/bots/Panel.d.ts +3 -4
- package/dist/bots/Panel.js +74 -36
- package/dist/bots/Roster.js +40 -22
- package/dist/bots/Thread.d.ts +0 -1
- package/dist/bots/Thread.js +45 -30
- package/dist/bots/face.d.ts +3 -1
- package/dist/bots/face.js +12 -8
- package/dist/bots/grid.d.ts +1 -1
- package/dist/bots/grid.js +17 -2
- package/dist/bots/ink.d.ts +6 -6
- package/dist/bots/ink.js +8 -16
- package/dist/bots/kit.d.ts +13 -12
- package/dist/bots/kit.js +33 -11
- package/dist/bots/said.d.ts +16 -0
- package/dist/bots/said.js +63 -0
- package/package.json +1 -1
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { useEffect, useState } from 'react';
|
|
4
|
+
import { useI18n } from '@hanzo/i18n/react';
|
|
5
|
+
import { Dialog, DialogContent, DialogTitle, Input, XStack, YStack } from '@hanzo/ui';
|
|
6
|
+
import { Search, X } from 'lucide-react';
|
|
7
|
+
import { FIRST, SettingsList } from './Settings.js';
|
|
8
|
+
import { SettingsPane } from './SettingsPane.js';
|
|
9
|
+
export function PreferencesDialog({ open, onOpenChange, initialSection = FIRST, }) {
|
|
10
|
+
const { t } = useI18n();
|
|
11
|
+
const [active, setActive] = useState(initialSection);
|
|
12
|
+
const [filter, setFilter] = useState('');
|
|
13
|
+
useEffect(() => {
|
|
14
|
+
if (open)
|
|
15
|
+
setActive(initialSection);
|
|
16
|
+
}, [open, initialSection]);
|
|
17
|
+
const pick = (row) => {
|
|
18
|
+
if (row.href) {
|
|
19
|
+
window.open(row.href, '_blank', 'noopener,noreferrer');
|
|
20
|
+
return;
|
|
21
|
+
}
|
|
22
|
+
setActive(row.id);
|
|
23
|
+
};
|
|
24
|
+
return (_jsx(Dialog, { open: open, onOpenChange: onOpenChange, children: _jsxs(DialogContent, { "data-slot": "preferences-dialog", width: "94vw", maxW: 980, height: "84vh", maxH: 760, p: 0, gap: 0, rounded: 14, overflow: "hidden", bg: "var(--pane-fill, var(--card))", borderWidth: 1, borderColor: "var(--pane-edge, var(--border))", children: [_jsx(DialogTitle, { display: "none", children: t('Settings') }), _jsxs(XStack, { flex: 1, minH: 0, width: "100%", children: [_jsxs(YStack, { width: 236, shrink: 0, height: "100%", bg: "var(--side-fill, var(--background))", borderRightWidth: 1, borderColor: "var(--pane-edge, var(--border))", "$max-md": { width: 184 }, children: [_jsx(XStack, { px: 12, pt: 12, pb: 8, shrink: 0, children: _jsxs(XStack, { flex: 1, height: 32, px: 10, gap: 7, items: "center", rounded: 8, bg: "var(--surface-card-emphasis)", borderWidth: 1, borderColor: "var(--pane-edge, var(--border))", children: [_jsx(Search, { size: 13, color: "var(--muted-foreground)", "aria-hidden": true }), _jsx(Input, { unstyled: true, value: filter, onChange: (e) => setFilter(e.target.value), placeholder: t('Search settings'), "aria-label": t('Search settings'), flex: 1, minW: 0, fontSize: 13, color: "var(--foreground)", placeholderTextColor: "$placeholderColor" })] }) }), _jsx(YStack, { flex: 1, minH: 0, px: 8, pb: 12, overflowY: "auto", overflowX: "hidden", children: _jsx(SettingsList, { active: active, filter: filter, onPick: pick, onBack: () => onOpenChange(false) }) })] }), _jsxs(YStack, { flex: 1, minW: 0, minH: 0, height: "100%", bg: "var(--pane-fill, var(--card))", position: "relative", children: [_jsx(XStack, { position: "absolute", t: 12, r: 14, z: 5, children: _jsx(XStack, { render: "button", type: 'button', "aria-label": t('Close'), onClick: () => onOpenChange(false), width: 32, height: 32, rounded: 999, items: "center", justify: "center", bg: "var(--surface-card-emphasis)", borderWidth: 1, borderColor: "var(--pane-edge, var(--border))", cursor: "pointer", hoverStyle: { bg: 'var(--secondary)' }, children: _jsx(X, { size: 15, color: "var(--foreground)", "aria-hidden": true }) }) }), _jsx(SettingsPane, { id: active })] })] })] }) }));
|
|
25
|
+
}
|
package/dist/bots/Bots.js
CHANGED
|
@@ -293,7 +293,7 @@ export function Bots({ foot = true, bot: held, onBot, } = {}) {
|
|
|
293
293
|
setSide(false);
|
|
294
294
|
setOver(false);
|
|
295
295
|
};
|
|
296
|
-
const panel = bot ? (_jsx(Panel, { bot: bot, kept: kept[bot.name] ?? '', onClose: close, onSchedule: schedule, onDelete: remove, focus: over && !laptop }, bot.name)) : null;
|
|
296
|
+
const panel = bot ? (_jsx(Panel, { bot: bot, runs: runs ?? [], kept: kept[bot.name] ?? '', onClose: close, onSchedule: schedule, onDelete: remove, focus: over && !laptop }, bot.name)) : null;
|
|
297
297
|
const shown = laptop ? side : over;
|
|
298
298
|
return (_jsxs(XStack, { "data-parity-key": "bots.window", width: "100%", height: "100%", overflow: "hidden", bg: FLOOR, position: "relative", children: [_jsx(YStack, { "data-parity-key": "bots.roster", width: 279, shrink: 0, height: "100%", bg: FLOOR, borderRightWidth: 1, borderColor: LINE, "$max-md": { width: '100%', borderRightWidth: 0, display: bot ? 'none' : 'flex' }, children: _jsx(Roster, { bots: bots, last: last, open: open, unread: unread, me: foot ? user : null, onPick: pick, onMake: () => setMaking(true), disabled: !live }) }), _jsx(YStack, { "data-parity-key": "bots.center", flex: 1, minW: 0, height: "100%", bg: GROUND, "$max-md": { display: bot ? 'flex' : 'none' }, children: _jsx(Thread, { bot: bot, bots: bots ?? [], runs: runs, pending: pending, notice: notice, wrong: wrong, side: shown, live: live, loaded: bots !== null, onSend: send, onDismiss: () => setNotice(null), onSide: () => (laptop ? setSide(!side) : setOver(!over)), onBack: back, onMake: () => setMaking(true) }) }), laptop && side && panel ? (_jsx(YStack, { "data-parity-key": "bots.panel", width: 319, shrink: 0, height: "100%", bg: GROUND, borderLeftWidth: 1, borderColor: LINE, "$max-xl": { display: 'none' }, children: panel })) : null, over && panel && !laptop ? (_jsx(YStack, { "data-parity-key": "bots.panel.over", role: "dialog", "aria-modal": true, "aria-label": bot?.name, position: "absolute", t: 0, r: 0, b: 0, width: 319, maxW: "100%", z: 10, bg: GROUND, borderLeftWidth: 1, borderColor: LINE, boxShadow: "var(--shadow-floating)", children: panel })) : null, making ? _jsx(Make, { onDone: made, onCancel: () => setMaking(false) }) : null] }));
|
|
299
299
|
}
|
package/dist/bots/Panel.d.ts
CHANGED
|
@@ -1,11 +1,10 @@
|
|
|
1
|
-
import type { Agent } from '@hanzo/ai';
|
|
2
|
-
export declare function Panel({ bot, onClose, kept, onSchedule, onDelete, focus, }: {
|
|
1
|
+
import type { Agent, AgentRun } from '@hanzo/ai';
|
|
2
|
+
export declare function Panel({ bot, runs, onClose, kept, onSchedule, onDelete, focus, }: {
|
|
3
3
|
bot: Agent;
|
|
4
|
-
|
|
4
|
+
runs?: readonly AgentRun[];
|
|
5
5
|
kept: string;
|
|
6
6
|
onClose: () => void;
|
|
7
7
|
onSchedule: (on: boolean, cron: string) => Promise<void>;
|
|
8
8
|
onDelete: () => Promise<void>;
|
|
9
|
-
/** Over the thread: the close control takes the focus, so Escape and Tab start here. */
|
|
10
9
|
focus?: boolean;
|
|
11
10
|
}): import("react").JSX.Element;
|
package/dist/bots/Panel.js
CHANGED
|
@@ -1,24 +1,36 @@
|
|
|
1
1
|
'use client';
|
|
2
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
-
//
|
|
4
|
-
//
|
|
5
|
-
//
|
|
6
|
-
import { useCallback, useEffect, useState } from 'react';
|
|
2
|
+
import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
// The open bot's right inspector panel: avatar, name, [Activity | Library]
|
|
4
|
+
// segmented control, Upcoming routines & connected networks, Bot's computer
|
|
5
|
+
// status monitor, and Voice chat preferences.
|
|
6
|
+
import { useCallback, useEffect, useMemo, useState } from 'react';
|
|
7
7
|
import { useI18n } from '@hanzo/i18n/react';
|
|
8
8
|
import { Text, XStack, YStack } from '@hanzo/gui';
|
|
9
|
-
import { Button, Dialog, DialogContent, DialogTitle, Switch } from '@hanzo/ui';
|
|
10
|
-
import { Clock, X } from 'lucide-react';
|
|
9
|
+
import { Button, Dialog, DialogContent, DialogTitle, DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuTrigger, Switch, } from '@hanzo/ui';
|
|
10
|
+
import { ChevronDown, ChevronRight, Clock, FileText, Image as ImageIcon, X } from 'lucide-react';
|
|
11
|
+
import { useKept } from '../kept.js';
|
|
11
12
|
import { useAi } from '../lib/ai.js';
|
|
12
13
|
import { say } from '../failure.js';
|
|
13
14
|
import { Network, of } from '../network.js';
|
|
15
|
+
import { called } from '../team.js';
|
|
14
16
|
import { Face } from './face.js';
|
|
15
17
|
import { ALWAYS, answering, disk, grant } from './api.js';
|
|
16
18
|
import { CARD, CLIP, LABEL, PILL, ROUND, WORD } from './kit.js';
|
|
17
|
-
import { DIM, INK, LINE } from './ink.js';
|
|
19
|
+
import { DIM, INK, LINE, PICKED, RAISED } from './ink.js';
|
|
20
|
+
import { partsOf } from './said.js';
|
|
18
21
|
import { cron as words } from './time.js';
|
|
22
|
+
const VOICES = ['Liora', 'Aria', 'Sol', 'Koe', 'Nova', 'Echo'];
|
|
23
|
+
const SPEEDS = ['0.9x', '1x', '1.25x', '1.5x', '2x'];
|
|
24
|
+
const LANGUAGES = ['Auto-detect', 'English', 'Spanish', 'French', 'German', 'Japanese', 'Chinese'];
|
|
19
25
|
/** One row of a card: a mark, two lines, and whatever acts on it. */
|
|
20
|
-
function Row({ mark, title, line, children, last }) {
|
|
21
|
-
return (_jsxs(XStack, { minH:
|
|
26
|
+
function Row({ mark, title, line, children, last, }) {
|
|
27
|
+
return (_jsxs(XStack, { minH: 52, px: 13, py: 9, gap: 11, items: "center", borderBottomWidth: last ? 0 : 1, borderColor: LINE, children: [mark, _jsxs(YStack, { flex: 1, minW: 0, children: [_jsx(Text, { ...CLIP, fontSize: 14, lineHeight: 19, color: INK, children: title }), line ? (_jsx(Text, { ...CLIP, fontSize: 13, lineHeight: 18, color: DIM, children: line })) : null] }), children] }));
|
|
28
|
+
}
|
|
29
|
+
function VoiceRow({ label, value, options, onSelect, last, }) {
|
|
30
|
+
return (_jsxs(XStack, { minH: 44, px: 14, items: "center", justify: "space-between", borderBottomWidth: last ? 0 : 1, borderColor: LINE, children: [_jsx(Text, { fontSize: 14, lineHeight: 19, color: INK, children: label }), _jsxs(DropdownMenu, { placement: "bottom-end", offset: 6, children: [_jsx(DropdownMenuTrigger, { asChild: true, children: _jsxs(XStack, { render: "button", type: 'button', items: "center", gap: 5, px: 6, py: 4, rounded: 6, bg: "transparent", borderWidth: 0, cursor: "pointer", hoverStyle: { bg: PICKED }, children: [_jsx(Text, { fontSize: 14, lineHeight: 19, color: INK, children: value }), _jsx(ChevronDown, { size: 14, color: DIM, "aria-hidden": true })] }) }), _jsx(DropdownMenuContent, { minW: 160, "aria-label": label, children: options.map((opt) => (_jsx(DropdownMenuItem, { onSelect: () => onSelect(opt), children: _jsx(Text, { fontSize: "$3", color: "$ink", fontWeight: opt === value ? '600' : '400', children: opt }) }, opt))) })] })] }));
|
|
31
|
+
}
|
|
32
|
+
function ComputerScreen({ awake }) {
|
|
33
|
+
return (_jsx(YStack, { "aria-hidden": true, width: 56, height: 36, rounded: 9, shrink: 0, items: "center", justify: "center", position: "relative", overflow: "hidden", bg: PICKED, borderWidth: 1, borderColor: LINE, children: awake ? (_jsx(YStack, { width: 10, height: 10, rounded: 999, bg: "var(--state-online)" })) : (_jsxs(_Fragment, { children: [_jsx(Text, { position: "absolute", t: 2, r: 6, fontSize: 9, lineHeight: 10, fontWeight: "600", color: DIM, children: "z" }), _jsxs("svg", { width: "20", height: "18", viewBox: "0 0 20 18", fill: "none", "aria-hidden": "true", children: [_jsx("path", { d: "M10 16.2C10 16.2 2.5 11.4 2.5 6.3C2.5 3.8 4.4 2 6.7 2C8.1 2 9.3 2.7 10 3.8C10.7 2.7 11.9 2 13.3 2C15.6 2 17.5 3.8 17.5 6.3C17.5 11.4 10 16.2 10 16.2Z", fill: "currentColor", opacity: "0.34" }), _jsx("circle", { cx: "8.1", cy: "7.9", r: "0.9", fill: "var(--pane-fill, var(--card))" }), _jsx("circle", { cx: "11.9", cy: "7.9", r: "0.9", fill: "var(--pane-fill, var(--card))" })] })] })) }));
|
|
22
34
|
}
|
|
23
35
|
/** A computer's state as a person reads it. No lease is a computer asleep. */
|
|
24
36
|
function state(box, t) {
|
|
@@ -30,13 +42,12 @@ function state(box, t) {
|
|
|
30
42
|
return t('Waking');
|
|
31
43
|
return box.error || t('Stopped');
|
|
32
44
|
}
|
|
33
|
-
/** The computer to draw: a running one first, then one waking, then any. */
|
|
34
45
|
const best = (boxes) => boxes.find((b) => b.status === 'running') ?? boxes.find((b) => b.status === 'pending') ?? boxes[0] ?? null;
|
|
35
|
-
/** How often a waking computer is asked whether it is awake. */
|
|
36
46
|
const POLL = 5000;
|
|
37
|
-
export function Panel({ bot, onClose, kept, onSchedule, onDelete, focus = false, }) {
|
|
47
|
+
export function Panel({ bot, runs = [], onClose, kept, onSchedule, onDelete, focus = false, }) {
|
|
38
48
|
const { t, locale } = useI18n();
|
|
39
49
|
const { client } = useAi();
|
|
50
|
+
const [tab, setTab] = useState('activity');
|
|
40
51
|
const [instructions, setInstructions] = useState('');
|
|
41
52
|
const [answers, setAnswers] = useState([]);
|
|
42
53
|
const [box, setBox] = useState(null);
|
|
@@ -45,9 +56,12 @@ export function Panel({ bot, onClose, kept, onSchedule, onDelete, focus = false,
|
|
|
45
56
|
const [saving, setSaving] = useState(false);
|
|
46
57
|
const [wrong, setWrong] = useState(null);
|
|
47
58
|
const [deleting, setDeleting] = useState(false);
|
|
48
|
-
|
|
49
|
-
|
|
59
|
+
const [voiceName, setVoiceName] = useKept('hanzo.bots.voice.name', 'Liora');
|
|
60
|
+
const [voiceSpeed, setVoiceSpeed] = useKept('hanzo.bots.voice.speed', '1x');
|
|
61
|
+
const [voiceLang, setVoiceLang] = useKept('hanzo.bots.voice.lang', 'Auto-detect');
|
|
62
|
+
const displayName = called(bot.name);
|
|
50
63
|
const cron = bot.schedule || kept;
|
|
64
|
+
const activeSchedule = bot.executionMode === ALWAYS && Boolean(bot.schedule);
|
|
51
65
|
const survey = useCallback(async (signal) => {
|
|
52
66
|
if (!client)
|
|
53
67
|
return;
|
|
@@ -70,10 +84,12 @@ export function Panel({ bot, onClose, kept, onSchedule, onDelete, focus = false,
|
|
|
70
84
|
const bound = await Promise.allSettled(connected.map((n) => answering(client, n.id, signal)));
|
|
71
85
|
if (signal?.aborted)
|
|
72
86
|
return;
|
|
73
|
-
setAnswers(connected
|
|
87
|
+
setAnswers(connected
|
|
88
|
+
.filter((_, i) => {
|
|
74
89
|
const r = bound[i];
|
|
75
90
|
return r.status === 'fulfilled' && r.value.default === bot.name;
|
|
76
|
-
})
|
|
91
|
+
})
|
|
92
|
+
.map((n) => n.id));
|
|
77
93
|
}
|
|
78
94
|
}, [client, bot.name]);
|
|
79
95
|
useEffect(() => {
|
|
@@ -81,7 +97,6 @@ export function Panel({ bot, onClose, kept, onSchedule, onDelete, focus = false,
|
|
|
81
97
|
void survey(stop.signal);
|
|
82
98
|
return () => stop.abort();
|
|
83
99
|
}, [survey]);
|
|
84
|
-
// A waking computer is asked again until it is awake or says why it is not.
|
|
85
100
|
useEffect(() => {
|
|
86
101
|
if (!client || box?.status !== 'pending')
|
|
87
102
|
return;
|
|
@@ -97,28 +112,23 @@ export function Panel({ bot, onClose, kept, onSchedule, onDelete, focus = false,
|
|
|
97
112
|
stop.abort();
|
|
98
113
|
};
|
|
99
114
|
}, [client, box?.status, bot.name]);
|
|
100
|
-
/**
|
|
101
|
-
* Asleep, a press wakes it; awake, a press opens its screen in a new tab. The
|
|
102
|
-
* tab is opened inside the press, before the grant answers, because a browser
|
|
103
|
-
* allows a new window only from the press itself.
|
|
104
|
-
*/
|
|
105
115
|
const computer = async () => {
|
|
106
116
|
if (!client || busy)
|
|
107
117
|
return;
|
|
108
118
|
setBusy(true);
|
|
109
119
|
setWrong(null);
|
|
110
|
-
const
|
|
120
|
+
const win = box?.status === 'running' ? window.open('', '_blank') : null;
|
|
111
121
|
try {
|
|
112
122
|
if (box?.status === 'running') {
|
|
113
123
|
const g = await grant(client, box.id, box.class === 'desktop' ? 'screen' : 'terminal');
|
|
114
|
-
if (!
|
|
124
|
+
if (!win)
|
|
115
125
|
return setWrong(t('The browser kept the new tab from opening.'));
|
|
116
126
|
if (!g.url?.startsWith('https://')) {
|
|
117
|
-
|
|
127
|
+
win.close();
|
|
118
128
|
return setWrong(t('The platform opened no window onto it.'));
|
|
119
129
|
}
|
|
120
|
-
|
|
121
|
-
|
|
130
|
+
win.opener = null;
|
|
131
|
+
win.location.href = g.url;
|
|
122
132
|
}
|
|
123
133
|
else if (!box || box.status === 'error') {
|
|
124
134
|
await client.sandboxes.lease({ class: 'desktop', project: disk(bot.name) });
|
|
@@ -126,24 +136,52 @@ export function Panel({ bot, onClose, kept, onSchedule, onDelete, focus = false,
|
|
|
126
136
|
}
|
|
127
137
|
}
|
|
128
138
|
catch (e) {
|
|
129
|
-
|
|
130
|
-
setWrong(say(e, t('{name}’s computer', { name:
|
|
139
|
+
win?.close();
|
|
140
|
+
setWrong(say(e, t('{name}’s computer', { name: displayName }), 'save', t));
|
|
131
141
|
}
|
|
132
142
|
finally {
|
|
133
143
|
setBusy(false);
|
|
134
144
|
}
|
|
135
145
|
};
|
|
136
|
-
const routine = cron ? instructions.split('\n')[0].trim() ||
|
|
137
|
-
|
|
146
|
+
const routine = cron ? bot.description || instructions.split('\n')[0].trim() || displayName : '';
|
|
147
|
+
const scheduleLine = cron
|
|
148
|
+
? activeSchedule
|
|
149
|
+
? words(cron, locale, t)
|
|
150
|
+
: cron === 'paused'
|
|
151
|
+
? t('Paused')
|
|
152
|
+
: `${t('Paused')} · ${words(cron, locale, t)}`
|
|
153
|
+
: '';
|
|
154
|
+
const libraryItems = useMemo(() => {
|
|
155
|
+
const items = [];
|
|
156
|
+
for (const r of runs) {
|
|
157
|
+
for (const blob of [r.input, r.output]) {
|
|
158
|
+
if (!blob)
|
|
159
|
+
continue;
|
|
160
|
+
for (const [idx, part] of partsOf(blob).entries()) {
|
|
161
|
+
if (part.kind === 'doc') {
|
|
162
|
+
items.push({ key: `${r.id}-${idx}-${part.name}`, kind: 'doc', label: part.name, sub: part.size, href: part.href });
|
|
163
|
+
}
|
|
164
|
+
else if (part.kind === 'image') {
|
|
165
|
+
items.push({ key: `${r.id}-${idx}-img`, kind: 'image', label: part.alt || t('Preview image'), href: part.src });
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
return items.reverse();
|
|
171
|
+
}, [runs, t]);
|
|
172
|
+
return (_jsxs(YStack, { flex: 1, minH: 0, overflowY: "auto", overflowX: "hidden", "aria-label": displayName, render: "aside", children: [_jsx(XStack, { height: 58, shrink: 0, px: 14, items: "center", justify: "flex-end", children: _jsx(XStack, { ...ROUND, "aria-label": t('Close'), onClick: onClose, autoFocus: focus, children: _jsx(X, { size: 16, color: INK, "aria-hidden": true }) }) }), _jsxs(YStack, { items: "center", gap: 14, pt: 4, pb: 22, px: 16, children: [_jsx(Face, { bot: bot, size: 72 }), _jsx(Text, { ...CLIP, maxW: "100%", fontSize: 19, lineHeight: 24, fontWeight: "600", color: INK, children: displayName }), _jsx(XStack, { "data-parity-key": "bots.panel.tabs", role: "tablist", p: 3, rounded: 999, bg: RAISED, borderWidth: 1, borderColor: LINE, gap: 2, children: ['activity', 'library'].map((id) => {
|
|
173
|
+
const selected = tab === id;
|
|
174
|
+
return (_jsx(XStack, { render: "button", type: 'button', role: 'tab', 'aria-selected': selected, onClick: () => setTab(id), height: 28, px: 14, rounded: 999, items: "center", justify: "center", bg: selected ? PICKED : 'transparent', borderWidth: 0, cursor: "pointer", children: _jsx(Text, { fontSize: 13, lineHeight: 18, fontWeight: selected ? '500' : '400', color: selected ? INK : DIM, children: id === 'activity' ? t('Activity') : t('Library') }) }, id));
|
|
175
|
+
}) })] }), tab === 'activity' ? (_jsxs(YStack, { px: 15, pb: 24, gap: 20, children: [cron || answers.length ? (_jsxs(YStack, { gap: 10, "data-parity-key": "bots.panel.upcoming", children: [_jsx(Text, { ...LABEL, px: 4, children: t('Upcoming') }), cron ? (_jsx(YStack, { ...CARD, children: _jsx(Row, { mark: _jsx(Clock, { size: 16, color: DIM, "aria-hidden": true }), title: routine, line: scheduleLine, last: true, children: _jsx(Switch, { "aria-label": t('Run {name} on its schedule', { name: displayName }), checked: activeSchedule, disabled: saving, onCheckedChange: (on) => {
|
|
138
176
|
setWrong(null);
|
|
139
177
|
setSaving(true);
|
|
140
|
-
onSchedule(on, cron)
|
|
141
|
-
.catch((e) => setWrong(say(e, t('{name}’s schedule', { name:
|
|
178
|
+
onSchedule(on, cron === 'paused' ? '0 9 * * *' : cron)
|
|
179
|
+
.catch((e) => setWrong(say(e, t('{name}’s schedule', { name: displayName }), 'save', t)))
|
|
142
180
|
.finally(() => setSaving(false));
|
|
143
|
-
} }) }) })
|
|
181
|
+
} }) }) })) : null, answers.length ? (_jsx(YStack, { ...CARD, "data-parity-key": "bots.panel.networks", children: answers.map((id, i) => (_jsx(Row, { mark: _jsx(Network, { transport: id, size: 18 }), title: of(id).name, line: t('Connected'), last: i === answers.length - 1, children: _jsx(ChevronRight, { size: 15, color: DIM, "aria-hidden": true }) }, id))) })) : null] })) : null, boxed ? (_jsxs(YStack, { gap: 10, "data-parity-key": "bots.panel.computer", children: [_jsx(Text, { ...LABEL, px: 4, children: t('Computer') }), _jsxs(XStack, { ...CARD, render: "button", type: 'button', onClick: computer, disabled: busy || box?.status === 'pending', "aria-label": t(box?.status === 'running' ? 'Open {name}’s computer' : 'Wake {name}’s computer', { name: displayName }), minH: 60, px: 13, py: 10, items: "center", gap: 12, cursor: "pointer", hoverStyle: { bg: PICKED }, children: [_jsxs(YStack, { flex: 1, minW: 0, items: "flex-start", children: [_jsx(Text, { ...CLIP, fontSize: 14, lineHeight: 19, color: INK, children: t("Bot's computer") }), _jsx(Text, { ...CLIP, fontSize: 13, lineHeight: 18, color: DIM, children: busy ? t('Waking') : state(box, t) })] }), _jsx(ComputerScreen, { awake: box?.status === 'running' })] })] })) : null, _jsxs(YStack, { gap: 10, "data-parity-key": "bots.panel.voice", children: [_jsx(Text, { ...LABEL, px: 4, children: t('Voice chat') }), _jsxs(YStack, { ...CARD, children: [_jsx(VoiceRow, { label: t('Voice'), value: voiceName, options: VOICES, onSelect: setVoiceName }), _jsx(VoiceRow, { label: t('Speed'), value: voiceSpeed, options: SPEEDS, onSelect: setVoiceSpeed }), _jsx(VoiceRow, { label: t('Language'), value: voiceLang, options: LANGUAGES, onSelect: setVoiceLang, last: true })] })] }), wrong ? (_jsx(Text, { render: "p", role: "alert", px: 8, m: 0, fontSize: 13, lineHeight: 18, color: DIM, children: wrong })) : null, _jsx(XStack, { px: 8, pt: 4, children: _jsx(Text, { render: "button", type: 'button', onClick: () => setDeleting(true), bg: "transparent", borderWidth: 0, p: 0, cursor: "pointer", fontSize: 13, lineHeight: 18, color: DIM, hoverStyle: { color: INK }, children: t('Delete {name}', { name: displayName }) }) })] })) : (_jsx(YStack, { px: 15, pb: 24, gap: 12, "data-parity-key": "bots.panel.library", children: libraryItems.length ? (_jsx(YStack, { ...CARD, children: libraryItems.map((item, i) => (_jsx(Row, { mark: item.kind === 'doc' ? _jsx(FileText, { size: 16, color: DIM, "aria-hidden": true }) : _jsx(ImageIcon, { size: 16, color: DIM, "aria-hidden": true }), title: item.label, line: item.sub, last: i === libraryItems.length - 1, children: item.href ? _jsx(ChevronRight, { size: 15, color: DIM, "aria-hidden": true }) : null }, item.key))) })) : (_jsx(YStack, { ...CARD, px: 14, py: 16, items: "center", children: _jsx(Text, { fontSize: 13, lineHeight: 19, color: DIM, text: "center", children: t('Files, documents, and images shared with {name} appear here.', { name: displayName }) }) })) })), _jsx(Dialog, { open: deleting, onOpenChange: setDeleting, children: _jsxs(DialogContent, { maxW: 440, rounded: 20, gap: 14, children: [_jsx(DialogTitle, { children: t('Delete {name}?', { name: displayName }) }), _jsx(Text, { fontSize: 15, lineHeight: 22, color: DIM, children: t('{name} and every message it was sent are deleted for good.', { name: displayName }) }), _jsxs(XStack, { gap: 8, justify: "flex-end", children: [_jsx(Button, { size: "sm", variant: "outline", rounded: 999, onPress: () => setDeleting(false), children: t('Cancel') }), _jsx(XStack, { ...PILL, height: 34, bg: INK, borderColor: INK, hoverStyle: { bg: INK, opacity: 0.9 }, onClick: () => {
|
|
144
182
|
if (!deleting)
|
|
145
183
|
return;
|
|
146
184
|
setDeleting(false);
|
|
147
|
-
onDelete().catch((e) => setWrong(say(e,
|
|
185
|
+
onDelete().catch((e) => setWrong(say(e, displayName, 'save', t)));
|
|
148
186
|
}, children: _jsx(Text, { ...WORD, color: "var(--background)", children: t('Delete') }) })] })] }) })] }));
|
|
149
187
|
}
|
package/dist/bots/Roster.js
CHANGED
|
@@ -1,21 +1,20 @@
|
|
|
1
1
|
'use client';
|
|
2
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
-
// The roster: search and new at the top, the bots as a grid of faces, the
|
|
4
|
-
// as rows with the last thing each said, and the reader
|
|
5
|
-
//
|
|
6
|
-
|
|
7
|
-
// a face does not move once you know where it is. A bot past the twelfth is a
|
|
8
|
-
// row, newest conversation first, which is where a bot you are busy with is.
|
|
9
|
-
import { useMemo, useState } from 'react';
|
|
2
|
+
import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
// The roster: search and new at the top, the bots as a 3x4 grid of faces, the
|
|
4
|
+
// rest as rows with the last thing each said, and the reader + Preferences at
|
|
5
|
+
// the foot.
|
|
6
|
+
import { useEffect, useMemo, useState } from 'react';
|
|
10
7
|
import { useI18n } from '@hanzo/i18n/react';
|
|
11
8
|
import { Input, Text, XStack, YStack } from '@hanzo/gui';
|
|
12
9
|
import { DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuLabel, DropdownMenuSeparator, DropdownMenuTrigger, } from '@hanzo/ui';
|
|
13
10
|
import { BUSINESS_APPS } from '@hanzo/ui/product';
|
|
14
|
-
import {
|
|
11
|
+
import { Grid2x2Plus, Plus, Search, SlidersHorizontal, X } from 'lucide-react';
|
|
15
12
|
import { useSignOut } from '../lib/signout.js';
|
|
13
|
+
import { PreferencesDialog } from '../PreferencesDialog.js';
|
|
14
|
+
import { called, member } from '../team.js';
|
|
16
15
|
import { Face } from './face.js';
|
|
17
16
|
import { CLIP, PILL, ROUND, WORD } from './kit.js';
|
|
18
|
-
import { DIM, INK, LINE, PICKED, RAISED } from './ink.js';
|
|
17
|
+
import { DIM, FLOOR, INK, LINE, PICKED, RAISED } from './ink.js';
|
|
19
18
|
import { lastWord, split } from './grid.js';
|
|
20
19
|
export function Roster({ bots, last, open, unread, me, onPick, onMake, disabled, }) {
|
|
21
20
|
const { t } = useI18n();
|
|
@@ -24,27 +23,46 @@ export function Roster({ bots, last, open, unread, me, onPick, onMake, disabled,
|
|
|
24
23
|
const shown = useMemo(() => {
|
|
25
24
|
const q = query.trim().toLowerCase();
|
|
26
25
|
const all = bots ?? [];
|
|
27
|
-
return q
|
|
26
|
+
return q
|
|
27
|
+
? all.filter((b) => b.name.toLowerCase().includes(q) ||
|
|
28
|
+
called(b.name).toLowerCase().includes(q) ||
|
|
29
|
+
(b.description ?? '').toLowerCase().includes(q))
|
|
30
|
+
: all;
|
|
28
31
|
}, [bots, query]);
|
|
29
32
|
const { grid, rows } = useMemo(() => split(shown, last), [shown, last]);
|
|
30
|
-
return (_jsxs(YStack, { flex: 1, minH: 0, children: [_jsxs(XStack, { "data-parity-key": "bots.roster.bar", height: 58, shrink: 0, px: 16, items: "center", justify: "flex-end", gap:
|
|
33
|
+
return (_jsxs(YStack, { flex: 1, minH: 0, position: "relative", children: [_jsxs(XStack, { "data-parity-key": "bots.roster.bar", height: 58, shrink: 0, px: 16, items: "center", justify: "flex-end", gap: 10, children: [_jsx(XStack, { ...ROUND, "aria-label": t(seeking ? 'Close search' : 'Search bots'), "aria-pressed": seeking, onClick: () => {
|
|
31
34
|
setSeeking(!seeking);
|
|
32
35
|
setQuery('');
|
|
33
|
-
}, children: seeking ? _jsx(X, { size: 16, color: INK, "aria-hidden": true }) : _jsx(Search, { size: 16, color: INK, "aria-hidden": true }) }), _jsx(XStack, { ...ROUND, "aria-label": t('New bot'), onClick: onMake, disabled: disabled, opacity: disabled ? 0.5 : 1, children: _jsx(Plus, { size: 18, color: INK, "aria-hidden": true }) })] }), seeking ? (_jsx(XStack, { px: 12, pb: 10, shrink: 0, children: _jsx(Input, { unstyled: true, autoFocus: true, value: query, onChange: (e) => setQuery(e.target.value), placeholder: t('Search'), "aria-label": t('Search bots'), width: "100%", height: 36, px: 14, rounded: 999, bg: RAISED, borderWidth: 1, borderColor: LINE, color: INK, fontSize:
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
36
|
+
}, children: seeking ? _jsx(X, { size: 16, color: INK, "aria-hidden": true }) : _jsx(Search, { size: 16, color: INK, "aria-hidden": true }) }), _jsx(XStack, { ...ROUND, "aria-label": t('New bot'), onClick: onMake, disabled: disabled, opacity: disabled ? 0.5 : 1, children: _jsx(Plus, { size: 18, color: INK, "aria-hidden": true }) })] }), seeking ? (_jsx(XStack, { px: 12, pb: 10, shrink: 0, children: _jsx(Input, { unstyled: true, autoFocus: true, value: query, onChange: (e) => setQuery(e.target.value), placeholder: t('Search'), "aria-label": t('Search bots'), width: "100%", height: 36, px: 14, rounded: 999, bg: RAISED, borderWidth: 1, borderColor: LINE, color: INK, fontSize: 14, placeholderTextColor: "$placeholderColor" }) })) : null, _jsxs(YStack, { flex: 1, minH: 0, position: "relative", children: [_jsxs(YStack, { flex: 1, minH: 0, overflowY: "auto", overflowX: "hidden", children: [unread ? (_jsx(Text, { render: "p", px: 18, py: 10, fontSize: 13, lineHeight: 18, color: DIM, children: unread })) : null, bots && bots.length === 0 && !unread && !disabled ? (_jsxs(YStack, { display: "none", "$max-md": { display: 'flex' }, items: "center", gap: 16, pt: 160, px: 24, children: [_jsx(Text, { render: "h1", m: 0, fontSize: 22, lineHeight: 28, fontWeight: "500", color: INK, children: t('Make your first bot') }), _jsx(XStack, { ...PILL, onClick: onMake, children: _jsx(Text, { ...WORD, children: t('New bot') }) })] })) : null, grid.length ? (_jsx(XStack, { "data-parity-key": "bots.grid", role: "group", "aria-label": t('Bots'), flexWrap: "wrap", px: 11, pt: 6, columnGap: 3, rowGap: 12, "$max-md": { px: 12, columnGap: 0, justify: 'space-between' }, children: grid.map((b) => {
|
|
37
|
+
const here = b.name === open;
|
|
38
|
+
const label = called(b.name);
|
|
39
|
+
return (_jsxs(YStack, { render: "button", type: 'button', "data-parity-key": "bots.tile", "data-name": b.name, "aria-current": here, "aria-label": label, onClick: () => onPick(b.name), width: 83, height: 92, rounded: 12, items: "center", pt: 6, gap: 6, bg: here ? PICKED : 'transparent', borderWidth: 0, cursor: "pointer", hoverStyle: { bg: here ? PICKED : 'var(--rail-hover, var(--muted))' }, focusVisibleStyle: { outlineWidth: 2, outlineStyle: 'solid', outlineColor: '$outlineColor' }, "$max-md": { width: '33%' }, children: [_jsx(Face, { bot: b, size: 60, starred: member(b.name)?.seat === 1 }), _jsx(Text, { ...CLIP, maxW: 77, fontSize: 13, lineHeight: 17, fontWeight: here ? '500' : '400', color: INK, children: label })] }, b.id || b.name));
|
|
40
|
+
}) })) : null, rows.length ? (_jsx(YStack, { "data-parity-key": "bots.rows", role: "group", "aria-label": t('More bots'), pt: 16, pb: 22, children: rows.map((b) => {
|
|
41
|
+
const here = b.name === open;
|
|
42
|
+
const label = called(b.name);
|
|
43
|
+
const word = lastWord(last.get(b.name)) || b.description || '';
|
|
44
|
+
return (_jsxs(XStack, { render: "button", type: 'button', "data-parity-key": "bots.row", "data-name": b.name, "aria-current": here, onClick: () => onPick(b.name), height: 56, mx: 6, px: 12, gap: 10, items: "center", rounded: 10, bg: here ? PICKED : 'transparent', borderWidth: 0, cursor: "pointer", hoverStyle: { bg: here ? PICKED : 'var(--rail-hover, var(--muted))' }, focusVisibleStyle: { outlineWidth: 2, outlineStyle: 'solid', outlineColor: '$outlineColor' }, children: [_jsx(Face, { bot: b, size: 36 }), _jsxs(YStack, { flex: 1, minW: 0, items: "flex-start", children: [_jsx(Text, { ...CLIP, maxW: "100%", fontSize: 14, lineHeight: 19, fontWeight: "500", color: INK, children: label }), word ? (_jsx(Text, { ...CLIP, maxW: "100%", fontSize: 13, lineHeight: 18, color: DIM, children: word })) : null] })] }, b.id || b.name));
|
|
45
|
+
}) })) : null] }), rows.length ? (_jsx(YStack, { "aria-hidden": true, pointerEvents: "none", position: "absolute", l: 0, r: 0, b: 0, height: 28, "$platform-web": { backgroundImage: `linear-gradient(to bottom, transparent, ${FLOOR})` } })) : null] }), _jsx(Foot, { me: me })] }));
|
|
41
46
|
}
|
|
42
|
-
/** You, at the foot: your account,
|
|
47
|
+
/** You, at the foot: your account, Hanzo apps, and unified Hanzo Preferences. */
|
|
43
48
|
function Foot({ me }) {
|
|
44
49
|
const { t } = useI18n();
|
|
45
50
|
const leave = useSignOut();
|
|
51
|
+
const [prefsOpen, setPrefsOpen] = useState(false);
|
|
46
52
|
const name = me?.displayName || me?.name || '';
|
|
53
|
+
useEffect(() => {
|
|
54
|
+
if (!me)
|
|
55
|
+
return;
|
|
56
|
+
const onKey = (e) => {
|
|
57
|
+
if ((e.metaKey || e.ctrlKey) && e.key === ',') {
|
|
58
|
+
e.preventDefault();
|
|
59
|
+
setPrefsOpen(true);
|
|
60
|
+
}
|
|
61
|
+
};
|
|
62
|
+
window.addEventListener('keydown', onKey);
|
|
63
|
+
return () => window.removeEventListener('keydown', onKey);
|
|
64
|
+
}, [me]);
|
|
47
65
|
if (!me)
|
|
48
66
|
return null;
|
|
49
|
-
return (_jsxs(XStack, { "data-parity-key": "bots.me", height:
|
|
67
|
+
return (_jsxs(_Fragment, { children: [_jsxs(XStack, { "data-parity-key": "bots.me", height: 64, shrink: 0, px: 14, items: "center", gap: 8, children: [_jsxs(DropdownMenu, { placement: "top-start", offset: 8, children: [_jsx(DropdownMenuTrigger, { asChild: true, children: _jsxs(XStack, { render: "button", type: 'button', "aria-label": t('Account: {name}', { name }), flex: 1, minW: 0, items: "center", gap: 10, bg: "transparent", borderWidth: 0, p: 0, cursor: "pointer", children: [_jsx(Face, { bot: { name, avatar: me.avatar }, size: 34, person: true }), _jsx(Text, { ...CLIP, fontSize: 14, lineHeight: 19, fontWeight: "500", color: INK, children: name })] }) }), _jsxs(DropdownMenuContent, { minW: 240, "aria-label": t('Account'), children: [_jsx(DropdownMenuLabel, { children: _jsxs(YStack, { minW: 0, gap: 2, children: [_jsx(Text, { fontSize: "$3", color: "$ink", numberOfLines: 1, children: name }), me.email ? (_jsx(Text, { fontSize: "$2", color: "$soft", numberOfLines: 1, children: me.email })) : null] }) }), _jsx(DropdownMenuSeparator, {}), _jsx(DropdownMenuItem, { onSelect: () => setPrefsOpen(true), children: _jsx(Text, { fontSize: "$3", color: "$ink", children: t('Preferences') }) }), _jsx(DropdownMenuItem, { onSelect: () => void leave(), children: _jsx(Text, { fontSize: "$3", color: "$ink", children: t('Log out') }) })] })] }), _jsxs(DropdownMenu, { placement: "top-end", offset: 8, children: [_jsx(DropdownMenuTrigger, { asChild: true, children: _jsx(XStack, { ...ROUND, "aria-label": t('Hanzo apps'), children: _jsx(Grid2x2Plus, { size: 16, color: INK, "aria-hidden": true }) }) }), _jsx(DropdownMenuContent, { minW: 240, maxH: 420, "aria-label": t('Hanzo apps'), children: BUSINESS_APPS.map((app) => (_jsx(DropdownMenuItem, { onSelect: () => window.location.assign(app.href), children: _jsxs(YStack, { minW: 0, children: [_jsx(Text, { fontSize: "$3", color: "$ink", numberOfLines: 1, children: app.productTitle }), _jsx(Text, { fontSize: "$1", color: "$soft", numberOfLines: 1, children: app.description })] }) }, app.id))) })] }), _jsx(XStack, { ...ROUND, "aria-label": t('Preferences'), onClick: () => setPrefsOpen(true), children: _jsx(SlidersHorizontal, { size: 15, color: INK, "aria-hidden": true }) })] }), _jsx(PreferencesDialog, { open: prefsOpen, onOpenChange: setPrefsOpen })] }));
|
|
50
68
|
}
|
package/dist/bots/Thread.d.ts
CHANGED
|
@@ -10,7 +10,6 @@ export declare function Thread({ bot, bots, runs, pending, notice, wrong, side,
|
|
|
10
10
|
wrong: string | null;
|
|
11
11
|
side: boolean;
|
|
12
12
|
live: boolean;
|
|
13
|
-
/** The roster has answered, so an empty one is an empty org and not a slow one. */
|
|
14
13
|
loaded: boolean;
|
|
15
14
|
onSend: (input: string) => Promise<boolean>;
|
|
16
15
|
onDismiss: () => void;
|
package/dist/bots/Thread.js
CHANGED
|
@@ -1,11 +1,8 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
-
// The thread with the open bot:
|
|
4
|
-
//
|
|
5
|
-
//
|
|
6
|
-
// A message is a run the platform recorded: your words are its input, the bot's
|
|
7
|
-
// its output (or the error its model returned). A run another bot asked for is
|
|
8
|
-
// marked as that bot's message. Nothing here is drawn that the runs do not say.
|
|
3
|
+
// The thread with the open bot: floating frosted bot pill and circular Share
|
|
4
|
+
// button over the scrolling messages, structured attachment/image cards,
|
|
5
|
+
// timestamps wherever the conversation paused, and the pill composer.
|
|
9
6
|
import { useEffect, useMemo, useRef, useState } from 'react';
|
|
10
7
|
import { navigable } from '@hanzo/ui/product/limits';
|
|
11
8
|
import { useI18n } from '@hanzo/i18n/react';
|
|
@@ -14,18 +11,27 @@ import { Text, XStack, YStack } from '@hanzo/gui';
|
|
|
14
11
|
import { Caret } from '@hanzo/ui/chat';
|
|
15
12
|
import { Composer, Control, Field } from '@hanzo/composer';
|
|
16
13
|
import { speech, useDictation, useVoice, Voice } from '@hanzo/voice';
|
|
17
|
-
import { ArrowLeft, ArrowUp, Gauge, Mic, Plus, X } from 'lucide-react';
|
|
14
|
+
import { ArrowLeft, ArrowUp, AudioLines, Check, Gauge, Mic, Plus, Share, X } from 'lucide-react';
|
|
18
15
|
import { base } from '../lib/ai.js';
|
|
19
16
|
import { Prose } from '../Prose.js';
|
|
17
|
+
import { called } from '../team.js';
|
|
20
18
|
import { Face } from './face.js';
|
|
21
19
|
import { CLIP, PILL, ROUND, WORD } from './kit.js';
|
|
22
|
-
import { DIM, EDGE, INK, LINE, MINE, RAISED } from './ink.js';
|
|
20
|
+
import { DIM, EDGE, GROUND, INK, LINE, MINE, RAISED } from './ink.js';
|
|
23
21
|
import { instant } from './time.js';
|
|
24
|
-
import { lines } from './said.js';
|
|
22
|
+
import { lines, partsOf } from './said.js';
|
|
25
23
|
import { compose, fits, MAX, texty } from './carry.js';
|
|
26
24
|
import { PARAM } from './api.js';
|
|
27
25
|
/** The widest a conversation reads, as the desktop app draws it. */
|
|
28
|
-
const MEASURE =
|
|
26
|
+
const MEASURE = 900;
|
|
27
|
+
function DocBadge({ ext }) {
|
|
28
|
+
const accent = ext === 'pdf'
|
|
29
|
+
? 'var(--destructive)'
|
|
30
|
+
: ext === 'ppt' || ext === 'pptx'
|
|
31
|
+
? 'var(--warning, var(--chrome-dot-yellow))'
|
|
32
|
+
: 'var(--info, var(--muted-foreground))';
|
|
33
|
+
return (_jsxs(YStack, { "aria-hidden": true, width: 40, height: 44, shrink: 0, rounded: 9, overflow: "hidden", bg: "var(--secondary)", borderWidth: 1, borderColor: LINE, children: [_jsxs(YStack, { flex: 1, px: 7, pt: 7, gap: 4, justify: "center", children: [_jsxs(XStack, { gap: 3, children: [_jsx(YStack, { width: 9, height: 9, rounded: 2, bg: "var(--muted-foreground)", opacity: 0.4 }), _jsxs(YStack, { flex: 1, gap: 3, justify: "center", children: [_jsx(YStack, { height: 3, rounded: 2, bg: "var(--muted-foreground)", opacity: 0.4 }), _jsx(YStack, { height: 3, width: "75%", rounded: 2, bg: "var(--muted-foreground)", opacity: 0.3 })] })] }), _jsx(YStack, { height: 3, rounded: 2, bg: "var(--muted-foreground)", opacity: 0.34 })] }), _jsx(YStack, { height: 12, bg: accent })] }));
|
|
34
|
+
}
|
|
29
35
|
/** "It resets in 3 days." from the instant a refusal lifts, in the reader's calendar days. */
|
|
30
36
|
function lifts(iso, now, t) {
|
|
31
37
|
const at = instant(iso ?? undefined);
|
|
@@ -46,14 +52,11 @@ export function Thread({ bot, bots, runs, pending, notice, wrong, side, live, lo
|
|
|
46
52
|
const [note, setNote] = useState(null);
|
|
47
53
|
const foot = useRef(null);
|
|
48
54
|
const pick = useRef(null);
|
|
49
|
-
// Dictation through Hanzo's own ear, as Chat's composer does: each pause is
|
|
50
|
-
// transcribed and lands after what the draft already held.
|
|
51
55
|
const { token } = useIamToken();
|
|
52
56
|
const ear = useMemo(() => speech({ ...base(), ...(token ? { token } : {}) }), [token]);
|
|
53
57
|
const voice = useVoice({ speech: ear, ...useDictation(draft, setDraft) });
|
|
54
58
|
const now = Date.now();
|
|
55
59
|
const said = useMemo(() => (bot ? lines(runs ?? [], bots, bot.name, pending, now, locale, t) : []),
|
|
56
|
-
// `now` moves every render; the stamps only need it when the thread does.
|
|
57
60
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
58
61
|
[bot, runs, bots, pending, locale, t]);
|
|
59
62
|
useEffect(() => {
|
|
@@ -64,7 +67,7 @@ export function Thread({ bot, bots, runs, pending, notice, wrong, side, live, lo
|
|
|
64
67
|
setFile(null);
|
|
65
68
|
setNote(null);
|
|
66
69
|
}, [bot?.name]);
|
|
67
|
-
|
|
70
|
+
const displayName = bot ? called(bot.name) : '';
|
|
68
71
|
const share = async () => {
|
|
69
72
|
if (!bot)
|
|
70
73
|
return;
|
|
@@ -74,20 +77,18 @@ export function Thread({ bot, bots, runs, pending, notice, wrong, side, live, lo
|
|
|
74
77
|
const nav = navigator;
|
|
75
78
|
try {
|
|
76
79
|
if (nav.share && window.matchMedia('(pointer: coarse)').matches)
|
|
77
|
-
await nav.share({ url: link, title:
|
|
80
|
+
await nav.share({ url: link, title: displayName });
|
|
78
81
|
else
|
|
79
82
|
await navigator.clipboard.writeText(link);
|
|
80
83
|
setShared(t('Link copied'));
|
|
81
84
|
}
|
|
82
85
|
catch (e) {
|
|
83
|
-
// A share the reader closed is not a failure; a copy the browser refused is.
|
|
84
86
|
if (e?.name === 'AbortError')
|
|
85
87
|
return;
|
|
86
88
|
setShared(t('Copy failed'));
|
|
87
89
|
}
|
|
88
90
|
window.setTimeout(() => setShared(null), 2000);
|
|
89
91
|
};
|
|
90
|
-
// A text file goes with the message, held beside the draft until it is sent.
|
|
91
92
|
const carry = async (picked) => {
|
|
92
93
|
setNote(null);
|
|
93
94
|
try {
|
|
@@ -111,35 +112,49 @@ export function Thread({ bot, bots, runs, pending, notice, wrong, side, live, lo
|
|
|
111
112
|
setDraft('');
|
|
112
113
|
setFile(null);
|
|
113
114
|
setNote(null);
|
|
114
|
-
void onSend(input).then((
|
|
115
|
-
|
|
116
|
-
if (said)
|
|
115
|
+
void onSend(input).then((ok) => {
|
|
116
|
+
if (ok)
|
|
117
117
|
return;
|
|
118
118
|
setDraft((d) => d || words);
|
|
119
119
|
setFile((f) => f ?? held);
|
|
120
120
|
});
|
|
121
121
|
};
|
|
122
|
-
|
|
122
|
+
const hasDraft = Boolean(draft.trim() || file);
|
|
123
|
+
return (_jsxs(YStack, { flex: 1, minH: 0, position: "relative", children: [_jsxs(XStack, { "data-parity-key": "bots.bar", position: "absolute", t: 0, l: 0, r: 0, z: 4, height: 58, px: 14, items: "center", gap: 8, pointerEvents: "none", "$platform-web": {
|
|
124
|
+
backgroundImage: `linear-gradient(to bottom, ${GROUND} 18%, color-mix(in srgb, ${GROUND} 68%, transparent) 64%, transparent)`,
|
|
125
|
+
}, children: [_jsx(XStack, { flex: 1, minW: 0, items: "center", children: _jsx(XStack, { ...ROUND, pointerEvents: "auto", "aria-label": t('All bots'), onClick: onBack, display: "none", "$max-md": { display: 'flex' }, children: _jsx(ArrowLeft, { size: 16, color: INK, "aria-hidden": true, "data-i18n-mirror": true }) }) }), bot ? (_jsxs(XStack, { ...PILL, pointerEvents: "auto", "data-parity-key": "bots.pill", "aria-label": t('{name}’s details', { name: displayName }), "aria-expanded": side, onClick: onSide, height: 36, pl: 6, pr: 13, maxW: "60%", bg: RAISED, "$platform-web": { backdropFilter: 'blur(16px)', WebkitBackdropFilter: 'blur(16px)' }, children: [_jsx(Face, { bot: bot, size: 24 }), _jsx(Text, { ...WORD, ...CLIP, children: displayName })] })) : null, _jsx(XStack, { flex: 1, minW: 0, items: "center", justify: "flex-end", children: bot ? (_jsx(XStack, { ...ROUND, pointerEvents: "auto", "data-parity-key": "bots.share", "aria-label": shared ?? t('Share'), onClick: share, "$platform-web": { backdropFilter: 'blur(16px)', WebkitBackdropFilter: 'blur(16px)' }, children: shared ? _jsx(Check, { size: 15, color: INK, "aria-hidden": true }) : _jsx(Share, { size: 15, color: INK, "aria-hidden": true }) })) : null })] }), !bot ? (_jsx(YStack, { flex: 1, items: "center", justify: "center", gap: 16, px: 24, children: live && loaded && bots.length === 0 ? (_jsxs(_Fragment, { children: [_jsx(Text, { render: "h1", m: 0, fontSize: 22, lineHeight: 28, fontWeight: "500", color: INK, children: t('Make your first bot') }), _jsx(XStack, { ...PILL, onClick: onMake, children: _jsx(Text, { ...WORD, children: t('New bot') }) })] })) : null })) : (_jsx(YStack, { "data-parity-key": "bots.thread", flex: 1, minH: 0, overflowY: "auto", overflowX: "hidden", children: _jsxs(YStack, { width: "100%", maxW: MEASURE + 48, mx: "auto", px: 24, pt: 64, pb: 18, "$max-md": { px: 12 }, children: [said.map((line, i) => {
|
|
123
126
|
const prev = said[i - 1];
|
|
124
|
-
const gap = !prev ? 0 : line.kind === prev.kind && (line.kind === 'mine' || line.kind === 'theirs') ?
|
|
127
|
+
const gap = !prev ? 0 : line.kind === prev.kind && (line.kind === 'mine' || line.kind === 'theirs') ? 6 : 16;
|
|
125
128
|
if (line.kind === 'stamp')
|
|
126
|
-
return (_jsx(Text, { self: "center", mt: i ? 22 :
|
|
129
|
+
return (_jsx(Text, { self: "center", mt: i ? 22 : 6, mb: 4, fontSize: 12, lineHeight: 17, color: DIM, children: line.text }, line.key));
|
|
127
130
|
if (line.kind === 'from')
|
|
128
|
-
return (_jsxs(XStack, { self: "center", mt: gap, items: "center", gap: 6, children: [_jsx(Text, { fontSize:
|
|
131
|
+
return (_jsxs(XStack, { self: "center", mt: gap, items: "center", gap: 6, children: [_jsx(Text, { fontSize: 12, lineHeight: 17, color: DIM, children: t('Message from') }), _jsx(Face, { bot: line.bot, size: 16 }), _jsx(Text, { fontSize: 12, lineHeight: 17, color: DIM, children: called(line.bot.name) })] }, line.key));
|
|
129
132
|
if (line.kind === 'mine')
|
|
130
|
-
return (_jsx(YStack, { self: "flex-end", items: "flex-end", maxW: "78%", mt: gap, children: _jsx(Text, { "data-parity-key": "bots.mine", render: "div", px:
|
|
133
|
+
return (_jsx(YStack, { self: "flex-end", items: "flex-end", maxW: "78%", mt: gap, children: _jsx(Text, { "data-parity-key": "bots.mine", render: "div", px: 14, py: 8, rounded: 18, fontSize: 15, lineHeight: 22, color: INK, whiteSpace: "pre-wrap", "$platform-web": { overflowWrap: 'anywhere', backgroundColor: MINE }, children: line.text }) }, line.key));
|
|
131
134
|
if (line.kind === 'thinking')
|
|
132
|
-
return (_jsx(XStack, { "data-parity-key": "bots.thinking", role: "status", "aria-label": t('{name} is working', { name:
|
|
133
|
-
|
|
134
|
-
|
|
135
|
+
return (_jsx(XStack, { "data-parity-key": "bots.thinking", role: "status", "aria-label": t('{name} is working', { name: displayName }), self: "flex-start", mt: gap, px: 14, height: 38, items: "center", rounded: 16, bg: RAISED, borderWidth: 1, borderColor: LINE, children: _jsx(Caret, {}) }, line.key));
|
|
136
|
+
if (line.kind === 'theirs' && line.failed)
|
|
137
|
+
return (_jsx(YStack, { "data-parity-key": "bots.theirs", self: "flex-start", maxW: 520, mt: gap, px: 15, py: 11, rounded: 18, bg: RAISED, borderWidth: 1, borderColor: LINE, "$max-md": { maxW: '88%' }, children: _jsx(Text, { fontSize: 15, lineHeight: 22, color: DIM, children: line.text }) }, line.key));
|
|
138
|
+
const parts = partsOf(line.text);
|
|
139
|
+
return (_jsx(YStack, { "data-parity-key": line.kind === 'other' ? 'bots.other' : 'bots.theirs', self: "flex-start", items: "flex-start", gap: 10, maxW: "100%", mt: gap, children: parts.map((part, idx) => {
|
|
140
|
+
if (part.kind === 'doc') {
|
|
141
|
+
const inner = (_jsxs(XStack, { px: 12, py: 10, gap: 12, items: "center", rounded: 16, bg: RAISED, borderWidth: 1, borderColor: LINE, maxW: 290, children: [_jsx(DocBadge, { ext: part.ext }), _jsxs(YStack, { flex: 1, minW: 0, children: [_jsx(Text, { ...CLIP, fontSize: 14, lineHeight: 19, fontWeight: "500", color: INK, children: part.name }), part.size ? (_jsx(Text, { fontSize: 12, lineHeight: 17, color: DIM, children: part.size })) : null] })] }));
|
|
142
|
+
return part.href ? (_jsx(YStack, { render: "a", href: part.href, target: '_blank', rel: 'noopener noreferrer', "$platform-web": { textDecoration: 'none' }, children: inner }, idx)) : (_jsx(YStack, { children: inner }, idx));
|
|
143
|
+
}
|
|
144
|
+
if (part.kind === 'image') {
|
|
145
|
+
return (_jsx(YStack, { width: 172, rounded: 14, overflow: "hidden", bg: RAISED, borderWidth: 1, borderColor: LINE, children: _jsx(YStack, { render: "img", src: part.src, alt: part.alt, width: "100%", height: "auto", display: "block" }) }, idx));
|
|
146
|
+
}
|
|
147
|
+
return (_jsx(YStack, { maxW: 520, px: 15, py: 11, rounded: 18, bg: RAISED, borderWidth: 1, borderColor: LINE, "$max-md": { maxW: '88%' }, children: _jsx(Prose, { text: part.text }) }, idx));
|
|
148
|
+
}) }, line.key));
|
|
149
|
+
}), wrong ? (_jsx(Text, { render: "p", self: "center", mt: 12, fontSize: 13, lineHeight: 18, color: DIM, children: wrong })) : null, _jsx("div", { ref: foot })] }) })), bot ? (_jsxs(YStack, { width: "100%", maxW: MEASURE + 48, mx: "auto", px: 20, pb: 14, gap: 8, shrink: 0, "$max-md": { px: 8, pb: 8 }, children: [notice ? (_jsxs(YStack, { "data-parity-key": "bots.notice", role: "alert", bg: RAISED, borderWidth: 1, borderColor: LINE, rounded: 16, pt: 12, pb: 10, px: 14, gap: 10, children: [_jsxs(XStack, { items: "flex-start", gap: 10, children: [_jsx(YStack, { pt: 3, children: _jsx(Gauge, { size: 16, color: DIM, "aria-hidden": true }) }), _jsxs(YStack, { flex: 1, minW: 0, children: [_jsx(Text, { fontSize: 15, lineHeight: 22, color: INK, children: notice.message }), lifts(notice.resets, now, t) ? (_jsx(Text, { fontSize: 15, lineHeight: 22, color: DIM, children: lifts(notice.resets, now, t) })) : null] }), _jsx(XStack, { ...ROUND, width: 28, height: 28, bg: "transparent", borderWidth: 0, "aria-label": t('Dismiss'), onClick: onDismiss, children: _jsx(X, { size: 14, color: DIM, "aria-hidden": true }) })] }), notice.actions.some(navigable) ? (_jsx(XStack, { justify: "flex-end", gap: 8, flexWrap: "wrap", children: notice.actions.filter(navigable).map((a, i, all) => (_jsx(XStack, { ...PILL, render: "a", href: a.url, height: 34, bg: i === all.length - 1 ? INK : RAISED, borderColor: i === all.length - 1 ? INK : LINE, "$platform-web": { textDecoration: 'none' }, children: _jsx(Text, { ...WORD, color: i === all.length - 1 ? 'var(--background)' : INK, children: a.label }) }, `${a.kind}-${a.label}`))) })) : null] })) : null, file ? (_jsxs(XStack, { self: "flex-start", items: "center", gap: 6, height: 30, pl: 12, pr: 4, rounded: 999, bg: RAISED, borderWidth: 1, borderColor: LINE, children: [_jsx(Text, { ...CLIP, maxW: 260, fontSize: 13, lineHeight: 18, color: INK, children: file.name }), _jsx(XStack, { ...ROUND, width: 24, height: 24, bg: "transparent", borderWidth: 0, "aria-label": t('Remove {name}', { name: file.name }), onClick: () => setFile(null), children: _jsx(X, { size: 12, color: DIM, "aria-hidden": true }) })] })) : null, note ? (_jsx(Text, { role: "alert", fontSize: 13, lineHeight: 18, color: DIM, px: 8, children: note })) : null, _jsx(Composer, { render: "form", onSubmit: (e) => {
|
|
135
150
|
e.preventDefault();
|
|
136
151
|
submit();
|
|
137
|
-
}, control: 32, width: "100%", children: _jsxs(XStack, { "data-parity-key": "bots.composer", height:
|
|
152
|
+
}, control: 32, width: "100%", children: _jsxs(XStack, { "data-parity-key": "bots.composer", height: 46, pl: 7, pr: 7, gap: 6, items: "center", rounded: 999, bg: RAISED, borderWidth: 1, borderColor: EDGE, focusWithinStyle: { borderColor: 'var(--ring)' }, children: [_jsx(Control, { type: "button", "aria-label": t('Add a text file'), onClick: () => pick.current?.click(), disabled: !live, children: _jsx(Plus, { size: 16 }) }), _jsx(Field, { value: draft, onChangeText: setDraft, onKeyDown: (e) => {
|
|
138
153
|
if (e.key === 'Enter' && !e.shiftKey && !e.nativeEvent?.isComposing) {
|
|
139
154
|
e.preventDefault();
|
|
140
155
|
submit();
|
|
141
156
|
}
|
|
142
|
-
}, placeholder: t('Message {name}', { name:
|
|
157
|
+
}, placeholder: t('Message {name}', { name: displayName }), "aria-label": t('Message {name}', { name: displayName }), disabled: !live, fontSize: 15, px: 4 }), _jsx(Control, { asChild: true, children: _jsx(Voice, { voice: voice, disabled: !live, children: (state) => _jsx(Mic, { size: 15, fill: state === 'idle' ? 'none' : 'currentColor' }) }) }), hasDraft ? (_jsx(Control, { type: "submit", "aria-label": t('Send'), fill: true, disabled: !live || Boolean(pending), children: _jsx(ArrowUp, { size: 15, strokeWidth: 2.5 }) })) : (_jsx(Voice, { voice: voice, disabled: !live, children: () => (_jsx(XStack, { width: 32, height: 32, rounded: 999, items: "center", justify: "center", bg: INK, opacity: live ? 1 : 0.45, children: _jsx(AudioLines, { size: 15, color: "var(--background)", strokeWidth: 2.2, "aria-hidden": true }) })) }))] }) }), _jsx("input", { ref: pick, type: "file", hidden: true, accept: "text/*,.md,.txt,.csv,.json,.yaml,.yml,.tsv,.log", onChange: (e) => {
|
|
143
158
|
const picked = e.target.files?.[0];
|
|
144
159
|
e.target.value = '';
|
|
145
160
|
if (picked)
|
package/dist/bots/face.d.ts
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import type { Agent } from '@hanzo/ai';
|
|
2
|
-
export declare function Face({ bot, size }: {
|
|
2
|
+
export declare function Face({ bot, size, person, starred, }: {
|
|
3
3
|
bot: Pick<Agent, 'name' | 'avatar' | 'emoji'>;
|
|
4
4
|
size?: number;
|
|
5
|
+
person?: boolean;
|
|
6
|
+
starred?: boolean;
|
|
5
7
|
}): import("react").JSX.Element;
|
package/dist/bots/face.js
CHANGED
|
@@ -1,13 +1,17 @@
|
|
|
1
1
|
'use client';
|
|
2
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
3
|
import { Text, YStack } from '@hanzo/gui';
|
|
4
|
-
import {
|
|
5
|
-
|
|
4
|
+
import { Star } from 'lucide-react';
|
|
5
|
+
import { roleOf } from '../cast.js';
|
|
6
|
+
import { called } from '../team.js';
|
|
7
|
+
import { FLOOR, INK } from './ink.js';
|
|
8
|
+
export function Face({ bot, size = 36, person = false, starred = false, }) {
|
|
6
9
|
const round = { width: size, height: size, shrink: 0, rounded: 9999, overflow: 'hidden' };
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
// The glyph scales with the disc, so its size is a number of pixels rather
|
|
10
|
-
// than a rung; the leading is the size itself, which centres it.
|
|
10
|
+
const src = bot.avatar || (!person ? roleOf(bot.name)?.portrait : undefined);
|
|
11
|
+
const label = person ? (bot.name || '') : called(bot.name || '');
|
|
11
12
|
const glyph = Math.round(size * (bot.emoji ? 0.5 : 0.42));
|
|
12
|
-
|
|
13
|
+
const disc = src ? (_jsx(YStack, { render: "img", src, alt: '', "aria-hidden": true, ...round, objectFit: "cover" })) : (_jsx(YStack, { "aria-hidden": true, ...round, items: "center", justify: "center", bg: person ? 'var(--info, var(--secondary))' : 'var(--secondary)', userSelect: 'none', children: _jsx(Text, { color: person ? 'var(--pure-white, var(--foreground))' : INK, fontSize: glyph, lineHeight: glyph, fontWeight: "600", children: bot.emoji || (label || '?').trim().charAt(0).toUpperCase() }) }));
|
|
14
|
+
if (!starred)
|
|
15
|
+
return disc;
|
|
16
|
+
return (_jsxs(YStack, { position: "relative", width: size, height: size, shrink: 0, children: [disc, _jsx(YStack, { "aria-hidden": true, position: "absolute", r: -1, b: -1, width: 20, height: 20, rounded: 9999, items: "center", justify: "center", bg: "var(--warning, var(--chrome-dot-yellow))", borderWidth: 2, borderColor: FLOOR, children: _jsx(Star, { size: 10, color: "var(--pure-white, var(--foreground))", fill: "currentColor", strokeWidth: 2 }) })] }));
|
|
13
17
|
}
|
package/dist/bots/grid.d.ts
CHANGED
|
@@ -3,7 +3,7 @@ import type { Agent, AgentRun } from '@hanzo/ai';
|
|
|
3
3
|
export declare const GRID = 12;
|
|
4
4
|
/** What a row says under a bot's name: its newest run's last word. */
|
|
5
5
|
export declare function lastWord(run: AgentRun | undefined): string;
|
|
6
|
-
/** The bots in the grid and the
|
|
6
|
+
/** The bots in the grid (lead seat order first, then creation order) and the rest in rows. */
|
|
7
7
|
export declare function split(bots: readonly Agent[], last: ReadonlyMap<string, AgentRun>): {
|
|
8
8
|
grid: Agent[];
|
|
9
9
|
rows: Agent[];
|
package/dist/bots/grid.js
CHANGED
|
@@ -1,17 +1,32 @@
|
|
|
1
1
|
// Which bots are faces in the grid and which are rows, and what a row says.
|
|
2
2
|
// Pure, so the roster's order is tested as data.
|
|
3
|
+
import { member } from '../team.js';
|
|
3
4
|
import { instant } from './time.js';
|
|
4
5
|
/** How many bots the grid holds before the rest become rows. */
|
|
5
6
|
export const GRID = 12;
|
|
7
|
+
const LEAD_ORDER = new Map(['vi', 'opera', 'mana', 'dev', 'des', 'fin', 'huma', 'mark', 'sal', 'sci', 'su', 'cyber'].map((id, i) => [id, i]));
|
|
8
|
+
function rankOf(name) {
|
|
9
|
+
const lead = LEAD_ORDER.get(name.toLowerCase());
|
|
10
|
+
if (lead !== undefined)
|
|
11
|
+
return lead;
|
|
12
|
+
const seat = member(name)?.seat;
|
|
13
|
+
return seat !== undefined ? 100 + seat : Number.MAX_SAFE_INTEGER;
|
|
14
|
+
}
|
|
6
15
|
/** What a row says under a bot's name: its newest run's last word. */
|
|
7
16
|
export function lastWord(run) {
|
|
8
17
|
if (!run)
|
|
9
18
|
return '';
|
|
10
19
|
return (run.output || run.error || run.input || '').replace(/\s+/g, ' ').trim();
|
|
11
20
|
}
|
|
12
|
-
/** The bots in the grid and the
|
|
21
|
+
/** The bots in the grid (lead seat order first, then creation order) and the rest in rows. */
|
|
13
22
|
export function split(bots, last) {
|
|
14
|
-
const made = [...bots].sort((a, b) =>
|
|
23
|
+
const made = [...bots].sort((a, b) => {
|
|
24
|
+
const sa = rankOf(a.name);
|
|
25
|
+
const sb = rankOf(b.name);
|
|
26
|
+
if (sa !== sb)
|
|
27
|
+
return sa - sb;
|
|
28
|
+
return (instant(a.createdAt) ?? 0) - (instant(b.createdAt) ?? 0);
|
|
29
|
+
});
|
|
15
30
|
const grid = made.slice(0, GRID);
|
|
16
31
|
const rows = made
|
|
17
32
|
.slice(GRID)
|
package/dist/bots/ink.d.ts
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
/** The roster's ground:
|
|
2
|
-
export declare const FLOOR = "var(--background)";
|
|
3
|
-
/** The thread's and the panel's ground. */
|
|
4
|
-
export declare const GROUND = "var(--card)";
|
|
1
|
+
/** The roster's ground: matches hanzo.app and hanzo.team sidebar surface. */
|
|
2
|
+
export declare const FLOOR = "var(--side-fill, var(--background))";
|
|
3
|
+
/** The thread's and the panel's ground: matches hanzo.app and hanzo.team main canvas. */
|
|
4
|
+
export declare const GROUND = "var(--pane-fill, var(--card))";
|
|
5
5
|
/** What stands on the ground: the pills, the cards, the composer, a bot's message. */
|
|
6
6
|
export declare const RAISED = "var(--surface-card-emphasis)";
|
|
7
7
|
/** The bot that is open, in the roster. */
|
|
8
8
|
export declare const PICKED = "var(--secondary)";
|
|
9
9
|
/** Your own message: lighter than a bot's, in either theme. */
|
|
10
|
-
export declare const MINE = "color-mix(in oklab, var(--foreground)
|
|
10
|
+
export declare const MINE = "color-mix(in oklab, var(--foreground) 17%, var(--pane-fill, var(--card)))";
|
|
11
11
|
export declare const INK = "var(--foreground)";
|
|
12
12
|
export declare const DIM = "var(--muted-foreground)";
|
|
13
13
|
export declare const FAINT = "$faint";
|
|
14
|
-
export declare const LINE = "var(--border)";
|
|
14
|
+
export declare const LINE = "var(--pane-edge, var(--border))";
|
|
15
15
|
/** The composer's edge, the one control drawn a step louder. */
|
|
16
16
|
export declare const EDGE = "var(--border-strong)";
|
package/dist/bots/ink.js
CHANGED
|
@@ -1,28 +1,20 @@
|
|
|
1
1
|
// The ramp the Bots app is drawn in.
|
|
2
2
|
//
|
|
3
|
-
// Greyscale,
|
|
4
|
-
//
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
// Two grounds, as the window is drawn: the roster stands on the floor and the
|
|
10
|
-
// thread and the panel on the ground one step above it.
|
|
11
|
-
/** The roster's ground: the window itself. */
|
|
12
|
-
export const FLOOR = 'var(--background)';
|
|
13
|
-
/** The thread's and the panel's ground. */
|
|
14
|
-
export const GROUND = 'var(--card)';
|
|
3
|
+
// Greyscale, aligned to the shared Hanzo deep-black product family (--side-fill
|
|
4
|
+
// on the roster column, --pane-fill on the thread and inspector surfaces).
|
|
5
|
+
/** The roster's ground: matches hanzo.app and hanzo.team sidebar surface. */
|
|
6
|
+
export const FLOOR = 'var(--side-fill, var(--background))';
|
|
7
|
+
/** The thread's and the panel's ground: matches hanzo.app and hanzo.team main canvas. */
|
|
8
|
+
export const GROUND = 'var(--pane-fill, var(--card))';
|
|
15
9
|
/** What stands on the ground: the pills, the cards, the composer, a bot's message. */
|
|
16
10
|
export const RAISED = 'var(--surface-card-emphasis)';
|
|
17
11
|
/** The bot that is open, in the roster. */
|
|
18
12
|
export const PICKED = 'var(--secondary)';
|
|
19
13
|
/** Your own message: lighter than a bot's, in either theme. */
|
|
20
|
-
export const MINE = 'color-mix(in oklab, var(--foreground)
|
|
14
|
+
export const MINE = 'color-mix(in oklab, var(--foreground) 17%, var(--pane-fill, var(--card)))';
|
|
21
15
|
export const INK = 'var(--foreground)';
|
|
22
16
|
export const DIM = 'var(--muted-foreground)';
|
|
23
|
-
// The dimmest ink is gui's `$faint` rung: design's --text-tertiary is 4.32:1 on
|
|
24
|
-
// the light ground, under text's 4.5.
|
|
25
17
|
export const FAINT = '$faint';
|
|
26
|
-
export const LINE = 'var(--border)';
|
|
18
|
+
export const LINE = 'var(--pane-edge, var(--border))';
|
|
27
19
|
/** The composer's edge, the one control drawn a step louder. */
|
|
28
20
|
export const EDGE = 'var(--border-strong)';
|
package/dist/bots/kit.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/** A round icon control, 34px: the roster's search and new,
|
|
1
|
+
/** A round icon control, 34px: the roster's search and new, Share, Preferences, Close. */
|
|
2
2
|
export declare const ROUND: {
|
|
3
3
|
readonly render: 'button';
|
|
4
4
|
readonly type: 'button';
|
|
@@ -8,13 +8,13 @@ export declare const ROUND: {
|
|
|
8
8
|
readonly rounded: 999;
|
|
9
9
|
readonly bg: "var(--surface-card-emphasis)";
|
|
10
10
|
readonly borderWidth: 1;
|
|
11
|
-
readonly borderColor: "var(--border)";
|
|
11
|
+
readonly borderColor: "var(--pane-edge, var(--border))";
|
|
12
12
|
readonly items: 'center';
|
|
13
13
|
readonly justify: 'center';
|
|
14
14
|
readonly cursor: 'pointer';
|
|
15
15
|
readonly p: 0;
|
|
16
16
|
readonly hoverStyle: {
|
|
17
|
-
readonly bg:
|
|
17
|
+
readonly bg: "var(--secondary)";
|
|
18
18
|
};
|
|
19
19
|
readonly focusVisibleStyle: {
|
|
20
20
|
readonly outlineWidth: 2;
|
|
@@ -22,23 +22,23 @@ export declare const ROUND: {
|
|
|
22
22
|
readonly outlineColor: '$outlineColor';
|
|
23
23
|
};
|
|
24
24
|
};
|
|
25
|
-
/** A pill: the open bot in the bar,
|
|
25
|
+
/** A pill: the open bot in the bar, a notice's ways past. */
|
|
26
26
|
export declare const PILL: {
|
|
27
27
|
readonly render: 'button';
|
|
28
28
|
readonly type: 'button';
|
|
29
29
|
readonly display: 'flex';
|
|
30
30
|
readonly items: 'center';
|
|
31
31
|
readonly gap: 8;
|
|
32
|
-
readonly height:
|
|
33
|
-
readonly px:
|
|
32
|
+
readonly height: 36;
|
|
33
|
+
readonly px: 13;
|
|
34
34
|
readonly rounded: 999;
|
|
35
35
|
readonly bg: "var(--surface-card-emphasis)";
|
|
36
36
|
readonly borderWidth: 1;
|
|
37
|
-
readonly borderColor: "var(--border)";
|
|
37
|
+
readonly borderColor: "var(--pane-edge, var(--border))";
|
|
38
38
|
readonly cursor: 'pointer';
|
|
39
39
|
readonly shrink: 0;
|
|
40
40
|
readonly hoverStyle: {
|
|
41
|
-
readonly bg:
|
|
41
|
+
readonly bg: "var(--secondary)";
|
|
42
42
|
};
|
|
43
43
|
readonly focusVisibleStyle: {
|
|
44
44
|
readonly outlineWidth: 2;
|
|
@@ -48,8 +48,9 @@ export declare const PILL: {
|
|
|
48
48
|
};
|
|
49
49
|
/** A pill's words. */
|
|
50
50
|
export declare const WORD: {
|
|
51
|
-
readonly fontSize:
|
|
52
|
-
readonly lineHeight:
|
|
51
|
+
readonly fontSize: 14;
|
|
52
|
+
readonly lineHeight: 19;
|
|
53
|
+
readonly fontWeight: '500';
|
|
53
54
|
readonly color: "var(--foreground)";
|
|
54
55
|
readonly numberOfLines: 1;
|
|
55
56
|
};
|
|
@@ -66,8 +67,8 @@ export declare const LABEL: {
|
|
|
66
67
|
export declare const CARD: {
|
|
67
68
|
readonly bg: "var(--surface-card-emphasis)";
|
|
68
69
|
readonly borderWidth: 1;
|
|
69
|
-
readonly borderColor: "var(--border)";
|
|
70
|
-
readonly rounded:
|
|
70
|
+
readonly borderColor: "var(--pane-edge, var(--border))";
|
|
71
|
+
readonly rounded: 14;
|
|
71
72
|
};
|
|
72
73
|
/** One line, cut with an ellipsis where it runs out of space. */
|
|
73
74
|
export declare const CLIP: {
|
package/dist/bots/kit.js
CHANGED
|
@@ -1,25 +1,47 @@
|
|
|
1
1
|
// The controls the Bots app is drawn from, as gui props, stated once and spread
|
|
2
2
|
// where they are drawn.
|
|
3
|
-
import { DIM, INK, LINE, RAISED } from './ink.js';
|
|
4
|
-
/** A round icon control, 34px: the roster's search and new,
|
|
3
|
+
import { DIM, INK, LINE, PICKED, RAISED } from './ink.js';
|
|
4
|
+
/** A round icon control, 34px: the roster's search and new, Share, Preferences, Close. */
|
|
5
5
|
export const ROUND = {
|
|
6
|
-
render: 'button',
|
|
7
|
-
|
|
8
|
-
|
|
6
|
+
render: 'button',
|
|
7
|
+
type: 'button',
|
|
8
|
+
width: 34,
|
|
9
|
+
height: 34,
|
|
10
|
+
shrink: 0,
|
|
11
|
+
rounded: 999,
|
|
12
|
+
bg: RAISED,
|
|
13
|
+
borderWidth: 1,
|
|
14
|
+
borderColor: LINE,
|
|
15
|
+
items: 'center',
|
|
16
|
+
justify: 'center',
|
|
17
|
+
cursor: 'pointer',
|
|
18
|
+
p: 0,
|
|
19
|
+
hoverStyle: { bg: PICKED },
|
|
9
20
|
focusVisibleStyle: { outlineWidth: 2, outlineStyle: 'solid', outlineColor: '$outlineColor' },
|
|
10
21
|
};
|
|
11
|
-
/** A pill: the open bot in the bar,
|
|
22
|
+
/** A pill: the open bot in the bar, a notice's ways past. */
|
|
12
23
|
export const PILL = {
|
|
13
|
-
render: 'button',
|
|
14
|
-
|
|
15
|
-
|
|
24
|
+
render: 'button',
|
|
25
|
+
type: 'button',
|
|
26
|
+
display: 'flex',
|
|
27
|
+
items: 'center',
|
|
28
|
+
gap: 8,
|
|
29
|
+
height: 36,
|
|
30
|
+
px: 13,
|
|
31
|
+
rounded: 999,
|
|
32
|
+
bg: RAISED,
|
|
33
|
+
borderWidth: 1,
|
|
34
|
+
borderColor: LINE,
|
|
35
|
+
cursor: 'pointer',
|
|
36
|
+
shrink: 0,
|
|
37
|
+
hoverStyle: { bg: PICKED },
|
|
16
38
|
focusVisibleStyle: { outlineWidth: 2, outlineStyle: 'solid', outlineColor: '$outlineColor' },
|
|
17
39
|
};
|
|
18
40
|
/** A pill's words. */
|
|
19
|
-
export const WORD = { fontSize:
|
|
41
|
+
export const WORD = { fontSize: 14, lineHeight: 19, fontWeight: '500', color: INK, numberOfLines: 1 };
|
|
20
42
|
/** A section's heading in the panel. */
|
|
21
43
|
export const LABEL = { render: 'h3', fontSize: 13, lineHeight: 18, fontWeight: '400', color: DIM, m: 0 };
|
|
22
44
|
/** A card in the panel. */
|
|
23
|
-
export const CARD = { bg: RAISED, borderWidth: 1, borderColor: LINE, rounded:
|
|
45
|
+
export const CARD = { bg: RAISED, borderWidth: 1, borderColor: LINE, rounded: 14 };
|
|
24
46
|
/** One line, cut with an ellipsis where it runs out of space. */
|
|
25
47
|
export const CLIP = { whiteSpace: 'nowrap', overflow: 'hidden', textOverflow: 'ellipsis' };
|
package/dist/bots/said.d.ts
CHANGED
|
@@ -32,3 +32,19 @@ export type Line = {
|
|
|
32
32
|
};
|
|
33
33
|
/** The thread as lines: stamps where it paused, each run as the messages it holds. */
|
|
34
34
|
export declare function lines(runs: readonly AgentRun[], bots: readonly Agent[], self: string, pending: Pending | null, now: number, locale: string, t: (s: string, v?: Record<string, unknown>) => string): Line[];
|
|
35
|
+
export type MessagePart = {
|
|
36
|
+
kind: 'prose';
|
|
37
|
+
text: string;
|
|
38
|
+
} | {
|
|
39
|
+
kind: 'doc';
|
|
40
|
+
name: string;
|
|
41
|
+
size?: string;
|
|
42
|
+
href?: string;
|
|
43
|
+
ext: string;
|
|
44
|
+
} | {
|
|
45
|
+
kind: 'image';
|
|
46
|
+
alt: string;
|
|
47
|
+
src: string;
|
|
48
|
+
};
|
|
49
|
+
/** Splits a message into prose blocks, standalone document cards, and standalone preview images. */
|
|
50
|
+
export declare function partsOf(raw: string): MessagePart[];
|
package/dist/bots/said.js
CHANGED
|
@@ -41,3 +41,66 @@ export function lines(runs, bots, self, pending, now, locale, t) {
|
|
|
41
41
|
}
|
|
42
42
|
return out;
|
|
43
43
|
}
|
|
44
|
+
function formatBytes(bytes) {
|
|
45
|
+
if (bytes >= 1_048_576)
|
|
46
|
+
return `${(bytes / 1_048_576).toFixed(1)}MB`;
|
|
47
|
+
if (bytes >= 1024)
|
|
48
|
+
return `${Math.max(1, Math.round(bytes / 1024))}KB`;
|
|
49
|
+
return `${bytes}B`;
|
|
50
|
+
}
|
|
51
|
+
const DOC_EXT = /\.(pdf|pptx?|docx?|xlsx?|csv|zip|md|json|txt)$/i;
|
|
52
|
+
/** Splits a message into prose blocks, standalone document cards, and standalone preview images. */
|
|
53
|
+
export function partsOf(raw) {
|
|
54
|
+
const out = [];
|
|
55
|
+
const prose = [];
|
|
56
|
+
const flush = () => {
|
|
57
|
+
const joined = prose.join('\n').trim();
|
|
58
|
+
if (joined)
|
|
59
|
+
out.push({ kind: 'prose', text: joined });
|
|
60
|
+
prose.length = 0;
|
|
61
|
+
};
|
|
62
|
+
const fenceRe = /^(`{3,})([^\n`]+\.[a-z0-9]{2,5})\n([\s\S]*?)\n\1$/gm;
|
|
63
|
+
let cursor = 0;
|
|
64
|
+
for (const match of raw.matchAll(fenceRe)) {
|
|
65
|
+
const before = raw.slice(cursor, match.index ?? 0);
|
|
66
|
+
parseLines(before, out, prose, flush);
|
|
67
|
+
flush();
|
|
68
|
+
const name = match[2].trim();
|
|
69
|
+
const ext = (name.split('.').pop() ?? '').toLowerCase();
|
|
70
|
+
out.push({ kind: 'doc', name, size: formatBytes(new TextEncoder().encode(match[3]).length), ext });
|
|
71
|
+
cursor = (match.index ?? 0) + match[0].length;
|
|
72
|
+
}
|
|
73
|
+
parseLines(raw.slice(cursor), out, prose, flush);
|
|
74
|
+
flush();
|
|
75
|
+
return out.length ? out : [{ kind: 'prose', text: raw }];
|
|
76
|
+
}
|
|
77
|
+
function parseLines(chunk, out, prose, flush) {
|
|
78
|
+
for (const line of chunk.split('\n')) {
|
|
79
|
+
const trimmed = line.trim();
|
|
80
|
+
const img = /^!\[([^\]]*)\]\(([^)]+)\)$/.exec(trimmed);
|
|
81
|
+
if (img) {
|
|
82
|
+
flush();
|
|
83
|
+
out.push({ kind: 'image', alt: img[1], src: img[2] });
|
|
84
|
+
continue;
|
|
85
|
+
}
|
|
86
|
+
const link = /^\[([^\]]+)\]\(([^)]+)\)$/.exec(trimmed);
|
|
87
|
+
if (link) {
|
|
88
|
+
const label = link[1].trim();
|
|
89
|
+
const parts = label.split(/\s*[·•|]\s*/);
|
|
90
|
+
const filePart = parts[0].trim();
|
|
91
|
+
const extMatch = DOC_EXT.exec(filePart);
|
|
92
|
+
if (extMatch) {
|
|
93
|
+
flush();
|
|
94
|
+
out.push({
|
|
95
|
+
kind: 'doc',
|
|
96
|
+
name: filePart,
|
|
97
|
+
size: parts[1]?.trim(),
|
|
98
|
+
href: link[2].trim(),
|
|
99
|
+
ext: extMatch[1].toLowerCase(),
|
|
100
|
+
});
|
|
101
|
+
continue;
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
prose.push(line);
|
|
105
|
+
}
|
|
106
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hanzo/app",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.74",
|
|
4
4
|
"description": "Hanzo's app: the shell and its apps (Home, Chat, Inbox, Contacts, Meet, Calendar, Drive, Board, Work, Bots), once, for every Hanzo surface.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|