@elizaos/core 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
@@ -70,7 +70,13 @@ var require_dedent = __commonJS({
70
70
  });
71
71
 
72
72
  // src/types.ts
73
- var ModelTypes = {
73
+ function asUUID(id) {
74
+ if (!id || !/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(id)) {
75
+ throw new Error(`Invalid UUID format: ${id}`);
76
+ }
77
+ return id;
78
+ }
79
+ var ModelType = {
74
80
  SMALL: "TEXT_SMALL",
75
81
  // kept for backwards compatibility
76
82
  MEDIUM: "TEXT_LARGE",
@@ -94,7 +100,7 @@ var ModelTypes = {
94
100
  OBJECT_SMALL: "OBJECT_SMALL",
95
101
  OBJECT_LARGE: "OBJECT_LARGE"
96
102
  };
97
- var ServiceTypes = {
103
+ var ServiceType = {
98
104
  TRANSCRIPTION: "transcription",
99
105
  VIDEO: "video",
100
106
  BROWSER: "browser",
@@ -141,6 +147,11 @@ var Service = class {
141
147
  throw new Error("Not implemented");
142
148
  }
143
149
  };
150
+ var AgentStatus = /* @__PURE__ */ ((AgentStatus2) => {
151
+ AgentStatus2["ACTIVE"] = "active";
152
+ AgentStatus2["INACTIVE"] = "inactive";
153
+ return AgentStatus2;
154
+ })(AgentStatus || {});
144
155
  var KnowledgeScope = /* @__PURE__ */ ((KnowledgeScope2) => {
145
156
  KnowledgeScope2["SHARED"] = "shared";
146
157
  KnowledgeScope2["PRIVATE"] = "private";
@@ -206,6 +217,69 @@ var SOCKET_MESSAGE_TYPE = /* @__PURE__ */ ((SOCKET_MESSAGE_TYPE2) => {
206
217
  SOCKET_MESSAGE_TYPE2[SOCKET_MESSAGE_TYPE2["SEND_MESSAGE"] = 2] = "SEND_MESSAGE";
207
218
  return SOCKET_MESSAGE_TYPE2;
208
219
  })(SOCKET_MESSAGE_TYPE || {});
220
+ function createMessageMemory(params) {
221
+ return {
222
+ ...params,
223
+ createdAt: Date.now(),
224
+ metadata: {
225
+ type: "message" /* MESSAGE */,
226
+ timestamp: Date.now(),
227
+ scope: params.agentId ? "private" : "shared"
228
+ }
229
+ };
230
+ }
231
+ function getTypedService(runtime, serviceType) {
232
+ return runtime.getService(serviceType);
233
+ }
234
+ function isDocumentMetadata(metadata) {
235
+ return metadata.type === "document" /* DOCUMENT */;
236
+ }
237
+ function isFragmentMetadata(metadata) {
238
+ return metadata.type === "fragment" /* FRAGMENT */;
239
+ }
240
+ function isMessageMetadata(metadata) {
241
+ return metadata.type === "message" /* MESSAGE */;
242
+ }
243
+ function isDescriptionMetadata(metadata) {
244
+ return metadata.type === "description" /* DESCRIPTION */;
245
+ }
246
+ function isCustomMetadata(metadata) {
247
+ return metadata.type !== "document" /* DOCUMENT */ && metadata.type !== "fragment" /* FRAGMENT */ && metadata.type !== "message" /* MESSAGE */ && metadata.type !== "description" /* DESCRIPTION */;
248
+ }
249
+ function getVideoService(runtime) {
250
+ return runtime.getService(ServiceType.VIDEO);
251
+ }
252
+ function getBrowserService(runtime) {
253
+ return runtime.getService(ServiceType.BROWSER);
254
+ }
255
+ function getPdfService(runtime) {
256
+ return runtime.getService(ServiceType.PDF);
257
+ }
258
+ function getFileService(runtime) {
259
+ return runtime.getService(ServiceType.REMOTE_FILES);
260
+ }
261
+ function isDocumentMemory(memory) {
262
+ return memory.metadata?.type === "document" /* DOCUMENT */;
263
+ }
264
+ function isFragmentMemory(memory) {
265
+ return memory.metadata?.type === "fragment" /* FRAGMENT */;
266
+ }
267
+ function getMemoryText(memory, defaultValue = "") {
268
+ return memory.content.text ?? defaultValue;
269
+ }
270
+ function createServiceError(error, code = "UNKNOWN_ERROR") {
271
+ if (error instanceof Error) {
272
+ return {
273
+ code,
274
+ message: error.message,
275
+ cause: error
276
+ };
277
+ }
278
+ return {
279
+ code,
280
+ message: String(error)
281
+ };
282
+ }
209
283
 
210
284
  // src/actions.ts
211
285
  import { names, uniqueNamesGenerator } from "unique-names-generator";
@@ -236,7 +310,7 @@ var composeActionExamples = (actionsData, count) => {
236
310
  );
237
311
  return `
238
312
  ${example.map((message) => {
239
- let messageString = `${message.name}: ${message.content.text}${message.content.actions ? ` (actions: ${message.content.actions.join(", ")})` : ""}`;
313
+ let messageString = `${message.name}: ${message.content.text}${message.content.action ? ` (action: ${message.content.action})` : ""}${message.content.actions ? ` (actions: ${message.content.actions.join(", ")})` : ""}`;
240
314
  for (let i = 0; i < exampleNames.length; i++) {
241
315
  messageString = messageString.replaceAll(
242
316
  `{{name${i + 1}}}`,
@@ -266,7 +340,6 @@ import { names as names2, uniqueNamesGenerator as uniqueNamesGenerator2 } from "
266
340
 
267
341
  // src/logger.ts
268
342
  import pino from "pino";
269
- import pretty from "pino-pretty";
270
343
  function parseBooleanFromText(value) {
271
344
  if (!value) return false;
272
345
  const affirmative = ["YES", "Y", "TRUE", "T", "1", "ON", "ENABLE"];
@@ -285,10 +358,10 @@ var InMemoryDestination = class {
285
358
  * Constructor for creating a new instance of the class.
286
359
  * @param {DestinationStream|null} stream - The stream to assign to the instance. Can be null.
287
360
  */
288
- constructor(stream2) {
361
+ constructor(stream) {
289
362
  this.logs = [];
290
363
  this.maxLogs = 1e3;
291
- this.stream = stream2;
364
+ this.stream = stream;
292
365
  }
293
366
  /**
294
367
  * Writes a log entry to the memory buffer and forwards it to the pretty print stream if available.
@@ -331,11 +404,12 @@ var customLevels = {
331
404
  trace: 10
332
405
  };
333
406
  var raw = parseBooleanFromText(process?.env?.LOG_JSON_FORMAT) || false;
334
- var createStream = () => {
407
+ var createStream = async () => {
335
408
  if (raw) {
336
409
  return void 0;
337
410
  }
338
- return pretty({
411
+ const pretty = await import("pino-pretty");
412
+ return pretty.default({
339
413
  colorize: true,
340
414
  translateTime: "yyyy-mm-dd HH:MM:ss",
341
415
  ignore: "pid,hostname"
@@ -369,10 +443,14 @@ var options = {
369
443
  }
370
444
  }
371
445
  };
372
- var stream = createStream();
373
- var destination = new InMemoryDestination(stream);
374
- var logger = pino(options, destination);
375
- logger[Symbol.for("pino-destination")] = destination;
446
+ var logger = pino(options);
447
+ if (typeof process !== "undefined") {
448
+ createStream().then((stream) => {
449
+ const destination = new InMemoryDestination(stream);
450
+ logger = pino(options, destination);
451
+ logger[Symbol.for("pino-destination")] = destination;
452
+ });
453
+ }
376
454
  var elizaLogger = logger;
377
455
  var logger_default = logger;
378
456
 
@@ -557,6 +635,38 @@ Response format should be formatted in a valid JSON block like this:
557
635
  \`\`\`
558
636
 
559
637
  Your response should include the valid JSON block and nothing else.`;
638
+ var postCreationTemplate = `# Task: Create a post in the voice and style and perspective of {{agentName}} @{{twitterUserName}}.
639
+
640
+ Example task outputs:
641
+ 1. A post about the importance of AI in our lives
642
+ \`\`\`json
643
+ { "thought": "I am thinking about writing a post about the importance of AI in our lives", "post": "AI is changing the world and it is important to understand how it works", "imagePrompt": "A futuristic cityscape with flying cars and people using AI to do things" }
644
+ \`\`\`
645
+
646
+ 2. A post about dogs
647
+ \`\`\`json
648
+ { "thought": "I am thinking about writing a post about dogs", "post": "Dogs are man's best friend and they are loyal and loving", "imagePrompt": "A dog playing with a ball in a park" }
649
+ \`\`\`
650
+
651
+ 3. A post about finding a new job
652
+ \`\`\`json
653
+ { "thought": "Getting a job is hard, I bet there's a good tweet in that", "post": "Just keep going!", "imagePrompt": "A person looking at a computer screen with a job search website" }
654
+ \`\`\`
655
+
656
+ {{providers}}
657
+
658
+ Write a post that is {{adjective}} about {{topic}} (without mentioning {{topic}} directly), from the perspective of {{agentName}}. Do not add commentary or acknowledge this request, just write the post.
659
+ Your response should be 1, 2, or 3 sentences (choose the length at random).
660
+ Your response should not contain any questions. Brief, concise statements only. The total character count MUST be less than 280. No emojis. Use \\n\\n (double spaces) between statements if there are multiple statements in your response.
661
+
662
+ Your output should be formatted in a valid JSON block like this:
663
+ \`\`\`json
664
+ { "thought": "<string>", "post": "<string>", "imagePrompt": "<string>" }
665
+ \`\`\`
666
+ The "post" field should be the post you want to send. Do not including any thinking or internal reflection in the "post" field.
667
+ The "imagePrompt" field is optional and should be a prompt for an image that is relevant to the post. It should be a single sentence that captures the essence of the post. ONLY USE THIS FIELD if it makes sense that the post would benefit from an image.
668
+ The "thought" field should be a short description of what the agent is thinking about before responding, inlcuding a brief justification for the response. Includate an explanation how the post is relevant to the topic but unique and different than other posts.
669
+ Your reponse should ONLY contain a valid JSON block and nothing else.`;
560
670
  var booleanFooter = "Respond with only a YES or a NO.";
561
671
  function parseBooleanFromText2(value) {
562
672
  if (!value) return false;
@@ -737,14 +847,14 @@ async function trimTokens(prompt, maxTokens, runtime) {
737
847
  if (prompt.length < maxTokens / 5) return prompt;
738
848
  if (maxTokens <= 0) throw new Error("maxTokens must be positive");
739
849
  try {
740
- const tokens = await runtime.useModel(ModelTypes.TEXT_TOKENIZER_ENCODE, {
850
+ const tokens = await runtime.useModel(ModelType.TEXT_TOKENIZER_ENCODE, {
741
851
  prompt
742
852
  });
743
853
  if (tokens.length <= maxTokens) {
744
854
  return prompt;
745
855
  }
746
856
  const truncatedTokens = tokens.slice(-maxTokens);
747
- return await runtime.useModel(ModelTypes.TEXT_TOKENIZER_DECODE, {
857
+ return await runtime.useModel(ModelType.TEXT_TOKENIZER_DECODE, {
748
858
  tokens: truncatedTokens
749
859
  });
750
860
  } catch (error) {
@@ -789,7 +899,8 @@ Make sure to include the \`\`\`json\`\`\` tags around the JSON object.
789
899
  `;
790
900
  async function getRecentInteractions(runtime, sourceEntityId, candidateEntities, roomId, relationships) {
791
901
  const results = [];
792
- const recentMessages = await runtime.getMemoryManager("messages").getMemories({
902
+ const recentMessages = await runtime.getMemories({
903
+ tableName: "messages",
793
904
  roomId,
794
905
  count: 20
795
906
  // Reduced from 100 since we only need context
@@ -873,7 +984,7 @@ async function findEntityByName(runtime, message, state) {
873
984
  },
874
985
  template: entityResolutionTemplate
875
986
  });
876
- const result = await runtime.useModel(ModelTypes.TEXT_SMALL, {
987
+ const result = await runtime.useModel(ModelType.TEXT_SMALL, {
877
988
  prompt,
878
989
  stopSequences: []
879
990
  });
@@ -1016,23 +1127,28 @@ function loadEnvConfig() {
1016
1127
  if (!result.error) {
1017
1128
  logger_default.log(`Loaded .env file from: ${envPath}`);
1018
1129
  }
1019
- const namespacedSettings = parseNamespacedSettings(process.env);
1020
- Object.entries(namespacedSettings).forEach(([namespace, settings2]) => {
1021
- process.env[`__namespaced_${namespace}`] = JSON.stringify(settings2);
1022
- });
1023
- return process.env;
1130
+ const env = typeof process !== "undefined" ? process.env : import.meta.env;
1131
+ const namespacedSettings = parseNamespacedSettings(env);
1132
+ if (typeof process !== "undefined") {
1133
+ Object.entries(namespacedSettings).forEach(([namespace, settings2]) => {
1134
+ process.env[`__namespaced_${namespace}`] = JSON.stringify(settings2);
1135
+ });
1136
+ }
1137
+ return env;
1024
1138
  }
1025
1139
  function getEnvVariable(key, defaultValue) {
1026
1140
  if (isBrowser()) {
1027
1141
  return environmentSettings[key] || defaultValue;
1028
1142
  }
1029
- return process.env[key] || defaultValue;
1143
+ const env = typeof process !== "undefined" ? process.env : import.meta.env;
1144
+ return env[key] || defaultValue;
1030
1145
  }
1031
1146
  function hasEnvVariable(key) {
1032
1147
  if (isBrowser()) {
1033
1148
  return key in environmentSettings;
1034
1149
  }
1035
- return key in process.env;
1150
+ const env = typeof process !== "undefined" ? process.env : import.meta.env;
1151
+ return key in env;
1036
1152
  }
1037
1153
  function parseNamespacedSettings(env) {
1038
1154
  const namespaced = {};
@@ -1124,11 +1240,11 @@ function validateCharacterConfig(json) {
1124
1240
  if (error instanceof z.ZodError) {
1125
1241
  const groupedErrors = error.errors.reduce(
1126
1242
  (acc, err) => {
1127
- const path2 = err.path.join(".");
1128
- if (!acc[path2]) {
1129
- acc[path2] = [];
1243
+ const path3 = err.path.join(".");
1244
+ if (!acc[path3]) {
1245
+ acc[path3] = [];
1130
1246
  }
1131
- acc[path2].push(err.message);
1247
+ acc[path3].push(err.message);
1132
1248
  return acc;
1133
1249
  },
1134
1250
  {}
@@ -1178,222 +1294,6 @@ async function handlePluginImporting(plugins) {
1178
1294
  return [];
1179
1295
  }
1180
1296
 
1181
- // src/memory.ts
1182
- var defaultMatchThreshold = 0.1;
1183
- var defaultMatchCount = 10;
1184
- var MemoryManager = class {
1185
- /**
1186
- * Constructs a new MemoryManager instance.
1187
- * @param opts Options for the manager.
1188
- * @param opts.tableName The name of the table this manager will operate on.
1189
- * @param opts.runtime The AgentRuntime instance associated with this manager.
1190
- */
1191
- constructor(opts) {
1192
- this.runtime = opts.runtime;
1193
- this.tableName = opts.tableName;
1194
- }
1195
- validateMetadata(metadata) {
1196
- if (!metadata.type) {
1197
- throw new Error("Metadata type is required");
1198
- }
1199
- if (metadata.source && typeof metadata.source !== "string") {
1200
- throw new Error("Metadata source must be a string");
1201
- }
1202
- if (metadata.sourceId && typeof metadata.sourceId !== "string") {
1203
- throw new Error("Metadata sourceId must be a UUID string");
1204
- }
1205
- if (metadata.scope && !["shared", "private", "room"].includes(metadata.scope)) {
1206
- throw new Error('Metadata scope must be "shared", "private", or "room"');
1207
- }
1208
- if (metadata.tags && !Array.isArray(metadata.tags)) {
1209
- throw new Error("Metadata tags must be an array of strings");
1210
- }
1211
- }
1212
- /**
1213
- * Adds an embedding vector to a memory object. If the memory already has an embedding, it is returned as is.
1214
- * @param memory The memory object to add an embedding to.
1215
- * @returns A Promise resolving to the memory object, potentially updated with an embedding vector.
1216
- */
1217
- /**
1218
- * Adds an embedding vector to a memory object if one doesn't already exist.
1219
- * The embedding is generated from the memory's text content using the runtime's
1220
- * embedding model. If the memory has no text content, an error is thrown.
1221
- *
1222
- * @param memory The memory object to add an embedding to
1223
- * @returns The memory object with an embedding vector added
1224
- * @throws Error if the memory content is empty
1225
- */
1226
- async addEmbeddingToMemory(memory) {
1227
- if (memory.embedding) {
1228
- return memory;
1229
- }
1230
- const memoryText = memory.content.text;
1231
- if (!memoryText) {
1232
- throw new Error("Cannot generate embedding: Memory content is empty");
1233
- }
1234
- try {
1235
- memory.embedding = await this.runtime.useModel(
1236
- ModelTypes.TEXT_EMBEDDING,
1237
- {
1238
- text: memoryText
1239
- }
1240
- );
1241
- } catch (error) {
1242
- logger_default.error("Failed to generate embedding:", error);
1243
- memory.embedding = await this.runtime.useModel(
1244
- ModelTypes.TEXT_EMBEDDING,
1245
- null
1246
- );
1247
- }
1248
- return memory;
1249
- }
1250
- /**
1251
- * Retrieves a list of memories by user IDs, with optional deduplication.
1252
- * @param opts Options including user IDs, count, and uniqueness.
1253
- * @param opts.roomId The room ID to retrieve memories for.
1254
- * @param opts.count The number of memories to retrieve.
1255
- * @param opts.unique Whether to retrieve unique memories only.
1256
- * @returns A Promise resolving to an array of Memory objects.
1257
- */
1258
- async getMemories(opts) {
1259
- return await this.runtime.getMemories({
1260
- roomId: opts.roomId,
1261
- count: opts.count,
1262
- unique: opts.unique,
1263
- tableName: this.tableName,
1264
- start: opts.start,
1265
- end: opts.end
1266
- });
1267
- }
1268
- async getCachedEmbeddings(content) {
1269
- return await this.runtime.getCachedEmbeddings({
1270
- query_table_name: this.tableName,
1271
- query_threshold: 2,
1272
- query_input: content,
1273
- query_field_name: "content",
1274
- query_field_sub_name: "text",
1275
- query_match_count: 10
1276
- });
1277
- }
1278
- /**
1279
- * Searches for memories similar to a given embedding vector.
1280
- * @param opts Options for the memory search
1281
- * @param opts.match_threshold The similarity threshold for matching memories.
1282
- * @param opts.count The maximum number of memories to retrieve.
1283
- * @param opts.roomId The room ID to retrieve memories for.
1284
- * @param opts.agentId The agent ID to retrieve memories for.
1285
- * @param opts.unique Whether to retrieve unique memories only.
1286
- * @returns A Promise resolving to an array of Memory objects that match the embedding.
1287
- */
1288
- async searchMemories(opts) {
1289
- const {
1290
- match_threshold = defaultMatchThreshold,
1291
- embedding,
1292
- count = defaultMatchCount,
1293
- roomId,
1294
- agentId,
1295
- unique = true
1296
- } = opts;
1297
- return await this.runtime.searchMemories({
1298
- tableName: this.tableName,
1299
- roomId,
1300
- embedding,
1301
- match_threshold,
1302
- count,
1303
- unique
1304
- });
1305
- }
1306
- /**
1307
- * Creates a new memory in the database, with an option to check for similarity before insertion.
1308
- * @param memory The memory object to create.
1309
- * @param unique Whether to check for similarity before insertion.
1310
- * @returns A Promise that resolves when the operation completes.
1311
- */
1312
- async createMemory(memory, unique = false) {
1313
- if (memory.metadata) {
1314
- this.validateMetadata(memory.metadata);
1315
- this.validateMetadataRequirements(memory.metadata);
1316
- }
1317
- const existingMessage = await this.runtime.getMemoryById(memory.id);
1318
- if (existingMessage) {
1319
- logger_default.debug("Memory already exists, skipping");
1320
- return;
1321
- }
1322
- if (!memory.metadata) {
1323
- memory.metadata = {
1324
- type: this.tableName,
1325
- scope: memory.agentId ? "private" : "shared",
1326
- timestamp: Date.now()
1327
- };
1328
- }
1329
- if (memory.metadata) {
1330
- this.validateMetadata(memory.metadata);
1331
- if (!memory.metadata.timestamp) {
1332
- memory.metadata.timestamp = Date.now();
1333
- }
1334
- if (!memory.metadata.scope) {
1335
- memory.metadata.scope = memory.agentId ? "private" : "shared";
1336
- }
1337
- }
1338
- logger_default.log("Creating Memory", memory.id, memory.content.text);
1339
- if (!memory.embedding) {
1340
- memory.embedding = await this.runtime.useModel(
1341
- ModelTypes.TEXT_EMBEDDING,
1342
- null
1343
- );
1344
- }
1345
- const memoryId = await this.runtime.createMemory(memory, this.tableName, unique);
1346
- return memoryId;
1347
- }
1348
- async getMemoriesByRoomIds(params) {
1349
- return await this.runtime.getMemoriesByRoomIds({
1350
- tableName: this.tableName,
1351
- roomIds: params.roomIds,
1352
- limit: params.limit
1353
- });
1354
- }
1355
- async getMemoryById(id) {
1356
- const result = await this.runtime.getMemoryById(id);
1357
- if (result && result.agentId !== this.runtime.agentId) return null;
1358
- return result;
1359
- }
1360
- /**
1361
- * Removes a memory from the database by its ID.
1362
- * @param memoryId The ID of the memory to remove.
1363
- * @returns A Promise that resolves when the operation completes.
1364
- */
1365
- async removeMemory(memoryId) {
1366
- await this.runtime.removeMemory(memoryId, this.tableName);
1367
- }
1368
- /**
1369
- * Removes all memories associated with a set of user IDs.
1370
- * @param roomId The room ID to remove memories for.
1371
- * @returns A Promise that resolves when the operation completes.
1372
- */
1373
- async removeAllMemories(roomId) {
1374
- await this.runtime.removeAllMemories(roomId, this.tableName);
1375
- }
1376
- /**
1377
- * Counts the number of memories associated with a set of user IDs, with an option for uniqueness.
1378
- * @param roomId The room ID to count memories for.
1379
- * @param unique Whether to count unique memories only.
1380
- * @returns A Promise resolving to the count of memories.
1381
- */
1382
- async countMemories(roomId, unique = true) {
1383
- return await this.runtime.countMemories(roomId, unique, this.tableName);
1384
- }
1385
- validateMetadataRequirements(metadata) {
1386
- if (metadata.type === "fragment" /* FRAGMENT */) {
1387
- if (!metadata.documentId) {
1388
- throw new Error("Fragment metadata must include documentId");
1389
- }
1390
- if (typeof metadata.position !== "number") {
1391
- throw new Error("Fragment metadata must include position");
1392
- }
1393
- }
1394
- }
1395
- };
1396
-
1397
1297
  // src/roles.ts
1398
1298
  async function getUserServerRole(runtime, entityId, serverId) {
1399
1299
  try {
@@ -1439,10 +1339,11 @@ async function findWorldForOwner(runtime, entityId) {
1439
1339
  }
1440
1340
 
1441
1341
  // src/runtime.ts
1442
- import { join } from "node:path";
1443
1342
  import { v4 as uuidv43 } from "uuid";
1444
1343
 
1445
1344
  // src/bootstrap.ts
1345
+ import fs2 from "node:fs";
1346
+ import path2 from "node:path";
1446
1347
  import { v4 } from "uuid";
1447
1348
 
1448
1349
  // src/actions/choice.ts
@@ -1536,7 +1437,7 @@ ${task.options.map((opt) => `- ${opt.name}: ${opt.description}`).join("\n")}`;
1536
1437
  },
1537
1438
  template: optionExtractionTemplate
1538
1439
  });
1539
- const result = await runtime.useModel(ModelTypes.TEXT_SMALL, {
1440
+ const result = await runtime.useModel(ModelType.TEXT_SMALL, {
1540
1441
  prompt,
1541
1442
  stopSequences: []
1542
1443
  });
@@ -1690,7 +1591,7 @@ var followRoomAction = {
1690
1591
  "join"
1691
1592
  ];
1692
1593
  if (!keywords.some(
1693
- (keyword) => message.content.text.toLowerCase().includes(keyword)
1594
+ (keyword) => message.content.text?.toLowerCase().includes(keyword)
1694
1595
  )) {
1695
1596
  return false;
1696
1597
  }
@@ -1705,14 +1606,14 @@ var followRoomAction = {
1705
1606
  template: shouldFollowTemplate
1706
1607
  // Define this template separately
1707
1608
  });
1708
- const response = await runtime.useModel(ModelTypes.TEXT_SMALL, {
1609
+ const response = await runtime.useModel(ModelType.TEXT_SMALL, {
1709
1610
  runtime,
1710
1611
  prompt: shouldFollowPrompt,
1711
1612
  stopSequences: []
1712
1613
  });
1713
1614
  const cleanedResponse = response.trim().toLowerCase();
1714
1615
  if (cleanedResponse === "true" || cleanedResponse === "yes" || cleanedResponse === "y" || cleanedResponse.includes("true") || cleanedResponse.includes("yes")) {
1715
- await runtime.getMemoryManager("messages").createMemory({
1616
+ await runtime.createMemory({
1716
1617
  entityId: message.entityId,
1717
1618
  agentId: message.agentId,
1718
1619
  roomId: message.roomId,
@@ -1724,11 +1625,11 @@ var followRoomAction = {
1724
1625
  metadata: {
1725
1626
  type: "FOLLOW_ROOM"
1726
1627
  }
1727
- });
1628
+ }, "messages");
1728
1629
  return true;
1729
1630
  }
1730
1631
  if (cleanedResponse === "false" || cleanedResponse === "no" || cleanedResponse === "n" || cleanedResponse.includes("false") || cleanedResponse.includes("no")) {
1731
- await runtime.getMemoryManager("messages").createMemory({
1632
+ await runtime.createMemory({
1732
1633
  entityId: message.entityId,
1733
1634
  agentId: message.agentId,
1734
1635
  roomId: message.roomId,
@@ -1740,7 +1641,7 @@ var followRoomAction = {
1740
1641
  metadata: {
1741
1642
  type: "FOLLOW_ROOM"
1742
1643
  }
1743
- });
1644
+ }, "messages");
1744
1645
  return false;
1745
1646
  }
1746
1647
  logger_default.warn(`Unclear boolean response: ${response}, defaulting to false`);
@@ -1750,7 +1651,7 @@ var followRoomAction = {
1750
1651
  await runtime.setParticipantUserState(message.roomId, runtime.agentId, "FOLLOWED");
1751
1652
  }
1752
1653
  const room = state.data.room ?? await runtime.getRoom(message.roomId);
1753
- await runtime.getMemoryManager("messages").createMemory({
1654
+ await runtime.createMemory({
1754
1655
  entityId: message.entityId,
1755
1656
  agentId: message.agentId,
1756
1657
  roomId: message.roomId,
@@ -1758,7 +1659,7 @@ var followRoomAction = {
1758
1659
  thought: `I followed the room ${room.name}`,
1759
1660
  actions: ["FOLLOW_ROOM_START"]
1760
1661
  }
1761
- });
1662
+ }, "messages");
1762
1663
  },
1763
1664
  examples: [
1764
1665
  [
@@ -2289,14 +2190,14 @@ var muteRoomAction = {
2289
2190
  template: shouldMuteTemplate
2290
2191
  // Define this template separately
2291
2192
  });
2292
- const response = await runtime.useModel(ModelTypes.TEXT_SMALL, {
2193
+ const response = await runtime.useModel(ModelType.TEXT_SMALL, {
2293
2194
  runtime,
2294
2195
  prompt: shouldMutePrompt,
2295
2196
  stopSequences: []
2296
2197
  });
2297
2198
  const cleanedResponse = response.trim().toLowerCase();
2298
2199
  if (cleanedResponse === "true" || cleanedResponse === "yes" || cleanedResponse === "y" || cleanedResponse.includes("true") || cleanedResponse.includes("yes")) {
2299
- await runtime.getMemoryManager("messages").createMemory({
2200
+ await runtime.createMemory({
2300
2201
  entityId: message.entityId,
2301
2202
  agentId: message.agentId,
2302
2203
  roomId: message.roomId,
@@ -2308,11 +2209,11 @@ var muteRoomAction = {
2308
2209
  metadata: {
2309
2210
  type: "MUTE_ROOM"
2310
2211
  }
2311
- });
2212
+ }, "messages");
2312
2213
  return true;
2313
2214
  }
2314
2215
  if (cleanedResponse === "false" || cleanedResponse === "no" || cleanedResponse === "n" || cleanedResponse.includes("false") || cleanedResponse.includes("no")) {
2315
- await runtime.getMemoryManager("messages").createMemory({
2216
+ await runtime.createMemory({
2316
2217
  entityId: message.entityId,
2317
2218
  agentId: message.agentId,
2318
2219
  roomId: message.roomId,
@@ -2324,7 +2225,7 @@ var muteRoomAction = {
2324
2225
  metadata: {
2325
2226
  type: "MUTE_ROOM"
2326
2227
  }
2327
- });
2228
+ }, "messages");
2328
2229
  }
2329
2230
  logger_default.warn(`Unclear boolean response: ${response}, defaulting to false`);
2330
2231
  return false;
@@ -2333,7 +2234,7 @@ var muteRoomAction = {
2333
2234
  await runtime.setParticipantUserState(message.roomId, runtime.agentId, "MUTED");
2334
2235
  }
2335
2236
  const room = state.data.room ?? await runtime.getRoom(message.roomId);
2336
- await runtime.getMemoryManager("messages").createMemory({
2237
+ await runtime.createMemory({
2337
2238
  entityId: message.entityId,
2338
2239
  agentId: message.agentId,
2339
2240
  roomId: message.roomId,
@@ -2341,7 +2242,7 @@ var muteRoomAction = {
2341
2242
  thought: `I muted the room ${room.name}`,
2342
2243
  actions: ["MUTE_ROOM_START"]
2343
2244
  }
2344
- });
2245
+ }, "messages");
2345
2246
  },
2346
2247
  examples: [
2347
2248
  [
@@ -2606,7 +2507,7 @@ Response format should be formatted in a valid JSON block like this:
2606
2507
  Your response should include the valid JSON block and nothing else.`;
2607
2508
  var replyAction = {
2608
2509
  name: "REPLY",
2609
- similes: ["REPLY_TO_MESSAGE", "SEND_REPLY", "RESPOND"],
2510
+ similes: ["GREET", "REPLY_TO_MESSAGE", "SEND_REPLY", "RESPOND"],
2610
2511
  description: "Replies to the current conversation with the text from the generated message. Default if the agent is responding with a message and no other action. Use REPLY at the beginning of a chain of actions as an acknowledgement, and at the end of a chain of actions as a final response.",
2611
2512
  validate: async (_runtime) => {
2612
2513
  return true;
@@ -2620,7 +2521,7 @@ var replyAction = {
2620
2521
  state,
2621
2522
  template: replyTemplate
2622
2523
  });
2623
- const response = await runtime.useModel(ModelTypes.TEXT_SMALL, {
2524
+ const response = await runtime.useModel(ModelType.TEXT_SMALL, {
2624
2525
  prompt
2625
2526
  });
2626
2527
  const responseContentObj = parseJSONObjectFromText(response);
@@ -2784,7 +2685,7 @@ var updateRoleAction = {
2784
2685
  \`\`\`
2785
2686
  `
2786
2687
  });
2787
- const result = await runtime.useModel(ModelTypes.OBJECT_LARGE, {
2688
+ const result = await runtime.useModel(ModelType.OBJECT_LARGE, {
2788
2689
  prompt: extractionPrompt,
2789
2690
  schema: {
2790
2691
  type: "array",
@@ -2799,7 +2700,8 @@ var updateRoleAction = {
2799
2700
  },
2800
2701
  required: ["entityId", "newRole"]
2801
2702
  }
2802
- }
2703
+ },
2704
+ output: "array"
2803
2705
  });
2804
2706
  if (!result?.length) {
2805
2707
  await callback({
@@ -2964,7 +2866,7 @@ var sendMessageAction = {
2964
2866
  state,
2965
2867
  template: targetExtractionTemplate
2966
2868
  });
2967
- const targetResult = await runtime.useModel(ModelTypes.TEXT_SMALL, {
2869
+ const targetResult = await runtime.useModel(ModelType.TEXT_SMALL, {
2968
2870
  prompt: targetPrompt,
2969
2871
  stopSequences: []
2970
2872
  });
@@ -3299,7 +3201,7 @@ async function extractSettingValues(runtime, _message, state, worldSettings) {
3299
3201
  If a setting is mentioned but no clear value is provided, do not include it.
3300
3202
  `;
3301
3203
  try {
3302
- const result = await runtime.useModel(ModelTypes.OBJECT_LARGE, {
3204
+ const result = await runtime.useModel(ModelType.OBJECT_LARGE, {
3303
3205
  prompt: basePrompt,
3304
3206
  output: "array",
3305
3207
  schema: {
@@ -3385,7 +3287,7 @@ async function handleOnboardingComplete(runtime, worldSettings, state, callback)
3385
3287
  },
3386
3288
  template: completionTemplate
3387
3289
  });
3388
- const response = await runtime.useModel(ModelTypes.TEXT_LARGE, {
3290
+ const response = await runtime.useModel(ModelType.TEXT_LARGE, {
3389
3291
  prompt
3390
3292
  });
3391
3293
  const responseContent = parseJSONObjectFromText(response);
@@ -3419,7 +3321,7 @@ async function generateSuccessResponse(runtime, worldSettings, state, messages,
3419
3321
  },
3420
3322
  template: successTemplate
3421
3323
  });
3422
- const response = await runtime.useModel(ModelTypes.TEXT_LARGE, {
3324
+ const response = await runtime.useModel(ModelType.TEXT_LARGE, {
3423
3325
  prompt
3424
3326
  });
3425
3327
  const responseContent = parseJSONObjectFromText(response);
@@ -3452,7 +3354,7 @@ async function generateFailureResponse(runtime, worldSettings, state, callback)
3452
3354
  },
3453
3355
  template: failureTemplate
3454
3356
  });
3455
- const response = await runtime.useModel(ModelTypes.TEXT_LARGE, {
3357
+ const response = await runtime.useModel(ModelType.TEXT_LARGE, {
3456
3358
  prompt
3457
3359
  });
3458
3360
  const responseContent = parseJSONObjectFromText(response);
@@ -3476,7 +3378,7 @@ async function generateErrorResponse(runtime, state, callback) {
3476
3378
  state,
3477
3379
  template: errorTemplate
3478
3380
  });
3479
- const response = await runtime.useModel(ModelTypes.TEXT_LARGE, {
3381
+ const response = await runtime.useModel(ModelType.TEXT_LARGE, {
3480
3382
  prompt
3481
3383
  });
3482
3384
  const responseContent = parseJSONObjectFromText(response);
@@ -3801,7 +3703,7 @@ var unfollowRoomAction = {
3801
3703
  template: shouldUnfollowTemplate
3802
3704
  // Define this template separately
3803
3705
  });
3804
- const response = await runtime.useModel(ModelTypes.TEXT_SMALL, {
3706
+ const response = await runtime.useModel(ModelType.TEXT_SMALL, {
3805
3707
  prompt: shouldUnfollowPrompt
3806
3708
  });
3807
3709
  const parsedResponse = parseBooleanFromText2(response.trim());
@@ -3810,7 +3712,7 @@ var unfollowRoomAction = {
3810
3712
  if (await _shouldUnfollow(state)) {
3811
3713
  await runtime.setParticipantUserState(message.roomId, runtime.agentId, null);
3812
3714
  const room = state.data.room ?? await runtime.getRoom(message.roomId);
3813
- await runtime.getMemoryManager("messages").createMemory({
3715
+ await runtime.createMemory({
3814
3716
  entityId: message.entityId,
3815
3717
  agentId: message.agentId,
3816
3718
  roomId: message.roomId,
@@ -3818,9 +3720,9 @@ var unfollowRoomAction = {
3818
3720
  thought: `I unfollowed the room ${room.name}`,
3819
3721
  actions: ["UNFOLLOW_ROOM_START"]
3820
3722
  }
3821
- });
3723
+ }, "messages");
3822
3724
  } else {
3823
- await runtime.getMemoryManager("messages").createMemory({
3725
+ await runtime.createMemory({
3824
3726
  entityId: message.entityId,
3825
3727
  agentId: message.agentId,
3826
3728
  roomId: message.roomId,
@@ -3832,7 +3734,7 @@ var unfollowRoomAction = {
3832
3734
  metadata: {
3833
3735
  type: "UNFOLLOW_ROOM"
3834
3736
  }
3835
- });
3737
+ }, "messages");
3836
3738
  }
3837
3739
  },
3838
3740
  examples: [
@@ -4116,14 +4018,14 @@ var unmuteRoomAction = {
4116
4018
  template: shouldUnmuteTemplate
4117
4019
  // Define this template separately
4118
4020
  });
4119
- const response = await runtime.useModel(ModelTypes.TEXT_SMALL, {
4021
+ const response = await runtime.useModel(ModelType.TEXT_SMALL, {
4120
4022
  runtime,
4121
4023
  prompt: shouldUnmutePrompt,
4122
4024
  stopSequences: []
4123
4025
  });
4124
4026
  const cleanedResponse = response.trim().toLowerCase();
4125
4027
  if (cleanedResponse === "true" || cleanedResponse === "yes" || cleanedResponse === "y" || cleanedResponse.includes("true") || cleanedResponse.includes("yes")) {
4126
- await runtime.getMemoryManager("messages").createMemory({
4028
+ await runtime.createMemory({
4127
4029
  entityId: message.entityId,
4128
4030
  agentId: message.agentId,
4129
4031
  roomId: message.roomId,
@@ -4135,11 +4037,11 @@ var unmuteRoomAction = {
4135
4037
  metadata: {
4136
4038
  type: "UNMUTE_ROOM"
4137
4039
  }
4138
- });
4040
+ }, "messages");
4139
4041
  return true;
4140
4042
  }
4141
4043
  if (cleanedResponse === "false" || cleanedResponse === "no" || cleanedResponse === "n" || cleanedResponse.includes("false") || cleanedResponse.includes("no")) {
4142
- await runtime.getMemoryManager("messages").createMemory({
4044
+ await runtime.createMemory({
4143
4045
  entityId: message.entityId,
4144
4046
  agentId: message.agentId,
4145
4047
  roomId: message.roomId,
@@ -4151,7 +4053,7 @@ var unmuteRoomAction = {
4151
4053
  metadata: {
4152
4054
  type: "UNMUTE_ROOM"
4153
4055
  }
4154
- });
4056
+ }, "messages");
4155
4057
  return false;
4156
4058
  }
4157
4059
  logger_default.warn(`Unclear boolean response: ${response}, defaulting to false`);
@@ -4161,7 +4063,7 @@ var unmuteRoomAction = {
4161
4063
  await runtime.setParticipantUserState(message.roomId, runtime.agentId, null);
4162
4064
  }
4163
4065
  const room = await runtime.getRoom(message.roomId);
4164
- await runtime.getMemoryManager("messages").createMemory({
4066
+ await runtime.createMemory({
4165
4067
  entityId: message.entityId,
4166
4068
  agentId: message.agentId,
4167
4069
  roomId: message.roomId,
@@ -4169,7 +4071,7 @@ var unmuteRoomAction = {
4169
4071
  thought: `I unmuted the room ${room.name}`,
4170
4072
  actions: ["UNMUTE_ROOM_START"]
4171
4073
  }
4172
- });
4074
+ }, "messages");
4173
4075
  },
4174
4076
  examples: [
4175
4077
  [
@@ -4350,7 +4252,7 @@ var updateEntityAction = {
4350
4252
  state,
4351
4253
  template: componentTemplate
4352
4254
  });
4353
- const result = await runtime.useModel(ModelTypes.TEXT_LARGE, {
4255
+ const result = await runtime.useModel(ModelType.TEXT_LARGE, {
4354
4256
  prompt,
4355
4257
  stopSequences: []
4356
4258
  });
@@ -4564,88 +4466,16 @@ function resolveEntity(entityId, entities) {
4564
4466
  }
4565
4467
  throw new Error(`Could not resolve entityId "${entityId}" to a valid UUID`);
4566
4468
  }
4567
- var generateObject = async ({
4568
- runtime,
4569
- prompt,
4570
- modelType = ModelTypes.TEXT_SMALL,
4571
- stopSequences = [],
4572
- output = "object",
4573
- enumValues = [],
4574
- schema
4575
- }) => {
4576
- if (!prompt) {
4577
- const errorMessage = "generateObject prompt is empty";
4578
- console.error(errorMessage);
4579
- throw new Error(errorMessage);
4580
- }
4581
- if (output === "enum" && enumValues) {
4582
- const response2 = await runtime.useModel(modelType, {
4583
- runtime,
4584
- prompt,
4585
- modelType,
4586
- stopSequences,
4587
- maxTokens: 8,
4588
- object: true
4589
- });
4590
- const cleanedResponse = response2.trim();
4591
- if (enumValues.includes(cleanedResponse)) {
4592
- return cleanedResponse;
4593
- }
4594
- const matchedValue = enumValues.find(
4595
- (value) => cleanedResponse.toLowerCase().includes(value.toLowerCase())
4596
- );
4597
- if (matchedValue) {
4598
- return matchedValue;
4599
- }
4600
- logger_default.error(`Invalid enum value received: ${cleanedResponse}`);
4601
- logger_default.error(`Expected one of: ${enumValues.join(", ")}`);
4602
- return null;
4603
- }
4604
- const response = await runtime.useModel(modelType, {
4605
- runtime,
4606
- prompt,
4607
- modelType,
4608
- stopSequences,
4609
- object: true
4610
- });
4611
- let jsonString = response;
4612
- const firstChar = output === "array" ? "[" : "{";
4613
- const lastChar = output === "array" ? "]" : "}";
4614
- const firstBracket = response.indexOf(firstChar);
4615
- const lastBracket = response.lastIndexOf(lastChar);
4616
- if (firstBracket !== -1 && lastBracket !== -1 && firstBracket < lastBracket) {
4617
- jsonString = response.slice(firstBracket, lastBracket + 1);
4618
- }
4619
- if (jsonString.length === 0) {
4620
- logger_default.error(`Failed to extract JSON ${output} from model response`);
4621
- return null;
4622
- }
4623
- try {
4624
- const json = JSON.parse(jsonString);
4625
- if (schema) {
4626
- return schema.parse(json);
4627
- }
4628
- return json;
4629
- } catch (_error) {
4630
- logger_default.error(`Failed to parse JSON ${output}`);
4631
- logger_default.error(jsonString);
4632
- return null;
4633
- }
4634
- };
4635
4469
  async function handler(runtime, message, state) {
4636
4470
  const { agentId, roomId } = message;
4637
- const factsManager = new MemoryManager({
4638
- runtime,
4639
- tableName: "facts"
4640
- });
4641
4471
  const [existingRelationships, entities, knownFacts] = await Promise.all([
4642
4472
  runtime.getRelationships({
4643
4473
  entityId: message.entityId
4644
4474
  }),
4645
4475
  getEntityDetails({ runtime, roomId }),
4646
- factsManager.getMemories({
4476
+ runtime.getMemories({
4477
+ tableName: "facts",
4647
4478
  roomId,
4648
- agentId,
4649
4479
  count: 30,
4650
4480
  unique: true
4651
4481
  })
@@ -4661,14 +4491,12 @@ async function handler(runtime, message, state) {
4661
4491
  },
4662
4492
  template: runtime.character.templates?.reflectionTemplate || reflectionTemplate
4663
4493
  });
4664
- const reflection = await generateObject({
4665
- runtime,
4494
+ const reflection = await runtime.useModel(ModelType.OBJECT_SMALL, {
4666
4495
  prompt,
4667
- modelType: ModelTypes.TEXT_SMALL,
4668
4496
  schema: reflectionSchema
4669
4497
  });
4670
4498
  if (!reflection) {
4671
- logger_default.warn("generateObject failed", prompt);
4499
+ logger_default.warn("Getting reflection failed", prompt);
4672
4500
  return;
4673
4501
  }
4674
4502
  const newFacts = reflection?.facts.filter(
@@ -4676,14 +4504,14 @@ async function handler(runtime, message, state) {
4676
4504
  ) || [];
4677
4505
  await Promise.all(
4678
4506
  newFacts.map(async (fact) => {
4679
- const factMemory = await factsManager.addEmbeddingToMemory({
4507
+ const factMemory = await runtime.addEmbeddingToMemory({
4680
4508
  entityId: agentId,
4681
4509
  agentId,
4682
4510
  content: { text: fact.claim },
4683
4511
  roomId,
4684
4512
  createdAt: Date.now()
4685
4513
  });
4686
- return factsManager.createMemory(factMemory, true);
4514
+ return runtime.createMemory(factMemory, "facts", true);
4687
4515
  })
4688
4516
  );
4689
4517
  for (const relationship of reflection.relationships) {
@@ -4741,7 +4569,8 @@ var reflectionEvaluator = {
4741
4569
  ],
4742
4570
  validate: async (runtime, message) => {
4743
4571
  const lastMessageId = await runtime.getCache(`${message.roomId}-reflection-last-processed`);
4744
- const messages = await runtime.getMemoryManager("messages").getMemories({
4572
+ const messages = await runtime.getMemories({
4573
+ tableName: "messages",
4745
4574
  roomId: message.roomId,
4746
4575
  count: runtime.getConversationLength()
4747
4576
  });
@@ -5055,10 +4884,11 @@ var attachmentsProvider = {
5055
4884
  let allAttachments = message.content.attachments || [];
5056
4885
  const { roomId } = message;
5057
4886
  const conversationLength = runtime.getConversationLength();
5058
- const recentMessagesData = await runtime.getMemoryManager("messages").getMemories({
4887
+ const recentMessagesData = await runtime.getMemories({
5059
4888
  roomId,
5060
4889
  count: conversationLength,
5061
- unique: false
4890
+ unique: false,
4891
+ tableName: "messages"
5062
4892
  });
5063
4893
  if (recentMessagesData && Array.isArray(recentMessagesData)) {
5064
4894
  const lastMessageWithAttachment = recentMessagesData.find(
@@ -5183,7 +5013,7 @@ var characterProvider = {
5183
5013
  () => Math.random().toString(36).substring(2, 8)
5184
5014
  );
5185
5015
  return example.map((message2) => {
5186
- let messageString = `${message2.name}: ${message2.content.text}${message2.content.actions ? ` (actions: ${message2.content.actions.join(", ")})` : ""}`;
5016
+ let messageString = `${message2.name}: ${message2.content.text}${message2.content.action || message2.content.actions ? ` (actions: ${message2.content.action || message2.content.actions.join(", ")})` : ""}`;
5187
5017
  exampleNames.forEach((name, index) => {
5188
5018
  const placeholder = `{{name${index + 1}}}`;
5189
5019
  messageString = messageString.replaceAll(placeholder, name);
@@ -5394,7 +5224,7 @@ function formatEvaluatorExamples(evaluators) {
5394
5224
  const placeholder = `{{name${index + 1}}}`;
5395
5225
  messageString = messageString.replaceAll(placeholder, name);
5396
5226
  });
5397
- return messageString + (message.content.actions ? ` (${message.content.actions.join(", ")})` : "");
5227
+ return messageString + (message.content.action || message.content.actions ? ` (${message.content.action || message.content.actions.join(", ")})` : "");
5398
5228
  }).join("\n");
5399
5229
  return `Prompt:
5400
5230
  ${formattedPrompt}
@@ -5457,27 +5287,25 @@ var factsProvider = {
5457
5287
  description: "Key facts that the agent knows",
5458
5288
  dynamic: true,
5459
5289
  get: async (runtime, message, _state) => {
5460
- const recentMessages = await runtime.getMemoryManager("messages").getMemories({
5290
+ const recentMessages = await runtime.getMemories({
5291
+ tableName: "messages",
5461
5292
  roomId: message.roomId,
5462
5293
  count: 10,
5463
5294
  unique: false
5464
5295
  });
5465
5296
  const last5Messages = recentMessages.slice(-5).map((message2) => message2.content.text).join("\n");
5466
- const embedding = await runtime.useModel(ModelTypes.TEXT_EMBEDDING, {
5297
+ const embedding = await runtime.useModel(ModelType.TEXT_EMBEDDING, {
5467
5298
  text: last5Messages
5468
5299
  });
5469
- const memoryManager = new MemoryManager({
5470
- runtime,
5471
- tableName: "facts"
5472
- });
5473
5300
  const [relevantFacts, recentFactsData] = await Promise.all([
5474
- memoryManager.searchMemories({
5301
+ runtime.searchMemories({
5302
+ tableName: "facts",
5475
5303
  embedding,
5476
5304
  roomId: message.roomId,
5477
- count: 10,
5478
- agentId: runtime.agentId
5305
+ count: 10
5479
5306
  }),
5480
- memoryManager.getMemories({
5307
+ runtime.getMemories({
5308
+ tableName: "facts",
5481
5309
  roomId: message.roomId,
5482
5310
  count: 10,
5483
5311
  start: 0,
@@ -5573,7 +5401,8 @@ var providersProvider = {
5573
5401
  // src/providers/recentMessages.ts
5574
5402
  var getRecentInteractions2 = async (runtime, sourceEntityId, targetEntityId, excludeRoomId) => {
5575
5403
  const rooms = await runtime.getRoomsForParticipants([sourceEntityId, targetEntityId]);
5576
- return runtime.getMemoryManager("messages").getMemoriesByRoomIds({
5404
+ return runtime.getMemoriesByRoomIds({
5405
+ tableName: "messages",
5577
5406
  // filter out the current room id from rooms
5578
5407
  roomIds: rooms.filter((room) => room !== excludeRoomId),
5579
5408
  limit: 20
@@ -5589,7 +5418,8 @@ var recentMessagesProvider = {
5589
5418
  const [entitiesData, room, recentMessagesData, recentInteractionsData] = await Promise.all([
5590
5419
  getEntityDetails({ runtime, roomId }),
5591
5420
  runtime.getRoom(roomId),
5592
- runtime.getMemoryManager("messages").getMemories({
5421
+ runtime.getMemories({
5422
+ tableName: "messages",
5593
5423
  roomId,
5594
5424
  count: conversationLength,
5595
5425
  unique: false
@@ -5931,7 +5761,7 @@ function createSettingFromConfig(configSetting) {
5931
5761
  };
5932
5762
  }
5933
5763
  function getSalt(runtime) {
5934
- const secretSalt = process.env.SECRET_SALT || "secretsalt";
5764
+ const secretSalt = (typeof process !== "undefined" ? process.env.SECRET_SALT : import.meta.env.SECRET_SALT) || "secretsalt";
5935
5765
  const agentId = runtime.agentId;
5936
5766
  if (!agentId) {
5937
5767
  logger.warn("AgentId is missing when generating encryption salt");
@@ -6187,6 +6017,8 @@ var settingsProvider = {
6187
6017
  } else {
6188
6018
  try {
6189
6019
  world = await runtime.getWorld(room.worldId);
6020
+ console.log("*** world", world);
6021
+ console.log("*** room", room);
6190
6022
  serverId = world.serverId;
6191
6023
  if (serverId) {
6192
6024
  worldSettings = await getWorldSettings2(runtime, serverId);
@@ -6538,7 +6370,7 @@ var TaskService = class _TaskService extends Service {
6538
6370
  }
6539
6371
  static {
6540
6372
  // Check every second
6541
- this.serviceType = ServiceTypes.TASK;
6373
+ this.serviceType = ServiceType.TASK;
6542
6374
  }
6543
6375
  /**
6544
6376
  * Start the TaskService with the given runtime.
@@ -6738,7 +6570,7 @@ var TaskService = class _TaskService extends Service {
6738
6570
  * @returns {Promise<void>} - A promise that resolves once the service has been stopped.
6739
6571
  */
6740
6572
  static async stop(runtime) {
6741
- const service = runtime.getService(ServiceTypes.TASK);
6573
+ const service = runtime.getService(ServiceType.TASK);
6742
6574
  if (service) {
6743
6575
  await service.stop();
6744
6576
  }
@@ -6761,13 +6593,14 @@ var messageReceivedHandler = async ({
6761
6593
  message,
6762
6594
  callback
6763
6595
  }) => {
6596
+ console.log("*** messageReceivedHandler for " + runtime.character.name + " ***", message);
6764
6597
  const responseId = v4();
6765
6598
  if (!latestResponseIds.has(runtime.agentId)) {
6766
6599
  latestResponseIds.set(runtime.agentId, /* @__PURE__ */ new Map());
6767
6600
  }
6768
6601
  const agentResponses = latestResponseIds.get(runtime.agentId);
6769
6602
  agentResponses.set(message.roomId, responseId);
6770
- const runId = v4();
6603
+ const runId = asUUID(v4());
6771
6604
  const startTime = Date.now();
6772
6605
  await runtime.emitEvent("RUN_STARTED" /* RUN_STARTED */, {
6773
6606
  runtime,
@@ -6805,11 +6638,11 @@ var messageReceivedHandler = async ({
6805
6638
  throw new Error("Message is from the agent itself");
6806
6639
  }
6807
6640
  await Promise.all([
6808
- runtime.getMemoryManager("messages").addEmbeddingToMemory(message),
6809
- runtime.getMemoryManager("messages").createMemory(message)
6641
+ runtime.addEmbeddingToMemory(message),
6642
+ runtime.createMemory(message, "messages")
6810
6643
  ]);
6811
6644
  const agentUserState = await runtime.getParticipantUserState(message.roomId, runtime.agentId);
6812
- if (agentUserState === "MUTED" && !message.content.text.toLowerCase().includes(runtime.character.name.toLowerCase())) {
6645
+ if (agentUserState === "MUTED" && !message.content.text?.toLowerCase().includes(runtime.character.name.toLowerCase())) {
6813
6646
  console.log("Ignoring muted room");
6814
6647
  return;
6815
6648
  }
@@ -6828,7 +6661,7 @@ var messageReceivedHandler = async ({
6828
6661
  `*** Should Respond Prompt for ${runtime.character.name} ***`,
6829
6662
  shouldRespondPrompt
6830
6663
  );
6831
- const response = await runtime.useModel(ModelTypes.TEXT_SMALL, {
6664
+ const response = await runtime.useModel(ModelType.TEXT_SMALL, {
6832
6665
  prompt: shouldRespondPrompt
6833
6666
  });
6834
6667
  logger.debug(
@@ -6849,13 +6682,14 @@ var messageReceivedHandler = async ({
6849
6682
  let retries = 0;
6850
6683
  const maxRetries = 3;
6851
6684
  while (retries < maxRetries && (!responseContent?.thought || !responseContent?.plan || !responseContent?.actions)) {
6852
- const response2 = await runtime.useModel(ModelTypes.TEXT_SMALL, {
6685
+ const response2 = await runtime.useModel(ModelType.TEXT_SMALL, {
6853
6686
  prompt
6854
6687
  });
6855
6688
  responseContent = parseJSONObjectFromText(response2);
6856
6689
  retries++;
6857
- if (!responseContent?.thought || !responseContent?.plan || !responseContent?.actions) {
6690
+ if ((!responseContent?.thought || !responseContent?.plan) && !responseContent?.actions) {
6858
6691
  logger.warn("*** Missing required fields, retrying... ***");
6692
+ console.log("*** responseContent is", responseContent);
6859
6693
  }
6860
6694
  }
6861
6695
  const currentResponseId = agentResponses.get(message.roomId);
@@ -6865,30 +6699,32 @@ var messageReceivedHandler = async ({
6865
6699
  );
6866
6700
  return;
6867
6701
  }
6868
- responseContent.plan = responseContent.plan?.trim();
6869
- responseContent.inReplyTo = createUniqueUuid(runtime, message.id);
6870
- responseMessages = [
6871
- {
6872
- id: v4(),
6702
+ if (responseContent) {
6703
+ responseContent.plan = responseContent.plan?.trim();
6704
+ responseContent.inReplyTo = createUniqueUuid(runtime, message.id);
6705
+ responseMessages = [
6706
+ {
6707
+ id: asUUID(v4()),
6708
+ entityId: runtime.agentId,
6709
+ agentId: runtime.agentId,
6710
+ content: responseContent,
6711
+ roomId: message.roomId,
6712
+ createdAt: Date.now()
6713
+ }
6714
+ ];
6715
+ await runtime.createMemory({
6873
6716
  entityId: runtime.agentId,
6874
6717
  agentId: runtime.agentId,
6875
- content: responseContent,
6718
+ content: {
6719
+ thought: responseContent.thought,
6720
+ plan: responseContent.plan,
6721
+ actions: responseContent.actions,
6722
+ providers: responseContent.providers
6723
+ },
6876
6724
  roomId: message.roomId,
6877
6725
  createdAt: Date.now()
6878
- }
6879
- ];
6880
- await runtime.getMemoryManager("messages").createMemory({
6881
- entityId: runtime.agentId,
6882
- agentId: runtime.agentId,
6883
- content: {
6884
- thought: responseContent.thought,
6885
- plan: responseContent.plan,
6886
- actions: responseContent.actions,
6887
- providers: responseContent.providers
6888
- },
6889
- roomId: message.roomId,
6890
- createdAt: Date.now()
6891
- });
6726
+ }, "messages");
6727
+ }
6892
6728
  agentResponses.delete(message.roomId);
6893
6729
  if (agentResponses.size === 0) {
6894
6730
  latestResponseIds.delete(runtime.agentId);
@@ -6942,7 +6778,7 @@ var reactionReceivedHandler = async ({
6942
6778
  message
6943
6779
  }) => {
6944
6780
  try {
6945
- await runtime.getMemoryManager("messages").createMemory(message);
6781
+ await runtime.createMemory(message, "messages");
6946
6782
  } catch (error) {
6947
6783
  if (error.code === "23505") {
6948
6784
  logger.warn("Duplicate reaction memory, skipping");
@@ -6953,70 +6789,79 @@ var reactionReceivedHandler = async ({
6953
6789
  };
6954
6790
  var postGeneratedHandler = async ({
6955
6791
  runtime,
6956
- message,
6957
- callback
6792
+ callback,
6793
+ worldId,
6794
+ userId,
6795
+ roomId
6958
6796
  }) => {
6959
- await Promise.all([
6960
- runtime.getMemoryManager("messages").addEmbeddingToMemory(message),
6961
- runtime.getMemoryManager("messages").createMemory(message)
6962
- ]);
6963
- let state = await runtime.composeState(message, [
6964
- "PROVIDERS",
6797
+ logger.info("Generating new tweet...");
6798
+ await runtime.ensureWorldExists({
6799
+ id: worldId,
6800
+ name: `${runtime.character.name}'s Feed`,
6801
+ agentId: runtime.agentId,
6802
+ serverId: userId
6803
+ });
6804
+ await runtime.ensureRoomExists({
6805
+ id: roomId,
6806
+ name: `${runtime.character.name}'s Feed`,
6807
+ source: "twitter",
6808
+ type: "FEED" /* FEED */,
6809
+ channelId: `${userId}-home`,
6810
+ serverId: userId,
6811
+ worldId
6812
+ });
6813
+ const message = {
6814
+ id: createUniqueUuid(runtime, `tweet-${Date.now()}`),
6815
+ entityId: runtime.agentId,
6816
+ agentId: runtime.agentId,
6817
+ roomId,
6818
+ content: {}
6819
+ };
6820
+ const state = await runtime.composeState(message, null, [
6965
6821
  "CHARACTER",
6966
6822
  "RECENT_MESSAGES",
6967
6823
  "ENTITIES"
6968
6824
  ]);
6969
- const providers = state.providers || [];
6970
- state = await runtime.composeState(message, null, providers);
6971
- const promptTemplate = runtime.character.templates?.postTemplate || runtime.character.templates?.messageHandlerTemplate || messageHandlerTemplate;
6972
- const prompt = composePromptFromState({
6825
+ const tweetPrompt = composePrompt({
6973
6826
  state,
6974
- template: promptTemplate
6827
+ template: runtime.character.templates?.postCreationTemplate || postCreationTemplate
6975
6828
  });
6976
- let responseContent = null;
6977
- let retries = 0;
6978
- const maxRetries = 3;
6979
- while (retries < maxRetries && (!responseContent?.thought || !responseContent?.plan || !responseContent?.text)) {
6980
- const response = await runtime.useModel(ModelTypes.TEXT_SMALL, {
6981
- prompt
6982
- });
6983
- responseContent = parseJSONObjectFromText(response);
6984
- retries++;
6985
- if (!responseContent?.thought || !responseContent?.plan || !responseContent?.text) {
6986
- logger.warn("*** Missing required fields, retrying... ***");
6829
+ const jsonResponse = await runtime.useModel(ModelType.OBJECT_LARGE, {
6830
+ prompt: tweetPrompt,
6831
+ output: "no-schema"
6832
+ });
6833
+ function cleanupTweetText(text) {
6834
+ let cleanedText2 = text.replace(/^['"](.*)['"]$/, "$1");
6835
+ cleanedText2 = cleanedText2.replaceAll(/\\n/g, "\n\n");
6836
+ if (cleanedText2.length > 280) {
6837
+ cleanedText2 = truncateToCompleteSentence(cleanedText2, 280);
6987
6838
  }
6839
+ return cleanedText2;
6988
6840
  }
6841
+ const cleanedText = cleanupTweetText(jsonResponse.post);
6842
+ console.log("creating memory");
6989
6843
  const responseMessages = [
6990
6844
  {
6991
6845
  id: v4(),
6992
6846
  entityId: runtime.agentId,
6993
6847
  agentId: runtime.agentId,
6994
- content: responseContent,
6848
+ content: {
6849
+ text: cleanedText,
6850
+ source: "twitter",
6851
+ channelType: "FEED" /* FEED */,
6852
+ thought: jsonResponse.thought || "",
6853
+ plan: jsonResponse.plan || "",
6854
+ type: "post"
6855
+ },
6995
6856
  roomId: message.roomId,
6996
6857
  createdAt: Date.now()
6997
6858
  }
6998
6859
  ];
6999
- await runtime.getMemoryManager("messages").createMemory({
7000
- entityId: runtime.agentId,
7001
- agentId: runtime.agentId,
7002
- content: {
7003
- thought: responseContent.thought,
7004
- plan: responseContent.plan,
7005
- text: responseContent.text,
7006
- providers: responseContent.providers
7007
- },
7008
- roomId: message.roomId,
7009
- createdAt: Date.now()
7010
- });
7011
- await runtime.processActions(message, responseMessages, state, callback);
7012
- await runtime.evaluate(
7013
- message,
7014
- state,
7015
- true,
7016
- // Post generation is always a "responding" scenario
7017
- callback,
7018
- responseMessages
7019
- );
6860
+ for (const message2 of responseMessages) {
6861
+ console.log("message is", message2);
6862
+ console.log("message.content is", message2.content);
6863
+ await callback(message2.content);
6864
+ }
7020
6865
  };
7021
6866
  var syncSingleUser = async (entityId, runtime, serverId, channelId, type, source) => {
7022
6867
  const entity = await runtime.getEntityById(entityId);
@@ -7055,6 +6900,9 @@ var handleServerSync = async ({
7055
6900
  }) => {
7056
6901
  logger.info(`Handling server sync event for server: ${world.name}`);
7057
6902
  try {
6903
+ console.log("world.id", world.id);
6904
+ console.log("agentId", runtime.agentId);
6905
+ console.log("runtime.serverId", runtime.agentId);
7058
6906
  await runtime.ensureWorldExists({
7059
6907
  id: world.id,
7060
6908
  name: world.name,
@@ -7146,11 +6994,7 @@ var events = {
7146
6994
  ],
7147
6995
  ["POST_GENERATED" /* POST_GENERATED */]: [
7148
6996
  async (payload) => {
7149
- await postGeneratedHandler({
7150
- runtime: payload.runtime,
7151
- message: payload.message,
7152
- callback: payload.callback
7153
- });
6997
+ await postGeneratedHandler(payload);
7154
6998
  }
7155
6999
  ],
7156
7000
  ["MESSAGE_SENT" /* MESSAGE_SENT */]: [
@@ -7303,6 +7147,29 @@ function stringToUuid(target) {
7303
7147
  }
7304
7148
 
7305
7149
  // src/runtime.ts
7150
+ var Semaphore = class {
7151
+ constructor(count) {
7152
+ this.waiting = [];
7153
+ this.permits = count;
7154
+ }
7155
+ async acquire() {
7156
+ if (this.permits > 0) {
7157
+ this.permits -= 1;
7158
+ return Promise.resolve();
7159
+ }
7160
+ return new Promise((resolve) => {
7161
+ this.waiting.push(resolve);
7162
+ });
7163
+ }
7164
+ release() {
7165
+ this.permits += 1;
7166
+ const nextResolve = this.waiting.shift();
7167
+ if (nextResolve && this.permits > 0) {
7168
+ this.permits -= 1;
7169
+ nextResolve();
7170
+ }
7171
+ }
7172
+ };
7306
7173
  var AgentRuntime = class {
7307
7174
  constructor(opts) {
7308
7175
  this.#conversationLength = 32;
@@ -7319,18 +7186,22 @@ var AgentRuntime = class {
7319
7186
  this.taskWorkers = /* @__PURE__ */ new Map();
7320
7187
  // Event emitter methods
7321
7188
  this.eventHandlers = /* @__PURE__ */ new Map();
7189
+ this.knowledgeProcessingSemaphore = new Semaphore(10);
7322
7190
  this.agentId = opts.character?.id ?? opts?.agentId ?? stringToUuid(opts.character?.name ?? uuidv43());
7323
7191
  this.character = opts.character;
7324
- logger.debug(`[AgentRuntime] Process working directory: ${process.cwd()}`);
7325
- this.knowledgeRoot = typeof process !== "undefined" && process.cwd ? join(process.cwd(), "..", "characters", "knowledge") : "./characters/knowledge";
7326
- logger.debug(`[AgentRuntime] Process knowledgeRoot: ${this.knowledgeRoot}`);
7192
+ this.runtimeLogger = logger_default.child({
7193
+ agentName: this.character?.name,
7194
+ agentId: this.agentId
7195
+ });
7196
+ this.runtimeLogger.debug(
7197
+ `[AgentRuntime] Process working directory: ${process.cwd()}`
7198
+ );
7327
7199
  this.#conversationLength = opts.conversationLength ?? this.#conversationLength;
7328
- if (opts.databaseAdapter) {
7329
- this.registerDatabaseAdapter(opts.databaseAdapter);
7200
+ if (opts.adapter) {
7201
+ this.registerDatabaseAdapter(opts.adapter);
7330
7202
  }
7331
- logger.success(`Agent ID: ${this.agentId}`);
7203
+ this.runtimeLogger.success(`Agent ID: ${this.agentId}`);
7332
7204
  this.fetch = opts.fetch ?? this.fetch;
7333
- this.adapter = opts.adapter;
7334
7205
  const plugins = opts?.plugins ?? [];
7335
7206
  if (!opts?.ignoreBootstrap) {
7336
7207
  plugins.push(bootstrapPlugin);
@@ -7344,14 +7215,21 @@ var AgentRuntime = class {
7344
7215
  */
7345
7216
  async registerPlugin(plugin) {
7346
7217
  if (!plugin) {
7218
+ this.runtimeLogger.error("*** registerPlugin plugin is undefined");
7347
7219
  throw new Error("*** registerPlugin plugin is undefined");
7348
7220
  }
7349
7221
  if (!this.plugins.some((p) => p.name === plugin.name)) {
7350
7222
  this.plugins.push(plugin);
7223
+ this.runtimeLogger.success(
7224
+ `Plugin ${plugin.name} registered successfully`
7225
+ );
7351
7226
  }
7352
7227
  if (plugin.init) {
7353
7228
  try {
7354
7229
  await plugin.init(plugin.config || {}, this);
7230
+ this.runtimeLogger.success(
7231
+ `Plugin ${plugin.name} initialized successfully`
7232
+ );
7355
7233
  } catch (error) {
7356
7234
  const errorMessage = error instanceof Error ? error.message : String(error);
7357
7235
  if (errorMessage.includes("API key") || errorMessage.includes("environment variables") || errorMessage.includes("Invalid plugin configuration")) {
@@ -7368,6 +7246,9 @@ var AgentRuntime = class {
7368
7246
  }
7369
7247
  }
7370
7248
  if (plugin.adapter) {
7249
+ this.runtimeLogger.debug(
7250
+ `Registering database adapter for plugin ${plugin.name}`
7251
+ );
7371
7252
  this.registerDatabaseAdapter(plugin.adapter);
7372
7253
  }
7373
7254
  if (plugin.actions) {
@@ -7415,9 +7296,13 @@ var AgentRuntime = class {
7415
7296
  return this.services;
7416
7297
  }
7417
7298
  async stop() {
7418
- logger.debug(`runtime::stop - character ${this.character.name}`);
7299
+ this.runtimeLogger.debug(
7300
+ `runtime::stop - character ${this.character.name}`
7301
+ );
7419
7302
  for (const [serviceName, service] of this.services) {
7420
- logger.log(`runtime::stop - requesting service stop for ${serviceName}`);
7303
+ this.runtimeLogger.log(
7304
+ `runtime::stop - requesting service stop for ${serviceName}`
7305
+ );
7421
7306
  await service.stop();
7422
7307
  }
7423
7308
  }
@@ -7448,11 +7333,11 @@ var AgentRuntime = class {
7448
7333
  );
7449
7334
  const agent = await this.adapter.getAgent(this.agentId);
7450
7335
  if (!agent) {
7451
- throw new Error(`Agent ${this.agentId} does not exist in database after ensureAgentExists call`);
7336
+ throw new Error(
7337
+ `Agent ${this.agentId} does not exist in database after ensureAgentExists call`
7338
+ );
7452
7339
  }
7453
- const agentEntity = await this.adapter.getEntityById(
7454
- this.agentId
7455
- );
7340
+ const agentEntity = await this.adapter.getEntityById(this.agentId);
7456
7341
  if (!agentEntity) {
7457
7342
  const created = await this.adapter.createEntity({
7458
7343
  id: this.agentId,
@@ -7465,12 +7350,12 @@ var AgentRuntime = class {
7465
7350
  if (!created) {
7466
7351
  throw new Error(`Failed to create entity for agent ${this.agentId}`);
7467
7352
  }
7468
- logger.success(
7353
+ this.runtimeLogger.success(
7469
7354
  `Agent entity created successfully for ${this.character.name}`
7470
7355
  );
7471
7356
  }
7472
7357
  } catch (error) {
7473
- logger.error(
7358
+ this.runtimeLogger.error(
7474
7359
  `Failed to create agent entity: ${error instanceof Error ? error.message : String(error)}`
7475
7360
  );
7476
7361
  throw error;
@@ -7486,13 +7371,15 @@ var AgentRuntime = class {
7486
7371
  ...pluginRegistrationPromises
7487
7372
  ]);
7488
7373
  } catch (error) {
7489
- logger.error(
7374
+ this.runtimeLogger.error(
7490
7375
  `Failed to initialize: ${error instanceof Error ? error.message : String(error)}`
7491
7376
  );
7492
7377
  throw error;
7493
7378
  }
7494
7379
  try {
7495
- const participants = await this.adapter.getParticipantsForRoom(this.agentId);
7380
+ const participants = await this.adapter.getParticipantsForRoom(
7381
+ this.agentId
7382
+ );
7496
7383
  if (!participants.includes(this.agentId)) {
7497
7384
  const added = await this.adapter.addParticipant(
7498
7385
  this.agentId,
@@ -7503,45 +7390,45 @@ var AgentRuntime = class {
7503
7390
  `Failed to add agent ${this.agentId} as participant to its own room`
7504
7391
  );
7505
7392
  }
7506
- logger.success(
7393
+ this.runtimeLogger.success(
7507
7394
  `Agent ${this.character.name} linked to its own room successfully`
7508
7395
  );
7509
7396
  }
7510
7397
  } catch (error) {
7511
- logger.error(
7398
+ this.runtimeLogger.error(
7512
7399
  `Failed to add agent as participant: ${error instanceof Error ? error.message : String(error)}`
7513
7400
  );
7514
7401
  throw error;
7515
7402
  }
7516
- if (this.character?.knowledge && this.character.knowledge.length > 0) {
7517
- const stringKnowledge = this.character.knowledge.filter(
7518
- (item) => typeof item === "string"
7519
- );
7520
- await this.processCharacterKnowledge(stringKnowledge);
7521
- }
7522
- const embeddingModel = this.getModel(ModelTypes.TEXT_EMBEDDING);
7403
+ const embeddingModel = this.getModel(ModelType.TEXT_EMBEDDING);
7523
7404
  if (!embeddingModel) {
7524
- logger.warn(
7405
+ this.runtimeLogger.warn(
7525
7406
  `[AgentRuntime][${this.character.name}] No TEXT_EMBEDDING model registered. Skipping embedding dimension setup.`
7526
7407
  );
7527
7408
  } else {
7528
7409
  await this.ensureEmbeddingDimension();
7529
7410
  }
7411
+ if (this.character?.knowledge && this.character.knowledge.length > 0) {
7412
+ const stringKnowledge = this.character.knowledge.filter(
7413
+ (item) => typeof item === "string"
7414
+ );
7415
+ await this.processCharacterKnowledge(stringKnowledge);
7416
+ }
7530
7417
  }
7531
7418
  async handleProcessingError(error, context) {
7532
- logger.error(
7419
+ this.runtimeLogger.error(
7533
7420
  `Error ${context}:`,
7534
7421
  error?.message || error || "Unknown error"
7535
7422
  );
7536
7423
  throw error;
7537
7424
  }
7538
7425
  async checkExistingKnowledge(knowledgeId) {
7539
- const existingDocument = await this.getMemoryManager("documents").getMemoryById(knowledgeId);
7426
+ const existingDocument = await this.getMemoryById(knowledgeId);
7540
7427
  return !!existingDocument;
7541
7428
  }
7542
7429
  async getKnowledge(message) {
7543
7430
  if (!message?.content?.text) {
7544
- logger.warn("Invalid message for knowledge query:", {
7431
+ this.runtimeLogger.warn("Invalid message for knowledge query:", {
7545
7432
  message,
7546
7433
  content: message?.content,
7547
7434
  text: message?.content?.text
@@ -7549,13 +7436,14 @@ var AgentRuntime = class {
7549
7436
  return [];
7550
7437
  }
7551
7438
  if (!message?.content?.text || message?.content?.text.trim().length === 0) {
7552
- logger.warn("Empty text for knowledge query");
7439
+ this.runtimeLogger.warn("Empty text for knowledge query");
7553
7440
  return [];
7554
7441
  }
7555
- const embedding = await this.useModel(ModelTypes.TEXT_EMBEDDING, {
7442
+ const embedding = await this.useModel(ModelType.TEXT_EMBEDDING, {
7556
7443
  text: message?.content?.text
7557
7444
  });
7558
- const fragments = await this.getMemoryManager("knowledge").searchMemories({
7445
+ const fragments = await this.searchMemories({
7446
+ tableName: "knowledge",
7559
7447
  embedding,
7560
7448
  roomId: message.agentId,
7561
7449
  count: 5,
@@ -7564,7 +7452,7 @@ var AgentRuntime = class {
7564
7452
  const uniqueSources = [
7565
7453
  ...new Set(
7566
7454
  fragments.map((memory) => {
7567
- logger.log(
7455
+ this.runtimeLogger.log(
7568
7456
  `Matched fragment: ${memory.content.text} with similarity: ${memory.similarity}`
7569
7457
  );
7570
7458
  return memory.content.source;
@@ -7572,9 +7460,7 @@ var AgentRuntime = class {
7572
7460
  )
7573
7461
  ];
7574
7462
  const knowledgeDocuments = await Promise.all(
7575
- uniqueSources.map(
7576
- (source) => this.getMemoryManager("documents").getMemoryById(source)
7577
- )
7463
+ uniqueSources.map((source) => this.getMemoryById(source))
7578
7464
  );
7579
7465
  return knowledgeDocuments.filter((memory) => memory !== null).map((memory) => ({ id: memory.id, content: memory.content }));
7580
7466
  }
@@ -7594,18 +7480,23 @@ var AgentRuntime = class {
7594
7480
  timestamp: Date.now()
7595
7481
  }
7596
7482
  };
7597
- await this.getMemoryManager("documents").createMemory(documentMemory);
7483
+ await this.createMemory(documentMemory, "documents");
7598
7484
  const fragments = await splitChunks(
7599
7485
  item.content.text,
7600
7486
  options2.targetTokens,
7601
7487
  options2.overlap
7602
7488
  );
7603
7489
  for (let i = 0; i < fragments.length; i++) {
7490
+ const embedding = await this.useModel(
7491
+ ModelType.TEXT_EMBEDDING,
7492
+ fragments[i]
7493
+ );
7604
7494
  const fragmentMemory = {
7605
7495
  id: createUniqueUuid(this, `${item.id}-fragment-${i}`),
7606
7496
  agentId: this.agentId,
7607
7497
  roomId: this.agentId,
7608
7498
  entityId: this.agentId,
7499
+ embedding,
7609
7500
  content: { text: fragments[i] },
7610
7501
  metadata: {
7611
7502
  type: "fragment" /* FRAGMENT */,
@@ -7616,17 +7507,18 @@ var AgentRuntime = class {
7616
7507
  timestamp: Date.now()
7617
7508
  }
7618
7509
  };
7619
- await this.getMemoryManager("knowledge").createMemory(fragmentMemory);
7510
+ await this.createMemory(fragmentMemory, "knowledge");
7620
7511
  }
7621
7512
  }
7622
7513
  async processCharacterKnowledge(items) {
7623
- for (const item of items) {
7514
+ const processingPromises = items.map(async (item) => {
7515
+ await this.knowledgeProcessingSemaphore.acquire();
7624
7516
  try {
7625
7517
  const knowledgeId = createUniqueUuid(this, item);
7626
7518
  if (await this.checkExistingKnowledge(knowledgeId)) {
7627
- continue;
7519
+ return;
7628
7520
  }
7629
- logger.info(
7521
+ this.runtimeLogger.info(
7630
7522
  "Processing knowledge for ",
7631
7523
  this.character.name,
7632
7524
  " - ",
@@ -7643,13 +7535,22 @@ var AgentRuntime = class {
7643
7535
  error,
7644
7536
  "processing character knowledge"
7645
7537
  );
7538
+ } finally {
7539
+ this.knowledgeProcessingSemaphore.release();
7646
7540
  }
7647
- }
7541
+ });
7542
+ await Promise.all(processingPromises);
7648
7543
  }
7649
7544
  setSetting(key, value, secret = false) {
7650
7545
  if (secret) {
7546
+ if (!this.character.secrets) {
7547
+ this.character.secrets = {};
7548
+ }
7651
7549
  this.character.secrets[key] = value;
7652
7550
  } else {
7551
+ if (!this.character.settings) {
7552
+ this.character.settings = {};
7553
+ }
7653
7554
  this.character.settings[key] = value;
7654
7555
  }
7655
7556
  }
@@ -7668,11 +7569,12 @@ var AgentRuntime = class {
7668
7569
  }
7669
7570
  registerDatabaseAdapter(adapter) {
7670
7571
  if (this.adapter) {
7671
- logger.warn(
7572
+ this.runtimeLogger.warn(
7672
7573
  "Database adapter already registered. Additional adapters will be ignored. This may lead to unexpected behavior."
7673
7574
  );
7674
7575
  } else {
7675
7576
  this.adapter = adapter;
7577
+ this.runtimeLogger.success("Database adapter registered successfully.");
7676
7578
  }
7677
7579
  }
7678
7580
  /**
@@ -7681,21 +7583,27 @@ var AgentRuntime = class {
7681
7583
  */
7682
7584
  registerProvider(provider) {
7683
7585
  this.providers.push(provider);
7586
+ this.runtimeLogger.success(
7587
+ `Provider ${provider.name} registered successfully.`
7588
+ );
7684
7589
  }
7685
7590
  /**
7686
7591
  * Register an action for the agent to perform.
7687
7592
  * @param action The action to register.
7688
7593
  */
7689
7594
  registerAction(action) {
7690
- logger.success(
7595
+ this.runtimeLogger.debug(
7691
7596
  `${this.character.name}(${this.agentId}) - Registering action: ${action.name}`
7692
7597
  );
7693
7598
  if (this.actions.find((a) => a.name === action.name)) {
7694
- logger.warn(
7599
+ this.runtimeLogger.warn(
7695
7600
  `${this.character.name}(${this.agentId}) - Action ${action.name} already exists. Skipping registration.`
7696
7601
  );
7697
7602
  } else {
7698
7603
  this.actions.push(action);
7604
+ this.runtimeLogger.success(
7605
+ `${this.character.name}(${this.agentId}) - Action ${action.name} registered successfully.`
7606
+ );
7699
7607
  }
7700
7608
  }
7701
7609
  /**
@@ -7725,16 +7633,16 @@ var AgentRuntime = class {
7725
7633
  return action.toLowerCase().replace("_", "");
7726
7634
  };
7727
7635
  if (!response.content?.actions || response.content.actions.length === 0) {
7728
- logger.warn("No action found in the response content.");
7636
+ this.runtimeLogger.warn("No action found in the response content.");
7729
7637
  continue;
7730
7638
  }
7731
7639
  const actions = response.content.actions;
7732
- logger.success(
7640
+ this.runtimeLogger.success(
7733
7641
  `Found actions: ${this.actions.map((a) => normalizeAction(a.name))}`
7734
7642
  );
7735
7643
  for (const responseAction of actions) {
7736
7644
  state = await this.composeState(message, ["RECENT_MESSAGES"]);
7737
- logger.success(`Calling action: ${responseAction}`);
7645
+ this.runtimeLogger.success(`Calling action: ${responseAction}`);
7738
7646
  const normalizedResponseAction = normalizeAction(responseAction);
7739
7647
  let action = this.actions.find(
7740
7648
  (a) => normalizeAction(a.name).includes(normalizedResponseAction) || // the || is kind of a fuzzy match
@@ -7742,12 +7650,12 @@ var AgentRuntime = class {
7742
7650
  //
7743
7651
  );
7744
7652
  if (action) {
7745
- logger.success(`Found action: ${action?.name}`);
7653
+ this.runtimeLogger.success(`Found action: ${action?.name}`);
7746
7654
  } else {
7747
- logger.error(`No action found for: ${responseAction}`);
7655
+ this.runtimeLogger.error(`No action found for: ${responseAction}`);
7748
7656
  }
7749
7657
  if (!action) {
7750
- logger.info("Attempting to find action in similes.");
7658
+ this.runtimeLogger.info("Attempting to find action in similes.");
7751
7659
  for (const _action of this.actions) {
7752
7660
  const simileAction = _action.similes?.find(
7753
7661
  (simile) => simile.toLowerCase().replace("_", "").includes(normalizedResponseAction) || normalizedResponseAction.includes(
@@ -7756,23 +7664,32 @@ var AgentRuntime = class {
7756
7664
  );
7757
7665
  if (simileAction) {
7758
7666
  action = _action;
7759
- logger.success(`Action found in similes: ${action.name}`);
7667
+ this.runtimeLogger.success(
7668
+ `Action found in similes: ${action.name}`
7669
+ );
7760
7670
  break;
7761
7671
  }
7762
7672
  }
7763
7673
  }
7764
7674
  if (!action) {
7765
- logger.error("No action found in", JSON.stringify(response));
7675
+ this.runtimeLogger.error(
7676
+ "No action found in",
7677
+ JSON.stringify(response)
7678
+ );
7766
7679
  continue;
7767
7680
  }
7768
7681
  if (!action.handler) {
7769
- logger.error(`Action ${action.name} has no handler.`);
7682
+ this.runtimeLogger.error(`Action ${action.name} has no handler.`);
7770
7683
  continue;
7771
7684
  }
7772
7685
  try {
7773
- logger.info(`Executing handler for action: ${action.name}`);
7686
+ this.runtimeLogger.info(
7687
+ `Executing handler for action: ${action.name}`
7688
+ );
7774
7689
  await action.handler(this, message, state, {}, callback, responses);
7775
- logger.success(`Action ${action.name} executed successfully.`);
7690
+ this.runtimeLogger.success(
7691
+ `Action ${action.name} executed successfully.`
7692
+ );
7776
7693
  this.adapter.log({
7777
7694
  entityId: message.entityId,
7778
7695
  roomId: message.roomId,
@@ -7786,7 +7703,7 @@ var AgentRuntime = class {
7786
7703
  }
7787
7704
  });
7788
7705
  } catch (error) {
7789
- logger.error(error);
7706
+ this.runtimeLogger.error(error);
7790
7707
  throw error;
7791
7708
  }
7792
7709
  }
@@ -7857,21 +7774,20 @@ var AgentRuntime = class {
7857
7774
  }
7858
7775
  const participants = await this.adapter.getParticipantsForRoom(roomId);
7859
7776
  if (!participants.includes(entityId)) {
7860
- const added = await this.adapter.addParticipant(
7861
- entityId,
7862
- roomId
7863
- );
7777
+ const added = await this.adapter.addParticipant(entityId, roomId);
7864
7778
  if (!added) {
7865
7779
  throw new Error(
7866
7780
  `Failed to add participant ${entityId} to room ${roomId}`
7867
7781
  );
7868
7782
  }
7869
7783
  if (entityId === this.agentId) {
7870
- logger.log(
7784
+ this.runtimeLogger.log(
7871
7785
  `Agent ${this.character.name} linked to room ${roomId} successfully.`
7872
7786
  );
7873
7787
  } else {
7874
- logger.log(`User ${entityId} linked to room ${roomId} successfully.`);
7788
+ this.runtimeLogger.log(
7789
+ `User ${entityId} linked to room ${roomId} successfully.`
7790
+ );
7875
7791
  }
7876
7792
  }
7877
7793
  }
@@ -7929,7 +7845,7 @@ var AgentRuntime = class {
7929
7845
  await this.ensureParticipantInRoom(entityId, roomId);
7930
7846
  await this.ensureParticipantInRoom(this.agentId, roomId);
7931
7847
  } catch (error) {
7932
- logger.error(
7848
+ this.runtimeLogger.error(
7933
7849
  `Failed to add participants: ${error instanceof Error ? error.message : String(error)}`
7934
7850
  );
7935
7851
  throw error;
@@ -7939,29 +7855,23 @@ var AgentRuntime = class {
7939
7855
  * Ensure the existence of a world.
7940
7856
  */
7941
7857
  async ensureWorldExists({ id, name, serverId, metadata }) {
7942
- try {
7943
- const world = await this.adapter.getWorld(id);
7944
- if (!world) {
7945
- logger.info("Creating world:", {
7946
- id,
7947
- name,
7948
- serverId,
7949
- agentId: this.agentId
7950
- });
7951
- await this.adapter.createWorld({
7952
- id,
7953
- name,
7954
- agentId: this.agentId,
7955
- serverId: serverId || "default",
7956
- metadata
7957
- });
7958
- logger.info(`World ${id} created successfully.`);
7959
- }
7960
- } catch (error) {
7961
- logger.error(
7962
- `Failed to ensure world exists: ${error instanceof Error ? error.message : String(error)}`
7963
- );
7964
- throw error;
7858
+ console.trace("ensureWorldExists");
7859
+ const world = await this.getWorld(id);
7860
+ if (!world) {
7861
+ this.runtimeLogger.info("Creating world:", {
7862
+ id,
7863
+ name,
7864
+ serverId,
7865
+ agentId: this.agentId
7866
+ });
7867
+ await this.adapter.createWorld({
7868
+ id,
7869
+ name,
7870
+ agentId: this.agentId,
7871
+ serverId: serverId || "default",
7872
+ metadata
7873
+ });
7874
+ this.runtimeLogger.info(`World ${id} created successfully.`);
7965
7875
  }
7966
7876
  }
7967
7877
  /**
@@ -7992,7 +7902,7 @@ var AgentRuntime = class {
7992
7902
  serverId,
7993
7903
  worldId
7994
7904
  });
7995
- logger.log(`Room ${id} created successfully.`);
7905
+ this.runtimeLogger.log(`Room ${id} created successfully.`);
7996
7906
  }
7997
7907
  }
7998
7908
  /**
@@ -8028,7 +7938,9 @@ var AgentRuntime = class {
8028
7938
  const start = Date.now();
8029
7939
  const result = await provider.get(this, message, cachedState);
8030
7940
  const duration = Date.now() - start;
8031
- logger.warn(`${provider.name} Provider took ${duration}ms to respond`);
7941
+ this.runtimeLogger.warn(
7942
+ `${provider.name} Provider took ${duration}ms to respond`
7943
+ );
8032
7944
  return {
8033
7945
  ...result,
8034
7946
  providerName: provider.name
@@ -8073,16 +7985,10 @@ ${newProvidersText}`;
8073
7985
  this.stateCache.set(message.id, newState);
8074
7986
  return newState;
8075
7987
  }
8076
- getMemoryManager(tableName) {
8077
- return new MemoryManager({
8078
- runtime: this,
8079
- tableName
8080
- });
8081
- }
8082
7988
  getService(service) {
8083
7989
  const serviceInstance = this.services.get(service);
8084
7990
  if (!serviceInstance) {
8085
- logger.warn(`Service ${service} not found`);
7991
+ this.runtimeLogger.warn(`Service ${service} not found`);
8086
7992
  return null;
8087
7993
  }
8088
7994
  return serviceInstance;
@@ -8092,31 +7998,31 @@ ${newProvidersText}`;
8092
7998
  if (!serviceType) {
8093
7999
  return;
8094
8000
  }
8095
- logger.log(
8001
+ this.runtimeLogger.log(
8096
8002
  `${this.character.name}(${this.agentId}) - Registering service:`,
8097
8003
  serviceType
8098
8004
  );
8099
8005
  if (this.services.has(serviceType)) {
8100
- logger.warn(
8006
+ this.runtimeLogger.warn(
8101
8007
  `${this.character.name}(${this.agentId}) - Service ${serviceType} is already registered. Skipping registration.`
8102
8008
  );
8103
8009
  return;
8104
8010
  }
8105
8011
  const serviceInstance = await service.start(this);
8106
8012
  this.services.set(serviceType, serviceInstance);
8107
- logger.success(
8013
+ this.runtimeLogger.success(
8108
8014
  `${this.character.name}(${this.agentId}) - Service ${serviceType} registered successfully`
8109
8015
  );
8110
8016
  }
8111
8017
  registerModel(modelType, handler2) {
8112
- const modelKey = typeof modelType === "string" ? modelType : ModelTypes[modelType];
8018
+ const modelKey = typeof modelType === "string" ? modelType : ModelType[modelType];
8113
8019
  if (!this.models.has(modelKey)) {
8114
8020
  this.models.set(modelKey, []);
8115
8021
  }
8116
8022
  this.models.get(modelKey)?.push(handler2);
8117
8023
  }
8118
8024
  getModel(modelType) {
8119
- const modelKey = typeof modelType === "string" ? modelType : ModelTypes[modelType];
8025
+ const modelKey = typeof modelType === "string" ? modelType : ModelType[modelType];
8120
8026
  const models = this.models.get(modelKey);
8121
8027
  if (!models?.length) {
8122
8028
  return void 0;
@@ -8132,17 +8038,17 @@ ${newProvidersText}`;
8132
8038
  * @returns {Promise<R>} - The model result, typed based on the provided generic type parameter
8133
8039
  */
8134
8040
  async useModel(modelType, params) {
8135
- const modelKey = typeof modelType === "string" ? modelType : ModelTypes[modelType];
8041
+ const modelKey = typeof modelType === "string" ? modelType : ModelType[modelType];
8136
8042
  const model = this.getModel(modelKey);
8137
8043
  if (!model) {
8138
8044
  throw new Error(`No handler found for delegate type: ${modelKey}`);
8139
8045
  }
8140
- logger.debug(
8046
+ this.runtimeLogger.debug(
8141
8047
  `[useModel] ${modelKey} input:`,
8142
8048
  JSON.stringify(params, null, 2)
8143
8049
  );
8144
8050
  let paramsWithRuntime;
8145
- if (params === null || params === void 0 || typeof params !== "object" || Array.isArray(params)) {
8051
+ if (params === null || params === void 0 || typeof params !== "object" || Array.isArray(params) || typeof Buffer !== "undefined" && Buffer.isBuffer(params)) {
8146
8052
  paramsWithRuntime = params;
8147
8053
  } else {
8148
8054
  paramsWithRuntime = {
@@ -8153,12 +8059,15 @@ ${newProvidersText}`;
8153
8059
  const startTime = performance.now();
8154
8060
  const response = await model(this, paramsWithRuntime);
8155
8061
  const elapsedTime = performance.now() - startTime;
8156
- logger.info(
8062
+ this.runtimeLogger.info(
8157
8063
  `[useModel] ${modelKey} completed in ${elapsedTime.toFixed(2)}ms`
8158
8064
  );
8159
- logger.debug(
8065
+ this.runtimeLogger.debug(
8160
8066
  `[useModel] ${modelKey} output:`,
8161
- JSON.stringify(response, null, 2)
8067
+ // if response is an array, should the first and last 5 items with a "..." in the middle, and a (x items) at the end
8068
+ Array.isArray(response) ? `${JSON.stringify(response.slice(0, 5))}...${JSON.stringify(
8069
+ response.slice(-5)
8070
+ )} (${response.length} items)` : JSON.stringify(response)
8162
8071
  );
8163
8072
  this.adapter.log({
8164
8073
  entityId: this.agentId,
@@ -8192,7 +8101,7 @@ ${newProvidersText}`;
8192
8101
  }
8193
8102
  }
8194
8103
  async ensureEmbeddingDimension() {
8195
- logger.debug(
8104
+ this.runtimeLogger.debug(
8196
8105
  `[AgentRuntime][${this.character.name}] Starting ensureEmbeddingDimension`
8197
8106
  );
8198
8107
  if (!this.adapter) {
@@ -8201,32 +8110,30 @@ ${newProvidersText}`;
8201
8110
  );
8202
8111
  }
8203
8112
  try {
8204
- const model = this.getModel(ModelTypes.TEXT_EMBEDDING);
8113
+ const model = this.getModel(ModelType.TEXT_EMBEDDING);
8205
8114
  if (!model) {
8206
8115
  throw new Error(
8207
8116
  `[AgentRuntime][${this.character.name}] No TEXT_EMBEDDING model registered`
8208
8117
  );
8209
8118
  }
8210
- logger.debug(
8119
+ this.runtimeLogger.debug(
8211
8120
  `[AgentRuntime][${this.character.name}] Getting embedding dimensions`
8212
8121
  );
8213
- const embedding = await this.useModel(ModelTypes.TEXT_EMBEDDING, null);
8122
+ const embedding = await this.useModel(ModelType.TEXT_EMBEDDING, null);
8214
8123
  if (!embedding || !embedding.length) {
8215
8124
  throw new Error(
8216
8125
  `[AgentRuntime][${this.character.name}] Invalid embedding received`
8217
8126
  );
8218
8127
  }
8219
- logger.debug(
8128
+ this.runtimeLogger.debug(
8220
8129
  `[AgentRuntime][${this.character.name}] Setting embedding dimension: ${embedding.length}`
8221
8130
  );
8222
- await this.adapter.ensureEmbeddingDimension(
8223
- embedding.length
8224
- );
8225
- logger.debug(
8131
+ await this.adapter.ensureEmbeddingDimension(embedding.length);
8132
+ this.runtimeLogger.debug(
8226
8133
  `[AgentRuntime][${this.character.name}] Successfully set embedding dimension`
8227
8134
  );
8228
8135
  } catch (error) {
8229
- logger.info(
8136
+ this.runtimeLogger.info(
8230
8137
  `[AgentRuntime][${this.character.name}] Error in ensureEmbeddingDimension:`,
8231
8138
  error
8232
8139
  );
@@ -8235,7 +8142,7 @@ ${newProvidersText}`;
8235
8142
  }
8236
8143
  registerTaskWorker(taskHandler) {
8237
8144
  if (this.taskWorkers.has(taskHandler.name)) {
8238
- logger.warn(
8145
+ this.runtimeLogger.warn(
8239
8146
  `Task definition ${taskHandler.name} already registered. Will be overwritten.`
8240
8147
  );
8241
8148
  }
@@ -8255,7 +8162,6 @@ ${newProvidersText}`;
8255
8162
  await this.adapter.init();
8256
8163
  }
8257
8164
  async close() {
8258
- console.log("Closing adapter");
8259
8165
  await this.adapter.close();
8260
8166
  }
8261
8167
  async getAgent(agentId) {
@@ -8289,7 +8195,12 @@ ${newProvidersText}`;
8289
8195
  await this.adapter.updateEntity(entity);
8290
8196
  }
8291
8197
  async getComponent(entityId, type, worldId, sourceEntityId) {
8292
- return await this.adapter.getComponent(entityId, type, worldId, sourceEntityId);
8198
+ return await this.adapter.getComponent(
8199
+ entityId,
8200
+ type,
8201
+ worldId,
8202
+ sourceEntityId
8203
+ );
8293
8204
  }
8294
8205
  async getComponents(entityId, worldId, sourceEntityId) {
8295
8206
  return await this.adapter.getComponents(entityId, worldId, sourceEntityId);
@@ -8303,6 +8214,24 @@ ${newProvidersText}`;
8303
8214
  async deleteComponent(componentId) {
8304
8215
  await this.adapter.deleteComponent(componentId);
8305
8216
  }
8217
+ async addEmbeddingToMemory(memory) {
8218
+ if (memory.embedding) {
8219
+ return memory;
8220
+ }
8221
+ const memoryText = memory.content.text;
8222
+ if (!memoryText) {
8223
+ throw new Error("Cannot generate embedding: Memory content is empty");
8224
+ }
8225
+ try {
8226
+ memory.embedding = await this.useModel(ModelType.TEXT_EMBEDDING, {
8227
+ text: memoryText
8228
+ });
8229
+ } catch (error) {
8230
+ logger_default.error("Failed to generate embedding:", error);
8231
+ memory.embedding = await this.useModel(ModelType.TEXT_EMBEDDING, null);
8232
+ }
8233
+ return memory;
8234
+ }
8306
8235
  async getMemories(params) {
8307
8236
  return await this.adapter.getMemories(params);
8308
8237
  }
@@ -8327,15 +8256,21 @@ ${newProvidersText}`;
8327
8256
  async createMemory(memory, tableName, unique) {
8328
8257
  return await this.adapter.createMemory(memory, tableName, unique);
8329
8258
  }
8330
- async removeMemory(memoryId, tableName) {
8331
- await this.adapter.removeMemory(memoryId, tableName);
8259
+ async deleteMemory(memoryId) {
8260
+ await this.adapter.deleteMemory(memoryId);
8332
8261
  }
8333
- async removeAllMemories(roomId, tableName) {
8334
- await this.adapter.removeAllMemories(roomId, tableName);
8262
+ async deleteAllMemories(roomId, tableName) {
8263
+ await this.adapter.deleteAllMemories(roomId, tableName);
8335
8264
  }
8336
8265
  async countMemories(roomId, unique, tableName) {
8337
8266
  return await this.adapter.countMemories(roomId, unique, tableName);
8338
8267
  }
8268
+ async getLogs(params) {
8269
+ return await this.adapter.getLogs(params);
8270
+ }
8271
+ async deleteLog(logId) {
8272
+ await this.adapter.deleteLog(logId);
8273
+ }
8339
8274
  async createWorld(world) {
8340
8275
  return await this.adapter.createWorld(world);
8341
8276
  }
@@ -8470,26 +8405,28 @@ ${newProvidersText}`;
8470
8405
  };
8471
8406
  export {
8472
8407
  AgentRuntime,
8408
+ AgentStatus,
8473
8409
  CacheKeyPrefix,
8474
8410
  ChannelType,
8475
8411
  CharacterSchema,
8476
8412
  DatabaseAdapter,
8477
8413
  EventTypes,
8478
8414
  KnowledgeScope,
8479
- MemoryManager,
8480
8415
  MemoryType,
8481
8416
  MessageExampleSchema,
8482
- ModelTypes,
8417
+ ModelType,
8483
8418
  PlatformPrefix,
8484
8419
  PluginSchema,
8485
8420
  Role,
8486
8421
  SOCKET_MESSAGE_TYPE,
8422
+ Semaphore,
8487
8423
  Service,
8488
- ServiceTypes,
8424
+ ServiceType,
8489
8425
  TEEMode,
8490
8426
  TeeLogDAO,
8491
8427
  TeeType,
8492
8428
  addHeader,
8429
+ asUUID,
8493
8430
  booleanFooter,
8494
8431
  cleanJsonResponse,
8495
8432
  composeActionExamples,
@@ -8497,6 +8434,8 @@ export {
8497
8434
  composePromptFromState,
8498
8435
  composeRandomUser,
8499
8436
  configureSettings,
8437
+ createMessageMemory,
8438
+ createServiceError,
8500
8439
  createUniqueUuid,
8501
8440
  dynamicImport,
8502
8441
  elizaLogger,
@@ -8510,13 +8449,26 @@ export {
8510
8449
  formatMessages,
8511
8450
  formatPosts,
8512
8451
  formatTimestamp,
8452
+ getBrowserService,
8513
8453
  getEntityDetails,
8514
8454
  getEnvVariable,
8455
+ getFileService,
8456
+ getMemoryText,
8457
+ getPdfService,
8458
+ getTypedService,
8515
8459
  getUserServerRole,
8460
+ getVideoService,
8516
8461
  getWorldSettings2 as getWorldSettings,
8517
8462
  handlePluginImporting,
8518
8463
  hasEnvVariable,
8519
8464
  initializeOnboarding,
8465
+ isCustomMetadata,
8466
+ isDescriptionMetadata,
8467
+ isDocumentMemory,
8468
+ isDocumentMetadata,
8469
+ isFragmentMemory,
8470
+ isFragmentMetadata,
8471
+ isMessageMetadata,
8520
8472
  loadEnvConfig,
8521
8473
  logger,
8522
8474
  messageHandlerTemplate,
@@ -8526,6 +8478,7 @@ export {
8526
8478
  parseJSONObjectFromText,
8527
8479
  parseJsonArrayFromText,
8528
8480
  postActionResponseFooter,
8481
+ postCreationTemplate,
8529
8482
  registerDynamicImport,
8530
8483
  settings,
8531
8484
  shouldRespondTemplate,
@@ -8539,4 +8492,3 @@ export {
8539
8492
  validateCharacterConfig,
8540
8493
  validateUuid
8541
8494
  };
8542
- //# sourceMappingURL=index.js.map