@gemies/sdk 3.2.0 → 3.3.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,22 @@
1
1
  # @gemies/sdk
2
2
 
3
+ ## 3.3.0
4
+
5
+ - **New: `@gemies/sdk/connectors`**, the connectors a person connects — providers' own remote MCP
6
+ servers (Notion, Linear, Slack…) and their own MCP servers by URL — drawn the same in the Gemies
7
+ and the Alia apps:
8
+ - `GemieConnectorsStore`: the store, with search, categories, each connector's real logo, Connect
9
+ (or Add account, for a further account of the same connector) and Add a custom MCP server.
10
+ - `GemieConnectedConnectors`: Settings › Connected, only what the person connected, each account
11
+ with its state, the gemies that may use it, Reconnect, Rename and Disconnect.
12
+ - `ConnectorLogo`: the one logo every screen draws for a connector, loaded only from the API's
13
+ origin, with a monogram when there is none.
14
+ - `useConnectorCatalogue`, `useConnections`, `useConnectorActions`, `useWebSignInReturn`,
15
+ `connectionOfTool`. A web sign-in returns to `/connectors`; a native one finishes in the auth
16
+ session on the app's scheme (`nativeScheme`).
17
+ - **A connector's tool step in the thought panel shows that connector's logo**
18
+ (`mcp_<account>__<tool>`); the connections are read only for a turn that used one.
19
+
3
20
  ## 3.2.0
4
21
 
5
22
  - **Telegram is Telegram Business (Gemies ADR 0037).** `GemieAccounts` links a person's Telegram
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gemies/sdk",
3
- "version": "3.2.0",
3
+ "version": "3.3.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",
@@ -14,6 +14,7 @@
14
14
  "./ask/text": "./src/ask-text.ts",
15
15
  "./avatar": "./src/avatar.ts",
16
16
  "./character": "./src/character.ts",
17
+ "./connectors": "./src/connectors.ts",
17
18
  "./content": "./src/lib/content-utils.ts",
18
19
  "./csp": "./src/csp.ts",
19
20
  "./dictation": "./src/dictation.ts",
