Skip to content

Commit 02f8459

Browse files
authored
Merge branch 'main' into db-key-loss-ios
2 parents b1f6098 + fab4781 commit 02f8459

File tree

19 files changed

+9860
-9396
lines changed

19 files changed

+9860
-9396
lines changed

docs/pages/*.mdx

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# Page not found
2+
3+
This page may have been moved, renamed, or removed. Our docs are actively maintained, so URLs occasionally change.
4+
5+
Please use the search field or links in the header to find what you need.
6+
7+
To request help or report a bug, please [open an issue](https://github.com/xmtp/docs-xmtp-org/issues).
8+
9+
We know how important it is to have reliable documentation and we appreciate your patience.

docs/pages/agents/build-agents/create-a-client.mdx

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ const signer = createSigner(user);
1515

1616
const agent = await Agent.create(signer, {
1717
env: 'dev', // or 'production'
18-
dbEncryptionKey: getRandomValues(new Uint8Array(32)), // save it for later
18+
dbEncryptionKey: `0x${getRandomValues(new Uint8Array(32))}`, // save it for later
1919
});
2020
```
2121

@@ -25,11 +25,11 @@ The XMTP Agent SDK allows you to use environment variables (`process.env`) for e
2525

2626
**Available variables:**
2727

28-
| Variable | Purpose | Example |
29-
| ------------------------ | -------------------------------------------------------------- | --------------------------------------- |
30-
| `XMTP_WALLET_KEY` | Private key for wallet | `XMTP_WALLET_KEY=0x1234...abcd` |
31-
| `XMTP_ENV` | XMTP network environment (`local`, `dev`, or `production`) | `XMTP_ENV=dev` or `XMTP_ENV=production` |
32-
| `XMTP_DB_ENCRYPTION_KEY` | Database encryption key for the local database (32 bytes, hex) | `XMTP_DB_ENCRYPTION_KEY=0xabcd...1234` |
28+
| Variable | Purpose | Example |
29+
| ------------------------ | ------------------------------------------------------------------------------------ | --------------------------------------- |
30+
| `XMTP_WALLET_KEY` | Private key for wallet | `XMTP_WALLET_KEY=0x1234...abcd` |
31+
| `XMTP_ENV` | XMTP network environment (`local`, `dev`, or `production`) | `XMTP_ENV=dev` or `XMTP_ENV=production` |
32+
| `XMTP_DB_ENCRYPTION_KEY` | Database encryption key for the local database (32 bytes, hex string with 0x prefix) | `XMTP_DB_ENCRYPTION_KEY=0xabcd...1234` |
3333

3434
Using the environment variables, you can setup your agent in just a few lines of code:
3535

@@ -40,7 +40,7 @@ import { generatePrivateKey } from 'viem';
4040
import { getRandomValues } from 'node:crypto';
4141

4242
const walletKey = generatePrivateKey();
43-
const encryptionKeyHex = getRandomValues(new Uint8Array(32));
43+
const encryptionKeyHex = `0x${getRandomValues(new Uint8Array(32))}`;
4444

4545
console.log(`Wallet key: ${walletKey}`);
4646
console.log(`Encryption key: ${encryptionKeyHex}`);
@@ -121,9 +121,13 @@ apiUrl?: string;
121121
*/
122122
dbPath?: string | null | ((inboxId: string) => string);
123123
/**
124-
* Encryption key for the local DB
124+
* Encryption key for the local DB (32 bytes)
125+
*
126+
* Accepts either:
127+
* - Uint8Array (32 bytes)
128+
* - Hex string with 0x prefix (64 hex characters representing 32 bytes)
125129
*/
126-
dbEncryptionKey?: Uint8Array;
130+
dbEncryptionKey?: Uint8Array | `0x${string}`;
127131
/**
128132
* Allow configuring codecs for additional content types
129133
*/

docs/pages/agents/build-agents/group-permissions.mdx

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
1-
# Understand the group permissions system
1+
# Understand group permissions
2+
3+
The group permissions system controls what actions different members can take in a group chat. This guide explains how the system works conceptually. For practical code examples of managing roles and permissions, see [Manage group chats](/agents/build-agents/groups).
24

35
## Member statuses
46

5-
Member statuses are the roles that can be assigned to each participant (inbox ID) in a group chat. These are the available member statuses:
7+
Member statuses are the roles that can be assigned to each participant (inbox ID) in a group chat:
68

