@gemies/sdk 3.3.1 → 4.1.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,36 @@
1
1
  # @gemies/sdk
2
2
 
3
+ ## 4.1.0
4
+
5
+ - **The group welcome no longer links Bloom's whole multi-agent template.** `GemieGroupWelcome`
6
+ imports `SelectedAgentPreview` from `@oxy.so/bloom/multi-agent-chat/selected-agent-preview`
7
+ instead of the `multi-agent-chat` barrel: in Gemies' web export that took `multi-agent-chat` from
8
+ 149,484 to 9,309 bytes of the chunk every route loads first. The Bloom peer floor is
9
+ `>=21.1.0`, the first Bloom with that entry.
10
+
11
+ ## 4.0.0
12
+
13
+ - **Breaking: a connected account is the person's, granted to their gemies (Gemies ADR 0035 as
14
+ amended).** The person connects WhatsApp and Telegram once, in Settings, and chooses which of
15
+ their gemies may use each account and which one, if any, answers it on its own.
16
+ - `GemieConnectedAccounts` (`@gemies/sdk/accounts`) is Settings › Connected accounts: connect an
17
+ account, the gemies that may use it (a switch each, Alia among them), the gemie that answers
18
+ it and whom it answers. It takes no gemie.
19
+ - `GemieAccountGrants` is the list a gemie's editor shows: the person's accounts, one switch
20
+ each, and `onManage` to open Settings.
21
+ - `GemieAccounts` is gone, and so are `useGemieAccounts`, `useGemieAccountQr`,
22
+ `useGemieAccountChats`, `useGemieAccountMutations` and `GemieAccountsAnswer`; the hooks are
23
+ `useConnectedAccounts`, `useConnectedAccountQr`, `useConnectedAccountChats` and
24
+ `useConnectedAccountMutations` (`connect`, `update`, `grant`, `remove`) over `/me/accounts`.
25
+ `GemieAccount` is `ConnectedAccount`, with `gemieIds` and `answeringGemieId`;
26
+ `ConnectedAccountsAnswer` carries the `gemies` an account can be granted to.
27
+ - `@gemies/sdk/accounts` no longer re-exports `ALIA_GEMIE_ID` (it is still in the root entry).
28
+ - Copy: the panel says "connect" for "link"; new keys under `gemie.accounts.*`
29
+ (`answeringLabel`, `usedBy`, `grantLabel`, `grants.*`…); `link`, `linkNamed`, `linkFailed`
30
+ and `linked` are gone.
31
+ - **New: `GrantSwitchRow` (`@gemies/sdk/connectors`)**, the switch row every list that grants a
32
+ connected account to a gemie draws, connectors included.
33
+
3
34
  ## 3.3.1
4
35
 
