@elizaos/plugin-discord 1.0.0-alpha.57 → 1.0.0-alpha.59

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 CHANGED
@@ -7,7 +7,7 @@ import {
7
7
  import fs from "node:fs";
8
8
  import {
9
9
  ChannelType,
10
- ModelTypes,
10
+ ModelType,
11
11
  composePromptFromState,
12
12
  parseJSONObjectFromText,
13
13
  trimTokens
@@ -42,7 +42,7 @@ var getAttachmentIds = async (runtime, _message, state) => {
42
42
  template: attachmentIdsTemplate
43
43
  });
44
44
  for (let i = 0; i < 5; i++) {
45
- const response = await runtime.useModel(ModelTypes.TEXT_SMALL, {
45
+ const response = await runtime.useModel(ModelType.TEXT_SMALL, {
46
46
  prompt
47
47
  });
48
48
  console.log("response", response);
@@ -104,7 +104,7 @@ var chatWithAttachments = {
104
104
  "watch"
105
105
  ];
106
106
  return keywords.some(
107
- (keyword) => message.content.text.toLowerCase().includes(keyword.toLowerCase())
107
+ (keyword) => message.content.text?.toLowerCase().includes(keyword.toLowerCase())
108
108
  );
109
109
  },
110
110
  handler: async (runtime, message, state, _options, callback) => {
@@ -118,7 +118,7 @@ var chatWithAttachments = {
118
118
  const attachmentData = await getAttachmentIds(runtime, message, state);
119
119
  if (!attachmentData) {
120
120
  console.error("Couldn't get attachment IDs from message");
121
- await runtime.getMemoryManager("messages").createMemory({
121
+ await runtime.createMemory({
122
122
  entityId: message.entityId,
123
123
  agentId: message.agentId,
124
124
  roomId: message.roomId,
@@ -130,7 +130,7 @@ var chatWithAttachments = {
130
130
  metadata: {
131
131
  type: "CHAT_WITH_ATTACHMENTS"
132
132
  }
133
- });
133
+ }, "messages");
134
134
  return;
135
135
  }
136
136
  const { objective, attachmentIds } = attachmentData;
@@ -160,14 +160,14 @@ ${attachment.text}`).join("\n\n");
160
160
  // Get the model's tokenizer based on the current model being used
161
161
  template
162
162
  });
163
- const summary = await runtime.useModel(ModelTypes.TEXT_SMALL, {
163
+ const summary = await runtime.useModel(ModelType.TEXT_SMALL, {
164
164
  prompt
165
165
  });
166
166
  currentSummary = `${currentSummary}
167
167
  ${summary}`;
168
168
  if (!currentSummary) {
169
169
  console.error("No summary found, that's not good!");
170
- await runtime.getMemoryManager("messages").createMemory({
170
+ await runtime.createMemory({
171
171
  entityId: message.entityId,
172
172
  agentId: message.agentId,
173
173
  roomId: message.roomId,
@@ -179,7 +179,7 @@ ${summary}`;
179
179
  metadata: {
180
180
  type: "CHAT_WITH_ATTACHMENTS"
181
181
  }
182
- });
182
+ }, "messages");
183
183
  return;
184
184
  }
185
185
  callbackData.text = currentSummary.trim();
@@ -289,8 +289,8 @@ var chatWithAttachments_default = chatWithAttachments;
289
289
 
290
290
  // src/actions/downloadMedia.ts
291
291
  import {
292
- ModelTypes as ModelTypes2,
293
- ServiceTypes,
292
+ ModelType as ModelType2,
293
+ ServiceType,
294
294
  composePromptFromState as composePromptFromState2,
295
295
  parseJSONObjectFromText as parseJSONObjectFromText2
296
296
  } from "@elizaos/core";
@@ -313,7 +313,7 @@ var getMediaUrl = async (runtime, _message, state) => {
313
313
  template: mediaUrlTemplate
314
314
  });
