@gemies/sdk 6.1.0 → 6.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,25 @@
1
1
  # @gemies/sdk
2
2
 
3
+ ## 6.3.0
4
+
5
+ - **A turn's attachments are drawn as media** (`TurnAttachments`, used by every user turn in the
6
+ thread). A file kept in Oxy Files is drawn from the URL Oxy answers the signed-in caller
7
+ (`useFileDownloadUrl`):
8
+ - a photo is a photo, and a channel's sticker a sticker (an animated one by its still);
9
+ - a voice note or audio is a voice message that plays, with its transcript;
10
+ - any other file is a file chip that opens it.
11
+
12
+ A photo sent inline stays the thumbnail it was. Media that arrived on a gemie's Telegram bot or a
13
+ connected account carries `kind`, `description`, `durationSeconds` and `transcript` on its `file`
14
+ part, so the app shows it as the person sent it, not as a line about it.
15
+
16
+ ## 6.2.0
17
+
18
+ - **The connectors store also lists Docker's MCP catalogue.** `ConnectorEntry.source` may be `docker`:
19
+ a remote server from Docker's reviewed catalogue (`github.com/docker/mcp-registry`) that the
20
+ official MCP Registry does not list, with the `verified` badge. The store's description
21
+ (`gemie.connectors.store.description`) names both catalogues.
22
+
3
23
  ## 6.1.0
4
24
 
5
25
  - **New: a person's folders, projects, pins and favourites are their account's**, the same on every
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gemies/sdk",
3
- "version": "6.1.0",
3
+ "version": "6.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",
@@ -22,7 +22,8 @@ import type { ReadAloudState } from '../../hooks/useReadAloud';
22
22
  import type { Vote } from '../../hooks/useMessageVote';
23
23
  import { readAgentCharacter } from '../../lib/agent-character';
24
24
  import { useBubbles } from '../../lib/bubbles';
25
- import { getImagesFromContent, messageText } from '../../lib/content-utils';
25
+ import { messageText } from '../../lib/content-utils';
26
+ import { hasAttachments, TurnAttachments } from './TurnAttachments';
26
27
  import { ANCHORS, useGemieFlights } from '../../lib/flights';
27
28
  import { useLabels } from '../../lib/labels';
28
29
  import { canvasResultOf } from '../../lib/canvas-result';
@@ -32,7 +33,6 @@ import { isWebInvocation, taskListLog, webSearchLog } from '../../lib/work-log';
32
33
  import { useGemieRuntime } from '../../runtime/config';
33
34
  import { type Message, cardOf, formatElapsed, getToolPillLabel } from '../../runtime/model';
34
35
  import type { OpenThought } from '../../hooks/useOpenThought';
35
- import { Image } from '../Image';
36
36
  import { PlanPreviewCard } from '../PlanPreviewCard';
37
37
  import { AskedQuestions } from '../QuestionCard';
38
38
  import { CanvasComponent } from '../canvas/CanvasComponent';
