@gemies/sdk 7.1.0 → 9.0.0
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/CHANGELOG.md +43 -0
- package/README.md +9 -6
- package/package.json +1 -1
- package/src/accounts.ts +0 -11
- package/src/components/GemieBetweenGemies.tsx +115 -0
- package/src/components/GemieChatContent.tsx +38 -44
- package/src/components/GemieParticipants.tsx +12 -64
- package/src/components/GemieSharedConversation.tsx +1 -9
- package/src/components/thread/GemieConversationCard.tsx +120 -0
- package/src/components/thread/GemieThread.tsx +30 -80
- package/src/components/thread/ThreadRow.tsx +24 -5
- package/src/hooks/useThreadRows.ts +0 -12
- package/src/index.ts +5 -6
- package/src/lib/copy-en.ts +8 -5
- package/src/lib/copy-es.ts +8 -5
- package/src/lib/gemie-conversation-opener.ts +14 -0
- package/src/lib/participants.ts +16 -22
- package/src/realtime/cache.ts +5 -0
- package/src/realtime/contract.ts +4 -0
- package/src/runtime/connected-accounts.ts +2 -24
- package/src/runtime/conversations.ts +18 -8
- package/src/runtime/gemie-conversations.ts +122 -0
- package/src/runtime/index.ts +6 -2
- package/src/runtime/message-history.ts +9 -12
- package/src/runtime/query-keys.ts +6 -3
- package/src/runtime/room-events.ts +23 -17
- package/src/runtime/routes.ts +0 -5
- package/src/runtime/stream-events.ts +10 -7
- package/src/runtime/types.ts +10 -3
- package/src/runtime/use-conversation-stream.ts +31 -26
- package/src/runtime/use-conversation-thread.ts +1 -1
- package/src/components/thread/AgentExchangeView.tsx +0 -112
- package/src/runtime/channel-tasks.ts +0 -78
- package/src/runtime/thread/agent-exchange.ts +0 -94
- package/src/runtime/thread/speaker-changes.ts +0 -66
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,48 @@
|
|
|
1
1
|
# @gemies/sdk
|
|
2
2
|
|
|
3
|
+
## 9.0.0
|
|
4
|
+
|
|
5
|
+
Gemies acts for the person with Oxy's first-party authority (oxy ADR 0066): what the Oxy registry
|
|
6
|
+
declares for it, checked live by Oxy on every call. A channel, a linked Telegram or a gemie's
|
|
7
|
+
background work holds no Oxy task any more, so there is nothing to renew or reauthorise.
|
|
8
|
+
|
|
9
|
+
- **Breaking — channel task renewal is gone.** `useChannelTaskRenewal`, `useReauthorizeChannels`,
|
|
10
|
+
`renewChannelTasks`, `CHANNEL_TASK_KINDS` and the `ChannelTaskKind`, `ChannelTaskRef` and
|
|
11
|
+
`ChannelTaskRenewal` types are removed from `@gemies/sdk/accounts`, with the
|
|
12
|
+
`ACCOUNT_ROUTES.renewChannelTasks` route and the `accounts.channelTaskRenewal` query key. The API
|
|
13
|
+
no longer serves `POST /me/channel-tasks/renew` or `POST /me/accounts/:accountId/reauthorize`.
|
|
14
|
+
- **Breaking — `ConnectedAccount.oxyTaskState` is removed.** `useConnectedAccounts` only reads the
|
|
15
|
+
list. The person's off switches stay where they were: which gemie answers an account, whom it
|
|
16
|
+
answers, and removing the account.
|
|
17
|
+
|
|
18
|
+
## 8.0.0
|
|
19
|
+
|
|
20
|
+
Gemies talk to each other in real conversations (Gemies ADR 0042). A gemie that wants something from
|
|
21
|
+
another writes to it (`sendMessage`) in the conversation the two of them have for the person; the
|
|
22
|
+
other answers in its own turn, and the first reads the answer and continues or tells the person.
|
|
23
|
+
|
|
24
|
+
- **New: the card of a conversation between gemies.** A `sendMessage` call in the chat draws
|
|
25
|
+
"Pepe is talking to Lumen…" while they talk — who is writing, the last thing said, live over the
|
|
26
|
+
conversation's room events — then "Pepe talked to Lumen". Pressed, it opens their whole
|
|
27
|
+
conversation over the chat, read-only.
|
|
28
|
+
- **New: `GemieBetweenGemies`**, that read-only conversation: every turn under its gemie's name and
|
|
29
|
+
avatar (Alia drawn as herself), its tool steps and thought panel, streaming while they still talk,
|
|
30
|
+
no composer. An app may also give it a screen of its own.
|
|
31
|
+
- **`useConversations({ kind: 'gemies' })`** lists the conversations the person's gemies have with
|
|
32
|
+
each other; `Conversation.kind` and `Conversation.members` say which one is and who talks in it.
|
|
33
|
+
- **A gemie telling the person what another answered streams into the chat as its own reply**: a
|
|
34
|
+
room event with `lead: true` draws the conversation's lead, not a guest.
|
|
35
|
+
- **Breaking — consultations are gone.** Nobody joins a chat mid-turn any more, so `useParticipants`
|
|
36
|
+
(and `UseParticipantsOptions`) is removed: the header is drawn from who is in the conversation
|
|
37
|
+
when it opens. The "Chatted with" line, the agent exchange it opened and `GemieThread`'s
|
|
38
|
+
`memberIds` and `onOpenAgentChat` are removed. A group turn's member frames are
|
|
39
|
+
`MemberTurnEvent`, `MemberTurnAgent` and `parseMemberTurnEvent` (were `ConsultEvent`,
|
|
40
|
+
`ConsultAgent`, `parseConsultEvent`), and only a group turn's request carries them.
|
|
41
|
+
- **Copy:** `chat.betweenGemiesNotice`, `chat.gemiesTalking`, `chat.gemiesTalked`,
|
|
42
|
+
`chat.gemieWriting`, `chat.gemiesOpen`, `tasks.tool.*.sendMessage` are new; `chat.consultFailed`
|
|
43
|
+
is `chat.agentFailed`; `chat.chattedWith`, `chat.agentChatNotice` and `tasks.tool.*.consultAgent`
|
|
44
|
+
are gone.
|
|
45
|
+
|
|
3
46
|
## 7.1.0
|
|
4
47
|
|
|
5
48
|
- **A person's channels keep their authority** (Gemies ADR 0037, amendment of 2026-11-14). Each
|
package/README.md
CHANGED
|
@@ -226,16 +226,19 @@ The sheet offers the person's latest conversations with its lead under the greet
|
|
|
226
226
|
- **The lead.** `agent={{ id }}` (on `GemieChatSheet`, `GemieChatScreen` and `GemieChatContent`) makes
|
|
227
227
|
that agent the conversation's lead: its greeting, name, character and starters
|
|
228
228
|
(`GET /v1/agents/:id/profile`) and the header's first avatar. Omitted, Alia.
|
|
229
|
-
- **The participants.** `GemieChatState.participants` is `{ lead, joined }
|
|
230
|
-
`GemieParticipants` (or `GemieParticipantsHeader` inside
|
|
231
|
-
chrome puts the conversation's title.
|
|
232
|
-
|
|
233
|
-
|
|
229
|
+
- **The participants.** `GemieChatState.participants` is `{ lead, joined }` — the lead, and a
|
|
230
|
+
group's other members; draw it with `GemieParticipants` (or `GemieParticipantsHeader` inside
|
|
231
|
+
Bloom's AI chat shell) wherever the chrome puts the conversation's title.
|
|
232
|
+
- **Gemies talking to each other** (Gemies ADR 0042). A gemie that writes to another
|
|
233
|
+
(`sendMessage`) draws a card in the chat — "Pepe is talking to Lumen…", live over the
|
|
234
|
+
conversation's room events, then "Pepe talked to Lumen" — that opens their whole conversation
|
|
235
|
+
read-only over the chat (`GemieBetweenGemies`). An app can give that view a screen of its own and
|
|
236
|
+
list the conversations with `useConversations({ kind: 'gemies' })`.
|
|
234
237
|
- **Host tools** are UI effects the app's own client performs. An `alia.host_action` is executed
|
|
235
238
|
once, by `execute`, and its outcome is sent with the next request; an outcome whose request did
|
|
236
239
|
not get through goes with the one after. They are never authority over data.
|
|
237
240
|
- **Tool renderers** are keyed `<app>:<tool>`, parsed only from `oxy_<app>__<tool>` /
|
|
238
|
-
`self_<app>__<tool>`, and drawn before the generic tool card — for
|
|
241
|
+
`self_<app>__<tool>`, and drawn before the generic tool card — for every gemie in the conversation.
|
|
239
242
|
- **Feature gates.** The attach menu offers photos and files as the lead offers them
|
|
240
243
|
(`GET /v1/agents/:id/features`); a locked row, and a turn refused with
|
|
241
244
|
`feature_entitlement_required`, call `onFeatureLocked(key)`. Documents are uploaded to the
|
package/package.json
CHANGED
package/src/accounts.ts
CHANGED
|
@@ -4,10 +4,6 @@
|
|
|
4
4
|
* person connects once and grants to their gemies. `GemieConnectedAccounts` is Settings ›
|
|
5
5
|
* Connected accounts; `GemieAccountGrants` is the list of them a gemie's editor shows, one switch
|
|
6
6
|
* each. Its own entry so an app that does not draw them never reaches the QR encoder.
|
|
7
|
-
*
|
|
8
|
-
* Every channel's Oxy task is renewed from here too (`runtime/channel-tasks.ts`): mount
|
|
9
|
-
* `useChannelTaskRenewal` once where the app is signed in, and `useReauthorizeChannels` on the page
|
|
10
|
-
* a channel's notice opens.
|
|
11
7
|
*/
|
|
12
8
|
export { GemieAccountGrants } from './components/accounts/GemieAccountGrants';
|
|
13
9
|
export type { GemieAccountGrantsProps } from './components/accounts/GemieAccountGrants';
|
|
@@ -35,10 +31,3 @@ export type {
|
|
|
35
31
|
GemieAccountStatus,
|
|
36
32
|
GrantableGemie,
|
|
37
33
|
} from './runtime/connected-accounts';
|
|
38
|
-
export {
|
|
39
|
-
CHANNEL_TASK_KINDS,
|
|
40
|
-
renewChannelTasks,
|
|
41
|
-
useChannelTaskRenewal,
|
|
42
|
-
useReauthorizeChannels,
|
|
43
|
-
} from './runtime/channel-tasks';
|
|
44
|
-
export type { ChannelTaskKind, ChannelTaskRef, ChannelTaskRenewal } from './runtime/channel-tasks';
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
import { AgentAvatarProvider } from '@oxy.so/bloom/agent-avatar';
|
|
2
|
+
import type { AiChatThreadHandle } from '@oxy.so/bloom/ai-chat';
|
|
3
|
+
import { ButtonGroup, ButtonGroupItem } from '@oxy.so/bloom/button-group';
|
|
4
|
+
import { RiArrowLeftLine } from '@oxy.so/bloom/icons/RiArrowLeftLine';
|
|
5
|
+
import { PageHeader } from '@oxy.so/bloom/page-header';
|
|
6
|
+
import { Text } from '@oxy.so/bloom/typography';
|
|
7
|
+
import { useEffect, useMemo, useRef, useState } from 'react';
|
|
8
|
+
import { View } from 'react-native';
|
|
9
|
+
import { BubblesProvider } from '../lib/bubbles';
|
|
10
|
+
import { useLabels } from '../lib/labels';
|
|
11
|
+
import { type GemieChatParticipants, participantOf } from '../lib/participants';
|
|
12
|
+
import { useConversation } from '../runtime/conversations';
|
|
13
|
+
import { createRoomLedger } from '../runtime/room-events';
|
|
14
|
+
import type { Message } from '../runtime/types';
|
|
15
|
+
import { useRoomEvents } from '../runtime/use-room-events';
|
|
16
|
+
import { GemieParticipants } from './GemieParticipants';
|
|
17
|
+
import { GemieThread } from './thread/GemieThread';
|
|
18
|
+
|
|
19
|
+
export interface GemieBetweenGemiesProps {
|
|
20
|
+
/** A conversation between gemies (`kind: 'gemies'`, ADR 0042). */
|
|
21
|
+
conversationId: string;
|
|
22
|
+
/** Back to wherever it was opened from. */
|
|
23
|
+
onBack: () => void;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
type Agent = NonNullable<Message['agentInfo']>;
|
|
27
|
+
|
|
28
|
+
/** Who talks in it: the two gemies the server names, or, before it answers, whoever spoke. */
|
|
29
|
+
function membersOf(members: readonly Agent[] | undefined, messages: readonly Message[]): Agent[] {
|
|
30
|
+
if (members && members.length > 0) return [...members];
|
|
31
|
+
const seen = new Map<string, Agent>();
|
|
32
|
+
for (const message of messages) {
|
|
33
|
+
if (message.agentInfo && !seen.has(message.agentInfo.id)) {
|
|
34
|
+
seen.set(message.agentInfo.id, message.agentInfo);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
return [...seen.values()];
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* A conversation between gemies, read-only, in the same thread the person reads their own
|
|
42
|
+
* conversations in: every turn under its gemie's name and avatar, its tool steps and thought
|
|
43
|
+
* panel where it has them, the time it was said. While the gemies are still talking it streams,
|
|
44
|
+
* through the conversation's `room` frames on the realtime socket, exactly as a group room does. There is no
|
|
45
|
+
* composer: the person reads it and never writes in it (the API refuses a turn there).
|
|
46
|
+
*
|
|
47
|
+
* The chat draws it over itself when its card is pressed; an app may also give it a screen of its
|
|
48
|
+
* own (a route to the conversation), where it is the whole page.
|
|
49
|
+
*/
|
|
50
|
+
export function GemieBetweenGemies(props: GemieBetweenGemiesProps) {
|
|
51
|
+
// Keyed, so another conversation starts with nothing of this one's: its messages, its ledger.
|
|
52
|
+
return <ConversationBetweenGemies key={props.conversationId} {...props} />;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
function ConversationBetweenGemies({ conversationId, onBack }: GemieBetweenGemiesProps) {
|
|
56
|
+
const { t, back } = useLabels();
|
|
57
|
+
const threadRef = useRef<AiChatThreadHandle | null>(null);
|
|
58
|
+
const { data, isPending, refetch } = useConversation(conversationId);
|
|
59
|
+
const [messages, setMessages] = useState<Message[]>([]);
|
|
60
|
+
// Which live reply each room event draws, for as long as this conversation is open.
|
|
61
|
+
const [ledger] = useState(createRoomLedger);
|
|
62
|
+
|
|
63
|
+
// Opened, it is read fresh: the gemies may have said more since it was last loaded.
|
|
64
|
+
useEffect(() => {
|
|
65
|
+
void refetch();
|
|
66
|
+
}, [refetch]);
|
|
67
|
+
useEffect(() => {
|
|
68
|
+
if (data) setMessages(data.messages);
|
|
69
|
+
}, [data]);
|
|
70
|
+
useRoomEvents(conversationId, ledger, setMessages);
|
|
71
|
+
|
|
72
|
+
const participants = useMemo<GemieChatParticipants | null>(() => {
|
|
73
|
+
const [first, ...rest] = membersOf(data?.members, messages).map(participantOf);
|
|
74
|
+
return first === undefined
|
|
75
|
+
? null
|
|
76
|
+
: { lead: { ...first, isAlia: false, starters: [] }, joined: rest };
|
|
77
|
+
}, [data?.members, messages]);
|
|
78
|
+
|
|
79
|
+
return (
|
|
80
|
+
<View className="flex-1 bg-background" testID="gemie-conversation">
|
|
81
|
+
<PageHeader
|
|
82
|
+
leading={
|
|
83
|
+
<ButtonGroup accessibilityLabel={back}>
|
|
84
|
+
<ButtonGroupItem
|
|
85
|
+
iconOnly
|
|
86
|
+
leadingIcon={RiArrowLeftLine}
|
|
87
|
+
accessibilityLabel={back}
|
|
88
|
+
onPress={onBack}
|
|
89
|
+
/>
|
|
90
|
+
</ButtonGroup>
|
|
91
|
+
}
|
|
92
|
+
title={participants ? <GemieParticipants participants={participants} /> : undefined}
|
|
93
|
+
titleAlign="center"
|
|
94
|
+
scrim="none"
|
|
95
|
+
sticky={false}
|
|
96
|
+
safeArea={false}
|
|
97
|
+
/>
|
|
98
|
+
<Text className="px-4 pb-2 text-center text-xs text-muted-foreground">
|
|
99
|
+
{t('chat.betweenGemiesNotice')}
|
|
100
|
+
</Text>
|
|
101
|
+
<AgentAvatarProvider>
|
|
102
|
+
<BubblesProvider value>
|
|
103
|
+
<GemieThread
|
|
104
|
+
messages={messages}
|
|
105
|
+
conversationId={conversationId}
|
|
106
|
+
isLoading={false}
|
|
107
|
+
conversationLoading={isPending}
|
|
108
|
+
threadRef={threadRef}
|
|
109
|
+
readOnly
|
|
110
|
+
/>
|
|
111
|
+
</BubblesProvider>
|
|
112
|
+
</AgentAvatarProvider>
|
|
113
|
+
</View>
|
|
114
|
+
);
|
|
115
|
+
}
|
|
@@ -51,6 +51,7 @@ import { usePendingQuestions } from '../hooks/usePendingQuestions';
|
|
|
51
51
|
import { useThreadView } from '../hooks/useThreadView';
|
|
52
52
|
import { useTTS } from '../hooks/useTTS';
|
|
53
53
|
import { BubblesProvider } from '../lib/bubbles';
|
|
54
|
+
import { GemieConversationOpenerProvider } from '../lib/gemie-conversation-opener';
|
|
54
55
|
import type { GemieAddMenu } from '../lib/add-menu';
|
|
55
56
|
import { GemieFlightsProvider } from '../lib/flights';
|
|
56
57
|
import {
|
|
@@ -69,7 +70,6 @@ import { type GemieHostTools, APP_SLUG } from '../runtime/host-tools';
|
|
|
69
70
|
import { useCreateConversation } from '../runtime/conversations';
|
|
70
71
|
import { gemieQueryKeys } from '../runtime/query-keys';
|
|
71
72
|
import { type GemieThreadAddress, threadKey } from '../runtime/routes';
|
|
72
|
-
import type { AgentExchange } from '../runtime/thread/agent-exchange';
|
|
73
73
|
import type { Message } from '../runtime/types';
|
|
74
74
|
import { useAgentActivity } from '../runtime/use-agent-activity';
|
|
75
75
|
import { useConversationThread } from '../runtime/use-conversation-thread';
|
|
@@ -77,12 +77,11 @@ import { UsageLimitError } from '../runtime/usage-limit-error';
|
|
|
77
77
|
import type { GemieSuggestion } from '../types';
|
|
78
78
|
import type { GemieAvatarState } from './GemieAvatar';
|
|
79
79
|
import { GemieComposer } from './GemieComposer';
|
|
80
|
-
import { useParticipants } from './GemieParticipants';
|
|
81
80
|
import { GemieGroupWelcome } from './GemieGroupWelcome';
|
|
82
81
|
import { GemieWelcomeMessage } from './GemieWelcomeMessage';
|
|
83
82
|
import { AmbientField } from './AmbientField';
|
|
84
83
|
import { InertWhen } from './InertWhen';
|
|
85
|
-
import {
|
|
84
|
+
import { GemieBetweenGemies } from './GemieBetweenGemies';
|
|
86
85
|
import { GemieThread } from './thread/GemieThread';
|
|
87
86
|
import { ThreadSearch } from './thread/ThreadSearch';
|
|
88
87
|
import { VoiceModeIcon } from './VoiceModeIcon';
|
|
@@ -411,20 +410,13 @@ function GemieConversationView({
|
|
|
411
410
|
failedTurn,
|
|
412
411
|
retryFailedTurn,
|
|
413
412
|
} = thread;
|
|
414
|
-
|
|
415
|
-
// The direct agent is a member too. Use the requested id before its profile loads: an
|
|
416
|
-
// attributed follow-up is still its own reply, never a consultation with itself.
|
|
417
|
-
const memberIds = useMemo(
|
|
418
|
-
() =>
|
|
419
|
-
new Set(group === undefined ? (agentId ? [agentId] : []) : group.map((member) => member.id)),
|
|
420
|
-
[agentId, group],
|
|
421
|
-
);
|
|
413
|
+
// Who is in it is known when it opens: its lead, or a group's members (ADR 0020 §7).
|
|
422
414
|
const participants = useMemo(
|
|
423
415
|
() => ({
|
|
424
|
-
...(group === undefined ?
|
|
416
|
+
...(group === undefined ? { lead, joined: [] } : groupParticipants(group)),
|
|
425
417
|
...(conversationId === undefined ? {} : { conversationId }),
|
|
426
418
|
}),
|
|
427
|
-
[group,
|
|
419
|
+
[group, lead, conversationId],
|
|
428
420
|
);
|
|
429
421
|
const asked = usePendingQuestions(messages, isLoading);
|
|
430
422
|
const gemieId = gemieThread?.gemieId;
|
|
@@ -438,10 +430,10 @@ function GemieConversationView({
|
|
|
438
430
|
[threadHandle, gemieId],
|
|
439
431
|
);
|
|
440
432
|
const view = useThreadView(threadAddress, conversationId);
|
|
441
|
-
//
|
|
442
|
-
// mounted under it, so its scroll and the draft are
|
|
443
|
-
const [
|
|
444
|
-
const
|
|
433
|
+
// A conversation between gemies a card in the thread opened (ADR 0042), read-only, drawn over the
|
|
434
|
+
// chat (which stays mounted under it, so its scroll and the draft are as they were on the way back).
|
|
435
|
+
const [betweenGemies, setBetweenGemies] = useState<string | null>(null);
|
|
436
|
+
const closeBetweenGemies = useCallback(() => setBetweenGemies(null), []);
|
|
445
437
|
const agentActivity = useAgentActivity(agentRun?.turnId ?? null, agentRun?.agentId);
|
|
446
438
|
|
|
447
439
|
// The turn was refused for the usage limit: the composer is closed until the host's dialog is
|
|
@@ -776,7 +768,7 @@ function GemieConversationView({
|
|
|
776
768
|
const showsPast = view.jumped;
|
|
777
769
|
return (
|
|
778
770
|
<GemieFlightsProvider value={flights}>
|
|
779
|
-
<InertWhen inert={
|
|
771
|
+
<InertWhen inert={betweenGemies !== null}>
|
|
780
772
|
<AiChatContainer
|
|
781
773
|
header={frame.header}
|
|
782
774
|
title={frame.title}
|
|
@@ -793,30 +785,30 @@ function GemieConversationView({
|
|
|
793
785
|
background={background}
|
|
794
786
|
>
|
|
795
787
|
<BubblesProvider value={bubbles || group !== undefined}>
|
|
796
|
-
<
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
788
|
+
<GemieConversationOpenerProvider value={setBetweenGemies}>
|
|
789
|
+
<GemieThread
|
|
790
|
+
// Nothing live under a window: it is a view of the past, and the conversation being
|
|
791
|
+
// streamed into is not below it in the thread.
|
|
792
|
+
messages={showsPast ? NO_MESSAGES : messages}
|
|
793
|
+
conversationId={conversationId}
|
|
794
|
+
isLoading={isLoading}
|
|
795
|
+
conversationLoading={conversationLoading || loading}
|
|
796
|
+
history={view.history}
|
|
797
|
+
focusCursor={view.focusCursor}
|
|
798
|
+
failedTurn={failedTurn}
|
|
799
|
+
onRetryTurn={retryFailedTurn}
|
|
800
|
+
onRegenerate={composer.regenerate}
|
|
801
|
+
onStartEdit={edit.start}
|
|
802
|
+
newConversationOffer={newConversationOffer}
|
|
803
|
+
agentActivity={agentRun === null ? null : agentActivity}
|
|
804
|
+
call={voice.isActive ? { agentState: voice.agentState } : undefined}
|
|
805
|
+
empty={welcome}
|
|
806
|
+
threadRef={threadRef}
|
|
807
|
+
onScroll={onScroll}
|
|
808
|
+
onReply={quoteIntoComposer}
|
|
809
|
+
onReactionChange={thread.applyReaction}
|
|
810
|
+
/>
|
|
811
|
+
</GemieConversationOpenerProvider>
|
|
820
812
|
</BubblesProvider>
|
|
821
813
|
{!showsPast ? null : (
|
|
822
814
|
<View className="absolute inset-x-0 top-16 z-10 items-center" pointerEvents="box-none">
|
|
@@ -830,8 +822,10 @@ function GemieConversationView({
|
|
|
830
822
|
)}
|
|
831
823
|
</AiChatContainer>
|
|
832
824
|
</InertWhen>
|
|
833
|
-
{
|
|
834
|
-
<
|
|
825
|
+
{betweenGemies === null ? null : (
|
|
826
|
+
<View className="absolute inset-0 z-20">
|
|
827
|
+
<GemieBetweenGemies conversationId={betweenGemies} onBack={closeBetweenGemies} />
|
|
828
|
+
</View>
|
|
835
829
|
)}
|
|
836
830
|
{usageLimit === null ? null : renderUsageLimit?.({ error: usageLimit, dismiss: clearError })}
|
|
837
831
|
{sharedFlights ? null : <AvatarFlightLayer flights={ownFlights} />}
|
|
@@ -1,46 +1,23 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* The conversation's participants: Bloom's `AgentProfile` with `[lead, ...joined]
|
|
3
|
-
* agents joining it (ADR 0020 §7).
|
|
2
|
+
* The conversation's participants: Bloom's `AgentProfile` with `[lead, ...joined]` (ADR 0020 §7).
|
|
4
3
|
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
* the conversation when the chat opens is simply there.
|
|
4
|
+
* Who is in a conversation is known when it opens: its lead, a group's members, or the two gemies
|
|
5
|
+
* of a conversation between gemies (ADR 0042). Nobody joins a chat mid-turn any more — a gemie that
|
|
6
|
+
* wants something from another writes to it in their own conversation — so the header is drawn,
|
|
7
|
+
* never joined. A GROUP's first message flies its members' avatars out of the empty chat into it
|
|
8
|
+
* (`groupFirstSend`), Bloom's own multi-agent choreography.
|
|
11
9
|
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
* This is the ONLY file that draws `AgentProfile` or joins agents to it (`one-thread.test.tsx`
|
|
16
|
-
* holds it), so the header of the sheet, the screen and the Alia app are one header.
|
|
10
|
+
* This is the ONLY file that draws `AgentProfile` (`one-thread.test.tsx` holds it), so the header
|
|
11
|
+
* of the sheet, the screen and the Alia app are one header.
|
|
17
12
|
*/
|
|
18
13
|
|
|
19
14
|
import { AgentProfile } from '@oxy.so/bloom/agent-reply';
|
|
20
|
-
import {
|
|
21
|
-
type AvatarFlightSpec,
|
|
22
|
-
type AvatarFlights,
|
|
23
|
-
avatarJoinFlights,
|
|
24
|
-
useAvatarJoin,
|
|
25
|
-
} from '@oxy.so/bloom/avatar-flight';
|
|
15
|
+
import { type AvatarFlightSpec, avatarJoinFlights } from '@oxy.so/bloom/avatar-flight';
|
|
26
16
|
import { memo, useMemo } from 'react';
|
|
27
17
|
import { ANCHORS, useGemieFlights } from '../lib/flights';
|
|
28
|
-
import {
|
|
29
|
-
type GemieChatParticipants,
|
|
30
|
-
type GemieLead,
|
|
31
|
-
type GemieParticipant,
|
|
32
|
-
consultedAgents,
|
|
33
|
-
} from '../lib/participants';
|
|
34
|
-
import type { Message } from '../runtime/types';
|
|
18
|
+
import type { GemieChatParticipants, GemieParticipant } from '../lib/participants';
|
|
35
19
|
import { useConversationActivityText } from '../realtime/activity-text';
|
|
36
20
|
|
|
37
|
-
export interface UseParticipantsOptions {
|
|
38
|
-
lead: GemieLead;
|
|
39
|
-
messages: readonly Message[];
|
|
40
|
-
/** The chat's flights; `null` draws everybody in place without flying. */
|
|
41
|
-
flights: AvatarFlights | null;
|
|
42
|
-
}
|
|
43
|
-
|
|
44
21
|
/** How long the answering member's avatar takes to land on its reply. */
|
|
45
22
|
const REPLY_LANDING_MS = 800;
|
|
46
23
|
|
|
@@ -68,35 +45,6 @@ export function groupFirstSend(members: readonly GemieParticipant[]): AvatarFlig
|
|
|
68
45
|
];
|
|
69
46
|
}
|
|
70
47
|
|
|
71
|
-
const fromReply = (agent: GemieParticipant) => ANCHORS.reply(agent.id);
|
|
72
|
-
const characterOf = (agent: GemieParticipant) => agent.character;
|
|
73
|
-
|
|
74
|
-
/** Who the header shows: the lead, then the agents it consulted as each one's avatar lands. */
|
|
75
|
-
export function useParticipants({
|
|
76
|
-
lead,
|
|
77
|
-
messages,
|
|
78
|
-
flights,
|
|
79
|
-
}: UseParticipantsOptions): GemieChatParticipants {
|
|
80
|
-
const arrivals = useMemo(
|
|
81
|
-
() =>
|
|
82
|
-
consultedAgents(messages, lead.id).map(({ participant, live }) => ({
|
|
83
|
-
agent: participant,
|
|
84
|
-
live,
|
|
85
|
-
})),
|
|
86
|
-
[messages, lead.id],
|
|
87
|
-
);
|
|
88
|
-
const joined = useAvatarJoin({
|
|
89
|
-
arrivals,
|
|
90
|
-
flights,
|
|
91
|
-
from: fromReply,
|
|
92
|
-
to: ANCHORS.profile,
|
|
93
|
-
character: characterOf,
|
|
94
|
-
// A new lead is a new conversation: nobody has joined it.
|
|
95
|
-
resetKey: lead.id,
|
|
96
|
-
});
|
|
97
|
-
return useMemo(() => ({ lead, joined: [...joined] }), [lead, joined]);
|
|
98
|
-
}
|
|
99
|
-
|
|
100
48
|
export interface GemieParticipantsProps {
|
|
101
49
|
participants: GemieChatParticipants;
|
|
102
50
|
/** Pressing the profile. Omitted, every avatar in it waves. */
|
|
@@ -106,8 +54,8 @@ export interface GemieParticipantsProps {
|
|
|
106
54
|
const noop = () => undefined;
|
|
107
55
|
|
|
108
56
|
/**
|
|
109
|
-
* The header's participants: the lead's avatar above its name,
|
|
110
|
-
* ("
|
|
57
|
+
* The header's participants: the lead's avatar above its name, with the others in the conversation
|
|
58
|
+
* ("Pepe + Lumen"). Place it in the chat's chrome; it is the conversation's title.
|
|
111
59
|
*/
|
|
112
60
|
export const GemieParticipants = memo(function GemieParticipants({
|
|
113
61
|
participants,
|
|
@@ -35,8 +35,6 @@ function SharedThread({ token }: { token: string }) {
|
|
|
35
35
|
const { data, error, isLoading } = useSharedConversation(token);
|
|
36
36
|
const threadRef = useRef<AiChatThreadHandle | null>(null);
|
|
37
37
|
const messages = useMemo(() => (data ? sharedMessages(data) : []), [data]);
|
|
38
|
-
const agentId = data?.agent?.id;
|
|
39
|
-
const memberIds = useMemo(() => new Set(agentId ? [agentId] : []), [agentId]);
|
|
40
38
|
|
|
41
39
|
if (isLoading) {
|
|
42
40
|
return (
|
|
@@ -63,13 +61,7 @@ function SharedThread({ token }: { token: string }) {
|
|
|
63
61
|
{data.title}
|
|
64
62
|
</Text>
|
|
65
63
|
) : null}
|
|
66
|
-
<GemieThread
|
|
67
|
-
messages={messages}
|
|
68
|
-
memberIds={memberIds}
|
|
69
|
-
isLoading={false}
|
|
70
|
-
threadRef={threadRef}
|
|
71
|
-
readOnly
|
|
72
|
-
/>
|
|
64
|
+
<GemieThread messages={messages} isLoading={false} threadRef={threadRef} readOnly />
|
|
73
65
|
</View>
|
|
74
66
|
);
|
|
75
67
|
}
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
import { AgentStack } from '@oxy.so/bloom/agent-reply';
|
|
2
|
+
import { AiChatMessageLine } from '@oxy.so/bloom/ai-chat';
|
|
3
|
+
import { Card } from '@oxy.so/bloom/card';
|
|
4
|
+
import { TypingDots } from '@oxy.so/bloom/chat-indicators';
|
|
5
|
+
import { RiArrowRightSLine } from '@oxy.so/bloom/icons/RiArrowRightSLine';
|
|
6
|
+
import { Item } from '@oxy.so/bloom/item';
|
|
7
|
+
import { useRef, useState } from 'react';
|
|
8
|
+
import { useOpenGemieConversation } from '../../lib/gemie-conversation-opener';
|
|
9
|
+
import { useLabels } from '../../lib/labels';
|
|
10
|
+
import { agentCharacterOf } from '../../lib/participants';
|
|
11
|
+
import { useRealtimeEvent } from '../../realtime/react';
|
|
12
|
+
import type { RoomEvent } from '../../runtime/room-events';
|
|
13
|
+
import type { RealtimeData } from '../../realtime/contract';
|
|
14
|
+
import {
|
|
15
|
+
type GemieConversationCall,
|
|
16
|
+
type GemieConversationLive,
|
|
17
|
+
foldGemieConversationEvent,
|
|
18
|
+
foldGemieConversationRow,
|
|
19
|
+
} from '../../runtime/gemie-conversations';
|
|
20
|
+
|
|
21
|
+
/** The card's size for the two gemies' avatars together: a list row's leading box. */
|
|
22
|
+
const STACK_SIZE = 36;
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Follows a conversation between gemies while the card is on screen, over the account's realtime
|
|
26
|
+
* `room` frames: whether they are still talking, who is writing, and the last thing said.
|
|
27
|
+
* `talking` starts as `startedLive` — the call was made in this session, so the chain is running —
|
|
28
|
+
* and the conversation's own events move it from there; a card read from history waits for an
|
|
29
|
+
* event before it says anyone is talking.
|
|
30
|
+
*/
|
|
31
|
+
function useGemieConversationLive(
|
|
32
|
+
conversationId: string | null,
|
|
33
|
+
chainId: string | null,
|
|
34
|
+
startedLive: boolean,
|
|
35
|
+
): GemieConversationLive {
|
|
36
|
+
const [live, setLive] = useState<GemieConversationLive>({
|
|
37
|
+
talking: startedLive,
|
|
38
|
+
speaking: null,
|
|
39
|
+
lastLine: null,
|
|
40
|
+
});
|
|
41
|
+
useRealtimeEvent('room', (frame) => {
|
|
42
|
+
if (conversationId === null) return;
|
|
43
|
+
const event = frame.data as RoomEvent;
|
|
44
|
+
setLive((current) => foldGemieConversationEvent(current, event, conversationId, chainId));
|
|
45
|
+
});
|
|
46
|
+
useRealtimeEvent('conversation', (frame) => {
|
|
47
|
+
if (conversationId === null) return;
|
|
48
|
+
const { conversation } = frame.data as RealtimeData['conversation'];
|
|
49
|
+
setLive((current) => foldGemieConversationRow(current, conversation, conversationId));
|
|
50
|
+
});
|
|
51
|
+
return live;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* The card a `sendMessage` call draws in the chat (ADR 0042): "Pepe is talking to Lumen…" while
|
|
56
|
+
* the gemies talk, with who is writing and the last thing said, then "Pepe talked to Lumen".
|
|
57
|
+
* Pressed, it opens their whole conversation, read-only. The result the gemie that wrote comes back
|
|
58
|
+
* with is its own reply, under the card, when it has it.
|
|
59
|
+
*/
|
|
60
|
+
export function GemieConversationCard({
|
|
61
|
+
call,
|
|
62
|
+
startedLive,
|
|
63
|
+
}: {
|
|
64
|
+
call: GemieConversationCall;
|
|
65
|
+
/** Whether the call was made while this chat was open (its turn is the one streaming). */
|
|
66
|
+
startedLive: boolean;
|
|
67
|
+
}) {
|
|
68
|
+
const { t } = useLabels();
|
|
69
|
+
const open = useOpenGemieConversation();
|
|
70
|
+
// Read once: the turn that made the call ends long before the conversation does.
|
|
71
|
+
const startedLiveRef = useRef(startedLive);
|
|
72
|
+
const live = useGemieConversationLive(
|
|
73
|
+
call.conversationId,
|
|
74
|
+
call.chainId,
|
|
75
|
+
startedLiveRef.current || call.writing,
|
|
76
|
+
);
|
|
77
|
+
const { from, to } = call;
|
|
78
|
+
if (from === null || to === null || call.error !== null) return null;
|
|
79
|
+
|
|
80
|
+
const names = { from: from.name, to: to.name };
|
|
81
|
+
const talking = call.writing || live.talking;
|
|
82
|
+
const title = talking ? t('chat.gemiesTalking', names) : t('chat.gemiesTalked', names);
|
|
83
|
+
const subtitle =
|
|
84
|
+
live.speaking !== null
|
|
85
|
+
? t('chat.gemieWriting', { name: live.speaking.name })
|
|
86
|
+
: (live.lastLine ?? t('chat.gemiesOpen'));
|
|
87
|
+
const conversationId = call.conversationId;
|
|
88
|
+
const pressable = open !== null && conversationId !== null;
|
|
89
|
+
|
|
90
|
+
return (
|
|
91
|
+
<AiChatMessageLine block>
|
|
92
|
+
<Card>
|
|
93
|
+
<Item
|
|
94
|
+
leading={
|
|
95
|
+
<AgentStack
|
|
96
|
+
size={STACK_SIZE}
|
|
97
|
+
agents={[from, to].map((agent) => ({
|
|
98
|
+
id: agent.id,
|
|
99
|
+
name: agent.name,
|
|
100
|
+
avatar: agentCharacterOf(agent),
|
|
101
|
+
}))}
|
|
102
|
+
/>
|
|
103
|
+
}
|
|
104
|
+
title={title}
|
|
105
|
+
subtitle={subtitle}
|
|
106
|
+
// The last thing said is a glimpse; the whole of it is one press away.
|
|
107
|
+
subtitleNumberOfLines={1}
|
|
108
|
+
trailing={talking ? <TypingDots /> : pressable ? <RiArrowRightSLine size="sm" /> : null}
|
|
109
|
+
{...(pressable
|
|
110
|
+
? {
|
|
111
|
+
accessibilityRole: 'button' as const,
|
|
112
|
+
accessibilityLabel: `${title}. ${t('chat.gemiesOpen')}`,
|
|
113
|
+
onPress: () => open(conversationId),
|
|
114
|
+
}
|
|
115
|
+
: {})}
|
|
116
|
+
/>
|
|
117
|
+
</Card>
|
|
118
|
+
</AiChatMessageLine>
|
|
119
|
+
);
|
|
120
|
+
}
|