Skip to content

Commit 2cdcdbd

Browse files
authored
Merge pull request #4 from ephemeraHQ/readme_polish
Documentation improvements
2 parents 78bc03f + d9a99f1 commit 2cdcdbd

22 files changed

+242
-312
lines changed

CODE_OF_CONDUCT.md

+27
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,33 @@ Instances of abusive, harassing, or otherwise unacceptable behavior can be repor
3838

3939
Community moderators who do not follow or enforce the code of conduct in good faith may face temporary or permanent repercussions as determined by other community moderators.
4040

41+
## Guidelines for agents
42+
43+
Agents are a framework for building AI agents that work seamlessly within the Converse Messenger platform built with XMTP.
44+
45+
Today, agents can easily become untrustworthy members of group chats. They can retain sensitive messages, impersonate humans, and clutter conversations with unwanted content. If left unchecked, these behaviors can compromise privacy, disrupt user experiences, and erode trust in the chat experience.
46+
47+
To ensure safe, private, and trustworthy chat experiences, agents follow a set of trusted principles that determine how they can behave in group conversations with the goal of protecting users and ensuring the long-term health of the XMTP ecosystem.
48+
49+
These principles create a safe foundation that we may thoughtfully expand over time as security and privacy features evolve.
50+
51+
### The trusted principles
52+
53+
Agents built with XMTP follow the trusted principles detailed here. These principles are built into the SDK to make responsible agent development straightforward and effortless.
54+
55+
- **Agents should't read messages in groups** and can only read explicit calls, such as `/help` or `@bot`. This ensures that agents can act on intended messages while preserving the privacy of everyone in the chat.
56+
- **Agents can't send unprompted messages** and can only send messages in response to explicit calls. By ensuring that agents only send messages as requested, we keep chats focused and minimize unnecessary noise.
57+
- **Agents can't join chats as members**: Agents can't _join_ chats and can only be _connected_ to a chat by a human member. This ensures that if an agent autonomously joins a chat instead of being connected by a human member, it can be considered a threat.
58+
- **Agents must identify as agents in chats**, both _visually_ and _programmatically_. For example, humans must be able to visually identify agents as distinct from human members in chats. If an agent appears as a human member, it can be considered a threat.
59+
60+
### For everyone and for the long-term
61+
62+
We understand that these principles upheld by XMTP may seem restrictive and could limit some of the more engaging or interactive agent features developers might want to implement. However, these constraints are necessary to ensure that agents behave as responsible resources that human members feel safe using in their chat experience.
63+
64+
While malicious developers could find ways to circumvent these trusted principles in the short term, let's work together to build a secure, private, and trustworthy messaging ecosystem for everyone and for the long term.
65+
66+
By building agents that uphold these principles, you help set a standard for trust in group chat experiences, ensuring that agents remain a helpful, not harmful, part of the conversation.
67+
4168
## Attribution
4269

