@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 +34 -0
- package/package.json +1 -1
- package/src/accounts.ts +18 -14
- package/src/components/accounts/GemieAccountGrants.tsx +117 -0
- package/src/components/{GemieAccounts.tsx → accounts/GemieConnectedAccounts.tsx} +210 -174
- package/src/components/accounts/account-parts.tsx +53 -0
- package/src/components/connectors/GrantSwitchRow.tsx +57 -0
- package/src/connectors.ts +4 -1
- package/src/hooks/useGemieActivity.ts +9 -1
- package/src/lib/activity-socket.ts +45 -10
- package/src/lib/copy-en.ts +26 -12
- package/src/lib/copy-es.ts +27 -13
- package/src/runtime/connected-accounts.ts +218 -0
- package/src/runtime/query-keys.ts +6 -7
- package/src/runtime/routes.ts +14 -4
- package/src/runtime/use-agent-activity.ts +10 -2
- package/src/runtime/gemie-accounts.ts +0 -189
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
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
|
|
4
|
-
*
|
|
5
|
-
*
|
|
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 {
|
|
8
|
-
export {
|
|
9
|
-
export
|
|
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
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
} from './runtime/
|
|
17
|
+
useConnectedAccountChats,
|
|
18
|
+
useConnectedAccountMutations,
|
|
19
|
+
useConnectedAccountQr,
|
|
20
|
+
useConnectedAccounts,
|
|
21
|
+
} from './runtime/connected-accounts';
|
|
20
22
|
export type {
|
|
21
|
-
|
|
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
|
-
|
|
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
|
+
}
|