@hanzo/app 0.3.96 → 0.3.97
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 +48 -11
- package/dist/about.d.ts +12 -0
- package/dist/about.js +44 -0
- package/dist/lastpage.d.ts +9 -0
- package/dist/lastpage.js +15 -0
- package/package.json +1 -1
package/dist/Chat.js
CHANGED
|
@@ -41,7 +41,9 @@ import { conversation, drop, hold, landed, localOf, spend, take, usePane, useWor
|
|
|
41
41
|
import { Face, brief as castBrief, join, roleOf, castTurn, roster as rosterLine, rosterOf, speakers, speaksOf, voiceOf } from "./cast.js";
|
|
42
42
|
import { cleanForSpeech, speakAgent } from "./speech.js";
|
|
43
43
|
import { AgentMaker, HOUSE, useAgentShelf, useCrew } from "./crew.js";
|
|
44
|
-
import { called } from "./team.js";
|
|
44
|
+
import { TEAM, called } from "./team.js";
|
|
45
|
+
import { ABOUT, about } from "./about.js";
|
|
46
|
+
import { written as lastPage } from "./lastpage.js";
|
|
45
47
|
import { Box, Button, Dialog, DialogContent, DialogTitle, Input, Text, Tooltip, TooltipContent, TooltipTrigger, View, VisuallyHidden, XStack, YStack, toast } from "@hanzo/ui";
|
|
46
48
|
import { useMedia } from "@hanzo/gui";
|
|
47
49
|
import { given, tidy } from "./lib/title.js";
|
|
@@ -58,7 +60,7 @@ import { useHydrated } from "./lib/hydrated.js";
|
|
|
58
60
|
import { base, served } from "./lib/ai.js";
|
|
59
61
|
import { onServed } from "./lib/served.js";
|
|
60
62
|
import { refused as worded, speech, useDictation, useTalk, useVoice } from "@hanzo/voice";
|
|
61
|
-
import { CalendarClock, Check, Code2, Copy, Download, FileText, Ghost, GitBranch, Image as ImageMark, KanbanSquare, Library as LibraryMark, PanelRight, Paperclip, Pencil, RefreshCw, ShieldCheck, Sparkles, Upload, X } from "lucide-react";
|
|
63
|
+
import { CalendarClock, Check, Code2, Copy, Download, FileText, Ghost, GitBranch, Globe, Image as ImageMark, KanbanSquare, Library as LibraryMark, PanelRight, Paperclip, Pencil, RefreshCw, ShieldCheck, Sparkles, Upload, X } from "lucide-react";
|
|
62
64
|
import { branched } from "./lib/branch.js";
|
|
63
65
|
import { openModelPicker } from "./lib/model-picker.js";
|
|
64
66
|
import { open as openBoardCard, home as boardHome } from "./lib/todo.js";
|
|
@@ -264,10 +266,17 @@ const CAST = "cast";
|
|
|
264
266
|
const ROUTERS = new Set(["enso", "enso-auto", "hanzo/enso", "auto"]);
|
|
265
267
|
/** The id of the turn drawn in the thread when a turn is refused. */
|
|
266
268
|
const FAILED = "failed";
|
|
267
|
-
/**
|
|
269
|
+
/**
|
|
270
|
+
* The turns with the conversation's system turns first: the cast's, when it has
|
|
271
|
+
* one, then what the app is (about.ts) — its agents, where a page it writes
|
|
272
|
+
* shows, and to ask before a build nobody described. Neither is ever recorded:
|
|
273
|
+
* a kept thread holds what was said (@hanzo/ai `useChat` records the question
|
|
274
|
+
* and its answer), so a conversation reopened is seated afresh.
|
|
275
|
+
*/
|
|
268
276
|
function seated(turns, turn) {
|
|
269
|
-
const rest = turns.filter((one) => one.id !== CAST);
|
|
270
|
-
|
|
277
|
+
const rest = turns.filter((one) => one.id !== CAST && one.id !== ABOUT);
|
|
278
|
+
const app = { id: ABOUT, role: "system", content: about(brand(), TEAM) };
|
|
279
|
+
return turn ? [{ id: CAST, role: "system", content: turn }, app, ...rest] : [app, ...rest];
|
|
271
280
|
}
|
|
272
281
|
/** An answer that came back with nothing in it. */
|
|
273
282
|
const blank = (one) => one.role === "assistant" && !String(one.content ?? "").trim() && !one.tool_calls?.length;
|
|
@@ -333,7 +342,7 @@ function plainTurnText(m) {
|
|
|
333
342
|
return "";
|
|
334
343
|
}
|
|
335
344
|
/** Quiet monochrome hover/focus-reveal actions under every completed assistant response. */
|
|
336
|
-
function AssistantTurnActions({ text, latest = false, canRegenerate, onRegenerate, onBranch, onOpen, onOpenInDev, onCreateBoardCard, onSchedule, }) {
|
|
345
|
+
function AssistantTurnActions({ text, latest = false, canRegenerate, onRegenerate, onBranch, onOpen, preview = false, onOpenInDev, onCreateBoardCard, onSchedule, }) {
|
|
337
346
|
const { t } = useI18n();
|
|
338
347
|
const [copied, setCopied] = useState(false);
|
|
339
348
|
useEffect(() => {
|
|
@@ -367,7 +376,17 @@ function AssistantTurnActions({ text, latest = false, canRegenerate, onRegenerat
|
|
|
367
376
|
setCopied(true);
|
|
368
377
|
toast.success(t("Copied to clipboard"));
|
|
369
378
|
}, () => toast.error(t("Could not copy")));
|
|
370
|
-
}, ...actionButton, bg: copied ? "$hover" : "transparent", borderColor: copied ? "var(--border-strong)" : "transparent", children: _jsxs(XStack, { items: "center", gap: "$1", children: [copied ? (_jsx(Check, { size: 13, color: "var(--state-success)", "aria-hidden": true })) : (_jsx(Copy, { size: 13, color: "var(--muted-foreground)", "aria-hidden": true })), copied ? (_jsx(Text, { fontSize: "$1", color: "$ink", children: t("Copied") })) : null] }) }), canRegenerate && onRegenerate ? (_jsx(Box, { render: _jsx("button", { type: "button", title: t("Regenerate") }), "data-slot": "assistant-turn-regenerate", "aria-label": t("Regenerate response"), onClick: onRegenerate, ...actionButton, children: _jsx(RefreshCw, { size: 13, color: "var(--muted-foreground)", "aria-hidden": true }) })) : null, onBranch ? (_jsx(Box, { render: _jsx("button", { type: "button", title: t("Branch") }), "data-slot": "assistant-turn-branch", "aria-label": t("Branch into a new chat"), onClick: onBranch, ...actionButton, children: _jsx(GitBranch, { size: 13, color: "var(--muted-foreground)", "aria-hidden": true }) })) : null, onOpenInDev ? (_jsx(Box, { render: _jsx("button", { type: "button", title: t("Open in Dev") }), "data-slot": "assistant-turn-dev", "aria-label": t("Open in Dev"), onClick: onOpenInDev, ...actionButton, children: _jsx(Code2, { size: 13, color: "var(--muted-foreground)", "aria-hidden": true }) })) : null, onCreateBoardCard ? (_jsx(Box, { render: _jsx("button", { type: "button", title: t("Create Board card") }), "data-slot": "assistant-turn-board", "aria-label": t("Create Board card"), onClick: onCreateBoardCard, ...actionButton, children: _jsx(KanbanSquare, { size: 13, color: "var(--muted-foreground)", "aria-hidden": true }) })) : null, onSchedule ? (_jsx(Box, { render: _jsx("button", { type: "button", title: t("Schedule task") }), "data-slot": "assistant-turn-schedule", "aria-label": t("Schedule task"), onClick: onSchedule, ...actionButton, children: _jsx(CalendarClock, { size: 13, color: "var(--muted-foreground)", "aria-hidden": true }) })) : null, onOpen ? (_jsx(Box, { render: _jsx("button", { type: "button", title: t("Open in side panel") }), "data-slot": "assistant-turn-open", "aria-label": t("Open in side panel"), onClick: onOpen, ...actionButton, children: _jsxs(XStack, { items: "center", gap: "$1", children: [_jsx(PanelRight, { size: 13, color: "var(--muted-foreground)", "aria-hidden": true }), _jsx(Text, { fontSize: "$1", color: "$soft", children: t("Open") })] }) })) : null] }));
|
|
379
|
+
}, ...actionButton, bg: copied ? "$hover" : "transparent", borderColor: copied ? "var(--border-strong)" : "transparent", children: _jsxs(XStack, { items: "center", gap: "$1", children: [copied ? (_jsx(Check, { size: 13, color: "var(--state-success)", "aria-hidden": true })) : (_jsx(Copy, { size: 13, color: "var(--muted-foreground)", "aria-hidden": true })), copied ? (_jsx(Text, { fontSize: "$1", color: "$ink", children: t("Copied") })) : null] }) }), canRegenerate && onRegenerate ? (_jsx(Box, { render: _jsx("button", { type: "button", title: t("Regenerate") }), "data-slot": "assistant-turn-regenerate", "aria-label": t("Regenerate response"), onClick: onRegenerate, ...actionButton, children: _jsx(RefreshCw, { size: 13, color: "var(--muted-foreground)", "aria-hidden": true }) })) : null, onBranch ? (_jsx(Box, { render: _jsx("button", { type: "button", title: t("Branch") }), "data-slot": "assistant-turn-branch", "aria-label": t("Branch into a new chat"), onClick: onBranch, ...actionButton, children: _jsx(GitBranch, { size: 13, color: "var(--muted-foreground)", "aria-hidden": true }) })) : null, onOpenInDev ? (_jsx(Box, { render: _jsx("button", { type: "button", title: t("Open in Dev") }), "data-slot": "assistant-turn-dev", "aria-label": t("Open in Dev"), onClick: onOpenInDev, ...actionButton, children: _jsx(Code2, { size: 13, color: "var(--muted-foreground)", "aria-hidden": true }) })) : null, onCreateBoardCard ? (_jsx(Box, { render: _jsx("button", { type: "button", title: t("Create Board card") }), "data-slot": "assistant-turn-board", "aria-label": t("Create Board card"), onClick: onCreateBoardCard, ...actionButton, children: _jsx(KanbanSquare, { size: 13, color: "var(--muted-foreground)", "aria-hidden": true }) })) : null, onSchedule ? (_jsx(Box, { render: _jsx("button", { type: "button", title: t("Schedule task") }), "data-slot": "assistant-turn-schedule", "aria-label": t("Schedule task"), onClick: onSchedule, ...actionButton, children: _jsx(CalendarClock, { size: 13, color: "var(--muted-foreground)", "aria-hidden": true }) })) : null, onOpen ? (_jsx(Box, { render: _jsx("button", { type: "button", title: preview ? t("Preview") : t("Open in side panel") }), "data-slot": "assistant-turn-open", "data-preview": preview ? "" : undefined, "aria-label": preview ? t("Preview") : t("Open in side panel"), onClick: onOpen, ...actionButton, children: _jsxs(XStack, { items: "center", gap: "$1", children: [preview ? (_jsx(Globe, { size: 13, color: "var(--foreground)", "aria-hidden": true })) : (_jsx(PanelRight, { size: 13, color: "var(--muted-foreground)", "aria-hidden": true })), _jsx(Text, { fontSize: "$1", color: preview ? "$ink" : "$soft", fontWeight: preview ? "600" : undefined, children: preview ? t("Preview") : t("Open") })] }) })) : null] }));
|
|
380
|
+
}
|
|
381
|
+
/**
|
|
382
|
+
* THE PREVIEW, BY NAME, just above the message box on a phone: one labelled
|
|
383
|
+
* press to the page the conversation last wrote. A fence's own file name
|
|
384
|
+
* (`html index.html`) follows the word; a bare language (`html block`) does not.
|
|
385
|
+
*/
|
|
386
|
+
function PreviewButton({ name, onOpen }) {
|
|
387
|
+
const { t } = useI18n();
|
|
388
|
+
const file = name.includes(".") ? name : "";
|
|
389
|
+
return (_jsxs(XStack, { render: "button", "data-slot": "composer-preview", "aria-label": file ? t("Preview {name}", { name: file }) : t("Preview"), self: "flex-start", maxW: "100%", items: "center", gap: "$1.5", px: "$3", minH: 44, rounded: 999, borderWidth: 1, borderColor: "var(--border-strong)", bg: "var(--surface-card)", cursor: "pointer", hoverStyle: { bg: "$hover" }, focusVisibleStyle: { outlineWidth: 2, outlineStyle: "solid", outlineColor: "var(--ring)" }, onClick: onOpen, children: [_jsx(Globe, { size: 14, color: "var(--foreground)", "aria-hidden": true }), _jsx(Text, { fontSize: "$2", fontWeight: "600", color: "$ink", children: t("Preview") }), file ? (_jsx(Text, { fontSize: "$2", color: "$soft", numberOfLines: 1, shrink: 1, minW: 0, children: file })) : null] }));
|
|
371
390
|
}
|
|
372
391
|
/**
|
|
373
392
|
* How long a turn may stream without a word before it is stopped and said to
|
|
@@ -647,7 +666,11 @@ function Thread({ placeholder = message(), initial, anonymous = false, settled =
|
|
|
647
666
|
const agentShelf = useAgentShelf();
|
|
648
667
|
// The opening greets the person by the first word of their display name, capitalised ("Good to see you, Z. What’s next?").
|
|
649
668
|
// A username is a handle, not a name: without a display name the greeting has none.
|
|
650
|
-
|
|
669
|
+
// The name is the stored token's, the one every request carries, and it follows
|
|
670
|
+
// that token: kept only while `anonymous` held still, it went on greeting
|
|
671
|
+
// whoever the token named when the pane mounted (hanzo-inc/app issue 441).
|
|
672
|
+
const signedAs = anonymous ? null : bearer();
|
|
673
|
+
const firstName = useMemo(() => (signedAs ? given(named()?.display ?? "") : ""), [signedAs]);
|
|
651
674
|
// Private / forgetful mode: an ephemeral conversation kept in memory only, never saved to server history.
|
|
652
675
|
const [forgetful, setForgetful] = useState(false);
|
|
653
676
|
// Up to three things worth doing next, from the person's own activity (@hanzo/build).
|
|
@@ -1514,6 +1537,11 @@ function Thread({ placeholder = message(), initial, anonymous = false, settled =
|
|
|
1514
1537
|
const a = lead(artifacts(text));
|
|
1515
1538
|
return a ? () => see(a) : undefined;
|
|
1516
1539
|
};
|
|
1540
|
+
/** Whether what `opener` opens is a page or a picture: its button is the Preview. */
|
|
1541
|
+
const previews = (text) => {
|
|
1542
|
+
const a = lead(artifacts(text));
|
|
1543
|
+
return Boolean(a && renders(a));
|
|
1544
|
+
};
|
|
1517
1545
|
const threadActions = useThreadActions();
|
|
1518
1546
|
const [customTitle, setCustomTitle] = useState("");
|
|
1519
1547
|
const [editingTitle, setEditingTitle] = useState(false);
|
|
@@ -1616,6 +1644,9 @@ function Thread({ placeholder = message(), initial, anonymous = false, settled =
|
|
|
1616
1644
|
// brief in the transcript as though somebody had typed it, and would make a
|
|
1617
1645
|
// conversation nobody has spoken in look like one already under way.
|
|
1618
1646
|
const said = useMemo(() => chat.messages.filter((m) => m.role !== "system"), [chat.messages]);
|
|
1647
|
+
// THE PAGE THE CONVERSATION LAST WROTE, for the Preview above the message box
|
|
1648
|
+
// on a phone (`PreviewButton`). Read once the answer has ended, not per token.
|
|
1649
|
+
const page = useMemo(() => (chat.streaming ? null : lastPage(said)), [said, chat.streaming]);
|
|
1619
1650
|
const currentThread = useMemo(() => {
|
|
1620
1651
|
const firstText = said[0]?.content;
|
|
1621
1652
|
const initialText = typeof firstText === "string" ? firstText : Array.isArray(firstText) ? firstText[0]?.text : "";
|
|
@@ -2046,6 +2077,12 @@ function Thread({ placeholder = message(), initial, anonymous = false, settled =
|
|
|
2046
2077
|
}, [media.md]);
|
|
2047
2078
|
const inTopChrome = Boolean(media.md && titlebarSlot);
|
|
2048
2079
|
const showAccessMode = devMode || carry.on.length > 0 || cast.length > 0 || chatPrefs.approvalMode === "manual";
|
|
2080
|
+
// ON A PHONE THE PREVIEW IS NAMED where the message box is. The panel is a
|
|
2081
|
+
// sheet there, shut until something opens it; the header that holds its
|
|
2082
|
+
// toggle on a laptop is not drawn, and an answer's own Preview scrolls away
|
|
2083
|
+
// with it. So while the sheet is shut, the page the conversation last wrote
|
|
2084
|
+
// stands one labelled press away (hanzo-inc/app issue 443).
|
|
2085
|
+
const previewing = !wide && !panel ? page : null;
|
|
2049
2086
|
const composer = {
|
|
2050
2087
|
value: draft,
|
|
2051
2088
|
onChange: setDraft,
|
|
@@ -2087,7 +2124,7 @@ function Thread({ placeholder = message(), initial, anonymous = false, settled =
|
|
|
2087
2124
|
},
|
|
2088
2125
|
// WHAT GOES WITH THE MESSAGE, above the frame and at its width: the
|
|
2089
2126
|
// pause and its ways past, wallet recovery, one chip a file, and talk mode's words.
|
|
2090
|
-
head: files.length || turnedAway || prepWrong || preparing || talk.open || talk.refusal || banner || simulatedResetAt || walletRecovery ? (_jsxs(_Fragment, { children: [walletRecovery ? (_jsxs(XStack, { role: "alert", "data-slot": "wallet-recovery-strip", items: "center", justify: "space-between", gap: "$2.5", flexWrap: "wrap", px: "$3", py: "$2", rounded: "$4", bg: "var(--surface-card)", borderWidth: 1, borderColor: "var(--border-strong)", children: [_jsxs(YStack, { gap: "$0.5", flex: 1, minW: 180, children: [_jsx(Text, { fontSize: "$2", fontWeight: "600", color: "$ink", children: t("Out of credits — your prompt was kept in the composer") }), _jsx(Text, { fontSize: "$1", color: "$soft", children: t("Add credits to continue with this model, or switch to another model.") })] }), _jsxs(XStack, { items: "center", gap: "$1.5", flexWrap: "wrap", children: [_jsx(Button, { size: "xs", rounded: 999, "$max-sm": { minH: 44 }, onPress: () => requestUpgrade(), children: t("Add credits") }), _jsx(Button, { size: "xs", variant: "outline", rounded: 999, borderColor: "var(--border-strong)", "$max-sm": { minH: 44 }, onPress: switchModelFromRecovery, children: t("Switch model") }), _jsx(Box, { render: _jsx("button", { type: "button", title: t("Dismiss") }), "aria-label": t("Dismiss"), onClick: () => setWalletRecovery(null), display: "flex", items: "center", justify: "center", width: 28, height: 28, rounded: 999, cursor: "pointer", hoverStyle: { bg: "$hover" }, focusVisibleStyle: { outlineWidth: 2, outlineStyle: "solid", outlineColor: "var(--ring)" }, "$max-sm": { minW: 44, minH: 44 }, children: _jsx(X, { size: 14, color: "var(--muted-foreground)", "aria-hidden": true }) })] })] })) : null, (banner && isUsageLimitReached) || simulatedResetAt ? (_jsx(NeedMoreUsageBanner, { resetsAt: pause?.resets_at ?? simulatedResetAt, fallbackModel: pause?.fallback ? nameOf(pause.fallback, listed) : null, isUncapped: uncapped(limits), customMessage: banner?.message ?? null, onGetMoreUsage: () => setNeedMoreUsageOpen(true), onSeeUsage: () => showSettings("usage") })) : banner ? (_jsx(LimitedBanner, { message: banner.message, actions: banner.actions, onAction: act, onUsage: () => showSettings("usage"), labels: { usage: t("See usage"), dismiss: t("Dismiss") } })) : null, actWrong ? (_jsx(Text, { role: "alert", "data-slot": "limited-banner-wrong", fontSize: "$2", color: BAD, children: actWrong })) : null, files.length ? (_jsx(XStack, { gap: "$1.5", flexWrap: "wrap", role: "list", "aria-label": t("Attached files"), "data-slot": "composer-attached", children: files.map((one) => (_jsx(HeldChip, { one: one, onOpen: openFile, onRemove: () => drop(at, one.id), onSave: anonymous ? undefined : (url, id) => keepOne(url, id, one.name, one.type) }, one.id))) })) : null, preparing ? (_jsxs(Text, { role: "status", "aria-live": "polite", "data-slot": "composer-preparing", fontSize: "$2", color: "$soft", children: [preparing, "\u2026"] })) : null, turnedAway || prepWrong ? (_jsx(Text, { role: "alert", fontSize: "$2", color: BAD, children: turnedAway || prepWrong })) : null, talk.open || talk.refusal ? (_jsx(Text, { role: "status", "aria-live": "polite", "data-slot": "composer-talk-reply", fontSize: "$2", color: talk.refusal ? BAD : "$soft", children: talk.refusal
|
|
2127
|
+
head: previewing || files.length || turnedAway || prepWrong || preparing || talk.open || talk.refusal || banner || simulatedResetAt || walletRecovery ? (_jsxs(_Fragment, { children: [previewing ? _jsx(PreviewButton, { name: previewing.name, onOpen: () => see(previewing) }) : null, walletRecovery ? (_jsxs(XStack, { role: "alert", "data-slot": "wallet-recovery-strip", items: "center", justify: "space-between", gap: "$2.5", flexWrap: "wrap", px: "$3", py: "$2", rounded: "$4", bg: "var(--surface-card)", borderWidth: 1, borderColor: "var(--border-strong)", children: [_jsxs(YStack, { gap: "$0.5", flex: 1, minW: 180, children: [_jsx(Text, { fontSize: "$2", fontWeight: "600", color: "$ink", children: t("Out of credits — your prompt was kept in the composer") }), _jsx(Text, { fontSize: "$1", color: "$soft", children: t("Add credits to continue with this model, or switch to another model.") })] }), _jsxs(XStack, { items: "center", gap: "$1.5", flexWrap: "wrap", children: [_jsx(Button, { size: "xs", rounded: 999, "$max-sm": { minH: 44 }, onPress: () => requestUpgrade(), children: t("Add credits") }), _jsx(Button, { size: "xs", variant: "outline", rounded: 999, borderColor: "var(--border-strong)", "$max-sm": { minH: 44 }, onPress: switchModelFromRecovery, children: t("Switch model") }), _jsx(Box, { render: _jsx("button", { type: "button", title: t("Dismiss") }), "aria-label": t("Dismiss"), onClick: () => setWalletRecovery(null), display: "flex", items: "center", justify: "center", width: 28, height: 28, rounded: 999, cursor: "pointer", hoverStyle: { bg: "$hover" }, focusVisibleStyle: { outlineWidth: 2, outlineStyle: "solid", outlineColor: "var(--ring)" }, "$max-sm": { minW: 44, minH: 44 }, children: _jsx(X, { size: 14, color: "var(--muted-foreground)", "aria-hidden": true }) })] })] })) : null, (banner && isUsageLimitReached) || simulatedResetAt ? (_jsx(NeedMoreUsageBanner, { resetsAt: pause?.resets_at ?? simulatedResetAt, fallbackModel: pause?.fallback ? nameOf(pause.fallback, listed) : null, isUncapped: uncapped(limits), customMessage: banner?.message ?? null, onGetMoreUsage: () => setNeedMoreUsageOpen(true), onSeeUsage: () => showSettings("usage") })) : banner ? (_jsx(LimitedBanner, { message: banner.message, actions: banner.actions, onAction: act, onUsage: () => showSettings("usage"), labels: { usage: t("See usage"), dismiss: t("Dismiss") } })) : null, actWrong ? (_jsx(Text, { role: "alert", "data-slot": "limited-banner-wrong", fontSize: "$2", color: BAD, children: actWrong })) : null, files.length ? (_jsx(XStack, { gap: "$1.5", flexWrap: "wrap", role: "list", "aria-label": t("Attached files"), "data-slot": "composer-attached", children: files.map((one) => (_jsx(HeldChip, { one: one, onOpen: openFile, onRemove: () => drop(at, one.id), onSave: anonymous ? undefined : (url, id) => keepOne(url, id, one.name, one.type) }, one.id))) })) : null, preparing ? (_jsxs(Text, { role: "status", "aria-live": "polite", "data-slot": "composer-preparing", fontSize: "$2", color: "$soft", children: [preparing, "\u2026"] })) : null, turnedAway || prepWrong ? (_jsx(Text, { role: "alert", fontSize: "$2", color: BAD, children: turnedAway || prepWrong })) : null, talk.open || talk.refusal ? (_jsx(Text, { role: "status", "aria-live": "polite", "data-slot": "composer-talk-reply", fontSize: "$2", color: talk.refusal ? BAD : "$soft", children: talk.refusal
|
|
2091
2128
|
? worded(talk.refusal)
|
|
2092
2129
|
: talk.reply
|
|
2093
2130
|
? `Hanzo: ${talk.reply}`
|
|
@@ -2369,11 +2406,11 @@ function Thread({ placeholder = message(), initial, anonymous = false, settled =
|
|
|
2369
2406
|
const silent = cast.length > 1 && !(chat.streaming && at === shown.length - 1)
|
|
2370
2407
|
? addressed(words(q?.content), cast).filter((name) => !parts.some((part) => part.who?.toLowerCase() === name.toLowerCase()))
|
|
2371
2408
|
: [];
|
|
2372
|
-
return (_jsxs(YStack, { gap: "$3", "data-turn-id": String(turn.id), "data-turn-role": turn.role, children: [parts.map((part, i) => (_jsxs(YStack, { gap: "$1.5", children: [part.who ? (_jsxs(XStack, { items: "center", gap: "$2", children: [_jsx(Face, { src: faces[part.who]?.avatar, emoji: faces[part.who]?.emoji, name: part.who, size: 20 }), _jsx(Text, { fontSize: "$2", fontWeight: "600", color: "$ink", children: part.who })] })) : null, _jsx(Prose, { text: part.text }), part.text && !isStreamingThisTurn ? (_jsx(AssistantTurnActions, { text: part.text, latest: isLatestAssistant, canRegenerate: !chat.streaming && !anonBusy, onRegenerate: () => redoTurn(turn.id, { mode: "retry" }), onBranch: anonymous || forgetful ? undefined : () => branchTurn(turn.id), onOpen: opener(part.text), onOpenInDev: () => openInDev({ prompt: part.text }), onCreateBoardCard: anonymous ? undefined : () => createBoardCardFromTurn(part.text), onSchedule: anonymous ? undefined : () => setPlan(part.text) })) : null] }, i))), silent.length ? (_jsx(Text, { fontSize: "$2", color: "$soft", children: t("No answer from {names} in this reply.", { names: join(silent, t) }) })) : null, byline(turn.id)] }));
|
|
2409
|
+
return (_jsxs(YStack, { gap: "$3", "data-turn-id": String(turn.id), "data-turn-role": turn.role, children: [parts.map((part, i) => (_jsxs(YStack, { gap: "$1.5", children: [part.who ? (_jsxs(XStack, { items: "center", gap: "$2", children: [_jsx(Face, { src: faces[part.who]?.avatar, emoji: faces[part.who]?.emoji, name: part.who, size: 20 }), _jsx(Text, { fontSize: "$2", fontWeight: "600", color: "$ink", children: part.who })] })) : null, _jsx(Prose, { text: part.text }), part.text && !isStreamingThisTurn ? (_jsx(AssistantTurnActions, { text: part.text, latest: isLatestAssistant, canRegenerate: !chat.streaming && !anonBusy, onRegenerate: () => redoTurn(turn.id, { mode: "retry" }), onBranch: anonymous || forgetful ? undefined : () => branchTurn(turn.id), onOpen: opener(part.text), preview: previews(part.text), onOpenInDev: () => openInDev({ prompt: part.text }), onCreateBoardCard: anonymous ? undefined : () => createBoardCardFromTurn(part.text), onSchedule: anonymous ? undefined : () => setPlan(part.text) })) : null] }, i))), silent.length ? (_jsx(Text, { fontSize: "$2", color: "$soft", children: t("No answer from {names} in this reply.", { names: join(silent, t) }) })) : null, byline(turn.id)] }));
|
|
2373
2410
|
}
|
|
2374
2411
|
const ms = turn.durationMs;
|
|
2375
2412
|
const worked = turn.role === "assistant" && typeof ms === "number" && ms >= 1000 ? ms : 0;
|
|
2376
|
-
return (_jsxs(YStack, { gap: "$2", "data-turn-id": String(turn.id), "data-turn-role": turn.role, children: [worked ? (_jsx(Text, { "data-slot": "worked-for", fontSize: "$2", color: "$soft", children: t("Worked for {n}s", { n: Math.round(worked / 1000) }) })) : null, _jsx(Prose, { text: said }), turn.role === "assistant" && said && !isStreamingThisTurn ? (_jsx(AssistantTurnActions, { text: said, latest: isLatestAssistant, canRegenerate: !chat.streaming && !anonBusy, onRegenerate: () => redoTurn(turn.id, { mode: "retry" }), onBranch: anonymous || forgetful ? undefined : () => branchTurn(turn.id), onOpen: opener(said), onOpenInDev: () => openInDev({ prompt: said }), onCreateBoardCard: anonymous ? undefined : () => createBoardCardFromTurn(said), onSchedule: anonymous ? undefined : () => setPlan(said) })) : null, turn.role === "assistant" && said ? byline(turn.id) : null] }));
|
|
2413
|
+
return (_jsxs(YStack, { gap: "$2", "data-turn-id": String(turn.id), "data-turn-role": turn.role, children: [worked ? (_jsx(Text, { "data-slot": "worked-for", fontSize: "$2", color: "$soft", children: t("Worked for {n}s", { n: Math.round(worked / 1000) }) })) : null, _jsx(Prose, { text: said }), turn.role === "assistant" && said && !isStreamingThisTurn ? (_jsx(AssistantTurnActions, { text: said, latest: isLatestAssistant, canRegenerate: !chat.streaming && !anonBusy, onRegenerate: () => redoTurn(turn.id, { mode: "retry" }), onBranch: anonymous || forgetful ? undefined : () => branchTurn(turn.id), onOpen: opener(said), preview: previews(said), onOpenInDev: () => openInDev({ prompt: said }), onCreateBoardCard: anonymous ? undefined : () => createBoardCardFromTurn(said), onSchedule: anonymous ? undefined : () => setPlan(said) })) : null, turn.role === "assistant" && said ? byline(turn.id) : null] }));
|
|
2377
2414
|
},
|
|
2378
2415
|
// The page's ONE heading, and it belongs to the empty transcript rather
|
|
2379
2416
|
// than to a signed-out branch — the branch is gone, and the heading went
|
package/dist/about.d.ts
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { Member } from './team.js';
|
|
2
|
+
/** The id the turn is held under in the thread, beside the cast's. */
|
|
3
|
+
export declare const ABOUT = "about";
|
|
4
|
+
/**
|
|
5
|
+
* The turn, for a product named `brand` whose agent team is `team`.
|
|
6
|
+
*
|
|
7
|
+
* The control it names, Preview, is the one Chat draws: the label on an
|
|
8
|
+
* answer's own button where the answer wrote a page, and on a phone, where the
|
|
9
|
+
* panel is a sheet, the button just above the message box (Chat.tsx
|
|
10
|
+
* `PreviewButton`).
|
|
11
|
+
*/
|
|
12
|
+
export declare function about(brand: string, team: readonly Member[]): string;
|
package/dist/about.js
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
// What Chat tells the model about the place it is answering in.
|
|
2
|
+
//
|
|
3
|
+
// A model knows itself (zen's family.md names it and its maker) and nothing of
|
|
4
|
+
// the app around the conversation. Asked "tell me about the Dev, Des, Vi agents
|
|
5
|
+
// below the chat bar", Enso answered that it could not see any Hanzo interface
|
|
6
|
+
// and refused the whole question (hanzo-inc/app issue 441); asked for a landing page
|
|
7
|
+
// it built a Hanzo AI showcase nobody had described (issue 442); and having written
|
|
8
|
+
// the page it sent the person to "the Output panel", a name no control on a
|
|
9
|
+
// phone carries (issue 443). Each answer was the model filling a gap with a guess.
|
|
10
|
+
//
|
|
11
|
+
// So Chat seats this beside the conversation as a system turn of its own, after
|
|
12
|
+
// the cast's (Chat.tsx `seated`): the agents as @hanzo/personas publishes them,
|
|
13
|
+
// where a page it writes shows and what that place is called, and to ask before
|
|
14
|
+
// a build nobody has described. English, because the model reads it, and pure,
|
|
15
|
+
// so the tests read exactly what the wire carries.
|
|
16
|
+
/** The id the turn is held under in the thread, beside the cast's. */
|
|
17
|
+
export const ABOUT = 'about';
|
|
18
|
+
/** One member as a line: `Dev (Development): code, engineering, software systems`. */
|
|
19
|
+
const line = (one) => `- ${one.name} (${one.role}): ${one.owns}`;
|
|
20
|
+
/**
|
|
21
|
+
* The turn, for a product named `brand` whose agent team is `team`.
|
|
22
|
+
*
|
|
23
|
+
* The control it names, Preview, is the one Chat draws: the label on an
|
|
24
|
+
* answer's own button where the answer wrote a page, and on a phone, where the
|
|
25
|
+
* panel is a sheet, the button just above the message box (Chat.tsx
|
|
26
|
+
* `PreviewButton`).
|
|
27
|
+
*/
|
|
28
|
+
export function about(brand, team) {
|
|
29
|
+
const leads = team.filter((one) => one.lead);
|
|
30
|
+
const bots = team.filter((one) => !one.lead);
|
|
31
|
+
return [
|
|
32
|
+
`You are answering in ${brand} Chat. You cannot see the screen, but you know the app: when the person asks about ${brand}, its agents or this app, answer from what follows, in plain words, and never say you have no access to it.`,
|
|
33
|
+
'',
|
|
34
|
+
`AGENTS. ${brand}'s agents are AI teammates, each with its own role, voice and tools. They are offered with the message box (its + menu › Agents, and as faces beside it). Picking one brings it into this conversation, where it answers in its own voice, and several can be in one conversation. These lead the team and answer when asked:`,
|
|
35
|
+
...leads.map(line),
|
|
36
|
+
'These can also run on their own around the clock, woken by a schedule or a trigger:',
|
|
37
|
+
...bots.map(line),
|
|
38
|
+
`An organization adds the ones it wants, or makes its own, under + › Agents › Manage agents. For hands-on work, Dev also has its own section of ${brand}, where it works in a codebase.`,
|
|
39
|
+
'',
|
|
40
|
+
'PREVIEW. A page or picture you write in a fenced code block (```html or ```svg) opens beside the conversation as soon as your answer ends; on a phone it opens over the conversation. Call that place "the Preview": your answer gets a Preview button that reopens it, and on a phone a Preview button also stands just above the message box. Never send the person to a panel, tab or button by any other name. Say a page is ready only after you have written it in full.',
|
|
41
|
+
'',
|
|
42
|
+
'BEFORE A BIG BUILD. When asked to build something large (a site, a landing page, an app, a long document) and the request does not say what it is for, who it is for, or what it should contain, do not invent those. Ask one or two short questions first, or say in a sentence what you would build and ask whether to go ahead. A small or fully described request you just do.',
|
|
43
|
+
].join('\n');
|
|
44
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { type Artifact } from '@hanzo/build';
|
|
2
|
+
/** One turn as the thread holds it: who said it, and what. */
|
|
3
|
+
interface Turn {
|
|
4
|
+
role: string;
|
|
5
|
+
content?: unknown;
|
|
6
|
+
}
|
|
7
|
+
/** The last page or picture an answer in `turns` wrote, or null: what the Preview opens. */
|
|
8
|
+
export declare function written(turns: readonly Turn[]): Artifact | null;
|
|
9
|
+
export {};
|
package/dist/lastpage.js
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
// The page a conversation last wrote: what Chat's Preview opens (Chat.tsx
|
|
2
|
+
// `PreviewButton`, and `see`). Pure, so the tests read it without a pane.
|
|
3
|
+
import { artifacts, renders } from '@hanzo/build';
|
|
4
|
+
/** The last page or picture an answer in `turns` wrote, or null: what the Preview opens. */
|
|
5
|
+
export function written(turns) {
|
|
6
|
+
for (let i = turns.length - 1; i >= 0; i--) {
|
|
7
|
+
const one = turns[i];
|
|
8
|
+
if (one.role !== 'assistant' || typeof one.content !== 'string')
|
|
9
|
+
continue;
|
|
10
|
+
const page = [...artifacts(one.content)].reverse().find(renders);
|
|
11
|
+
if (page)
|
|
12
|
+
return page;
|
|
13
|
+
}
|
|
14
|
+
return null;
|
|
15
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hanzo/app",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.97",
|
|
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",
|