@hanzo/build 0.2.126 → 0.2.127
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/api/machines.d.ts +8 -0
- package/lib/api/machines.js +16 -5
- package/lib/api/places.d.ts +12 -4
- package/lib/api/places.js +11 -3
- package/lib/automations.js +74 -35
- package/lib/awake.d.ts +24 -0
- package/lib/awake.js +68 -0
- package/lib/clipboard.d.ts +2 -0
- package/lib/clipboard.js +10 -0
- package/lib/customize/agents.js +149 -31
- package/lib/customize/connectors.js +91 -34
- package/lib/customize/drafted.js +23 -10
- package/lib/customize/index.js +40 -10
- package/lib/customize/inventory.d.ts +4 -1
- package/lib/customize/inventory.js +66 -17
- package/lib/customize/plugins.js +43 -15
- package/lib/customize/skills.js +87 -23
- package/lib/customize/ui.d.ts +29 -3
- package/lib/customize/ui.js +89 -12
- package/lib/desk.d.ts +1 -1
- package/lib/desk.js +67 -40
- package/lib/dev-mode.d.ts +22 -0
- package/lib/dev-mode.js +80 -0
- package/lib/environment.js +4 -4
- package/lib/forge.js +97 -24
- package/lib/handoff.d.ts +8 -0
- package/lib/handoff.js +22 -0
- package/lib/index.d.ts +1 -0
- package/lib/index.js +1 -0
- package/lib/landing.js +100 -25
- package/lib/library.js +108 -39
- package/lib/make.js +3 -2
- package/lib/mind.d.ts +9 -29
- package/lib/mind.js +43 -4
- package/lib/pane.d.ts +13 -0
- package/lib/pane.js +4 -0
- package/lib/panel.d.ts +4 -0
- package/lib/panel.js +49 -46
- package/lib/plans.js +36 -15
- package/lib/project.js +72 -63
- package/lib/reply.d.ts +6 -1
- package/lib/reply.js +19 -9
- package/lib/run.js +23 -41
- package/lib/scheduled.js +36 -16
- package/lib/settings/account.js +2 -1
- package/lib/settings/billing.js +9 -4
- package/lib/settings/credits.d.ts +2 -1
- package/lib/settings/credits.js +2 -2
- package/lib/settings/machines.js +41 -18
- package/lib/settings/notifications.js +2 -1
- package/lib/shelf.d.ts +4 -1
- package/lib/shelf.js +79 -14
- package/lib/suggestions.js +2 -1
- package/lib/summary.js +3 -2
- package/lib/sync.js +3 -3
- package/lib/transcript.js +13 -6
- package/package.json +11 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
1
|
+
import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
/**
|
|
3
3
|
* Connectors: MCP servers whose tools an agent calls.
|
|
4
4
|
*
|
|
@@ -17,19 +17,26 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
17
17
|
*/
|
|
18
18
|
import { SizableText, XStack, YStack } from '@hanzo/gui';
|
|
19
19
|
import { useI18n } from '@hanzo/i18n/react';
|
|
20
|
-
import { ChevronDown, ExternalLink, KeyRound, Server as ServerIcon } from '@hanzogui/lucide-icons-2';
|
|
21
|
-
import { Button, Input, Switch } from '@hanzo/ui';
|
|
20
|
+
import { AlertCircle, Check, ChevronDown, ChevronUp, ExternalLink, KeyRound, Plug, Search, Server as ServerIcon, SlidersHorizontal, Trash2, X } from '@hanzogui/lucide-icons-2';
|
|
21
|
+
import { Button, DropdownMenu, Input, Switch } from '@hanzo/ui';
|
|
22
22
|
import { useEffect, useMemo, useState } from 'react';
|
|
23
23
|
import { add, one, owns, ready, remove, servers, shelf, titleOf } from '../api/connectors.js';
|
|
24
24
|
import { natives } from '../api/mcp.js';
|
|
25
25
|
import { toggle, tools } from '../api/tools.js';
|
|
26
|
+
import { RING, RING_INSET } from '../pane.js';
|
|
26
27
|
import { useHost, useTarget } from '../host.js';
|
|
27
28
|
import { Out } from '../out.js';
|
|
28
29
|
import { route } from '../route.js';
|
|
29
30
|
import { useLoad } from './load.js';
|
|
30
31
|
import { say } from './say.js';
|
|
31
|
-
import { Add, Confirm, Empty, Failed, Featured, Field,
|
|
32
|
+
import { Add, Confirm, Empty, Failed, Featured, Field, FilterPills, Grid, Mark, matches, MenuTrigger, Part, RowsSkeleton, Sheet, Soft, Tile, TilesSkeleton, useCount, Visitor } from './ui.js';
|
|
32
33
|
const PAGE = 48;
|
|
34
|
+
const BUILTIN_INITIAL = 6;
|
|
35
|
+
function StatusBanner({ notice }) {
|
|
36
|
+
if (!notice?.text)
|
|
37
|
+
return null;
|
|
38
|
+
return (_jsxs(XStack, { items: "center", gap: "$1.5", role: notice.error ? 'alert' : 'status', children: [notice.error ? _jsx(AlertCircle, { size: 14, color: "var(--state-error)", "aria-hidden": true }) : _jsx(Check, { size: 14, color: "var(--state-success)", "aria-hidden": true }), _jsx(SizableText, { size: "$1", color: notice.error ? 'var(--state-error)' : '$soft', flex: 1, minW: 0, children: notice.text })] }));
|
|
39
|
+
}
|
|
33
40
|
/** The part of a URL a person reads: its host and path. */
|
|
34
41
|
const where = (url) => url.replace(/^https?:\/\//, '').replace(/\/$/, '');
|
|
35
42
|
export function Connectors({ view, q, adding, onAdding, onView, onCount }) {
|
|
@@ -43,10 +50,11 @@ export function Connectors({ view, q, adding, onAdding, onView, onCount }) {
|
|
|
43
50
|
// Every server's tools, for the switch on each card; read once for all of them.
|
|
44
51
|
const plane = useLoad(signed && view === 'yours' && mine.value.length ? () => tools(target, { source: 'mcp' }) : null, [], [target, signed, view, mine.value]);
|
|
45
52
|
const [opened, setOpened] = useState(null);
|
|
53
|
+
const [removing, setRemoving] = useState(null);
|
|
46
54
|
const [listing, setListing] = useState(null);
|
|
47
55
|
const [connecting, setConnecting] = useState(null);
|
|
48
56
|
const [busy, setBusy] = useState('');
|
|
49
|
-
const [
|
|
57
|
+
const [notice, setNotice] = useState(null);
|
|
50
58
|
useCount(mine.value.length, onCount);
|
|
51
59
|
/** Switch every tool a server brings on or off at once, then read them again. */
|
|
52
60
|
const flip = async (s, next) => {
|
|
@@ -54,14 +62,14 @@ export function Connectors({ view, q, adding, onAdding, onView, onCount }) {
|
|
|
54
62
|
if (!its.length)
|
|
55
63
|
return;
|
|
56
64
|
setBusy(s.id);
|
|
57
|
-
|
|
65
|
+
setNotice(null);
|
|
58
66
|
try {
|
|
59
67
|
await toggle(target, next ? its : [], next ? [] : its);
|
|
60
68
|
plane.reload();
|
|
61
|
-
|
|
69
|
+
setNotice({ text: next ? t('{name} is on', { name: s.name }) : t('{name} is off', { name: s.name }) });
|
|
62
70
|
}
|
|
63
71
|
catch (e) {
|
|
64
|
-
|
|
72
|
+
setNotice({ text: say(e, t), error: true });
|
|
65
73
|
}
|
|
66
74
|
finally {
|
|
67
75
|
setBusy('');
|
|
@@ -75,20 +83,27 @@ export function Connectors({ view, q, adding, onAdding, onView, onCount }) {
|
|
|
75
83
|
onAdding(false);
|
|
76
84
|
mine.reload();
|
|
77
85
|
onView('yours');
|
|
78
|
-
|
|
86
|
+
setNotice({ text: said });
|
|
79
87
|
} })) : null;
|
|
80
88
|
const detail = listing ? (_jsx(About, { listing: listing, added: mine.value.some((s) => s.listing === listing.id), signed: may, onAdd: () => {
|
|
81
89
|
setConnecting(listing);
|
|
82
90
|
setListing(null);
|
|
83
91
|
}, onClose: () => setListing(null) })) : null;
|
|
92
|
+
const confirmRemove = removing ? (_jsx(Confirm, { what: removing.name, says: t('Its tools leave your organization and every agent, and its sealed secret is destroyed.'), open: true, onOpenChange: (o) => !o && setRemoving(null), onYes: async () => {
|
|
93
|
+
const gone = removing;
|
|
94
|
+
await remove(target, gone.id);
|
|
95
|
+
setRemoving(null);
|
|
96
|
+
mine.reload();
|
|
97
|
+
setNotice({ text: t('{name} is removed', { name: gone.name }) });
|
|
98
|
+
} })) : null;
|
|
84
99
|
if (view === 'discover') {
|
|
85
|
-
return (_jsxs(YStack, { gap: "$6", children: [_jsx(
|
|
100
|
+
return (_jsxs(YStack, { gap: "$6", children: [_jsx(StatusBanner, { notice: notice }), _jsx(Shelf, { q: q, signed: signed, may: may, added: new Set(mine.value.map((s) => s.listing).filter(Boolean)), onOpen: setListing, onAdd: setConnecting }), _jsx(Natives, { q: q }), detail, connect] }));
|
|
86
101
|
}
|
|
87
102
|
if (!signed) {
|
|
88
103
|
return _jsx(Visitor, { children: t('Sign in to see your connectors.') });
|
|
89
104
|
}
|
|
90
105
|
const shown = mine.value.filter((s) => matches(q, s.name, s.url, s.listing));
|
|
91
|
-
return (_jsxs(YStack, { gap: "$3", children: [_jsx(
|
|
106
|
+
return (_jsxs(YStack, { gap: "$3", children: [_jsx(StatusBanner, { notice: notice }), mine.error && !mine.value.length ? (_jsx(Failed, { error: mine.error, onRetry: mine.reload })) : mine.loading && !mine.value.length ? (_jsx(TilesSkeleton, { label: t('Loading your connectors'), count: 4 })) : !mine.value.length ? (_jsxs(Empty, { title: t('No connectors yet'), detail: may ? t('Connect an app from Browse, or add any MCP server by its URL.') : t('An org admin adds connectors. Browse what there is.'), children: [_jsx(Button, { size: "sm", variant: "outline", onPress: () => onView('discover'), children: t('Browse connectors') }), may ? (_jsx(Button, { size: "sm", onPress: () => onAdding(true), children: t('Add by URL') })) : null] })) : !shown.length ? (_jsx(Soft, { children: t('No connector of yours matches “{q}”.', { q: q.trim() }) })) : (_jsx(Grid, { label: t('Your connectors'), children: shown.map((s) => {
|
|
92
107
|
const its = plane.value.filter((x) => owns(s, x.name));
|
|
93
108
|
const lit = its.filter((x) => x.activated).length;
|
|
94
109
|
return (_jsx(Tile, { title: s.name, detail: where(s.url), meta: [
|
|
@@ -98,15 +113,34 @@ export function Connectors({ view, q, adding, onAdding, onView, onCount }) {
|
|
|
98
113
|
s.admitted ? '' : t('Not in runs until an admin adds it again'),
|
|
99
114
|
]
|
|
100
115
|
.filter(Boolean)
|
|
101
|
-
.join(' · '), mark: _jsx(Mark, { name: s.name }), onOpen: () => setOpened(s), action: may && its.length ? (_jsx(Switch, { checked: lit > 0, disabled: busy === s.id, onCheckedChange: (v) => void flip(s, v), "aria-label": t('{name} on', { name: s.name }) })) : its.length ? (_jsx(SizableText, { size: "$1", color: "$soft", children: lit ? t('On') : t('Off') })) :
|
|
102
|
-
|
|
116
|
+
.join(' · '), mark: _jsx(Mark, { name: s.name, icon: _jsx(Plug, { size: 15, color: "$soft", "aria-hidden": true }) }), onOpen: () => setOpened(s), action: _jsxs(XStack, { items: "center", gap: "$1.5", shrink: 0, children: [may && its.length ? (_jsx(Switch, { checked: lit > 0, disabled: busy === s.id, onCheckedChange: (v) => void flip(s, v), "aria-label": t('{name} on', { name: s.name }) })) : its.length ? (_jsx(SizableText, { size: "$1", color: "$soft", children: lit ? t('On') : t('Off') })) : null, _jsx(DropdownMenu, { placement: "bottom-end", offset: 6, trigger: _jsx(MenuTrigger, { label: t('Actions for {name}', { name: s.name }) }), items: [
|
|
117
|
+
{ key: 'inspect', label: t('Inspect tools'), icon: _jsx(SlidersHorizontal, { size: 15 }), onSelect: () => setOpened(s) },
|
|
118
|
+
...(may && its.length
|
|
119
|
+
? [
|
|
120
|
+
{
|
|
121
|
+
key: 'toggle',
|
|
122
|
+
label: lit > 0 ? t('Turn all off') : t('Turn all on'),
|
|
123
|
+
icon: _jsx(Check, { size: 15 }),
|
|
124
|
+
disabled: busy === s.id,
|
|
125
|
+
onSelect: () => void flip(s, lit === 0),
|
|
126
|
+
},
|
|
127
|
+
]
|
|
128
|
+
: []),
|
|
129
|
+
...(may
|
|
130
|
+
? [
|
|
131
|
+
{ type: 'separator' },
|
|
132
|
+
{ key: 'remove', label: t('Remove connector'), icon: _jsx(Trash2, { size: 15 }), destructive: true, onSelect: () => setRemoving(s) },
|
|
133
|
+
]
|
|
134
|
+
: []),
|
|
135
|
+
] })] }) }, s.id));
|
|
136
|
+
}) })), plane.error && mine.value.length ? _jsx(StatusBanner, { notice: { text: t('Tools: {reason}', { reason: say(plane.error, t) }), error: true } }) : null, opened ? (_jsx(Detail, { server: opened, may: may, onClose: () => {
|
|
103
137
|
setOpened(null);
|
|
104
138
|
plane.reload();
|
|
105
139
|
}, onDeleted: () => {
|
|
106
|
-
|
|
140
|
+
setNotice({ text: t('{name} is removed', { name: opened.name }) });
|
|
107
141
|
setOpened(null);
|
|
108
142
|
mine.reload();
|
|
109
|
-
} })) : null, connect] }));
|
|
143
|
+
} })) : null, confirmRemove, connect] }));
|
|
110
144
|
}
|
|
111
145
|
/** The shelf: featured first, then by name, a page at a time. The platform searches it. */
|
|
112
146
|
function Shelf({ q, signed, may, added, onOpen, onAdd }) {
|
|
@@ -115,6 +149,7 @@ function Shelf({ q, signed, may, added, onOpen, onAdd }) {
|
|
|
115
149
|
const text = useSettled(q.trim(), 300);
|
|
116
150
|
const first = useLoad(signed ? () => shelf(target, { text, limit: PAGE }) : null, null, [target, signed, text]);
|
|
117
151
|
const [more, setMore] = useState([]);
|
|
152
|
+
const [filter, setFilter] = useState('all');
|
|
118
153
|
const [paging, setPaging] = useState(false);
|
|
119
154
|
const [note, setNote] = useState('');
|
|
120
155
|
useEffect(() => setMore([]), [first.value]);
|
|
@@ -122,8 +157,9 @@ function Shelf({ q, signed, may, added, onOpen, onAdd }) {
|
|
|
122
157
|
return (_jsx(Part, { title: t('Connect an app'), detail: t('Give runs the tools you already use.'), children: _jsx(Visitor, { children: t('Sign in to browse connectors.') }) }));
|
|
123
158
|
}
|
|
124
159
|
const page = first.value;
|
|
125
|
-
const
|
|
126
|
-
const
|
|
160
|
+
const loaded = [...(page?.listings ?? []), ...more];
|
|
161
|
+
const list = loaded.filter((l) => (filter === 'hosted' ? ready(l) : filter === 'official' ? l.official : true));
|
|
162
|
+
const hero = !text && filter === 'all' ? list.find((l) => l.featured) : undefined;
|
|
127
163
|
const rest = hero ? list.filter((l) => l !== hero) : list;
|
|
128
164
|
// A listing that ships only as a package has no Add: its card says it needs a place to run.
|
|
129
165
|
const action = (l) => (may && ready(l) ? _jsx(Add, { name: titleOf(l), added: added.has(l.id), onPress: () => onAdd(l) }) : undefined);
|
|
@@ -131,7 +167,7 @@ function Shelf({ q, signed, may, added, onOpen, onAdd }) {
|
|
|
131
167
|
setPaging(true);
|
|
132
168
|
setNote('');
|
|
133
169
|
try {
|
|
134
|
-
const got = await shelf(target, { text, limit: PAGE, offset:
|
|
170
|
+
const got = await shelf(target, { text, limit: PAGE, offset: loaded.length });
|
|
135
171
|
setMore((m) => [...m, ...got.listings]);
|
|
136
172
|
}
|
|
137
173
|
catch (e) {
|
|
@@ -141,7 +177,19 @@ function Shelf({ q, signed, may, added, onOpen, onAdd }) {
|
|
|
141
177
|
setPaging(false);
|
|
142
178
|
}
|
|
143
179
|
};
|
|
144
|
-
return (_jsx(Part, { title: t('Connect an app'), detail: t('Give runs the tools you already use. Adding one turns its tools on for your organization.'), children: first.error && !page ? (_jsx(Failed, { error: first.error, onRetry: first.reload })) : !page ? (_jsx(
|
|
180
|
+
return (_jsx(Part, { title: t('Connect an app'), detail: t('Give runs the tools you already use. Adding one turns its tools on for your organization.'), children: first.error && !page ? (_jsx(Failed, { error: first.error, onRetry: first.reload })) : !page ? (_jsx(TilesSkeleton, { label: t('Loading connectors'), withHero: true })) : (_jsxs(YStack, { gap: "$3", children: [loaded.length > 0 ? (_jsx(FilterPills, { label: t('Filter connectors'), value: filter, options: [
|
|
181
|
+
{ id: 'all', label: t('All') },
|
|
182
|
+
{ id: 'hosted', label: t('Hosted') },
|
|
183
|
+
{ id: 'official', label: t('Official') },
|
|
184
|
+
], onChange: setFilter, maxVisibleDesktop: 6, mobileLimit: 4 })) : null, !list.length ? (_jsx(Soft, { action: filter !== 'all' ? (_jsx(Button, { size: "sm", variant: "outline", borderColor: "var(--border-strong)", onPress: () => setFilter('all'), children: t('Show all connectors') })) : undefined, children: text
|
|
185
|
+
? t('No connector matches “{q}”.', { q: text })
|
|
186
|
+
: filter !== 'all'
|
|
187
|
+
? t('No connectors in this view on the loaded page.')
|
|
188
|
+
: t('There are no connectors to add yet.') })) : (_jsxs(_Fragment, { children: [hero ? (_jsx(Featured, { title: titleOf(hero), detail: hero.description, meta: facts(hero, t), mark: _jsx(Mark, { name: titleOf(hero), logo: hero.logo, size: 48 }), onOpen: () => onOpen(hero), action: action(hero) })) : null, _jsx(SizableText, { size: "$1", color: "$soft", fontVariant: ['tabular-nums'], children: filter !== 'all'
|
|
189
|
+
? t('{shown} matching in {loaded} loaded', { shown: list.length, loaded: loaded.length })
|
|
190
|
+
: loaded.length < page.total
|
|
191
|
+
? t('{shown} of {n} connectors', { shown: loaded.length, n: page.total })
|
|
192
|
+
: t('{n} connectors', { n: page.total }) }), _jsx(Grid, { label: t('Servers on the shelf'), children: rest.map((l) => (_jsx(Tile, { title: titleOf(l), detail: l.description, meta: facts(l, t), mark: _jsx(Mark, { name: titleOf(l), logo: l.logo }), onOpen: () => onOpen(l), action: action(l) }, l.id))) }), note ? _jsx(StatusBanner, { notice: { text: note, error: true } }) : null, loaded.length < page.total ? (_jsx(XStack, { justify: "center", children: _jsx(Button, { size: "sm", variant: "outline", borderColor: "var(--border-strong)", disabled: paging, onPress: () => void next(), children: paging ? t('Loading…') : t('Show more') }) })) : null] }))] })) }));
|
|
145
193
|
}
|
|
146
194
|
/** The facts a card carries under its description, said in the reader's language. */
|
|
147
195
|
const facts = (l, t) => [l.vendor, l.official ? t('Official') : '', ready(l) ? t('Hosted') : t('Package only: needs a place to run')].filter(Boolean).join(' · ');
|
|
@@ -167,12 +215,15 @@ function Natives({ q }) {
|
|
|
167
215
|
const [asked, setAsked] = useState(r.kind === 'screen' && r.screen === 'mcp');
|
|
168
216
|
const list = useLoad(asked ? () => natives(target) : null, [], [target, asked]);
|
|
169
217
|
const [open, setOpen] = useState(null);
|
|
218
|
+
const [showAll, setShowAll] = useState(false);
|
|
170
219
|
const shown = list.value.filter((s) => matches(q, s.name, s.description, ...s.ops));
|
|
171
220
|
const ops = shown.reduce((n, s) => n + s.ops.length, 0);
|
|
172
|
-
|
|
221
|
+
const searching = Boolean(q.trim());
|
|
222
|
+
const visible = searching || showAll ? shown : shown.slice(0, BUILTIN_INITIAL);
|
|
223
|
+
return (_jsx(Part, { title: t('Built in'), detail: t('Hanzo’s own servers. Always on: every run can call them, and nothing needs adding.'), action: asked ? undefined : (_jsx(Button, { size: "sm", variant: "outline", onPress: () => setAsked(true), children: t('Show built-in servers') })), children: !asked ? null : list.loading && !list.value.length ? (_jsx(RowsSkeleton, { label: t('Loading built-in servers') })) : list.error && !list.value.length ? (_jsx(Failed, { error: list.error, onRetry: list.reload })) : !shown.length ? (_jsx(Soft, { children: list.value.length ? t('No built-in server matches “{q}”.', { q: q.trim() }) : t('No built-in servers are listed.') })) : (_jsxs(YStack, { gap: "$2", children: [_jsx(SizableText, { size: "$1", color: "$soft", fontVariant: ['tabular-nums'], children: t('{servers} servers · {ops} operations', { servers: shown.length, ops }) }), visible.map((s) => {
|
|
173
224
|
const on = open === s.name;
|
|
174
|
-
return (_jsxs(YStack, { borderWidth: 1, borderColor: "$borderColor", rounded: "$3", overflow: "hidden", children: [_jsxs(XStack, { render: "button", "aria-expanded": on, "aria-label": s.name, items: "center", gap: "$3", px: "$3", py: "$2.5",
|
|
175
|
-
})] })) }));
|
|
225
|
+
return (_jsxs(YStack, { borderWidth: 1, borderColor: "$borderColor", bg: "$panel", rounded: "$3", overflow: "hidden", children: [_jsxs(XStack, { render: "button", "aria-expanded": on, "aria-label": s.name, width: "100%", items: "center", gap: "$3", px: "$3", py: "$2.5", minH: 44, focusVisibleStyle: RING_INSET, "$platform-web": { textAlign: 'start' }, onPress: () => setOpen(on ? null : s.name), children: [_jsx(ServerIcon, { size: 14, color: "$soft", "aria-hidden": true }), _jsxs(YStack, { flex: 1, minW: 0, gap: "$0.5", children: [_jsx(SizableText, { size: "$3", color: "$ink", children: s.name }), s.description ? (_jsx(SizableText, { size: "$1", color: "$soft", numberOfLines: on ? undefined : 2, children: s.description })) : null] }), _jsx(SizableText, { size: "$1", color: "$soft", fontVariant: ['tabular-nums'], shrink: 0, children: s.ops.length }), on ? _jsx(ChevronUp, { size: 14, color: "$soft", "aria-hidden": true }) : _jsx(ChevronDown, { size: 14, color: "$soft", "aria-hidden": true })] }), on ? (_jsx(YStack, { px: "$3", py: "$2", gap: "$1", borderTopWidth: 1, borderColor: "$borderColor", children: s.ops.length ? (s.ops.map((op) => (_jsx(SizableText, { size: "$1", color: "$ink", fontFamily: "$mono", children: op }, op)))) : (_jsx(SizableText, { size: "$1", color: "$soft", children: t('This server lists no operations.') })) })) : null] }, s.name));
|
|
226
|
+
}), !searching && shown.length > BUILTIN_INITIAL ? (_jsx(XStack, { justify: "flex-start", children: _jsx(Button, { size: "sm", variant: "outline", borderColor: "var(--border-strong)", onPress: () => setShowAll((v) => !v), children: showAll ? t('Show fewer') : t('Show all {n} built-in servers', { n: shown.length }) }) })) : null] })) }));
|
|
176
227
|
}
|
|
177
228
|
/** One listing in full: what it is, where it is served, and adding it. */
|
|
178
229
|
function About({ listing, added, signed, onAdd, onClose }) {
|
|
@@ -181,7 +232,7 @@ function About({ listing, added, signed, onAdd, onClose }) {
|
|
|
181
232
|
const full = useLoad(() => one(target, listing.id), listing, [target, listing.id]);
|
|
182
233
|
const l = full.value;
|
|
183
234
|
const links = [l.site, l.repo].filter((u) => u.startsWith('https://'));
|
|
184
|
-
return (_jsxs(Sheet, { title: titleOf(l), open: true, onOpenChange: (o) => !o && onClose(), children: [_jsxs(XStack, { gap: "$3", items: "center", children: [_jsx(Mark, { name: titleOf(l), logo: l.logo, size: 40 }), _jsxs(YStack, { flex: 1, minW: 0, children: [_jsx(SizableText, { size: "$2", color: "$ink", numberOfLines: 1,
|
|
235
|
+
return (_jsxs(Sheet, { title: titleOf(l), open: true, onOpenChange: (o) => !o && onClose(), children: [_jsxs(XStack, { gap: "$3", items: "center", children: [_jsx(Mark, { name: titleOf(l), logo: l.logo, size: 40 }), _jsxs(YStack, { flex: 1, minW: 0, children: [_jsx(SizableText, { size: "$2", color: "$ink", numberOfLines: 1, fontFamily: "$mono", children: l.name }), _jsx(SizableText, { size: "$1", color: "$soft", numberOfLines: 1, children: [l.vendor, l.version ? `v${l.version}` : '', l.official ? t('Official') : ''].filter(Boolean).join(' · ') })] })] }), l.description ? (_jsx(SizableText, { size: "$2", color: "$soft", children: l.description })) : null, l.remotes.length ? (_jsx(Field, { label: t('Served at'), children: l.remotes.map((r) => (_jsxs(SizableText, { size: "$1", color: "$ink", fontFamily: "$mono", numberOfLines: 1, children: [r.url, " \u00B7 ", r.transport] }, r.url))) })) : null, l.packages.length ? (_jsx(Field, { label: t('Packages'), hint: ready(l) ? undefined : t('It ships only as a package, so it needs a place to run before it can be added here.'), children: l.packages.map((p) => (_jsx(SizableText, { size: "$1", color: "$ink", fontFamily: "$mono", numberOfLines: 1, children: [p.registry, p.identifier, p.version, p.runtime].filter(Boolean).join(' · ') }, `${p.registry}:${p.identifier}`))) })) : null, links.length ? (_jsx(XStack, { gap: "$4", flexWrap: "wrap", children: links.map((u) => (_jsxs(Out, { href: u, children: [_jsx(SizableText, { size: "$2", color: "$soft", children: where(u) }), _jsx(ExternalLink, { size: 12, color: "$soft", "aria-hidden": true })] }, u))) })) : null, full.error ? _jsx(StatusBanner, { notice: { text: t('Showing what Browse listed. {reason}', { reason: say(full.error, t) }), error: true } }) : null, signed && ready(l) ? (_jsx(XStack, { justify: "flex-end", children: _jsx(Button, { size: "sm", disabled: added, onPress: onAdd, children: added ? t('Added') : t('Add to your connectors') }) })) : null] }));
|
|
185
236
|
}
|
|
186
237
|
/**
|
|
187
238
|
* Add a server: a listing off the shelf, or any MCP URL. The secret, when it
|
|
@@ -195,10 +246,11 @@ function Connect({ listing, onClose, onAdded }) {
|
|
|
195
246
|
const [header, setHeader] = useState('Authorization');
|
|
196
247
|
const [secret, setSecret] = useState('');
|
|
197
248
|
const [working, setWorking] = useState(false);
|
|
198
|
-
const [
|
|
249
|
+
const [error, setError] = useState('');
|
|
250
|
+
const canSubmit = !working && (Boolean(listing) || (Boolean(name.trim()) && Boolean(url.trim()))) && (!secret || Boolean(header.trim()));
|
|
199
251
|
const save = async () => {
|
|
200
252
|
setWorking(true);
|
|
201
|
-
|
|
253
|
+
setError('');
|
|
202
254
|
const a = listing ? { listing: listing.id, name, header, secret } : { name, url, header, secret };
|
|
203
255
|
try {
|
|
204
256
|
const s = await add(target, a);
|
|
@@ -215,13 +267,13 @@ function Connect({ listing, onClose, onAdded }) {
|
|
|
215
267
|
onAdded(said);
|
|
216
268
|
}
|
|
217
269
|
catch (e) {
|
|
218
|
-
|
|
270
|
+
setError(say(e, t));
|
|
219
271
|
}
|
|
220
272
|
finally {
|
|
221
273
|
setWorking(false);
|
|
222
274
|
}
|
|
223
275
|
};
|
|
224
|
-
return (_jsxs(Sheet, { title: listing ? t('Add {name}', { name: titleOf(listing) }) : t('Add by URL'), open: true, onOpenChange: (o) => !o && onClose(), width: 500, children: [listing ? (_jsx(SizableText, { size: "$2", color: "$soft", children: listing.description || listing.name })) : (_jsx(SizableText, { size: "$2", color: "$soft", children: t('Any MCP server that speaks HTTP. Its tools are on once it is added.') })), _jsx(Field, { label: t('Name'), hint: listing ? t('Leave it empty to use the listing’s own.') : undefined, children: _jsx(Input, { value: name, onChangeText: setName, placeholder: listing ? titleOf(listing) : t('Docs'), "aria-label": t('Name') }) }), listing ? null : (_jsx(Field, { label: "URL", hint: t('A public http(s) address. Private and loopback addresses are refused.'), children: _jsx(Input, { value: url, onChangeText: setUrl, placeholder: "https://mcp.example.com/mcp", "aria-label": "URL", autoCapitalize: "none" }) })), _jsx(Field, { label: t('Secret'), hint: t('Optional. Kept sealed in KMS, sent on every call, and never shown again.'), children: _jsx(Input, { value: secret, onChangeText: setSecret, placeholder: "Bearer \u2026", "aria-label": t('Secret'), secureTextEntry: true }) }), secret ? (_jsx(Field, { label: t('Header'), children: _jsx(Input, { value: header, onChangeText: setHeader, "aria-label": t('Header'), autoCapitalize: "none" }) })) : null, _jsx(
|
|
276
|
+
return (_jsxs(Sheet, { title: listing ? t('Add {name}', { name: titleOf(listing) }) : t('Add by URL'), open: true, onOpenChange: (o) => !o && onClose(), width: 500, children: [listing ? (_jsx(SizableText, { size: "$2", color: "$soft", children: listing.description || listing.name })) : (_jsx(SizableText, { size: "$2", color: "$soft", children: t('Any MCP server that speaks HTTP. Its tools are on once it is added.') })), _jsx(Field, { label: t('Name'), hint: listing ? t('Leave it empty to use the listing’s own.') : undefined, children: _jsx(Input, { value: name, onChangeText: setName, placeholder: listing ? titleOf(listing) : t('Docs'), "aria-label": t('Name') }) }), listing ? null : (_jsx(Field, { label: "URL", hint: t('A public http(s) address. Private and loopback addresses are refused.'), children: _jsx(Input, { value: url, onChangeText: setUrl, placeholder: "https://mcp.example.com/mcp", "aria-label": "URL", autoCapitalize: "none" }) })), _jsx(Field, { label: t('Secret'), hint: t('Optional. Kept sealed in KMS, sent on every call, and never shown again.'), children: _jsx(Input, { value: secret, onChangeText: setSecret, placeholder: "Bearer \u2026", "aria-label": t('Secret'), secureTextEntry: true }) }), secret ? (_jsx(Field, { label: t('Header'), children: _jsx(Input, { value: header, onChangeText: setHeader, "aria-label": t('Header'), autoCapitalize: "none" }) })) : null, error ? _jsx(StatusBanner, { notice: { text: error, error: true } }) : null, _jsxs(XStack, { gap: "$2", justify: "flex-end", children: [_jsx(Button, { size: "sm", variant: "ghost", onPress: onClose, children: t('Cancel') }), _jsx(Button, { size: "sm", variant: "primary", disabled: !canSubmit, onPress: () => void save(), children: working ? t('Adding…') : t('Add') })] })] }));
|
|
225
277
|
}
|
|
226
278
|
/** One of the org's servers: where it is, its secret, its tools and their switches, and removing it. */
|
|
227
279
|
function Detail({ server, may, onClose, onDeleted }) {
|
|
@@ -229,32 +281,37 @@ function Detail({ server, may, onClose, onDeleted }) {
|
|
|
229
281
|
const target = useTarget();
|
|
230
282
|
const list = useLoad(() => tools(target, { source: 'mcp' }), [], [target, server.id]);
|
|
231
283
|
const its = useMemo(() => list.value.filter((x) => owns(server, x.name)), [list.value, server]);
|
|
284
|
+
const [toolQuery, setToolQuery] = useState('');
|
|
232
285
|
const [busy, setBusy] = useState(false);
|
|
233
|
-
const [
|
|
286
|
+
const [error, setError] = useState('');
|
|
234
287
|
const [asking, setAsking] = useState(false);
|
|
235
288
|
const off = its.filter((x) => !x.activated).map((x) => x.name);
|
|
289
|
+
const filteredTools = useMemo(() => (toolQuery.trim() ? its.filter((x) => matches(toolQuery, x.name.slice(server.id.length + 1), x.description)) : its), [its, server.id, toolQuery]);
|
|
236
290
|
const flip = async (on, offNames) => {
|
|
237
291
|
setBusy(true);
|
|
238
|
-
|
|
292
|
+
setError('');
|
|
239
293
|
try {
|
|
240
294
|
await toggle(target, on, offNames);
|
|
241
295
|
list.reload();
|
|
242
296
|
}
|
|
243
297
|
catch (e) {
|
|
244
|
-
|
|
298
|
+
setError(say(e, t));
|
|
245
299
|
}
|
|
246
300
|
finally {
|
|
247
301
|
setBusy(false);
|
|
248
302
|
}
|
|
249
303
|
};
|
|
250
|
-
return (_jsxs(Sheet, { title: server.name, open: true, onOpenChange: (o) => !o && onClose(), children: [_jsxs(YStack, { gap: "$1", children: [_jsx(SizableText, { size: "$1", color: "$ink",
|
|
304
|
+
return (_jsxs(Sheet, { title: server.name, open: true, onOpenChange: (o) => !o && onClose(), children: [_jsxs(YStack, { gap: "$1.5", p: "$3", rounded: "$3", borderWidth: 1, borderColor: "$borderColor", bg: "$panel", children: [_jsx(SizableText, { size: "$1", color: "$ink", fontFamily: "$mono", numberOfLines: 2, children: server.url }), _jsxs(XStack, { items: "center", gap: "$1.5", children: [server.secret ? _jsx(KeyRound, { size: 12, color: "$soft", "aria-hidden": true }) : _jsx(ServerIcon, { size: 12, color: "$soft", "aria-hidden": true }), _jsx(SizableText, { size: "$1", color: "$soft", flex: 1, minW: 0, children: server.secret
|
|
251
305
|
? server.header
|
|
252
306
|
? t('A secret is sealed in KMS and sent in {header}.', { header: server.header })
|
|
253
307
|
: t('A secret is sealed in KMS and sent in its header.')
|
|
254
|
-
: t('No secret: it is called as it is.') })] })] }), _jsxs(XStack, { items: "center", gap: "$2", children: [_jsx(SizableText, { size: "$3", color: "$ink", flex: 1, children: t('Tools') }), its.length && may ? (_jsx(Button, { size: "sm", variant: "outline", disabled: busy, onPress: () => void (off.length ? flip(off, []) : flip([], its.map((x) => x.name))), children: off.length ? t('Turn all on') : t('Turn all off') })) : null] }),
|
|
308
|
+
: t('No secret: it is called as it is.') })] })] }), _jsxs(XStack, { items: "center", gap: "$2", children: [_jsx(SizableText, { size: "$3", fontWeight: "500", color: "$ink", flex: 1, children: its.length ? t('Tools ({n})', { n: its.length }) : t('Tools') }), its.length && may ? (_jsx(Button, { size: "sm", variant: "outline", disabled: busy, onPress: () => void (off.length ? flip(off, []) : flip([], its.map((x) => x.name))), children: off.length ? t('Turn all on') : t('Turn all off') })) : null] }), its.length > 8 ? (_jsx(Input, { value: toolQuery, onChangeText: setToolQuery, placeholder: t('Filter tools…'), "aria-label": t('Filter tools'), startAdornment: _jsx(Search, { size: 14, color: "$soft", "aria-hidden": true }), endAdornment: toolQuery ? (_jsx(XStack, { render: "button", "aria-label": t('Clear search'), onPress: () => setToolQuery(''), minW: 24, minH: 24, items: "center", justify: "center", focusVisibleStyle: RING, children: _jsx(X, { size: 13, color: "$soft", "aria-hidden": true }) })) : undefined, onKeyDown: (e) => {
|
|
309
|
+
if (e.key === 'Escape' && toolQuery)
|
|
310
|
+
setToolQuery('');
|
|
311
|
+
} })) : null, list.loading && !list.value.length ? (_jsx(RowsSkeleton, { label: t('Loading tools') })) : list.error && !list.value.length ? (_jsx(Failed, { error: list.error, onRetry: list.reload })) : !its.length ? (_jsx(Soft, { children: t('No tools listed yet. A server that does not answer shows its tools once it does.') })) : !filteredTools.length ? (_jsx(Soft, { children: t('No tool matches “{q}”.', { q: toolQuery.trim() }) })) : (_jsx(YStack, { borderWidth: 1, borderColor: "$borderColor", bg: "$panel", rounded: "$3", overflow: "hidden", children: filteredTools.map((x, i) => {
|
|
255
312
|
const short = x.name.slice(server.id.length + 1);
|
|
256
|
-
return (_jsxs(XStack, { items: "center", gap: "$3", px: "$3", py: "$2", borderTopWidth: i ? 1 : 0, borderColor: "$borderColor", children: [_jsxs(YStack, { flex: 1, minW: 0, gap: "$0.5", children: [_jsx(SizableText, { size: "$2", color: "$ink",
|
|
257
|
-
}) })), _jsx(
|
|
313
|
+
return (_jsxs(XStack, { items: "center", gap: "$3", px: "$3", py: "$2", borderTopWidth: i ? 1 : 0, borderColor: "$borderColor", children: [_jsxs(YStack, { flex: 1, minW: 0, gap: "$0.5", children: [_jsx(SizableText, { size: "$2", color: "$ink", fontFamily: "$mono", numberOfLines: 1, children: short }), x.description ? (_jsx(SizableText, { size: "$1", color: "$soft", numberOfLines: 2, children: x.description })) : null] }), may ? (_jsx(Switch, { checked: x.activated, disabled: busy, onCheckedChange: (v) => void flip(v ? [x.name] : [], v ? [] : [x.name]), "aria-label": t('{name} on', { name: short }) })) : (_jsx(SizableText, { size: "$1", color: "$soft", children: x.activated ? t('On') : t('Off') }))] }, x.name));
|
|
314
|
+
}) })), error ? (_jsx(StatusBanner, { notice: { text: error, error: true } })) : !may ? (_jsx(SizableText, { size: "$1", color: "$soft", role: "status", children: t('Only an org admin can switch or remove connectors.') })) : null, may ? (_jsx(XStack, { justify: "flex-start", children: _jsxs(Button, { size: "sm", variant: "ghost", tone: "danger", onPress: () => setAsking(true), children: [_jsx(Trash2, { size: 14 }), " ", t('Remove connector')] }) })) : null, _jsx(Confirm, { what: server.name, says: t('Its tools leave your organization and every agent, and its sealed secret is destroyed.'), open: asking, onOpenChange: setAsking, onYes: async () => {
|
|
258
315
|
await remove(target, server.id);
|
|
259
316
|
onDeleted();
|
|
260
317
|
} })] }));
|
package/lib/customize/drafted.js
CHANGED
|
@@ -9,40 +9,53 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
9
9
|
*/
|
|
10
10
|
import { SizableText, XStack, YStack } from '@hanzo/gui';
|
|
11
11
|
import { useI18n } from '@hanzo/i18n/react';
|
|
12
|
-
import {
|
|
12
|
+
import { AlertCircle, Sparkles, X } from '@hanzogui/lucide-icons-2';
|
|
13
|
+
import { Button, Input, Skeleton, Textarea } from '@hanzo/ui';
|
|
13
14
|
import { useState } from 'react';
|
|
15
|
+
import { RING } from '../pane.js';
|
|
14
16
|
import { agents, CAST_CAP, CAST_TASK, create, EMPTY, free, handle } from '../api/agents.js';
|
|
15
17
|
import { portrait, saved, sketch } from '../api/draft.js';
|
|
16
18
|
import { useTarget } from '../host.js';
|
|
17
19
|
import { say } from './say.js';
|
|
18
|
-
import { Field,
|
|
20
|
+
import { Field, Mark, Sheet } from './ui.js';
|
|
19
21
|
/** How long a portrait is waited for before the draft is shown without one. */
|
|
20
22
|
const WAIT = 6000;
|
|
23
|
+
function ErrorLine({ text }) {
|
|
24
|
+
if (!text)
|
|
25
|
+
return null;
|
|
26
|
+
return (_jsxs(XStack, { items: "center", gap: "$1.5", role: "alert", children: [_jsx(AlertCircle, { size: 14, color: "var(--state-error)", "aria-hidden": true }), _jsx(SizableText, { size: "$1", color: "var(--state-error)", flex: 1, minW: 0, children: text })] }));
|
|
27
|
+
}
|
|
28
|
+
function DraftSkeleton({ label }) {
|
|
29
|
+
return (_jsxs(XStack, { role: "status", "aria-busy": true, "aria-label": label, items: "flex-start", gap: "$3", p: "$3", rounded: "$3", borderWidth: 1, borderColor: "$borderColor", bg: "$background", children: [_jsx(Skeleton, { layout: "block", width: 40, height: 40, rounded: "$3", shrink: 0 }), _jsxs(YStack, { flex: 1, minW: 0, gap: "$1.5", children: [_jsx(Skeleton, { layout: "block", width: "36%", height: 13, rounded: "$2" }), _jsx(Skeleton, { layout: "block", width: "76%", height: 11, rounded: "$2" }), _jsx(Skeleton, { layout: "block", width: "58%", height: 11, rounded: "$2" })] })] }));
|
|
30
|
+
}
|
|
21
31
|
export function Drafted({ onMade }) {
|
|
22
32
|
const { t } = useI18n();
|
|
23
33
|
const target = useTarget();
|
|
24
34
|
const [line, setLine] = useState('');
|
|
25
35
|
const [busy, setBusy] = useState(false);
|
|
26
|
-
const [
|
|
36
|
+
const [error, setError] = useState('');
|
|
27
37
|
const [draft, setDraft] = useState(null);
|
|
28
38
|
const make = async () => {
|
|
29
39
|
if (!line.trim() || busy)
|
|
30
40
|
return;
|
|
31
41
|
setBusy(true);
|
|
32
|
-
|
|
42
|
+
setError('');
|
|
33
43
|
try {
|
|
34
44
|
const s = await sketch(target, line);
|
|
35
45
|
const face = s.figure ? await portrait(s.figure, AbortSignal.timeout(WAIT)) : null;
|
|
36
46
|
setDraft({ s, face });
|
|
37
47
|
}
|
|
38
48
|
catch (e) {
|
|
39
|
-
|
|
49
|
+
setError(say(e, t));
|
|
40
50
|
}
|
|
41
51
|
finally {
|
|
42
52
|
setBusy(false);
|
|
43
53
|
}
|
|
44
54
|
};
|
|
45
|
-
return (_jsxs(YStack, { gap: "$2", children: [_jsxs(XStack, { gap: "$2", items: "center", children: [
|
|
55
|
+
return (_jsxs(YStack, { gap: "$2.5", width: "100%", minW: 0, children: [_jsxs(XStack, { width: "100%", minW: 0, gap: "$2", items: "center", "$max-sm": { flexDirection: 'column', items: 'stretch' }, children: [_jsxs(XStack, { flex: 1, minW: 0, height: 38, "$max-sm": { flexBasis: 'auto', grow: 0, width: '100%', minH: 44, height: 44 }, px: "$3", gap: "$2", items: "center", rounded: "$3", borderWidth: 1, borderColor: "var(--border-strong)", bg: "$background", focusWithinStyle: RING, children: [_jsx(Sparkles, { size: 14, color: "$soft", shrink: 0, "aria-hidden": true }), _jsx(Input, { unstyled: true, flex: 1, minW: 0, height: 36, p: 0, borderWidth: 0, bg: "transparent", fontSize: "$2", color: "$ink", style: { outlineStyle: 'none' }, value: line, onChangeText: setLine, disabled: busy, placeholder: t('A name or a description: Marie Curie, a skeptical CFO…'), "aria-label": t('Make with AI'), onKeyDown: (e) => {
|
|
56
|
+
if (e.key === 'Escape' && line && !busy)
|
|
57
|
+
setLine('');
|
|
58
|
+
}, onSubmitEditing: () => void make() }), line && !busy ? (_jsx(XStack, { render: "button", "aria-label": t('Clear'), onPress: () => setLine(''), minW: 24, minH: 24, $touchable: { minW: 44, minH: 44 }, "$max-sm": { minW: 44, minH: 44 }, items: "center", justify: "center", rounded: "$2", borderWidth: 0, bg: "transparent", cursor: "pointer", shrink: 0, hoverStyle: { bg: '$hover' }, focusVisibleStyle: RING, children: _jsx(X, { size: 13, color: "$soft", "aria-hidden": true }) })) : null] }), _jsx(Button, { size: "sm", variant: "primary", shrink: 0, "$max-sm": { width: '100%' }, disabled: !line.trim() || busy, onPress: () => void make(), children: busy ? t('Drafting…') : t('Make with AI') })] }), busy ? _jsx(DraftSkeleton, { label: t('Drafting agent…') }) : null, _jsx(ErrorLine, { text: error }), draft ? _jsx(Review, { draft: draft, onClose: () => setDraft(null), onMade: onMade }) : null] }));
|
|
46
59
|
}
|
|
47
60
|
function Review({ draft, onClose, onMade }) {
|
|
48
61
|
const { t } = useI18n();
|
|
@@ -52,10 +65,10 @@ function Review({ draft, onClose, onMade }) {
|
|
|
52
65
|
const [instructions, setInstructions] = useState(draft.s.instructions);
|
|
53
66
|
const [opening, setOpening] = useState(draft.s.opening);
|
|
54
67
|
const [working, setWorking] = useState(false);
|
|
55
|
-
const [
|
|
68
|
+
const [error, setError] = useState('');
|
|
56
69
|
const save = async () => {
|
|
57
70
|
setWorking(true);
|
|
58
|
-
|
|
71
|
+
setError('');
|
|
59
72
|
try {
|
|
60
73
|
const have = await agents(target);
|
|
61
74
|
const made = await create(target, {
|
|
@@ -71,9 +84,9 @@ function Review({ draft, onClose, onMade }) {
|
|
|
71
84
|
onMade(made);
|
|
72
85
|
}
|
|
73
86
|
catch (e) {
|
|
74
|
-
|
|
87
|
+
setError(say(e, t));
|
|
75
88
|
setWorking(false);
|
|
76
89
|
}
|
|
77
90
|
};
|
|
78
|
-
return (_jsxs(Sheet, { title: t('New agent'), open: true, onOpenChange: (o) => !o && onClose(), children: [_jsxs(XStack, { items: "center", gap: "$3", children: [_jsx(Mark, { name: name || draft.s.name, size: 48, logo: draft.face?.url, icon: !draft.face && draft.s.emoji ? _jsx(SizableText, { size: "$8", children: draft.s.emoji }) : undefined }),
|
|
91
|
+
return (_jsxs(Sheet, { title: t('New agent'), open: true, onOpenChange: (o) => !o && onClose(), children: [_jsxs(XStack, { items: "center", gap: "$3", children: [_jsx(Mark, { name: name || draft.s.name, size: 48, logo: draft.face?.url, icon: !draft.face && draft.s.emoji ? _jsx(SizableText, { size: "$8", children: draft.s.emoji }) : undefined }), _jsxs(YStack, { flex: 1, minW: 0, gap: "$1", children: [_jsx(Input, { value: name, onChangeText: setName, "aria-label": t('Name'), borderColor: "var(--border-strong)" }), draft.face?.licence ? (_jsx(SizableText, { size: "$1", color: "$soft", numberOfLines: 1, children: t('Portrait: {licence}', { licence: draft.face.licence }) })) : null] })] }), _jsx(Field, { label: t('Role'), children: _jsx(Input, { value: role, onChangeText: setRole, "aria-label": t('Role'), borderColor: "var(--border-strong)" }) }), _jsx(Field, { label: t('Instructions'), children: _jsx(Textarea, { value: instructions, onChangeText: setInstructions, "aria-label": t('Instructions'), rows: 8, borderColor: "var(--border-strong)" }) }), _jsx(Field, { label: t('Opening line'), children: _jsx(Input, { value: opening, onChangeText: setOpening, "aria-label": t('Opening line'), borderColor: "var(--border-strong)" }) }), _jsx(ErrorLine, { text: error }), _jsxs(XStack, { gap: "$2", items: "center", justify: "flex-end", children: [_jsx(Button, { size: "sm", variant: "ghost", disabled: working, onPress: onClose, children: t('Cancel') }), _jsx(Button, { size: "sm", variant: "primary", disabled: working || !name.trim() || !instructions.trim(), onPress: () => void save(), children: working ? t('Saving…') : t('Save') })] })] }));
|
|
79
92
|
}
|
package/lib/customize/index.js
CHANGED
|
@@ -12,12 +12,13 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
12
12
|
*
|
|
13
13
|
* Its words are the reader's language (@hanzo/i18n `t`).
|
|
14
14
|
*/
|
|
15
|
-
import { SizableText, XStack, YStack } from '@hanzo/gui';
|
|
15
|
+
import { SizableText, useMedia, XStack, YStack } from '@hanzo/gui';
|
|
16
16
|
import { phrase } from '@hanzo/i18n';
|
|
17
17
|
import { useI18n } from '@hanzo/i18n/react';
|
|
18
|
-
import { BookOpen, Bot, Plug, Plus, Puzzle, Users } from '@hanzogui/lucide-icons-2';
|
|
18
|
+
import { BookOpen, Bot, Plug, Plus, Puzzle, Search, Users, X } from '@hanzogui/lucide-icons-2';
|
|
19
19
|
import { Button, Input } from '@hanzo/ui';
|
|
20
|
-
import { useCallback, useState } from 'react';
|
|
20
|
+
import { useCallback, useId, useState } from 'react';
|
|
21
|
+
import { RING, RING_INSET } from '../pane.js';
|
|
21
22
|
import { useHost } from '../host.js';
|
|
22
23
|
import { path, TABS } from '../route.js';
|
|
23
24
|
import { Agents } from './agents.js';
|
|
@@ -72,6 +73,8 @@ const LABEL = {
|
|
|
72
73
|
export function Customize({ tab, view: first }) {
|
|
73
74
|
const { t } = useI18n();
|
|
74
75
|
const host = useHost();
|
|
76
|
+
const wide = Boolean(useMedia().sm);
|
|
77
|
+
const tabId = useId();
|
|
75
78
|
const [view, setView] = useState(first ?? 'discover');
|
|
76
79
|
const [q, setQ] = useState('');
|
|
77
80
|
const [adding, setAdding] = useState(false);
|
|
@@ -87,11 +90,38 @@ export function Customize({ tab, view: first }) {
|
|
|
87
90
|
const pane = { view, q, adding, onAdding: setAdding, onView: setView, onCount };
|
|
88
91
|
const kit = ORG_KIT.includes(tab);
|
|
89
92
|
const may = Boolean(host.person) && (host.admin || !kit);
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
93
|
+
const inlineCreator = tab === 'agents' || tab === 'bots';
|
|
94
|
+
// Keep one primary white action per view: soften the toolbar button when an empty state or open creator panel owns the primary CTA.
|
|
95
|
+
const quietToolbarAdd = (view === 'yours' && count === 0) || (inlineCreator && adding);
|
|
96
|
+
const choice = (_jsx(Choice, { label: t('Show'), value: view, options: [
|
|
97
|
+
{ id: 'discover', label: t('Browse') },
|
|
98
|
+
{ id: 'yours', label: t('Yours'), count },
|
|
99
|
+
], onChange: setView }));
|
|
100
|
+
const search = (_jsxs(XStack, { items: "center", gap: "$2", px: "$3", height: 36, focusWithinStyle: { borderColor: '$outlineColor' }, children: [_jsx(Search, { size: 14, color: "$soft", shrink: 0, "aria-hidden": true }), _jsx(Input, { unstyled: true, flex: 1, minW: 0, height: "100%", p: 0, fontSize: "$2", color: "$ink", value: q, onChangeText: setQ, placeholder: t(LABEL[tab].typing), "aria-label": t(LABEL[tab].find), onKeyDown: (e) => {
|
|
101
|
+
if (e.key === 'Escape' && q)
|
|
102
|
+
setQ('');
|
|
103
|
+
} }), q ? (_jsx(XStack, { render: "button", "aria-label": t('Clear search'), onPress: () => setQ(''), minW: 24, minH: 24, items: "center", justify: "center", focusVisibleStyle: RING, children: _jsx(X, { size: 13, color: "$soft" }) })) : null] }));
|
|
104
|
+
const addButton = may ? (_jsxs(Button, { size: "sm", variant: quietToolbarAdd ? 'outline' : 'primary', shrink: 0, "aria-expanded": inlineCreator ? adding : undefined, onPress: () => setAdding(inlineCreator ? !adding : true), children: [_jsx(Plus, { size: 14 }), " ", t(LABEL[tab].add)] })) : null;
|
|
105
|
+
return (_jsx(YStack, { flex: 1, minH: 0, overflow: "scroll", px: "$6", py: "$6", "$max-md": { px: '$4', py: '$4' }, children: _jsxs(YStack, { width: "100%", maxW: 1080, mx: "auto", gap: "$4", children: [_jsxs(YStack, { gap: "$1", children: [_jsx(SizableText, { render: "h1", size: "$6", color: "$ink", children: host.sections ? t(LABEL[tab].title) : t('Customize') }), _jsx(SizableText, { size: "$2", color: "$soft", children: host.sections ? t(LABEL[tab].says) : t('What your agent can use in every run.') })] }), _jsxs(YStack, { gap: "$3", children: [host.sections ? null : (_jsx(XStack, { role: "tablist", "aria-label": t('Customize'), gap: "$4", borderBottomWidth: 1, overflowX: "auto", overflowY: "hidden", "$platform-web": { scrollbarWidth: 'none' }, children: TABS.map((id, idx) => {
|
|
106
|
+
const on = id === tab;
|
|
107
|
+
return (_jsxs(XStack, { id: `${tabId}-${id}`, role: "tab", render: "button", "aria-selected": on, "aria-controls": `${tabId}-panel`, tabIndex: on ? 0 : -1, onPress: () => pick(id), onKeyDown: (e) => {
|
|
108
|
+
let nextIdx = null;
|
|
109
|
+
if (e.key === 'ArrowRight')
|
|
110
|
+
nextIdx = (idx + 1) % TABS.length;
|
|
111
|
+
else if (e.key === 'ArrowLeft')
|
|
112
|
+
nextIdx = (idx - 1 + TABS.length) % TABS.length;
|
|
113
|
+
else if (e.key === 'Home')
|
|
114
|
+
nextIdx = 0;
|
|
115
|
+
else if (e.key === 'End')
|
|
116
|
+
nextIdx = TABS.length - 1;
|
|
117
|
+
if (nextIdx === null)
|
|
118
|
+
return;
|
|
119
|
+
e.preventDefault?.();
|
|
120
|
+
const nextTab = TABS[nextIdx];
|
|
121
|
+
if (!nextTab)
|
|
122
|
+
return;
|
|
123
|
+
pick(nextTab);
|
|
124
|
+
queueMicrotask(() => document.getElementById(`${tabId}-${nextTab}`)?.focus());
|
|
125
|
+
}, items: "center", gap: "$1.5", pb: "$2", minH: 36, mb: -1, shrink: 0, borderTopWidth: 0, borderLeftWidth: 0, borderRightWidth: 0, borderBottomWidth: 2, focusVisibleStyle: RING_INSET, children: [_jsx(XStack, { opacity: on ? 1 : 0.7, "$max-md": { display: 'none' }, children: LABEL[id].icon }), _jsx(SizableText, { size: "$3", fontWeight: on ? '500' : '400', color: on ? '$ink' : '$soft', children: t(LABEL[id].title) })] }, id));
|
|
126
|
+
}) })), host.sections ? null : (_jsx(SizableText, { size: "$2", color: "$soft", children: t(LABEL[tab].says) })), wide ? (_jsxs(XStack, { items: "center", gap: "$2.5", children: [choice, _jsx(YStack, { flex: 1, minW: 0, children: search }), addButton] })) : (_jsxs(YStack, { gap: "$2.5", children: [_jsxs(XStack, { items: "center", justify: "space-between", gap: "$2", flexWrap: "wrap", children: [choice, addButton] }), search] })), host.person && kit && !host.admin && LABEL[tab].admin ? (_jsx(SizableText, { size: "$1", color: "$soft", children: t(LABEL[tab].admin) })) : null, _jsx(YStack, { role: "tabpanel", id: `${tabId}-panel`, "aria-labelledby": host.sections ? undefined : `${tabId}-${tab}`, children: tab === 'skills' ? (_jsx(Skills, { ...pane })) : tab === 'connectors' ? (_jsx(Connectors, { ...pane })) : tab === 'plugins' ? (_jsx(Plugins, { ...pane })) : tab === 'bots' ? (_jsx(Agents, { ...pane, mode: "bots" })) : (_jsx(Agents, { ...pane, mode: "agents" })) })] })] }) }));
|
|
97
127
|
}
|
|
@@ -4,7 +4,10 @@ export declare function Inventory({ answers, onChange, onDone }: {
|
|
|
4
4
|
onChange: (a: Answers) => void;
|
|
5
5
|
onDone: () => void;
|
|
6
6
|
}): import("react").JSX.Element;
|
|
7
|
-
/**
|
|
7
|
+
/**
|
|
8
|
+
* The five domains as bars of their raw means, 1 to 5. On the long form, each
|
|
9
|
+
* domain's six facets stay folded by default so only 5 primary bars appear at rest.
|
|
10
|
+
*/
|
|
8
11
|
export declare function Traits({ form, score }: {
|
|
9
12
|
form: Form;
|
|
10
13
|
score: Score;
|