Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: XMTP #1441

Open
wants to merge 9 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions agent/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@
*.env
.env*
/data
/.data
/generatedImages
122 changes: 62 additions & 60 deletions agent/package.json
Original file line number Diff line number Diff line change
@@ -1,62 +1,64 @@
{
"name": "@elizaos/agent",
"version": "0.1.7-alpha.1",
"main": "src/index.ts",
"type": "module",
"scripts": {
"start": "node --loader ts-node/esm src/index.ts",
"dev": "node --loader ts-node/esm src/index.ts",
"check-types": "tsc --noEmit"
},
"nodemonConfig": {
"watch": [
"src",
"../core/dist"
],
"ext": "ts,json",
"exec": "node --enable-source-maps --loader ts-node/esm src/index.ts"
},
"dependencies": {
"@elizaos/adapter-postgres": "workspace:*",
"@elizaos/adapter-redis": "workspace:*",
"@elizaos/adapter-sqlite": "workspace:*",
"@elizaos/client-auto": "workspace:*",
"@elizaos/client-direct": "workspace:*",
"@elizaos/client-discord": "workspace:*",
"@elizaos/client-farcaster": "workspace:*",
"@elizaos/client-lens": "workspace:*",
"@elizaos/client-telegram": "workspace:*",
"@elizaos/client-twitter": "workspace:*",
"@elizaos/client-slack": "workspace:*",
"@elizaos/core": "workspace:*",
"@elizaos/plugin-0g": "workspace:*",
"@elizaos/plugin-aptos": "workspace:*",
"@elizaos/plugin-bootstrap": "workspace:*",
"@elizaos/plugin-intiface": "workspace:*",
"@elizaos/plugin-coinbase": "workspace:*",
"@elizaos/plugin-conflux": "workspace:*",
"@elizaos/plugin-evm": "workspace:*",
"@elizaos/plugin-flow": "workspace:*",
"@elizaos/plugin-story": "workspace:*",
"@elizaos/plugin-goat": "workspace:*",
"@elizaos/plugin-icp": "workspace:*",
"@elizaos/plugin-image-generation": "workspace:*",
"@elizaos/plugin-nft-generation": "workspace:*",
"@elizaos/plugin-node": "workspace:*",
"@elizaos/plugin-solana": "workspace:*",
"@elizaos/plugin-starknet": "workspace:*",
"@elizaos/plugin-ton": "workspace:*",
"@elizaos/plugin-sui": "workspace:*",
"@elizaos/plugin-tee": "workspace:*",
"@elizaos/plugin-multiversx": "workspace:*",
"@elizaos/plugin-near": "workspace:*",
"@elizaos/plugin-zksync-era": "workspace:*",
"readline": "1.3.0",
"ws": "8.18.0",
"yargs": "17.7.2"
},
"devDependencies": {
"ts-node": "10.9.2",
"tsup": "8.3.5"
}
"name": "@elizaos/agent",
"version": "0.1.7-alpha.1",
"main": "src/index.ts",
"type": "module",
"scripts": {
"start": "node --loader ts-node/esm src/index.ts",
"dev": "node --loader ts-node/esm src/index.ts",
"check-types": "tsc --noEmit"
},
"nodemonConfig": {
"watch": [
"src",
"../core/dist"
],
"ext": "ts,json",
"exec": "node --enable-source-maps --loader ts-node/esm src/index.ts"
},
"dependencies": {
"@elizaos/adapter-postgres": "workspace:*",
"@elizaos/adapter-redis": "workspace:*",
"@elizaos/adapter-sqlite": "workspace:*",
"@elizaos/client-auto": "workspace:*",
"@elizaos/client-direct": "workspace:*",
"@elizaos/client-discord": "workspace:*",
"@elizaos/client-farcaster": "workspace:*",
"@elizaos/client-lens": "workspace:*",
"@elizaos/client-telegram": "workspace:*",
"@elizaos/client-twitter": "workspace:*",
"@elizaos/client-slack": "workspace:*",
"@elizaos/client-xmtp": "workspace:*",
"@elizaos/core": "workspace:*",
"@elizaos/plugin-0g": "workspace:*",
"@elizaos/plugin-aptos": "workspace:*",
"@elizaos/plugin-bootstrap": "workspace:*",
"@elizaos/plugin-intiface": "workspace:*",
"@elizaos/plugin-coinbase": "workspace:*",
"@elizaos/plugin-conflux": "workspace:*",
"@elizaos/plugin-concierge": "workspace:*",
"@elizaos/plugin-evm": "workspace:*",
"@elizaos/plugin-flow": "workspace:*",
"@elizaos/plugin-story": "workspace:*",
"@elizaos/plugin-goat": "workspace:*",
"@elizaos/plugin-icp": "workspace:*",
"@elizaos/plugin-image-generation": "workspace:*",
"@elizaos/plugin-nft-generation": "workspace:*",
"@elizaos/plugin-node": "workspace:*",
"@elizaos/plugin-solana": "workspace:*",
"@elizaos/plugin-starknet": "workspace:*",
"@elizaos/plugin-ton": "workspace:*",
"@elizaos/plugin-sui": "workspace:*",
"@elizaos/plugin-tee": "workspace:*",
"@elizaos/plugin-multiversx": "workspace:*",
"@elizaos/plugin-near": "workspace:*",
"@elizaos/plugin-zksync-era": "workspace:*",
"readline": "1.3.0",
"ws": "8.18.0",
"yargs": "17.7.2"
},
"devDependencies": {
"ts-node": "10.9.2",
"tsup": "8.3.5"
}
}
8 changes: 7 additions & 1 deletion agent/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,15 @@ import { FarcasterAgentClient } from "@elizaos/client-farcaster";
import { LensAgentClient } from "@elizaos/client-lens";
import { SlackClientInterface } from "@elizaos/client-slack";
import { TelegramClientInterface } from "@elizaos/client-telegram";
import { XmtpClientInterface } from "@elizaos/client-xmtp";
import { TwitterClientInterface } from "@elizaos/client-twitter";
import { paymentagent as defaultCharacter } from "./paymentagent";
import {
AgentRuntime,
CacheManager,
Character,
Clients,
DbCacheAdapter,
defaultCharacter,
elizaLogger,
FsCacheAdapter,
IAgentRuntime,
Expand Down Expand Up @@ -383,6 +384,11 @@ export async function initializeClients(
if (telegramClient) clients.telegram = telegramClient;
}

if (clientTypes.includes(Clients.XMTP)) {
const xmtpClient = await XmtpClientInterface.start(runtime);
if (xmtpClient) clients.xmtp = xmtpClient;
}

if (clientTypes.includes(Clients.TWITTER)) {
const twitterClient = await TwitterClientInterface.start(runtime);

Expand Down
66 changes: 66 additions & 0 deletions docs/docs/advanced/e2ee.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
---
sidebar_position: 18
---

# End-to-end encrypted messaging

AI is transforming consumer tech, with messaging becoming the main channel for interacting with agent services. This shift will scale message traffic astronomically, analogous to the web’s rise in the 2000s. Just as Cloudflare and https secured web traffic, messaging will need robust scalable end-to-end encrypted messages to protect sensitive information.

## Risks

Risks of not using end-to-end encryption for agent interactions exposes the users to what is called as Man in the **Middle Attacks**.

> **Man in the Middle Attacks**: Intercept requests in between to alter or manipulate data sent or received by the AI service

- **Phishing**: Messages can be intercepted and manipulated.
- **Privacy**: Sensitive information read by unwanted parties
- **Tampering**: Content can be altered without detection.

:::tip
More concrete sensitive data could include credit card details, private keys and passwords which is not yet widely spread but as agents become smarter more use cases will include this type of sharing.
:::

## XMTP

Eliza agents come with a ready to use client that uses XMTP providing end-to-end encrypted messaging for every agent intereaction, crucial for privacy, security, and compliance provided by the XMTP network.

### Features:

- **E2EE**: End to end encrypted MLS encryption
- **Multi-agent**: Support multi-agent through group chats
- **Interoperable**: Works across all platforms and frontends
- **Scalable**: Decentralized, open-source
- **Anonymous**: By default every identity is ephemeral and anonymous.

### Installation

Install the `xmtp` package

```bash [cmd]
bun install xmtp
```

### Usage

This is how you can use the `xmtp` package to create an agent and handle messages.

- `WALLET_PRIVATE_KEY`: This will encrypt all messages and make it available through its public address or ens domain.

```tsx
import { XMTP } from "xmtp";

const xmtp = new XMTP(onMessage, {
encryptionKey: WALLET_PRIVATE_KEY,
});
await xmtp.init();
const onMessage = async (message, user) => {
console.log(`Decoded message: ${message.content.text} by ${user.address}`);
// Your AI model response
await xmtp.send({
message: response,
originalMessage: message,
});
};
```

For more information visit XMTP [website](https://xmtp.org/)
1 change: 1 addition & 0 deletions docs/docs/guides/advanced.md
Original file line number Diff line number Diff line change
Expand Up @@ -402,3 +402,4 @@ debug("Detailed operation info: %O", {
- [Autonomous Trading Guide](../advanced/autonomous-trading.md) for trading features
- [Fine-tuning Guide](../advanced/fine-tuning.md) for model optimization
- [Eliza in TEE](../advanced/eliza-in-tee.md) for TEE integration
- [Secure messaging](../advanced/eliza-in-tee.md) for E2EE XMTP integration
5 changes: 5 additions & 0 deletions docs/docs/packages/agent.md
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,11 @@ export async function initializeClients(
if (clientTypes.includes(Clients.TELEGRAM)) {
clients.push(await TelegramClientInterface.start(runtime));
}

if (clientTypes.includes(Clients.XMTP)) {
clients.push(await Xmtp.start(runtime));
}

if (clientTypes.includes(Clients.TWITTER)) {
clients.push(await TwitterClientInterface.start(runtime));
}
Expand Down
Loading
Loading