@elizaos/core 1.0.0-alpha.26 → 1.0.0-alpha.27
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/entities.d.ts +15 -0
- package/dist/index.js +33 -19
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/entities.d.ts
CHANGED
|
@@ -31,3 +31,18 @@ export declare function getEntityDetails({ runtime, roomId, }: {
|
|
|
31
31
|
runtime: IAgentRuntime;
|
|
32
32
|
roomId: UUID;
|
|
33
33
|
}): Promise<any[]>;
|
|
34
|
+
/**
|
|
35
|
+
* Format entities into a string
|
|
36
|
+
* @param entities - list of entities
|
|
37
|
+
* @returns string
|
|
38
|
+
*/
|
|
39
|
+
/**
|
|
40
|
+
* Format the given entities into a string representation.
|
|
41
|
+
*
|
|
42
|
+
* @param {Object} options - The options object.
|
|
43
|
+
* @param {Entity[]} options.entities - The list of entities to format.
|
|
44
|
+
* @returns {string} A formatted string representing the entities.
|
|
45
|
+
*/
|
|
46
|
+
export declare function formatEntities({ entities }: {
|
|
47
|
+
entities: Entity[];
|
|
48
|
+
}): string;
|
package/dist/index.js
CHANGED
|
@@ -262,6 +262,19 @@ import { names as names2, uniqueNamesGenerator as uniqueNamesGenerator2 } from "
|
|
|
262
262
|
// src/logger.ts
|
|
263
263
|
import pino from "pino";
|
|
264
264
|
import pretty from "pino-pretty";
|
|
265
|
+
function parseBooleanFromText(value) {
|
|
266
|
+
if (!value) return false;
|
|
267
|
+
const affirmative = ["YES", "Y", "TRUE", "T", "1", "ON", "ENABLE"];
|
|
268
|
+
const negative = ["NO", "N", "FALSE", "F", "0", "OFF", "DISABLE"];
|
|
269
|
+
const normalizedText = value.trim().toUpperCase();
|
|
270
|
+
if (affirmative.includes(normalizedText)) {
|
|
271
|
+
return true;
|
|
272
|
+
}
|
|
273
|
+
if (negative.includes(normalizedText)) {
|
|
274
|
+
return false;
|
|
275
|
+
}
|
|
276
|
+
return false;
|
|
277
|
+
}
|
|
265
278
|
var InMemoryDestination = class {
|
|
266
279
|
/**
|
|
267
280
|
* Constructor for creating a new instance of the class.
|
|
@@ -468,7 +481,7 @@ var formatMessages = ({
|
|
|
468
481
|
const timestampString = `${timeString} (${timestamp}) [${shortId}]`;
|
|
469
482
|
const textString = messageText ? `${timestampString} ${formattedName}: ${messageText}` : null;
|
|
470
483
|
const actionString = messageActions && messageActions.length > 0 ? `${textString ? "" : timestampString} (${formattedName}'s actions: ${messageActions.join(", ")})` : null;
|
|
471
|
-
const planString = newestMessageWithContentPlan?.id === message.id ? `(${formattedName}'s plan: ${newestMessageWithContentPlan
|
|
484
|
+
const planString = newestMessageWithContentPlan?.id === message.id ? `(${formattedName}'s plan: ${newestMessageWithContentPlan?.content?.plan})` : null;
|
|
472
485
|
const messageString = [
|
|
473
486
|
textString,
|
|
474
487
|
thoughtString,
|
|
@@ -540,7 +553,7 @@ Response format should be formatted in a valid JSON block like this:
|
|
|
540
553
|
|
|
541
554
|
Your response should include the valid JSON block and nothing else.`;
|
|
542
555
|
var booleanFooter = "Respond with only a YES or a NO.";
|
|
543
|
-
function
|
|
556
|
+
function parseBooleanFromText2(value) {
|
|
544
557
|
if (!value) return false;
|
|
545
558
|
const affirmative = ["YES", "Y", "TRUE", "T", "1", "ON", "ENABLE"];
|
|
546
559
|
const negative = ["NO", "N", "FALSE", "F", "0", "OFF", "DISABLE"];
|
|
@@ -601,7 +614,7 @@ function parseJSONObjectFromText(text) {
|
|
|
601
614
|
const jsonBlockMatch = text.match(jsonBlockPattern);
|
|
602
615
|
try {
|
|
603
616
|
if (jsonBlockMatch) {
|
|
604
|
-
jsonData = JSON.parse(jsonBlockMatch[1].trim());
|
|
617
|
+
jsonData = JSON.parse(normalizeJsonString(jsonBlockMatch[1].trim()));
|
|
605
618
|
} else {
|
|
606
619
|
jsonData = JSON.parse(normalizeJsonString(text.trim()));
|
|
607
620
|
}
|
|
@@ -929,7 +942,7 @@ async function getEntityDetails({
|
|
|
929
942
|
for (const entity of roomEntities) {
|
|
930
943
|
if (uniqueEntities.has(entity.id)) continue;
|
|
931
944
|
const allData = {};
|
|
932
|
-
for (const component of entity.components) {
|
|
945
|
+
for (const component of entity.components || []) {
|
|
933
946
|
Object.assign(allData, component.data);
|
|
934
947
|
}
|
|
935
948
|
const mergedData = {};
|
|
@@ -953,6 +966,16 @@ async function getEntityDetails({
|
|
|
953
966
|
}
|
|
954
967
|
return Array.from(uniqueEntities.values());
|
|
955
968
|
}
|
|
969
|
+
function formatEntities({ entities }) {
|
|
970
|
+
const entityStrings = entities.map((entity) => {
|
|
971
|
+
const header = `${entity.names.join(" aka ")}
|
|
972
|
+
ID: ${entity.id}${entity.metadata && Object.keys(entity.metadata).length > 0 ? `
|
|
973
|
+
Data: ${JSON.stringify(entity.metadata)}
|
|
974
|
+
` : "\n"}`;
|
|
975
|
+
return header;
|
|
976
|
+
});
|
|
977
|
+
return entityStrings.join("\n");
|
|
978
|
+
}
|
|
956
979
|
|
|
957
980
|
// src/environment.ts
|
|
958
981
|
import fs from "node:fs";
|
|
@@ -7821,7 +7844,7 @@ var unfollowRoomAction = {
|
|
|
7821
7844
|
const response = await runtime.useModel(ModelTypes.TEXT_SMALL, {
|
|
7822
7845
|
prompt: shouldUnfollowPrompt
|
|
7823
7846
|
});
|
|
7824
|
-
const parsedResponse =
|
|
7847
|
+
const parsedResponse = parseBooleanFromText2(response.trim());
|
|
7825
7848
|
return parsedResponse;
|
|
7826
7849
|
}
|
|
7827
7850
|
if (await _shouldUnfollow(state)) {
|
|
@@ -9358,16 +9381,6 @@ var choiceProvider = {
|
|
|
9358
9381
|
};
|
|
9359
9382
|
|
|
9360
9383
|
// src/providers/entities.ts
|
|
9361
|
-
function formatEntities({ entities }) {
|
|
9362
|
-
const entityStrings = entities.map((entity) => {
|
|
9363
|
-
const header = `${entity.names.join(" aka ")}
|
|
9364
|
-
ID: ${entity.id}${entity.metadata && Object.keys(entity.metadata).length > 0 ? `
|
|
9365
|
-
Data: ${JSON.stringify(entity.metadata)}
|
|
9366
|
-
` : "\n"}`;
|
|
9367
|
-
return header;
|
|
9368
|
-
});
|
|
9369
|
-
return entityStrings.join("\n");
|
|
9370
|
-
}
|
|
9371
9384
|
var entitiesProvider = {
|
|
9372
9385
|
name: "ENTITIES",
|
|
9373
9386
|
description: "People in the current conversation",
|
|
@@ -9686,16 +9699,16 @@ var recentMessagesProvider = {
|
|
|
9686
9699
|
return formattedInteractions.join("\n");
|
|
9687
9700
|
};
|
|
9688
9701
|
const getRecentPostInteractions = async (recentInteractionsData2, entities) => {
|
|
9689
|
-
const
|
|
9702
|
+
const combinedEntities = [...entities];
|
|
9690
9703
|
const actorIds = new Set(entities.map((entity) => entity.id));
|
|
9691
9704
|
for (const [id, entity] of interactionEntityMap.entries()) {
|
|
9692
9705
|
if (!actorIds.has(id)) {
|
|
9693
|
-
|
|
9706
|
+
combinedEntities.push(entity);
|
|
9694
9707
|
}
|
|
9695
9708
|
}
|
|
9696
9709
|
const formattedInteractions = formatPosts({
|
|
9697
9710
|
messages: recentInteractionsData2,
|
|
9698
|
-
entities:
|
|
9711
|
+
entities: combinedEntities,
|
|
9699
9712
|
conversationHeader: true
|
|
9700
9713
|
});
|
|
9701
9714
|
return formattedInteractions;
|
|
@@ -12529,6 +12542,7 @@ export {
|
|
|
12529
12542
|
findWorldForOwner,
|
|
12530
12543
|
formatActionNames,
|
|
12531
12544
|
formatActions,
|
|
12545
|
+
formatEntities,
|
|
12532
12546
|
formatMessages,
|
|
12533
12547
|
formatPosts,
|
|
12534
12548
|
formatTimestamp,
|
|
@@ -12544,7 +12558,7 @@ export {
|
|
|
12544
12558
|
messageHandlerTemplate,
|
|
12545
12559
|
normalizeJsonString,
|
|
12546
12560
|
parseActionResponseFromText,
|
|
12547
|
-
parseBooleanFromText,
|
|
12561
|
+
parseBooleanFromText2 as parseBooleanFromText,
|
|
12548
12562
|
parseJSONObjectFromText,
|
|
12549
12563
|
parseJsonArrayFromText,
|
|
12550
12564
|
postActionResponseFooter,
|