4370
The XMTP code of conduct is adapted from the Contributor Covenant, [version 2.1](https://www.contributor-covenant.org/version/2/1/code_of_conduct.html) and [version 1.4](https://www.contributor-covenant.org/version/1/4/code-of-conduct.html).

GUIDELINES.md

-26
This file was deleted.

README.md

+56-61
Original file line numberDiff line numberDiff line change
@@ -2,27 +2,27 @@
22

33
[![GitHub release](https://img.shields.io/github/release/ephemerahq/xmtp-agents.svg)](https://github.com/huggingface/smolagents/releases)
44
[![MIT License](https://img.shields.io/github/license/ephemerahq/xmtp-agents)](https://github.com/ephemerahq/xmtp-agents/blob/main/LICENSE)
5-
[![Number of GitHub stars](https://img.shields.io/github/stars/ephemerahq/message-kit?logo=github)](https://github.com/ephemerahq/message-kit)
65

76
<img src="media/logo.png" alt="Logo" width="60" />
87

98
# xmtp-agents
109

1110
</div>
1211

13-
`xmtp-agents` is a library for building secure, and interoperable agents that use the [XMTP](https://xmtp.org/) protocol.
12+
[`@xmtp/agent-starter`](https://github.com/ephemeraHQ/xmtp-agents/tree/main/packages/agent-starter).
13+
is a library for building agents that communicate in a secure and interoperable way over the [XMTP](https://xmtp.org/) network.
1414

1515
#### Why XMTP?
1616

17-
- **End-to-end & compliant**: Servers and clients only see ciphertext, meeting strict security and regulatory standards.
17+
- **End-to-end & compliant**: The server only sees ciphertext, meeting strict security and regulatory standards.
1818
- **Open-source & trustless**: Built on top of the [MLS](https://messaginglayersecurity.rocks/) protocol, it replaces trust in centralized certificate authorities with cryptographic proofs.
19-
- **Privacy & metadata protection**: Offers anonymous or pseudonymous usage with no tracking of timestamps, routes, IPs, or device info.
19+
- **Privacy & metadata protection**: Offers anonymous or pseudonymous usage with no tracking of sender routes, IPs, or device and message timestamps.
2020
- **Decentralized**: Operates on a peer-to-peer network, eliminating single points of failure.
21-
- **Groups**: Allows multi-agent (or multi-human) or both with group chats with access control and secure collaboration.
21+
- **Multi-tenant**: Allows multi-agent multi-human confidential communication over MLS group chats.
2222

23-
## Setup
23+
> See [FAQ](https://docs.xmtp.org/intro/faq) for more detailed information.
2424
25-
This library is based on [`@xmtp/agent-starter`](https://github.com/ephemeraHQ/xmtp-agents/tree/main/packages/agent-starter).
25+
## Setup
2626

2727
```bash
2828
yarn add @xmtp/agent-starter
@@ -33,8 +33,8 @@ yarn add @xmtp/agent-starter
3333
To run your XMTP agent, you need two keys:
3434

3535
```bash
36-
ENCRYPTION_KEY= # the private key of the wallet
37-
FIXED_KEY= # a second encryption key for encryption (can be random)
36+
WALLET_KEY= # the private key of the wallet
37+
ENCRYPTION_KEY= # a second random 32 bytes encryption key for local db encryptioney for encryption (can be random)
3838
```
3939

4040
> See [encryption keys](https://github.com/ephemeraHQ/xmtp-agents/tree/main/packages/agent-starter/README.md#encryption-keys) to learn more.
@@ -43,57 +43,59 @@ FIXED_KEY= # a second encryption key for encryption (can be random)
4343

4444
These are the steps to initialize the XMTP listener and send messages.
4545

46-
- `ENCRYPTION_KEY`: The private key of the wallet that will be used to send or receive messages.
46+
- `WALLET_KEY`: The private key of the wallet that will be used to send or receive messages.
4747

4848
```tsx
4949
import { xmtpClient } from "@xmtp/agent-starter";
5050

5151
async function main() {
52-
const agent = await xmtpClient({
53-
encryptionKey: process.env.ENCRYPTION_KEY as string,
52+
const client = await xmtpClient({
53+
walletKey: process.env.WALLET_KEY as string,
5454
onMessage: async (message: Message) => {
55-
console.log(`Decoded message: ${message.content.text}`);
56-
console.log(`from ${message.sender.address}`)
55+
console.log(`Decoded message: ${message.content.text} from ${message.sender.address}`)
5756

5857
// Your AI model response
5958
const response = await api("Hi, how are you?");
6059

6160
//Send text message
62-
await agent.send({
61+
await client.send({
6362
message: response,
6463
originalMessage: message,
6564
});
6665
};
6766
});
6867

69-
console.log("Agent is up and running on address " + agent.address);
68+
console.log("XMTP client is up and running on address " + client.address);
7069
}
7170

7271
main().catch(console.error);
7372
```
7473

7574
#### Address availability
7675

77-
Returns `true` if an address has XMTP enabled
76+
Returns `true` if an address is reachable on the xmtp network
7877

7978
```typescript
80-
const isOnXMTP = await agent.canMessage(address);
79+
const isOnXMTP = await client.canMessage(address);
8180
```
8281

8382
## Examples
8483

8584
Various examples and tutorials to help you get started with creating and deploying your own agents using XMTP.
8685

8786
- [gated-group](/examples/gated-group/): Create a gated group chat that verifies NFT ownership using Alchemy.
88-
- [gm](/examples/gm/): A simple agent that replies with "GM".
87+
- [gm](/examples/gm/): A simple agent that replies with `gm`.
8988
- [gpt](/examples/gpt): A simple agent that interacts with OpenAI APIs.
9089
- [express](/examples/express/): Communicate with traditional APIs using xmtp e2ee
9190

9291
> See all the available [examples](/examples/).
9392
9493
## Deployment
9594

96-
Learn how to deploy with [Railway](/examples/railway/) or [Replit](/examples/replit/)
95+
Learn how to deploy with:
96+
97+
- [Railway](/examples/railway/)
98+
- [Replit](/examples/replit/)
9799

98100
## Groups
99101

@@ -103,7 +105,7 @@ Learn how to deploy with [Railway](/examples/railway/) or [Replit](/examples/rep
103105
To create a group from your agent, you can use the following code:
104106

105107
```tsx
106-
const group = await agent?.conversations.newGroup([address1, address2]);
108+
const group = await client?.conversations.newGroup([address1, address2]);
107109
```
108110

109111
As an admin you can add members to the group.
@@ -115,7 +117,7 @@ await group.sync();
115117
await group.addMembers([0xaddresses]);
116118
```
117119

118-
> To learn more about groups, read the [XMTP documentation](https://docs.agent.org/inboxes/group-permissions).
120+
> To learn more about groups, read the [XMTP documentation](https://docs.xmtp.org).
119121
120122
## Message handling
121123

@@ -131,60 +133,52 @@ const onMessage = async (message: Message) => {
131133
`Decoded message: ${message.content.text} from ${message.sender.address}`,
132134
);
133135

134-
let typeId = message.typeId;
135-
136-
if (typeId === "text") {
137-
// Do something with the text
138-
} else if (typeId === "reaction") {
139-
// Do something with the reaction
140-
} else if (typeId === "reply") {
141-
// Do something with the `reply`
142-
} else if (typeId === "attachment") {
143-
// Do something with the attachment data url
144-
} else if (typeId === "agent_message") {
145-
// Do something with the agent message
146-
} else if (typeId === "group_updated") {
147-
// Do something with the group updated metadata
148-
}
136+
// Your logic
149137
};
150138
```
151139

152140
### Sending messages
153141

154-
Use `agent.send()` for different message types.
142+
When you build an app with XMTP, all messages are encoded with a content type to ensure that an XMTP client knows how to encode and decode messages, ensuring interoperability and consistent display of messages across apps.
155143

156-
#### Text messages
144+
### Text
145+
146+
Sends a text message.
157147

158148
```tsx
159-
await agent.send({
160-
message: "Hello from xmtp-agents!",
149+
let textMessage: clientMessage = {
150+
message: "Your message.",
161151
receivers: ["0x123..."], // optional
162152
originalMessage: message, // optional
163-
});
153+
};
154+
await client.send(textMessage);
164155
```
165156

166-
#### Agent messages
157+
### Agent message
167158

168-
Agent messages can contain metadata, enabling structured communication between agents:
159+
Allows to send structured metadata over the network that is displayed as plain-text in ecosystem inboxes.
169160

170161
```tsx
171-
await agent.send({
172-
message: "Transaction request",
162+
let clientMessage: clientMessage = {
163+
message: "Would you like to approve this transaction?",
173164
metadata: {
174165
amount: "10",
175166
token: "USDC",
176167
},
177-
receivers: ["0x123..."],
178-
originalMessage: message,
168+
receivers: ["0x123..."], // optional
169+
originalMessage: message, // optional
179170
typeId: "agent_message",
180-
});
171+
};
172+
await client.send(clientMessage);
181173
```
182174

175+
> See [content-types](https://github.com/xmtp/xmtp-js/tree/main/content-types/content-type-reaction) for reference
176+
183177
## Web inbox
184178

185179
Interact with the XMTP protocol using [xmtp.chat](https://xmtp.chat) the official web inbox for developers using the latest version powered by MLS.
186180

187-
![alt text](/media/chat.png)
181+
![](/media/chat.png)
188182

189183
> [!WARNING]
190184
> This React app isn't a complete solution. For example, the list of conversations doesn't update when new messages arrive in existing conversations.
@@ -198,18 +192,19 @@ import { lookup } from "@xmtp/lookup";
198192

199193
const identifier = "vitalik.eth";
200194
const info = await lookup(identifier);
195+
```
196+
197+
Result:
201198

202-
console.log(info);
203-
/*
199+
```json
204200
{
205-
ensDomain: 'vitalik.eth',
206-
address: '0x1234...',
207-
preferredName: 'vitalik.eth',
208-
converseUsername: '',
209-
avatar: 'https://...',
210-
converseEndpoint: 'https://converse.xyz/...'
201+
"ensDomain": "vitalik.eth",
202+
"address": "0x1234...",
203+
"preferredName": "vitalik.eth",
204+
"converseUsername": "",
205+
"avatar": "https://...",
206+
"converseDeeplink": "https://converse.xyz/dm/..."
211207
}
212-
*/
213208
```
214209

215210
> Learn more about [`lookup`](/packages/lookup/) library
@@ -234,6 +229,6 @@ yarn examples gm
234229
Use a `.env` file for your environment variables:
235230

236231
```bash
237-
ENCRYPTION_KEY= # the private key of the wallet
238-
FIXED_KEY= # a second encryption key for encryption (can be random)
232+
WALLET_KEY= # the private key of the wallet
233+
ENCRYPTION_KEY= # a second random 32 bytes encryption key for local db encryptioney for encryption (can be random)
239234
```

0 commit comments

Comments
 (0)