@elizaos/core 1.6.2-alpha.20 → 1.6.2-alpha.21
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/node/index.node.js
CHANGED
|
@@ -43820,7 +43820,7 @@ class AgentRuntime {
|
|
|
43820
43820
|
currentActionContext;
|
|
43821
43821
|
maxWorkingMemoryEntries = 50;
|
|
43822
43822
|
constructor(opts) {
|
|
43823
|
-
this.agentId = opts.character?.id ?? opts?.agentId ?? stringToUuid(opts.character?.name ?? v4_default()
|
|
43823
|
+
this.agentId = opts.character?.id ?? opts?.agentId ?? stringToUuid(opts.character?.name ?? v4_default());
|
|
43824
43824
|
this.character = opts.character;
|
|
43825
43825
|
this.initPromise = new Promise((resolve, reject) => {
|
|
43826
43826
|
this.initResolver = resolve;
|
|
@@ -43986,9 +43986,12 @@ class AgentRuntime {
|
|
|
43986
43986
|
this.logger.info("Running plugin migrations...");
|
|
43987
43987
|
await this.runPluginMigrations();
|
|
43988
43988
|
this.logger.info("Plugin migrations completed.");
|
|
43989
|
-
const existingAgent = await this.ensureAgentExists(
|
|
43989
|
+
const existingAgent = await this.ensureAgentExists({
|
|
43990
|
+
...this.character,
|
|
43991
|
+
id: this.agentId
|
|
43992
|
+
});
|
|
43990
43993
|
if (!existingAgent) {
|
|
43991
|
-
const errorMsg = `Agent ${this.
|
|
43994
|
+
const errorMsg = `Agent ${this.agentId} does not exist in database after ensureAgentExists call`;
|
|
43992
43995
|
throw new Error(errorMsg);
|
|
43993
43996
|
}
|
|
43994
43997
|
let agentEntity = await this.getEntityById(this.agentId);
|
|
@@ -44536,42 +44539,56 @@ class AgentRuntime {
|
|
|
44536
44539
|
}
|
|
44537
44540
|
}
|
|
44538
44541
|
async evaluate(message, state, didRespond, callback, responses) {
|
|
44539
|
-
|
|
44540
|
-
|
|
44541
|
-
|
|
44542
|
-
|
|
44543
|
-
|
|
44544
|
-
|
|
44545
|
-
|
|
44546
|
-
|
|
44547
|
-
|
|
44548
|
-
|
|
44542
|
+
try {
|
|
44543
|
+
const evaluatorPromises = this.evaluators.map(async (evaluator) => {
|
|
44544
|
+
try {
|
|
44545
|
+
if (!evaluator.handler) {
|
|
44546
|
+
return null;
|
|
44547
|
+
}
|
|
44548
|
+
if (!didRespond && !evaluator.alwaysRun) {
|
|
44549
|
+
return null;
|
|
44550
|
+
}
|
|
44551
|
+
const result = await evaluator.validate(this, message, state);
|
|
44552
|
+
if (result) {
|
|
44553
|
+
return evaluator;
|
|
44554
|
+
}
|
|
44555
|
+
return null;
|
|
44556
|
+
} catch (error) {
|
|
44557
|
+
this.logger.error({ error, evaluatorName: evaluator.name }, `Error validating evaluator ${evaluator.name}`);
|
|
44558
|
+
return null;
|
|
44559
|
+
}
|
|
44560
|
+
});
|
|
44561
|
+
const evaluators = (await Promise.all(evaluatorPromises)).filter(Boolean);
|
|
44562
|
+
if (evaluators.length === 0) {
|
|
44563
|
+
return [];
|
|
44549
44564
|
}
|
|
44550
|
-
|
|
44551
|
-
|
|
44552
|
-
|
|
44553
|
-
|
|
44565
|
+
state = await this.composeState(message, ["RECENT_MESSAGES", "EVALUATORS"]);
|
|
44566
|
+
await Promise.all(evaluators.map(async (evaluator) => {
|
|
44567
|
+
try {
|
|
44568
|
+
if (evaluator.handler) {
|
|
44569
|
+
await evaluator.handler(this, message, state, {}, callback, responses);
|
|
44570
|
+
this.adapter.log({
|
|
44571
|
+
entityId: message.entityId,
|
|
44572
|
+
roomId: message.roomId,
|
|
44573
|
+
type: "evaluator",
|
|
44574
|
+
body: {
|
|
44575
|
+
evaluator: evaluator.name,
|
|
44576
|
+
messageId: message.id,
|
|
44577
|
+
message: message.content.text,
|
|
44578
|
+
state,
|
|
44579
|
+
runId: this.getCurrentRunId()
|
|
44580
|
+
}
|
|
44581
|
+
});
|
|
44582
|
+
}
|
|
44583
|
+
} catch (error) {
|
|
44584
|
+
this.logger.error({ error, evaluatorName: evaluator.name }, `Error executing evaluator ${evaluator.name}`);
|
|
44585
|
+
}
|
|
44586
|
+
}));
|
|
44587
|
+
return evaluators;
|
|
44588
|
+
} catch (error) {
|
|
44589
|
+
this.logger.error({ error, messageId: message.id, roomId: message.roomId }, "Error in evaluate method");
|
|
44554
44590
|
return [];
|
|
44555
44591
|
}
|
|
44556
|
-
state = await this.composeState(message, ["RECENT_MESSAGES", "EVALUATORS"]);
|
|
44557
|
-
await Promise.all(evaluators.map(async (evaluator) => {
|
|
44558
|
-
if (evaluator.handler) {
|
|
44559
|
-
await evaluator.handler(this, message, state, {}, callback, responses);
|
|
44560
|
-
this.adapter.log({
|
|
44561
|
-
entityId: message.entityId,
|
|
44562
|
-
roomId: message.roomId,
|
|
44563
|
-
type: "evaluator",
|
|
44564
|
-
body: {
|
|
44565
|
-
evaluator: evaluator.name,
|
|
44566
|
-
messageId: message.id,
|
|
44567
|
-
message: message.content.text,
|
|
44568
|
-
state,
|
|
44569
|
-
runId: this.getCurrentRunId()
|
|
44570
|
-
}
|
|
44571
|
-
});
|
|
44572
|
-
}
|
|
44573
|
-
}));
|
|
44574
|
-
return evaluators;
|
|
44575
44592
|
}
|
|
44576
44593
|
async ensureConnections(entities, rooms, source, world) {
|
|
44577
44594
|
if (!entities) {
|
|
@@ -45307,34 +45324,33 @@ ${input}`;
|
|
|
45307
45324
|
return await this.adapter.deleteAgent(agentId);
|
|
45308
45325
|
}
|
|
45309
45326
|
async ensureAgentExists(agent) {
|
|
45310
|
-
if (!agent.
|
|
45311
|
-
throw new Error("Agent
|
|
45327
|
+
if (!agent.id) {
|
|
45328
|
+
throw new Error("Agent id is required");
|
|
45312
45329
|
}
|
|
45313
|
-
const
|
|
45314
|
-
|
|
45315
|
-
if (existingAgentId) {
|
|
45330
|
+
const existingAgent = await this.adapter.getAgent(agent.id);
|
|
45331
|
+
if (existingAgent) {
|
|
45316
45332
|
const updatedAgent = {
|
|
45317
45333
|
...agent,
|
|
45318
|
-
id:
|
|
45334
|
+
id: agent.id,
|
|
45319
45335
|
updatedAt: Date.now()
|
|
45320
45336
|
};
|
|
45321
|
-
await this.adapter.updateAgent(
|
|
45322
|
-
const
|
|
45323
|
-
if (!
|
|
45324
|
-
throw new Error(`Failed to retrieve agent after update: ${
|
|
45337
|
+
await this.adapter.updateAgent(agent.id, updatedAgent);
|
|
45338
|
+
const refreshedAgent = await this.adapter.getAgent(agent.id);
|
|
45339
|
+
if (!refreshedAgent) {
|
|
45340
|
+
throw new Error(`Failed to retrieve agent after update: ${agent.id}`);
|
|
45325
45341
|
}
|
|
45326
|
-
this.logger.debug(`Updated existing agent ${agent.
|
|
45327
|
-
return
|
|
45342
|
+
this.logger.debug(`Updated existing agent ${agent.id} on restart`);
|
|
45343
|
+
return refreshedAgent;
|
|
45328
45344
|
}
|
|
45329
45345
|
const newAgent = {
|
|
45330
45346
|
...agent,
|
|
45331
|
-
id:
|
|
45347
|
+
id: agent.id
|
|
45332
45348
|
};
|
|
45333
45349
|
const created = await this.adapter.createAgent(newAgent);
|
|
45334
45350
|
if (!created) {
|
|
45335
|
-
throw new Error(`Failed to create agent: ${agent.
|
|
45351
|
+
throw new Error(`Failed to create agent: ${agent.id}`);
|
|
45336
45352
|
}
|
|
45337
|
-
this.logger.debug(`Created new agent ${agent.
|
|
45353
|
+
this.logger.debug(`Created new agent ${agent.id}`);
|
|
45338
45354
|
return newAgent;
|
|
45339
45355
|
}
|
|
45340
45356
|
async getEntityById(entityId) {
|
|
@@ -46928,5 +46944,5 @@ export {
|
|
|
46928
46944
|
AgentRuntime
|
|
46929
46945
|
};
|
|
46930
46946
|
|
|
46931
|
-
//# debugId=
|
|
46947
|
+
//# debugId=4E1D16D9C214CAAC64756E2164756E21
|
|
46932
46948
|
//# sourceMappingURL=index.node.js.map
|