@hanzo/app 0.2.58 → 0.3.1
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/README.md +8 -8
- package/dist/{Me.d.ts → Account.d.ts} +1 -1
- package/dist/{Me.js → Account.js} +3 -3
- package/dist/App.d.ts +2 -2
- package/dist/App.js +16 -16
- package/dist/{Top.d.ts → Bar.d.ts} +1 -1
- package/dist/{Top.js → Bar.js} +3 -3
- package/dist/Betas.js +1 -1
- package/dist/Board.js +4 -4
- package/dist/Chat.d.ts +4 -4
- package/dist/Chat.js +96 -96
- package/dist/Contacts.js +17 -15
- package/dist/Directory.js +7 -21
- package/dist/Drive.js +6 -6
- package/dist/{Orgs.d.ts → Gate.d.ts} +1 -1
- package/dist/{Orgs.js → Gate.js} +32 -32
- package/dist/{Chrome.d.ts → Header.d.ts} +1 -1
- package/dist/{Chrome.js → Header.js} +1 -1
- package/dist/Home.d.ts +3 -3
- package/dist/Home.js +30 -30
- package/dist/Inbox.js +29 -33
- package/dist/Meet.js +22 -22
- package/dist/Rail.js +6 -6
- package/dist/RightPane.js +2 -2
- package/dist/{Palette.d.ts → Search.d.ts} +1 -1
- package/dist/{Palette.js → Search.js} +1 -1
- package/dist/Settings.d.ts +3 -3
- package/dist/Settings.js +5 -5
- package/dist/SettingsPane.d.ts +2 -2
- package/dist/SettingsPane.js +5 -5
- package/dist/Setup.js +2 -2
- package/dist/Shell.d.ts +22 -31
- package/dist/Shell.js +167 -114
- package/dist/{Column.d.ts → Sidebar.d.ts} +1 -1
- package/dist/{Column.js → Sidebar.js} +5 -5
- package/dist/Support.js +2 -2
- package/dist/Talk.d.ts +3 -3
- package/dist/Talk.js +18 -18
- package/dist/TeamPreview.js +26 -26
- package/dist/TeamStory.js +1 -1
- package/dist/Usage.js +2 -2
- package/dist/Work.js +2 -2
- package/dist/bots/Bots.js +2 -2
- package/dist/bots/Lights.d.ts +1 -1
- package/dist/bots/Lights.js +1 -1
- package/dist/bots/api.d.ts +8 -7
- package/dist/bots/api.js +4 -4
- package/dist/bots/ink.js +3 -3
- package/dist/bots/kit.d.ts +2 -2
- package/dist/bots/kit.js +4 -4
- package/dist/bots/runtime.js +12 -12
- package/dist/cast.d.ts +14 -14
- package/dist/cast.js +12 -12
- package/dist/channels.d.ts +132 -0
- package/dist/{rooms.js → channels.js} +56 -55
- package/dist/conversations.d.ts +8 -8
- package/dist/conversations.js +18 -17
- package/dist/crew.d.ts +1 -1
- package/dist/crew.js +12 -12
- package/dist/dev.js +6 -6
- package/dist/failure.d.ts +2 -2
- package/dist/failure.js +6 -6
- package/dist/ground.d.ts +1 -1
- package/dist/ground.js +1 -1
- package/dist/help.d.ts +1 -1
- package/dist/help.js +2 -2
- package/dist/hint.d.ts +1 -1
- package/dist/hint.js +1 -1
- package/dist/host.d.ts +15 -15
- package/dist/host.js +13 -13
- package/dist/index.d.ts +5 -5
- package/dist/index.js +4 -4
- package/dist/lib/ai.js +1 -1
- package/dist/lib/api.d.ts +1 -1
- package/dist/lib/api.js +1 -1
- package/dist/lib/destination.d.ts +3 -3
- package/dist/lib/destination.js +3 -3
- package/dist/lib/home.d.ts +2 -2
- package/dist/lib/home.js +2 -2
- package/dist/lib/host.d.ts +17 -16
- package/dist/lib/host.js +19 -18
- package/dist/lib/hostname.d.ts +1 -1
- package/dist/lib/hostname.js +1 -1
- package/dist/lib/list.d.ts +1 -1
- package/dist/lib/list.js +1 -1
- package/dist/lib/models.js +1 -1
- package/dist/lib/org.d.ts +1 -1
- package/dist/lib/org.js +1 -1
- package/dist/lib/orgname.d.ts +1 -1
- package/dist/lib/orgname.js +1 -1
- package/dist/lib/session.d.ts +4 -4
- package/dist/lib/session.js +6 -6
- package/dist/lib/tier.d.ts +4 -4
- package/dist/lib/tier.js +5 -5
- package/dist/lib/tiers.d.ts +1 -1
- package/dist/lib/tiers.js +10 -10
- package/dist/lib/web.d.ts +1 -1
- package/dist/lib/web.js +1 -1
- package/dist/look.js +7 -9
- package/dist/network.d.ts +18 -18
- package/dist/network.js +28 -28
- package/dist/open.d.ts +24 -22
- package/dist/open.js +19 -19
- package/dist/pane.d.ts +6 -6
- package/dist/pane.js +10 -10
- package/dist/roster.d.ts +2 -2
- package/dist/roster.js +1 -1
- package/dist/seek.js +1 -1
- package/dist/slide.d.ts +1 -1
- package/dist/slide.js +1 -1
- package/dist/span.js +1 -1
- package/dist/stars.d.ts +4 -4
- package/dist/stars.js +8 -10
- package/dist/tabs.d.ts +1 -1
- package/dist/tabs.js +1 -1
- package/dist/team.js +1 -1
- package/dist/thread.d.ts +3 -3
- package/dist/thread.js +4 -4
- package/dist/ui.d.ts +1 -1
- package/dist/ui.js +1 -1
- package/dist/where.d.ts +7 -7
- package/dist/where.js +2 -2
- package/dist/workday.d.ts +26 -26
- package/dist/workday.js +187 -187
- package/package.json +8 -8
- package/dist/Room.d.ts +0 -8
- package/dist/Room.js +0 -51
- package/dist/rooms.d.ts +0 -131
- /package/dist/lib/{rooms.json → routes.json} +0 -0
package/dist/Chat.js
CHANGED
|
@@ -9,12 +9,12 @@ import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-run
|
|
|
9
9
|
// WHO CAN SEND: an account. `/v1/agents/chat` answers a signed-out caller
|
|
10
10
|
// "a validated principal is required" — measured on production, with and
|
|
11
11
|
// without the publishable key the bundle ships and with a browser's own Origin
|
|
12
|
-
// — so a visitor's first message comes back refused however the
|
|
13
|
-
// The
|
|
12
|
+
// — so a visitor's first message comes back refused however the pane is drawn.
|
|
13
|
+
// The pane says that in the reader's words and offers the way past it; what it
|
|
14
14
|
// must not do is describe an account they do not have.
|
|
15
15
|
//
|
|
16
16
|
// The free MODEL is a separate question and still exists: `anonymous` opens on
|
|
17
|
-
// the free pool, so what changes at sign-in is the menu, not the
|
|
17
|
+
// the free pool, so what changes at sign-in is the menu, not the conversation.
|
|
18
18
|
//
|
|
19
19
|
// The FREE lane is about PRICE, not identity: a free turn spends no balance and
|
|
20
20
|
// is data-shared in exchange. That choice is made once, at onboarding, where
|
|
@@ -36,8 +36,8 @@ import { useAgent, useAi, useChat, } from "@hanzo/ai/react";
|
|
|
36
36
|
import { Chat as ChatSurface, EFFORTS, Failure, MEASURE, Parts, useFamilies, words } from "@hanzo/ui/chat";
|
|
37
37
|
import { carriedIn, carrying, compose, partsOf, said as told, weigh } from "./lib/attach.js";
|
|
38
38
|
import { download, dropped, fileOf, pct, readable, refOf, retrieve } from "./lib/files.js";
|
|
39
|
-
import {
|
|
40
|
-
import { Face, brief as
|
|
39
|
+
import { conversation, drop, hold, landed, localOf, spend, take, usePane, useWorkFile } from "./pane.js";
|
|
40
|
+
import { Face, brief as castBrief, join, roleOf, castTurn, roster as rosterLine, rosterOf, speakers, speaksOf, voiceOf } from "./cast.js";
|
|
41
41
|
import { cleanForSpeech, speakAgent } from "./speech.js";
|
|
42
42
|
import { AgentMaker, HOUSE, useAgentShelf, useCrew } from "./crew.js";
|
|
43
43
|
import { called } from "./team.js";
|
|
@@ -48,7 +48,7 @@ import { useIam, useIamToken } from "@hanzo/iam/react";
|
|
|
48
48
|
import { bearer, hasSession, named, org } from "./lib/session.js";
|
|
49
49
|
import { api } from "./lib/api.js";
|
|
50
50
|
import { app, dev, go } from "./lib/host.js";
|
|
51
|
-
import {
|
|
51
|
+
import { useHost } from "./host.js";
|
|
52
52
|
import { chats, house, paidPlan, paused, setCreditsAfterAllowance, useLimits } from "./lib/limits.js";
|
|
53
53
|
import { LimitedBanner } from "@hanzo/ui/product/LimitedBanner";
|
|
54
54
|
import { WEB } from "./lib/web.js";
|
|
@@ -59,7 +59,7 @@ import { refused as worded, speech, useDictation, useTalk, useVoice } from "@han
|
|
|
59
59
|
import { Check, Clock, FileText, Ghost, Image as ImageMark, Library as LibraryMark, Paperclip, Sparkles, X } from "lucide-react";
|
|
60
60
|
import { FREE, ENSO } from "./lib/ai.js";
|
|
61
61
|
import { openThread, useOpen } from "./open.js";
|
|
62
|
-
import {
|
|
62
|
+
import { Side, Framed } from "./Shell.js";
|
|
63
63
|
import { SEED, look, useSections, useSites } from "./RightPane.js";
|
|
64
64
|
import { Share } from "./Share.js";
|
|
65
65
|
import { ConversationMenu, ThreadMore, useThreadList } from "./thread.js";
|
|
@@ -115,7 +115,7 @@ function useOpening() {
|
|
|
115
115
|
const asked = url.searchParams.get("q");
|
|
116
116
|
// A conversation carried in from hanzo.chat. The free chat records the thread
|
|
117
117
|
// under the reader's own account and sends its id, never the transcript; this
|
|
118
|
-
//
|
|
118
|
+
// pane opens that thread once the reader is signed in. Struck from the bar
|
|
119
119
|
// like `?q=`, for the same reasons.
|
|
120
120
|
const carried = url.searchParams.get("thread");
|
|
121
121
|
if (asked !== null || carried !== null) {
|
|
@@ -157,25 +157,25 @@ export function Chat() {
|
|
|
157
157
|
if (carried && settled && signedIn)
|
|
158
158
|
openThread(carried);
|
|
159
159
|
}, [carried, settled, signedIn]);
|
|
160
|
-
// The client is the SHELL's — one per
|
|
160
|
+
// The client is the SHELL's — one per shell, so the thread and the roster share
|
|
161
161
|
// a session rather than each minting its own. `Thread` is therefore only ever
|
|
162
162
|
// mounted under the provider the shell already put above it.
|
|
163
163
|
//
|
|
164
|
-
// ONE
|
|
164
|
+
// ONE pane, for everyone. `anonymous` changes which models are on offer and
|
|
165
165
|
// nothing else — the composer and the transcript are the same components
|
|
166
166
|
// either way, because a visitor is having the same conversation.
|
|
167
167
|
//
|
|
168
168
|
// The conversations are NOT drawn here. `Threads` is the list and the shell
|
|
169
|
-
// owns the column it sits in — one sidebar for six
|
|
169
|
+
// owns the column it sits in — one sidebar for six apps, already built, and a
|
|
170
170
|
// second one in this pane would be two designs for one job. This file draws
|
|
171
|
-
// the conversation; the shell draws the
|
|
171
|
+
// the conversation; the shell draws the frame.
|
|
172
172
|
return _jsx(Thread, { initial: opening, anonymous: settled && !signedIn });
|
|
173
173
|
}
|
|
174
174
|
/**
|
|
175
175
|
* The same conversation, embedded in a page that is not /chat.
|
|
176
176
|
*
|
|
177
177
|
* R8: there were TWO live chat surfaces, so /models mounts this one and the
|
|
178
|
-
* second is gone. The data-share choice is made once at onboarding; this
|
|
178
|
+
* second is gone. The data-share choice is made once at onboarding; this view
|
|
179
179
|
* does not ask again when a message is sent. It carries no
|
|
180
180
|
* heading of its own: the host page already has one, and a second `<h1>` is the
|
|
181
181
|
* defect that took the landings off /chat and /dev.
|
|
@@ -205,26 +205,26 @@ export function Ask({ placeholder, idle, }) {
|
|
|
205
205
|
const message = () => `Ask ${brand()}`;
|
|
206
206
|
/** The panel offers no kinds of its own in Chat: its tabs are pages. */
|
|
207
207
|
const NONE = [];
|
|
208
|
-
/** The id the
|
|
209
|
-
const
|
|
208
|
+
/** The id the conversation's system turn is held under in the thread. */
|
|
209
|
+
const CAST = "cast";
|
|
210
210
|
/** The models that route a turn rather than name the one that answers it. */
|
|
211
211
|
const ROUTERS = new Set(["enso", "enso-auto", "enso-free", "hanzo/enso", "auto", "free"]);
|
|
212
212
|
/** The id of the turn drawn in the thread when a turn is refused. */
|
|
213
213
|
const FAILED = "failed";
|
|
214
|
-
/** The turns with the
|
|
214
|
+
/** The turns with the conversation's system turn first, or without one for an empty cast. */
|
|
215
215
|
function seated(turns, turn) {
|
|
216
|
-
const rest = turns.filter((one) => one.id !==
|
|
217
|
-
return turn ? [{ id:
|
|
216
|
+
const rest = turns.filter((one) => one.id !== CAST);
|
|
217
|
+
return turn ? [{ id: CAST, role: "system", content: turn }, ...rest] : rest;
|
|
218
218
|
}
|
|
219
219
|
/** An answer that came back with nothing in it. */
|
|
220
220
|
const blank = (one) => one.role === "assistant" && !String(one.content ?? "").trim() && !one.tool_calls?.length;
|
|
221
221
|
/**
|
|
222
|
-
* The agents a question speaks to: those it names, or the whole
|
|
223
|
-
* names nobody — the rule the
|
|
222
|
+
* The agents a question speaks to: those it names, or the whole cast when it
|
|
223
|
+
* names nobody — the rule the cast's brief gives the model (cast.tsx `brief`).
|
|
224
224
|
*/
|
|
225
|
-
export function addressed(question,
|
|
226
|
-
const named =
|
|
227
|
-
return named.length ? named :
|
|
225
|
+
export function addressed(question, cast) {
|
|
226
|
+
const named = cast.filter((name) => new RegExp(`(^|[^\\p{L}\\p{N}])${name.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")}($|[^\\p{L}\\p{N}])`, "iu").test(question));
|
|
227
|
+
return named.length ? named : cast;
|
|
228
228
|
}
|
|
229
229
|
/**
|
|
230
230
|
* Which kind of refusal a failed turn met, read off the platform's own codes:
|
|
@@ -381,7 +381,7 @@ const THUMB = 48;
|
|
|
381
381
|
* A PICTURE SHOWS ITSELF and a PDF shows a tile, each with its name and size
|
|
382
382
|
* beside it; any other kind is a chip of its name. Nothing is filled behind
|
|
383
383
|
* them: a hairline on whatever they sit on, so a file reads alike over the
|
|
384
|
-
* composer and inside a turn's bubble,
|
|
384
|
+
* composer and inside a turn's bubble, on a light page and a dark one. A second
|
|
385
385
|
* fill on the bubble's was the darker grey that read as a stain. The word for
|
|
386
386
|
* how far a file has got shows only while it is getting there — a picture of
|
|
387
387
|
* the file already says it is attached — and `data-state` keeps the index's own
|
|
@@ -479,7 +479,7 @@ function Plan({ onPress }) {
|
|
|
479
479
|
* answer, because listing a paid model to someone with no balance is an offer
|
|
480
480
|
* that fails at send. Everything else — the transcript, the composer — is
|
|
481
481
|
* identical, which is the point: signing in later changes the models on the
|
|
482
|
-
* menu, not the
|
|
482
|
+
* menu, not the conversation.
|
|
483
483
|
*/
|
|
484
484
|
function Thread({ placeholder = message(), initial, anonymous = false, heading, }) {
|
|
485
485
|
/**
|
|
@@ -515,10 +515,10 @@ function Thread({ placeholder = message(), initial, anonymous = false, heading,
|
|
|
515
515
|
// In the app's frame the composer floats on the pane as a pane of its own.
|
|
516
516
|
const framed = useContext(Framed);
|
|
517
517
|
const opened = useOpen();
|
|
518
|
-
const { thread: open, open: reopen, agents:
|
|
518
|
+
const { thread: open, open: reopen, agents: cast, openAgent, seat, emptied, aside, showAside, showSettings } = opened;
|
|
519
519
|
// What the conversation carries beside its words (@hanzo/build `useCarry`):
|
|
520
520
|
// the skills picked from `+`, what Hanzo remembers and the mode, said at the
|
|
521
|
-
// end of the
|
|
521
|
+
// end of the conversation's system turn so every request carries them.
|
|
522
522
|
// What the plugins act on — the draft and the files held for the next message —
|
|
523
523
|
// read when they act, so it is lent through a ref filled further down.
|
|
524
524
|
const lent = useRef({ draft: "", setDraft: () => { }, attach: () => { } });
|
|
@@ -552,9 +552,9 @@ function Thread({ placeholder = message(), initial, anonymous = false, heading,
|
|
|
552
552
|
const mine = open ? listing.threads.find((t) => t.id === open) : undefined;
|
|
553
553
|
const alone = useMemo(() => new Map(mine ? [[mine.id, mine]] : []), [mine]);
|
|
554
554
|
// The conversation's key in `pane.ts`, the one the column beside it reads.
|
|
555
|
-
const at =
|
|
555
|
+
const at = conversation(opened);
|
|
556
556
|
// The first of them: what a surface that addresses one person reads.
|
|
557
|
-
const withWhom =
|
|
557
|
+
const withWhom = cast[0] ?? null;
|
|
558
558
|
// THE SIDE PANEL (@hanzo/build `Panel`), the one Dev's runs open too: shut
|
|
559
559
|
// until the reader opens it or a preview lands (`see`, a link that frames),
|
|
560
560
|
// kept per conversation with its tabs, so a chat opens as it was left and
|
|
@@ -610,30 +610,30 @@ function Thread({ placeholder = message(), initial, anonymous = false, heading,
|
|
|
610
610
|
* already has a place for who is speaking, and this is it.
|
|
611
611
|
*/
|
|
612
612
|
// THE COLUMN'S OWN LIST, because that is what draws the faces beside this
|
|
613
|
-
//
|
|
613
|
+
// conversation. `useAgent` asks the API for one agent BY REF and an agent is
|
|
614
614
|
// addressed here by the name a reader picked, so it answers null for every
|
|
615
615
|
// row whose id is not its name — which is why the hero had no picture and no
|
|
616
616
|
// sentence for an agent the column had just drawn a memoji for.
|
|
617
617
|
const { agents: roster, loading: gathering } = useCrew();
|
|
618
|
-
// THE HANDLE A NAME IS FILED UNDER. The
|
|
618
|
+
// THE HANDLE A NAME IS FILED UNDER. The cast holds the names a person reads
|
|
619
619
|
// ("Dev"); the platform files a core member under its lower-case handle
|
|
620
620
|
// ("dev"), so a read goes out under the org's own spelling.
|
|
621
621
|
const handle = useCallback((name) => (Array.isArray(roster) ? roster : []).find((one) => one.name.toLowerCase() === name.toLowerCase())?.name ?? name, [roster]);
|
|
622
622
|
const { agent: read, loading: reading } = useAgent(withWhom && !gathering ? handle(withWhom) : null);
|
|
623
623
|
// THIS agent's record only: the hook keeps the last agent's row while it reads
|
|
624
|
-
// the next, so a row whose name is not the one in the
|
|
624
|
+
// the next, so a row whose name is not the one in the conversation is not theirs.
|
|
625
625
|
const persona = read && withWhom && read.name?.toLowerCase() === withWhom.toLowerCase() ? read : null;
|
|
626
626
|
// Until the record answers, the model they are pinned to is unknown, so a send
|
|
627
627
|
// waits for it rather than going out on the reader's own model.
|
|
628
628
|
const resolving = Boolean(withWhom) && (gathering || reading);
|
|
629
629
|
const resolvingNow = useRef(resolving);
|
|
630
630
|
resolvingNow.current = resolving;
|
|
631
|
-
// THE
|
|
631
|
+
// THE CAST'S FACES, by name: what the column's own list says each one looks
|
|
632
632
|
// like, which is what the header, the hero and a reply's byline all draw.
|
|
633
633
|
const faces = useMemo(() => {
|
|
634
634
|
const rows = Array.isArray(roster) ? roster : [];
|
|
635
|
-
return Object.fromEntries(
|
|
636
|
-
}, [roster,
|
|
635
|
+
return Object.fromEntries(cast.map((name) => [name, rows.find((one) => one.name.toLowerCase() === name.toLowerCase())]));
|
|
636
|
+
}, [roster, cast]);
|
|
637
637
|
const mate = withWhom ? faces[withWhom] : undefined;
|
|
638
638
|
// ONE SPELLING PER AGENT. A core member is named as hanzoai/personas names
|
|
639
639
|
// them whatever the org's handle ("des" is Des, `called`); any other agent is
|
|
@@ -641,21 +641,21 @@ function Thread({ placeholder = message(), initial, anonymous = false, heading,
|
|
|
641
641
|
// is named again once they do, and its row, picture and brief are the org's.
|
|
642
642
|
useEffect(() => {
|
|
643
643
|
const rows = Array.isArray(roster) ? roster : [];
|
|
644
|
-
const named =
|
|
645
|
-
if (named.some((name, i) => name !==
|
|
644
|
+
const named = cast.map((name) => called(rows.find((one) => one.name.toLowerCase() === name.toLowerCase())?.name ?? name));
|
|
645
|
+
if (named.some((name, i) => name !== cast[i]))
|
|
646
646
|
seat(named);
|
|
647
|
-
}, [roster,
|
|
648
|
-
// WHO A REPLY MAY NAME: the
|
|
649
|
-
// said while someone was in the
|
|
650
|
-
const known = useMemo(() => [...new Set([...
|
|
651
|
-
// EVERYONE ELSE IN THE
|
|
647
|
+
}, [roster, cast, seat]);
|
|
648
|
+
// WHO A REPLY MAY NAME: the cast, the org's agents and the house crew. A turn
|
|
649
|
+
// said while someone was in the conversation stays split by speaker after they leave.
|
|
650
|
+
const known = useMemo(() => [...new Set([...cast, ...(Array.isArray(roster) ? roster.map((one) => called(one.name)) : []), ...HOUSE])], [cast, roster]);
|
|
651
|
+
// EVERYONE ELSE IN THE CONVERSATION. `useAgent` reads the first by ref; the rest are
|
|
652
652
|
// read here once each and kept, so a member who steps out and back in does
|
|
653
653
|
// not cost a second read. A name the platform does not hold reads null and
|
|
654
654
|
// falls to what the cast says of them.
|
|
655
655
|
const [briefs, setBriefs] = useState({});
|
|
656
656
|
const asked = useRef(new Set());
|
|
657
657
|
useEffect(() => {
|
|
658
|
-
for (const name of
|
|
658
|
+
for (const name of cast) {
|
|
659
659
|
const ref = handle(name);
|
|
660
660
|
if (name === withWhom || asked.current.has(ref))
|
|
661
661
|
continue;
|
|
@@ -668,20 +668,20 @@ function Thread({ placeholder = message(), initial, anonymous = false, heading,
|
|
|
668
668
|
setBriefs((all) => ({ ...all, [name]: null }));
|
|
669
669
|
});
|
|
670
670
|
}
|
|
671
|
-
}, [ai,
|
|
672
|
-
// THE SYSTEM TURN: one brief as it is, or the whole
|
|
671
|
+
}, [ai, cast, withWhom, handle]);
|
|
672
|
+
// THE SYSTEM TURN: one brief as it is, or the whole cast. The org's row
|
|
673
673
|
// speaks for an agent it holds — the cloud keeps a core member's row in step
|
|
674
674
|
// with hanzoai/personas, and an agent the org made under the same name keeps
|
|
675
675
|
// its own brief — and a core member the org holds no row for speaks as
|
|
676
676
|
// hanzoai/personas writes them (`speaksOf`), so a visitor pressing Feynman
|
|
677
677
|
// gets Feynman rather than the house model.
|
|
678
|
-
const brief = useMemo(() =>
|
|
678
|
+
const brief = useMemo(() => castBrief(cast.map((name) => ({
|
|
679
679
|
name,
|
|
680
680
|
says: (name === withWhom ? persona?.instructions?.trim() : briefs[name]) || speaksOf(name) || null,
|
|
681
|
-
}))), [
|
|
681
|
+
}))), [cast, withWhom, persona?.instructions, briefs]);
|
|
682
682
|
// AN AGENT BRINGS ITS OWN MODEL. It is a field on the row, so choosing one
|
|
683
683
|
// for them would be answering a question they have already answered. The
|
|
684
|
-
// default for plain chats lives in Settings, so this
|
|
684
|
+
// default for plain chats lives in Settings, so this pane has no second model
|
|
685
685
|
// control that can drift from it.
|
|
686
686
|
//
|
|
687
687
|
// NAMED, THEN CHECKED AGAINST WHAT THE GATEWAY SERVES. `enso` is the house
|
|
@@ -690,7 +690,7 @@ function Thread({ placeholder = message(), initial, anonymous = false, heading,
|
|
|
690
690
|
// round as a completion for a model nobody has, which the round returns as a
|
|
691
691
|
// bare "not found", after it has already recorded the question. `served`
|
|
692
692
|
// keeps the house name where it is served and otherwise falls to the first
|
|
693
|
-
// model that is, so a
|
|
693
|
+
// model that is, so a conversation on any catalogue can be spoken to.
|
|
694
694
|
// A SPEECH MODEL NEVER ANSWERS A CHAT TURN. The catalog lists the
|
|
695
695
|
// transcriber and the voice beside the chat models; one that names its
|
|
696
696
|
// outputs and names no text (`chats`) is neither offered nor fallen back to.
|
|
@@ -721,7 +721,7 @@ function Thread({ placeholder = message(), initial, anonymous = false, heading,
|
|
|
721
721
|
const sent = anonymous ? FREE : wanted;
|
|
722
722
|
const model = persona?.model || (rowOf(sent) ? sent : served(models, sent));
|
|
723
723
|
// THE PLAN'S USAGE (lib/limits.ts), kept current by every chat answer's
|
|
724
|
-
// headers and read again whenever a send settles, below. The
|
|
724
|
+
// headers and read again whenever a send settles, below. The pane draws no
|
|
725
725
|
// bars and no near note — those live on Settings → Usage. It says something
|
|
726
726
|
// only once the reader is turned away: a reply answered from a free model, or
|
|
727
727
|
// a refusal.
|
|
@@ -731,7 +731,7 @@ function Thread({ placeholder = message(), initial, anonymous = false, heading,
|
|
|
731
731
|
const banner = pause ? paused(pause, limits?.plan ?? "", (id) => nameOf(id, listed), Date.now(), t) : null;
|
|
732
732
|
// EVERY MODEL IS CHOSEN, never asked for: one the plan does not cover still
|
|
733
733
|
// picks, and the gateway answers it with the policy's refusal or from Enso,
|
|
734
|
-
// which the
|
|
734
|
+
// which the pane then shows. A turn the gateway refuses `plan_required`
|
|
735
735
|
// opens the upgrade, titled with the model.
|
|
736
736
|
const free = useFree(!anonymous) && !held;
|
|
737
737
|
const [ask, setAsk] = useState(null);
|
|
@@ -769,10 +769,10 @@ function Thread({ placeholder = message(), initial, anonymous = false, heading,
|
|
|
769
769
|
// fetch for one, and fetching anyway would race a live conversation to
|
|
770
770
|
// replace it with the server's copy mid-sentence.
|
|
771
771
|
const written = useRef(new Set());
|
|
772
|
-
// The
|
|
772
|
+
// The cast each thread last recorded, by thread, as the names joined.
|
|
773
773
|
const recorded = useRef(new Map());
|
|
774
774
|
// A conversation that has just been written down becomes the OPEN one, so the
|
|
775
|
-
// rail marks the
|
|
775
|
+
// rail marks the conversation the reader is standing in. Only on the mint, which is
|
|
776
776
|
// `kept` changing: when the reader opens another Recent, `open` moves first and
|
|
777
777
|
// `kept` follows it a render later (the hook takes `thread` in an effect), and
|
|
778
778
|
// reopening the stale `kept` then sent the two chasing each other until React
|
|
@@ -797,20 +797,20 @@ function Thread({ placeholder = message(), initial, anonymous = false, heading,
|
|
|
797
797
|
// hook's own state setter, so it takes either.
|
|
798
798
|
const apply = useRef(set);
|
|
799
799
|
apply.current = set;
|
|
800
|
-
// THE
|
|
801
|
-
// of them talks. It is the first turn every request carries and it follows the
|
|
800
|
+
// THE CONVERSATION'S SYSTEM TURN: who is in the conversation (`roster`), then how each
|
|
801
|
+
// of them talks. It is the first turn every request carries and it follows the cast, so
|
|
802
802
|
// pressing a face adds them to the conversation that is open rather than
|
|
803
803
|
// starting another; the turns already said stay where they are.
|
|
804
|
-
const turn = useMemo(() => [
|
|
804
|
+
const turn = useMemo(() => [castTurn(cast, brief), carry.text].filter(Boolean).join("\n\n") || null, [cast, brief, carry.text]);
|
|
805
805
|
const turnNow = useRef(turn);
|
|
806
806
|
turnNow.current = turn;
|
|
807
|
-
const
|
|
808
|
-
|
|
807
|
+
const castNow = useRef(cast);
|
|
808
|
+
castNow.current = cast;
|
|
809
809
|
useEffect(() => {
|
|
810
810
|
apply.current((held) => seated(held, turn));
|
|
811
811
|
}, [turn]);
|
|
812
|
-
// A NEW CONVERSATION holds the
|
|
813
|
-
// "New chat" (`emptied` counts the presses, so a press on an empty
|
|
812
|
+
// A NEW CONVERSATION holds the cast's turn and nothing else: on arrival, on
|
|
813
|
+
// "New chat" (`emptied` counts the presses, so a press on an empty conversation still
|
|
814
814
|
// lands), and when the open thread is left for none.
|
|
815
815
|
useEffect(() => {
|
|
816
816
|
if (open)
|
|
@@ -820,10 +820,10 @@ function Thread({ placeholder = message(), initial, anonymous = false, heading,
|
|
|
820
820
|
// A RECENT THAT OPENS. `threads.get` answers null for an id this caller may
|
|
821
821
|
// not read — the route replies 200 with no messages rather than 404 — so an
|
|
822
822
|
// empty transcript is read as absent instead of drawn as a real but blank
|
|
823
|
-
// conversation. The last roster turn it holds names its
|
|
823
|
+
// conversation. The last roster turn it holds names its cast, which is seated
|
|
824
824
|
// as it arrives; a thread that never recorded one has nobody in it.
|
|
825
825
|
//
|
|
826
|
-
// Its own effect, apart from the
|
|
826
|
+
// Its own effect, apart from the cast's turn: a character arriving while the
|
|
827
827
|
// read is out must not abort it.
|
|
828
828
|
useEffect(() => {
|
|
829
829
|
if (!open)
|
|
@@ -848,24 +848,24 @@ function Thread({ placeholder = message(), initial, anonymous = false, heading,
|
|
|
848
848
|
names = held;
|
|
849
849
|
}
|
|
850
850
|
recorded.current.set(open, names.join("\n"));
|
|
851
|
-
// The
|
|
851
|
+
// The cast already seated keeps its briefs; another is seated by name
|
|
852
852
|
// and its briefs follow as they are read.
|
|
853
|
-
const same = names.join("\n") ===
|
|
853
|
+
const same = names.join("\n") === castNow.current.join("\n");
|
|
854
854
|
seat(names);
|
|
855
|
-
apply.current(seated(turns.filter((one) => !(one.role === "system" && rosterOf(one.content))), same ? turnNow.current :
|
|
855
|
+
apply.current(seated(turns.filter((one) => !(one.role === "system" && rosterOf(one.content))), same ? turnNow.current : castTurn(names, null)));
|
|
856
856
|
})
|
|
857
857
|
.catch(() => apply.current(seated([], turnNow.current)));
|
|
858
858
|
return () => stop.abort();
|
|
859
859
|
}, [ai, open, seat]);
|
|
860
|
-
// WHO IS IN THE CONVERSATION IS KEPT WITH IT. A thread records its
|
|
860
|
+
// WHO IS IN THE CONVERSATION IS KEPT WITH IT. A thread records its cast as a
|
|
861
861
|
// roster turn when it is first written down with somebody in it, and again
|
|
862
|
-
// whenever the
|
|
862
|
+
// whenever the cast changes; reopening it — after a reload, on another
|
|
863
863
|
// device — seats the same faces. The briefs are not recorded: they are read
|
|
864
|
-
// fresh from the agents each time the
|
|
864
|
+
// fresh from the agents each time the cast is seated.
|
|
865
865
|
useEffect(() => {
|
|
866
866
|
if (!open || anonymous)
|
|
867
867
|
return;
|
|
868
|
-
const now =
|
|
868
|
+
const now = cast.join("\n");
|
|
869
869
|
const was = recorded.current.get(open);
|
|
870
870
|
if (was === now)
|
|
871
871
|
return;
|
|
@@ -874,12 +874,12 @@ function Thread({ placeholder = message(), initial, anonymous = false, heading,
|
|
|
874
874
|
if (was === undefined && !written.current.has(open))
|
|
875
875
|
return;
|
|
876
876
|
recorded.current.set(open, now);
|
|
877
|
-
if (was === undefined &&
|
|
877
|
+
if (was === undefined && cast.length === 0)
|
|
878
878
|
return;
|
|
879
|
-
void ai.threads.record([{ role: "system", content: rosterLine(
|
|
879
|
+
void ai.threads.record([{ role: "system", content: rosterLine(cast) }], open).catch(() => {
|
|
880
880
|
recorded.current.delete(open);
|
|
881
881
|
});
|
|
882
|
-
}, [ai, open,
|
|
882
|
+
}, [ai, open, cast, anonymous]);
|
|
883
883
|
// `send` is read through a ref and NEVER through a dependency array. Its
|
|
884
884
|
// identity changes on every `setMessages` — `useChat` closes over `messages` —
|
|
885
885
|
// so an effect depending on it re-runs after each streamed token.
|
|
@@ -891,7 +891,7 @@ function Thread({ placeholder = message(), initial, anonymous = false, heading,
|
|
|
891
891
|
// it.
|
|
892
892
|
const [draft, setDraft] = useState("");
|
|
893
893
|
// FILES WITH THE NEXT MESSAGE, held by `pane.ts` for this conversation: the
|
|
894
|
-
// paperclip, a drop anywhere on the
|
|
894
|
+
// paperclip, a drop anywhere on the pane, a paste into the field and the
|
|
895
895
|
// column's `+` all go through its one `hold`, so the chips here and the rows
|
|
896
896
|
// under Sources are one list. Each goes to the org's workspace and is indexed
|
|
897
897
|
// there; the turn carries it by reference (lib/attach), with the passages
|
|
@@ -931,14 +931,14 @@ function Thread({ placeholder = message(), initial, anonymous = false, heading,
|
|
|
931
931
|
const talk = useTalk({ ...base(), ...(token ? { token } : {}), org: org() ?? undefined });
|
|
932
932
|
// WHILE THE MIC IS OPEN, A FINISHED REPLY IS READ ALOUD by the platform's
|
|
933
933
|
// voice, through the conversation's own mouth so speaking over it stops it.
|
|
934
|
-
// A
|
|
934
|
+
// A reply from the cast is read part by part, each in its speaker's cast voice.
|
|
935
935
|
const wasStreaming = useRef(false);
|
|
936
936
|
useEffect(() => {
|
|
937
937
|
if (wasStreaming.current && !chat.streaming && voice.open) {
|
|
938
938
|
const msgs = chat.messages;
|
|
939
939
|
const lastMsg = msgs[msgs.length - 1];
|
|
940
940
|
if (lastMsg && lastMsg.role === "assistant" && typeof lastMsg.content === "string") {
|
|
941
|
-
const parts =
|
|
941
|
+
const parts = cast.length > 1 ? speakers(lastMsg.content, cast) : [{ who: withWhom, text: lastMsg.content }];
|
|
942
942
|
// A part spoken over ends the reading rather than handing on to the next.
|
|
943
943
|
void (async () => {
|
|
944
944
|
for (const part of parts) {
|
|
@@ -950,7 +950,7 @@ function Thread({ placeholder = message(), initial, anonymous = false, heading,
|
|
|
950
950
|
}
|
|
951
951
|
}
|
|
952
952
|
wasStreaming.current = chat.streaming;
|
|
953
|
-
}, [chat.streaming, voice.open, voice.say, chat.messages, withWhom,
|
|
953
|
+
}, [chat.streaming, voice.open, voice.say, chat.messages, withWhom, cast]);
|
|
954
954
|
// A SEND THAT WAITS ONE RENDER. `send` closes over the turns it was rendered
|
|
955
955
|
// with, so a send that first tidies the thread is held here and made from the
|
|
956
956
|
// next render, where the tidied turns are the ones it sends.
|
|
@@ -1138,7 +1138,7 @@ function Thread({ placeholder = message(), initial, anonymous = false, heading,
|
|
|
1138
1138
|
// WHAT WAS SAID, which is not everything the thread holds. The persona rides
|
|
1139
1139
|
// as a system turn so the wire carries it; drawing it would print a character
|
|
1140
1140
|
// brief in the transcript as though somebody had typed it, and would make a
|
|
1141
|
-
//
|
|
1141
|
+
// conversation nobody has spoken in look like one already under way.
|
|
1142
1142
|
const said = useMemo(() => chat.messages.filter((m) => m.role !== "system"), [chat.messages]);
|
|
1143
1143
|
const currentThread = useMemo(() => {
|
|
1144
1144
|
const firstText = said[0]?.content;
|
|
@@ -1148,9 +1148,9 @@ function Thread({ placeholder = message(), initial, anonymous = false, heading,
|
|
|
1148
1148
|
title: tidy(initialText || t("New chat")),
|
|
1149
1149
|
created: Date.now(),
|
|
1150
1150
|
updated: Date.now(),
|
|
1151
|
-
|
|
1151
|
+
cast: cast.length ? cast : [],
|
|
1152
1152
|
};
|
|
1153
|
-
}, [mine, open, said, t,
|
|
1153
|
+
}, [mine, open, said, t, cast]);
|
|
1154
1154
|
const currentThreadMap = useMemo(() => {
|
|
1155
1155
|
const map = new Map(alone);
|
|
1156
1156
|
if (!map.has(currentThread.id))
|
|
@@ -1318,7 +1318,7 @@ function Thread({ placeholder = message(), initial, anonymous = false, heading,
|
|
|
1318
1318
|
const failure = (question) => {
|
|
1319
1319
|
const failed = failures[question.id];
|
|
1320
1320
|
const text = words(question.content);
|
|
1321
|
-
const whom = addressed(text,
|
|
1321
|
+
const whom = addressed(text, cast);
|
|
1322
1322
|
const wrong = failed?.error ?? null;
|
|
1323
1323
|
const how = wrong ? refusalOf(wrong) : null;
|
|
1324
1324
|
// A BILLING REFUSAL is said in the gateway's words; its way past —
|
|
@@ -1353,7 +1353,7 @@ function Thread({ placeholder = message(), initial, anonymous = false, heading,
|
|
|
1353
1353
|
// Dev, from the Summary's Create file or site: a move inside the app where the
|
|
1354
1354
|
// host's app reads the path (hanzo.ai), else Dev on hanzo.ai, as the shell's
|
|
1355
1355
|
// Dev place goes from a host without it (hanzo.team).
|
|
1356
|
-
const pathed =
|
|
1356
|
+
const pathed = useHost().path !== null;
|
|
1357
1357
|
const create = () => (pathed ? go(app("")) : window.location.assign(dev()));
|
|
1358
1358
|
const sections = useSections({ at, said, held: files, deck, onCreate: create });
|
|
1359
1359
|
/** The tabs' browser, as this conversation offers it: the org's sites to start from, and a page asked about, captured or opened in Dev. */
|
|
@@ -1369,15 +1369,15 @@ function Thread({ placeholder = message(), initial, anonymous = false, heading,
|
|
|
1369
1369
|
window.location.assign(dev(slug));
|
|
1370
1370
|
},
|
|
1371
1371
|
};
|
|
1372
|
-
// THE COMPOSER'S SLOTS (@hanzo/ui/chat): this
|
|
1372
|
+
// THE COMPOSER'S SLOTS (@hanzo/ui/chat): this pane hands it what it carries,
|
|
1373
1373
|
// and the composer draws the rest the way the person's setting says.
|
|
1374
1374
|
// What pressing a suggestion does, at once: open what it names, send its prompt
|
|
1375
|
-
// here (the
|
|
1375
|
+
// here (the pane is a new chat while one shows), hand its run to Dev, or make
|
|
1376
1376
|
// its scheduled task and show it in Scheduled tasks.
|
|
1377
1377
|
const hint = (a, row) => {
|
|
1378
1378
|
handleHint(a, row, { reopen, submit, target, setPrepWrong, t });
|
|
1379
1379
|
};
|
|
1380
|
-
// A chat a suggestion in Dev left for this
|
|
1380
|
+
// A chat a suggestion in Dev left for this pane is sent once the pane is a new
|
|
1381
1381
|
// chat: the address's own conversation let go of, nothing said yet.
|
|
1382
1382
|
const [handed] = useState(() => ({ prompt: anonymous ? "" : taken("send") }));
|
|
1383
1383
|
useEffect(() => {
|
|
@@ -1436,13 +1436,13 @@ function Thread({ placeholder = message(), initial, anonymous = false, heading,
|
|
|
1436
1436
|
research: { on: carry.gear.gear.research, set: (on) => carry.gear.set({ research: on }) },
|
|
1437
1437
|
memory: { on: carry.gear.gear.memory, set: (on) => carry.gear.set({ memory: on }) },
|
|
1438
1438
|
},
|
|
1439
|
-
// Who is in the
|
|
1439
|
+
// Who is in the conversation, then what it carries, as chips after `+`.
|
|
1440
1440
|
carried: [
|
|
1441
|
-
...
|
|
1441
|
+
...cast.map((name) => ({
|
|
1442
1442
|
id: `agent:${name}`,
|
|
1443
1443
|
label: name,
|
|
1444
1444
|
icon: _jsx(Face, { src: faces[name]?.avatar, emoji: faces[name]?.emoji, name: name, size: 16 }),
|
|
1445
|
-
onRemove: () => seat(
|
|
1445
|
+
onRemove: () => seat(cast.filter((one) => one !== name)),
|
|
1446
1446
|
})),
|
|
1447
1447
|
...(anonymous ? [] : carry.on),
|
|
1448
1448
|
],
|
|
@@ -1491,7 +1491,7 @@ function Thread({ placeholder = message(), initial, anonymous = false, heading,
|
|
|
1491
1491
|
: undefined
|
|
1492
1492
|
: undefined,
|
|
1493
1493
|
};
|
|
1494
|
-
return (_jsxs(YStack, { display: "grid", gridTemplateRows: "auto minmax(0, 1fr)", width: "100%", height: "100%", minH: 0, position: "relative", "data-slot": "
|
|
1494
|
+
return (_jsxs(YStack, { display: "grid", gridTemplateRows: "auto minmax(0, 1fr)", width: "100%", height: "100%", minH: 0, position: "relative", "data-slot": "conversation",
|
|
1495
1495
|
// A LINK IN AN ANSWER OPENS IN A TAB beside the conversation when the tab
|
|
1496
1496
|
// can show it — a site or preview we host — and in a browser tab of its
|
|
1497
1497
|
// own otherwise, as a modified click always does.
|
|
@@ -1533,7 +1533,7 @@ function Thread({ placeholder = message(), initial, anonymous = false, heading,
|
|
|
1533
1533
|
}, children: [_jsx(Schedule, { open: plan !== null, onOpenChange: (open) => {
|
|
1534
1534
|
if (!open)
|
|
1535
1535
|
setPlan(null);
|
|
1536
|
-
}, 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, display: "grid", gridTemplateColumns: "minmax(0, 1fr) auto", items: "center", gap: "$3", paddingInlineStart: "$4", paddingInlineEnd: "$2", shrink: 0, "data-tauri-drag-region": "deep", onMouseDown: dragWindow, onDoubleClick: toggleWindowMaximize, "$max-md": !mine && !
|
|
1536
|
+
}, 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, display: "grid", gridTemplateColumns: "minmax(0, 1fr) auto", items: "center", gap: "$3", paddingInlineStart: "$4", paddingInlineEnd: "$2", shrink: 0, "data-tauri-drag-region": "deep", onMouseDown: dragWindow, onDoubleClick: toggleWindowMaximize, "$max-md": !mine && !cast.length ? { display: 'none' } : undefined, children: [_jsxs(XStack, { items: "center", gap: "$2", minW: 0, children: [mine ? (_jsx(Text, { fontSize: 15, lineHeight: 20, color: "$ink", numberOfLines: 1, shrink: 1, minW: 0, children: tidy(mine.title) })) : null, cast.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: cast.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, said.length > 0 ? (_jsx(ConversationMenu, { threads: currentThreadMap, active: open || currentThread.id, onSchedule: anonymous || forgetful ? undefined : () => setPlan(lastAsked()), children: _jsx(XStack, { children: _jsx(ThreadMore, { t: currentThread }) }) })) : (_jsxs(XStack, { render: "button", "data-slot": "header-private-chat", "aria-label": t("Private chat mode"), "aria-pressed": forgetful, ...{ title: forgetful ? t("Private chat enabled: messages will not be saved") : t("Private chat: forgetful mode") }, items: "center", gap: "$1.5", px: "$2", py: "$1", height: 28, rounded: "$3", cursor: "pointer", borderWidth: 1, borderColor: forgetful ? 'var(--primary)' : '$borderColor', bg: forgetful ? 'var(--primary-10, var(--white-10))' : 'transparent', hoverStyle: { bg: forgetful ? 'var(--primary-15, var(--white-15))' : '$hover' }, onPress: () => setForgetful(!forgetful), children: [_jsx(Ghost, { size: 13, strokeWidth: 1.75, color: forgetful ? 'var(--primary)' : 'var(--soft, var(--muted-foreground))', "aria-hidden": true }), _jsx(Text, { fontSize: "$1", fontWeight: forgetful ? '600' : '500', color: forgetful ? 'var(--primary)' : '$soft', children: t("Private") }), _jsx(Switch, { size: "sm", checked: forgetful, pointerEvents: "none" })] })), _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(Side, { 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,
|
|
1537
1537
|
// THE COMPOSER IS FIXED TO THE FOOT, on a laptop and on a phone, empty or
|
|
1538
1538
|
// not: while nothing has been said the opening (the heading) stands at the
|
|
1539
1539
|
// foot of the height above it; once a turn exists the transcript scrolls
|
|
@@ -1564,13 +1564,13 @@ function Thread({ placeholder = message(), initial, anonymous = false, heading,
|
|
|
1564
1564
|
return (_jsxs(YStack, { gap: "$1", children: [_jsx(Carried, { text: read.text, attached: read.carried.attached, reused: read.carried.reused, onOpen: openFile, onSave: anonymous ? undefined : (url, id, f) => keepOne(url, id, f.name, f.type) }), !anonymous && read.text ? _jsx(Plan, { onPress: () => setPlan(read.text) }) : null] }));
|
|
1565
1565
|
}
|
|
1566
1566
|
// WHILE THE ANSWER HAS NO WORDS YET: who is answering (the agents the
|
|
1567
|
-
// question addresses, or the whole
|
|
1567
|
+
// question addresses, or the whole cast when it names nobody), and the
|
|
1568
1568
|
// model's reasoning as it streams (`reasoning` on the turn), dimmed and
|
|
1569
1569
|
// cut to its last lines.
|
|
1570
1570
|
const thought = turn.role === "assistant" && !said && chat.streaming ? (turn.reasoning ?? "").trim() : "";
|
|
1571
|
-
if (turn.role === "assistant" && !said && chat.streaming && (
|
|
1571
|
+
if (turn.role === "assistant" && !said && chat.streaming && (cast.length || thought)) {
|
|
1572
1572
|
const q = [...shown].reverse().find((one) => one.role === "user");
|
|
1573
|
-
const whom =
|
|
1573
|
+
const whom = cast.length ? addressed(words(q?.content), cast) : [];
|
|
1574
1574
|
return (_jsxs(YStack, { gap: "$1", "data-slot": "thinking", children: [_jsx(Text, { fontSize: "$2", color: "$soft", children: whom.length
|
|
1575
1575
|
? whom.length > 1
|
|
1576
1576
|
? thought
|
|
@@ -1581,7 +1581,7 @@ function Thread({ placeholder = message(), initial, anonymous = false, heading,
|
|
|
1581
1581
|
: t("{names} is answering…", { names: join(whom, t) })
|
|
1582
1582
|
: t("Thinking…") }), thought ? (_jsx(Text, { fontSize: "$2", color: "$soft", opacity: 0.72, "data-slot": "thought", children: thought.length > THOUGHT ? `…${thought.slice(-THOUGHT).replace(/^\S*\s/, "")}` : thought })) : null] }));
|
|
1583
1583
|
}
|
|
1584
|
-
// A
|
|
1584
|
+
// A CAST'S ANSWER IS SEVERAL PEOPLE'S. Each opens a line with their
|
|
1585
1585
|
// name, as the brief asks, so each is drawn under their own face and
|
|
1586
1586
|
// read in their own voice. A reply that names nobody is drawn whole.
|
|
1587
1587
|
const parts = turn.role === "assistant" ? speakers(said, known) : null;
|
|
@@ -1590,8 +1590,8 @@ function Thread({ placeholder = message(), initial, anonymous = false, heading,
|
|
|
1590
1590
|
// in this reply.
|
|
1591
1591
|
const at = shown.findIndex((one) => one.id === turn.id);
|
|
1592
1592
|
const q = shown.slice(0, at).reverse().find((one) => one.role === "user");
|
|
1593
|
-
const silent =
|
|
1594
|
-
? addressed(words(q?.content),
|
|
1593
|
+
const silent = cast.length > 1 && !(chat.streaming && at === shown.length - 1)
|
|
1594
|
+
? addressed(words(q?.content), cast).filter((name) => !parts.some((part) => part.who?.toLowerCase() === name.toLowerCase()))
|
|
1595
1595
|
: [];
|
|
1596
1596
|
return (_jsxs(YStack, { gap: "$3", children: [parts.map((part, i) => (_jsxs(YStack, { gap: "$1", 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 ? _jsx(Reply, { text: part.text, listen: listen(part.who ?? withWhom ?? undefined), onOpen: opener(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)] }));
|
|
1597
1597
|
}
|
|
@@ -1602,7 +1602,7 @@ function Thread({ placeholder = message(), initial, anonymous = false, heading,
|
|
|
1602
1602
|
// with it when it did. `Ask` passes its own, because the page embedding
|
|
1603
1603
|
// it already has an `<h1>` and a second is the defect that took the
|
|
1604
1604
|
// landings off /chat and /dev.
|
|
1605
|
-
empty: heading === null ? undefined : (_jsxs(YStack, { "data-slot": "opening", display: "grid", gridTemplateRows: "1fr auto", items: "center", width: "100%", height: "100%", pt: "$6", pb: "$2", children: [
|
|
1605
|
+
empty: heading === null ? undefined : (_jsxs(YStack, { "data-slot": "opening", display: "grid", gridTemplateRows: "1fr auto", items: "center", width: "100%", height: "100%", pt: "$6", pb: "$2", children: [cast.length > 1 ? (_jsx(XStack, { items: "center", justify: "center", mb: "$4", children: cast.map((name, i) => (_jsx(Box, { marginInlineStart: i ? -16 : 0, rounded: 40, borderWidth: 2, borderColor: "$background", z: cast.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, cast.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(cast, t) || heading || (firstName ? t("What’s up, {name}?", { name: firstName }) : t("What’s up?")) }), cast.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] })),
|
|
1606
1606
|
// The transcript reads at the same measure. `Thread` defaults to 768
|
|
1607
1607
|
// itself; handing it the column here is what lets Width reach it.
|
|
1608
1608
|
column: { maxW: MEASURE }, composer: composer }), _jsx(AgentMaker, {}), carry.dialog, _jsx(Upgrade, { ask: ask, onClose: () => setAsk(null) })] }));
|