@@ -127,8 +127,8 @@ export const ThreadRow = memo(function ThreadRow({
127
127
  }: ThreadRowProps) {
128
128
  const { t } = useLabels();
129
129
  const text = messageText(message);
130
- const images = message.content ? getImagesFromContent(message.content) : [];
131
130
  const isReply = message.role === 'assistant';
131
+ const attached = !isReply && hasAttachments(message.content);
132
132
  const storedIn = message.unsaved === true ? undefined : conversationId;
133
133
  const hasText = text.length > 0;
134
134
 
@@ -161,7 +161,7 @@ export const ThreadRow = memo(function ThreadRow({
161
161
  const questionActions = [copyAction, editAction].filter(isPresent);
162
162
  return (
163
163
  <Animated.View onLayout={onLayout}>
164
- {text.length === 0 && images.length === 0 ? null : (
164
+ {text.length === 0 && !attached ? null : (
165
165
  // Bloom's user turn, with the breathing room above it the thread has always had.
166
166
  <View className="mt-2 w-full flex-col items-end">
167
167
  <TurnMenu actions={questionActions} label={t('chat.turnActions')}>
@@ -171,40 +171,23 @@ export const ThreadRow = memo(function ThreadRow({
171
171
  <ChatBubble side="user" menu={questionActions} onReply={onQuestionReply}>
172
172
  {(foreground) => (
173
173
  <>
174
- {images.length > 0 && (
175
- <View className="flex-row flex-wrap gap-2">
176
- {images.map((url) => (
177
- <View key={url} className="size-[120px] overflow-hidden rounded-xl">
178
- <Image
179
- source={{ uri: url }}
180
- className="h-full w-full"
181
- contentFit="cover"
182
- />
183
- </View>
184
- ))}
185
- </View>
186
- )}
187
- <Text variant="body-regular" selectable style={{ color: foreground }}>
188
- {text}
189
- </Text>
174
+ <TurnAttachments
175
+ content={message.content}
176
+ tone="outgoing"
177
+ onColor={foreground}
178
+ />
179
+ {text.length > 0 ? (
180
+ <Text variant="body-regular" selectable style={{ color: foreground }}>
181
+ {text}
182
+ </Text>
183
+ ) : null}
190
184
  </>
191
185
  )}
192
186
  </ChatBubble>
193
187
  ) : (
194
188
  <AiChatUserMessage animate={isNew} actions={questionActions}>
195
- {images.length > 0 && (
196
- <View className="flex-row flex-wrap gap-2">
197
- {images.map((url) => (
198
- <View key={url} className="size-[120px] overflow-hidden rounded-xl">
199
- <Image
200
- source={{ uri: url }}
201
- className="h-full w-full"
202
- contentFit="cover"
203
- />
204
- </View>
205
- ))}
206
- </View>
207
- )}
189
+ {/* Bloom's user turn sits on a neutral surface, not the accent. */}
190
+ <TurnAttachments content={message.content} tone="incoming" />
208
191
  {text}
209
192
  </AiChatUserMessage>
210
193
  )}
@@ -0,0 +1,202 @@
1
+ /**
2
+ * A turn's attachments, drawn as the thread draws every attachment: a photo sent inline, and a file
3
+ * kept in Oxy Files — attached in the app, or media that arrived on a channel (a gemie's Telegram
4
+ * bot, a connected account), which says what it was there.
5
+ *
6
+ * - An image is the photo, and a channel's sticker is a sticker (its still, for an animated one).
7
+ * - A voice note or audio is a voice message that plays, with its transcript under it.
8
+ * - Anything else is a file chip that opens the file.
9
+ *
10
+ * A file is private to its person: its URL is the one Oxy answers the signed-in caller
11
+ * (`useFileDownloadUrl`), never a public one. One component for every turn, so a channel's media
12
+ * and the app's own attachments are drawn the same way.
13
+ */
14
+
15
+ import {
16
+ FileMessage,
17
+ ImageMessage,
18
+ StickerMessage,
19
+ VoiceMessage,
20
+ } from '@oxy.so/bloom/message-media';
21
+ import { useFileDownloadUrl, useOxy } from '@oxy.so/services/ui/client';
22
+ import { useEffect, useMemo, useRef, useState } from 'react';
23
+ import { Linking, View } from 'react-native';
24
+ import { useLabels } from '../../lib/labels';
25
+ import { loadExpoAudio } from '../../lib/deferred/expo-audio';
26
+ import {
27
+ getAttachmentsFromContent,
28
+ type MessageContent,
29
+ type TurnAttachment,
30
+ } from '../../lib/content-utils';
31
+ import { Image } from '../Image';
32
+
33
+ type Tone = 'incoming' | 'outgoing';
34
+ /** The bubble's tone, and its own foreground when the app paints a custom bubble. */
35
+ interface Paint {
36
+ tone: Tone;
37
+ onColor?: string;
38
+ }
39
+ type FileAttachment = Extract<TurnAttachment, { type: 'file' }>;
40
+
41
+ /** A waveform for a voice note whose samples were never measured: steady, from its id. */
42
+ export function placeholderWaveform(seed: string, bars = 32): number[] {
43
+ let h = 0;
44
+ for (const char of seed) h = (Math.imul(h, 31) + char.charCodeAt(0)) | 0;
45
+ return Array.from({ length: bars }, (_, i) => {
46
+ h = (Math.imul(h ^ (h >>> 13), 0x5bd1e995) + i) | 0;
47
+ return 0.25 + ((h >>> 0) % 1000) / 1600;
48
+ });
49
+ }
50
+
51
+ function useFileUrl(fileId: string): string | null {
52
+ const { oxyServices } = useOxy();
53
+ return useFileDownloadUrl(oxyServices, fileId).url;
54
+ }
55
+
56
+ function StoredImage({ file, tone, onColor }: { file: FileAttachment } & Paint) {
57
+ const { t } = useLabels();
58
+ const url = useFileUrl(file.fileId);
59
+ if (file.kind === 'sticker') {
60
+ // A sticker IS its meaning: its words name it for a screen reader.
61
+ return url ? (
62
+ <StickerMessage
63
+ source={url}
64
+ tone={tone}
65
+ onColor={onColor}
66
+ size={128}
67
+ accessibilityLabel={file.description ?? t('chat.attachment.sticker')}
68
+ />
69
+ ) : (
70
+ <View className="size-32 rounded-xl bg-surface-secondary" />
71
+ );
72
+ }
73
+ return url ? (
74
+ <ImageMessage
75
+ source={url}
76
+ tone={tone}
77
+ onColor={onColor}
78
+ maxWidth={240}
79
+ maxHeight={280}
80
+ accessibilityLabel={file.description ?? t('chat.attachment.photo')}
81
+ onPress={() => void Linking.openURL(url)}
82
+ />
83
+ ) : (
84
+ <View className="h-40 w-60 rounded-2xl bg-surface-secondary" />
85
+ );
86
+ }
87
+
88
+ function StoredVoice({ file, tone, onColor }: { file: FileAttachment } & Paint) {
89
+ const { t } = useLabels();
90
+ const url = useFileUrl(file.fileId);
91
+ const samples = useMemo(() => placeholderWaveform(file.fileId), [file.fileId]);
92
+ const [playing, setPlaying] = useState(false);
93
+ const [position, setPosition] = useState(0);
94
+ const player = useRef<{ play(): void; pause(): void; remove(): void } | null>(null);
95
+ useEffect(() => () => player.current?.remove(), []);
96
+
97
+ const toggle = async () => {
98
+ if (!url) return;
99
+ if (player.current && playing) {
100
+ player.current.pause();
101
+ setPlaying(false);
102
+ return;
103
+ }
104
+ if (!player.current) {
105
+ const { createAudioPlayer } = await loadExpoAudio();
106
+ const created = createAudioPlayer({ uri: url });
107
+ created.addListener('playbackStatusUpdate', (status) => {
108
+ setPosition(status.currentTime);
109
+ if (status.didJustFinish) {
110
+ setPlaying(false);
111
+ setPosition(0);
112
+ created.seekTo(0);
113
+ }
114
+ });
115
+ player.current = created;
116
+ }
117
+ player.current.play();
118
+ setPlaying(true);
119
+ };
120
+
121
+ return (
122
+ <VoiceMessage
123
+ tone={tone}
124
+ onColor={onColor}
125
+ samples={samples}
126
+ duration={file.durationSeconds ?? 0}
127
+ position={position}
128
+ playing={playing}
129
+ onPlayPress={() => void toggle()}
130
+ transcript={file.transcript}
131
+ transcribeLabel={t('chat.attachment.transcribe')}
132
+ hideTranscriptLabel={t('chat.attachment.hideTranscript')}
133
+ accessibilityLabel={file.description ?? t('chat.attachment.voice')}
134
+ />
135
+ );
136
+ }
137
+
138
+ function StoredFile({ file, tone, onColor }: { file: FileAttachment } & Paint) {
139
+ const url = useFileUrl(file.fileId);
140
+ return (
141
+ <FileMessage
142
+ tone={tone}
143
+ onColor={onColor}
144
+ name={file.filename}
145
+ mimeType={file.mime}
146
+ accessibilityLabel={file.description ?? file.filename}
147
+ onPress={url ? () => void Linking.openURL(url) : undefined}
148
+ />
149
+ );
150
+ }
151
+
152
+ function Attachment({ item, tone, onColor }: { item: TurnAttachment } & Paint) {
153
+ if (item.type === 'inline-image') {
154
+ return (
155
+ <View className="size-[120px] overflow-hidden rounded-xl">
156
+ <Image source={{ uri: item.url }} className="h-full w-full" contentFit="cover" />
157
+ </View>
158
+ );
159
+ }
160
+ if (item.mime.startsWith('image/')) {
161
+ return <StoredImage file={item} tone={tone} onColor={onColor} />;
162
+ }
163
+ if (item.mime.startsWith('audio/')) {
164
+ return <StoredVoice file={item} tone={tone} onColor={onColor} />;
165
+ }
166
+ return <StoredFile file={item} tone={tone} onColor={onColor} />;
167
+ }
168
+
169
+ /** The turn's attachments, or nothing when it has none. */
170
+ export function TurnAttachments({
171
+ content,
172
+ tone = 'incoming',
173
+ onColor,
174
+ }: {
175
+ content: MessageContent | null | undefined;
176
+ tone?: Tone;
177
+ onColor?: string;
178
+ }) {
179
+ const items = getAttachmentsFromContent(content);
180
+ if (items.length === 0) return null;
181
+ const inline = items.filter((item) => item.type === 'inline-image');
182
+ const files = items.filter((item) => item.type === 'file');
183
+ return (
184
+ <View className="gap-2">
185
+ {inline.length > 0 ? (
186
+ <View className="flex-row flex-wrap gap-2">
187
+ {inline.map((item) => (
188
+ <Attachment key={item.url} item={item} tone={tone} onColor={onColor} />
189
+ ))}
190
+ </View>
191
+ ) : null}
192
+ {files.map((item) => (
193
+ <Attachment key={item.fileId} item={item} tone={tone} onColor={onColor} />
194
+ ))}
195
+ </View>
196
+ );
197
+ }
198
+
199
+ /** Whether a turn has anything to draw as an attachment. */
200
+ export function hasAttachments(content: MessageContent | null | undefined): boolean {
201
+ return getAttachmentsFromContent(content).length > 0;
202
+ }
@@ -44,3 +44,52 @@ export function getImagesFromContent(content: MessageContent | null | undefined)
44
44
  )
45
45
  .map((p) => p.image_url.url);
46
46
  }
47
+
48
+ /**
49
+ * One attachment of a turn, as the thread draws it: a photo sent inline (`image_url`), or a file kept
50
+ * in Oxy Files (`file`) — attached in the app, or media that arrived on a channel, which says what it
51
+ * was there (`kind`: a sticker, a voice note…), how long it lasts and, for audio, what it says.
52
+ */
53
+ export type TurnAttachment =
54
+ | { readonly type: 'inline-image'; readonly url: string }
55
+ | {
56
+ readonly type: 'file';
57
+ readonly fileId: string;
58
+ readonly filename: string;
59
+ readonly mime: string;
60
+ readonly kind?: string;
61
+ readonly description?: string;
62
+ readonly durationSeconds?: number;
63
+ readonly transcript?: string;
64
+ };
65
+
66
+ /** A turn's attachments, in order. */
67
+ export function getAttachmentsFromContent(
68
+ content: MessageContent | null | undefined,
69
+ ): TurnAttachment[] {
70
+ if (!Array.isArray(content)) return [];
71
+ const out: TurnAttachment[] = [];
72
+ for (const part of content) {
73
+ if (part.type === 'image_url' && typeof part.image_url?.url === 'string') {
74
+ out.push({ type: 'inline-image', url: part.image_url.url });
75
+ continue;
76
+ }
77
+ const file = part.type === 'file' ? (part.file as Record<string, unknown> | undefined) : null;
78
+ if (!file || typeof file.file_id !== 'string' || file.file_id === '') continue;
79
+ const text = (key: string) =>
80
+ typeof file[key] === 'string' ? (file[key] as string) : undefined;
81
+ out.push({
82
+ type: 'file',
83
+ fileId: file.file_id,
84
+ filename: text('filename') ?? file.file_id,
85
+ mime: (text('mime') ?? 'application/octet-stream').toLowerCase(),
86
+ ...(text('kind') ? { kind: text('kind') } : {}),
87
+ ...(text('description') ? { description: text('description') } : {}),
88
+ ...(typeof file.durationSeconds === 'number'
89
+ ? { durationSeconds: file.durationSeconds }
90
+ : {}),
91
+ ...(text('transcript') ? { transcript: text('transcript') } : {}),
92
+ });
93
+ }
94
+ return out;
95
+ }
@@ -71,6 +71,12 @@ export const COPY_EN: Readonly<Record<string, CopyEntry>> = {
71
71
  'chat.bloom.taskStopped': "Didn't finish",
72
72
  'chat.bloom.visited': 'Visited',
73
73
  'chat.bloom.writingFile': 'Writing',
74
+ 'chat.attachment.photo': 'Photo',
75
+ 'chat.attachment.sticker': 'Sticker',
76
+ 'chat.attachment.voice': 'Voice note',
77
+ 'chat.attachment.transcribe': 'Transcript',
78
+ 'chat.attachment.hideTranscript': 'Hide transcript',
79
+ 'chat.attachment.unavailable': "This file can't be opened",
74
80
  'chat.copied': 'Copied!',
75
81
  'chat.copiedToClipboard': 'Copied to clipboard',
76
82
  'chat.copy': 'Copy',
@@ -218,7 +224,7 @@ export const COPY_EN: Readonly<Record<string, CopyEntry>> = {
218
224
  other: '{{count}} accounts connected',
219
225
  },
220
226
  'gemie.connectors.store.description':
221
- 'Connect the apps you work with: the providers’ own MCP servers, and hundreds more from the official MCP Registry. Official means the provider publishes it; Community means a developer does. When one asks you to sign in, you sign in with them, and Gemies never sees your password.',
227
+ 'Connect the apps you work with: the providers’ own MCP servers, and hundreds more from the official MCP Registry and Docker’s MCP catalogue. Official means the provider publishes it; Community means a developer does. When one asks you to sign in, you sign in with them, and Gemies never sees your password.',
222
228
  'gemie.connectors.store.docs': 'About',
223
229
  'gemie.connectors.store.empty': 'No connector is available right now.',
224
230
  'gemie.connectors.store.featured': 'Featured',
@@ -67,6 +67,12 @@ export const COPY_ES: Readonly<Record<string, CopyEntry>> = {
67
67
  'chat.bloom.taskStopped': 'No terminó',
68
68
  'chat.bloom.visited': 'Visitó',
69
69
  'chat.bloom.writingFile': 'Escribiendo',
70
+ 'chat.attachment.photo': 'Foto',
71
+ 'chat.attachment.sticker': 'Sticker',
72
+ 'chat.attachment.voice': 'Nota de voz',
73
+ 'chat.attachment.transcribe': 'Transcripción',
74
+ 'chat.attachment.hideTranscript': 'Ocultar transcripción',
75
+ 'chat.attachment.unavailable': 'No se puede abrir este archivo',
70
76
  'chat.copied': '¡Copiado!',
71
77
  'chat.copiedToClipboard': 'Copiado al portapapeles',
72
78
  'chat.copy': 'Copiar',
@@ -214,7 +220,7 @@ export const COPY_ES: Readonly<Record<string, CopyEntry>> = {
214
220
  other: '{{count}} cuentas conectadas',
215
221
  },
216
222
  'gemie.connectors.store.description':
217
- 'Conecta las apps con las que trabajas: los servidores MCP de los propios proveedores y cientos más del registro oficial de MCP. Oficial significa que lo publica el proveedor; Comunidad, que lo publica un desarrollador. Si alguno te pide iniciar sesión, la inicias con ellos y Gemies nunca ve tu contraseña.',
223
+ 'Conecta las apps con las que trabajas: los servidores MCP de los propios proveedores y cientos más del registro oficial de MCP y del catálogo MCP de Docker. Oficial significa que lo publica el proveedor; Comunidad, que lo publica un desarrollador. Si alguno te pide iniciar sesión, la inicias con ellos y Gemies nunca ve tu contraseña.',
218
224
  'gemie.connectors.store.docs': 'Más información',
219
225
  'gemie.connectors.store.empty': 'Ahora mismo no hay conectores disponibles.',
220
226
  'gemie.connectors.store.featured': 'Destacados',
@@ -76,8 +76,8 @@ export interface ConnectorEntry {
76
76
  category: ConnectorCategory;
77
77
  featured: boolean;
78
78
  trust: ConnectorTrust;
79
- /** `curated` by Gemies, or synced from the official MCP Registry. */
80
- source: 'curated' | 'mcp_registry';
79
+ /** `curated` by Gemies, or the catalogue it was synced from: the official MCP Registry, Docker's. */
80
+ source: 'curated' | 'mcp_registry' | 'docker';
81
81
  /** `oauth` opens the provider's sign-in; `none` connects at once. */
82
82
  signIn: 'oauth' | 'none';
83
83
  /** How many tools it offers, when known before connecting. */