@hanzo/build 0.2.126 → 0.2.128
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/suggest.d.ts +6 -0
- package/lib/suggest.js +7 -1
- 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
|
@@ -3,27 +3,41 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
3
3
|
* The Big Five questionnaire Clone yourself asks, and what it found.
|
|
4
4
|
*
|
|
5
5
|
* On a phone one statement fills the screen, with a bar, Back, and the keys 1
|
|
6
|
-
* to 5; a wider window
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
* IPIP's (ocean.ts), drawn
|
|
6
|
+
* to 5; a wider window shows a focused block of 5 statements at a time (with an
|
|
7
|
+
* option to view all), and the keys answer the first one left. Every answer goes
|
|
8
|
+
* to `onChange` as it is given, which keeps it in this browser, so a closed
|
|
9
|
+
* dialog opens where it stopped. The statements are the IPIP's (ocean.ts), drawn
|
|
10
|
+
* through `t`; figures are drawn as given.
|
|
10
11
|
*/
|
|
11
12
|
import { SizableText, useMedia, XStack, YStack } from '@hanzo/gui';
|
|
12
13
|
import { useI18n } from '@hanzo/i18n/react';
|
|
14
|
+
import { Check, ChevronDown, ChevronLeft, ChevronRight, ChevronUp } from '@hanzogui/lucide-icons-2';
|
|
13
15
|
import { Button } from '@hanzo/ui';
|
|
14
16
|
import { memo, useCallback, useEffect, useRef, useState } from 'react';
|
|
17
|
+
import { RING, RING_INSET } from '../pane.js';
|
|
15
18
|
import { ANCHORS, DOMAIN, DOMAINS, FACET, FACETS, ITEMS } from './ocean.js';
|
|
16
19
|
const LEVELS = [1, 2, 3, 4, 5];
|
|
20
|
+
const PAGE_SIZE = 5;
|
|
17
21
|
export function Inventory({ answers, onChange, onDone }) {
|
|
18
22
|
const { t } = useI18n();
|
|
19
23
|
const phone = !useMedia().sm;
|
|
20
24
|
const items = ITEMS[answers.form];
|
|
21
25
|
const given = answers[answers.form];
|
|
22
26
|
const n = given.filter(Boolean).length;
|
|
23
|
-
const
|
|
27
|
+
const complete = n === items.length;
|
|
28
|
+
const firstOpen = given.indexOf(0);
|
|
29
|
+
const [at, setAt] = useState(() => Math.max(0, firstOpen));
|
|
30
|
+
const [page, setPage] = useState(() => Math.floor(Math.max(0, firstOpen) / PAGE_SIZE));
|
|
31
|
+
const [showAll, setShowAll] = useState(false);
|
|
24
32
|
const list = useRef(null);
|
|
25
|
-
|
|
26
|
-
const
|
|
33
|
+
const totalPages = Math.max(1, Math.ceil(items.length / PAGE_SIZE));
|
|
34
|
+
const safeAt = Math.min(at, Math.max(0, items.length - 1));
|
|
35
|
+
const safePage = Math.min(page, totalPages - 1);
|
|
36
|
+
const pageStart = showAll ? 0 : safePage * PAGE_SIZE;
|
|
37
|
+
const pageEnd = showAll ? items.length : Math.min(items.length, pageStart + PAGE_SIZE);
|
|
38
|
+
// The keys answer the statement on screen, or the first unanswered one on the active page (or anywhere in the list).
|
|
39
|
+
const pageOpen = given.findIndex((x, idx) => idx >= pageStart && idx < pageEnd && !x);
|
|
40
|
+
const current = phone ? safeAt : showAll ? firstOpen : pageOpen >= 0 ? pageOpen : firstOpen;
|
|
27
41
|
const answer = (i, v) => {
|
|
28
42
|
const next = given.map((x, j) => (j === i ? v : x));
|
|
29
43
|
onChange({ ...answers, [answers.form]: next });
|
|
@@ -35,8 +49,15 @@ export function Inventory({ answers, onChange, onDone }) {
|
|
|
35
49
|
else
|
|
36
50
|
setAt(left);
|
|
37
51
|
}
|
|
52
|
+
else if (showAll) {
|
|
53
|
+
if (left >= 0)
|
|
54
|
+
list.current?.querySelector(`[data-item="${left}"]`)?.scrollIntoView({ block: 'nearest' });
|
|
55
|
+
}
|
|
38
56
|
else if (left >= 0) {
|
|
39
|
-
|
|
57
|
+
// Advance smoothly once every statement on the visible page has an answer.
|
|
58
|
+
const stillOnPage = next.findIndex((x, j) => j >= pageStart && j < pageEnd && !x);
|
|
59
|
+
if (stillOnPage < 0)
|
|
60
|
+
setPage(Math.floor(left / PAGE_SIZE));
|
|
40
61
|
}
|
|
41
62
|
};
|
|
42
63
|
const press = useRef(answer);
|
|
@@ -45,6 +66,9 @@ export function Inventory({ answers, onChange, onDone }) {
|
|
|
45
66
|
const pick = useCallback((i, v) => press.current(i, v), []);
|
|
46
67
|
useEffect(() => {
|
|
47
68
|
const key = (e) => {
|
|
69
|
+
const target = e.target;
|
|
70
|
+
if (target instanceof HTMLElement && (target.tagName === 'INPUT' || target.tagName === 'TEXTAREA' || target.isContentEditable))
|
|
71
|
+
return;
|
|
48
72
|
const v = Number(e.key);
|
|
49
73
|
if (e.metaKey || e.ctrlKey || e.altKey || !(v >= 1 && v <= 5) || current < 0)
|
|
50
74
|
return;
|
|
@@ -54,25 +78,50 @@ export function Inventory({ answers, onChange, onDone }) {
|
|
|
54
78
|
window.addEventListener('keydown', key);
|
|
55
79
|
return () => window.removeEventListener('keydown', key);
|
|
56
80
|
}, [current]);
|
|
81
|
+
const progressPct = items.length ? Math.round((n / items.length) * 100) : 0;
|
|
57
82
|
// Pinned to the top of the dialog's scroll, so the count and Done stay in reach down the list.
|
|
58
|
-
const head = (_jsxs(YStack, { gap: "$2", pb: "$2", bg: "$background", z: 1, position: "sticky", t: 0, children: [_jsxs(XStack, { items: "center", gap: "$3", children: [_jsx(YStack, { flex: 1, height:
|
|
83
|
+
const head = (_jsxs(YStack, { gap: "$2", pb: "$2.5", borderBottomWidth: 1, borderColor: "$borderColor", bg: "$background", z: 1, position: "sticky", t: 0, children: [_jsxs(XStack, { items: "center", gap: "$3", children: [_jsx(YStack, { flex: 1, height: 6, overflow: "hidden", role: "progressbar", "aria-label": t('Answered'), "aria-valuenow": n, "aria-valuemin": 0, "aria-valuemax": items.length, children: _jsx(YStack, { height: 6, width: `${progressPct}%`, rounded: 999, bg: "$ink" }) }), _jsx(SizableText, { size: "$1", color: "$soft", fontVariant: ['tabular-nums'], shrink: 0, children: t('{n} of {total}', { n, total: items.length }) }), _jsx(Button, { size: "sm", variant: complete ? 'primary' : 'outline', borderColor: complete ? undefined : 'var(--border-strong)', onPress: onDone, children: t('Done') })] }), _jsx(SizableText, { size: "$1", color: "$soft", children: t('Describe yourself as you generally are now, not as you wish to be in the future. From 1, very inaccurate, to 5, very accurate.') })] }));
|
|
59
84
|
if (phone) {
|
|
60
|
-
const item = items[
|
|
61
|
-
return (_jsxs(YStack, { gap: "$4", children: [head,
|
|
85
|
+
const item = items[safeAt];
|
|
86
|
+
return (_jsxs(YStack, { gap: "$4", children: [head, _jsxs(YStack, { gap: "$1.5", children: [_jsx(SizableText, { size: "$1", color: "$soft", fontVariant: ['tabular-nums'], children: t('Statement {i} of {total}', { i: safeAt + 1, total: items.length }) }), _jsx(SizableText, { size: "$5", fontWeight: "500", color: "$ink", minH: 56, children: t(item.text) })] }), _jsx(YStack, { role: "radiogroup", "aria-label": t(item.text), gap: "$2", children: LEVELS.map((v) => {
|
|
87
|
+
const selected = given[safeAt] === v;
|
|
88
|
+
return (_jsxs(XStack, { render: "button", role: "radio", "aria-checked": selected, "aria-label": t(ANCHORS[v - 1]), onPress: () => answer(safeAt, v), width: "100%", minH: 48, px: "$3.5", py: "$2", gap: "$3", items: "center", focusVisibleStyle: RING, "$platform-web": { textAlign: 'start' }, children: [_jsx(SizableText, { size: "$2", fontWeight: "500", color: selected ? '$ink' : '$soft', width: 16, fontVariant: ['tabular-nums'], shrink: 0, children: v }), _jsx(SizableText, { size: "$3", color: "$ink", flex: 1, minW: 0, children: t(ANCHORS[v - 1]) }), selected ? _jsx(Check, { size: 15, color: "$ink", "aria-hidden": true }) : null] }, v));
|
|
89
|
+
}) }), _jsxs(XStack, { items: "center", justify: "space-between", gap: "$2", children: [_jsxs(Button, { size: "sm", variant: "outline", borderColor: "var(--border-strong)", disabled: safeAt === 0, onPress: () => setAt(safeAt - 1), children: [_jsx(ChevronLeft, { size: 14 }), " ", t('Back')] }), _jsxs(Button, { size: "sm", variant: "ghost", disabled: safeAt >= items.length - 1, onPress: () => setAt(safeAt + 1), children: [t('Next'), " ", _jsx(ChevronRight, { size: 14 })] })] })] }));
|
|
62
90
|
}
|
|
63
|
-
return (_jsxs(YStack, { gap: "$3", children: [head,
|
|
91
|
+
return (_jsxs(YStack, { gap: "$3", children: [head, _jsxs(XStack, { items: "center", justify: "space-between", gap: "$2", px: "$1", children: [_jsx(SizableText, { size: "$1", color: "$soft", children: t('1 Very inaccurate · 5 Very accurate') }), _jsx(SizableText, { size: "$1", color: "$soft", children: t('Keys 1–5 answer the highlighted row') })] }), _jsx(YStack, { ref: list, role: "list", "aria-label": t('Statements'), rounded: "$4", borderWidth: 1, borderColor: "$borderColor", bg: "$panel", overflow: "hidden", children: items.slice(pageStart, pageEnd).map((item, offset) => {
|
|
92
|
+
const idx = pageStart + offset;
|
|
93
|
+
return _jsx(Statement, { i: idx, first: offset === 0, text: t(item.text), value: given[idx] ?? 0, current: idx === current, onAnswer: pick }, idx);
|
|
94
|
+
}) }), _jsxs(XStack, { items: "center", justify: "space-between", gap: "$2", flexWrap: "wrap", children: [!showAll ? (_jsxs(XStack, { items: "center", gap: "$2", children: [_jsxs(Button, { size: "sm", variant: "outline", borderColor: "var(--border-strong)", disabled: safePage === 0, onPress: () => setPage(safePage - 1), children: [_jsx(ChevronLeft, { size: 14 }), " ", t('Previous')] }), _jsx(SizableText, { size: "$1", color: "$soft", fontVariant: ['tabular-nums'], children: t('Page {page} of {total}', { page: safePage + 1, total: totalPages }) }), _jsxs(Button, { size: "sm", variant: "outline", borderColor: "var(--border-strong)", disabled: safePage >= totalPages - 1, onPress: () => setPage(safePage + 1), children: [t('Next'), " ", _jsx(ChevronRight, { size: 14 })] })] })) : (_jsx(SizableText, { size: "$1", color: "$soft", fontVariant: ['tabular-nums'], children: t('Showing all {total} statements', { total: items.length }) })), _jsx(Button, { size: "sm", variant: "ghost", onPress: () => setShowAll((v) => !v), children: showAll ? t('Show 5 at a time') : t('Show all {total}', { total: items.length }) })] })] }));
|
|
64
95
|
}
|
|
65
96
|
/** One statement of the list, with its five answers. */
|
|
66
|
-
const Statement = memo(function Statement({ i, text, value, current, onAnswer }) {
|
|
97
|
+
const Statement = memo(function Statement({ i, first, text, value, current, onAnswer, }) {
|
|
67
98
|
const { t } = useI18n();
|
|
68
|
-
return (_jsxs(XStack, { role: "listitem", "data-item": i, items: "center", gap: "$3", px: "$
|
|
99
|
+
return (_jsxs(XStack, { role: "listitem", "data-item": i, items: "center", gap: "$3", px: "$3", py: "$2.5", minH: 48, borderTopWidth: first ? 0 : 1, children: [_jsx(SizableText, { size: "$1", color: "$soft", width: 24, fontVariant: ['tabular-nums'], shrink: 0, children: i + 1 }), _jsx(SizableText, { flex: 1, minW: 0, size: "$2", fontWeight: current ? '500' : '400', color: value && !current ? '$soft' : '$ink', children: text }), _jsx(XStack, { role: "radiogroup", "aria-label": text, gap: "$1.5", shrink: 0, children: LEVELS.map((v) => {
|
|
100
|
+
const selected = value === v;
|
|
101
|
+
return (_jsx(XStack, { render: "button", role: "radio", "aria-checked": selected, "aria-label": t(ANCHORS[v - 1]), onPress: () => onAnswer(i, v), width: 32, height: 32, items: "center", justify: "center", focusVisibleStyle: RING, children: _jsx(SizableText, { size: "$1", fontWeight: selected ? '600' : '400', color: selected ? '$background' : '$soft', fontVariant: ['tabular-nums'], children: v }) }, v));
|
|
102
|
+
}) })] }));
|
|
69
103
|
});
|
|
70
|
-
/**
|
|
104
|
+
/**
|
|
105
|
+
* The five domains as bars of their raw means, 1 to 5. On the long form, each
|
|
106
|
+
* domain's six facets stay folded by default so only 5 primary bars appear at rest.
|
|
107
|
+
*/
|
|
71
108
|
export function Traits({ form, score }) {
|
|
72
109
|
const { t } = useI18n();
|
|
73
|
-
|
|
110
|
+
const [expanded, setExpanded] = useState({});
|
|
111
|
+
const hasFacets = form === 'long';
|
|
112
|
+
const allOpen = hasFacets && DOMAINS.every((d) => expanded[d]);
|
|
113
|
+
const toggleDomain = (d) => setExpanded((prev) => ({ ...prev, [d]: !prev[d] }));
|
|
114
|
+
const toggleAll = () => {
|
|
115
|
+
const next = !allOpen;
|
|
116
|
+
setExpanded(Object.fromEntries(DOMAINS.map((d) => [d, next])));
|
|
117
|
+
};
|
|
118
|
+
return (_jsxs(YStack, { gap: "$2.5", children: [_jsx(YStack, { rounded: "$4", borderWidth: 1, borderColor: "$borderColor", bg: "$panel", overflow: "hidden", children: DOMAINS.map((d, idx) => {
|
|
119
|
+
const open = hasFacets && Boolean(expanded[d]);
|
|
120
|
+
return (_jsxs(YStack, { borderTopWidth: idx ? 1 : 0, borderColor: "$borderColor", children: [hasFacets ? (_jsxs(XStack, { render: "button", "aria-expanded": open, "aria-label": t('{domain}: {score}', { domain: t(DOMAIN[d]), score: score.domains[d].toFixed(1) }), onPress: () => toggleDomain(d), width: "100%", px: "$3", py: "$2.5", minH: 44, items: "center", gap: "$2", focusVisibleStyle: RING_INSET, "$platform-web": { textAlign: 'start' }, children: [_jsx(YStack, { flex: 1, minW: 0, children: _jsx(Bar, { label: t(DOMAIN[d]), value: score.domains[d], strong: true }) }), open ? _jsx(ChevronUp, { size: 14, color: "$soft", "aria-hidden": true }) : _jsx(ChevronDown, { size: 14, color: "$soft", "aria-hidden": true })] })) : (_jsx(YStack, { px: "$3", py: "$2.5", children: _jsx(Bar, { label: t(DOMAIN[d]), value: score.domains[d], strong: true }) })), open ? (_jsx(YStack, { px: "$3", py: "$2.5", gap: "$2", borderTopWidth: 1, borderColor: "$borderColor", bg: "$background", children: FACETS(d).map((f) => (_jsx(Bar, { label: t(FACET[f]), value: score.facets[f] ?? 0 }, f))) })) : null] }, d));
|
|
121
|
+
}) }), hasFacets ? (_jsx(XStack, { justify: "flex-end", children: _jsx(Button, { size: "sm", variant: "ghost", onPress: toggleAll, children: allOpen ? t('Hide facets') : t('Show all facets') }) })) : null] }));
|
|
74
122
|
}
|
|
75
123
|
function Bar({ label, value, strong = false }) {
|
|
76
124
|
const h = strong ? 6 : 4;
|
|
77
|
-
|
|
125
|
+
const pct = Math.max(0, Math.min(100, ((value - 1) / 4) * 100));
|
|
126
|
+
return (_jsxs(XStack, { items: "center", gap: "$3", role: "meter", "aria-label": label, "aria-valuenow": value, "aria-valuemin": 1, "aria-valuemax": 5, "aria-valuetext": value.toFixed(1), pl: strong ? 0 : '$2', children: [_jsxs(XStack, { items: "center", justify: "space-between", gap: "$2", width: strong ? 150 : 142, shrink: 0, "$max-sm": { width: '100%' }, children: [_jsx(SizableText, { size: strong ? '$2' : '$1', fontWeight: strong ? '500' : '400', color: strong ? '$ink' : '$soft', numberOfLines: 1, flex: 1, minW: 0, children: label }), _jsx(XStack, { display: "none", shrink: 0, "$max-sm": { display: 'flex' }, children: _jsx(SizableText, { size: "$1", color: "$soft", fontVariant: ['tabular-nums'], children: value.toFixed(1) }) })] }), _jsx(YStack, { flex: 1, minW: 0, height: h, rounded: 999, bg: "$hover", overflow: "hidden", "$max-sm": { flexBasis: 'auto', grow: 0, minW: 0, width: '100%' }, children: _jsx(YStack, { height: h, width: `${pct}%`, rounded: 999, bg: strong ? '$ink' : '$soft' }) }), _jsx(XStack, { width: 28, justify: "flex-end", shrink: 0, "$max-sm": { display: 'none' }, children: _jsx(SizableText, { size: "$1", color: "$soft", fontVariant: ['tabular-nums'], children: value.toFixed(1) }) })] }));
|
|
78
127
|
}
|
package/lib/customize/plugins.js
CHANGED
|
@@ -15,16 +15,22 @@ import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-run
|
|
|
15
15
|
*/
|
|
16
16
|
import { SizableText, XStack, YStack } from '@hanzo/gui';
|
|
17
17
|
import { useI18n } from '@hanzo/i18n/react';
|
|
18
|
-
import { Puzzle } from '@hanzogui/lucide-icons-2';
|
|
19
|
-
import { Button, Input, Textarea } from '@hanzo/ui';
|
|
18
|
+
import { AlertCircle, Check, Code2, Puzzle, Trash2 } from '@hanzogui/lucide-icons-2';
|
|
19
|
+
import { Button, DropdownMenu, Input, Textarea } from '@hanzo/ui';
|
|
20
20
|
import { Code } from '@hanzo/ui/chat';
|
|
21
21
|
import { useState } from 'react';
|
|
22
22
|
import { authored, build, mounted, remove } from '../api/plugins.js';
|
|
23
23
|
import { useHost, useTarget } from '../host.js';
|
|
24
24
|
import { useLoad } from './load.js';
|
|
25
25
|
import { say } from './say.js';
|
|
26
|
-
import { Choice, Confirm, day, Empty, Failed, Field, Grid,
|
|
26
|
+
import { Choice, Confirm, day, Empty, Failed, Field, Grid, Mark, matches, MenuTrigger, Part, Sheet, Soft, Tile, TilesSkeleton, useCount, Visitor } from './ui.js';
|
|
27
|
+
const INITIAL_MOUNTS = 6;
|
|
27
28
|
const kb = (n) => (n < 1024 ? `${n} B` : `${(n / 1024).toFixed(1)} KB`);
|
|
29
|
+
function StatusBanner({ notice }) {
|
|
30
|
+
if (!notice?.text)
|
|
31
|
+
return null;
|
|
32
|
+
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 })] }));
|
|
33
|
+
}
|
|
28
34
|
export function Plugins({ view, q, adding, onAdding, onView, onCount }) {
|
|
29
35
|
const { t } = useI18n();
|
|
30
36
|
const host = useHost();
|
|
@@ -33,28 +39,48 @@ export function Plugins({ view, q, adding, onAdding, onView, onCount }) {
|
|
|
33
39
|
const mine = useLoad(signed ? () => authored(target) : null, [], [target, signed]);
|
|
34
40
|
const mounts = useLoad(signed && view === 'discover' ? () => mounted(target) : null, [], [target, signed, view]);
|
|
35
41
|
const [opened, setOpened] = useState(null);
|
|
36
|
-
const [
|
|
42
|
+
const [deleting, setDeleting] = useState(null);
|
|
43
|
+
const [mountDetail, setMountDetail] = useState(null);
|
|
44
|
+
const [showAllMounts, setShowAllMounts] = useState(false);
|
|
45
|
+
const [notice, setNotice] = useState(null);
|
|
37
46
|
useCount(mine.value.length, onCount);
|
|
38
47
|
const sheets = (_jsxs(_Fragment, { children: [adding ? (_jsx(Build, { onClose: () => onAdding(false), onBuilt: (p, said) => {
|
|
39
48
|
onAdding(false);
|
|
40
49
|
onView('yours');
|
|
41
50
|
mine.reload();
|
|
42
|
-
|
|
51
|
+
setNotice({ text: said });
|
|
43
52
|
setOpened(p);
|
|
44
53
|
} })) : null, opened ? (_jsx(Source, { plugin: opened, onClose: () => setOpened(null), onDeleted: () => {
|
|
45
|
-
|
|
54
|
+
setNotice({ text: t('{name} is deleted', { name: opened.name }) });
|
|
46
55
|
setOpened(null);
|
|
47
56
|
mine.reload();
|
|
48
|
-
} })) : null
|
|
57
|
+
} })) : null, deleting ? (_jsx(Confirm, { what: deleting.name, says: t('The runtime can no longer load it.'), open: true, onOpenChange: (o) => !o && setDeleting(null), onYes: async () => {
|
|
58
|
+
const gone = deleting;
|
|
59
|
+
await remove(target, gone.id);
|
|
60
|
+
setDeleting(null);
|
|
61
|
+
setNotice({ text: t('{name} is deleted', { name: gone.name }) });
|
|
62
|
+
mine.reload();
|
|
63
|
+
} })) : null, mountDetail ? _jsx(MountSheet, { mount: mountDetail, onClose: () => setMountDetail(null) }) : null] }));
|
|
49
64
|
if (!signed) {
|
|
50
65
|
return _jsx(Visitor, { children: view === 'discover' ? t('Sign in to browse plugins.') : t('Sign in to see your plugins.') });
|
|
51
66
|
}
|
|
52
67
|
if (view === 'discover') {
|
|
53
68
|
const shown = mounts.value.filter((m) => matches(q, m.name, ...m.prefixes));
|
|
54
|
-
|
|
69
|
+
const searching = Boolean(q.trim());
|
|
70
|
+
const visible = searching || showAllMounts ? shown : shown.slice(0, INITIAL_MOUNTS);
|
|
71
|
+
return (_jsxs(YStack, { gap: "$6", children: [_jsx(StatusBanner, { notice: notice }), _jsxs(XStack, { items: "center", gap: "$3", p: "$4", children: [_jsx(Mark, { name: t('Build your own'), size: 36, icon: _jsx(Code2, { size: 16, color: "$soft", "aria-hidden": true }) }), _jsxs(YStack, { flex: 1, minW: 0, gap: "$0.5", "$max-sm": { flexBasis: 'auto', grow: 0, minW: 0, width: '100%' }, children: [_jsx(SizableText, { size: "$3", fontWeight: "500", color: "$ink", children: t('Build your own') }), _jsx(SizableText, { size: "$2", color: "$soft", children: t('Write a connector in TypeScript, or describe an API and Hanzo writes it.') })] }), _jsx(Button, { size: "sm", variant: "outline", borderColor: "var(--border-strong)", shrink: 0, onPress: () => onAdding(true), children: t('Build a plugin') })] }), _jsx(Part, { title: t('Built in'), detail: t('Part of Hanzo. Always on, nothing to add.'), children: mounts.error && !mounts.value.length ? (_jsx(Failed, { error: mounts.error, onRetry: mounts.reload })) : mounts.loading && !mounts.value.length ? (_jsx(TilesSkeleton, { label: t('Loading built-in plugins') })) : !shown.length ? (_jsx(Soft, { children: mounts.value.length ? t('Nothing built in matches “{q}”.', { q: q.trim() }) : t('Nothing built in is listed.') })) : (_jsxs(YStack, { gap: "$3", children: [_jsx(SizableText, { size: "$1", color: "$soft", fontVariant: ['tabular-nums'], children: t('{n} built in', { n: shown.length }) }), _jsx(Grid, { label: t('Mounted subsystems'), children: visible.map((m) => (_jsx(Tile, { title: m.name, detail: m.prefixes.join(' · '), meta: m.enabled ? t('On') : t('Off'), mark: _jsx(Mark, { name: m.name, icon: _jsx(Puzzle, { size: 15, color: "$soft", "aria-hidden": true }) }), onOpen: () => setMountDetail(m) }, m.name))) }), !searching && shown.length > INITIAL_MOUNTS ? (_jsx(XStack, { justify: "flex-start", children: _jsx(Button, { size: "sm", variant: "outline", borderColor: "var(--border-strong)", onPress: () => setShowAllMounts((v) => !v), children: showAllMounts ? t('Show fewer') : t('Show all {n} built-in plugins', { n: shown.length }) }) })) : null] })) }), sheets] }));
|
|
55
72
|
}
|
|
56
73
|
const shown = mine.value.filter((p) => matches(q, p.name, p.provider));
|
|
57
|
-
return (_jsxs(YStack, { gap: "$3", children: [_jsx(
|
|
74
|
+
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 plugins'), count: 4 })) : !mine.value.length ? (_jsx(Empty, { title: t('No plugins yet'), detail: t('Write a connector in TypeScript, or describe an API and Hanzo writes it.'), children: _jsx(Button, { size: "sm", onPress: () => onAdding(true), children: t('Build a plugin') }) })) : !shown.length ? (_jsx(Soft, { children: t('No plugin of yours matches “{q}”.', { q: q.trim() }) })) : (_jsx(Grid, { label: t('Your plugins'), children: shown.map((p) => (_jsx(Tile, { title: p.name, detail: p.provider ? t('Reads the {provider} connector’s credential when it runs.', { provider: p.provider }) : t('Needs no credential.'), meta: day(p.built) ? t('Built {date}', { date: day(p.built) }) : undefined, mark: _jsx(Mark, { name: p.name, icon: _jsx(Code2, { size: 15, color: "$soft", "aria-hidden": true }) }), onOpen: () => setOpened(p), action: _jsx(DropdownMenu, { placement: "bottom-end", offset: 6, trigger: _jsx(MenuTrigger, { label: t('Actions for {name}', { name: p.name }) }), items: [
|
|
75
|
+
{ key: 'source', label: t('View source'), icon: _jsx(Code2, { size: 15 }), onSelect: () => setOpened(p) },
|
|
76
|
+
{ type: 'separator' },
|
|
77
|
+
{ key: 'delete', label: t('Delete plugin'), icon: _jsx(Trash2, { size: 15 }), destructive: true, onSelect: () => setDeleting(p) },
|
|
78
|
+
] }) }, p.id))) })), sheets] }));
|
|
79
|
+
}
|
|
80
|
+
/** Read-only inspection sheet for a built-in mounted subsystem. */
|
|
81
|
+
function MountSheet({ mount, onClose }) {
|
|
82
|
+
const { t } = useI18n();
|
|
83
|
+
return (_jsxs(Sheet, { title: mount.name, open: true, onOpenChange: (o) => !o && onClose(), width: 480, children: [_jsxs(XStack, { items: "center", gap: "$2", children: [_jsx(YStack, { width: 8, height: 8, rounded: 999, bg: mount.enabled ? 'var(--state-success)' : '$soft', shrink: 0, "aria-hidden": true }), _jsx(SizableText, { size: "$2", color: "$soft", children: mount.enabled ? t('Built in and always on for every run.') : t('Built in, currently off in this deployment.') })] }), _jsx(Field, { label: t('Route prefixes'), children: _jsx(YStack, { borderWidth: 1, borderColor: "$borderColor", bg: "$panel", rounded: "$3", overflow: "hidden", children: mount.prefixes.length ? (mount.prefixes.map((prefix, i) => (_jsx(XStack, { px: "$3", py: "$2", borderTopWidth: i ? 1 : 0, borderColor: "$borderColor", children: _jsx(SizableText, { size: "$1", color: "$ink", fontFamily: "$mono", children: prefix }) }, prefix)))) : (_jsx(XStack, { px: "$3", py: "$2", children: _jsx(SizableText, { size: "$1", color: "$soft", children: t('No route prefixes listed.') }) })) }) })] }));
|
|
58
84
|
}
|
|
59
85
|
/** Build a plugin from its TypeScript, or from a description of the API it calls. */
|
|
60
86
|
function Build({ onClose, onBuilt }) {
|
|
@@ -67,28 +93,30 @@ function Build({ onClose, onBuilt }) {
|
|
|
67
93
|
const [source, setSource] = useState('');
|
|
68
94
|
const [spec, setSpec] = useState('');
|
|
69
95
|
const [working, setWorking] = useState(false);
|
|
70
|
-
const [
|
|
96
|
+
const [notice, setNotice] = useState(null);
|
|
97
|
+
const body = way === 'source' ? source : spec;
|
|
98
|
+
const canBuild = !working && Boolean(name.trim()) && Boolean(body.trim());
|
|
71
99
|
const go = async () => {
|
|
72
100
|
setWorking(true);
|
|
73
|
-
|
|
101
|
+
setNotice({ text: way === 'spec' ? t('Writing and building it…') : t('Building it…') });
|
|
74
102
|
try {
|
|
75
103
|
const out = await build(target, { name: name.trim(), provider, source: way === 'source' ? source : '', spec: way === 'spec' ? spec : '' });
|
|
76
104
|
const built = { name: out.plugin.name, size: kb(out.bytes) };
|
|
77
105
|
onBuilt(out.plugin, out.generated ? t('{name} built: {size}, written from your description — read it below.', built) : t('{name} built: {size}.', built));
|
|
78
106
|
}
|
|
79
107
|
catch (e) {
|
|
80
|
-
|
|
108
|
+
setNotice({ text: say(e, t), error: true });
|
|
81
109
|
}
|
|
82
110
|
finally {
|
|
83
111
|
setWorking(false);
|
|
84
112
|
}
|
|
85
113
|
};
|
|
86
|
-
return (_jsxs(Sheet, { title: t('Build a plugin'), open: true, onOpenChange: (o) => !o && onClose(), width: 680, children: [_jsx(Field, { label: t('Name'), hint: t('One lowercase word: letters, digits, _ or -.'), children: _jsx(Input, { value: name, onChangeText: setName, "aria-label": t('Name'), autoCapitalize: "none" }) }), _jsx(Field, { label: t('Connector'), hint: t('Optional. The connector whose key it uses when it runs; a plugin never holds a key itself.'), children: _jsx(Input, { value: provider, onChangeText: setProvider, "aria-label": t('Connector'), autoCapitalize: "none" }) }), _jsx(Choice, { label: t('Build from'), value: way, options: [
|
|
114
|
+
return (_jsxs(Sheet, { title: t('Build a plugin'), open: true, onOpenChange: (o) => !o && onClose(), width: 680, children: [_jsx(Field, { label: t('Name'), hint: t('One lowercase word: letters, digits, _ or -.'), children: _jsx(Input, { value: name, onChangeText: setName, placeholder: "acme-crm", "aria-label": t('Name'), autoCapitalize: "none", borderColor: "var(--border-strong)" }) }), _jsx(Field, { label: t('Connector'), hint: t('Optional. The connector whose key it uses when it runs; a plugin never holds a key itself.'), children: _jsx(Input, { value: provider, onChangeText: setProvider, placeholder: "acme", "aria-label": t('Connector'), autoCapitalize: "none", borderColor: "var(--border-strong)" }) }), _jsx(Choice, { label: t('Build from'), value: way, options: [
|
|
87
115
|
{ id: 'source', label: 'TypeScript' },
|
|
88
116
|
{ id: 'spec', label: t('Describe an API') },
|
|
89
117
|
], onChange: setWay }), _jsx(Field, { label: way === 'source' ? t('Source') : t('The API'), hint: way === 'source'
|
|
90
118
|
? t('Kept only if it builds. A failed build says why.')
|
|
91
|
-
: t('An OpenAPI document, or the endpoints in plain words. You read the TypeScript before it runs.'), children: _jsx(Textarea, { value:
|
|
119
|
+
: t('An OpenAPI document, or the endpoints in plain words. You read the TypeScript before it runs.'), children: _jsx(Textarea, { value: body, onChangeText: way === 'source' ? setSource : setSpec, "aria-label": way === 'source' ? t('Source') : t('The API'), placeholder: way === 'source' ? 'export const acme = createProvider({ … })' : t('POST /v1/things creates a thing…'), rows: 14, fontFamily: "$mono" }) }), notice ? (notice.error ? (_jsx(StatusBanner, { notice: notice })) : (_jsx(SizableText, { size: "$1", color: "$soft", role: "status", children: notice.text }))) : 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: !canBuild, onPress: () => void go(), children: working ? (way === 'spec' ? t('Writing & building…') : t('Building…')) : t('Build') })] })] }));
|
|
92
120
|
}
|
|
93
121
|
/** A built plugin's source, as the runtime will run it, and deleting it. */
|
|
94
122
|
function Source({ plugin, onClose, onDeleted }) {
|
|
@@ -100,7 +128,7 @@ function Source({ plugin, onClose, onDeleted }) {
|
|
|
100
128
|
day(plugin.built) ? t('Built {date}.', { date: day(plugin.built) }) : '',
|
|
101
129
|
]
|
|
102
130
|
.filter(Boolean)
|
|
103
|
-
.join(' ') }), _jsx(Code, { language: "TypeScript", value: plugin.source, children: _jsx(SizableText, { size: "$1", color: "$ink",
|
|
131
|
+
.join(' ') }), _jsx(Code, { language: "TypeScript", value: plugin.source, children: _jsx(SizableText, { size: "$1", color: "$ink", fontFamily: "$mono", "$platform-web": { whiteSpace: 'pre' }, children: plugin.source }) }), _jsx(YStack, { items: "flex-start", children: _jsxs(Button, { size: "sm", variant: "ghost", tone: "danger", onPress: () => setAsking(true), children: [_jsx(Trash2, { size: 14 }), " ", t('Delete plugin')] }) }), _jsx(Confirm, { what: plugin.name, says: t('The runtime can no longer load it.'), open: asking, onOpenChange: setAsking, onYes: async () => {
|
|
104
132
|
await remove(target, plugin.id);
|
|
105
133
|
onDeleted();
|
|
106
134
|
} })] }));
|
package/lib/customize/skills.js
CHANGED
|
@@ -13,17 +13,26 @@ import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-run
|
|
|
13
13
|
*/
|
|
14
14
|
import { SizableText, XStack, YStack } from '@hanzo/gui';
|
|
15
15
|
import { useI18n } from '@hanzo/i18n/react';
|
|
16
|
-
import { BookOpen } from '@hanzogui/lucide-icons-2';
|
|
17
|
-
import { Button, Input, Switch, Textarea } from '@hanzo/ui';
|
|
16
|
+
import { AlertCircle, BookOpen, Check, Eye, Pencil, SlidersHorizontal, Trash2 } from '@hanzogui/lucide-icons-2';
|
|
17
|
+
import { Button, DropdownMenu, Input, Skeleton, Switch, Textarea } from '@hanzo/ui';
|
|
18
18
|
import { Code } from '@hanzo/ui/chat';
|
|
19
|
-
import { useMemo, useState } from 'react';
|
|
19
|
+
import { useEffect, useMemo, useState } from 'react';
|
|
20
20
|
import { active, authored, brand, document, nameOf, remove, tool, write } from '../api/skills.js';
|
|
21
21
|
import { toggle } from '../api/tools.js';
|
|
22
22
|
import { useHost, useTarget } from '../host.js';
|
|
23
23
|
import { useLoad } from './load.js';
|
|
24
24
|
import { say } from './say.js';
|
|
25
|
-
import { Add, Confirm, day, Empty, Failed, Field,
|
|
25
|
+
import { Add, Confirm, day, Empty, Failed, Field, FilterPills, Grid, Mark, matches, MenuTrigger, Part, Sheet, Soft, Tile, TilesSkeleton, useCount, Visitor } from './ui.js';
|
|
26
26
|
const PAGE = 60;
|
|
27
|
+
const ANY = '';
|
|
28
|
+
function StatusBanner({ notice }) {
|
|
29
|
+
if (!notice?.text)
|
|
30
|
+
return null;
|
|
31
|
+
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 })] }));
|
|
32
|
+
}
|
|
33
|
+
function DocSkeleton({ label }) {
|
|
34
|
+
return (_jsxs(YStack, { role: "status", "aria-busy": true, "aria-label": label, p: "$3.5", gap: "$2", rounded: "$3", borderWidth: 1, borderColor: "$borderColor", bg: "$panel", children: [_jsx(Skeleton, { layout: "block", width: "38%", height: 13, rounded: "$2" }), _jsx(Skeleton, { layout: "block", width: "94%", height: 11, rounded: "$2" }), _jsx(Skeleton, { layout: "block", width: "82%", height: 11, rounded: "$2" }), _jsx(Skeleton, { layout: "block", width: "88%", height: 11, rounded: "$2" }), _jsx(Skeleton, { layout: "block", width: "64%", height: 11, rounded: "$2" }), _jsx(Skeleton, { layout: "block", width: "76%", height: 11, rounded: "$2" })] }));
|
|
35
|
+
}
|
|
27
36
|
export function Skills({ view, q, adding, onAdding, onView, onCount }) {
|
|
28
37
|
const { t } = useI18n();
|
|
29
38
|
const host = useHost();
|
|
@@ -36,24 +45,36 @@ export function Skills({ view, q, adding, onAdding, onView, onCount }) {
|
|
|
36
45
|
const shelf = useLoad(view === 'discover' ? () => brand(target) : null, null, [target.api, view]);
|
|
37
46
|
const [editing, setEditing] = useState(null);
|
|
38
47
|
const [reading, setReading] = useState(null);
|
|
48
|
+
const [deleting, setDeleting] = useState(null);
|
|
39
49
|
const [busy, setBusy] = useState('');
|
|
40
|
-
const [
|
|
50
|
+
const [notice, setNotice] = useState(null);
|
|
51
|
+
const [product, setProduct] = useState(ANY);
|
|
41
52
|
const [shown, setShown] = useState(PAGE);
|
|
53
|
+
useEffect(() => setShown(PAGE), [q, product]);
|
|
42
54
|
const lit = useMemo(() => new Set(on.value.map((x) => x.name)), [on.value]);
|
|
43
55
|
const mine = useMemo(() => new Set(own.value.map((s) => s.name)), [own.value]);
|
|
44
56
|
const added = on.value.filter((x) => nameOf(x.name) && !mine.has(nameOf(x.name)));
|
|
45
57
|
useCount(own.value.length + added.length, onCount);
|
|
58
|
+
const productOptions = useMemo(() => {
|
|
59
|
+
const c = shelf.value;
|
|
60
|
+
if (!c)
|
|
61
|
+
return [];
|
|
62
|
+
const names = c.products.length
|
|
63
|
+
? [...c.products].sort((a, b) => b.count - a.count || a.name.localeCompare(b.name)).map((p) => p.name)
|
|
64
|
+
: [...new Set(c.skills.map((e) => e.product).filter(Boolean))].sort((a, b) => a.localeCompare(b));
|
|
65
|
+
return names.length > 1 ? [{ id: ANY, label: t('All') }, ...names.map((name) => ({ id: name, label: name }))] : [];
|
|
66
|
+
}, [shelf.value, t]);
|
|
46
67
|
/** Switch one skill on or off, then read what is on again. */
|
|
47
68
|
const flip = async (name, next) => {
|
|
48
69
|
setBusy(name);
|
|
49
|
-
|
|
70
|
+
setNotice(null);
|
|
50
71
|
try {
|
|
51
72
|
await toggle(target, next ? [tool(name)] : [], next ? [] : [tool(name)]);
|
|
52
73
|
on.reload();
|
|
53
|
-
|
|
74
|
+
setNotice({ text: next ? t('{name} is on', { name }) : t('{name} is off', { name }) });
|
|
54
75
|
}
|
|
55
76
|
catch (e) {
|
|
56
|
-
|
|
77
|
+
setNotice({ text: say(e, t), error: true });
|
|
57
78
|
}
|
|
58
79
|
finally {
|
|
59
80
|
setBusy('');
|
|
@@ -69,17 +90,29 @@ export function Skills({ view, q, adding, onAdding, onView, onCount }) {
|
|
|
69
90
|
own.reload();
|
|
70
91
|
on.reload();
|
|
71
92
|
onView('yours');
|
|
72
|
-
|
|
93
|
+
setNotice({ text: fresh ? t('{name} is saved and on', { name: s.name }) : t('{name} is saved', { name: s.name }) });
|
|
73
94
|
}, onDeleted: (name) => {
|
|
74
95
|
setEditing(null);
|
|
75
96
|
own.reload();
|
|
76
97
|
on.reload();
|
|
77
|
-
|
|
98
|
+
setNotice({ text: t('{name} is deleted', { name }) });
|
|
99
|
+
} })) : null;
|
|
100
|
+
const confirmDelete = deleting ? (_jsx(Confirm, { what: deleting.name, says: t('The skill leaves your organization and every agent that names it.'), open: true, onOpenChange: (o) => !o && setDeleting(null), onYes: async () => {
|
|
101
|
+
const gone = deleting;
|
|
102
|
+
await remove(target, gone.id);
|
|
103
|
+
setDeleting(null);
|
|
104
|
+
own.reload();
|
|
105
|
+
on.reload();
|
|
106
|
+
setNotice({ text: t('{name} is deleted', { name: gone.name }) });
|
|
78
107
|
} })) : null;
|
|
79
108
|
if (view === 'discover') {
|
|
80
109
|
const all = shelf.value?.skills ?? [];
|
|
81
|
-
const found = all.filter((e) => matches(q, e.name, e.description, e.product));
|
|
82
|
-
return (_jsxs(YStack, { gap: "$3", children: [_jsx(
|
|
110
|
+
const found = all.filter((e) => (!product || e.product === product) && matches(q, e.name, e.description, e.product));
|
|
111
|
+
return (_jsxs(YStack, { gap: "$3", children: [_jsx(StatusBanner, { notice: notice }), _jsx(Part, { title: t('From Hanzo'), detail: t('Add one and every run in your organization can use it.'), children: shelf.error && !shelf.value ? (_jsx(Failed, { error: shelf.error, onRetry: shelf.reload })) : !shelf.value ? (_jsx(TilesSkeleton, { label: t('Loading skills') })) : (_jsxs(YStack, { gap: "$3", children: [productOptions.length > 1 ? (_jsx(FilterPills, { label: t('Product'), value: product, options: productOptions, onChange: setProduct, maxVisibleDesktop: 6, mobileLimit: 4 })) : null, !found.length ? (_jsx(Soft, { action: product ? (_jsx(Button, { size: "sm", variant: "outline", borderColor: "var(--border-strong)", onPress: () => setProduct(ANY), children: t('Show all products') })) : undefined, children: q.trim()
|
|
112
|
+
? t('No skill matches “{q}”.', { q: q.trim() })
|
|
113
|
+
: product
|
|
114
|
+
? t('No skills in {product}.', { product })
|
|
115
|
+
: t('There are no skills to add yet.') })) : (_jsxs(_Fragment, { children: [_jsx(SizableText, { size: "$1", color: "$soft", fontVariant: ['tabular-nums'], children: found.length === all.length ? t('{n} skills', { n: all.length }) : t('{found} of {n} skills', { found: found.length, n: all.length }) }), _jsx(Grid, { label: t('Skills to add'), children: found.slice(0, shown).map((e) => (_jsx(Tile, { title: e.name, detail: e.description, meta: e.product || undefined, mark: _jsx(Mark, { name: e.name, icon: _jsx(BookOpen, { size: 15, color: "$soft", "aria-hidden": true }) }), onOpen: () => setReading(e), action: may ? _jsx(Add, { name: e.name, added: lit.has(tool(e.name)), busy: busy === e.name, onPress: () => void flip(e.name, true) }) : undefined }, e.name))) }), found.length > shown ? (_jsx(XStack, { justify: "center", children: _jsx(Button, { size: "sm", variant: "outline", borderColor: "var(--border-strong)", onPress: () => setShown(shown + PAGE), children: t('Show more') }) })) : null] }))] })) }), reader, editor] }));
|
|
83
116
|
}
|
|
84
117
|
if (!signed) {
|
|
85
118
|
return _jsx(Visitor, { children: t('Sign in to see your skills.') });
|
|
@@ -87,15 +120,46 @@ export function Skills({ view, q, adding, onAdding, onView, onCount }) {
|
|
|
87
120
|
const ownShown = own.value.filter((s) => matches(q, s.name, s.description));
|
|
88
121
|
const addedShown = added.filter((x) => matches(q, nameOf(x.name), x.description));
|
|
89
122
|
const error = own.error ?? on.error;
|
|
90
|
-
return (_jsxs(YStack, { gap: "$5", children: [_jsx(
|
|
123
|
+
return (_jsxs(YStack, { gap: "$5", children: [_jsx(StatusBanner, { notice: notice }), error && !own.value.length && !on.value.length ? (_jsx(Failed, { error: error, onRetry: () => {
|
|
91
124
|
own.reload();
|
|
92
125
|
on.reload();
|
|
93
|
-
} })) : (own.loading || on.loading) && !own.value.length && !on.value.length ? (_jsx(
|
|
94
|
-
|
|
95
|
-
|
|
126
|
+
} })) : (own.loading || on.loading) && !own.value.length && !on.value.length ? (_jsx(TilesSkeleton, { label: t('Loading your skills'), count: 4 })) : !own.value.length && !added.length ? (_jsxs(Empty, { title: t('No skills yet'), detail: may ? t('Add one from Hanzo, or write your own.') : t('An org admin adds skills. Browse what there is.'), children: [_jsx(Button, { size: "sm", variant: "outline", onPress: () => onView('discover'), children: t('Browse skills') }), may ? (_jsx(Button, { size: "sm", onPress: () => onAdding(true), children: t('Write a skill') })) : null] })) : !ownShown.length && !addedShown.length ? (_jsx(Soft, { children: t('No skill of yours matches “{q}”.', { q: q.trim() }) })) : (_jsxs(_Fragment, { children: [ownShown.length ? (_jsx(Part, { title: t('Made by your team'), detail: t('Off keeps a skill but leaves it out of every run.'), children: _jsx(Grid, { label: t('Your skills'), children: ownShown.map((s) => {
|
|
127
|
+
const activeNow = lit.has(tool(s.name));
|
|
128
|
+
return (_jsx(Tile, { title: s.name, detail: s.description || firstLine(s.content), meta: [s.source ? t('From {source}', { source: s.source }) : day(s.created) ? t('Saved {date}', { date: day(s.created) }) : '', s.admitted ? '' : t('Not in runs until an admin saves it')]
|
|
129
|
+
.filter(Boolean)
|
|
130
|
+
.join(' · ') || undefined, mark: _jsx(Mark, { name: s.name }), onOpen: () => setEditing(s), action: _jsxs(XStack, { items: "center", gap: "$1.5", shrink: 0, children: [may ? (_jsx(Switch, { checked: activeNow, disabled: busy === s.name, onCheckedChange: (v) => void flip(s.name, v), "aria-label": t('{name} on', { name: s.name }) })) : (_jsx(SizableText, { size: "$1", color: "$soft", children: activeNow ? t('On') : t('Off') })), _jsx(DropdownMenu, { placement: "bottom-end", offset: 6, trigger: _jsx(MenuTrigger, { label: t('Actions for {name}', { name: s.name }) }), items: may
|
|
131
|
+
? [
|
|
132
|
+
{ key: 'edit', label: t('Edit skill'), icon: _jsx(Pencil, { size: 15 }), onSelect: () => setEditing(s) },
|
|
133
|
+
{
|
|
134
|
+
key: 'toggle',
|
|
135
|
+
label: activeNow ? t('Turn off') : t('Turn on'),
|
|
136
|
+
icon: _jsx(SlidersHorizontal, { size: 15 }),
|
|
137
|
+
disabled: busy === s.name,
|
|
138
|
+
onSelect: () => void flip(s.name, !activeNow),
|
|
139
|
+
},
|
|
140
|
+
{ type: 'separator' },
|
|
141
|
+
{ key: 'delete', label: t('Delete'), icon: _jsx(Trash2, { size: 15 }), destructive: true, onSelect: () => setDeleting(s) },
|
|
142
|
+
]
|
|
143
|
+
: [{ key: 'view', label: t('View SKILL.md'), icon: _jsx(Eye, { size: 15 }), onSelect: () => setEditing(s) }] })] }) }, s.id));
|
|
144
|
+
}) }) })) : null, addedShown.length ? (_jsx(Part, { title: t('Added from Hanzo'), detail: t('On for every run in your organization.'), children: _jsx(Grid, { label: t('Added skills'), children: addedShown.map((x) => {
|
|
96
145
|
const name = nameOf(x.name);
|
|
97
|
-
return (_jsx(Tile, { title: name, detail: x.description, mark: _jsx(Mark, { name: name, icon: _jsx(BookOpen, { size: 15 }) }), onOpen: () => setReading({ name, description: x.description, product: '' }), action:
|
|
98
|
-
|
|
146
|
+
return (_jsx(Tile, { title: name, detail: x.description, mark: _jsx(Mark, { name: name, icon: _jsx(BookOpen, { size: 15, color: "$soft", "aria-hidden": true }) }), onOpen: () => setReading({ name, description: x.description, product: '' }), action: _jsx(DropdownMenu, { placement: "bottom-end", offset: 6, trigger: _jsx(MenuTrigger, { label: t('Actions for {name}', { name }) }), items: [
|
|
147
|
+
{ key: 'read', label: t('Read SKILL.md'), icon: _jsx(BookOpen, { size: 15 }), onSelect: () => setReading({ name, description: x.description, product: '' }) },
|
|
148
|
+
...(may
|
|
149
|
+
? [
|
|
150
|
+
{ type: 'separator' },
|
|
151
|
+
{
|
|
152
|
+
key: 'remove',
|
|
153
|
+
label: t('Remove'),
|
|
154
|
+
icon: _jsx(Trash2, { size: 15 }),
|
|
155
|
+
destructive: true,
|
|
156
|
+
disabled: busy === name,
|
|
157
|
+
onSelect: () => void flip(name, false),
|
|
158
|
+
},
|
|
159
|
+
]
|
|
160
|
+
: []),
|
|
161
|
+
] }) }, x.name));
|
|
162
|
+
}) }) })) : null] })), reader, editor, confirmDelete] }));
|
|
99
163
|
}
|
|
100
164
|
const firstLine = (md) => md
|
|
101
165
|
.split('\n')
|
|
@@ -106,7 +170,7 @@ function Reader({ skill, added, signed, busy, onFlip, onClose, }) {
|
|
|
106
170
|
const { t } = useI18n();
|
|
107
171
|
const target = useTarget();
|
|
108
172
|
const doc = useLoad(() => document(target, skill.name), '', [target.api, skill.name]);
|
|
109
|
-
return (_jsxs(Sheet, { title: skill.name, open: true, onOpenChange: (o) => !o && onClose(), width: 720, children: [skill.description ? (_jsx(SizableText, { size: "$2", color: "$soft", children: skill.description })) : null, signed ? (_jsxs(XStack, { gap: "$2", items: "center", children: [_jsx(Button, { size: "sm", variant: added ? 'outline' : '
|
|
173
|
+
return (_jsxs(Sheet, { title: skill.name, open: true, onOpenChange: (o) => !o && onClose(), width: 720, children: [skill.product ? (_jsxs(XStack, { items: "center", gap: "$1.5", children: [_jsx(BookOpen, { size: 13, color: "$soft", "aria-hidden": true }), _jsx(SizableText, { size: "$1", color: "$soft", children: skill.product })] })) : null, skill.description ? (_jsx(SizableText, { size: "$2", color: "$soft", children: skill.description })) : null, signed ? (_jsxs(XStack, { gap: "$2.5", items: "center", flexWrap: "wrap", "$max-sm": { flexDirection: 'column', items: 'stretch' }, children: [_jsx(Button, { size: "sm", variant: added ? 'outline' : 'primary', borderColor: added ? 'var(--border-strong)' : undefined, disabled: busy, onPress: () => onFlip(!added), children: busy ? t('Updating…') : added ? t('Remove') : t('Add to your skills') }), _jsx(SizableText, { size: "$1", color: "$soft", flex: 1, children: added ? t('On for your organization.') : t('Every run in your organization can use it once added.') })] })) : null, doc.error ? (_jsx(Failed, { error: doc.error, onRetry: doc.reload })) : doc.loading && !doc.value ? (_jsx(DocSkeleton, { label: t('Loading SKILL.md') })) : (_jsx(Code, { language: "SKILL.md", value: doc.value, children: _jsx(SizableText, { size: "$1", color: "$ink", fontFamily: "$mono", "$platform-web": { whiteSpace: 'pre-wrap' }, children: doc.value }) }))] }));
|
|
110
174
|
}
|
|
111
175
|
/** Write a skill, or revise one of the org's own. Its name is its id, so a saved skill keeps its name. */
|
|
112
176
|
function Editor({ skill, may, onClose, onSaved, onDeleted, }) {
|
|
@@ -116,11 +180,11 @@ function Editor({ skill, may, onClose, onSaved, onDeleted, }) {
|
|
|
116
180
|
const [description, setDescription] = useState(skill?.description ?? '');
|
|
117
181
|
const [content, setContent] = useState(skill?.content ?? '');
|
|
118
182
|
const [working, setWorking] = useState(false);
|
|
119
|
-
const [
|
|
183
|
+
const [error, setError] = useState('');
|
|
120
184
|
const [asking, setAsking] = useState(false);
|
|
121
185
|
const save = async () => {
|
|
122
186
|
setWorking(true);
|
|
123
|
-
|
|
187
|
+
setError('');
|
|
124
188
|
try {
|
|
125
189
|
const saved = await write(target, { name: name.trim(), description: description.trim(), content });
|
|
126
190
|
// A new skill is switched on as it is saved; a revised one keeps its switch.
|
|
@@ -129,13 +193,13 @@ function Editor({ skill, may, onClose, onSaved, onDeleted, }) {
|
|
|
129
193
|
onSaved(saved, !skill);
|
|
130
194
|
}
|
|
131
195
|
catch (e) {
|
|
132
|
-
|
|
196
|
+
setError(say(e, t));
|
|
133
197
|
}
|
|
134
198
|
finally {
|
|
135
199
|
setWorking(false);
|
|
136
200
|
}
|
|
137
201
|
};
|
|
138
|
-
return (_jsxs(Sheet, { title: skill ? skill.name : t('New skill'), open: true, onOpenChange: (o) => !o && onClose(), width: 680, children: [skill?.source ? (_jsx(SizableText, { size: "$2", color: "$soft", children: t('Read from {source}. The next push of that repository replaces what is saved here.', { source: skill.source }) })) : null, _jsx(Field, { label: t('Name'), hint: skill ? t('A skill keeps its name. Save under another name to make a new one.') : t('One lowercase word: letters, digits, _ or -.'), children: _jsx(Input, { value: name, onChangeText: setName, "aria-label": t('Name'), disabled: Boolean(skill), autoCapitalize: "none" }) }), _jsx(Field, { label: t('Description'), hint: t('One line. An agent reads it to decide whether it needs the skill.'), children: _jsx(Input, { value: description, onChangeText: setDescription, placeholder: t('How we triage an incoming issue'), "aria-label": t('Description') }) }), _jsx(Field, { label: "SKILL.md", hint: t('Markdown: what it is for, when to use it, and the steps.'), children: _jsx(Textarea, { value: content, onChangeText: setContent, placeholder: t('# Triage\n\n1. Read the issue…'), "aria-label": "SKILL.md", rows: 14, fontFamily: "$mono" }) }), _jsx(
|
|
202
|
+
return (_jsxs(Sheet, { title: skill ? skill.name : t('New skill'), open: true, onOpenChange: (o) => !o && onClose(), width: 680, children: [skill?.source ? (_jsx(SizableText, { size: "$2", color: "$soft", children: t('Read from {source}. The next push of that repository replaces what is saved here.', { source: skill.source }) })) : null, _jsx(Field, { label: t('Name'), hint: skill ? t('A skill keeps its name. Save under another name to make a new one.') : t('One lowercase word: letters, digits, _ or -.'), children: _jsx(Input, { value: name, onChangeText: setName, placeholder: "issue-triage", "aria-label": t('Name'), disabled: Boolean(skill) || !may, autoCapitalize: "none", borderColor: "var(--border-strong)" }) }), _jsx(Field, { label: t('Description'), hint: t('One line. An agent reads it to decide whether it needs the skill.'), children: _jsx(Input, { value: description, onChangeText: setDescription, placeholder: t('How we triage an incoming issue'), "aria-label": t('Description'), disabled: !may, borderColor: "var(--border-strong)" }) }), _jsx(Field, { label: "SKILL.md", hint: t('Markdown: what it is for, when to use it, and the steps.'), children: _jsx(Textarea, { value: content, onChangeText: setContent, placeholder: t('# Triage\n\n1. Read the issue…'), "aria-label": "SKILL.md", disabled: !may, rows: 14, fontFamily: "$mono", borderColor: "var(--border-strong)" }) }), error ? (_jsx(StatusBanner, { notice: { text: error, error: true } })) : !may ? (_jsx(SizableText, { size: "$1", color: "$soft", role: "status", children: t('Only an org admin can write or delete skills.') })) : null, _jsxs(XStack, { gap: "$2", items: "center", flexWrap: "wrap", children: [skill && may ? (_jsxs(Button, { size: "sm", variant: "ghost", tone: "danger", onPress: () => setAsking(true), children: [_jsx(Trash2, { size: 14 }), " ", t('Delete')] })) : null, _jsx(XStack, { flex: 1 }), _jsx(Button, { size: "sm", variant: "ghost", onPress: onClose, children: may ? t('Cancel') : t('Close') }), may ? (_jsx(Button, { size: "sm", variant: "primary", disabled: working || !name.trim() || !content.trim(), onPress: () => void save(), children: working ? t('Saving…') : t('Save') })) : null] }), skill ? (_jsx(Confirm, { what: skill.name, says: t('The skill leaves your organization and every agent that names it.'), open: asking, onOpenChange: setAsking, onYes: async () => {
|
|
139
203
|
await remove(target, skill.id);
|
|
140
204
|
onDeleted(skill.name);
|
|
141
205
|
} })) : null] }));
|
package/lib/customize/ui.d.ts
CHANGED
|
@@ -1,7 +1,4 @@
|
|
|
1
1
|
import { type ReactNode } from 'react';
|
|
2
|
-
export declare const mono: {
|
|
3
|
-
fontFamily: string;
|
|
4
|
-
};
|
|
5
2
|
/** Which half of a tab: what there is to browse and add (first), or what the org already has. */
|
|
6
3
|
export type View = 'discover' | 'yours';
|
|
7
4
|
/** What the shell hands a tab: which half, the search, the Add dialog's state, and where to say how many are yours. */
|
|
@@ -130,5 +127,34 @@ export declare function Choice<T extends string>({ value, options, onChange, lab
|
|
|
130
127
|
onChange: (v: T) => void;
|
|
131
128
|
label: string;
|
|
132
129
|
}): import("react").JSX.Element;
|
|
130
|
+
/**
|
|
131
|
+
* Compact filter pills for long category lists (e.g., agent categories): shows one clean
|
|
132
|
+
* primary row on desktop (`maxVisibleDesktop`, default 6) and `mobileLimit` (default 4)
|
|
133
|
+
* on narrow screens, collapsing the rest behind a `+{n} more` / `Show less` toggle pill
|
|
134
|
+
* while keeping the active category always visible in the primary row.
|
|
135
|
+
*/
|
|
136
|
+
export declare function FilterPills<T extends string>({ value, options, onChange, label, mobileLimit, maxVisibleDesktop, }: {
|
|
137
|
+
value: T;
|
|
138
|
+
options: readonly {
|
|
139
|
+
id: T;
|
|
140
|
+
label: string;
|
|
141
|
+
}[];
|
|
142
|
+
onChange: (v: T) => void;
|
|
143
|
+
label: string;
|
|
144
|
+
mobileLimit?: number;
|
|
145
|
+
maxVisibleDesktop?: number;
|
|
146
|
+
}): import("react").JSX.Element;
|
|
133
147
|
/** A date from Unix seconds, or ''. */
|
|
134
148
|
export declare const day: (s: number) => string;
|
|
149
|
+
export declare function TilesSkeleton({ label, count, withHero }: {
|
|
150
|
+
label: string;
|
|
151
|
+
count?: number;
|
|
152
|
+
withHero?: boolean;
|
|
153
|
+
}): import("react").JSX.Element;
|
|
154
|
+
export declare function RowsSkeleton({ label, count }: {
|
|
155
|
+
label: string;
|
|
156
|
+
count?: number;
|
|
157
|
+
}): import("react").JSX.Element;
|
|
158
|
+
export declare function MenuTrigger({ label }: {
|
|
159
|
+
label: string;
|
|
160
|
+
}): import("react").JSX.Element;
|