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

E2ee #168

Merged
merged 8 commits into from
Dec 28, 2024
Merged

E2ee #168

Changes from all 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
2 changes: 0 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -2,8 +2,6 @@

A set of tools for AI developers to build on top of [XMTP](https://xmtp.org)

## What's inside?

### MessageKit

- [`message-kit`](/packages/message-kit): A kit for quickly building messaging apps
7 changes: 0 additions & 7 deletions community/plugins.json
Original file line number Diff line number Diff line change
@@ -90,13 +90,6 @@
"icon": "📒",
"author": "humanagent"
},
{
"href": "/plugins/xmtp",
"title": "xmtp",
"description": "Use Xmtp to send E2EE messages.",
"icon": "💬",
"author": "ephemeraHQ"
},
{
"href": "/plugins/xmtp-groups",
"title": "Xmtp Groups",
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -32,6 +32,7 @@
"templates": "node scripts/devTemplates.js",
"test": "FORCE_COLOR=1 turbo run test --force --concurrency=1",
"test:client": "cd packages/xmtp/tests && yarn test:client",
"test:e2e": "cd packages/xmtp/tests && yarn test:e2e",
"test:flow": "cd packages/message-kit/tests && yarn test:flow",
"test:intent": "cd packages/message-kit/tests && yarn test:intent",
"test:links": "cd packages/message-kit/tests && yarn test:links",
13 changes: 9 additions & 4 deletions packages/client/src/components/Chat.module.css
Original file line number Diff line number Diff line change
@@ -169,16 +169,13 @@
}

.urlContainer {
margin: 8px 0;
display: flex;
flex-direction: column;
gap: 8px;
border-radius: 8px 8px 0 0;
max-width: 300px;
background: #e0e0e0;
}

