@gemies/sdk 3.3.0 → 4.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,39 @@
1
1
  # @gemies/sdk
2
2
 
3
+ ## 4.0.0
4
+
5
+ - **Breaking: a connected account is the person's, granted to their gemies (Gemies ADR 0035 as
6
+ amended).** The person connects WhatsApp and Telegram once, in Settings, and chooses which of
7
+ their gemies may use each account and which one, if any, answers it on its own.
8
+ - `GemieConnectedAccounts` (`@gemies/sdk/accounts`) is Settings › Connected accounts: connect an
9
+ account, the gemies that may use it (a switch each, Alia among them), the gemie that answers
10
+ it and whom it answers. It takes no gemie.
11
+ - `GemieAccountGrants` is the list a gemie's editor shows: the person's accounts, one switch
12
+ each, and `onManage` to open Settings.
13
+ - `GemieAccounts` is gone, and so are `useGemieAccounts`, `useGemieAccountQr`,
14
+ `useGemieAccountChats`, `useGemieAccountMutations` and `GemieAccountsAnswer`; the hooks are
15
+ `useConnectedAccounts`, `useConnectedAccountQr`, `useConnectedAccountChats` and
16
+ `useConnectedAccountMutations` (`connect`, `update`, `grant`, `remove`) over `/me/accounts`.
17
+ `GemieAccount` is `ConnectedAccount`, with `gemieIds` and `answeringGemieId`;
18
+ `ConnectedAccountsAnswer` carries the `gemies` an account can be granted to.
19
+ - `@gemies/sdk/accounts` no longer re-exports `ALIA_GEMIE_ID` (it is still in the root entry).
20
+ - Copy: the panel says "connect" for "link"; new keys under `gemie.accounts.*`
21
+ (`answeringLabel`, `usedBy`, `grantLabel`, `grants.*`…); `link`, `linkNamed`, `linkFailed`
22
+ and `linked` are gone.
23
+ - **New: `GrantSwitchRow` (`@gemies/sdk/connectors`)**, the switch row every list that grants a
24
+ connected account to a gemie draws, connectors included.
25
+
26
+ ## 3.3.1
27
+
28
+ - **The activity socket stops reconnecting every few seconds.** `useGemieActivity` (every Alia
29
+ button's avatar) and `useAgentActivity` authenticated their sockets with the session's base
30
+ `accessToken`, which is not refreshed for the Gemies API; once it expired the server refused
31
+ every handshake ("Token expired") and the shared socket opened a new websocket every 5 s for as
32
+ long as the tab stayed open (51 upgrades in 12 minutes for one person). Both now ask a linked
33
+ client for the API's own token on every handshake, refreshed by `@oxy.so/core` when due, as
34
+ every other request does; the shared socket asks a holder still holding it. A refused handshake
35
+ is retried after 5 s, doubling to at most a minute, and the next outage starts from 5 s again.
36
+
3
37
  ## 3.3.0
4
38
 
5
39
  - **New: `@gemies/sdk/connectors`**, the connectors a person connects — providers' own remote MCP
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gemies/sdk",
3
- "version": "3.3.0",
3
+ "version": "4.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",
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';
@@ -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
+ }