5
36
  - **The activity socket stops reconnecting every few seconds.** `useGemieActivity` (every Alia
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gemies/sdk",
3
- "version": "3.3.1",
3
+ "version": "4.1.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",
@@ -59,7 +59,7 @@
59
59
  "react": "^19.2.3",
60
60
  "react-native": "^0.86.0 || ^0.88.0",
61
61
  "@expo/vector-icons": "^15.1.1",
62
- "@oxy.so/bloom": ">=20.0.0",
62
+ "@oxy.so/bloom": ">=21.1.0",
63
63
  "@oxy.so/core": ">=7.1.0 <8",
64
64
  "@oxy.so/services": ">=14.19.1 <15",
65
65
  "@tanstack/react-query": "^5.101",
package/src/accounts.ts CHANGED
@@ -1,29 +1,33 @@
1
1
  /// <reference types="nativewind/types" />
2
2
  /**
3
- * The connected-accounts leaf entry (ADR 0035): the WhatsApp and Telegram accounts a person links
4
- * to a gemie, and the panel that manages them. Its own entry so an app that does not draw it never
5
- * reaches its QR encoder.
3
+ * The connected-accounts leaf entry (ADR 0035 as amended): the WhatsApp and Telegram accounts a
4
+ * person connects once and grants to their gemies. `GemieConnectedAccounts` is Settings ›
5
+ * Connected accounts; `GemieAccountGrants` is the list of them a gemie's editor shows, one switch
6
+ * each. Its own entry so an app that does not draw them never reaches the QR encoder.
6
7
  */
7
- export { GemieAccounts } from './components/GemieAccounts';
8
- export { ALIA_GEMIE_ID } from './lib/alia-gemie';
9
- export type { GemieAccountsProps } from './components/GemieAccounts';
8
+ export { GemieAccountGrants } from './components/accounts/GemieAccountGrants';
9
+ export type { GemieAccountGrantsProps } from './components/accounts/GemieAccountGrants';
10
+ export { GemieConnectedAccounts } from './components/accounts/GemieConnectedAccounts';
11
+ export type { GemieConnectedAccountsProps } from './components/accounts/GemieConnectedAccounts';
10
12
  export {
11
13
  GEMIE_ACCOUNT_GROUP_REPLIES,
12
14
  GEMIE_ACCOUNT_PLATFORMS,
13
15
  GEMIE_ACCOUNT_REPLIES,
14
16
  GEMIE_ACCOUNT_STATUSES,
15
- useGemieAccountChats,
16
- useGemieAccountMutations,
17
- useGemieAccountQr,
18
- useGemieAccounts,
19
- } from './runtime/gemie-accounts';
17
+ useConnectedAccountChats,
18
+ useConnectedAccountMutations,
19
+ useConnectedAccountQr,
20
+ useConnectedAccounts,
21
+ } from './runtime/connected-accounts';
20
22
  export type {
21
- GemieAccount,
23
+ ConnectedAccount,
24
+ ConnectedAccountPatch,
25
+ ConnectedAccountsAnswer,
22
26
  GemieAccountChat,
23
27
  GemieAccountGroupReplies,
24
28
  GemieAccountLink,
25
29
  GemieAccountPlatform,
26
30
  GemieAccountReplies,
27
- GemieAccountsAnswer,
28
31
  GemieAccountStatus,
29
- } from './runtime/gemie-accounts';
32
+ GrantableGemie,
33
+ } from './runtime/connected-accounts';
@@ -1,5 +1,5 @@
1
1
  import { useAvatarFlights } from '@oxy.so/bloom/avatar-flight';
2
- import { SelectedAgentPreview } from '@oxy.so/bloom/multi-agent-chat';
2
+ import { SelectedAgentPreview } from '@oxy.so/bloom/multi-agent-chat/selected-agent-preview';
3
3
  import { Text, View } from 'react-native';
4
4
  import { useMemo } from 'react';
5
5
  import { useGemieFlights } from '../lib/flights';
