@hanzo/app 0.2.41 → 0.2.43
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/Chat.js +45 -47
- package/dist/SettingsPane.js +3 -3
- package/dist/Setup.js +16 -12
- package/dist/agents.d.ts +1 -1
- package/dist/dev.js +1 -5
- package/dist/lib/chatPreferences.d.ts +5 -6
- package/dist/lib/chatPreferences.js +10 -10
- package/dist/lib/oauth.d.ts +43 -0
- package/dist/lib/oauth.js +121 -0
- package/dist/lib/signout.js +0 -1
- package/dist/look.js +2 -2
- package/package.json +7 -7
- package/dist/ThinkingEffort.d.ts +0 -21
- package/dist/ThinkingEffort.js +0 -97
package/dist/Chat.js
CHANGED
|
@@ -34,7 +34,7 @@ import { billed, detail, familyOf, planRequired, plainly, refused } from "./fail
|
|
|
34
34
|
import { english } from "./say.js";
|
|
35
35
|
import { Prose } from "./Prose.js";
|
|
36
36
|
import { useAgent, useAi, useChat, } from "@hanzo/ai/react";
|
|
37
|
-
import { Chat as ChatSurface, Failure, Parts, words } from "@hanzo/ui/chat";
|
|
37
|
+
import { Chat as ChatSurface, EFFORTS, Failure, MEASURE, Parts, useFamilies, words } from "@hanzo/ui/chat";
|
|
38
38
|
import { carriedIn, carrying, compose, partsOf, said as told, weigh } from "./lib/attach.js";
|
|
39
39
|
import { download, dropped, fileOf, pct, readable, refOf, retrieve } from "./lib/files.js";
|
|
40
40
|
import { channel, drop, hold, landed, localOf, spend, take, usePane, useWorkFile } from "./pane.js";
|
|
@@ -57,7 +57,7 @@ import { useHydrated } from "./lib/hydrated.js";
|
|
|
57
57
|
import { base, served } from "./lib/ai.js";
|
|
58
58
|
import { onServed } from "./lib/served.js";
|
|
59
59
|
import { refused as worded, speech, useDictation, useTalk, useVoice } from "@hanzo/voice";
|
|
60
|
-
import { Check, Clock, FileText, Image as ImageMark, Library as LibraryMark, Paperclip, Sparkles, X
|
|
60
|
+
import { Check, Clock, FileText, Image as ImageMark, Library as LibraryMark, Paperclip, Sparkles, X } from "lucide-react";
|
|
61
61
|
import { FREE, ENSO } from "./lib/ai.js";
|
|
62
62
|
import { openThread, useOpen } from "./open.js";
|
|
63
63
|
import { Beside, Framed } from "./Shell.js";
|
|
@@ -67,7 +67,7 @@ import { ConversationMenu, ThreadMore, useThreadList } from "./thread.js";
|
|
|
67
67
|
import { Schedule } from "./Schedule.js";
|
|
68
68
|
import { keepFile, useAttach, useKeep } from "./keep.js";
|
|
69
69
|
import { dragWindow, toggleWindowMaximize } from "./WindowControls.js";
|
|
70
|
-
import { artifacts, lead, nameOf, PAGE, Panel, PanelToggle,
|
|
70
|
+
import { artifacts, lead, nameOf, PAGE, Panel, PanelToggle, renders, Reply, Served, Summary, useDeck, useKey, Suggestions, useCarry, useLanguage, useMind, useSuggestions, book, hand, taken, want, path as devPath, CHAT_MODES, usePanel, frames, name as tabName, } from "@hanzo/build";
|
|
71
71
|
import { checkoutUrl, payUrl } from './lib/pay.js';
|
|
72
72
|
import { Upgrade, useFree } from './Upgrade.js';
|
|
73
73
|
import { enter, LOGIN } from './lib/destination.js';
|
|
@@ -75,7 +75,6 @@ import { first } from './lib/first.js';
|
|
|
75
75
|
import { BAD } from "./lib/mix.js";
|
|
76
76
|
import { brand } from './where.js';
|
|
77
77
|
import { BAND } from './ground.js';
|
|
78
|
-
import { ThinkingEffort } from './ThinkingEffort.js';
|
|
79
78
|
import { shared, useChatPreferences } from './lib/chatPreferences.js';
|
|
80
79
|
// NO REASONING PANEL HERE. Every assistant turn opened a "Thinking" disclosure
|
|
81
80
|
// listing seven steps — "Planning CSS extraction for chat styles", "Designing
|
|
@@ -87,12 +86,6 @@ import { shared, useChatPreferences } from './lib/chatPreferences.js';
|
|
|
87
86
|
//
|
|
88
87
|
// The queued-message box went with it: a second unmounted component, holding
|
|
89
88
|
// the file's last use of the chevrons imported for the panel.
|
|
90
|
-
/**
|
|
91
|
-
* The room's reading measure: the design system's prose width, which is what
|
|
92
|
-
* the Width setting (@hanzo/appearance) retunes. 48rem is 768px, the width this
|
|
93
|
-
* room has always read at, so an untouched setting changes nothing.
|
|
94
|
-
*/
|
|
95
|
-
const MEASURE = "var(--container-prose, 48rem)";
|
|
96
89
|
/**
|
|
97
90
|
* The text this screen arrived with, TYPED INTO THE COMPOSER — never sent.
|
|
98
91
|
*
|
|
@@ -512,7 +505,7 @@ function Thread({ placeholder = message(), initial, anonymous = false, heading,
|
|
|
512
505
|
const { limits, notice, reload: reread } = useLimits(!anonymous, org(), (id) => nameOf(id, catalog.current));
|
|
513
506
|
const mind = useMind(target, anonymous ? "free" : limits?.plan);
|
|
514
507
|
catalog.current = mind.models;
|
|
515
|
-
// Chat's effort is its own (
|
|
508
|
+
// Chat's effort is its own (six steps, sent as `reasoning_effort`); a
|
|
516
509
|
// pick of one Dev offers too moves Dev's, where it is made, and opening Chat
|
|
517
510
|
// never resets Dev's.
|
|
518
511
|
const [chatPrefs, setChatPrefs] = useChatPreferences();
|
|
@@ -1354,8 +1347,8 @@ function Thread({ placeholder = message(), initial, anonymous = false, heading,
|
|
|
1354
1347
|
window.location.assign(dev(slug));
|
|
1355
1348
|
},
|
|
1356
1349
|
};
|
|
1357
|
-
// THE COMPOSER'S
|
|
1358
|
-
//
|
|
1350
|
+
// THE COMPOSER'S SLOTS (@hanzo/ui/chat): this room hands it what it carries,
|
|
1351
|
+
// and the composer draws the rest the way the person's setting says.
|
|
1359
1352
|
// What pressing a suggestion does, at once: open what it names, send its prompt
|
|
1360
1353
|
// here (the room is a new chat while one shows), hand its run to Dev, or make
|
|
1361
1354
|
// its scheduled task and show it in Scheduled tasks.
|
|
@@ -1392,7 +1385,8 @@ function Thread({ placeholder = message(), initial, anonymous = false, heading,
|
|
|
1392
1385
|
submit(p);
|
|
1393
1386
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
1394
1387
|
}, [open, said.length]);
|
|
1395
|
-
const
|
|
1388
|
+
const families = useFamilies(mind, (id) => setAsk({ model: nameOf(id, listed) }));
|
|
1389
|
+
const composer = {
|
|
1396
1390
|
value: draft,
|
|
1397
1391
|
onChange: setDraft,
|
|
1398
1392
|
onSend: () => submit(),
|
|
@@ -1404,9 +1398,8 @@ function Thread({ placeholder = message(), initial, anonymous = false, heading,
|
|
|
1404
1398
|
// (the defaults @hanzo/ui and @hanzo/build each call ASK), said here so both are the reader's.
|
|
1405
1399
|
label: t("Ask anything"),
|
|
1406
1400
|
placeholder: t("Type / for skills"),
|
|
1407
|
-
//
|
|
1408
|
-
|
|
1409
|
-
// In the app's frame the composer floats on the pane as a pane of its own.
|
|
1401
|
+
// At the thread's measure, and in the app's frame floating on the pane as a pane of its own.
|
|
1402
|
+
column: true,
|
|
1410
1403
|
framed,
|
|
1411
1404
|
// A file or an image pasted into the field is held like a picked one;
|
|
1412
1405
|
// words paste as words.
|
|
@@ -1441,7 +1434,7 @@ function Thread({ placeholder = message(), initial, anonymous = false, heading,
|
|
|
1441
1434
|
memory: { on: carry.gear.gear.memory, set: (on) => carry.gear.set({ memory: on }) },
|
|
1442
1435
|
},
|
|
1443
1436
|
// Who is in the room, then what the conversation carries, as chips after `+`.
|
|
1444
|
-
|
|
1437
|
+
carried: [
|
|
1445
1438
|
...room.map((name) => ({
|
|
1446
1439
|
id: `agent:${name}`,
|
|
1447
1440
|
label: name,
|
|
@@ -1452,11 +1445,33 @@ function Thread({ placeholder = message(), initial, anonymous = false, heading,
|
|
|
1452
1445
|
],
|
|
1453
1446
|
slash: anonymous ? undefined : carry.skills,
|
|
1454
1447
|
at: anonymous ? undefined : carry.plugins,
|
|
1455
|
-
// Auto
|
|
1456
|
-
|
|
1457
|
-
|
|
1458
|
-
|
|
1459
|
-
|
|
1448
|
+
// The mode is Auto or Manual approval, the one Settings keeps; the person
|
|
1449
|
+
// turns the pill on in Settings → Appearance, and it is off until they do.
|
|
1450
|
+
mode: anonymous
|
|
1451
|
+
? null
|
|
1452
|
+
: {
|
|
1453
|
+
...carry.mode,
|
|
1454
|
+
set: (m) => {
|
|
1455
|
+
const approval = m === "manual" ? "manual" : "auto";
|
|
1456
|
+
setChatPrefs({ approvalMode: approval });
|
|
1457
|
+
carry.mode.set(approval);
|
|
1458
|
+
},
|
|
1459
|
+
},
|
|
1460
|
+
// The model, only where the person turned the model selector on; the effort, always.
|
|
1461
|
+
mind,
|
|
1462
|
+
effort: {
|
|
1463
|
+
value: chatPrefs.effort || "high",
|
|
1464
|
+
set: (eff) => {
|
|
1465
|
+
setChatPrefs({ effort: eff });
|
|
1466
|
+
const next = shared(eff);
|
|
1467
|
+
if (next)
|
|
1468
|
+
mind.pace(next);
|
|
1469
|
+
},
|
|
1470
|
+
items: EFFORTS,
|
|
1471
|
+
},
|
|
1472
|
+
// Chat keeps to the effort alone until the person asks for more: the family chips, the mode.
|
|
1473
|
+
chips: anonymous ? undefined : families,
|
|
1474
|
+
defaults: { chips: false, mode: false },
|
|
1460
1475
|
limits,
|
|
1461
1476
|
onUpgrade: (id) => setAsk({ model: nameOf(id, listed) }),
|
|
1462
1477
|
voice,
|
|
@@ -1464,9 +1479,8 @@ function Thread({ placeholder = message(), initial, anonymous = false, heading,
|
|
|
1464
1479
|
onLanguage: speakIn,
|
|
1465
1480
|
talk,
|
|
1466
1481
|
// While nothing has been said: what is worth doing next.
|
|
1467
|
-
|
|
1482
|
+
starters: said.length === 0 && !anonymous ? _jsx(Suggestions, { rows: hints.rows, onAct: hint, onDismiss: hints.dismiss }) : undefined,
|
|
1468
1483
|
};
|
|
1469
|
-
const mention = useMention(composing);
|
|
1470
1484
|
return (_jsxs(YStack, { flex: 1, minH: 0, width: "100%", position: "relative", "data-slot": "chat-room",
|
|
1471
1485
|
// A LINK IN AN ANSWER OPENS IN A TAB beside the conversation when the tab
|
|
1472
1486
|
// can show it — a site or preview we host — and in a browser tab of its
|
|
@@ -1510,12 +1524,10 @@ function Thread({ placeholder = message(), initial, anonymous = false, heading,
|
|
|
1510
1524
|
if (!open)
|
|
1511
1525
|
setPlan(null);
|
|
1512
1526
|
}, prompt: plan ?? "", model: model, models: models.map((m) => ({ id: m.id, name: nameOf(m.id, listed) })) }), dragging ? (_jsx(YStack, { "aria-hidden": true, position: "absolute", t: 0, r: 0, b: 0, l: 0, z: 10, items: "center", justify: "center", bg: "var(--surface-scrim)", borderWidth: 2, borderStyle: "dashed", borderColor: "$borderColor", rounded: "var(--pane-round)", pointerEvents: "none", children: _jsxs(XStack, { items: "center", gap: "$2", px: "$4", py: "$2.5", rounded: "$10", bg: "$background", borderWidth: 1, borderColor: "$borderColor", children: [_jsx(Paperclip, { size: 15, "aria-hidden": true }), _jsx(Text, { fontSize: "$4", color: "$ink", children: t("Drop files to attach") })] }) })) : null, _jsxs(XStack, { "data-slot": "conversation-head", height: BAND, items: "center", justify: "space-between", gap: "$3", paddingInlineStart: "$4", paddingInlineEnd: "$2", shrink: 0, "data-tauri-drag-region": "deep", onMouseDown: dragWindow, onDoubleClick: toggleWindowMaximize, "$max-md": !mine && !room.length ? { display: 'none' } : undefined, children: [_jsxs(XStack, { items: "center", gap: "$2", minW: 0, flex: 1, children: [mine ? (_jsx(Text, { fontSize: 15, lineHeight: 20, color: "$ink", numberOfLines: 1, shrink: 1, minW: 0, children: tidy(mine.title) })) : null, room.length ? (_jsx(XStack, { role: "list", "aria-label": t("Agents in this chat"), items: "center", gap: "$1.5", minW: 0, overflowX: "auto", "$platform-web": { scrollbarWidth: "none" }, children: room.map((name) => (_jsxs(XStack, { role: "listitem", items: "center", gap: "$1.5", paddingInlineStart: "$1", paddingInlineEnd: "$0.5", py: "$0.5", rounded: 999, borderWidth: 1, borderColor: "$borderColor", shrink: 0, children: [_jsx(Face, { src: faces[name]?.avatar ?? (name === withWhom ? portrait : undefined), emoji: faces[name]?.emoji ?? (name === withWhom ? persona?.emoji : undefined), name: name, size: 22 }), _jsx(Text, { fontSize: "$2", fontWeight: "600", color: "$color", numberOfLines: 1, display: "none", $sm: { display: "flex" }, children: name }), _jsx(Box, { render: "button", onClick: () => openAgent(name), "aria-label": t("Remove {name} from this chat", { name }), title: t("Remove {name}", { name }), width: 24, height: 24, rounded: 999, items: "center", justify: "center", hoverStyle: { bg: "$hover" }, children: _jsx(X, { size: 13, "aria-hidden": true, color: "var(--soft, var(--muted-foreground))" }) })] }, name))) })) : null] }), _jsxs(XStack, { "data-slot": "conversation-controls", "data-tauri-drag-region": "false", items: "center", gap: 4, shrink: 0, children: [free ? (_jsxs(Button, { size: "xs", variant: "outline", "data-slot": "header-upgrade", gap: "$1.5", px: "$2.5", py: "$1", rounded: "$4", cursor: "pointer", hoverStyle: { bg: 'var(--white-10)' }, onPress: () => window.location.assign(payUrl('/cart', { org: org(), returnUrl: window.location.href })), "aria-label": t("Upgrade plan"), children: [_jsx(Sparkles, { size: 13, color: "var(--primary)", "aria-hidden": true }), _jsx(Text, { fontSize: "$1", fontWeight: "600", color: "$ink", children: t("Upgrade plan") })] })) : null, open ? _jsx(Share, { thread: open }) : null, mine ? (_jsx(ConversationMenu, { threads: alone, active: open, onSchedule: anonymous ? undefined : () => setPlan(lastAsked()), children: _jsx(XStack, { children: _jsx(ThreadMore, { t: mine }) }) })) : null, _jsx(XStack, { "$max-md": { display: 'none' }, children: _jsx(Summary, { sections: sections, onOpen: () => setPanel(true), label: t("Summary") }) }), _jsx(XStack, { "$max-md": { display: 'none' }, children: _jsx(PanelToggle, { open: panel, onToggle: () => setPanel(!panel) }) })] })] }), wide && aside !== null ? (_jsx(Beside, { children: _jsx(Panel, { side: deck, kinds: NONE, onHide: () => setPanel(false), label: t("Tabs"), ...browsing }) })) : null, !wide && panel ? _jsx(Panel, { side: deck, kinds: NONE, sheet: true, onHide: () => setPanel(false), label: t("Tabs"), ...browsing }) : null, _jsx(ChatSurface, { ...chat, messages: shown, send: guarded,
|
|
1513
|
-
//
|
|
1514
|
-
// said the opening (the heading)
|
|
1515
|
-
//
|
|
1516
|
-
//
|
|
1517
|
-
// over the keyboard, from the first moment.
|
|
1518
|
-
center: media.sm,
|
|
1527
|
+
// THE COMPOSER IS FIXED TO THE FOOT, on a laptop and on a phone, empty or
|
|
1528
|
+
// not: while nothing has been said the opening (the heading) stands at the
|
|
1529
|
+
// foot of the height above it; once a turn exists the transcript scrolls
|
|
1530
|
+
// under it. Over the keyboard, from the first moment.
|
|
1519
1531
|
// AS IT WAS WRITTEN. The package renders a turn's words plainly and
|
|
1520
1532
|
// says so — it ships no markdown pipeline because the plugin set is the
|
|
1521
1533
|
// surface's to choose — so an answer arrived here reading "```ts" with
|
|
@@ -1580,22 +1592,8 @@ function Thread({ placeholder = message(), initial, anonymous = false, heading,
|
|
|
1580
1592
|
// with it when it did. `Ask` passes its own, because the page embedding
|
|
1581
1593
|
// it already has an `<h1>` and a second is the defect that took the
|
|
1582
1594
|
// landings off /chat and /dev.
|
|
1583
|
-
empty: heading === null ? undefined : (_jsxs(YStack, { "data-slot": "opening", items: "center", width: "100%", pt: "$6", pb: "$2",
|
|
1595
|
+
empty: heading === null ? undefined : (_jsxs(YStack, { "data-slot": "opening", items: "center", width: "100%", pt: "$6", pb: "$2", flex: 1, justify: "flex-end", children: [room.length > 1 ? (_jsx(XStack, { items: "center", justify: "center", mb: "$4", children: room.map((name, i) => (_jsx(Box, { marginInlineStart: i ? -16 : 0, rounded: 40, borderWidth: 2, borderColor: "$background", z: room.length - i, children: _jsx(Face, { src: faces[name]?.avatar, emoji: faces[name]?.emoji, name: name, size: 72 }) }, name))) })) : portrait ? (_jsx(Box, { width: 160, height: 160, rounded: 24, overflow: "hidden", borderWidth: 2, borderColor: "var(--white-15)", boxShadow: "0 10px 24px color-mix(in srgb, var(--pure-black) 70%, transparent)", mb: "$4", bg: "var(--neutral-900)", children: _jsx(View, { render: _jsx("img", { src: portrait, alt: withWhom }), width: "100%", height: "100%", objectFit: "cover" }) })) : null, room.length === 1 && !portrait ? (_jsx(Box, { mb: "$3", children: _jsx(Face, { emoji: mate?.emoji ?? persona?.emoji, name: withWhom, size: 72 }) })) : null, _jsx(Text, { render: "h1", fontSize: "$7", lineHeight: "$7", fontWeight: "700", color: "$ink", text: "center", mb: "$1", children: join(room, t) || heading || (firstName ? t("What’s up, {name}?", { name: firstName }) : t("What’s up?")) }), room.length === 1 && (mate?.description ?? persona?.description) ? (_jsx(Text, { fontSize: "$3", color: "$soft", text: "center", maxW: 500, mb: "$4", lineHeight: "$4", children: mate?.description ?? persona?.description })) : null] })),
|
|
1584
1596
|
// The transcript reads at the same measure. `Thread` defaults to 768
|
|
1585
1597
|
// itself; handing it the column here is what lets Width reach it.
|
|
1586
|
-
column: { maxW: MEASURE }, composer: (() =>
|
|
1587
|
-
const basePrompt = prompt({
|
|
1588
|
-
...composing,
|
|
1589
|
-
field: mention.field,
|
|
1590
|
-
}, mention.state);
|
|
1591
|
-
return {
|
|
1592
|
-
...basePrompt,
|
|
1593
|
-
send: (_jsxs(XStack, { items: "center", gap: "$1.5", shrink: 0, children: [chatPrefs.showTurboApproval ? (_jsxs(XStack, { items: "center", gap: "$1", px: "$2", py: "$1", rounded: 999, borderWidth: 1, borderColor: "$borderColor", bg: "$background", "aria-label": t("Turbo Approval: {mode}", { mode: chatPrefs.approvalMode }), children: [_jsx(Zap, { size: 12, color: "var(--primary)", "aria-hidden": true }), _jsx(Text, { fontSize: "$1", fontWeight: "600", color: "$ink", children: chatPrefs.approvalMode === "manual" ? t("Manual") : t("Turbo") })] })) : null, _jsx(ThinkingEffort, { effort: chatPrefs.effort || 'high', onChange: (eff) => {
|
|
1594
|
-
setChatPrefs({ effort: eff });
|
|
1595
|
-
const next = shared(eff);
|
|
1596
|
-
if (next)
|
|
1597
|
-
mind.pace(next);
|
|
1598
|
-
}, disabled: chat.streaming || talk.open }), basePrompt.send] })),
|
|
1599
|
-
};
|
|
1600
|
-
})() }), _jsx(AgentMaker, {}), carry.dialog, _jsx(Upgrade, { ask: ask, onClose: () => setAsk(null) })] }));
|
|
1598
|
+
column: { maxW: MEASURE }, composer: composer }), _jsx(AgentMaker, {}), carry.dialog, _jsx(Upgrade, { ask: ask, onClose: () => setAsk(null) })] }));
|
|
1601
1599
|
}
|
package/dist/SettingsPane.js
CHANGED
|
@@ -7,7 +7,7 @@ import { phrase } from '@hanzo/i18n';
|
|
|
7
7
|
import { useI18n } from '@hanzo/i18n/react';
|
|
8
8
|
import { ArrowUpRight, Check, ExternalLink, Lock, Sparkles } from 'lucide-react';
|
|
9
9
|
import { shared, useChatPreferences } from './lib/chatPreferences.js';
|
|
10
|
-
import {
|
|
10
|
+
import { EFFORTS } from '@hanzo/ui/chat/pure';
|
|
11
11
|
import { Box, Button, Input, Separator, Text, XStack, YStack, } from '@hanzo/ui';
|
|
12
12
|
import { tap } from './lib/tap.js';
|
|
13
13
|
import { useIam, useIamIdentity, useOrganizations } from '@hanzo/iam/react';
|
|
@@ -86,7 +86,7 @@ function Model() {
|
|
|
86
86
|
const { isAuthenticated } = useIam();
|
|
87
87
|
const { tier } = useTier(isAuthenticated, org());
|
|
88
88
|
const paid = Boolean(tier?.plan && tier.plan !== 'free');
|
|
89
|
-
return (_jsxs(YStack, { gap: "$5", maxW: 540, children: [_jsxs(YStack, { gap: "$2", children: [_jsx(Text, { fontSize: "$4", fontWeight: "600", color: "$ink", children: t('Default model') }), _jsx(Text, { fontSize: "$2", color: "$soft", children: t('Used for new chats and runs. An agent with its own model keeps that choice.') }), _jsx(XStack, { self: "flex-start", pt: "$1", children: _jsx(ModelPicker, { models: models, scope: "chat", value: choice.model, onChange: (id) => choose({ model: id }), size: "sm" }) })] }), _jsx(Separator, {}), _jsxs(YStack, { gap: "$2", children: [_jsx(Text, { fontSize: "$4", fontWeight: "600", color: "$ink", children: t('Default reasoning effort') }), _jsx(Text, { fontSize: "$2", color: "$soft", children: t('Sets how deeply models think before answering. Defaults to High across all plans.') }), _jsx(XStack, { gap: "$2", pt: "$1", flexWrap: "wrap", children:
|
|
89
|
+
return (_jsxs(YStack, { gap: "$5", maxW: 540, children: [_jsxs(YStack, { gap: "$2", children: [_jsx(Text, { fontSize: "$4", fontWeight: "600", color: "$ink", children: t('Default model') }), _jsx(Text, { fontSize: "$2", color: "$soft", children: t('Used for new chats and runs. An agent with its own model keeps that choice.') }), _jsx(XStack, { self: "flex-start", pt: "$1", children: _jsx(ModelPicker, { models: models, scope: "chat", value: choice.model, onChange: (id) => choose({ model: id }), size: "sm" }) })] }), _jsx(Separator, {}), _jsxs(YStack, { gap: "$2", children: [_jsx(Text, { fontSize: "$4", fontWeight: "600", color: "$ink", children: t('Default reasoning effort') }), _jsx(Text, { fontSize: "$2", color: "$soft", children: t('Sets how deeply models think before answering. Defaults to High across all plans.') }), _jsx(XStack, { gap: "$2", pt: "$1", flexWrap: "wrap", children: EFFORTS.map((step) => {
|
|
90
90
|
const active = (chatPrefs.effort || 'high') === step.id;
|
|
91
91
|
return (_jsx(Box, { render: _jsx("button", { type: "button" }), ...tap, onClick: () => {
|
|
92
92
|
setChatPrefs({ effort: step.id });
|
|
@@ -100,7 +100,7 @@ function Model() {
|
|
|
100
100
|
].map((opt) => {
|
|
101
101
|
const active = (chatPrefs.approvalMode || 'auto') === opt.id;
|
|
102
102
|
return (_jsxs(Box, { render: _jsx("button", { type: "button" }), ...tap, onClick: () => setChatPrefs({ approvalMode: opt.id }), ...CHOICE, flex: 1, p: 10, bg: active ? 'var(--edge, var(--white-14))' : 'transparent', borderColor: active ? 'var(--borderColor, var(--white-22))' : 'var(--white-08)', children: [_jsxs(XStack, { items: "center", justify: "space-between", children: [_jsx(Text, { fontSize: "$2", fontWeight: "600", color: "$ink", children: opt.label }), active ? _jsx(Check, { size: 12, color: "var(--primary)", "aria-hidden": true }) : null] }), _jsx(Text, { fontSize: "$1", color: "$soft", children: opt.desc })] }, opt.id));
|
|
103
|
-
}) })] }), _jsx(Separator, {}), _jsxs(YStack, { gap: "$3", children: [_jsx(XStack, { items: "center", justify: "space-between", children: _jsxs(YStack, { gap: "$0.5", children: [_jsxs(XStack, { items: "center", gap: "$1.5", children: [_jsx(Text, { fontSize: "$4", fontWeight: "600", color: "$ink", children: t('Advanced composer controls') }), !paid ? (_jsxs(XStack, { items: "center", gap: "$1", px: "$2", py: "$0.5", rounded: 9999, bg: "var(--edge, var(--white-10))", children: [_jsx(Lock, { size: 11, color: "$soft", "aria-hidden": true }), _jsx(Text, { fontSize: "$1", fontWeight: "600", color: "$soft", children: t('Paid plan') })] })) : null] }), _jsx(Text, { fontSize: "$2", color: "$soft", children: t('
|
|
103
|
+
}) })] }), _jsx(Separator, {}), _jsxs(YStack, { gap: "$3", children: [_jsx(XStack, { items: "center", justify: "space-between", children: _jsxs(YStack, { gap: "$0.5", children: [_jsxs(XStack, { items: "center", gap: "$1.5", children: [_jsx(Text, { fontSize: "$4", fontWeight: "600", color: "$ink", children: t('Advanced composer controls') }), !paid ? (_jsxs(XStack, { items: "center", gap: "$1", px: "$2", py: "$0.5", rounded: 9999, bg: "var(--edge, var(--white-10))", children: [_jsx(Lock, { size: 11, color: "$soft", "aria-hidden": true }), _jsx(Text, { fontSize: "$1", fontWeight: "600", color: "$soft", children: t('Paid plan') })] })) : null] }), _jsx(Text, { fontSize: "$2", color: "$soft", children: t('Third-party model access, and the language dictation listens in.') })] }) }), _jsx(YStack, { p: "$3", rounded: "$3", borderWidth: 1, borderColor: "$borderColor", gap: "$2", children: _jsxs(XStack, { items: "center", justify: "space-between", children: [_jsxs(YStack, { flex: 1, pr: "$2", children: [_jsx(Text, { fontSize: "$3", fontWeight: "600", color: "$ink", children: t('Enable third-party models') }), _jsx(Text, { fontSize: "$2", color: "$soft", children: t('Third-party models (OpenAI, Anthropic, Google, DeepSeek) are billed from your pre-paid credit topup. First-party models (Enso, Zen, Kai) are covered by your plan.') })] }), _jsx(Button, { size: "sm", variant: chatPrefs.allowThirdPartyModels ? 'default' : 'outline', disabled: !paid, onClick: () => paid && setChatPrefs({ allowThirdPartyModels: !chatPrefs.allowThirdPartyModels }), children: chatPrefs.allowThirdPartyModels ? t('Enabled') : t('Disabled') })] }) }), _jsx(YStack, { p: "$3", rounded: "$3", borderWidth: 1, borderColor: "$borderColor", gap: "$2", children: _jsxs(XStack, { items: "center", justify: "space-between", children: [_jsxs(YStack, { flex: 1, pr: "$2", children: [_jsx(Text, { fontSize: "$3", fontWeight: "600", color: "$ink", children: t('Show language selector beside +') }), _jsx(Text, { fontSize: "$2", color: "$soft", children: t('Display the dictation language indicator next to the + context button on the composer row.') })] }), _jsx(Button, { size: "sm", variant: chatPrefs.showLanguage ? 'default' : 'outline', onClick: () => setChatPrefs({ showLanguage: !chatPrefs.showLanguage }), children: chatPrefs.showLanguage ? t('Enabled') : t('Disabled') })] }) }), !paid ? (_jsx(XStack, { pt: "$1", children: _jsxs(Button, { size: "sm", variant: "outline", onClick: () => window.location.assign(site('/pricing')), children: [_jsx(Sparkles, { size: 14, color: "var(--primary)", "aria-hidden": true }), t('Upgrade to unlock advanced model controls')] }) })) : null] })] }));
|
|
104
104
|
}
|
|
105
105
|
/**
|
|
106
106
|
* WHAT THE GATEWAY SERVES, read from the same `/v1/models` the rooms read.
|
package/dist/Setup.js
CHANGED
|
@@ -31,6 +31,7 @@ import { enter } from './lib/destination.js';
|
|
|
31
31
|
import { brand, site } from './where.js';
|
|
32
32
|
import { GOOGLE_ACCOUNTS_KEY, GOOGLE_KEY, accounts, connect, drop, keep } from './lib/gmail.js';
|
|
33
33
|
import { GOOD } from './lib/mix.js';
|
|
34
|
+
import { RETURN, awaitAnswer } from './lib/oauth.js';
|
|
34
35
|
export const LATER_KEY = 'hanzo.onboarding.later';
|
|
35
36
|
export const GITHUB_KEY = 'hanzo.onboarding.github';
|
|
36
37
|
export const SLACK_KEY = 'hanzo.onboarding.slack';
|
|
@@ -199,20 +200,21 @@ export function Setup({ go } = {}) {
|
|
|
199
200
|
const activeStep = step === 1 || step === 2 || step === 3 ? step : 1;
|
|
200
201
|
if (later && !modalOpen)
|
|
201
202
|
return null;
|
|
202
|
-
const openOAuthPopup = (authorizeUrl, provider, onDone) => {
|
|
203
|
+
const openOAuthPopup = (authorizeUrl, provider, label, onDone) => {
|
|
203
204
|
const popup = window.open(authorizeUrl, `hanzo-oauth-${provider}`, 'width=600,height=700');
|
|
204
205
|
if (!popup) {
|
|
205
206
|
window.open(authorizeUrl, '_blank', 'noopener,noreferrer');
|
|
207
|
+
return;
|
|
206
208
|
}
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
}
|
|
214
|
-
|
|
215
|
-
}
|
|
209
|
+
// The return page hands the answer back and closes the popup (lib/oauth);
|
|
210
|
+
// a popup closed without one still re-reads what is connected.
|
|
211
|
+
awaitAnswer(popup, provider, (answer) => {
|
|
212
|
+
if (answer?.ok)
|
|
213
|
+
onDone();
|
|
214
|
+
else if (answer)
|
|
215
|
+
setErrorMsg(t('Could not connect {provider} right now. Please try again.', { provider: label }));
|
|
216
|
+
setSyncTurn((n) => n + 1);
|
|
217
|
+
});
|
|
216
218
|
};
|
|
217
219
|
const connectOAuthProvider = async (provider, label, onDone) => {
|
|
218
220
|
if (!signed) {
|
|
@@ -238,7 +240,9 @@ export function Setup({ go } = {}) {
|
|
|
238
240
|
const res = await fetch(`${api()}/v1/provider/${provider}/connect`, {
|
|
239
241
|
method: 'POST',
|
|
240
242
|
headers: { ...scope(), 'Content-Type': 'application/json' },
|
|
241
|
-
|
|
243
|
+
// Without a return the callback lands on the console's /connectors,
|
|
244
|
+
// where the popup stays open; RETURN is the page that closes it.
|
|
245
|
+
body: JSON.stringify({ return: RETURN }),
|
|
242
246
|
});
|
|
243
247
|
if (!res.ok) {
|
|
244
248
|
let detail = '';
|
|
@@ -257,7 +261,7 @@ export function Setup({ go } = {}) {
|
|
|
257
261
|
}
|
|
258
262
|
const j = (await res.json());
|
|
259
263
|
if (j.authorizeUrl) {
|
|
260
|
-
openOAuthPopup(j.authorizeUrl, provider, onDone);
|
|
264
|
+
openOAuthPopup(j.authorizeUrl, provider, label, onDone);
|
|
261
265
|
}
|
|
262
266
|
else if (j.connected) {
|
|
263
267
|
onDone();
|
package/dist/agents.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Host } from '@hanzo/build';
|
|
2
|
-
export type { Link, Shelf, ShelfRow as Row } from '@hanzo/
|
|
2
|
+
export type { Link, Shelf, ShelfRow as Row } from '@hanzo/ui/chat';
|
|
3
3
|
/**
|
|
4
4
|
* The model that draws an agent's face: Hanzo's own image SKU (hanzo-inc/zen
|
|
5
5
|
* catalog.yaml `zen-image`), named on every call, because the endpoint takes
|
package/dist/dev.js
CHANGED
|
@@ -41,7 +41,6 @@ import { CAST } from './agents.js';
|
|
|
41
41
|
import { app, place, settings, visit } from './lib/host.js';
|
|
42
42
|
import { link } from './lib/tags.js';
|
|
43
43
|
import { payUrl } from './lib/pay.js';
|
|
44
|
-
import { useChatPreferences } from './lib/chatPreferences.js';
|
|
45
44
|
/** Where the builder links out: every one of them an address of this site. */
|
|
46
45
|
const LINKS = {
|
|
47
46
|
github: app('-/sync'),
|
|
@@ -81,7 +80,6 @@ export function useDevHost() {
|
|
|
81
80
|
const { router, path: pathname } = useRooms();
|
|
82
81
|
const here = path(route(at(pathname)));
|
|
83
82
|
const look = useLook();
|
|
84
|
-
const [prefs] = useChatPreferences();
|
|
85
83
|
// The token's claims change only when the token does: a sign-in, a refresh.
|
|
86
84
|
const memberships = useMemo(() => orgs(), [accessToken]); // eslint-disable-line react-hooks/exhaustive-deps
|
|
87
85
|
const scoped = useMemo(() => org(), [accessToken]); // eslint-disable-line react-hooks/exhaustive-deps
|
|
@@ -113,8 +111,6 @@ export function useDevHost() {
|
|
|
113
111
|
links: LINKS,
|
|
114
112
|
// The sidebar lists Settings' sections and Customize's tabs (Column.tsx), and Customize › Agents offers the cast.
|
|
115
113
|
sections: true,
|
|
116
|
-
// The model is named, and its picker offered, only where Settings' model selector is on (as in Chat).
|
|
117
|
-
models: prefs.showModelSelector,
|
|
118
114
|
cast: CAST,
|
|
119
115
|
// An address of the app moves the app, another of this site moves in the
|
|
120
116
|
// router, and another origin is left in this tab. platform.hanzo.ai is
|
|
@@ -138,5 +134,5 @@ export function useDevHost() {
|
|
|
138
134
|
},
|
|
139
135
|
signIn: () => enter(),
|
|
140
136
|
signOut: () => void logout(),
|
|
141
|
-
}), [scoped, memberships, look.pref.theme, look.set,
|
|
137
|
+
}), [scoped, memberships, look.pref.theme, look.set, name, email, avatar, here, router, logout]);
|
|
142
138
|
}
|
|
@@ -1,17 +1,16 @@
|
|
|
1
|
-
import { type Effort } from '@hanzo/build/mind';
|
|
2
|
-
import { type
|
|
1
|
+
import { type Effort as Level } from '@hanzo/build/mind';
|
|
2
|
+
import { type Effort } from '@hanzo/ui/chat/pure';
|
|
3
3
|
export type ApprovalMode = 'auto' | 'manual';
|
|
4
|
+
export declare const DEFAULT_EFFORT: Effort;
|
|
4
5
|
export interface ChatPreferences {
|
|
5
|
-
showModelSelector: boolean;
|
|
6
6
|
allowThirdPartyModels: boolean;
|
|
7
|
-
effort:
|
|
7
|
+
effort: Effort;
|
|
8
8
|
approvalMode: ApprovalMode;
|
|
9
9
|
showLanguage?: boolean;
|
|
10
|
-
showTurboApproval?: boolean;
|
|
11
10
|
effortVersion?: number;
|
|
12
11
|
}
|
|
13
12
|
/** The effort Dev takes for one chosen here (@hanzo/build `EFFORTS`: Auto, High, XHigh, Max), or null for Low and Medium, which only Chat offers. */
|
|
14
|
-
export declare function shared(effort:
|
|
13
|
+
export declare function shared(effort: Effort): Level | null;
|
|
15
14
|
export declare function getChatPreferences(): ChatPreferences;
|
|
16
15
|
export declare function setChatPreferences(patch: Partial<ChatPreferences>): ChatPreferences;
|
|
17
16
|
export declare function useChatPreferences(): [ChatPreferences, (patch: Partial<ChatPreferences>) => void];
|
|
@@ -1,31 +1,33 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Chat composer
|
|
3
|
-
*
|
|
2
|
+
* What Chat does, kept in this browser. What the composer DRAWS (the key that
|
|
3
|
+
* sends, the chips, the model selector, the mode) is not here: it is one setting
|
|
4
|
+
* for every composer (@hanzo/appearance `composing`, Settings → Appearance).
|
|
4
5
|
* - allowThirdPartyModels: whether 3rd-party models (OpenAI, Anthropic, etc.) are enabled via pre-paid credit (default: false)
|
|
5
6
|
* - approvalMode: whether tools/actions run automatically ('auto') or ask for confirmation first ('manual') (default: 'auto')
|
|
7
|
+
* - effort: the reasoning effort a message asks for (default: high)
|
|
8
|
+
* - showLanguage: dictation listens in the person's own language rather than Auto
|
|
6
9
|
*/
|
|
7
10
|
import { useEffect, useState } from 'react';
|
|
8
|
-
import { EFFORTS } from '@hanzo/build/mind';
|
|
9
|
-
import {
|
|
11
|
+
import { EFFORTS as DEV } from '@hanzo/build/mind';
|
|
12
|
+
import { EFFORTS } from '@hanzo/ui/chat/pure';
|
|
13
|
+
export const DEFAULT_EFFORT = 'high';
|
|
10
14
|
const STORAGE_KEY = 'hanzo.chat.preferences';
|
|
11
15
|
const AUTONOMY_KEY = 'hanzo.agent.autonomy';
|
|
12
16
|
const EVENT_NAME = 'hanzo:chat:preferences';
|
|
13
17
|
const EFFORT_SCHEMA_VERSION = 3;
|
|
14
18
|
const DEFAULT_PREFERENCES = {
|
|
15
|
-
showModelSelector: false,
|
|
16
19
|
allowThirdPartyModels: false,
|
|
17
20
|
effort: DEFAULT_EFFORT,
|
|
18
21
|
approvalMode: 'auto',
|
|
19
22
|
showLanguage: false,
|
|
20
|
-
showTurboApproval: false,
|
|
21
23
|
effortVersion: EFFORT_SCHEMA_VERSION,
|
|
22
24
|
};
|
|
23
25
|
/** The effort Dev takes for one chosen here (@hanzo/build `EFFORTS`: Auto, High, XHigh, Max), or null for Low and Medium, which only Chat offers. */
|
|
24
26
|
export function shared(effort) {
|
|
25
|
-
return
|
|
27
|
+
return DEV.some((e) => e.id === effort) ? effort : null;
|
|
26
28
|
}
|
|
27
29
|
function validEffort(v) {
|
|
28
|
-
return
|
|
30
|
+
return EFFORTS.some((s) => s.id === v) ? v : DEFAULT_EFFORT;
|
|
29
31
|
}
|
|
30
32
|
function validApprovalMode(v, fallbackAutonomy) {
|
|
31
33
|
if (v === 'manual' || v === 'auto')
|
|
@@ -49,12 +51,10 @@ export function getChatPreferences() {
|
|
|
49
51
|
const parsed = JSON.parse(raw);
|
|
50
52
|
const migratedEffort = parsed.effortVersion === EFFORT_SCHEMA_VERSION ? validEffort(parsed.effort) : DEFAULT_EFFORT;
|
|
51
53
|
return {
|
|
52
|
-
showModelSelector: Boolean(parsed.showModelSelector),
|
|
53
54
|
allowThirdPartyModels: Boolean(parsed.allowThirdPartyModels),
|
|
54
55
|
effort: migratedEffort,
|
|
55
56
|
approvalMode: validApprovalMode(parsed.approvalMode, autonomy),
|
|
56
57
|
showLanguage: Boolean(parsed.showLanguage),
|
|
57
|
-
showTurboApproval: Boolean(parsed.showTurboApproval),
|
|
58
58
|
effortVersion: EFFORT_SCHEMA_VERSION,
|
|
59
59
|
};
|
|
60
60
|
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A provider's OAuth in a popup, and its answer back in the window that opened it.
|
|
3
|
+
*
|
|
4
|
+
* `/v1/provider/:provider/connect` answers an authorize URL; the provider sends the
|
|
5
|
+
* browser to api.hanzo.ai's callback, which 302s to the return page the connect
|
|
6
|
+
* named with `connected=<provider>&account=<label>` or `error=<provider>&reason=<why>`
|
|
7
|
+
* on its query. A connect that names no return lands on the console's /connectors,
|
|
8
|
+
* a whole other app on another origin: the popup stayed open there and the opener
|
|
9
|
+
* never heard. So the connect names `RETURN`, this site's registered return page
|
|
10
|
+
* (cloud brand.Info.Returns), where the site's first script (hanzo.ai app/page.tsx
|
|
11
|
+
* `RETURNED`) hands the answer to the opener and closes the popup.
|
|
12
|
+
*
|
|
13
|
+
* The answer arrives three ways, whichever reaches first: a `message` from the
|
|
14
|
+
* popup (same origin only), a `BroadcastChannel` post or a `storage` write for an
|
|
15
|
+
* opener the popup lost (`window.opener` is null after a cross-origin-isolated
|
|
16
|
+
* page). The opener also reads the popup's address itself once it is back on
|
|
17
|
+
* this origin, and closes it, so a popup that cannot close itself still does.
|
|
18
|
+
*/
|
|
19
|
+
/** The return page the connect names: hanzo.ai's Settings → Integrations, registered with the API. */
|
|
20
|
+
export declare const RETURN = "https://hanzo.ai/?at=-/settings/integrations";
|
|
21
|
+
/** The message, channel and storage key one answer travels by. */
|
|
22
|
+
export declare const RETURNED = "hanzo-oauth-return";
|
|
23
|
+
/** What the provider answered. */
|
|
24
|
+
export type Answer = {
|
|
25
|
+
type: typeof RETURNED;
|
|
26
|
+
provider: string;
|
|
27
|
+
ok: true;
|
|
28
|
+
account: string;
|
|
29
|
+
} | {
|
|
30
|
+
type: typeof RETURNED;
|
|
31
|
+
provider: string;
|
|
32
|
+
ok: false;
|
|
33
|
+
reason: string;
|
|
34
|
+
};
|
|
35
|
+
/** The answer a return page's query carries, or null when it carries none. */
|
|
36
|
+
export declare function answered(search: string): Answer | null;
|
|
37
|
+
/** `data` as an answer for `provider`, or null when it is anything else. */
|
|
38
|
+
export declare function heard(data: unknown, provider: string): Answer | null;
|
|
39
|
+
/**
|
|
40
|
+
* Wait for `provider`'s answer to the popup. `done` is called once: with the
|
|
41
|
+
* answer, or with null when the popup closed without one. Answers the cleanup.
|
|
42
|
+
*/
|
|
43
|
+
export declare function awaitAnswer(popup: Window, provider: string, done: (answer: Answer | null) => void): () => void;
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A provider's OAuth in a popup, and its answer back in the window that opened it.
|
|
3
|
+
*
|
|
4
|
+
* `/v1/provider/:provider/connect` answers an authorize URL; the provider sends the
|
|
5
|
+
* browser to api.hanzo.ai's callback, which 302s to the return page the connect
|
|
6
|
+
* named with `connected=<provider>&account=<label>` or `error=<provider>&reason=<why>`
|
|
7
|
+
* on its query. A connect that names no return lands on the console's /connectors,
|
|
8
|
+
* a whole other app on another origin: the popup stayed open there and the opener
|
|
9
|
+
* never heard. So the connect names `RETURN`, this site's registered return page
|
|
10
|
+
* (cloud brand.Info.Returns), where the site's first script (hanzo.ai app/page.tsx
|
|
11
|
+
* `RETURNED`) hands the answer to the opener and closes the popup.
|
|
12
|
+
*
|
|
13
|
+
* The answer arrives three ways, whichever reaches first: a `message` from the
|
|
14
|
+
* popup (same origin only), a `BroadcastChannel` post or a `storage` write for an
|
|
15
|
+
* opener the popup lost (`window.opener` is null after a cross-origin-isolated
|
|
16
|
+
* page). The opener also reads the popup's address itself once it is back on
|
|
17
|
+
* this origin, and closes it, so a popup that cannot close itself still does.
|
|
18
|
+
*/
|
|
19
|
+
/** The return page the connect names: hanzo.ai's Settings → Integrations, registered with the API. */
|
|
20
|
+
export const RETURN = 'https://hanzo.ai/?at=-/settings/integrations';
|
|
21
|
+
/** The message, channel and storage key one answer travels by. */
|
|
22
|
+
export const RETURNED = 'hanzo-oauth-return';
|
|
23
|
+
/** The answer a return page's query carries, or null when it carries none. */
|
|
24
|
+
export function answered(search) {
|
|
25
|
+
const q = new URLSearchParams(search);
|
|
26
|
+
const ok = q.get('connected');
|
|
27
|
+
if (ok)
|
|
28
|
+
return { type: RETURNED, provider: ok, ok: true, account: q.get('account') ?? '' };
|
|
29
|
+
const failed = q.get('error');
|
|
30
|
+
if (failed && q.has('reason'))
|
|
31
|
+
return { type: RETURNED, provider: failed, ok: false, reason: q.get('reason') ?? '' };
|
|
32
|
+
return null;
|
|
33
|
+
}
|
|
34
|
+
/** `data` as an answer for `provider`, or null when it is anything else. */
|
|
35
|
+
export function heard(data, provider) {
|
|
36
|
+
if (!data || typeof data !== 'object')
|
|
37
|
+
return null;
|
|
38
|
+
const a = data;
|
|
39
|
+
if (a.type !== RETURNED || a.provider !== provider || typeof a.ok !== 'boolean')
|
|
40
|
+
return null;
|
|
41
|
+
const text = (v) => (typeof v === 'string' ? v : '');
|
|
42
|
+
return a.ok ? { type: RETURNED, provider, ok: true, account: text(a.account) } : { type: RETURNED, provider, ok: false, reason: text(a.reason) };
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Wait for `provider`'s answer to the popup. `done` is called once: with the
|
|
46
|
+
* answer, or with null when the popup closed without one. Answers the cleanup.
|
|
47
|
+
*/
|
|
48
|
+
export function awaitAnswer(popup, provider, done) {
|
|
49
|
+
let over = false;
|
|
50
|
+
let channel = null;
|
|
51
|
+
const finish = (answer) => {
|
|
52
|
+
if (over)
|
|
53
|
+
return;
|
|
54
|
+
over = true;
|
|
55
|
+
stop();
|
|
56
|
+
try {
|
|
57
|
+
if (!popup.closed)
|
|
58
|
+
popup.close();
|
|
59
|
+
}
|
|
60
|
+
catch {
|
|
61
|
+
/* already gone */
|
|
62
|
+
}
|
|
63
|
+
done(answer);
|
|
64
|
+
};
|
|
65
|
+
const onMessage = (ev) => {
|
|
66
|
+
if (ev.origin !== window.location.origin)
|
|
67
|
+
return;
|
|
68
|
+
const a = heard(ev.data, provider);
|
|
69
|
+
if (a)
|
|
70
|
+
finish(a);
|
|
71
|
+
};
|
|
72
|
+
const onStorage = (ev) => {
|
|
73
|
+
if (ev.key !== RETURNED || !ev.newValue)
|
|
74
|
+
return;
|
|
75
|
+
try {
|
|
76
|
+
const a = heard(JSON.parse(ev.newValue), provider);
|
|
77
|
+
if (a)
|
|
78
|
+
finish(a);
|
|
79
|
+
}
|
|
80
|
+
catch {
|
|
81
|
+
/* not an answer */
|
|
82
|
+
}
|
|
83
|
+
};
|
|
84
|
+
const timer = window.setInterval(() => {
|
|
85
|
+
if (popup.closed) {
|
|
86
|
+
finish(null);
|
|
87
|
+
return;
|
|
88
|
+
}
|
|
89
|
+
try {
|
|
90
|
+
// Cross-origin (the provider, api.hanzo.ai) until the return page: reading throws.
|
|
91
|
+
if (popup.location.origin !== window.location.origin)
|
|
92
|
+
return;
|
|
93
|
+
const a = answered(popup.location.search);
|
|
94
|
+
if (a && a.provider === provider)
|
|
95
|
+
finish(a);
|
|
96
|
+
}
|
|
97
|
+
catch {
|
|
98
|
+
/* still away */
|
|
99
|
+
}
|
|
100
|
+
}, 250);
|
|
101
|
+
const stop = () => {
|
|
102
|
+
window.clearInterval(timer);
|
|
103
|
+
window.removeEventListener('message', onMessage);
|
|
104
|
+
window.removeEventListener('storage', onStorage);
|
|
105
|
+
channel?.close();
|
|
106
|
+
};
|
|
107
|
+
window.addEventListener('message', onMessage);
|
|
108
|
+
window.addEventListener('storage', onStorage);
|
|
109
|
+
if (typeof BroadcastChannel !== 'undefined') {
|
|
110
|
+
channel = new BroadcastChannel(RETURNED);
|
|
111
|
+
channel.onmessage = (ev) => {
|
|
112
|
+
const a = heard(ev.data, provider);
|
|
113
|
+
if (a)
|
|
114
|
+
finish(a);
|
|
115
|
+
};
|
|
116
|
+
}
|
|
117
|
+
return () => {
|
|
118
|
+
over = true;
|
|
119
|
+
stop();
|
|
120
|
+
};
|
|
121
|
+
}
|
package/dist/lib/signout.js
CHANGED
|
@@ -35,7 +35,6 @@ export const OUT = '/login?from=logout';
|
|
|
35
35
|
* the session. A third-party app the person signed into keeps its own.
|
|
36
36
|
*/
|
|
37
37
|
export function useSignOut() {
|
|
38
|
-
// @ts-expect-error everywhere option added in @hanzo/ui / IAM shared sign-out
|
|
39
38
|
const signOut = useUiSignOut({ to: OUT, track, everywhere: true });
|
|
40
39
|
return useCallback(async () => {
|
|
41
40
|
// Google One Tap signs a returning person in on its own (`auto_select`), which
|
package/dist/look.js
CHANGED
|
@@ -16,7 +16,7 @@ import { setActivePlatform, BUILTIN_MODS, applyMod, exportMod, importMod, inject
|
|
|
16
16
|
import { api } from './lib/api.js';
|
|
17
17
|
import { useChatPreferences } from './lib/chatPreferences.js';
|
|
18
18
|
import { useOrg } from './host.js';
|
|
19
|
-
import {
|
|
19
|
+
import { EFFORTS } from '@hanzo/ui/chat/pure';
|
|
20
20
|
import { brand } from './where.js';
|
|
21
21
|
import { tap } from './lib/tap.js';
|
|
22
22
|
const CHOICE = { rounded: 8, borderWidth: 1, borderStyle: 'solid', cursor: 'pointer' };
|
|
@@ -91,7 +91,7 @@ export function Look() {
|
|
|
91
91
|
].map((opt) => {
|
|
92
92
|
const active = (chatPrefs.approvalMode || 'auto') === opt.id;
|
|
93
93
|
return (_jsxs(Box, { render: _jsx("button", { type: "button" }), ...tap, onClick: () => setChatPrefs({ approvalMode: opt.id }), ...CHOICE, flex: 1, p: "$2.5", bg: active ? 'var(--edge, var(--white-14))' : 'transparent', borderColor: active ? 'var(--borderColor, var(--white-22))' : 'var(--white-08)', children: [_jsxs(XStack, { items: "center", justify: "space-between", children: [_jsx(Text, { fontSize: "$3", fontWeight: active ? '600' : '500', color: "$ink", children: opt.label }), active ? _jsx(Check, { size: 16, color: "var(--primary)", "aria-hidden": true }) : null] }), _jsx(Text, { fontSize: "$1", color: "$soft", children: opt.note })] }, opt.id));
|
|
94
|
-
}) })] }), _jsx(Separator, {}), _jsxs(YStack, { gap: "$2", "data-slot": "settings-reasoning-effort", children: [_jsx(Text, { fontSize: "$4", fontWeight: "600", color: "$ink", children: t('Default Reasoning Effort') }), _jsx(Text, { fontSize: "$2", color: "$soft", children: t('Sets how deeply models think before answering. Defaults to High.') }), _jsx(XStack, { gap: "$2", pt: "$1", flexWrap: "wrap", children:
|
|
94
|
+
}) })] }), _jsx(Separator, {}), _jsxs(YStack, { gap: "$2", "data-slot": "settings-reasoning-effort", children: [_jsx(Text, { fontSize: "$4", fontWeight: "600", color: "$ink", children: t('Default Reasoning Effort') }), _jsx(Text, { fontSize: "$2", color: "$soft", children: t('Sets how deeply models think before answering. Defaults to High.') }), _jsx(XStack, { gap: "$2", pt: "$1", flexWrap: "wrap", children: EFFORTS.map((step) => {
|
|
95
95
|
const active = (chatPrefs.effort || 'high') === step.id;
|
|
96
96
|
return (_jsx(Box, { render: _jsx("button", { type: "button" }), ...tap, onClick: () => setChatPrefs({ effort: step.id }), ...CHOICE, py: 6, px: 12, bg: active ? 'var(--edge, var(--white-14))' : 'transparent', borderColor: active ? 'var(--borderColor, var(--white-22))' : 'var(--white-08)', children: _jsxs(XStack, { items: "center", gap: "$1.5", children: [_jsx(Text, { fontSize: "$2", fontWeight: active ? '600' : '400', color: active ? '$ink' : '$soft', children: step.label }), active ? _jsx(Check, { size: 12, color: "var(--primary)", "aria-hidden": true }) : null] }) }, step.id));
|
|
97
97
|
}) })] })] }));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hanzo/app",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.43",
|
|
4
4
|
"description": "Hanzo's app: the shell and its apps (Home, Chat, Inbox, Contacts, Meet, Calendar, Drive, Board, Work, Bots), once, for every Hanzo surface.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -50,8 +50,8 @@
|
|
|
50
50
|
},
|
|
51
51
|
"peerDependencies": {
|
|
52
52
|
"@hanzo/ai": ">=0.6.23",
|
|
53
|
-
"@hanzo/appearance": ">=0.2.
|
|
54
|
-
"@hanzo/build": ">=0.2.
|
|
53
|
+
"@hanzo/appearance": ">=0.2.12",
|
|
54
|
+
"@hanzo/build": ">=0.2.84",
|
|
55
55
|
"@hanzo/composer": ">=0.2.0",
|
|
56
56
|
"@hanzo/event": ">=0.3.56",
|
|
57
57
|
"@hanzo/gui": "^8.3.5",
|
|
@@ -60,7 +60,7 @@
|
|
|
60
60
|
"@hanzo/logo": ">=1.0.26",
|
|
61
61
|
"@hanzo/studio": ">=0.1.0",
|
|
62
62
|
"@hanzo/tabs": ">=0.1.8",
|
|
63
|
-
"@hanzo/ui": ">=8.29.
|
|
63
|
+
"@hanzo/ui": ">=8.29.16",
|
|
64
64
|
"@hanzo/usage": ">=0.1.18",
|
|
65
65
|
"@hanzo/voice": ">=0.1.16",
|
|
66
66
|
"@hanzogui/shell": "^8.3.20",
|
|
@@ -70,8 +70,8 @@
|
|
|
70
70
|
},
|
|
71
71
|
"devDependencies": {
|
|
72
72
|
"@hanzo/ai": "0.6.23",
|
|
73
|
-
"@hanzo/appearance": "0.2.
|
|
74
|
-
"@hanzo/build": "0.2.
|
|
73
|
+
"@hanzo/appearance": "0.2.12",
|
|
74
|
+
"@hanzo/build": "0.2.84",
|
|
75
75
|
"@hanzo/composer": "0.2.0",
|
|
76
76
|
"@hanzo/design": "0.5.34",
|
|
77
77
|
"@hanzo/event": "0.3.56",
|
|
@@ -81,7 +81,7 @@
|
|
|
81
81
|
"@hanzo/logo": "1.0.26",
|
|
82
82
|
"@hanzo/studio": "0.1.0",
|
|
83
83
|
"@hanzo/tabs": "github:hanzo-inc/tabs",
|
|
84
|
-
"@hanzo/ui": "8.29.
|
|
84
|
+
"@hanzo/ui": "8.29.23",
|
|
85
85
|
"@hanzo/usage": "0.1.18",
|
|
86
86
|
"@hanzo/voice": "0.1.19",
|
|
87
87
|
"@hanzogui/config": "8.3.5",
|
package/dist/ThinkingEffort.d.ts
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
export type EffortLevel = 'auto' | 'low' | 'medium' | 'high' | 'xhigh' | 'max';
|
|
3
|
-
export declare const DEFAULT_EFFORT: EffortLevel;
|
|
4
|
-
export interface EffortStep {
|
|
5
|
-
id: EffortLevel;
|
|
6
|
-
label: string;
|
|
7
|
-
note: string;
|
|
8
|
-
}
|
|
9
|
-
export declare const EFFORT_STEPS: readonly EffortStep[];
|
|
10
|
-
export interface ThinkingEffortProps {
|
|
11
|
-
effort?: EffortLevel;
|
|
12
|
-
onChange: (effort: EffortLevel) => void;
|
|
13
|
-
disabled?: boolean;
|
|
14
|
-
}
|
|
15
|
-
/**
|
|
16
|
-
* Native iOS widget-style Thinking effort selector matching standard Safari mobile symmetry:
|
|
17
|
-
* - Subtle pill button showing only the active effort level ("High ⌄")
|
|
18
|
-
* - Segmented slider popover with discrete stop dots and smooth active fill
|
|
19
|
-
* - Default level: "high" across all plans
|
|
20
|
-
*/
|
|
21
|
-
export declare function ThinkingEffort({ effort, onChange, disabled }: ThinkingEffortProps): React.JSX.Element;
|
package/dist/ThinkingEffort.js
DELETED
|
@@ -1,97 +0,0 @@
|
|
|
1
|
-
'use client';
|
|
2
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
-
import { useRef, useState } from 'react';
|
|
4
|
-
import { Box, Popover, PopoverContent, PopoverTrigger, Text, XStack, YStack } from '@hanzo/ui';
|
|
5
|
-
import { ChevronDown, ChevronRight } from 'lucide-react';
|
|
6
|
-
import { useI18n } from '@hanzo/i18n/react';
|
|
7
|
-
export const DEFAULT_EFFORT = 'high';
|
|
8
|
-
export const EFFORT_STEPS = [
|
|
9
|
-
{ id: 'auto', label: 'Auto', note: 'Adaptive reasoning based on task complexity' },
|
|
10
|
-
{ id: 'low', label: 'Low', note: 'A quick pass with minimal thinking' },
|
|
11
|
-
{ id: 'medium', label: 'Medium', note: 'Thinks before answering' },
|
|
12
|
-
{ id: 'high', label: 'High', note: 'Deep reasoning for complex problems' },
|
|
13
|
-
{ id: 'xhigh', label: 'XHigh', note: 'Extended multi-step reasoning for hard tasks' },
|
|
14
|
-
{ id: 'max', label: 'Max', note: 'Maximum compute and exhaustive verification' },
|
|
15
|
-
];
|
|
16
|
-
/**
|
|
17
|
-
* Native iOS widget-style Thinking effort selector matching standard Safari mobile symmetry:
|
|
18
|
-
* - Subtle pill button showing only the active effort level ("High ⌄")
|
|
19
|
-
* - Segmented slider popover with discrete stop dots and smooth active fill
|
|
20
|
-
* - Default level: "high" across all plans
|
|
21
|
-
*/
|
|
22
|
-
export function ThinkingEffort({ effort = DEFAULT_EFFORT, onChange, disabled = false }) {
|
|
23
|
-
const { t } = useI18n();
|
|
24
|
-
const [open, setOpen] = useState(false);
|
|
25
|
-
const [dragging, setDragging] = useState(false);
|
|
26
|
-
const trackRef = useRef(null);
|
|
27
|
-
const foundIndex = EFFORT_STEPS.findIndex((s) => s.id === effort);
|
|
28
|
-
const activeIndex = foundIndex >= 0 ? foundIndex : EFFORT_STEPS.findIndex((s) => s.id === DEFAULT_EFFORT);
|
|
29
|
-
const current = EFFORT_STEPS[activeIndex] ?? EFFORT_STEPS[3];
|
|
30
|
-
const updateFromPosition = (clientX) => {
|
|
31
|
-
if (!trackRef.current)
|
|
32
|
-
return;
|
|
33
|
-
const rect = trackRef.current.getBoundingClientRect();
|
|
34
|
-
const relativeX = Math.max(0, Math.min(clientX - rect.left, rect.width));
|
|
35
|
-
const ratio = rect.width > 0 ? relativeX / rect.width : 0;
|
|
36
|
-
const stepIndex = Math.round(ratio * (EFFORT_STEPS.length - 1));
|
|
37
|
-
const selected = EFFORT_STEPS[stepIndex];
|
|
38
|
-
if (selected && selected.id !== effort) {
|
|
39
|
-
onChange(selected.id);
|
|
40
|
-
}
|
|
41
|
-
};
|
|
42
|
-
const handlePointerDown = (e) => {
|
|
43
|
-
if (disabled)
|
|
44
|
-
return;
|
|
45
|
-
setDragging(true);
|
|
46
|
-
e.target.setPointerCapture?.(e.pointerId);
|
|
47
|
-
updateFromPosition(e.clientX);
|
|
48
|
-
};
|
|
49
|
-
const handlePointerMove = (e) => {
|
|
50
|
-
if (!dragging || disabled)
|
|
51
|
-
return;
|
|
52
|
-
updateFromPosition(e.clientX);
|
|
53
|
-
};
|
|
54
|
-
const handlePointerUp = (e) => {
|
|
55
|
-
if (dragging) {
|
|
56
|
-
setDragging(false);
|
|
57
|
-
e.target.releasePointerCapture?.(e.pointerId);
|
|
58
|
-
}
|
|
59
|
-
};
|
|
60
|
-
const percentage = (activeIndex / (EFFORT_STEPS.length - 1)) * 100;
|
|
61
|
-
return (_jsxs(Popover, { open: open, onOpenChange: setOpen, allowFlip: true, children: [_jsx(PopoverTrigger, { disabled: disabled, children: _jsxs(XStack, { "data-slot": "thinking-effort-pill", role: "button", tabIndex: disabled ? -1 : 0, "aria-label": t('Thinking effort: {label}', { label: current.label }), "aria-haspopup": "dialog", "aria-expanded": open, items: "center", gap: "$1", px: "$2.5", height: 32, rounded: 9999, cursor: disabled ? 'default' : 'pointer', bg: "var(--edge, var(--white-10))", borderWidth: 1, borderColor: "var(--pane-edge, var(--white-10))", hoverStyle: disabled ? undefined : { bg: '$hover' }, focusVisibleStyle: { outlineColor: '$outlineColor', outlineWidth: 2, outlineStyle: 'solid' }, opacity: disabled ? 0.45 : 1, onKeyDown: (e) => {
|
|
62
|
-
if (disabled)
|
|
63
|
-
return;
|
|
64
|
-
if (e.key === 'Enter' || e.key === ' ' || e.key === 'ArrowUp' || e.key === 'ArrowDown') {
|
|
65
|
-
e.preventDefault();
|
|
66
|
-
setOpen(true);
|
|
67
|
-
}
|
|
68
|
-
}, children: [_jsx(Text, { fontSize: "$2", fontWeight: "500", color: "$ink", children: t(current.label) }), _jsx(ChevronDown, { size: 12, color: "var(--soft, var(--muted-foreground))", "aria-hidden": true })] }) }), _jsx(PopoverContent, { solid: true, align: "end", p: "$3", width: 260, minW: 260, maxW: 260, items: "stretch", rounded: "$4", bg: "var(--pane-fill, var(--surface-card))", borderWidth: 1, borderColor: "var(--pane-edge, var(--white-15))", boxShadow: "var(--shadow-sheet-1)", backdropFilter: "var(--pane-blur, blur(24px) saturate(190%))", children: _jsxs(YStack, { gap: "$3", width: "100%", minW: 234, maxW: 234, self: "stretch", "data-slot": "thinking-effort-card", role: "dialog", "aria-label": t('Thinking effort'), children: [_jsxs(XStack, { items: "center", justify: "center", gap: "$1", cursor: "pointer", onClick: () => {
|
|
69
|
-
if (disabled)
|
|
70
|
-
return;
|
|
71
|
-
const next = EFFORT_STEPS[(activeIndex + 1) % EFFORT_STEPS.length];
|
|
72
|
-
if (next)
|
|
73
|
-
onChange(next.id);
|
|
74
|
-
}, children: [_jsx(Text, { fontSize: "$3", fontWeight: "600", color: "$ink", children: current.label }), _jsx(ChevronRight, { size: 14, color: "var(--soft, var(--muted-foreground))", "aria-hidden": true })] }), _jsxs(Box, { ref: trackRef, "data-slot": "thinking-slider-track", role: "slider", "aria-valuemin": 0, "aria-valuemax": EFFORT_STEPS.length - 1, "aria-valuenow": activeIndex, "aria-valuetext": current.label, position: "relative", width: "100%", height: 28, rounded: 9999, bg: "var(--edge, var(--white-14))", cursor: "pointer", onPointerDown: handlePointerDown, onPointerMove: handlePointerMove, onPointerUp: handlePointerUp, onPointerCancel: () => setDragging(false),
|
|
75
|
-
// inline-style: touch-action for discrete slider gestures
|
|
76
|
-
style: { touchAction: 'none' }, children: [_jsx(Box, { position: "absolute", insetInlineStart: 0, t: 0, b: 0, rounded: 9999, bg: "var(--accent, var(--primary))",
|
|
77
|
-
// inline-style: dynamic percentage width of active effort slider fill
|
|
78
|
-
style: {
|
|
79
|
-
width: `calc(${percentage}% + 14px)`,
|
|
80
|
-
maxWidth: '100%',
|
|
81
|
-
transition: dragging ? 'none' : 'width 0.2s cubic-bezier(0.16, 1, 0.3, 1)',
|
|
82
|
-
} }), EFFORT_STEPS.map((step, idx) => {
|
|
83
|
-
const dotPercent = (idx / (EFFORT_STEPS.length - 1)) * 100;
|
|
84
|
-
const isPassed = idx <= activeIndex;
|
|
85
|
-
return (_jsx(Box, { position: "absolute", t: "50%",
|
|
86
|
-
// inline-style: discrete dot step stop position on track
|
|
87
|
-
style: {
|
|
88
|
-
left: `calc(14px + (100% - 28px) * ${dotPercent / 100})`,
|
|
89
|
-
transform: 'translate(-50%, -50%)',
|
|
90
|
-
}, width: 4, height: 4, rounded: 9999, bg: isPassed ? 'var(--pure-white)' : 'var(--white-40)', pointerEvents: "none" }, step.id));
|
|
91
|
-
}), _jsx(Box, { "data-slot": "thinking-slider-thumb", position: "absolute", t: 2, width: 24, height: 24, rounded: 9999, bg: "var(--pure-white)", boxShadow: "0 2px 6px var(--surface-overlay)", pointerEvents: "none",
|
|
92
|
-
// inline-style: discrete thumb position computed from active step
|
|
93
|
-
style: {
|
|
94
|
-
left: `calc(2px + (100% - 28px) * ${percentage / 100})`,
|
|
95
|
-
transition: dragging ? 'none' : 'left 0.2s cubic-bezier(0.16, 1, 0.3, 1)',
|
|
96
|
-
} })] }), _jsx(XStack, { width: "100%", minH: 32, items: "center", justify: "center", px: "$1", children: _jsx(Text, { fontSize: "$1", color: "$soft", text: "center", children: t(current.note) }) })] }) })] }));
|
|
97
|
-
}
|