@gemies/sdk 9.0.0 → 9.2.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 CHANGED
@@ -1,5 +1,15 @@
1
1
  # @gemies/sdk
2
2
 
3
+ ## 9.1.0
4
+
5
+ Conversation lists, search results and file/source rows now use Bloom's shared ListItem. Group
6
+ conversation avatars use AvatarGroup's conversation layout, and header actions use Button.Group
7
+ with the same Button component as standalone actions. Existing SDK exports, callbacks and
8
+ conversation behavior remain unchanged.
9
+
10
+ Requires Bloom 22 or later and Services 14.22 or later; earlier Services versions import Bloom
11
+ components removed in version 22.
12
+
3
13
  ## 9.0.0
4
14
 
5
15
  Gemies acts for the person with Oxy's first-party authority (oxy ADR 0066): what the Oxy registry
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gemies/sdk",
3
- "version": "9.0.0",
3
+ "version": "9.2.0",
4
4
  "description": "The Gemies SDK: the conversation runtime, chat UI, voice calls and dictation for Oxy apps that talk to a gemie",
5
5
  "main": "src/index.ts",
6
6
  "react-native": "src/index.ts",
@@ -60,9 +60,9 @@
60
60
  "react": "^19.2.3",
61
61
  "react-native": "^0.86.0 || ^0.88.0",
62
62
  "@expo/vector-icons": "^15.1.1",
63
- "@oxy.so/bloom": ">=21.1.0",
63
+ "@oxy.so/bloom": ">=22.0.0",
64
64
  "@oxy.so/core": ">=7.1.0 <8",
65
- "@oxy.so/services": ">=14.19.1 <15",
65
+ "@oxy.so/services": ">=14.22.0 <15",
66
66
  "@tanstack/react-query": "^5.101",
67
67
  "@react-native-async-storage/async-storage": "^2.2.0",
68
68
  "expo-blur": "^57.0.0 || ^58.0.0",
@@ -1,4 +1,4 @@
1
- import { Item } from '@oxy.so/bloom/item';
1
+ import { ListItem } from '@oxy.so/bloom/list';
2
2
  import { Text } from '@oxy.so/bloom/typography';
3
3
  import { View } from 'react-native';
4
4
  import type { Completion } from '../lib/suggestions';