@@ -0,0 +1,117 @@
1
+ import { Button } from '@oxy.so/bloom/button';
2
+ import * as Skeleton from '@oxy.so/bloom/skeleton';
3
+ import { toast } from '@oxy.so/bloom/toast';
4
+ import { Text } from '@oxy.so/bloom/typography';
5
+ import { View } from 'react-native';
6
+ import { englishCopy, type Translate } from '../../lib/copy';
7
+ import {
8
+ useConnectedAccountMutations,
9
+ useConnectedAccounts,
10
+ } from '../../runtime/connected-accounts';
11
+ import { GrantSwitchRow } from '../connectors/GrantSwitchRow';
12
+ import { K, PlatformMark, accountName, statusText } from './account-parts';
13
+
14
+ export interface GemieAccountGrantsProps {
15
+ /** The gemie whose grants these are (Alia's id for her locked editor). */
16
+ gemieId: string;
17
+ /** The gemie's name, as the copy says it. */
18
+ name: string;
19
+ /** Opens Settings › Connected accounts, where accounts are connected and who answers is chosen. */
20
+ onManage: () => void;
21
+ /** The host's translator, keyed as `gemie.accounts.*`; English when absent. */
22
+ t?: Translate;
23
+ }
24
+
25
+ /**
26
+ * The person's connected WhatsApp and Telegram accounts this gemie may use, one switch each (ADR
27
+ * 0035 as amended), for its editor: the same grant the Settings panel writes, seen from the gemie,
28
+ * the way its connectors are granted beside it (`GrantSwitchRow`). Connecting an account, and
29
+ * choosing which gemie answers it on its own, are Settings', a tap away.
30
+ */
31
+ export function GemieAccountGrants({
32
+ gemieId,
33
+ name,
34
+ onManage,
35
+ t = englishCopy,
36
+ }: GemieAccountGrantsProps) {
37
+ const { data, isPending, isError, isFetching, refetch } = useConnectedAccounts();
38
+ const { grant } = useConnectedAccountMutations();
39
+
40
+ if (isPending) {
41
+ return (
42
+ <Skeleton.Region>
43
+ <View className="gap-3 py-2.5">
44
+ <Skeleton.Box width={220} height={14} />
45
+ <Skeleton.Box width={160} height={14} />
46
+ </View>
47
+ </Skeleton.Region>
48
+ );
49
+ }
50
+
51
+ if (isError && data === undefined) {
52
+ return (
53
+ <View className="items-start gap-2 py-2.5 pe-2.5">
54
+ <Text variant="body-2-regular" className="text-text-secondary">
55
+ {t(`${K}.loadFailed`)}
56
+ </Text>
57
+ <Button
58
+ size="sm"
59
+ appearance="outline"
60
+ tone="neutral"
61
+ loading={isFetching}
62
+ onPress={() => void refetch()}
63
+ >
64
+ {t(`${K}.retry`)}
65
+ </Button>
66
+ </View>
67
+ );
68
+ }
69
+
70
+ // Only an account that has been connected can be used; one waiting for its scan is Settings'.
71
+ const accounts = (data?.accounts ?? []).filter((account) => account.status !== 'qr-pending');
72
+
73
+ const setGranted = async (accountId: string, granted: boolean) => {
74
+ try {
75
+ await grant.mutateAsync({ accountId, gemieId, granted });
76
+ } catch {
77
+ toast.error(t(`${K}.saveFailed`));
78
+ }
79
+ };
80
+
81
+ return (
82
+ <View>
83
+ <View className="py-2.5 pe-2.5">
84
+ <Text variant="body-2-regular" className="text-text-secondary">
85
+ {accounts.length === 0 ? t(`${K}.grants.empty`) : t(`${K}.grants.description`, { name })}
86
+ </Text>
87
+ </View>
88
+ {accounts.map((account) => {
89
+ const label = accountName(account);
90
+ const answers = account.answeringGemieId === gemieId;
91
+ return (
92
+ <GrantSwitchRow
93
+ key={account._id}
94
+ leading={<PlatformMark platform={account.platform} />}
95
+ label={label}
96
+ detail={
97
+ answers
98
+ ? t(`${K}.answersOnItsOwn`)
99
+ : account.status === 'connected'
100
+ ? null
101
+ : statusText(account, t)
102
+ }
103
+ checked={account.gemieIds.includes(gemieId)}
104
+ disabled={grant.isPending}
105
+ accessibilityLabel={t(`${K}.grantLabel`, { gemie: name, account: label })}
106
+ onCheckedChange={(granted) => void setGranted(account._id, granted)}
107
+ />
108
+ );
109
+ })}
110
+ <View className="flex-row border-t border-border py-2.5 pe-2.5">
111
+ <Button size="sm" appearance="outline" tone="neutral" onPress={onManage}>
112
+ {t(`${K}.grants.manage`)}
113
+ </Button>
114
+ </View>
115
+ </View>
116
+ );
117
+ }