@elizaos/plugin-twitter 1.2.12 → 1.2.14
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +93 -37
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -6460,6 +6460,15 @@ Response (YES/NO):`;
|
|
|
6460
6460
|
}
|
|
6461
6461
|
});
|
|
6462
6462
|
const roomId = createUniqueUuid2(this.runtime, conversationId);
|
|
6463
|
+
await this.runtime.ensureRoomExists({
|
|
6464
|
+
id: roomId,
|
|
6465
|
+
name: `Twitter conversation ${conversationId}`,
|
|
6466
|
+
source: "twitter",
|
|
6467
|
+
type: ChannelType.FEED,
|
|
6468
|
+
channelId: conversationId,
|
|
6469
|
+
serverId: userId,
|
|
6470
|
+
worldId
|
|
6471
|
+
});
|
|
6463
6472
|
const entityId = createUniqueUuid2(this.runtime, userId);
|
|
6464
6473
|
await this.runtime.ensureConnection({
|
|
6465
6474
|
entityId,
|
|
@@ -6617,6 +6626,15 @@ Response (YES/NO):`;
|
|
|
6617
6626
|
type: ChannelType.FEED,
|
|
6618
6627
|
worldId
|
|
6619
6628
|
});
|
|
6629
|
+
await this.runtime.ensureRoomExists({
|
|
6630
|
+
id: roomId,
|
|
6631
|
+
name: `Twitter conversation ${conversationId}`,
|
|
6632
|
+
source: "twitter",
|
|
6633
|
+
type: ChannelType.FEED,
|
|
6634
|
+
channelId: conversationId,
|
|
6635
|
+
serverId: userId,
|
|
6636
|
+
worldId
|
|
6637
|
+
});
|
|
6620
6638
|
const memory = {
|
|
6621
6639
|
id: tweetId,
|
|
6622
6640
|
entityId,
|
|
@@ -6894,6 +6912,7 @@ Response (YES/NO):`;
|
|
|
6894
6912
|
|
|
6895
6913
|
// src/post.ts
|
|
6896
6914
|
import {
|
|
6915
|
+
ChannelType as ChannelType2,
|
|
6897
6916
|
createUniqueUuid as createUniqueUuid3,
|
|
6898
6917
|
logger as logger4,
|
|
6899
6918
|
ModelType as ModelType2
|
|
@@ -6944,9 +6963,14 @@ var TwitterPostClient = class {
|
|
|
6944
6963
|
);
|
|
6945
6964
|
const interval = postIntervalMinutes * 60 * 1e3;
|
|
6946
6965
|
logger4.info(`Next tweet scheduled in ${postIntervalMinutes} minutes`);
|
|
6966
|
+
await new Promise((resolve) => setTimeout(resolve, interval));
|
|
6967
|
+
if (!this.isRunning) {
|
|
6968
|
+
logger4.log("Twitter post client stopped during wait, exiting loop");
|
|
6969
|
+
return;
|
|
6970
|
+
}
|
|
6947
6971
|
await this.generateNewTweet();
|
|
6948
6972
|
if (this.isRunning) {
|
|
6949
|
-
|
|
6973
|
+
generateNewTweetLoop();
|
|
6950
6974
|
}
|
|
6951
6975
|
};
|
|
6952
6976
|
await new Promise((resolve) => setTimeout(resolve, 1e3));
|
|
@@ -6987,6 +7011,13 @@ var TwitterPostClient = class {
|
|
|
6987
7011
|
roomId,
|
|
6988
7012
|
content: { text: "", type: "post" },
|
|
6989
7013
|
createdAt: Date.now()
|
|
7014
|
+
}).catch((error) => {
|
|
7015
|
+
logger4.warn("Error composing state, using minimal state:", error);
|
|
7016
|
+
return {
|
|
7017
|
+
agentId: this.runtime.agentId,
|
|
7018
|
+
recentMemories: [],
|
|
7019
|
+
values: {}
|
|
7020
|
+
};
|
|
6990
7021
|
});
|
|
6991
7022
|
const tweetPrompt = `You are ${this.runtime.character.name}.
|
|
6992
7023
|
${this.runtime.character.bio}
|
|
@@ -7077,7 +7108,40 @@ Generate a single tweet that sounds like YOU would actually write it:`;
|
|
|
7077
7108
|
logger4.info(`Tweet posted successfully! ID: ${tweetId}`);
|
|
7078
7109
|
if (result) {
|
|
7079
7110
|
const postedTweetId = createUniqueUuid3(this.runtime, tweetId);
|
|
7080
|
-
|
|
7111
|
+
await this.runtime.ensureWorldExists({
|
|
7112
|
+
id: worldId,
|
|
7113
|
+
name: `${this.client.profile?.username}'s Twitter`,
|
|
7114
|
+
agentId: this.runtime.agentId,
|
|
7115
|
+
serverId: userId
|
|
7116
|
+
});
|
|
7117
|
+
await this.runtime.ensureRoomExists({
|
|
7118
|
+
id: roomId,
|
|
7119
|
+
name: `${this.client.profile?.username}'s Timeline`,
|
|
7120
|
+
source: "twitter",
|
|
7121
|
+
type: ChannelType2.FEED,
|
|
7122
|
+
channelId: `${userId}-home`,
|
|
7123
|
+
serverId: userId,
|
|
7124
|
+
worldId
|
|
7125
|
+
});
|
|
7126
|
+
const postedMemory = {
|
|
7127
|
+
id: postedTweetId,
|
|
7128
|
+
entityId: this.runtime.agentId,
|
|
7129
|
+
agentId: this.runtime.agentId,
|
|
7130
|
+
roomId,
|
|
7131
|
+
content: {
|
|
7132
|
+
text: tweetText,
|
|
7133
|
+
source: "twitter",
|
|
7134
|
+
channelType: ChannelType2.FEED,
|
|
7135
|
+
type: "post",
|
|
7136
|
+
metadata: {
|
|
7137
|
+
tweetId,
|
|
7138
|
+
postedAt: Date.now()
|
|
7139
|
+
}
|
|
7140
|
+
},
|
|
7141
|
+
createdAt: Date.now()
|
|
7142
|
+
};
|
|
7143
|
+
await this.runtime.createMemory(postedMemory, "messages");
|
|
7144
|
+
logger4.info("Tweet posted and saved to memory successfully");
|
|
7081
7145
|
}
|
|
7082
7146
|
} catch (error) {
|
|
7083
7147
|
logger4.error("Error generating tweet:", error);
|
|
@@ -7365,6 +7429,15 @@ ${actionSummary.join("\n")}`);
|
|
|
7365
7429
|
} of tweetDecisions) {
|
|
7366
7430
|
const tweetId = this.createTweetId(this.runtime, tweet);
|
|
7367
7431
|
const executedActions = [];
|
|
7432
|
+
await this.runtime.ensureRoomExists({
|
|
7433
|
+
id: roomId,
|
|
7434
|
+
name: `Twitter conversation ${tweet.conversationId}`,
|
|
7435
|
+
source: "twitter",
|
|
7436
|
+
type: ChannelType3.GROUP,
|
|
7437
|
+
channelId: tweet.conversationId,
|
|
7438
|
+
serverId: tweet.userId,
|
|
7439
|
+
worldId: createUniqueUuid4(this.runtime, tweet.userId)
|
|
7440
|
+
});
|
|
7368
7441
|
await this.runtime.createMemory(
|
|
7369
7442
|
{
|
|
7370
7443
|
id: tweetId,
|
|
@@ -8108,43 +8181,12 @@ Quote tweet:`;
|
|
|
8108
8181
|
return response.trim();
|
|
8109
8182
|
}
|
|
8110
8183
|
async saveEngagementMemory(tweet, engagementType) {
|
|
8111
|
-
|
|
8112
|
-
|
|
8113
|
-
id: createUniqueUuid5(this.runtime, tweet.id),
|
|
8114
|
-
entityId: createUniqueUuid5(this.runtime, tweet.userId),
|
|
8115
|
-
content: {
|
|
8116
|
-
text: `${engagementType} tweet from @${tweet.username}: ${tweet.text}`,
|
|
8117
|
-
metadata: {
|
|
8118
|
-
tweetId: tweet.id,
|
|
8119
|
-
engagementType,
|
|
8120
|
-
source: "discovery",
|
|
8121
|
-
isDryRun: this.isDryRun
|
|
8122
|
-
}
|
|
8123
|
-
},
|
|
8124
|
-
roomId: createUniqueUuid5(this.runtime, tweet.conversationId)
|
|
8125
|
-
},
|
|
8126
|
-
"messages"
|
|
8127
|
-
);
|
|
8184
|
+
logger6.debug(`[Discovery] Would save engagement memory for ${engagementType} on tweet ${tweet.id}`);
|
|
8185
|
+
return;
|
|
8128
8186
|
}
|
|
8129
8187
|
async saveFollowMemory(user) {
|
|
8130
|
-
|
|
8131
|
-
|
|
8132
|
-
entityId: createUniqueUuid5(this.runtime, user.id),
|
|
8133
|
-
content: {
|
|
8134
|
-
text: `followed twitter user ${user.id} @${user.username}`,
|
|
8135
|
-
metadata: {
|
|
8136
|
-
userId: user.id,
|
|
8137
|
-
username: user.username,
|
|
8138
|
-
name: user.name,
|
|
8139
|
-
followersCount: user.followersCount,
|
|
8140
|
-
source: "discovery",
|
|
8141
|
-
isDryRun: this.isDryRun
|
|
8142
|
-
}
|
|
8143
|
-
},
|
|
8144
|
-
roomId: createUniqueUuid5(this.runtime, `twitter-follows`)
|
|
8145
|
-
},
|
|
8146
|
-
"messages"
|
|
8147
|
-
);
|
|
8188
|
+
logger6.debug(`[Discovery] Would save follow memory for @${user.username}`);
|
|
8189
|
+
return;
|
|
8148
8190
|
}
|
|
8149
8191
|
delay(ms) {
|
|
8150
8192
|
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
@@ -8856,9 +8898,23 @@ var postTweetAction = {
|
|
|
8856
8898
|
],
|
|
8857
8899
|
validate: async (runtime, message) => {
|
|
8858
8900
|
logger9.debug("Validating POST_TWEET action");
|
|
8901
|
+
logger9.debug("Message details:", {
|
|
8902
|
+
hasContent: !!message.content,
|
|
8903
|
+
contentType: message.content?.type,
|
|
8904
|
+
hasText: !!message.content?.text,
|
|
8905
|
+
textLength: message.content?.text?.length || 0,
|
|
8906
|
+
source: message.content?.source,
|
|
8907
|
+
roomId: message.roomId,
|
|
8908
|
+
entityId: message.entityId
|
|
8909
|
+
});
|
|
8910
|
+
if (message.content?.type === "post" && !message.content?.text) {
|
|
8911
|
+
logger9.debug("Skipping validation for provider context (empty post type)");
|
|
8912
|
+
return false;
|
|
8913
|
+
}
|
|
8859
8914
|
const text = message.content?.text?.trim();
|
|
8860
8915
|
if (!text || text.length === 0) {
|
|
8861
8916
|
logger9.error("No text content for tweet");
|
|
8917
|
+
logger9.debug("Stack trace:", new Error().stack);
|
|
8862
8918
|
return false;
|
|
8863
8919
|
}
|
|
8864
8920
|
if (text.length > 280) {
|