.urlPreview {
border-radius: 8px 8px 0 0;
overflow: hidden;
background: #ffffff;
border: 1px solid #b0b0b0;
@@ -231,3 +228,11 @@
color: var(--accent);
font-size: 0.9rem;
}
.encryptionInfo {
text-align: center !important;
width: 100%;
font-size: 0.7rem;
padding: 0rem;
padding-top: 0.4rem;
display: block !important;
}
17 changes: 9 additions & 8 deletions packages/client/src/components/Chat.tsx
Original file line number Diff line number Diff line change
@@ -37,8 +37,6 @@ function Chat({ user }: { user: UserInfo }) {
const [processedMessageIds] = useState(new Set<string>());

useEffect(() => {
console.log("useEffect triggered with user:", user);

const init = async () => {
try {
setRecipientInfo(user);
@@ -64,7 +62,6 @@ function Chat({ user }: { user: UserInfo }) {

const onMessage = async (message: Message | undefined) => {
if (message) {
console.log("onMessage", message);
setMessages((prevMessages) => [...prevMessages, message]);
}
};
@@ -88,7 +85,6 @@ function Chat({ user }: { user: UserInfo }) {
receivers: [recipientInfo.address],
originalMessage: undefined,
})) as Message;
console.log("message", message);

setMessages((prevMessages) => [...prevMessages, message]);
setNewMessage("");
@@ -144,17 +140,19 @@ function Chat({ user }: { user: UserInfo }) {
if (urlRegex.test(part)) {
try {
const urlType = getUrlType(part);
const isMessageKitUrl = part.includes("message-kit.org");

const isMessageKitUrl =
part.includes("message-kit.org") ||
part.includes("baselinks.vercel.app");
const isMobile = window.innerWidth < 768;
return (
<div key={index} className={styles.urlContainer}>
{isMessageKitUrl && <UrlPreview url={part} urlType={urlType} />}
{isMessageKitUrl && <UrlPreview url={part} />}
<div className={styles.buttonContainer}>
{urlType === "payment" && (
<button
onClick={() => {
const ethUrl = ethereumURL(part);
openUrl(ethUrl);
isMobile ? openUrl(ethUrl) : alert("Not on mobile");
}}
className={styles.urlButton}>
Pay in USDC
@@ -248,6 +246,9 @@ function Chat({ user }: { user: UserInfo }) {
Send
</button>
</div>
<div className={styles.encryptionInfo}>
End-to-end encrypted powered by XMTP
</div>
</form>
</div>
);
8 changes: 1 addition & 7 deletions packages/client/src/components/UrlPreview.tsx
Original file line number Diff line number Diff line change
@@ -8,13 +8,7 @@ interface OgData {
url?: string;
}

export const UrlPreview = ({
url,
urlType,
}: {
url: string;
urlType?: string;
}) => {
export const UrlPreview = ({ url }: { url: string; urlType?: string }) => {
const [ogData, setOgData] = useState<OgData | null>(null);
const [loading, setLoading] = useState(true);

2 changes: 1 addition & 1 deletion packages/create-message-kit/package.json
Original file line number Diff line number Diff line change
@@ -36,4 +36,4 @@
"access": "public",
"registry": "https://registry.npmjs.org/"
}
}
}
2 changes: 1 addition & 1 deletion packages/docs/pages/concepts/xmtp.mdx
Original file line number Diff line number Diff line change
@@ -2,7 +2,7 @@

[XMTP](https://xmtp.org/) is the protocol that MessageKit uses to send and receive messages.

> Check out the [XMTP AI](/plugins/xmtp) plugins for more information.
> Check out the [xmtp e2ee](https://docs-xmtp-org-git-agents-ephemerahq.vercel.app/agents/pluginxmtp) plugins for more information.

## Context

177 changes: 0 additions & 177 deletions packages/docs/pages/plugins/xmtp.mdx

This file was deleted.

2 changes: 1 addition & 1 deletion packages/xmtp-e2ee/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# XMTP

> See [XMTP AI](https://message-kit.org/plugins/xmtp) plugin
> See [xmtp e2ee](https://docs-xmtp-org-git-agents-ephemerahq.vercel.app/agents/plugins) plugins

### Installation

4 changes: 2 additions & 2 deletions packages/xmtp-e2ee/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "xmtp-e2ee",
"version": "0.0.8",
"version": "0.0.9",
"license": "MIT",
"type": "module",
"exports": {
@@ -61,4 +61,4 @@
"access": "public",
"registry": "https://registry.npmjs.org/"
}
}
}
3 changes: 2 additions & 1 deletion packages/xmtp-e2ee/src/lib/xmtp.ts
Original file line number Diff line number Diff line change
@@ -237,7 +237,8 @@ async function streamMessages(
while (true) {
try {
const stream = await client.conversations.streamAllMessages();
console.log(`Stream started`);
console.log(`XMTP: [v2] Stream started`);

for await (const message of stream) {
if (message) {
try {
2 changes: 1 addition & 1 deletion packages/xmtp/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# XMTP

> See [XMTP AI](https://message-kit.org/plugins/xmtp) plugin
> See [xmtp e2ee](https://docs-xmtp-org-git-agents-ephemerahq.vercel.app/agents/plugins) plugin

### Installation

7 changes: 4 additions & 3 deletions packages/xmtp/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "xmtp",
"version": "0.0.8",
"version": "0.0.9",
"license": "MIT",
"type": "module",
"exports": {
@@ -22,7 +22,8 @@
"clean": "rm -rf .turbo && rm -rf node_modules && rm -rf dist",
"publish": "npm publish",
"test": "yarn build && vitest",
"test:client": "vitest run tests/client"
"test:client": "vitest run tests/client",
"test:e2e": "vitest run tests/encryption"
},
"dependencies": {
"@changesets/changelog-git": "^0.2.0",
@@ -59,4 +60,4 @@
"access": "public",
"registry": "https://registry.npmjs.org/"
}
}
}
Loading

Unchanged files with check annotations Beta

export function findSkill(text: string, skills: Skill[][]): Skill | undefined {
const trigger = text.split(" ")[0].toLowerCase();
const handler = skills.flat().find((skill) => {

Check failure on line 11 in packages/message-kit/src/lib/skills.ts

GitHub Actions / test

tests/Parsing.test.ts > Parsing tests > Compare extracted values from skill: /check vitalik.eth

TypeError: Cannot read properties of undefined (reading 'flat') ❯ Module.findSkill src/lib/skills.ts:11:26 ❯ tests/Parsing.test.ts:53:27

Check failure on line 11 in packages/message-kit/src/lib/skills.ts

GitHub Actions / test

tests/Parsing.test.ts > Parsing tests > Compare extracted values from skill: /register vitalik.eth

TypeError: Cannot read properties of undefined (reading 'flat') ❯ Module.findSkill src/lib/skills.ts:11:26 ❯ tests/Parsing.test.ts:53:27

Check failure on line 11 in packages/message-kit/src/lib/skills.ts

GitHub Actions / test

tests/Parsing.test.ts > Parsing tests > Compare extracted values from skill: /cool vitalik.eth

TypeError: Cannot read properties of undefined (reading 'flat') ❯ Module.findSkill src/lib/skills.ts:11:26 ❯ tests/Parsing.test.ts:53:27

Check failure on line 11 in packages/message-kit/src/lib/skills.ts

GitHub Actions / test

tests/Parsing.test.ts > Parsing tests > Compare extracted values from skill: /renew vitalik.eth

TypeError: Cannot read properties of undefined (reading 'flat') ❯ Module.findSkill src/lib/skills.ts:11:26 ❯ tests/Parsing.test.ts:53:27

Check failure on line 11 in packages/message-kit/src/lib/skills.ts

GitHub Actions / test

tests/Parsing.test.ts > Parsing tests > Compare extracted values from skill: /info vitalik.eth

TypeError: Cannot read properties of undefined (reading 'flat') ❯ Module.findSkill src/lib/skills.ts:11:26 ❯ tests/Parsing.test.ts:53:27

Check failure on line 11 in packages/message-kit/src/lib/skills.ts

GitHub Actions / test

tests/Parsing.test.ts > Parsing tests > Compare extracted values from skill: /pay vitalik.eth

TypeError: Cannot read properties of undefined (reading 'flat') ❯ Module.findSkill src/lib/skills.ts:11:26 ❯ tests/Parsing.test.ts:53:27
return (
"/" + skill.skill?.replace("/", "").split(" ")[0].toLowerCase() ===
trigger
describe("Flow Tests", async () => {
afterEach(() => {
console.log("chatMemory", chatMemory.getHistory(memoryKey).length);

Check failure on line 18 in packages/message-kit/tests/Intent.test.ts

GitHub Actions / test

tests/Intent.test.ts > Flow Tests > Ask who holds vitalik.eth

TypeError: Cannot read properties of undefined (reading 'length') ❯ tests/Intent.test.ts:18:62

Check failure on line 18 in packages/message-kit/tests/Intent.test.ts

GitHub Actions / test

tests/Intent.test.ts > Flow Tests > Step 1: Tip vitalik.eth

TypeError: Cannot read properties of undefined (reading 'length') ❯ tests/Intent.test.ts:18:62

Check failure on line 18 in packages/message-kit/tests/Intent.test.ts

GitHub Actions / test

tests/Intent.test.ts > Flow Tests > Step 2: again

TypeError: Cannot read properties of undefined (reading 'length') ❯ tests/Intent.test.ts:18:62

Check failure on line 18 in packages/message-kit/tests/Intent.test.ts

GitHub Actions / test

tests/Intent.test.ts > Flow Tests > Step 3: Tip vitalik.eth again

TypeError: Cannot read properties of undefined (reading 'length') ❯ tests/Intent.test.ts:18:62

Check failure on line 18 in packages/message-kit/tests/Intent.test.ts

GitHub Actions / test

tests/Intent.test.ts > Flow Tests > Step 4: Tip it again

TypeError: Cannot read properties of undefined (reading 'length') ❯ tests/Intent.test.ts:18:62
});
afterAll(() => {
console.log("chatMemory", chatMemory.getHistory(memoryKey));
// @ts-ignore
const { reply } = await agentReply(mockReply);
chatMemory.addEntry(mockReply.getMemoryKey(), reply, "assistant");
expect(reply).toContain("/info vitalik.eth");

Check failure on line 29 in packages/message-kit/tests/Intent.test.ts

GitHub Actions / test

tests/Intent.test.ts > Flow Tests > Ask who holds vitalik.eth

AssertionError: expected 'An error occurred while processing yo…' to contain '/info vitalik.eth' Expected: "/info vitalik.eth" Received: "An error occurred while processing your request." ❯ tests/Intent.test.ts:29:19
});
const prompts = [
// @ts-ignore
const { reply } = await agentReply(mockReply);
chatMemory.addEntry(mockReply.getMemoryKey(), reply, "assistant");
expect(reply).toContain("/tip vitalik.eth");

Check failure on line 53 in packages/message-kit/tests/Intent.test.ts

GitHub Actions / test

tests/Intent.test.ts > Flow Tests > Step 1: Tip vitalik.eth

AssertionError: expected 'An error occurred while processing yo…' to contain '/tip vitalik.eth' Expected: "/tip vitalik.eth" Received: "An error occurred while processing your request." ❯ tests/Intent.test.ts:53:23

Check failure on line 53 in packages/message-kit/tests/Intent.test.ts

GitHub Actions / test

tests/Intent.test.ts > Flow Tests > Step 2: again

AssertionError: expected 'An error occurred while processing yo…' to contain '/tip vitalik.eth' Expected: "/tip vitalik.eth" Received: "An error occurred while processing your request." ❯ tests/Intent.test.ts:53:23

Check failure on line 53 in packages/message-kit/tests/Intent.test.ts

GitHub Actions / test

tests/Intent.test.ts > Flow Tests > Step 3: Tip vitalik.eth again

AssertionError: expected 'An error occurred while processing yo…' to contain '/tip vitalik.eth' Expected: "/tip vitalik.eth" Received: "An error occurred while processing your request." ❯ tests/Intent.test.ts:53:23

Check failure on line 53 in packages/message-kit/tests/Intent.test.ts

GitHub Actions / test

tests/Intent.test.ts > Flow Tests > Step 4: Tip it again

AssertionError: expected 'An error occurred while processing yo…' to contain '/tip vitalik.eth' Expected: "/tip vitalik.eth" Received: "An error occurred while processing your request." ❯ tests/Intent.test.ts:53:23
},
);
}