@@ -0,0 +1,61 @@
1
+ import { Text } from '@oxy.so/bloom/typography';
2
+ import { useState } from 'react';
3
+ import { View } from 'react-native';
4
+ import { useConnectorLogoUrl } from '../../runtime/connectors';
5
+ import { Image } from '../Image';
6
+
7
+ export interface ConnectorLogoProps {
8
+ /** The connector's name, for the monogram and for screen readers. */
9
+ name: string;
10
+ /** The logo path the API answered (`/mcp/logos/<id>`), or `null`. */
11
+ logoUrl: string | null | undefined;
12
+ /** Its side, in points. */
13
+ size?: number;
14
+ }
15
+
16
+ /**
17
+ * A connector's logo, wherever a connector appears: the store, Settings, a gemie's editor and a
18
+ * tool call in the chat. The image is always one the API stores and serves from its own origin
19
+ * (`lib/connector-logos.ts`): the server's own MCP icon, its MCP Registry icon or its provider's
20
+ * brand mark. Without one, or when it does not load, a monogram — never a broken image.
21
+ */
22
+ export function ConnectorLogo({ name, logoUrl, size = 40 }: ConnectorLogoProps) {
23
+ const src = useConnectorLogoUrl(logoUrl);
24
+ const [failed, setFailed] = useState(false);
25
+ const radius = Math.round(size * 0.22);
26
+
27
+ if (!src || failed) {
28
+ const letter = name.trim().charAt(0).toUpperCase() || '·';
29
+ return (
30
+ <View
31
+ accessibilityRole="image"
32
+ accessibilityLabel={name}
33
+ className="items-center justify-center bg-background-tertiary-default"
34
+ style={{ width: size, height: size, borderRadius: radius }}
35
+ >
36
+ <Text
37
+ variant="body-medium"
38
+ className="text-text-secondary"
39
+ style={{ fontSize: Math.round(size * 0.45), lineHeight: Math.round(size * 0.6) }}
40
+ >
41
+ {letter}
42
+ </Text>
43
+ </View>
44
+ );
45
+ }
46
+
47
+ return (
48
+ <View
49
+ className="overflow-hidden border border-border bg-white"
50
+ style={{ width: size, height: size, borderRadius: radius }}
51
+ >
52
+ <Image
53
+ source={{ uri: src }}
54
+ accessibilityLabel={name}
55
+ contentFit="contain"
56
+ style={{ width: size, height: size }}
57
+ onError={() => setFailed(true)}
58
+ />
59
+ </View>
60
+ );
61
+ }
@@ -0,0 +1,309 @@
1
+ import { Badge } from '@oxy.so/bloom/badge';
2
+ import { Button } from '@oxy.so/bloom/button';
3
+ import { Dialog } from '@oxy.so/bloom/dialog';
4
+ import { EmptyState } from '@oxy.so/bloom/empty-state';
5
+ import { RiPlugLine } from '@oxy.so/bloom/icons/RiPlugLine';
6
+ import * as Skeleton from '@oxy.so/bloom/skeleton';
7
+ import { confirm } from '@oxy.so/bloom/surfaces';
8
+ import { TextFieldInput, TextFieldLabel } from '@oxy.so/bloom/text-field';
9
+ import { toast } from '@oxy.so/bloom/toast';
10
+ import { Text } from '@oxy.so/bloom/typography';
11
+ import { useState } from 'react';
12
+ import { View } from 'react-native';
13
+ import { englishCopy, type Translate } from '../../lib/copy';
14
+ import {
15
+ type Connection,
16
+ connectorReturnTo,
17
+ useConnections,
18
+ useConnectorActions,
19
+ } from '../../runtime/connectors';
20
+ import { ConnectorLogo } from './ConnectorLogo';
21
+
22
+ /** This component's own strings. */
23
+ const K = 'gemie.connectors';
24
+
25
+ export interface GemieConnectedConnectorsProps {
26
+ /**
27
+ * The native app's URL scheme (`gemies`, `alia`): a provider's sign-in returns to the store at
28
+ * `<scheme>://connectors`, and on the web to the store's page (`connectorReturnTo`).
29
+ */
30
+ nativeScheme: string;
31
+ /** Opens the store, from the header and from the empty list. */
32
+ onBrowse: () => void;
33
+ /** The host's translator; English without one. */
34
+ t?: Translate;
35
+ }
36
+
37
+ const STATUS_COLOR = { running: 'success', error: 'error', installed: 'warning' } as const;
38
+
39
+ /**
40
+ * What the person connected, for Settings: every account on its own, with its logo, which account
41
+ * of the provider it is, its state, which gemies may use it, and how to reconnect, rename or
42
+ * disconnect it. Nothing they have not connected is listed here; the store is a tap away.
43
+ */
44
+ export function GemieConnectedConnectors({
45
+ nativeScheme,
46
+ onBrowse,
47
+ t = englishCopy,
48
+ }: GemieConnectedConnectorsProps) {
49
+ const connections = useConnections();
50
+ const actions = useConnectorActions({ returnTo: connectorReturnTo(nativeScheme) });
51
+ const [pending, setPending] = useState<string | null>(null);
52
+ const [renaming, setRenaming] = useState<Connection | null>(null);
53
+
54
+ const reconnect = async (connection: Connection) => {
55
+ setPending(connection._id);
56
+ try {
57
+ const done = await actions.reconnect.mutateAsync(connection._id);
58
+ if (done?.status === 'running') {
59
+ toast.success(t(`${K}.reconnected`, { name: connection.displayName }));
60
+ }
61
+ } catch {
62
+ toast.error(t(`${K}.reconnectFailed`, { name: connection.displayName }));
63
+ } finally {
64
+ setPending(null);
65
+ }
66
+ };
67
+
68
+ const disconnect = async (connection: Connection) => {
69
+ const name = label(connection);
70
+ const ok = await confirm({
71
+ title: t(`${K}.disconnectTitle`, { name }),
72
+ description: t(`${K}.disconnectDescription`, { name: connection.displayName }),
73
+ confirmLabel: t(`${K}.disconnect`),
74
+ cancelLabel: t(`${K}.cancel`),
75
+ destructive: true,
76
+ });
77
+ if (!ok) return;
78
+ setPending(connection._id);
79
+ try {
80
+ await actions.disconnect.mutateAsync(connection._id);
81
+ toast.success(t(`${K}.disconnected`, { name }));
82
+ } catch {
83
+ toast.error(t(`${K}.disconnectFailed`));
84
+ } finally {
85
+ setPending(null);
86
+ }
87
+ };
88
+
89
+ if (connections.isPending) return <ConnectedSkeleton />;
90
+
91
+ if (connections.isError) {
92
+ return (
93
+ <View className="items-start gap-2 py-2.5">
94
+ <Text variant="body-2-regular" className="text-text-secondary">
95
+ {t(`${K}.connected.loadFailed`)}
96
+ </Text>
97
+ <Button size="sm" appearance="outline" tone="neutral" onPress={() => connections.refetch()}>
98
+ {t(`${K}.store.retry`)}
99
+ </Button>
100
+ </View>
101
+ );
102
+ }
103
+
104
+ const rows = connections.data ?? [];
105
+ if (rows.length === 0) {
106
+ return (
107
+ <EmptyState
108
+ icon={RiPlugLine}
109
+ title={t(`${K}.connected.emptyTitle`)}
110
+ description={t(`${K}.connected.emptyDescription`)}
111
+ action={{ label: t(`${K}.connected.browse`), onPress: onBrowse }}
112
+ />
113
+ );
114
+ }
115
+
116
+ return (
117
+ <View className="gap-1">
118
+ <View className="flex-row items-center justify-between gap-3 pb-1">
119
+ <Text variant="body-2-regular" className="flex-1 text-text-secondary">
120
+ {t(`${K}.connected.description`)}
121
+ </Text>
122
+ <Button size="sm" appearance="outline" tone="neutral" onPress={onBrowse}>
123
+ {t(`${K}.connected.browse`)}
124
+ </Button>
125
+ </View>
126
+ {rows.map((connection, index) => (
127
+ <View
128
+ key={connection._id}
129
+ className={`gap-2 py-3 ${index === 0 ? '' : 'border-t border-border'}`}
130
+ >
131
+ <View className="flex-row items-center gap-3">
132
+ <ConnectorLogo name={connection.displayName} logoUrl={connection.logoUrl} size={36} />
133
+ <View className="flex-1 gap-0.5">
134
+ <Text variant="body-2-semibold" numberOfLines={1}>
135
+ {connection.displayName}
136
+ </Text>
137
+ <Text variant="body-2-regular" className="text-text-secondary" numberOfLines={1}>
138
+ {[
139
+ connection.accountLabel ??
140
+ (connection.source === 'custom' ? connection.config.url : null),
141
+ t(`${K}.toolCount`, { count: connection.tools.length }),
142
+ ]
143
+ .filter(Boolean)
144
+ .join(' · ')}
145
+ </Text>
146
+ </View>
147
+ <Badge
148
+ size="label-small"
149
+ variant="subtle"
150
+ color={STATUS_COLOR[connection.status]}
151
+ content={t(`${K}.status.${connection.status}`)}
152
+ />
153
+ </View>
154
+ {connection.status !== 'running' && connection.statusMessage ? (
155
+ <Text variant="body-2-regular" className="text-text-secondary">
156
+ {connection.statusMessage}
157
+ </Text>
158
+ ) : null}
159
+ {connection.usedBy.length > 0 ? (
160
+ <Text variant="body-2-regular" className="text-text-secondary">
161
+ {t(`${K}.usedBy`, { names: connection.usedBy.map((gemie) => gemie.name).join(', ') })}
162
+ </Text>
163
+ ) : null}
164
+ <View className="flex-row flex-wrap gap-2">
165
+ {connection.status !== 'running' ? (
166
+ <Button
167
+ size="sm"
168
+ appearance="solid"
169
+ tone="accent"
170
+ loading={pending === connection._id}
171
+ onPress={() => void reconnect(connection)}
172
+ >
173
+ {t(`${K}.reconnect`)}
174
+ </Button>
175
+ ) : null}
176
+ <Button
177
+ size="sm"
178
+ appearance="outline"
179
+ tone="neutral"
180
+ disabled={pending === connection._id}
181
+ onPress={() => setRenaming(connection)}
182
+ >
183
+ {t(`${K}.rename`)}
184
+ </Button>
185
+ {connection.status === 'running' ? (
186
+ <Button
187
+ size="sm"
188
+ appearance="outline"
189
+ tone="neutral"
190
+ disabled={pending === connection._id}
191
+ onPress={() => void reconnect(connection)}
192
+ >
193
+ {t(`${K}.reconnect`)}
194
+ </Button>
195
+ ) : null}
196
+ <Button
197
+ size="sm"
198
+ appearance="outline"
199
+ tone="neutral"
200
+ disabled={pending === connection._id}
201
+ onPress={() => void disconnect(connection)}
202
+ >
203
+ {t(`${K}.disconnect`)}
204
+ </Button>
205
+ </View>
206
+ </View>
207
+ ))}
208
+ <RenameDialog
209
+ connection={renaming}
210
+ onClose={() => setRenaming(null)}
211
+ onSave={async (accountLabel) => {
212
+ if (!renaming) return;
213
+ await actions.rename.mutateAsync({ id: renaming._id, accountLabel });
214
+ }}
215
+ t={t}
216
+ />
217
+ </View>
218
+ );
219
+ }
220
+
221
+ /** `Notion · ana@acme.com`: the connector, and which of the person's accounts. */
222
+ function label(connection: Connection): string {
223
+ return connection.accountLabel
224
+ ? `${connection.displayName} · ${connection.accountLabel}`
225
+ : connection.displayName;
226
+ }
227
+
228
+ function RenameDialog({
229
+ connection,
230
+ onClose,
231
+ onSave,
232
+ t,
233
+ }: {
234
+ connection: Connection | null;
235
+ onClose: () => void;
236
+ onSave: (accountLabel: string | null) => Promise<void>;
237
+ t: Translate;
238
+ }) {
239
+ const [value, setValue] = useState<string | null>(null);
240
+ const [saving, setSaving] = useState(false);
241
+ const current = value ?? connection?.accountLabel ?? '';
242
+
243
+ const close = () => {
244
+ setValue(null);
245
+ onClose();
246
+ };
247
+
248
+ const save = async () => {
249
+ setSaving(true);
250
+ try {
251
+ await onSave(current.trim() || null);
252
+ close();
253
+ } catch {
254
+ toast.error(t(`${K}.renameFailed`));
255
+ } finally {
256
+ setSaving(false);
257
+ }
258
+ };
259
+
260
+ return (
261
+ <Dialog
262
+ open={connection !== null}
263
+ onClose={close}
264
+ placement={{ base: 'bottom', md: 'center' }}
265
+ maxWidth={384}
266
+ title={t(`${K}.renameTitle`)}
267
+ description={t(`${K}.renameDescription`, { name: connection?.displayName ?? '' })}
268
+ actions={[
269
+ { label: t(`${K}.cancel`), color: 'cancel', disabled: saving },
270
+ {
271
+ label: t(`${K}.renameSave`),
272
+ onPress: save,
273
+ disabled: saving,
274
+ shouldCloseOnPress: false,
275
+ },
276
+ ]}
277
+ >
278
+ <View>
279
+ <TextFieldLabel>{t(`${K}.renameLabel`)}</TextFieldLabel>
280
+ <TextFieldInput
281
+ label={t(`${K}.renameLabel`)}
282
+ placeholder="ana@acme.com"
283
+ value={current}
284
+ onChangeText={setValue}
285
+ autoCapitalize="none"
286
+ />
287
+ </View>
288
+ </Dialog>
289
+ );
290
+ }
291
+
292
+ /** The list's shape while it is read: rows, never a spinner. */
293
+ function ConnectedSkeleton() {
294
+ return (
295
+ <Skeleton.Region>
296
+ <View className="gap-4 py-2.5">
297
+ {[0, 1].map((index) => (
298
+ <View key={index} className="flex-row items-center gap-3">
299
+ <Skeleton.Box width={36} height={36} borderRadius={8} />
300
+ <View className="flex-1 gap-1.5">
301
+ <Skeleton.Box width={140} height={14} />
302
+ <Skeleton.Box width={200} height={12} />
303
+ </View>
304
+ </View>
305
+ ))}
306
+ </View>
307
+ </Skeleton.Region>
308
+ );
309
+ }