Skip to content

Commit 7a12096

Browse files
committed
Merge branch 'feat/client-lens' of https://github.com/mad-finance/eliza into develop
2 parents 7b98b5d + d90474d commit 7a12096

18 files changed

+2940
-42
lines changed

agent/package.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@ai16z/agent",
3-
"version": "0.1.5-alpha.5",
3+
"version": "0.1.5-alpha.6",
44
"main": "src/index.ts",
55
"type": "module",
66
"scripts": {
@@ -23,6 +23,7 @@
2323
"@ai16z/client-direct": "workspace:*",
2424
"@ai16z/client-discord": "workspace:*",
2525
"@ai16z/client-farcaster": "workspace:*",
26+
"@ai16z/client-lens": "workspace:*",
2627
"@ai16z/client-telegram": "workspace:*",
2728
"@ai16z/client-twitter": "workspace:*",
2829
"@ai16z/client-slack": "workspace:*",

agent/src/index.ts

+13-9
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { SqliteDatabaseAdapter } from "@ai16z/adapter-sqlite";
33
import { AutoClientInterface } from "@ai16z/client-auto";
44
import { DiscordClientInterface } from "@ai16z/client-discord";
55
import { FarcasterAgentClient } from "@ai16z/client-farcaster";
6+
import { LensAgentClient } from "@ai16z/client-lens";
67
import { SlackClientInterface } from "@ai16z/client-slack";
78
import { TelegramClientInterface } from "@ai16z/client-telegram";
89
import { TwitterClientInterface } from "@ai16z/client-twitter";
@@ -355,16 +356,14 @@ export async function initializeClients(
355356
}
356357

357358
if (clientTypes.includes(Clients.TWITTER)) {
358-
TwitterClientInterface.enableSearch = !isFalsish(
359-
getSecret(character, "TWITTER_SEARCH_ENABLE")
360-
);
361359
const twitterClient = await TwitterClientInterface.start(runtime);
362-
// TODO: This might be incorrect, please test if you are concerned about this functionality
363-
// By default we have disabled this because it is annoying for users
364-
(twitterClient as any).enableSearch = !isFalsish(
365-
getSecret(character, "TWITTER_SEARCH_ENABLE")
366-
);
367-
if (twitterClient) clients.twitter = twitterClient;
360+
361+
if (twitterClient) {
362+
clients.twitter = twitterClient;
363+
(twitterClient as any).enableSearch = !isFalsish(
364+
getSecret(character, "TWITTER_SEARCH_ENABLE")
365+
);
366+
}
368367
}
369368

370369
if (clientTypes.includes(Clients.FARCASTER)) {
@@ -375,6 +374,11 @@ export async function initializeClients(
375374
clients.farcaster = farcasterClient;
376375
}
377376
}
377+
if (clientTypes.includes("lens")) {
378+
const lensClient = new LensAgentClient(runtime);
379+
lensClient.start();
380+
clients.lens = lensClient;
381+
}
378382

379383
elizaLogger.log("client keys", Object.keys(clients));
380384

docs/api/type-aliases/Character.md

+14-2
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,18 @@ Optional prompt templates
108108

109109
> `optional` **farcasterShouldRespondTemplate**: `string`
110110
111+
### templates.lensPostTemplate?
112+
113+
> `optional` **lensPostTemplate**: `string`
114+
115+
### templates.lensMessageHandlerTemplate?
116+
117+
> `optional` **farcasterMessageHandlerTemplate**: `string`
118+
119+
### templates.lensShouldRespondTemplate?
120+
121+
> `optional` **lensShouldRespondTemplate**: `string`
122+
111123
### templates.telegramMessageHandlerTemplate?
112124

113125
> `optional` **telegramMessageHandlerTemplate**: `string`
@@ -202,7 +214,7 @@ Optional configuration
202214
203215
#### Index Signature
204216

205-
\[`key`: `string`\]: `string`
217+
\[`key`: `string`\]: `string`
206218

207219
### settings.intiface?
208220

@@ -264,7 +276,7 @@ New structured ElevenLabs config
264276
265277
#### Index Signature
266278

267-
\[`key`: `string`\]: `any`[]
279+
\[`key`: `string`\]: `any`[]
268280

269281
### settings.chains.evm?
270282

packages/client-lens/package.json

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
{
2+
"name": "@ai16z/client-lens",
3+
"version": "0.1.0",
4+
"main": "dist/index.js",
5+
"type": "module",
6+
"types": "dist/index.d.ts",
7+
"dependencies": {
8+
"@ai16z/eliza": "workspace:*",
9+
"@lens-protocol/client": "2.2.0",
10+
"@lens-protocol/metadata": "1.2.0",
11+
"axios": "^1.7.9",
12+
"viem": "^2.13.8"
13+
},
14+
"devDependencies": {
15+
"tsup": "^8.3.5"
16+
},
17+
"peerDependencies": {
18+
"@ai16z/eliza": "workspace:*"
19+
},
20+
"scripts": {
21+
"build": "tsup --format esm --dts",
22+
"dev": "tsup --format esm --dts --watch"
23+
}
24+
}

packages/client-lens/src/actions.ts

+51
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
import type { LensClient } from "./client";
2+
import {
3+
elizaLogger,
4+
type Content,
5+
type IAgentRuntime,
6+
type Memory,
7+
type UUID,
8+
} from "@ai16z/eliza";
9+
import { textOnly } from "@lens-protocol/metadata";
10+
import { createPublicationMemory } from "./memory";
11+
import { AnyPublicationFragment } from "@lens-protocol/client";
12+
import StorjProvider from "./providers/StorjProvider";
13+
14+
export async function sendPublication({
15+
client,
16+
runtime,
17+
content,
18+
roomId,
19+
commentOn,
20+
ipfs,
21+
}: {
22+
client: LensClient;
23+
runtime: IAgentRuntime;
24+
content: Content;
25+
roomId: UUID;
26+
commentOn?: string;
27+
ipfs: StorjProvider;
28+
}): Promise<{ memory?: Memory; publication?: AnyPublicationFragment }> {
29+
// TODO: arweave provider for content hosting
30+
const metadata = textOnly({ content: content.text });
31+
const contentURI = await ipfs.pinJson(metadata);
32+
33+
const publication = await client.createPublication(
34+
contentURI,
35+
false, // TODO: support collectable settings
36+
commentOn
37+
);
38+
39+
if (publication) {
40+
return {
41+
publication,
42+
memory: createPublicationMemory({
43+
roomId,
44+
runtime,
45+
publication: publication as AnyPublicationFragment,
46+
}),
47+
};
48+
}
49+
50+
return {};
51+
}

0 commit comments

Comments
 (0)