315
315
  for (let i = 0; i < 5; i++) {
316
- const response = await runtime.useModel(ModelTypes2.TEXT_SMALL, {
316
+ const response = await runtime.useModel(ModelType2.TEXT_SMALL, {
317
317
  prompt
318
318
  });
319
319
  const parsedResponse = parseJSONObjectFromText2(response);
@@ -339,11 +339,11 @@ var downloadMedia = {
339
339
  }
340
340
  },
341
341
  handler: async (runtime, message, state, _options, callback) => {
342
- const videoService = runtime.getService(ServiceTypes.VIDEO);
342
+ const videoService = runtime.getService(ServiceType.VIDEO);
343
343
  const mediaUrl = await getMediaUrl(runtime, message, state);
344
344
  if (!mediaUrl) {
345
345
  console.error("Couldn't get media URL from messages");
346
- await runtime.getMemoryManager("messages").createMemory({
346
+ await runtime.createMemory({
347
347
  entityId: message.entityId,
348
348
  agentId: message.agentId,
349
349
  roomId: message.roomId,
@@ -355,7 +355,7 @@ var downloadMedia = {
355
355
  metadata: {
356
356
  type: "DOWNLOAD_MEDIA"
357
357
  }
358
- });
358
+ }, "messages");
359
359
  return;
360
360
  }
361
361
  const videoInfo = await videoService.fetchVideoInfo(mediaUrl);
@@ -443,7 +443,7 @@ var downloadMedia = {
443
443
  // src/actions/summarizeConversation.ts
444
444
  import fs2 from "node:fs";
445
445
  import {
446
- ModelTypes as ModelTypes3,
446
+ ModelType as ModelType3,
447
447
  composePromptFromState as composePromptFromState3,
448
448
  getEntityDetails,
449
449
  parseJSONObjectFromText as parseJSONObjectFromText3,
@@ -483,7 +483,7 @@ var getDateRange = async (runtime, _message, state) => {
483
483
  template: dateRangeTemplate
484
484
  });
485
485
  for (let i = 0; i < 5; i++) {
486
- const response = await runtime.useModel(ModelTypes3.TEXT_SMALL, {
486
+ const response = await runtime.useModel(ModelType3.TEXT_SMALL, {
487
487
  prompt
488
488
  });
489
489
  console.log("response", response);
@@ -574,7 +574,7 @@ var summarize = {
574
574
  "catch me up"
575
575
  ];
576
576
  return keywords.some(
577
- (keyword) => message.content.text.toLowerCase().includes(keyword.toLowerCase())
577
+ (keyword) => message.content.text?.toLowerCase().includes(keyword.toLowerCase())
578
578
  );
579
579
  },
580
580
  handler: async (runtime, message, state, _options, callback) => {
@@ -589,7 +589,7 @@ var summarize = {
589
589
  const dateRange = await getDateRange(runtime, message, state);
590
590
  if (!dateRange) {
591
591
  console.error("Couldn't get date range from message");
592
- await runtime.getMemoryManager("messages").createMemory({
592
+ await runtime.createMemory({
593
593
  entityId: message.entityId,
594
594
  agentId: message.agentId,
595
595
  roomId: message.roomId,
@@ -601,11 +601,12 @@ var summarize = {
601
601
  metadata: {
602
602
  type: "SUMMARIZE_CONVERSATION"
603
603
  }
604
- });
604
+ }, "messages");
605
605
  return;
606
606
  }
607
607
  const { objective, start, end } = dateRange;
608
- const memories = await runtime.getMemoryManager("messages").getMemories({
608
+ const memories = await runtime.getMemories({
609
+ tableName: "messages",
609
610
  roomId,
610
611
  // subtract start from current time
611
612
  start: Number.parseInt(start),
@@ -649,7 +650,7 @@ ${attachments}`;
649
650
  // make sure it fits, we can pad the tokens a bit
650
651
  template
651
652
  });
652
- const summary = await runtime.useModel(ModelTypes3.TEXT_SMALL, {
653
+ const summary = await runtime.useModel(ModelType3.TEXT_SMALL, {
653
654
  prompt
654
655
  });
655
656
  currentSummary = `${currentSummary}
@@ -657,7 +658,7 @@ ${summary}`;
657
658
  }
658
659
  if (!currentSummary) {
659
660
  console.error("No summary found, that's not good!");
660
- await runtime.getMemoryManager("messages").createMemory({
661
+ await runtime.createMemory({
661
662
  entityId: message.entityId,
662
663
  agentId: message.agentId,
663
664
  roomId: message.roomId,
@@ -669,7 +670,7 @@ ${summary}`;
669
670
  metadata: {
670
671
  type: "SUMMARIZE_CONVERSATION"
671
672
  }
672
- });
673
+ }, "messages");
673
674
  return;
674
675
  }
675
676
  callbackData.text = currentSummary.trim();
@@ -772,7 +773,7 @@ ${currentSummary.trim()}
772
773
 
773
774
  // src/actions/transcribeMedia.ts
774
775
  import {
775
- ModelTypes as ModelTypes4,
776
+ ModelType as ModelType4,
776
777
  composePromptFromState as composePromptFromState4,
777
778
  parseJSONObjectFromText as parseJSONObjectFromText4
778
779
  } from "@elizaos/core";
@@ -795,7 +796,7 @@ var getMediaAttachmentId = async (runtime, _message, state) => {
795
796
  template: mediaAttachmentIdTemplate
796
797
  });
797
798
  for (let i = 0; i < 5; i++) {
798
- const response = await runtime.useModel(ModelTypes4.TEXT_SMALL, {
799
+ const response = await runtime.useModel(ModelType4.TEXT_SMALL, {
799
800
  prompt
800
801
  });
801
802
  console.log("response", response);
@@ -838,7 +839,7 @@ var transcribeMedia = {
838
839
  "presentation"
839
840
  ];
840
841
  return keywords.some(
841
- (keyword) => message.content.text.toLowerCase().includes(keyword.toLowerCase())
842
+ (keyword) => message.content.text?.toLowerCase().includes(keyword.toLowerCase())
842
843
  );
843
844
  },
844
845
  handler: async (runtime, message, state, _options, callback) => {
@@ -852,7 +853,7 @@ var transcribeMedia = {
852
853
  const attachmentId = await getMediaAttachmentId(runtime, message, state);
853
854
  if (!attachmentId) {
854
855
  console.error("Couldn't get media attachment ID from message");
855
- await runtime.getMemoryManager("messages").createMemory({
856
+ await runtime.createMemory({
856
857
  entityId: message.entityId,
857
858
  agentId: message.agentId,
858
859
  roomId: message.roomId,
@@ -864,7 +865,7 @@ var transcribeMedia = {
864
865
  metadata: {
865
866
  type: "TRANSCRIBE_MEDIA"
866
867
  }
867
- });
868
+ }, "messages");
868
869
  return;
869
870
  }
870
871
  const attachment = state.data.recentMessages.filter(
@@ -874,7 +875,7 @@ var transcribeMedia = {
874
875
  );
875
876
  if (!attachment) {
876
877
  console.error(`Couldn't find attachment with ID ${attachmentId}`);
877
- await runtime.getMemoryManager("messages").createMemory({
878
+ await runtime.createMemory({
878
879
  entityId: message.entityId,
879
880
  agentId: message.agentId,
880
881
  roomId: message.roomId,
@@ -886,7 +887,7 @@ var transcribeMedia = {
886
887
  metadata: {
887
888
  type: "TRANSCRIBE_MEDIA"
888
889
  }
889
- });
890
+ }, "messages");
890
891
  return;
891
892
  }
892
893
  const mediaTranscript = attachment.text;
@@ -950,7 +951,7 @@ ${mediaTranscript.trim()}
950
951
  // src/actions/voiceJoin.ts
951
952
  import {
952
953
  ChannelType as ChannelType2,
953
- ModelTypes as ModelTypes5,
954
+ ModelType as ModelType5,
954
955
  composePromptFromState as composePromptFromState5,
955
956
  createUniqueUuid as createUniqueUuid2,
956
957
  logger
@@ -960,7 +961,7 @@ import {
960
961
  } from "discord.js";
961
962
 
962
963
  // src/types.ts
963
- var ServiceTypes2 = {
964
+ var ServiceType2 = {
964
965
  DISCORD: "discord"
965
966
  };
966
967
 
@@ -983,7 +984,7 @@ var joinVoice = {
983
984
  if (room?.type !== ChannelType2.GROUP) {
984
985
  return false;
985
986
  }
986
- const client = runtime.getService(ServiceTypes2.DISCORD);
987
+ const client = runtime.getService(ServiceType2.DISCORD);
987
988
  if (!client) {
988
989
  logger.error("Discord client not found");
989
990
  return false;
@@ -1005,7 +1006,7 @@ var joinVoice = {
1005
1006
  throw new Error("No server ID found");
1006
1007
  }
1007
1008
  const discordClient = runtime.getService(
1008
- ServiceTypes2.DISCORD
1009
+ ServiceType2.DISCORD
1009
1010
  );
1010
1011
  const client = discordClient.client;
1011
1012
  const voiceManager = discordClient.voiceManager;
@@ -1033,7 +1034,7 @@ var joinVoice = {
1033
1034
  );
1034
1035
  if (member?.voice?.channel) {
1035
1036
  voiceManager.joinChannel(member?.voice?.channel);
1036
- await runtime.getMemoryManager("messages").createMemory({
1037
+ await runtime.createMemory({
1037
1038
  entityId: message.entityId,
1038
1039
  agentId: message.agentId,
1039
1040
  roomId: message.roomId,
@@ -1045,8 +1046,8 @@ var joinVoice = {
1045
1046
  metadata: {
1046
1047
  type: "JOIN_VOICE"
1047
1048
  }
1048
- });
1049
- await runtime.getMemoryManager("messages").createMemory({
1049
+ }, "messages");
1050
+ await runtime.createMemory({
1050
1051
  entityId: message.entityId,
1051
1052
  agentId: message.agentId,
1052
1053
  roomId: createUniqueUuid2(runtime, targetChannel.id),
@@ -1058,7 +1059,7 @@ var joinVoice = {
1058
1059
  metadata: {
1059
1060
  type: "JOIN_VOICE"
1060
1061
  }
1061
- });
1062
+ }, "messages");
1062
1063
  return true;
1063
1064
  }
1064
1065
  const messageTemplate = `
@@ -1080,7 +1081,7 @@ You should only respond with the name of the voice channel or none, no commentar
1080
1081
  template: messageTemplate,
1081
1082
  state: guessState
1082
1083
  });
1083
- const responseContent = await runtime.useModel(ModelTypes5.TEXT_SMALL, {
1084
+ const responseContent = await runtime.useModel(ModelType5.TEXT_SMALL, {
1084
1085
  prompt
1085
1086
  });
1086
1087
  if (responseContent && responseContent.trim().length > 0) {
@@ -1092,7 +1093,7 @@ You should only respond with the name of the voice channel or none, no commentar
1092
1093
  });
1093
1094
  if (targetChannel2) {
1094
1095
  voiceManager.joinChannel(targetChannel2);
1095
- await runtime.getMemoryManager("messages").createMemory({
1096
+ await runtime.createMemory({
1096
1097
  entityId: message.entityId,
1097
1098
  agentId: message.agentId,
1098
1099
  roomId: message.roomId,
@@ -1104,8 +1105,8 @@ You should only respond with the name of the voice channel or none, no commentar
1104
1105
  metadata: {
1105
1106
  type: "JOIN_VOICE"
1106
1107
  }
1107
- });
1108
- await runtime.getMemoryManager("messages").createMemory({
1108
+ }, "messages");
1109
+ await runtime.createMemory({
1109
1110
  entityId: message.entityId,
1110
1111
  agentId: message.agentId,
1111
1112
  roomId: createUniqueUuid2(runtime, targetChannel2.id),
@@ -1117,7 +1118,7 @@ You should only respond with the name of the voice channel or none, no commentar
1117
1118
  metadata: {
1118
1119
  type: "JOIN_VOICE"
1119
1120
  }
1120
- });
1121
+ }, "messages");
1121
1122
  return true;
1122
1123
  }
1123
1124
  }
@@ -1272,7 +1273,7 @@ var leaveVoice = {
1272
1273
  if (message.content.source !== "discord") {
1273
1274
  return false;
1274
1275
  }
1275
- const service = runtime.getService(ServiceTypes2.DISCORD);
1276
+ const service = runtime.getService(ServiceType2.DISCORD);
1276
1277
  if (!service) {
1277
1278
  logger2.error("Discord client not found");
1278
1279
  return false;
@@ -1298,7 +1299,7 @@ var leaveVoice = {
1298
1299
  throw new Error("No server ID found 9");
1299
1300
  }
1300
1301
  const discordClient = runtime.getService(
1301
- ServiceTypes2.DISCORD
1302
+ ServiceType2.DISCORD
1302
1303
  );
1303
1304
  const voiceManager = discordClient.voiceManager;
1304
1305
  const client = discordClient.client;
@@ -1313,7 +1314,7 @@ var leaveVoice = {
1313
1314
  const guild = client.guilds.cache.get(serverId);
1314
1315
  if (!guild) {
1315
1316
  console.warn("Bot is not in any voice channel.");
1316
- await runtime.getMemoryManager("messages").createMemory({
1317
+ await runtime.createMemory({
1317
1318
  entityId: message.entityId,
1318
1319
  agentId: message.agentId,
1319
1320
  roomId: message.roomId,
@@ -1325,13 +1326,13 @@ var leaveVoice = {
1325
1326
  metadata: {
1326
1327
  type: "LEAVE_VOICE"
1327
1328
  }
1328
- });
1329
+ }, "messages");
1329
1330
  return false;
1330
1331
  }
1331
1332
  const voiceChannel = guild.members.me?.voice.channel;
1332
1333
  if (!voiceChannel || !(voiceChannel instanceof BaseGuildVoiceChannel)) {
1333
1334
  console.warn("Could not retrieve the voice channel.");
1334
- await runtime.getMemoryManager("messages").createMemory({
1335
+ await runtime.createMemory({
1335
1336
  entityId: message.entityId,
1336
1337
  agentId: message.agentId,
1337
1338
  roomId: message.roomId,
@@ -1343,13 +1344,13 @@ var leaveVoice = {
1343
1344
  metadata: {
1344
1345
  type: "LEAVE_VOICE"
1345
1346
  }
1346
- });
1347
+ }, "messages");
1347
1348
  return false;
1348
1349
  }
1349
1350
  const connection = voiceManager.getVoiceConnection(guild.id);
1350
1351
  if (!connection) {
1351
1352
  console.warn("No active voice connection found for the bot.");
1352
- await runtime.getMemoryManager("messages").createMemory({
1353
+ await runtime.createMemory({
1353
1354
  entityId: message.entityId,
1354
1355
  agentId: message.agentId,
1355
1356
  roomId: message.roomId,
@@ -1361,11 +1362,11 @@ var leaveVoice = {
1361
1362
  metadata: {
1362
1363
  type: "LEAVE_VOICE"
1363
1364
  }
1364
- });
1365
+ }, "messages");
1365
1366
  return false;
1366
1367
  }
1367
1368
  voiceManager.leaveChannel(voiceChannel);
1368
- await runtime.getMemoryManager("messages").createMemory({
1369
+ await runtime.createMemory({
1369
1370
  entityId: message.entityId,
1370
1371
  agentId: message.agentId,
1371
1372
  roomId: createUniqueUuid3(runtime, voiceChannel.id),
@@ -1377,7 +1378,7 @@ var leaveVoice = {
1377
1378
  metadata: {
1378
1379
  type: "LEAVE_VOICE"
1379
1380
  }
1380
- });
1381
+ }, "messages");
1381
1382
  return true;
1382
1383
  },
1383
1384
  examples: [
@@ -1548,7 +1549,7 @@ var channelStateProvider = {
1548
1549
  }
1549
1550
  channelId = room.channelId;
1550
1551
  const discordService = runtime.getService(
1551
- ServiceTypes2.DISCORD
1552
+ ServiceType2.DISCORD
1552
1553
  );
1553
1554
  if (!discordService) {
1554
1555
  console.warn("No discord client found");
@@ -1704,7 +1705,7 @@ var DISCORD_SERVICE_NAME = "discord";
1704
1705
  import {
1705
1706
  ChannelType as ChannelType7,
1706
1707
  EventTypes,
1707
- ServiceTypes as ServiceTypes4,
1708
+ ServiceType as ServiceType4,
1708
1709
  createUniqueUuid as createUniqueUuid4,
1709
1710
  logger as logger4
1710
1711
  } from "@elizaos/core";
@@ -1717,8 +1718,8 @@ import fs3 from "node:fs";
1717
1718
  import { trimTokens as trimTokens3 } from "@elizaos/core";
1718
1719
  import { parseJSONObjectFromText as parseJSONObjectFromText5 } from "@elizaos/core";
1719
1720
  import {
1720
- ModelTypes as ModelTypes6,
1721
- ServiceTypes as ServiceTypes3
1721
+ ModelType as ModelType6,
1722
+ ServiceType as ServiceType3
1722
1723
  } from "@elizaos/core";
1723
1724
  import { Collection } from "discord.js";
1724
1725
  import ffmpeg from "fluent-ffmpeg";
@@ -1737,7 +1738,7 @@ async function generateSummary(runtime, text) {
1737
1738
  "summary": "Generated summary and/or description of the text"
1738
1739
  }
1739
1740
  \`\`\``;
1740
- const response = await runtime.useModel(ModelTypes6.TEXT_SMALL, {
1741
+ const response = await runtime.useModel(ModelType6.TEXT_SMALL, {
1741
1742
  prompt
1742
1743
  });
1743
1744
  const parsedResponse = parseJSONObjectFromText5(response);
@@ -1801,7 +1802,7 @@ var AttachmentManager = class {
1801
1802
  media = await this.processAudioVideoAttachment(attachment);
1802
1803
  } else if (attachment.contentType?.startsWith("image/")) {
1803
1804
  media = await this.processImageAttachment(attachment);
1804
- } else if (attachment.contentType?.startsWith("video/") || this.runtime.getService(ServiceTypes3.VIDEO).isVideoUrl(attachment.url)) {
1805
+ } else if (attachment.contentType?.startsWith("video/") || this.runtime.getService(ServiceType3.VIDEO).isVideoUrl(attachment.url)) {
1805
1806
  media = await this.processVideoAttachment(attachment);
1806
1807
  } else {
1807
1808
  media = await this.processGenericAttachment(attachment);
@@ -1829,7 +1830,7 @@ var AttachmentManager = class {
1829
1830
  throw new Error("Unsupported audio/video format");
1830
1831
  }
1831
1832
  const transcription = await this.runtime.useModel(
1832
- ModelTypes6.TRANSCRIPTION,
1833
+ ModelType6.TRANSCRIPTION,
1833
1834
  audioBuffer
1834
1835
  );
1835
1836
  const { title, description } = await generateSummary(
@@ -1902,7 +1903,7 @@ var AttachmentManager = class {
1902
1903
  try {
1903
1904
  const response = await fetch(attachment.url);
1904
1905
  const pdfBuffer = await response.arrayBuffer();
1905
- const text = await this.runtime.getService(ServiceTypes3.PDF).convertPdfToText(Buffer.from(pdfBuffer));
1906
+ const text = await this.runtime.getService(ServiceType3.PDF).convertPdfToText(Buffer.from(pdfBuffer));
1906
1907
  const { title, description } = await generateSummary(this.runtime, text);
1907
1908
  return {
1908
1909
  id: attachment.id,
@@ -1965,7 +1966,7 @@ var AttachmentManager = class {
1965
1966
  async processImageAttachment(attachment) {
1966
1967
  try {
1967
1968
  const { description, title } = await this.runtime.useModel(
1968
- ModelTypes6.IMAGE_DESCRIPTION,
1969
+ ModelType6.IMAGE_DESCRIPTION,
1969
1970
  attachment.url
1970
1971
  );
1971
1972
  return {
@@ -2005,7 +2006,7 @@ var AttachmentManager = class {
2005
2006
  */
2006
2007
  async processVideoAttachment(attachment) {
2007
2008
  const videoService = this.runtime.getService(
2008
- ServiceTypes3.VIDEO
2009
+ ServiceType3.VIDEO
2009
2010
  );
2010
2011
  if (!videoService) {
2011
2012
  throw new Error("Video service not found");
@@ -2052,7 +2053,7 @@ var AttachmentManager = class {
2052
2053
 
2053
2054
  // src/utils.ts
2054
2055
  import {
2055
- ModelTypes as ModelTypes7,
2056
+ ModelType as ModelType7,
2056
2057
  logger as logger3,
2057
2058
  parseJSONObjectFromText as parseJSONObjectFromText6,
2058
2059
  trimTokens as trimTokens4
@@ -2302,7 +2303,7 @@ var MessageManager = class {
2302
2303
  memories.push(memory);
2303
2304
  }
2304
2305
  for (const m of memories) {
2305
- await this.runtime.getMemoryManager("messages").createMemory(m);
2306
+ await this.runtime.createMemory(m, "messages");
2306
2307
  }
2307
2308
  return memories;
2308
2309
  } catch (error) {
@@ -2371,9 +2372,9 @@ var MessageManager = class {
2371
2372
  const urlRegex = /(https?:\/\/[^\s]+)/g;
2372
2373
  const urls = processedContent.match(urlRegex) || [];
2373
2374
  for (const url of urls) {
2374
- if (this.runtime.getService(ServiceTypes4.VIDEO)?.isVideoUrl(url)) {
2375
+ if (this.runtime.getService(ServiceType4.VIDEO)?.isVideoUrl(url)) {
2375
2376
  const videoService = this.runtime.getService(
2376
- ServiceTypes4.VIDEO
2377
+ ServiceType4.VIDEO
2377
2378
  );
2378
2379
  if (!videoService) {
2379
2380
  throw new Error("Video service not found");
@@ -2389,7 +2390,7 @@ var MessageManager = class {
2389
2390
  });
2390
2391
  } else {
2391
2392
  const browserService = this.runtime.getService(
2392
- ServiceTypes4.BROWSER
2393
+ ServiceType4.BROWSER
2393
2394
  );
2394
2395
  if (!browserService) {
2395
2396
  throw new Error("Browser service not found");
@@ -2446,7 +2447,7 @@ import {
2446
2447
  } from "@discordjs/voice";
2447
2448
  import {
2448
2449
  ChannelType as ChannelType8,
2449
- ModelTypes as ModelTypes8,
2450
+ ModelType as ModelType8,
2450
2451
  createUniqueUuid as createUniqueUuid5,
2451
2452
  logger as logger5
2452
2453
  } from "@elizaos/core";
@@ -2982,7 +2983,7 @@ var VoiceManager = class extends EventEmitter {
2982
2983
  const wavBuffer = await this.convertOpusToWav(inputBuffer);
2983
2984
  console.log("Starting transcription...");
2984
2985
  const transcriptionText = await this.runtime.useModel(
2985
- ModelTypes8.TRANSCRIPTION,
2986
+ ModelType8.TRANSCRIPTION,
2986
2987
  wavBuffer
2987
2988
  );
2988
2989
  if (transcriptionText && isValidTranscription(transcriptionText)) {
@@ -3072,9 +3073,9 @@ var VoiceManager = class extends EventEmitter {
3072
3073
  createdAt: Date.now()
3073
3074
  };
3074
3075
  if (responseMemory.content.text?.trim()) {
3075
- await this.runtime.getMemoryManager("messages").createMemory(responseMemory);
3076
+ await this.runtime.createMemory(responseMemory);
3076
3077
  const responseStream = await this.runtime.useModel(
3077
- ModelTypes8.TEXT_TO_SPEECH,
3078
+ ModelType8.TEXT_TO_SPEECH,
3078
3079
  content.text
3079
3080
  );
3080
3081
  if (responseStream) {
@@ -3316,72 +3317,11 @@ var DiscordService = class _DiscordService extends Service {
3316
3317
  this.client = null;
3317
3318
  });
3318
3319
  this.setupEventListeners();
3319
- const ensureAllServersExist = async (runtime2) => {
3320
- const guilds = await this.client.guilds.fetch();
3321
- for (const [, guild] of guilds) {
3322
- await this.ensureAllChannelsExist(runtime2, guild);
3323
- }
3324
- };
3325
- ensureAllServersExist(this.runtime);
3326
3320
  } catch (error) {
3327
3321
  logger6.error(`Error initializing Discord client: ${error.message}`);
3328
3322
  this.client = null;
3329
3323
  }
3330
3324
  }
3331
- /**
3332
- * Ensures that all channels exist in the database for a given guild.
3333
- * @param {IAgentRuntime} runtime - The agent runtime object.
3334
- * @param {OAuth2Guild} guild - The OAuth2Guild object for which channels need to be ensured.
3335
- * @returns {Promise<void>} - A Promise that resolves once all channels are ensured.
3336
- */
3337
- async ensureAllChannelsExist(runtime, guild) {
3338
- let guildObj;
3339
- let guildChannels;
3340
- let retries = 3;
3341
- while (retries > 0) {
3342
- try {
3343
- guildObj = await guild.fetch();
3344
- guildChannels = await guild.fetch();
3345
- break;
3346
- } catch (error) {
3347
- retries--;
3348
- if (retries === 0) {
3349
- throw error;
3350
- }
3351
- await new Promise((resolve) => setTimeout(resolve, 1e3));
3352
- }
3353
- }
3354
- for (const [, channel] of guildChannels.channels.cache) {
3355
- const roomId = createUniqueUuid6(this.runtime, channel.id);
3356
- const room = await runtime.getRoom(roomId);
3357
- if (room) {
3358
- continue;
3359
- }
3360
- const worldId = createUniqueUuid6(runtime, guild.id);
3361
- const ownerId = createUniqueUuid6(this.runtime, guildObj.ownerId);
3362
- await runtime.ensureWorldExists({
3363
- id: worldId,
3364
- name: guild.name,
3365
- serverId: guild.id,
3366
- agentId: runtime.agentId,
3367
- metadata: {
3368
- ownership: guildObj.ownerId ? { ownerId } : void 0,
3369
- roles: {
3370
- [ownerId]: Role.OWNER
3371
- }
3372
- }
3373
- });
3374
- await runtime.ensureRoomExists({
3375
- id: roomId,
3376
- name: channel.name,
3377
- source: "discord",
3378
- type: ChannelType9.GROUP,
3379
- channelId: channel.id,
3380
- serverId: guild.id,
3381
- worldId
3382
- });
3383
- }
3384
- }
3385
3325
  /**
3386
3326
  * Set up event listeners for the client
3387
3327
  */
@@ -4083,7 +4023,7 @@ import {
4083
4023
  entersState as entersState2
4084
4024
  } from "@discordjs/voice";
4085
4025
  import {
4086
- ModelTypes as ModelTypes9,
4026
+ ModelType as ModelType9,
4087
4027
  logger as logger7
4088
4028
  } from "@elizaos/core";
4089
4029
  import { ChannelType as ChannelType10, Events as Events2 } from "discord.js";
@@ -4136,7 +4076,7 @@ var DiscordTestSuite = class {
4136
4076
  async testCreatingDiscordClient(runtime) {
4137
4077
  try {
4138
4078
  this.discordClient = runtime.getService(
4139
- ServiceTypes2.DISCORD
4079
+ ServiceType2.DISCORD
4140
4080
  );
4141
4081
  if (this.discordClient.client.isReady()) {
4142
4082
  logger7.success("DiscordService is already ready.");
@@ -4240,7 +4180,7 @@ var DiscordTestSuite = class {
4240
4180
  let responseStream = null;
4241
4181
  try {
4242
4182
  responseStream = await runtime.useModel(
4243
- ModelTypes9.TEXT_TO_SPEECH,
4183
+ ModelType9.TEXT_TO_SPEECH,
4244
4184
  `Hi! I'm ${runtime.character.name}! How are you doing today?`
4245
4185
  );
4246
4186
  } catch (_error) {