7-
- Member
8-
- Everyone in a group chat is a member. A member can be granted admin or super admin status. If a member's admin or super admin status is removed, they are still a member of the group.
9-
- Admin
10-
- Super admin
9+
- **Member** - Everyone in a group chat is a member. A member can be granted admin or super admin status. If a member's admin or super admin status is removed, they are still a member of the group.
10+
- **Admin** - Members with elevated permissions
11+
- **Super admin** - Highest permission level with full control over the group
1112

1213
## Options
1314

@@ -79,3 +80,10 @@ If you aren't opinionated and don't set any permissions and options, groups will
7980
- Update group metadata - All members
8081

8182
To learn more about the `All_Members` and `Admin_Only` policy sets, see [group_permissions.rs](https://github.com/xmtp/libxmtp/blob/85dd6d36f46db1ed74fe98273eea6871fea2e078/xmtp_mls/src/groups/group_permissions.rs#L1192-L1226) in the LibXMTP repo.
83+
84+
## Next steps
85+
86+
Now that you understand how the permission system works, see [Manage group chats](/agents/build-agents/groups) for practical code examples of:
87+
- Adding and removing members
88+
- Assigning roles
89+
- Managing group metadata

docs/pages/agents/build-agents/groups.mdx

Lines changed: 59 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,15 @@ Group chats can have metadata like names, descriptions, and images to help users
66
To learn more, see the [Gated group example](https://github.com/ephemeraHQ/xmtp-agent-examples/tree/main/examples/xmtp-gated-group) in the xmtp-agents-examples repo.
77
:::
88

9-
## Available metadata fields
9+
## Group metadata
10+
11+
### Available metadata fields
1012

1113
- `group_name`: The name of the group chat
1214
- `description`: A description of the group chat
1315
- `image_url`: A URL pointing to an image for the group chat
1416

15-
## Get and update metadata
17+
### Get and update metadata
1618

1719
```js [Node]
1820
// Get metadata
@@ -26,56 +28,46 @@ await group.updateDescription('New Group Description');
2628
await group.updateImageUrl('newurl.com');
2729
```
2830

29-
## Manage group chat membership
30-
31-
:::tip[Quickstart]
32-
To learn more, see the [Gated group example](https://github.com/ephemeraHQ/xmtp-agent-examples/tree/main/examples/xmtp-gated-group) in the xmtp-agents-examples repo.
33-
:::
31+
## Group membership
3432

3533
The maximum group chat size is 250 members.
3634

35+
### Add members
36+
37+
Add members directly by their Ethereum addresses or by their inbox IDs:
38+
3739
```js [Node]
38-
// Get inbox IDs for identities
39-
const inboxId = await client.getInboxIdByIdentities([
40-
bo.identity,
41-
caro.identity,
42-
]);
40+
// Add members by Ethereum address
41+
await ctx.addMembersWithAddresses(group, [ address1, address2 ]);
4342

44-
// Add/remove members
43+
// Add members using inbox IDs
4544
await group.addMembers([inboxId]);
46-
await group.removeMembers([inboxId]);
45+
```
4746

48-
// Get member information
49-
await group.sync();
50-
const members = group.members;
51-
const addedByInboxId = group.addedByInboxId;
47+
### Remove members
48+
49+
Remove members from the group by their Ethereum addresses or by their inbox IDs:
50+
51+
```js [Node]
52+
// Remove members by address
53+
await ctx.removeMembersWithAddresses(group, [ address1, address2 ]);
5254

53-
// Map inbox ID to account identity
54-
const inboxIdIdentityMap = new Map(
55-
members.map((member) => [member.inboxId, member.accountIdentity])
56-
);
55+
// Remove members by inbox ID
56+
await group.removeMembers([inboxId]);
5757
```
5858

59-
## Manage group chat admins
59+
### Get member information
6060

61-
```js [Node]
62-
// Check admin status
63-
const isAdmin = group.isAdmin(inboxId);
64-
const isSuperAdmin = group.isSuperAdmin(inboxId);
61+
Retrieve and work with member data:
6562

66-
// List admins
67-
const admins = group.admins;
68-
const superAdmins = group.superAdmins;
63+
```js [Node]
64+
// Sync group data to get latest member information
65+
await group.sync();
6966

70-
// Add/remove admin status
71-
await group.addAdmin(inboxId);
72-
await group.addSuperAdmin(inboxId);
73-
await group.removeAdmin(inboxId);
74-
await group.removeSuperAdmin(inboxId);
67+
// Get all members
68+
const members = await group.members();
7569
```
7670

77-
## Member information
78-
7971
Get detailed information about group members:
8072

8173
```typescript
@@ -98,3 +90,33 @@ agent.on('text', async (ctx) => {
9890
}
9991
});
10092
```
93+
94+
## Group roles
95+
96+
Members can be assigned different roles with varying permission levels. To learn more about how the permission system works, see [Understand group permissions](/agents/build-agents/group-permissions).
97+
98+
### Available roles
99+
100+
- **Member** - Default role for all group participants
101+
- **Admin** - Members with elevated permissions
102+
- **Super admin** - Highest permission level (creator starts as super admin)
103+
104+
### Manage roles
105+
106+
Check and assign roles to group members:
107+
108+
```js [Node]
109+
// Check admin status
110+
const isAdmin = group.isAdmin(inboxId);
111+
const isSuperAdmin = group.isSuperAdmin(inboxId);
112+
113+
// List admins
114+
const admins = group.admins;
115+
const superAdmins = group.superAdmins;
116+
117+
// Add/remove admin status
118+
await group.addAdmin(inboxId);
119+
await group.addSuperAdmin(inboxId);
120+
await group.removeAdmin(inboxId);
121+
await group.removeSuperAdmin(inboxId);
122+
```

docs/pages/agents/build-agents/local-database.mdx

Lines changed: 14 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,12 @@
22

33
Each XMTP agent installation maintains its own local database containing message history, conversation state, and cryptographic material. When you delete this database (or use an in-memory database), you create a new installation that counts toward your [installation limits](/chat-apps/core-messaging/manage-inboxes#inbox-update-and-installation-limits).
44

5+
:::danger[CRITICAL FOR PRODUCTION]
6+
7+
Each time you run your agent, XMTP creates local database files that must be **kept between restarts and between deployments**. Without persistent volumes, each restart creates a new installation and you're **limited to 10 installations per inbox**.
8+
9+
:::
10+
511
## Installation limits and revocation rules
612

713
Understanding XMTP's installation and inbox limits is critical for production deployments:
@@ -12,6 +18,7 @@ Understanding XMTP's installation and inbox limits is critical for production de
1218

1319
These limits protect inbox integrity and prevent unbounded key state growth across devices. For production environments, always use persistent volumes to back up and preserve your database across agent restarts.
1420

21+
1522
## Understand local database files
1623

1724
The Agent SDK creates database files in the `dbPath` directory (default is `'/'`). These files store your agent's identity and message history.
@@ -30,22 +37,6 @@ xmtp-production-62ff7c82fa2e8c9a0a0c9e58e7247704d102c41e5ceb4dc3573792d7d7a1c688
3037
- `62ff7c82fa2e8c9a0a0c9e58e7247704d102c41e5ceb4dc3573792d7d7a1c688`: Inbox ID (Your xmtp identity)
3138
- `.db3`: SQLite database file extension
3239

33-
**Keep these files between deployments:**
34-
35-
- Deleting them creates a new installation each time
36-
- Reusing them maintains the same installation
37-
- Each inbox can have up to 10 installations
38-
39-
**For production deployments:**
40-
41-
- Use persistent volumes (Railway volumes, Render disks, etc.)
42-
- The database needs to persist across restarts
43-
44-
:::warning[Note]
45-
46-
If you hit the 10 installation limit, use [this script](https://github.com/ephemeraHQ/xmtp-agent-examples?tab=readme-ov-file#revoke-installations) to revoke installations.
47-
48-
:::
4940

5041
## Understand installations
5142

@@ -89,45 +80,18 @@ If you deploy your agent to this same network environment, you have 1 inbox with
8980
/>
9081
</div>
9182

92-
Here are some best practices for agent installation management:
93-
94-
- Configure your deployments to preserve the agent's database
95-
- Consider how many platforms you'll need before hitting the 10 installation limit
96-
- Keep track of which installation corresponds to which platform
97-
- Regularly [check how many installations your agent has](/agents/deploy/debug-agents)
98-
- [Revoke installations](#revoke-agent-installations) from platforms you no longer use
99-
100-
## Common agent installation scenarios
101-
102-
### Deploy to a new platform
103-
104-
When you deploy your agent to a new platform (e.g., from Railway to Fly.io):
105-
106-
- Your agent creates a new installation for the new platform
107-
- If you already have 10 installations, you'll need to [revoke one first](#revoke-agent-installations)
108-
- The new installation will start fresh without conversation history
109-
110-
### Update an existing deployment
111-
112-
When you redeploy your agent to the same platform:
113-
114-
- If the platform preserves the database, the same installation continues working
115-
- If the platform doesn't preserve the database, a new installation is created
116-
11783
## Revoke agent installations
11884

119-
:::warning[Important]
85+
When you revoke an agent installation, it can no longer send or receive messages. However, you can still access the local database. Your agent can still run from any active installations on other deployment platforms.
12086

87+
:::danger[Important]
12188
Revoking an installation is permanent. You cannot recover access to a revoked installation.
122-
12389
:::
12490

125-
When you revoke an agent installation, it can no longer send or receive messages. However, you can still access the local database.
91+
1. Web tool: [xmtp.chat/inbox-tools](https://xmtp.chat/inbox-tools)
92+
2. CLI script: [revokeInstallations.ts](https://github.com/ephemeraHQ/xmtp-agent-examples/blob/eb1dc17e99570b77de906ba0d58094586a4af844/scripts/revokeInstallations.ts) in the xmtp-agent-examples repo
12693

127-
Your agent can still run from any active installations on other deployment platforms.
94+
```bash
95+
yarn revoke <inbox-id> <installations-to-exclude>
96+
```
12897

129-
To revoke an agent installation, use [revokeInstallations.ts](https://github.com/ephemeraHQ/xmtp-agent-examples/blob/eb1dc17e99570b77de906ba0d58094586a4af844/scripts/revokeInstallations.ts) in the xmtp-agent-examples repo. For example:
130-
131-
```bash
132-
yarn revoke <inbox-id> <installations-to-exclude>
133-
```

docs/pages/agents/concepts/context.mdx

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,15 @@ agent.on('text', async (ctx) => {
7373
});
7474
```
7575

76+
### Get inbox ID by identifier
77+
78+
```typescript
79+
const inboxId = await ctx.client.getInboxIdByIdentifier({
80+
identifier: targetAddress,
81+
identifierKind: IdentifierKind.Ethereum,
82+
});
83+
```
84+
7685
### getSenderAddress()
7786

7887
Get the Ethereum address of the message sender:

docs/pages/agents/concepts/identity.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ When you call `Agent.create()`, the following steps happen under the hood:
3636

3737
The `dbEncryptionKey` client option is used by the Node, React Native, Android, and Swift SDKs only.
3838

39-
The encryption key is critical to the stability and continuity of an XMTP client. It encrypts the local SQLite database created when you call `Client.create()`, and must be provided every time you create or build a client.
39+
The encryption key is used together with an auto-generated salt to encrypt the local database using [SQLCipher](https://www.zetetic.net/sqlcipher/). It encrypts the database created when you call `Agent.create()`.
4040

4141
This encryption key is not stored or persisted by the XMTP SDK, so it's your responsibility as the app developer to store it securely and consistently.
4242

docs/pages/agents/content-types/markdown.mdx

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,9 @@ The markdown content type supports the following formatting patterns:
7575
- `*italic text*` or `_italic text_`
7676
- `~~strikethrough text~~`
7777
- \`inline code\`
78+
- \`\`\`code block\`\`\`
79+
- > block quote
80+
- [link](https://www.example.com)
7881

7982
### Lists
8083

@@ -87,18 +90,6 @@ The markdown content type supports the following formatting patterns:
8790
- Standard markdown table syntax with `|` separators
8891
- Header rows with `---` separators
8992

90-
### Code blocks
91-
92-
- Fenced code blocks with triple backticks
93-
- Language-specific syntax highlighting
94-
- Inline code with single backticks
95-
96-
### Other elements
97-
98-
- Blockquotes with `>`
99-
- Horizontal rules with `---`
100-
- Links with `[text](url)`
101-
- Images with `![alt](url)`
10293

10394
### Example usage
10495

docs/pages/agents/get-started/build-an-agent.mdx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,9 +60,11 @@ await agent.start();
6060

6161
Each time you run your agent, XMTP creates local database files that must be **kept between restarts and between deployments**. Without persistent volumes, each restart creates a new installation and you're **limited to 10 installations per inbox**.
6262

63+
To learn more, see [Manage agent local database files and installations](/agents/build-agents/local-database).
64+
6365
:::
6466

65-
XMTP creates local database files in the `dbPath` (default is `'/'`) directory. These files store your device identity and message history. To learn more, see [Manage agent local database files and installations](/agents/build-agents/local-database).
67+
XMTP creates local database files in the `dbPath` (default is `'/'`) directory. These files store your device identity and message history.
6668

6769
### Set environment variables
6870

0 commit comments

Comments
 (0)