@@ -23,12 +23,11 @@ export function ComposerSuggestions<T extends GemieSuggestion>({
23
23
  {completions.map(({ suggestion, matchStart, matchEnd }, index) => {
24
24
  const { text } = suggestion;
25
25
  return (
26
- <Item
26
+ <ListItem
27
27
  key={suggestion.id}
28
- density="compact"
29
- highlighted={index === selected}
30
- accessibilityRole="button"
31
- accessibilityLabel={text}
28
+ active={index === selected}
29
+ role="button"
30
+ label={text}
32
31
  onPress={() => onPick(suggestion)}
33
32
  title={
34
33
  <Text numberOfLines={1}>
@@ -1,6 +1,6 @@
1
1
  import { AgentAvatarProvider } from '@oxy.so/bloom/agent-avatar';
2
2
  import type { AiChatThreadHandle } from '@oxy.so/bloom/ai-chat';
3
- import { ButtonGroup, ButtonGroupItem } from '@oxy.so/bloom/button-group';
3
+ import { Button } from '@oxy.so/bloom/button';
4
4
  import { RiArrowLeftLine } from '@oxy.so/bloom/icons/RiArrowLeftLine';
5
5
  import { PageHeader } from '@oxy.so/bloom/page-header';
6
6
  import { Text } from '@oxy.so/bloom/typography';
@@ -80,14 +80,14 @@ function ConversationBetweenGemies({ conversationId, onBack }: GemieBetweenGemie
80
80
  <View className="flex-1 bg-background" testID="gemie-conversation">
81
81
  <PageHeader
82
82
  leading={
83
- <ButtonGroup accessibilityLabel={back}>
84
- <ButtonGroupItem
83
+ <Button.Group accessibilityLabel={back}>
84
+ <Button
85
85
  iconOnly
86
86
  leadingIcon={RiArrowLeftLine}
87
87
  accessibilityLabel={back}
88
88
  onPress={onBack}
89
89
  />
90
- </ButtonGroup>
90
+ </Button.Group>
91
91
  }
92
92
  title={participants ? <GemieParticipants participants={participants} /> : undefined}
93
93
  titleAlign="center"
@@ -407,6 +407,8 @@ function GemieConversationView({
407
407
  suggestedNewConversation,
408
408
  dismissSuggestedNewConversation,
409
409
  agentRun,
410
+ approvals,
411
+ settleApproval,
410
412
  failedTurn,
411
413
  retryFailedTurn,
412
414
  } = thread;
@@ -644,6 +646,22 @@ function GemieConversationView({
644
646
  [suggestedNewConversation, acceptNewConversation, dismissSuggestedNewConversation],
645
647
  );
646
648
 
649
+ // A coding CLI's question to its own user (ADR 0043 §5): the host carries the answer to Gemies.
650
+ const decideApproval = runtime.host.onApprovalDecision;
651
+ const approvalCards = useMemo(
652
+ () => ({
653
+ entries: approvals,
654
+ agentName: lead.name,
655
+ onDecide:
656
+ decideApproval === undefined
657
+ ? undefined
658
+ : (entry: (typeof approvals)[number], decision: 'allow' | 'deny') =>
659
+ decideApproval(entry.requestId, entry.agentId, decision),
660
+ onSettled: settleApproval,
661
+ }),
662
+ [approvals, lead.name, decideApproval, settleApproval],
663
+ );
664
+
647
665
  // ── The chrome ──
648
666
  const latestMessages = useRef(messages);
649
667
  latestMessages.current = messages;
@@ -800,6 +818,7 @@ function GemieConversationView({
800
818
  onRegenerate={composer.regenerate}
801
819
  onStartEdit={edit.start}
802
820
  newConversationOffer={newConversationOffer}
821
+ approvals={approvalCards}
803
822
  agentActivity={agentRun === null ? null : agentActivity}
804
823
  call={voice.isActive ? { agentState: voice.agentState } : undefined}
805
824
  empty={welcome}
@@ -1,4 +1,4 @@
1
- import { ButtonGroup, ButtonGroupItem } from '@oxy.so/bloom/button-group';
1
+ import { Button } from '@oxy.so/bloom/button';
2
2
  import {
3
3
  DropdownMenu,
4
4
  DropdownMenuContent,
@@ -63,14 +63,14 @@ export const GemieChatHeader = memo(function GemieChatHeader({
63
63
  leading={
64
64
  leading ??
65
65
  (onBack ? (
66
- <ButtonGroup accessibilityLabel={labels.chatActions}>
67
- <ButtonGroupItem
66
+ <Button.Group accessibilityLabel={labels.chatActions}>
67
+ <Button
68
68
  iconOnly
69
69
  leadingIcon={RiArrowLeftLine}
70
70
  accessibilityLabel={labels.back}
71
71
  onPress={onBack}
72
72
  />
73
- </ButtonGroup>
73
+ </Button.Group>
74
74
  ) : undefined)
75
75
  }
76
76
  title={
@@ -83,9 +83,9 @@ export const GemieChatHeader = memo(function GemieChatHeader({
83
83
  <>
84
84
  {trailing}
85
85
  {hasMessages ? (
86
- <ButtonGroup accessibilityLabel={labels.chatActions}>
86
+ <Button.Group accessibilityLabel={labels.chatActions}>
87
87
  {onShare ? (
88
- <ButtonGroupItem
88
+ <Button
89
89
  iconOnly
90
90
  leadingIcon={RiShare2Line}
91
91
  accessibilityLabel={labels.share}
@@ -94,11 +94,7 @@ export const GemieChatHeader = memo(function GemieChatHeader({
94
94
  ) : null}
95
95
  <DropdownMenu>
96
96
  <DropdownMenuTrigger asChild label={labels.more}>
97
- <ButtonGroupItem
98
- iconOnly
99
- leadingIcon={RiMoreFill}
100
- accessibilityLabel={labels.more}
101
- />
97
+ <Button iconOnly leadingIcon={RiMoreFill} accessibilityLabel={labels.more} />
102
98
  </DropdownMenuTrigger>
103
99
  <DropdownMenuContent align="end">
104
100
  {menu}
@@ -111,7 +107,7 @@ export const GemieChatHeader = memo(function GemieChatHeader({
111
107
  </DropdownMenuItem>
112
108
  </DropdownMenuContent>
113
109
  </DropdownMenu>
114
- </ButtonGroup>
110
+ </Button.Group>
115
111
  ) : null}
116
112
  </>
117
113
  }
@@ -1,4 +1,4 @@
1
- import { Item } from '@oxy.so/bloom/item';
1
+ import { ListItem } from '@oxy.so/bloom/list';
2
2
  import { Text } from '@oxy.so/bloom/typography';
3
3
  import { useMemo } from 'react';
4
4
  import { View } from 'react-native';
@@ -45,11 +45,10 @@ export function GemieRecentConversations({
45
45
  {recent.map((conversation) => {
46
46
  const title = conversation.title || labels.newChat;
47
47
  return (
48
- <Item
48
+ <ListItem
49
49
  key={conversation.id}
50
- density="compact"
51
- accessibilityRole="button"
52
- accessibilityLabel={title}
50
+ role="button"
51
+ label={title}
53
52
  onPress={() => onOpen(conversation.id)}
54
53
  title={<Text numberOfLines={1}>{title}</Text>}
55
54
  trailing={
@@ -9,7 +9,7 @@ import {
9
9
  } from '@oxy.so/bloom/admonition';
10
10
  import { Card, CardBody, CardHeader, CardTitle } from '@oxy.so/bloom/card';
11
11
  import { RiExternalLinkLine } from '@oxy.so/bloom/icons/RiExternalLinkLine';
12
- import { Item } from '@oxy.so/bloom/item';
12
+ import { ListItem } from '@oxy.so/bloom/list';
13
13
  import { Rating } from '@oxy.so/bloom/rating';
14
14
  import { Muted, Text } from '@oxy.so/bloom/typography';
15
15
  import { Image } from './Image';
@@ -17,7 +17,7 @@ import { Linking, View } from 'react-native';
17
17
 
18
18
  /**
19
19
  * The rich blocks a reply can carry (```compactlist, ```banner, …), drawn with
20
- * Bloom: a card per block, `Item` rows, `Admonition` for a banner and `Rating`
20
+ * Bloom: a card per block, `ListItem` rows, `Admonition` for a banner and `Rating`
21
21
  * for a source's credibility. `ReplyMarkdown.tsx` parses the fences.
22
22
  */
23
23
 
@@ -37,11 +37,11 @@ export function CompactList({ title, items }: { title: string; items: CompactLis
37
37
  <CardBody>
38
38
  <View role="list">
39
39
  {items.map((item, index) => (
40
- <Item
40
+ <ListItem
41
41
  key={index}
42
42
  role="listitem"
43
43
  title={item.title}
44
- subtitle={item.meta}
44
+ supporting={item.meta}
45
45
  leading={
46
46
  item.image ? (
47
47
  <Image
@@ -151,12 +151,13 @@ export function Timeline({ title, items }: { title: string; items: TimelineItem[
151
151
  <CardBody>
152
152
  <View role="list">
153
153
  {items.map((item, index) => (
154
- <Item
154
+ <ListItem
155
155
  key={index}
156
156
  role="listitem"
157
157
  leading={<Muted>{item.date}</Muted>}
158
158
  title={item.title}
159
- subtitle={item.description}
159
+ supporting={item.description}
160
+ supportingLines="adaptive"
160
161
  />
161
162
  ))}
162
163
  </View>
@@ -9,13 +9,14 @@ import {
9
9
  import { EmptyState } from '@oxy.so/bloom/empty-state';
10
10
  import { RiFileTextLine } from '@oxy.so/bloom/icons/RiFileTextLine';
11
11
  import { RiGlobalLine } from '@oxy.so/bloom/icons/RiGlobalLine';
12
- import { Item } from '@oxy.so/bloom/item';
12
+ import { ListItem } from '@oxy.so/bloom/list';
13
13
  import { useTheme } from '@oxy.so/bloom/theme';
14
14
  import { useState } from 'react';
15
+ import { View } from 'react-native';
15
16
 
16
17
  /**
17
18
  * "Files and sources": what a turn produced and what it read, as two Bloom
18
- * `Accordion` sections of `Item` rows.
19
+ * `Accordion` sections of `ListItem` rows.
19
20
  *
20
21
  * An output row is pressable only when the canvas holds its artifact to open;
21
22
  * otherwise it is a labelled row and says so to assistive tech. A name is
@@ -77,15 +78,16 @@ export function FilesAndSources({
77
78
  // button under it.
78
79
  const openable = outputActions?.canOpen(output) === true;
79
80
  return (
80
- <Item
81
+ <ListItem
81
82
  key={output.id}
82
83
  role="listitem"
83
- density="compact"
84
- leading={<RiFileTextLine size="md" fill={colors.textSecondary} />}
85
- title={output.name}
86
- accessibilityLabel={
87
- openable ? t('thought.openOutput', { name: output.name }) : output.name
84
+ leading={
85
+ <View pointerEvents="none">
86
+ <RiFileTextLine size="md" fill={colors.textSecondary} />
87
+ </View>
88
88
  }
89
+ title={output.name}
90
+ label={openable ? t('thought.openOutput', { name: output.name }) : output.name}
89
91
  onPress={openable ? () => outputActions?.open(output) : undefined}
90
92
  />
91
93
  );
@@ -101,14 +103,17 @@ export function FilesAndSources({
101
103
  <EmptyState variant="compact" description={t('thought.noSources')} />
102
104
  ) : (
103
105
  sources.map((source, index) => (
104
- <Item
106
+ <ListItem
105
107
  key={source.url}
106
108
  role="listitem"
107
- density="compact"
108
- leading={<RiGlobalLine size="sm" fill={colors.textSecondary} />}
109
+ leading={
110
+ <View pointerEvents="none">
111
+ <RiGlobalLine size="sm" fill={colors.textSecondary} />
112
+ </View>
113
+ }
109
114
  title={source.title}
110
- subtitle={source.domain}
111
- accessibilityLabel={t('thought.sourceLabel', { n: index + 1, title: source.title })}
115
+ supporting={source.domain}
116
+ label={t('thought.sourceLabel', { n: index + 1, title: source.title })}
112
117
  onPress={() => onOpenSource(source)}
113
118
  />
114
119
  ))
@@ -0,0 +1,114 @@
1
+ import { Notification } from '@oxy.so/bloom/notification';
2
+ import { Muted } from '@oxy.so/bloom/typography';
3
+ import React, { useCallback, useState } from 'react';
4
+ import { View } from 'react-native';
5
+ import { useLabels } from '../../lib/labels';
6
+ import {
7
+ ApprovalExpiredError,
8
+ type ApprovalDecision,
9
+ type ApprovalEntry,
10
+ type ApprovalOutcome,
11
+ } from '../../runtime/approvals';
12
+
13
+ export interface ApprovalsProps {
14
+ readonly entries: readonly ApprovalEntry[];
15
+ /** Who is asking: the agent's name, as the thread names it. */
16
+ readonly agentName: string;
17
+ /**
18
+ * Carries the person's answer to Gemies. Rejects with `ApprovalExpiredError` when the question is
19
+ * no longer open. Omitted, a question is shown with no way to answer it.
20
+ */
21
+ readonly onDecide?: (entry: ApprovalEntry, decision: ApprovalDecision) => Promise<void>;
22
+ /** The answer is known here (the person's own, or the question closed): show it now. */
23
+ readonly onSettled: (requestId: string, outcome: ApprovalOutcome) => void;
24
+ }
25
+
26
+ /**
27
+ * A coding CLI asking its own user for permission to run something on their computer, in the
28
+ * conversation (Gemies ADR 0043 §5): who is asking, what for, and the two answers. The CLI waits
29
+ * for the person; once answered the card shrinks to one line saying how it ended.
30
+ *
31
+ * This is the CLI's prompt to the person who runs it, not a permission Gemies or Oxy asks for.
32
+ */
33
+ export const ApprovalCards = React.memo(function ApprovalCards({
34
+ entries,
35
+ agentName,
36
+ onDecide,
37
+ onSettled,
38
+ }: ApprovalsProps) {
39
+ return (
40
+ <>
41
+ {entries.map((entry) => (
42
+ <ApprovalCard
43
+ key={entry.requestId}
44
+ entry={entry}
45
+ agentName={agentName}
46
+ onDecide={onDecide}
47
+ onSettled={onSettled}
48
+ />
49
+ ))}
50
+ </>
51
+ );
52
+ });
53
+
54
+ function ApprovalCard({
55
+ entry,
56
+ agentName,
57
+ onDecide,
58
+ onSettled,
59
+ }: {
60
+ entry: ApprovalEntry;
61
+ agentName: string;
62
+ onDecide: ApprovalsProps['onDecide'];
63
+ onSettled: ApprovalsProps['onSettled'];
64
+ }) {
65
+ const { t } = useLabels();
66
+ const [sending, setSending] = useState(false);
67
+ const [failed, setFailed] = useState(false);
68
+
69
+ const decide = useCallback(
70
+ (decision: ApprovalDecision) => {
71
+ if (sending || !onDecide) return;
72
+ setSending(true);
73
+ setFailed(false);
74
+ onDecide(entry, decision).then(
75
+ () => onSettled(entry.requestId, decision),
76
+ (error: unknown) => {
77
+ setSending(false);
78
+ if (error instanceof ApprovalExpiredError) onSettled(entry.requestId, 'expired');
79
+ else setFailed(true);
80
+ },
81
+ );
82
+ },
83
+ [sending, onDecide, entry, onSettled],
84
+ );
85
+
86
+ if (entry.outcome !== 'pending') {
87
+ return (
88
+ <View className="px-4 py-1" accessibilityRole="text">
89
+ <Muted>{t(`chat.approval.resolved.${entry.outcome}`, { tool: entry.tool })}</Muted>
90
+ </View>
91
+ );
92
+ }
93
+
94
+ const description = [entry.summary, failed ? t('chat.approval.sendFailed') : undefined]
95
+ .filter(Boolean)
96
+ .join('\n');
97
+ return (
98
+ <Notification
99
+ status="warning"
100
+ title={t('chat.approval.title', { agent: agentName, tool: entry.tool })}
101
+ description={description === '' ? undefined : description}
102
+ // While an answer is on its way there is nothing to press: a second tap must not send another.
103
+ actions={
104
+ onDecide && !sending
105
+ ? [
106
+ { label: t('chat.approval.deny'), onPress: () => decide('deny') },
107
+ { label: t('chat.approval.allow'), onPress: () => decide('allow') },
108
+ ]
109
+ : undefined
110
+ }
111
+ dismissible={false}
112
+ />
113
+ );
114
+ }
@@ -1,10 +1,11 @@
1
- import { AgentStack } from '@oxy.so/bloom/agent-reply';
1
+ import { AvatarGroup } from '@oxy.so/bloom/avatar-group';
2
2
  import { AiChatMessageLine } from '@oxy.so/bloom/ai-chat';
3
3
  import { Card } from '@oxy.so/bloom/card';
4
4
  import { TypingDots } from '@oxy.so/bloom/chat-indicators';
5
5
  import { RiArrowRightSLine } from '@oxy.so/bloom/icons/RiArrowRightSLine';
6
- import { Item } from '@oxy.so/bloom/item';
6
+ import { ListItem } from '@oxy.so/bloom/list';
7
7
  import { useRef, useState } from 'react';
8
+ import { View } from 'react-native';
8
9
  import { useOpenGemieConversation } from '../../lib/gemie-conversation-opener';
9
10
  import { useLabels } from '../../lib/labels';
10
11
  import { agentCharacterOf } from '../../lib/participants';
@@ -90,26 +91,31 @@ export function GemieConversationCard({
90
91
  return (
91
92
  <AiChatMessageLine block>
92
93
  <Card>
93
- <Item
94
+ <ListItem
94
95
  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
- />
96
+ <View pointerEvents="none">
97
+ <AvatarGroup
98
+ layout="conversation"
99
+ motion="always"
100
+ size={STACK_SIZE}
101
+ items={[from, to].map((agent) => ({
102
+ id: agent.id,
103
+ name: agent.name,
104
+ kind: 'bot' as const,
105
+ character: agentCharacterOf(agent),
106
+ }))}
107
+ />
108
+ </View>
103
109
  }
104
110
  title={title}
105
- subtitle={subtitle}
111
+ supporting={subtitle}
106
112
  // The last thing said is a glimpse; the whole of it is one press away.
107
- subtitleNumberOfLines={1}
113
+ supportingLines={1}
108
114
  trailing={talking ? <TypingDots /> : pressable ? <RiArrowRightSLine size="sm" /> : null}
109
115
  {...(pressable
110
116
  ? {
111
- accessibilityRole: 'button' as const,
112
- accessibilityLabel: `${title}. ${t('chat.gemiesOpen')}`,
117
+ role: 'button' as const,
118
+ label: `${title}. ${t('chat.gemiesOpen')}`,
113
119
  onPress: () => open(conversationId),
114
120
  }
115
121
  : {})}
@@ -32,6 +32,7 @@ import type { ThreadHistory } from '../../runtime/thread/thread-history';
32
32
  import type { AgentState } from '../../types';
33
33
  import { AgentResultCard } from './AgentResultCard';
34
34
  import { AgentTaskCard } from './AgentTaskCard';
35
+ import { type ApprovalsProps, ApprovalCards } from './ApprovalCard';
35
36
  import { NewConversationOffer } from './NewConversationOffer';
36
37
  import { type ThreadActions, ThreadRow } from './ThreadRow';
37
38
 
@@ -81,6 +82,11 @@ export interface GemieThreadProps {
81
82
  /** Load one of this conversation's questions into the composer to rewrite it. */
82
83
  onStartEdit?: (userMessageId: string) => void;
83
84
  newConversationOffer?: NewConversationOfferProps;
85
+ /**
86
+ * A coding CLI asking its own user for permission to run something on their computer, while the
87
+ * turn waits (ADR 0043 §5). Drawn after the turns, where the person is looking.
88
+ */
89
+ approvals?: ApprovalsProps;
84
90
  /** The run an agent is on for this conversation: in progress, or the card it leaves. */
85
91
  agentActivity?: AgentActivityState | null;
86
92
  /**
@@ -136,6 +142,7 @@ export const GemieThread = memo(function GemieThread({
136
142
  onRegenerate,
137
143
  onStartEdit,
138
144
  newConversationOffer,
145
+ approvals,
139
146
  agentActivity,
140
147
  call,
141
148
  empty,
@@ -375,6 +382,10 @@ export const GemieThread = memo(function GemieThread({
375
382
  )
376
383
  ) : null}
377
384
 
385
+ {approvals === undefined || approvals.entries.length === 0 ? null : (
386
+ <ApprovalCards {...approvals} />
387
+ )}
388
+
378
389
  {/* The agent's offer to start the next stretch fresh. Last in the list on purpose: it
379
390
  must not cover what is being read, and ignoring it has to leave the thread exactly as
380
391
  it was. */}
@@ -5,7 +5,7 @@ import { useLabels } from '../../lib/labels';
5
5
  import { Button } from '@oxy.so/bloom/button';
6
6
  import { Card, CardBody } from '@oxy.so/bloom/card';
7
7
  import { RiCloseLine } from '@oxy.so/bloom/icons/RiCloseLine';
8
- import { Item } from '@oxy.so/bloom/item';
8
+ import { ListItem } from '@oxy.so/bloom/list';
9
9
  import { Search } from '@oxy.so/bloom/search';
10
10
  import { Muted } from '@oxy.so/bloom/typography';
11
11
  import { useState } from 'react';
@@ -24,7 +24,7 @@ import { ScrollView, View } from 'react-native';
24
24
  * can read and not reach is a wall, so `onJump` is not an extra: it is what the
25
25
  * hit is for.
26
26
  *
27
- * Bloom's `Search` for the field and an `Item` per hit, on a `Card` floating
27
+ * Bloom's `Search` for the field and a `ListItem` per hit, on a `Card` floating
28
28
  * over the top of the thread in its 768 column: the card is the surface, so
29
29
  * nothing here paints one of its own.
30
30
  */
@@ -109,12 +109,12 @@ export const ThreadSearch = ({ thread, onJump, onClose }: ThreadSearchProps) =>
109
109
  keyboardShouldPersistTaps="handled"
110
110
  >
111
111
  {found.map((hit) => (
112
- <Item
112
+ <ListItem
113
113
  // The cursor, never `messageId`: a message the server wrote
114
114
  // has no client id, and `null` is not a key.
115
115
  key={hit.cursor}
116
116
  title={hit.snippet}
117
- subtitle={`${t(
117
+ supporting={`${t(
118
118
  hit.role === 'user' ? 'chat.searchThreadYou' : 'chat.searchThreadAgent',
119
119
  )} · ${hitDay(hit.createdAt, locale)}`}
120
120
  onPress={() => onJump(hit)}
@@ -85,6 +85,13 @@ export const COPY_EN: Readonly<Record<string, CopyEntry>> = {
85
85
  'chat.edit': 'Edit',
86
86
  'chat.feedbackFailed': "Your feedback couldn't be saved.",
87
87
  'chat.like': 'Like',
88
+ 'chat.approval.allow': 'Allow',
89
+ 'chat.approval.deny': 'Deny',
90
+ 'chat.approval.resolved.allow': '%{tool}: allowed',
91
+ 'chat.approval.resolved.deny': '%{tool}: denied',
92
+ 'chat.approval.resolved.expired': '%{tool}: timed out',
93
+ 'chat.approval.sendFailed': "Your answer couldn't be sent. Try again.",
94
+ 'chat.approval.title': '%{agent} wants to run %{tool}',
88
95
  'chat.newConversationAccept': 'Start a new one',
89
96
  'chat.newConversationDismiss': 'Not now',
90
97
  'chat.newConversationOffer': 'Start a new conversation?',
@@ -81,6 +81,13 @@ export const COPY_ES: Readonly<Record<string, CopyEntry>> = {
81
81
  'chat.edit': 'Editar',
82
82
  'chat.feedbackFailed': 'No se ha podido guardar tu opinión.',
83
83
  'chat.like': 'Me gusta',
84
+ 'chat.approval.allow': 'Permitir',
85
+ 'chat.approval.deny': 'Denegar',
86
+ 'chat.approval.resolved.allow': '%{tool}: permitido',
87
+ 'chat.approval.resolved.deny': '%{tool}: denegado',
88
+ 'chat.approval.resolved.expired': '%{tool}: sin respuesta a tiempo',
89
+ 'chat.approval.sendFailed': 'No se pudo enviar tu respuesta. Inténtalo de nuevo.',
90
+ 'chat.approval.title': '%{agent} quiere ejecutar %{tool}',
84
91
  'chat.newConversationAccept': 'Empezar una nueva',
85
92
  'chat.newConversationDismiss': 'Ahora no',
86
93
  'chat.newConversationOffer': '¿Empezar una conversación nueva?',
@@ -0,0 +1,99 @@
1
+ /**
2
+ * A coding CLI asking its own user for permission, in the conversation (Gemies ADR 0043 §5).
3
+ *
4
+ * During a turn with an external agent (Claude Code on the person's computer), the CLI may stop and
5
+ * ask whether it can run something there. The turn waits; the stream carries two named events:
6
+ *
7
+ * `alia.cli_permission_request` the CLI asks: which tool, on what.
8
+ * `alia.cli_permission_resolved` the answer was given, or the time ran out.
9
+ *
10
+ * This is the third-party CLI's prompt to the person who runs it, on their own machine. It is not
11
+ * an Oxy grant: nothing here reaches Oxy, and the SDK does not know the endpoint that carries the
12
+ * answer — the host does (`GemieRuntimeHost.onApprovalDecision`).
13
+ */
14
+
15
+ export type ApprovalDecision = 'allow' | 'deny';
16
+ export type ApprovalOutcome = ApprovalDecision | 'expired';
17
+
18
+ export interface ApprovalRequest {
19
+ readonly requestId: string;
20
+ readonly agentId: string;
21
+ /** The CLI's tool: `Bash`, `Edit`, … */
22
+ readonly tool: string;
23
+ /** What it would act on (a command, a path), as the daemon reported it. */
24
+ readonly summary?: string;
25
+ /** ISO time after which the CLI is told no. */
26
+ readonly expiresAt: string;
27
+ }
28
+
29
+ /** A request and where it stands: waiting for the person, or how it ended. */
30
+ export interface ApprovalEntry extends ApprovalRequest {
31
+ readonly outcome: 'pending' | ApprovalOutcome;
32
+ }
33
+
34
+ const text = (value: unknown, max: number): string | undefined =>
35
+ typeof value === 'string' && value !== '' ? value.slice(0, max) : undefined;
36
+
37
+ /** The request in an `alia.cli_permission_request` frame, or `null` when the frame is not one. */
38
+ export function parseApprovalRequest(data: unknown): ApprovalRequest | null {
39
+ if (data === null || typeof data !== 'object') return null;
40
+ const d = data as Record<string, unknown>;
41
+ const requestId = text(d.requestId, 100);
42
+ const agentId = text(d.agentId, 100);
43
+ const tool = text(d.tool, 80);
44
+ const expiresAt = text(d.expiresAt, 40);
45
+ if (!requestId || !agentId || !tool || !expiresAt || Number.isNaN(Date.parse(expiresAt))) {
46
+ return null;
47
+ }
48
+ const summary = text(d.summary, 200);
49
+ return { requestId, agentId, tool, ...(summary ? { summary } : {}), expiresAt };
50
+ }
51
+
52
+ /** The answer in an `alia.cli_permission_resolved` frame, or `null` when the frame is not one. */
53
+ export function parseApprovalResolved(
54
+ data: unknown,
55
+ ): { requestId: string; outcome: ApprovalOutcome } | null {
56
+ if (data === null || typeof data !== 'object') return null;
57
+ const d = data as Record<string, unknown>;
58
+ const requestId = text(d.requestId, 100);
59
+ if (!requestId) return null;
60
+ const decision = d.decision;
61
+ if (decision !== 'allow' && decision !== 'deny' && decision !== 'expired') return null;
62
+ return { requestId, outcome: decision };
63
+ }
64
+
65
+ /** A request arrived: waiting, once. A repeat of one already here changes nothing. */
66
+ export function withApprovalRequest(
67
+ list: readonly ApprovalEntry[],
68
+ request: ApprovalRequest,
69
+ ): ApprovalEntry[] {
70
+ if (list.some((entry) => entry.requestId === request.requestId)) return [...list];
71
+ return [...list, { ...request, outcome: 'pending' }];
72
+ }
73
+
74
+ /** A request was answered. The first answer stands; an unknown request is ignored. */
75
+ export function withApprovalOutcome(
76
+ list: readonly ApprovalEntry[],
77
+ requestId: string,
78
+ outcome: ApprovalOutcome,
79
+ ): ApprovalEntry[] {
80
+ return list.map((entry) =>
81
+ entry.requestId === requestId && entry.outcome === 'pending' ? { ...entry, outcome } : entry,
82
+ );
83
+ }
84
+
85
+ /**
86
+ * What a host's `onApprovalDecision` rejects with when the question is no longer open (answered
87
+ * elsewhere, or its time ran out): the card then reads "Timed out" instead of offering a retry.
88
+ */
89
+ export class ApprovalExpiredError extends Error {
90
+ constructor() {
91
+ super('The approval request is no longer open');
92
+ this.name = 'ApprovalExpiredError';
93
+ }
94
+ }
95
+
96
+ /** What a new turn keeps of the last one's approvals: the ones still waiting. */
97
+ export function stillPending(list: readonly ApprovalEntry[]): ApprovalEntry[] {
98
+ return list.filter((entry) => entry.outcome === 'pending');
99
+ }
@@ -104,6 +104,16 @@ export interface GemieRuntimeHost {
104
104
  onFeatureLocked?: (key: string) => void;
105
105
  /** A delegated agent started a run of its own for this turn. */
106
106
  onAgentTurn?: (turn: AgentRun & { conversationId: string | null }) => void;
107
+ /**
108
+ * The person answered a coding CLI that asked for permission to run something on their own
109
+ * computer (`alia.cli_permission_request`, ADR 0043). The host carries the answer to Gemies; the
110
+ * promise rejects when it could not be sent. Omitted, the request is shown with no way to answer.
111
+ */
112
+ onApprovalDecision?: (
113
+ requestId: string,
114
+ agentId: string,
115
+ decision: 'allow' | 'deny',
116
+ ) => Promise<void>;
107
117
  /** The agent's row in the host's list, ahead of the server: your line, then her answer. */
108
118
  onTurnPreview?: (agentId: string | null | undefined, text: string) => void;
109
119
  /**
@@ -12,6 +12,8 @@
12
12
  */
13
13
 
14
14
  export { GemieRuntimeProvider, useGemieRuntime } from './config';
15
+ export { ApprovalExpiredError } from './approvals';
16
+ export type { ApprovalDecision, ApprovalEntry, ApprovalRequest } from './approvals';
15
17
  export type {
16
18
  GemieArtifact,
17
19
  GemieRuntimeConfig,
@@ -28,6 +28,15 @@ import {
28
28
  import { createRandomUuid } from './random-uuid';
29
29
  import { createChatTurnControl } from './chat-turn-control';
30
30
  import { awaitTurnPreparation } from './turn-preparation';
31
+ import {
32
+ type ApprovalEntry,
33
+ type ApprovalOutcome,
34
+ parseApprovalRequest,
35
+ parseApprovalResolved,
36
+ stillPending,
37
+ withApprovalOutcome,
38
+ withApprovalRequest,
39
+ } from './approvals';
31
40
  import { type GemieHostTools, HostOutcomeQueue, hostRequest } from './host-tools';
32
41
  import { API_ROUTES } from './routes';
33
42
  import { createSseFrameReader } from './sse-frame-reader';
@@ -243,6 +252,11 @@ export function useConversationStream({
243
252
  * was.
244
253
  */
245
254
  const [suggestedNewConversation, setSuggestedNewConversation] = useState<string | null>(null);
255
+ /**
256
+ * A coding CLI's questions to its own user, this turn's and any still waiting (`approvals.ts`).
257
+ * Held beside the messages, not in them: a question is not part of what was said.
258
+ */
259
+ const [approvals, setApprovals] = useState<ApprovalEntry[]>([]);
246
260
  /** The run a delegated agent started for this conversation (`alia.agent_turn`), or `null`. */
247
261
  const [agentRun, setAgentRun] = useState<AgentRun | null>(null);
248
262
  /**
@@ -375,6 +389,7 @@ export function useConversationStream({
375
389
  const conversationRef = useRef(conversationId);
376
390
  useEffect(() => {
377
391
  setFailedTurn(null);
392
+ setApprovals([]);
378
393
  retryRef.current = null;
379
394
  turnOptionsRef.current.clear();
380
395
  // Outcomes answer this conversation's calls. The first turn of a new chat gives it its id,
@@ -424,6 +439,7 @@ export function useConversationStream({
424
439
  setConversationTitle(null);
425
440
  setSuggestedNewConversation(null);
426
441
  setAgentRun(null);
442
+ setApprovals([]);
427
443
  setFailedTurn(null);
428
444
  retryRef.current = null;
429
445
  turnOptionsRef.current.clear();
@@ -438,6 +454,8 @@ export function useConversationStream({
438
454
  // A new send answers the old failure, whether it is the retry or a fresh
439
455
  // message: either way the card comes down.
440
456
  setFailedTurn(null);
457
+ // The last turn's answered questions are history; one still waiting stays.
458
+ setApprovals(stillPending);
441
459
  retryRef.current = null;
442
460
 
443
461
  // Everything the send is about to change, so a turn that produces no real
@@ -1204,6 +1222,20 @@ export function useConversationStream({
1204
1222
  );
1205
1223
  continue;
1206
1224
  }
1225
+ case 'alia.cli_permission_request': {
1226
+ const request = parseApprovalRequest(parsed);
1227
+ if (request) setApprovals((prev) => withApprovalRequest(prev, request));
1228
+ continue;
1229
+ }
1230
+ case 'alia.cli_permission_resolved': {
1231
+ const resolved = parseApprovalResolved(parsed);
1232
+ if (resolved) {
1233
+ setApprovals((prev) =>
1234
+ withApprovalOutcome(prev, resolved.requestId, resolved.outcome),
1235
+ );
1236
+ }
1237
+ continue;
1238
+ }
1207
1239
  case 'alia.agent_turn': {
1208
1240
  if (parsed.turnId) {
1209
1241
  const run = {
@@ -1675,6 +1707,11 @@ export function useConversationStream({
1675
1707
  if (!isLoading) setComposerPhase('idle');
1676
1708
  }, [isLoading, setComposerPhase]);
1677
1709
 
1710
+ /** The person's own answer, shown at once; the stream's `alia.cli_permission_resolved` repeats it. */
1711
+ const settleApproval = useCallback((requestId: string, outcome: ApprovalOutcome) => {
1712
+ setApprovals((prev) => withApprovalOutcome(prev, requestId, outcome));
1713
+ }, []);
1714
+
1678
1715
  /** Put the offer away. It wrote nothing, so there is nothing else to undo. */
1679
1716
  const dismissSuggestedNewConversation = useCallback(() => {
1680
1717
  setSuggestedNewConversation(null);
@@ -1700,6 +1737,8 @@ export function useConversationStream({
1700
1737
  suggestedNewConversation,
1701
1738
  dismissSuggestedNewConversation,
1702
1739
  agentRun,
1740
+ approvals,
1741
+ settleApproval,
1703
1742
  failedTurn,
1704
1743
  retryFailedTurn,
1705
1744
  clearFailedTurn,
@@ -157,6 +157,8 @@ export function useConversationThread({
157
157
  suggestedNewConversation,
158
158
  dismissSuggestedNewConversation,
159
159
  agentRun,
160
+ approvals,
161
+ settleApproval,
160
162
  failedTurn,
161
163
  retryFailedTurn: retry,
162
164
  clearFailedTurn,
@@ -624,6 +626,8 @@ export function useConversationThread({
624
626
  suggestedNewConversation,
625
627
  dismissSuggestedNewConversation,
626
628
  agentRun,
629
+ approvals,
630
+ settleApproval,
627
631
  failedTurn,
628
632
  retryFailedTurn,
629
633
  };