@gemies/sdk 2.0.0 → 3.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 CHANGED
@@ -1,5 +1,30 @@
1
1
  # @gemies/sdk
2
2
 
3
+ ## 3.0.0
4
+
5
+ - **Breaking: a gemie is painted in its Oxy account's colour, and nothing else.**
6
+ `readAgentCharacter(character, color)` takes the gemie's `color` (its account's `User.color`, a
7
+ Bloom preset key, which every response that carries a `character` carries beside it) and paints
8
+ the character in it through Bloom's `avatarCharacterInColor`; a paint the character may still
9
+ carry is never drawn. A gemie whose account colour is not known is drawn in one neutral preset
10
+ (`gray`). Every surface the SDK draws a gemie on (the chat's lead and participants, a consulted
11
+ agent's reply, the exchange view) paints it this way, so the avatar, the chat and the other apps
12
+ agree with the account.
13
+ - **New: `readAgentLook(character)`**, the stored look without a colour (its shape and features),
14
+ for an editor that saves it back: the API refuses a character that carries a paint.
15
+ - **Breaking: `DEFAULT_AGENT_CHARACTER` has no paint**, like every gemie's character.
16
+ - **Breaking: the Bloom peer is `>=20.0.0`**, the first Bloom with `avatarCharacterInColor`.
17
+ - Alia keeps her orchid until her gemie has an Oxy account (Gemies ADR 0034 phase 2); then she
18
+ is painted in its colour like every gemie.
19
+
20
+ ## 2.0.1
21
+
22
+ - **`GemieAccounts` says when the API does not answer**, with a Retry (`gemie.accounts.retry`), and
23
+ offers nothing to link until it does. It used to show a line of text and no way to try again —
24
+ what a person saw while the API was rolling out a release that served the accounts routes.
25
+ - **A link that fails is said in the panel**, with the API's reason and a Retry, instead of a toast
26
+ that was gone before it could be read.
27
+
3
28
  ## 2.0.0
4
29
 
5
30
  - **Lighter chat on web: the chart cards come from their own Bloom entries.** `ChartRenderer` and
package/README.md CHANGED
@@ -208,8 +208,9 @@ loads with the first `ask` (fetched in the background once the person is signed
208
208
  stays out of the app's entry bundle. The root entry exports the same two, with the whole chat
209
209
  (its provider imports the sheet statically).
210
210
  For hosts that need that exact eager behavior without the root barrel, import the provider and
211
- hook from `@gemies/sdk/ask/eager`. The character entry exports `readAgentCharacter`,
212
- and `DEFAULT_AGENT_CHARACTER` without the chat.
211
+ hook from `@gemies/sdk/ask/eager`. The character entry exports `readAgentCharacter`
212
+ (a gemie's stored character painted in its account's `color`), `readAgentLook` (the stored
213
+ character without a colour, for an editor) and `DEFAULT_AGENT_CHARACTER` without the chat.
213
214
 
214
215
  **On web, load the chat through ONE async boundary.** Expo's Metro serializer hoists every module
215
216
  two async chunks share into `__common.js`, which loads at first paint. The SDK draws no async chunk
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gemies/sdk",
3
- "version": "2.0.0",
3
+ "version": "3.0.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",
@@ -58,7 +58,7 @@
58
58
  "react": "^19.2.3",
59
59
  "react-native": "^0.86.0 || ^0.88.0",
60
60
  "@expo/vector-icons": "^15.1.1",
61
- "@oxy.so/bloom": ">=17.41.0",
61
+ "@oxy.so/bloom": ">=20.0.0",
62
62
  "@oxy.so/core": ">=7.1.0 <8",
63
63
  "@oxy.so/services": ">=14.19.1 <15",
64
64
  "@tanstack/react-query": "^5.101",
package/src/character.ts CHANGED
@@ -1 +1 @@
1
- export { DEFAULT_AGENT_CHARACTER, readAgentCharacter } from './lib/agent-character';
1
+ export { DEFAULT_AGENT_CHARACTER, readAgentCharacter, readAgentLook } from './lib/agent-character';
@@ -330,12 +330,17 @@ export interface GemieAccountsProps {
330
330
  * its own turns can read or send through them. Only what this deployment can link is offered.
331
331
  */
332
332
  export function GemieAccounts({ gemieId, name, t = englishCopy }: GemieAccountsProps) {
333
- const { data, isPending, isError } = useGemieAccounts(gemieId);
333
+ const { data, isPending, isError, isFetching, refetch } = useGemieAccounts(gemieId);
334
334
  const { link, remove } = useGemieAccountMutations(gemieId);
335
335
  const [linking, setLinking] = useState<{
336
336
  platform: GemieAccountPlatform;
337
337
  link: GemieAccountLink;
338
338
  } | null>(null);
339
+ /** The last link that failed, said in the panel with a way to try again. */
340
+ const [linkFailure, setLinkFailure] = useState<{
341
+ platform: GemieAccountPlatform;
342
+ reason: string;
343
+ } | null>(null);
339
344
  const linked = useCallback(() => setLinking(null), []);
340
345
 
341
346
  if (isPending) {
@@ -350,15 +355,11 @@ export function GemieAccounts({ gemieId, name, t = englishCopy }: GemieAccountsP
350
355
  }
351
356
 
352
357
  const handleLink = async (platform: GemieAccountPlatform) => {
358
+ setLinkFailure(null);
353
359
  try {
354
360
  setLinking({ platform, link: await link.mutateAsync(platform) });
355
361
  } catch (error) {
356
- toast.error(
357
- t(`${K}.linkFailed`, {
358
- platform: PLATFORM_LABELS[platform],
359
- reason: errorMessage(error, t(`${K}.tryAgain`)),
360
- }),
361
- );
362
+ setLinkFailure({ platform, reason: errorMessage(error, t(`${K}.tryAgain`)) });
362
363
  }
363
364
  };
364
365
 
@@ -374,11 +375,39 @@ export function GemieAccounts({ gemieId, name, t = englishCopy }: GemieAccountsP
374
375
  );
375
376
  const platforms = data?.platforms ?? [];
376
377
 
378
+ /**
379
+ * Nothing could be read: the API did not answer (offline, or mid-rollout before it serves these
380
+ * routes). Said so, with a retry, and nothing else is offered until it answers. A later refresh
381
+ * that fails keeps what was already read.
382
+ */
383
+ if (isError && data === undefined) {
384
+ return (
385
+ <View>
386
+ <Row first>
387
+ <Text variant="body-2-regular" className="text-text-secondary">
388
+ {t(`${K}.loadFailed`)}
389
+ </Text>
390
+ <View className="flex-row">
391
+ <Button
392
+ size="sm"
393
+ appearance="outline"
394
+ tone="neutral"
395
+ loading={isFetching}
396
+ onPress={() => void refetch()}
397
+ >
398
+ {t(`${K}.retry`)}
399
+ </Button>
400
+ </View>
401
+ </Row>
402
+ </View>
403
+ );
404
+ }
405
+
377
406
  return (
378
407
  <View>
379
408
  <Row first>
380
409
  <Text variant="body-2-regular" className="text-text-secondary">
381
- {isError ? t(`${K}.loadFailed`) : t(`${K}.description`, { name })}
410
+ {t(`${K}.description`, { name })}
382
411
  </Text>
383
412
  </Row>
384
413
  {accounts.map((account) => (
@@ -401,7 +430,7 @@ export function GemieAccounts({ gemieId, name, t = englishCopy }: GemieAccountsP
401
430
  onDone={linked}
402
431
  onCancel={handleCancel}
403
432
  />
404
- ) : isError ? null : (
433
+ ) : (
405
434
  <Row>
406
435
  <Text variant="body-2-semibold">{t(`${K}.link`)}</Text>
407
436
  {platforms.length === 0 ? (
@@ -409,7 +438,7 @@ export function GemieAccounts({ gemieId, name, t = englishCopy }: GemieAccountsP
409
438
  {t(`${K}.unavailable`)}
410
439
  </Text>
411
440
  ) : (
412
- <View className="flex-row gap-2">
441
+ <View className="flex-row flex-wrap gap-2">
413
442
  {platforms.map((platform) => (
414
443
  <Button
415
444
  key={platform}
@@ -426,6 +455,31 @@ export function GemieAccounts({ gemieId, name, t = englishCopy }: GemieAccountsP
426
455
  ))}
427
456
  </View>
428
457
  )}
458
+ {linkFailure ? (
459
+ <View className="gap-2">
460
+ <Text
461
+ variant="body-2-regular"
462
+ className="text-error-primary"
463
+ accessibilityRole="alert"
464
+ >
465
+ {t(`${K}.linkFailed`, {
466
+ platform: PLATFORM_LABELS[linkFailure.platform],
467
+ reason: linkFailure.reason,
468
+ })}
469
+ </Text>
470
+ <View className="flex-row">
471
+ <Button
472
+ size="sm"
473
+ appearance="outline"
474
+ tone="neutral"
475
+ disabled={link.isPending}
476
+ onPress={() => handleLink(linkFailure.platform)}
477
+ >
478
+ {t(`${K}.retry`)}
479
+ </Button>
480
+ </View>
481
+ </View>
482
+ ) : null}
429
483
  </Row>
430
484
  )}
431
485
  </View>
@@ -23,6 +23,8 @@ export function GemieGroupWelcome({ members }: { members: readonly GemieParticip
23
23
  label: '',
24
24
  description: '',
25
25
  avatar: member.character,
26
+ // Already painted in it; a colour the member does not have leaves that paint.
27
+ color: member.color ?? '',
26
28
  })),
27
29
  [members],
28
30
  );
@@ -475,7 +475,7 @@ function ReplyTurn({
475
475
  {agent && agentAnchor ? (
476
476
  <View className="mb-0.5">
477
477
  <AgentReplyIdentity
478
- character={readAgentCharacter(agent.character)}
478
+ character={readAgentCharacter(agent.character, agent.color)}
479
479
  name={agent.name}
480
480
  thinking={agentLive && text.length === 0}
481
481
  workingKey={agent.id}
package/src/index.ts CHANGED
@@ -48,7 +48,7 @@ export { VoiceModeIcon } from './components/VoiceModeIcon';
48
48
  export { AmbientField, PARALLAX_DURATION, PARALLAX_EASE } from './components/AmbientField';
49
49
  export type { AmbientFieldProps } from './components/AmbientField';
50
50
  export { ALIA_AVATAR, GemieAvatar } from './components/GemieAvatar';
51
- export { DEFAULT_AGENT_CHARACTER, readAgentCharacter } from './lib/agent-character';
51
+ export { DEFAULT_AGENT_CHARACTER, readAgentCharacter, readAgentLook } from './lib/agent-character';
52
52
  export type { GemieAvatarProps, GemieAvatarState } from './components/GemieAvatar';
53
53
  export { GemieAvatarIcon } from './components/GemieAvatarIcon';
54
54
  export { useGemieActivity } from './hooks/useGemieActivity';
@@ -1,28 +1,64 @@
1
- import { parseAvatarCharacter, type AvatarCharacter } from '@oxy.so/bloom/agent-avatar';
1
+ import {
2
+ avatarCharacterInColor,
3
+ parseAvatarCharacter,
4
+ type AvatarCharacter,
5
+ } from '@oxy.so/bloom/agent-avatar';
6
+
7
+ /**
8
+ * The colour a gemie is painted in when its account's is not known: an account Oxy did not resolve,
9
+ * an agent that has since been deleted. A Bloom colour preset key, like every account colour.
10
+ */
11
+ export const DEFAULT_AGENT_COLOR = 'gray';
2
12
 
3
13
  /**
4
14
  * The look of an agent whose own is not known: a server that does not send one yet, an agent that
5
15
  * has since been deleted, a stored character this Bloom cannot draw. One neutral character, the same
6
16
  * everywhere, so an unknown look is recognisably "not chosen" and never one that belongs to somebody.
17
+ * Like every gemie's, it has no colour of its own.
7
18
  */
8
19
  export const DEFAULT_AGENT_CHARACTER: AvatarCharacter = {
9
20
  shape: 'rounded_cube',
10
21
  eyes: 'oval',
11
22
  eyewear: 'none',
12
23
  accessory: 'none',
13
- color: 'violet',
14
24
  };
15
25
 
26
+ /** A character painted in an account's colour, or in the default one when that is not known. */
27
+ function painted(character: AvatarCharacter, color: string | null | undefined): AvatarCharacter {
28
+ // Bloom leaves a character as it is for a colour it cannot resolve: the default goes on first and
29
+ // the account's colour over it, so a character is always painted, and never in a stored paint.
30
+ return avatarCharacterInColor(avatarCharacterInColor(character, DEFAULT_AGENT_COLOR), color);
31
+ }
32
+
16
33
  /**
17
- * The character an agent is drawn as, from the JSON the server stores for it
18
- * (`agents.character`): Bloom's own parser decides what it can draw, and anything else is the
19
- * default look rather than an avatar that fails to render.
34
+ * The look the server stores for a gemie (`agents.character`), as Bloom can draw it: its shape and
35
+ * features, without a colour. What the agent editor edits and saves back. Bloom's own parser decides
36
+ * what it can draw, and anything else is the default look.
20
37
  */
21
- export function readAgentCharacter(value: unknown): AvatarCharacter {
22
- if (value === null || value === undefined) return DEFAULT_AGENT_CHARACTER;
38
+ export function readAgentLook(value: unknown): AvatarCharacter {
39
+ if (value === null || typeof value !== 'object' || Array.isArray(value)) {
40
+ return DEFAULT_AGENT_CHARACTER;
41
+ }
23
42
  try {
24
- return parseAvatarCharacter(value);
43
+ const {
44
+ color: _color,
45
+ bodyColor: _bodyColor,
46
+ ...look
47
+ } = parseAvatarCharacter(painted(value as AvatarCharacter, null));
48
+ return look;
25
49
  } catch {
26
50
  return DEFAULT_AGENT_CHARACTER;
27
51
  }
28
52
  }
53
+
54
+ /**
55
+ * The character a gemie is drawn as: its look (`readAgentLook`) painted in its account's colour
56
+ * (`color`, `User.color`, a Bloom preset key). A gemie's colour is its Oxy account's and nothing
57
+ * else, so `color` is required: every surface that draws a gemie has it beside the character.
58
+ */
59
+ export function readAgentCharacter(
60
+ value: unknown,
61
+ color: string | null | undefined,
62
+ ): AvatarCharacter {
63
+ return painted(readAgentLook(value), color);
64
+ }
@@ -5,6 +5,11 @@ import type { AvatarCharacter } from '@oxy.so/bloom/agent-avatar';
5
5
  * eyes, nothing on its head. It is `blue_beret` with the hat taken off and the paint changed,
6
6
  * so Bloom retargets that preset's animation onto it; change it here and nowhere else.
7
7
  *
8
+ * Every other gemie is painted in its Oxy account's colour and carries no paint of its own
9
+ * (`readAgentCharacter`). Alia is the one exception, and only because her gemie has no Oxy account
10
+ * yet (`agents.oxy_account_id` is `pending-oxy-account:alia` until Oxy gives her one, ADR 0034
11
+ * phase 2): when it exists, her colour is its `color` and the paint here goes.
12
+ *
8
13
  * A module of its own, without React.
9
14
  */
10
15
  export const ALIA_AVATAR: AvatarCharacter = {
@@ -179,6 +179,7 @@ export const COPY_EN: Readonly<Record<string, CopyEntry>> = {
179
179
  'gemie.accounts.replies.everyone': 'Everyone who writes',
180
180
  'gemie.accounts.replies.nobody': 'Nobody: {{name}} only reads and sends when you ask',
181
181
  'gemie.accounts.repliesLabel': 'Who {{name}} answers',
182
+ 'gemie.accounts.retry': 'Retry',
182
183
  'gemie.accounts.saveFailed': 'Could not save. Try again.',
183
184
  'gemie.accounts.scan.telegram':
184
185
  'Open Telegram on your phone, go to Settings > Devices > Link Desktop Device, and scan this code.',
@@ -175,6 +175,7 @@ export const COPY_ES: Readonly<Record<string, CopyEntry>> = {
175
175
  'gemie.accounts.replies.everyone': 'A todo el que escriba',
176
176
  'gemie.accounts.replies.nobody': 'A nadie: {{name}} solo lee y envía cuando se lo pides',
177
177
  'gemie.accounts.repliesLabel': 'A quién responde {{name}}',
178
+ 'gemie.accounts.retry': 'Reintentar',
178
179
  'gemie.accounts.saveFailed': 'No se ha podido guardar. Inténtalo de nuevo.',
179
180
  'gemie.accounts.scan.telegram':
180
181
  'Abre Telegram en tu teléfono, ve a Ajustes > Dispositivos > Vincular dispositivo de escritorio y escanea este código.',
@@ -9,8 +9,9 @@ export interface GemieParticipant {
9
9
  id: string;
10
10
  name: string;
11
11
  handle?: string;
12
- /** The 3D character it is drawn as. */
12
+ /** The character it is drawn as, painted in its colour. */
13
13
  character: AvatarCharacter;
14
+ /** Its colour: its Oxy account's (`User.color`, a Bloom preset key). */
14
15
  color?: string;
15
16
  }
16
17
 
@@ -59,7 +60,7 @@ export function leadOf(profile: GemieAgentProfile | null | undefined): GemieLead
59
60
  id: profile.id,
60
61
  name: profile.name,
61
62
  handle: profile.handle,
62
- character: readAgentCharacter(profile.character),
63
+ character: readAgentCharacter(profile.character, profile.color),
63
64
  color: profile.color,
64
65
  isAlia: false,
65
66
  greeting: profile.greeting,
@@ -73,7 +74,7 @@ export function participantOf(agentInfo: NonNullable<Message['agentInfo']>): Gem
73
74
  id: agentInfo.id,
74
75
  name: agentInfo.name,
75
76
  handle: agentInfo.handle,
76
- character: readAgentCharacter(agentInfo.character),
77
+ character: readAgentCharacter(agentInfo.character, agentInfo.color),
77
78
  color: agentInfo.color,
78
79
  };
79
80
  }
@@ -8,6 +8,7 @@
8
8
  */
9
9
 
10
10
  export { API_ROUTES as GEMIES_API_ROUTES } from './routes';
11
+ export { ALIA_GEMIE_ID } from '../lib/alia-gemie';
11
12
  export * from './power-levels';
12
13
  export { englishCopy } from '../lib/copy';
13
14
  export type { Translate } from '../lib/copy';