@elizaos/plugin-bootstrap 1.0.8 → 1.0.10
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 +228 -724
- package/dist/index.js.map +1 -1
- package/package.json +7 -9
package/dist/index.js
CHANGED
|
@@ -71,7 +71,7 @@ var require_dedent = __commonJS({
|
|
|
71
71
|
|
|
72
72
|
// src/index.ts
|
|
73
73
|
import {
|
|
74
|
-
asUUID
|
|
74
|
+
asUUID,
|
|
75
75
|
ChannelType as ChannelType9,
|
|
76
76
|
composePromptFromState as composePromptFromState9,
|
|
77
77
|
ContentType,
|
|
@@ -139,8 +139,7 @@ import {
|
|
|
139
139
|
getUserServerRole,
|
|
140
140
|
logger,
|
|
141
141
|
ModelType,
|
|
142
|
-
parseJSONObjectFromText
|
|
143
|
-
asUUID
|
|
142
|
+
parseJSONObjectFromText
|
|
144
143
|
} from "@elizaos/core";
|
|
145
144
|
var optionExtractionTemplate = `# Task: Extract selected task and option from user message
|
|
146
145
|
|
|
@@ -252,97 +251,55 @@ ${task.options?.map((opt) => `- ${opt.name}: ${opt.description}`).join("\n")}`;
|
|
|
252
251
|
const taskMap = new Map(formattedTasks.map((task) => [task.taskId, task]));
|
|
253
252
|
const taskInfo = taskMap.get(taskId);
|
|
254
253
|
if (!taskInfo) {
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
text: `Could not find a task matching ID: ${taskId}. Please try again.`,
|
|
261
|
-
source: message.content.source
|
|
262
|
-
},
|
|
263
|
-
roomId: message.roomId,
|
|
264
|
-
createdAt: Date.now()
|
|
265
|
-
};
|
|
266
|
-
responses?.push(errorMessage);
|
|
254
|
+
await callback?.({
|
|
255
|
+
text: `Could not find a task matching ID: ${taskId}. Please try again.`,
|
|
256
|
+
actions: ["SELECT_OPTION_ERROR"],
|
|
257
|
+
source: message.content.source
|
|
258
|
+
});
|
|
267
259
|
return;
|
|
268
260
|
}
|
|
269
261
|
const selectedTask = tasksWithOptions.find((task) => task.id === taskInfo.fullId);
|
|
270
262
|
if (!selectedTask) {
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
text: "Error locating the selected task. Please try again.",
|
|
277
|
-
source: message.content.source
|
|
278
|
-
},
|
|
279
|
-
roomId: message.roomId,
|
|
280
|
-
createdAt: Date.now()
|
|
281
|
-
};
|
|
282
|
-
responses?.push(errorMessage);
|
|
263
|
+
await callback?.({
|
|
264
|
+
text: "Error locating the selected task. Please try again.",
|
|
265
|
+
actions: ["SELECT_OPTION_ERROR"],
|
|
266
|
+
source: message.content.source
|
|
267
|
+
});
|
|
283
268
|
return;
|
|
284
269
|
}
|
|
285
270
|
if (selectedOption === "ABORT") {
|
|
286
271
|
if (!selectedTask?.id) {
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
text: "Error locating the selected task. Please try again.",
|
|
293
|
-
source: message.content.source
|
|
294
|
-
},
|
|
295
|
-
roomId: message.roomId,
|
|
296
|
-
createdAt: Date.now()
|
|
297
|
-
};
|
|
298
|
-
responses?.push(errorMessage);
|
|
272
|
+
await callback?.({
|
|
273
|
+
text: "Error locating the selected task. Please try again.",
|
|
274
|
+
actions: ["SELECT_OPTION_ERROR"],
|
|
275
|
+
source: message.content.source
|
|
276
|
+
});
|
|
299
277
|
return;
|
|
300
278
|
}
|
|
301
279
|
await runtime.deleteTask(selectedTask.id);
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
text: `Task "${selectedTask.name}" has been cancelled.`,
|
|
308
|
-
source: message.content.source
|
|
309
|
-
},
|
|
310
|
-
roomId: message.roomId,
|
|
311
|
-
createdAt: Date.now()
|
|
312
|
-
};
|
|
313
|
-
responses?.push(cancelMessage);
|
|
280
|
+
await callback?.({
|
|
281
|
+
text: `Task "${selectedTask.name}" has been cancelled.`,
|
|
282
|
+
actions: ["CHOOSE_OPTION_CANCELLED"],
|
|
283
|
+
source: message.content.source
|
|
284
|
+
});
|
|
314
285
|
return;
|
|
315
286
|
}
|
|
316
287
|
try {
|
|
317
288
|
const taskWorker = runtime.getTaskWorker(selectedTask.name);
|
|
318
289
|
await taskWorker?.execute(runtime, { option: selectedOption }, selectedTask);
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
text: `Selected option: ${selectedOption} for task: ${selectedTask.name}`,
|
|
325
|
-
source: message.content.source
|
|
326
|
-
},
|
|
327
|
-
roomId: message.roomId,
|
|
328
|
-
createdAt: Date.now()
|
|
329
|
-
};
|
|
330
|
-
responses?.push(successMessage);
|
|
290
|
+
await callback?.({
|
|
291
|
+
text: `Selected option: ${selectedOption} for task: ${selectedTask.name}`,
|
|
292
|
+
actions: ["CHOOSE_OPTION"],
|
|
293
|
+
source: message.content.source
|
|
294
|
+
});
|
|
331
295
|
return;
|
|
332
296
|
} catch (error) {
|
|
333
297
|
logger.error("Error executing task with option:", error);
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
text: "There was an error processing your selection.",
|
|
340
|
-
source: message.content.source
|
|
341
|
-
},
|
|
342
|
-
roomId: message.roomId,
|
|
343
|
-
createdAt: Date.now()
|
|
344
|
-
};
|
|
345
|
-
responses?.push(errorMessage);
|
|
298
|
+
await callback?.({
|
|
299
|
+
text: "There was an error processing your selection.",
|
|
300
|
+
actions: ["SELECT_OPTION_ERROR"],
|
|
301
|
+
source: message.content.source
|
|
302
|
+
});
|
|
346
303
|
return;
|
|
347
304
|
}
|
|
348
305
|
}
|
|
@@ -358,28 +315,11 @@ ${task.options?.map((opt) => `- ${opt.name}: ${opt.description}`).join("\n")}`;
|
|
|
358
315
|
optionsText += options?.map((opt) => `- ${opt}`).join("\n");
|
|
359
316
|
optionsText += "\n\n";
|
|
360
317
|
});
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
text: optionsText,
|
|
367
|
-
source: message.content.source
|
|
368
|
-
},
|
|
369
|
-
roomId: message.roomId,
|
|
370
|
-
createdAt: Date.now()
|
|
371
|
-
};
|
|
372
|
-
await runtime.createMemory(
|
|
373
|
-
{
|
|
374
|
-
...invalidMessage,
|
|
375
|
-
content: {
|
|
376
|
-
...invalidMessage.content,
|
|
377
|
-
actions: ["SELECT_OPTION_INVALID"]
|
|
378
|
-
}
|
|
379
|
-
},
|
|
380
|
-
"messages"
|
|
381
|
-
);
|
|
382
|
-
responses?.push(invalidMessage);
|
|
318
|
+
await callback?.({
|
|
319
|
+
text: optionsText,
|
|
320
|
+
actions: ["SELECT_OPTION_INVALID"],
|
|
321
|
+
source: message.content.source
|
|
322
|
+
});
|
|
383
323
|
},
|
|
384
324
|
examples: [
|
|
385
325
|
[
|
|
@@ -420,8 +360,7 @@ import {
|
|
|
420
360
|
booleanFooter,
|
|
421
361
|
composePromptFromState,
|
|
422
362
|
logger as logger2,
|
|
423
|
-
ModelType as ModelType2
|
|
424
|
-
asUUID as asUUID2
|
|
363
|
+
ModelType as ModelType2
|
|
425
364
|
} from "@elizaos/core";
|
|
426
365
|
var shouldFollowTemplate = `# Task: Decide if {{agentName}} should start following this room, i.e. eagerly participating without explicit mentions.
|
|
427
366
|
|
|
@@ -448,7 +387,7 @@ var followRoomAction = {
|
|
|
448
387
|
const roomState = await runtime.getParticipantUserState(roomId, runtime.agentId);
|
|
449
388
|
return roomState !== "FOLLOWED" && roomState !== "MUTED";
|
|
450
389
|
},
|
|
451
|
-
handler: async (runtime, message, state, _options, _callback,
|
|
390
|
+
handler: async (runtime, message, state, _options, _callback, _responses) => {
|
|
452
391
|
if (!state) {
|
|
453
392
|
logger2.error("State is required for followRoomAction");
|
|
454
393
|
throw new Error("State is required for followRoomAction");
|
|
@@ -522,30 +461,6 @@ var followRoomAction = {
|
|
|
522
461
|
},
|
|
523
462
|
"messages"
|
|
524
463
|
);
|
|
525
|
-
const followMessage = {
|
|
526
|
-
id: asUUID2(v4_default()),
|
|
527
|
-
entityId: runtime.agentId,
|
|
528
|
-
agentId: runtime.agentId,
|
|
529
|
-
content: {
|
|
530
|
-
text: "",
|
|
531
|
-
// Empty text since this is just an action
|
|
532
|
-
thought: `I followed the room ${room.name}`,
|
|
533
|
-
source: message.content.source
|
|
534
|
-
},
|
|
535
|
-
roomId: message.roomId,
|
|
536
|
-
createdAt: Date.now()
|
|
537
|
-
};
|
|
538
|
-
await runtime.createMemory(
|
|
539
|
-
{
|
|
540
|
-
...followMessage,
|
|
541
|
-
content: {
|
|
542
|
-
...followMessage.content,
|
|
543
|
-
actions: ["FOLLOW_ROOM"]
|
|
544
|
-
}
|
|
545
|
-
},
|
|
546
|
-
"messages"
|
|
547
|
-
);
|
|
548
|
-
responses?.push(followMessage);
|
|
549
464
|
},
|
|
550
465
|
examples: [
|
|
551
466
|
[
|
|
@@ -823,7 +738,6 @@ var followRoomAction = {
|
|
|
823
738
|
};
|
|
824
739
|
|
|
825
740
|
// src/actions/ignore.ts
|
|
826
|
-
import { asUUID as asUUID3 } from "@elizaos/core";
|
|
827
741
|
var ignoreAction = {
|
|
828
742
|
name: "IGNORE",
|
|
829
743
|
similes: ["STOP_TALKING", "STOP_CHATTING", "STOP_CONVERSATION"],
|
|
@@ -831,23 +745,10 @@ var ignoreAction = {
|
|
|
831
745
|
return true;
|
|
832
746
|
},
|
|
833
747
|
description: "Call this action if ignoring the user. If the user is aggressive, creepy or is finished with the conversation, use this action. Or, if both you and the user have already said goodbye, use this action instead of saying bye again. Use IGNORE any time the conversation has naturally ended. Do not use IGNORE if the user has engaged directly, or if something went wrong an you need to tell them. Only ignore if the user should be ignored.",
|
|
834
|
-
handler: async (
|
|
835
|
-
if (
|
|
836
|
-
|
|
748
|
+
handler: async (_runtime, _message, _state, _options, callback, responses) => {
|
|
749
|
+
if (callback && responses?.[0]?.content) {
|
|
750
|
+
await callback(responses[0].content);
|
|
837
751
|
}
|
|
838
|
-
const ignoreMessage = {
|
|
839
|
-
id: asUUID3(v4_default()),
|
|
840
|
-
entityId: runtime.agentId,
|
|
841
|
-
agentId: runtime.agentId,
|
|
842
|
-
content: {
|
|
843
|
-
text: "",
|
|
844
|
-
actions: ["IGNORE"],
|
|
845
|
-
source: message.content.source
|
|
846
|
-
},
|
|
847
|
-
roomId: message.roomId,
|
|
848
|
-
createdAt: Date.now()
|
|
849
|
-
};
|
|
850
|
-
await runtime.createMemory(ignoreMessage, "messages");
|
|
851
752
|
return true;
|
|
852
753
|
},
|
|
853
754
|
examples: [
|
|
@@ -879,7 +780,7 @@ var ignoreAction = {
|
|
|
879
780
|
{
|
|
880
781
|
name: "{{name2}}",
|
|
881
782
|
content: {
|
|
882
|
-
text: "Uh, don
|
|
783
|
+
text: "Uh, don\u2019t let the volatility sway your long-term strategy"
|
|
883
784
|
}
|
|
884
785
|
},
|
|
885
786
|
{
|
|
@@ -1062,8 +963,7 @@ import {
|
|
|
1062
963
|
booleanFooter as booleanFooter2,
|
|
1063
964
|
composePromptFromState as composePromptFromState2,
|
|
1064
965
|
logger as logger3,
|
|
1065
|
-
ModelType as ModelType3
|
|
1066
|
-
asUUID as asUUID4
|
|
966
|
+
ModelType as ModelType3
|
|
1067
967
|
} from "@elizaos/core";
|
|
1068
968
|
var shouldMuteTemplate = `# Task: Decide if {{agentName}} should mute this room and stop responding unless explicitly mentioned.
|
|
1069
969
|
|
|
@@ -1087,7 +987,7 @@ var muteRoomAction = {
|
|
|
1087
987
|
const roomState = await runtime.getParticipantUserState(roomId, runtime.agentId);
|
|
1088
988
|
return roomState !== "MUTED";
|
|
1089
989
|
},
|
|
1090
|
-
handler: async (runtime, message, state, _options, _callback,
|
|
990
|
+
handler: async (runtime, message, state, _options, _callback, _responses) => {
|
|
1091
991
|
if (!state) {
|
|
1092
992
|
logger3.error("State is required for muting a room");
|
|
1093
993
|
throw new Error("State is required for muting a room");
|
|
@@ -1160,21 +1060,6 @@ var muteRoomAction = {
|
|
|
1160
1060
|
},
|
|
1161
1061
|
"messages"
|
|
1162
1062
|
);
|
|
1163
|
-
const muteMessage = {
|
|
1164
|
-
id: asUUID4(v4_default()),
|
|
1165
|
-
entityId: runtime.agentId,
|
|
1166
|
-
agentId: runtime.agentId,
|
|
1167
|
-
content: {
|
|
1168
|
-
text: "",
|
|
1169
|
-
// Empty text since this is just an action
|
|
1170
|
-
thought: `I muted the room ${room.name}`,
|
|
1171
|
-
actions: ["MUTE_ROOM"],
|
|
1172
|
-
source: message.content.source
|
|
1173
|
-
},
|
|
1174
|
-
roomId: message.roomId,
|
|
1175
|
-
createdAt: Date.now()
|
|
1176
|
-
};
|
|
1177
|
-
await runtime.createMemory(muteMessage, "messages");
|
|
1178
1063
|
},
|
|
1179
1064
|
examples: [
|
|
1180
1065
|
[
|
|
@@ -1288,7 +1173,6 @@ var muteRoomAction = {
|
|
|
1288
1173
|
};
|
|
1289
1174
|
|
|
1290
1175
|
// src/actions/none.ts
|
|
1291
|
-
import { asUUID as asUUID5 } from "@elizaos/core";
|
|
1292
1176
|
var noneAction = {
|
|
1293
1177
|
name: "NONE",
|
|
1294
1178
|
similes: ["NO_ACTION", "NO_RESPONSE", "NO_REACTION"],
|
|
@@ -1296,23 +1180,7 @@ var noneAction = {
|
|
|
1296
1180
|
return true;
|
|
1297
1181
|
},
|
|
1298
1182
|
description: "Respond but perform no additional action. This is the default if the agent is speaking and not doing anything additional.",
|
|
1299
|
-
handler: async (
|
|
1300
|
-
if (responses && responses.length > 0) {
|
|
1301
|
-
return true;
|
|
1302
|
-
}
|
|
1303
|
-
const noneMessage = {
|
|
1304
|
-
id: asUUID5(v4_default()),
|
|
1305
|
-
entityId: runtime.agentId,
|
|
1306
|
-
agentId: runtime.agentId,
|
|
1307
|
-
content: {
|
|
1308
|
-
text: "",
|
|
1309
|
-
actions: ["NONE"],
|
|
1310
|
-
source: message.content.source
|
|
1311
|
-
},
|
|
1312
|
-
roomId: message.roomId,
|
|
1313
|
-
createdAt: Date.now()
|
|
1314
|
-
};
|
|
1315
|
-
await runtime.createMemory(noneMessage, "messages");
|
|
1183
|
+
handler: async (_runtime, _message) => {
|
|
1316
1184
|
return true;
|
|
1317
1185
|
},
|
|
1318
1186
|
examples: [
|
|
@@ -1436,7 +1304,6 @@ var noneAction = {
|
|
|
1436
1304
|
};
|
|
1437
1305
|
|
|
1438
1306
|
// src/actions/reply.ts
|
|
1439
|
-
import { asUUID as asUUID6 } from "@elizaos/core";
|
|
1440
1307
|
import {
|
|
1441
1308
|
composePromptFromState as composePromptFromState3,
|
|
1442
1309
|
ModelType as ModelType4
|
|
@@ -1456,28 +1323,6 @@ Response format should be formatted in a valid JSON block like this:
|
|
|
1456
1323
|
\`\`\`
|
|
1457
1324
|
|
|
1458
1325
|
Your response should include the valid JSON block and nothing else.`;
|
|
1459
|
-
function getFirstAvailableField(obj, fields) {
|
|
1460
|
-
for (const field of fields) {
|
|
1461
|
-
if (typeof obj[field] === "string" && obj[field].trim() !== "") {
|
|
1462
|
-
return obj[field];
|
|
1463
|
-
}
|
|
1464
|
-
}
|
|
1465
|
-
return null;
|
|
1466
|
-
}
|
|
1467
|
-
function extractReplyContent(response, replyFieldKeys) {
|
|
1468
|
-
if ("isPlan" in response && response.isPlan) {
|
|
1469
|
-
return null;
|
|
1470
|
-
}
|
|
1471
|
-
const hasReplyAction = response.content.actions?.includes("REPLY");
|
|
1472
|
-
const text = getFirstAvailableField(response.content, replyFieldKeys);
|
|
1473
|
-
if (!hasReplyAction || !text) return null;
|
|
1474
|
-
return {
|
|
1475
|
-
...response.content,
|
|
1476
|
-
thought: response.content.thought,
|
|
1477
|
-
text,
|
|
1478
|
-
actions: ["REPLY"]
|
|
1479
|
-
};
|
|
1480
|
-
}
|
|
1481
1326
|
var replyAction = {
|
|
1482
1327
|
name: "REPLY",
|
|
1483
1328
|
similes: ["GREET", "REPLY_TO_MESSAGE", "SEND_REPLY", "RESPOND", "RESPONSE"],
|
|
@@ -1486,15 +1331,7 @@ var replyAction = {
|
|
|
1486
1331
|
return true;
|
|
1487
1332
|
},
|
|
1488
1333
|
handler: async (runtime, message, state, _options, callback, responses) => {
|
|
1489
|
-
const replyFieldKeys = ["message", "text"];
|
|
1490
|
-
const existingReplies = responses?.map((r) => extractReplyContent(r, replyFieldKeys)).filter((reply) => reply !== null) ?? [];
|
|
1491
1334
|
const allProviders = responses?.flatMap((res) => res.content?.providers ?? []) ?? [];
|
|
1492
|
-
if (existingReplies.length > 0 && allProviders.length === 0) {
|
|
1493
|
-
for (const reply of existingReplies) {
|
|
1494
|
-
await callback(reply);
|
|
1495
|
-
}
|
|
1496
|
-
return;
|
|
1497
|
-
}
|
|
1498
1335
|
state = await runtime.composeState(message, [...allProviders ?? [], "RECENT_MESSAGES"]);
|
|
1499
1336
|
const prompt = composePromptFromState3({
|
|
1500
1337
|
state,
|
|
@@ -1505,30 +1342,10 @@ var replyAction = {
|
|
|
1505
1342
|
});
|
|
1506
1343
|
const responseContent = {
|
|
1507
1344
|
thought: response.thought,
|
|
1508
|
-
text: response.message || ""
|
|
1509
|
-
|
|
1510
|
-
// here that would cause a loop in this action.
|
|
1511
|
-
// So never add this to responses unless this is decided
|
|
1512
|
-
// by the agent and you want to try loop.
|
|
1513
|
-
};
|
|
1514
|
-
const replyMessage = {
|
|
1515
|
-
id: asUUID6(v4_default()),
|
|
1516
|
-
entityId: runtime.agentId,
|
|
1517
|
-
agentId: runtime.agentId,
|
|
1518
|
-
content: responseContent,
|
|
1519
|
-
roomId: message.roomId,
|
|
1520
|
-
createdAt: Date.now()
|
|
1345
|
+
text: response.message || "",
|
|
1346
|
+
actions: ["REPLY"]
|
|
1521
1347
|
};
|
|
1522
|
-
await
|
|
1523
|
-
{
|
|
1524
|
-
...replyMessage,
|
|
1525
|
-
content: {
|
|
1526
|
-
...replyMessage.content,
|
|
1527
|
-
actions: ["REPLY"]
|
|
1528
|
-
}
|
|
1529
|
-
},
|
|
1530
|
-
"messages"
|
|
1531
|
-
);
|
|
1348
|
+
await callback(responseContent);
|
|
1532
1349
|
return true;
|
|
1533
1350
|
},
|
|
1534
1351
|
examples: [
|
|
@@ -1602,8 +1419,7 @@ import {
|
|
|
1602
1419
|
composePrompt as composePrompt2,
|
|
1603
1420
|
logger as logger4,
|
|
1604
1421
|
ModelType as ModelType5,
|
|
1605
|
-
Role
|
|
1606
|
-
asUUID as asUUID7
|
|
1422
|
+
Role
|
|
1607
1423
|
} from "@elizaos/core";
|
|
1608
1424
|
var canModifyRole = (currentRole, targetRole, newRole) => {
|
|
1609
1425
|
if (targetRole === currentRole) return false;
|
|
@@ -1633,7 +1449,7 @@ var updateRoleAction = {
|
|
|
1633
1449
|
!!serverId
|
|
1634
1450
|
);
|
|
1635
1451
|
},
|
|
1636
|
-
handler: async (runtime, message, state, _options, callback
|
|
1452
|
+
handler: async (runtime, message, state, _options, callback) => {
|
|
1637
1453
|
if (!state) {
|
|
1638
1454
|
logger4.error("State is required for role assignment");
|
|
1639
1455
|
throw new Error("State is required for role assignment");
|
|
@@ -1647,18 +1463,9 @@ var updateRoleAction = {
|
|
|
1647
1463
|
}
|
|
1648
1464
|
if (!world) {
|
|
1649
1465
|
logger4.error("World not found");
|
|
1650
|
-
|
|
1651
|
-
|
|
1652
|
-
|
|
1653
|
-
agentId: runtime.agentId,
|
|
1654
|
-
content: {
|
|
1655
|
-
text: "I couldn't find the world. This action only works in a world.",
|
|
1656
|
-
source: message.content.source
|
|
1657
|
-
},
|
|
1658
|
-
roomId: message.roomId,
|
|
1659
|
-
createdAt: Date.now()
|
|
1660
|
-
};
|
|
1661
|
-
responses?.push(errorMessage);
|
|
1466
|
+
await callback?.({
|
|
1467
|
+
text: "I couldn't find the world. This action only works in a world."
|
|
1468
|
+
});
|
|
1662
1469
|
return;
|
|
1663
1470
|
}
|
|
1664
1471
|
if (!world.metadata?.roles) {
|
|
@@ -1726,18 +1533,11 @@ var updateRoleAction = {
|
|
|
1726
1533
|
}
|
|
1727
1534
|
);
|
|
1728
1535
|
if (!result?.length) {
|
|
1729
|
-
|
|
1730
|
-
|
|
1731
|
-
|
|
1732
|
-
|
|
1733
|
-
|
|
1734
|
-
text: "No valid role assignments found in the request.",
|
|
1735
|
-
source: "discord"
|
|
1736
|
-
},
|
|
1737
|
-
roomId: message.roomId,
|
|
1738
|
-
createdAt: Date.now()
|
|
1739
|
-
};
|
|
1740
|
-
responses?.push(noAssignmentsMessage);
|
|
1536
|
+
await callback?.({
|
|
1537
|
+
text: "No valid role assignments found in the request.",
|
|
1538
|
+
actions: ["UPDATE_ROLE"],
|
|
1539
|
+
source: "discord"
|
|
1540
|
+
});
|
|
1741
1541
|
return;
|
|
1742
1542
|
}
|
|
1743
1543
|
let worldUpdated = false;
|
|
@@ -1748,43 +1548,20 @@ var updateRoleAction = {
|
|
|
1748
1548
|
}
|
|
1749
1549
|
const currentRole = world.metadata.roles[assignment.entityId];
|
|
1750
1550
|
if (!canModifyRole(requesterRole, currentRole, assignment.newRole)) {
|
|
1751
|
-
|
|
1752
|
-
|
|
1753
|
-
|
|
1754
|
-
|
|
1755
|
-
|
|
1756
|
-
text: `You don't have permission to change ${targetEntity?.names[0]}'s role to ${assignment.newRole}.`,
|
|
1757
|
-
source: "discord"
|
|
1758
|
-
},
|
|
1759
|
-
roomId: message.roomId,
|
|
1760
|
-
createdAt: Date.now()
|
|
1761
|
-
};
|
|
1762
|
-
responses?.push(permissionErrorMessage);
|
|
1551
|
+
await callback?.({
|
|
1552
|
+
text: `You don't have permission to change ${targetEntity?.names[0]}'s role to ${assignment.newRole}.`,
|
|
1553
|
+
actions: ["UPDATE_ROLE"],
|
|
1554
|
+
source: "discord"
|
|
1555
|
+
});
|
|
1763
1556
|
continue;
|
|
1764
1557
|
}
|
|
1765
1558
|
world.metadata.roles[assignment.entityId] = assignment.newRole;
|
|
1766
1559
|
worldUpdated = true;
|
|
1767
|
-
|
|
1768
|
-
|
|
1769
|
-
|
|
1770
|
-
|
|
1771
|
-
|
|
1772
|
-
text: `Updated ${targetEntity?.names[0]}'s role to ${assignment.newRole}.`,
|
|
1773
|
-
source: "discord"
|
|
1774
|
-
},
|
|
1775
|
-
roomId: message.roomId,
|
|
1776
|
-
createdAt: Date.now()
|
|
1777
|
-
};
|
|
1778
|
-
await runtime.createMemory(
|
|
1779
|
-
{
|
|
1780
|
-
...successMessage,
|
|
1781
|
-
content: {
|
|
1782
|
-
...successMessage.content,
|
|
1783
|
-
actions: ["UPDATE_ROLE"]
|
|
1784
|
-
}
|
|
1785
|
-
},
|
|
1786
|
-
"messages"
|
|
1787
|
-
);
|
|
1560
|
+
await callback?.({
|
|
1561
|
+
text: `Updated ${targetEntity?.names[0]}'s role to ${assignment.newRole}.`,
|
|
1562
|
+
actions: ["UPDATE_ROLE"],
|
|
1563
|
+
source: "discord"
|
|
1564
|
+
});
|
|
1788
1565
|
}
|
|
1789
1566
|
if (worldUpdated) {
|
|
1790
1567
|
await runtime.updateWorld(world);
|
|
@@ -1849,8 +1626,7 @@ import {
|
|
|
1849
1626
|
findEntityByName,
|
|
1850
1627
|
logger as logger5,
|
|
1851
1628
|
ModelType as ModelType6,
|
|
1852
|
-
parseJSONObjectFromText as parseJSONObjectFromText2
|
|
1853
|
-
asUUID as asUUID8
|
|
1629
|
+
parseJSONObjectFromText as parseJSONObjectFromText2
|
|
1854
1630
|
} from "@elizaos/core";
|
|
1855
1631
|
var targetExtractionTemplate = `# Task: Extract Target and Source Information
|
|
1856
1632
|
|
|
@@ -1924,6 +1700,7 @@ var sendMessageAction = {
|
|
|
1924
1700
|
throw new Error("Responses are required for sendMessage action");
|
|
1925
1701
|
}
|
|
1926
1702
|
for (const response of responses) {
|
|
1703
|
+
await callback(response.content);
|
|
1927
1704
|
}
|
|
1928
1705
|
const sourceEntityId = message.entityId;
|
|
1929
1706
|
const room = state.data.room ?? await runtime.getRoom(message.roomId);
|
|
@@ -1938,38 +1715,22 @@ var sendMessageAction = {
|
|
|
1938
1715
|
});
|
|
1939
1716
|
const targetData = parseJSONObjectFromText2(targetResult);
|
|
1940
1717
|
if (!targetData?.targetType || !targetData?.source) {
|
|
1941
|
-
|
|
1942
|
-
|
|
1943
|
-
|
|
1944
|
-
|
|
1945
|
-
|
|
1946
|
-
text: "I couldn't determine where you want me to send the message. Could you please specify the target (user or room) and platform?",
|
|
1947
|
-
actions: ["SEND_MESSAGE_ERROR"],
|
|
1948
|
-
source: message.content.source
|
|
1949
|
-
},
|
|
1950
|
-
roomId: message.roomId,
|
|
1951
|
-
createdAt: Date.now()
|
|
1952
|
-
};
|
|
1953
|
-
responses?.push(errorMessage);
|
|
1718
|
+
await callback({
|
|
1719
|
+
text: "I couldn't determine where you want me to send the message. Could you please specify the target (user or room) and platform?",
|
|
1720
|
+
actions: ["SEND_MESSAGE_ERROR"],
|
|
1721
|
+
source: message.content.source
|
|
1722
|
+
});
|
|
1954
1723
|
return;
|
|
1955
1724
|
}
|
|
1956
1725
|
const source = targetData.source.toLowerCase();
|
|
1957
1726
|
if (targetData.targetType === "user") {
|
|
1958
1727
|
const targetEntity = await findEntityByName(runtime, message, state);
|
|
1959
1728
|
if (!targetEntity) {
|
|
1960
|
-
|
|
1961
|
-
|
|
1962
|
-
|
|
1963
|
-
|
|
1964
|
-
|
|
1965
|
-
text: "I couldn't find the user you want me to send a message to. Could you please provide more details about who they are?",
|
|
1966
|
-
actions: ["SEND_MESSAGE_ERROR"],
|
|
1967
|
-
source: message.content.source
|
|
1968
|
-
},
|
|
1969
|
-
roomId: message.roomId,
|
|
1970
|
-
createdAt: Date.now()
|
|
1971
|
-
};
|
|
1972
|
-
responses?.push(errorMessage);
|
|
1729
|
+
await callback({
|
|
1730
|
+
text: "I couldn't find the user you want me to send a message to. Could you please provide more details about who they are?",
|
|
1731
|
+
actions: ["SEND_MESSAGE_ERROR"],
|
|
1732
|
+
source: message.content.source
|
|
1733
|
+
});
|
|
1973
1734
|
return;
|
|
1974
1735
|
}
|
|
1975
1736
|
const userComponent = await runtime.getComponent(
|
|
@@ -1979,77 +1740,36 @@ var sendMessageAction = {
|
|
|
1979
1740
|
sourceEntityId
|
|
1980
1741
|
);
|
|
1981
1742
|
if (!userComponent) {
|
|
1982
|
-
|
|
1983
|
-
|
|
1984
|
-
|
|
1985
|
-
|
|
1986
|
-
|
|
1987
|
-
text: `I couldn't find ${source} information for that user. Could you please provide their ${source} details?`,
|
|
1988
|
-
actions: ["SEND_MESSAGE_ERROR"],
|
|
1989
|
-
source: message.content.source
|
|
1990
|
-
},
|
|
1991
|
-
roomId: message.roomId,
|
|
1992
|
-
createdAt: Date.now()
|
|
1993
|
-
};
|
|
1994
|
-
responses?.push(errorMessage);
|
|
1743
|
+
await callback({
|
|
1744
|
+
text: `I couldn't find ${source} information for that user. Could you please provide their ${source} details?`,
|
|
1745
|
+
actions: ["SEND_MESSAGE_ERROR"],
|
|
1746
|
+
source: message.content.source
|
|
1747
|
+
});
|
|
1995
1748
|
return;
|
|
1996
1749
|
}
|
|
1997
1750
|
const sendDirectMessage = runtime.getService(source)?.sendDirectMessage;
|
|
1998
1751
|
if (!sendDirectMessage) {
|
|
1999
|
-
|
|
2000
|
-
|
|
2001
|
-
|
|
2002
|
-
|
|
2003
|
-
|
|
2004
|
-
text: "I couldn't find the user you want me to send a message to. Could you please provide more details about who they are?",
|
|
2005
|
-
actions: ["SEND_MESSAGE_ERROR"],
|
|
2006
|
-
source: message.content.source
|
|
2007
|
-
},
|
|
2008
|
-
roomId: message.roomId,
|
|
2009
|
-
createdAt: Date.now()
|
|
2010
|
-
};
|
|
2011
|
-
responses?.push(errorMessage);
|
|
1752
|
+
await callback({
|
|
1753
|
+
text: "I couldn't find the user you want me to send a message to. Could you please provide more details about who they are?",
|
|
1754
|
+
actions: ["SEND_MESSAGE_ERROR"],
|
|
1755
|
+
source: message.content.source
|
|
1756
|
+
});
|
|
2012
1757
|
return;
|
|
2013
1758
|
}
|
|
2014
1759
|
try {
|
|
2015
1760
|
await sendDirectMessage(runtime, targetEntity.id, source, message.content.text, worldId);
|
|
2016
|
-
|
|
2017
|
-
|
|
2018
|
-
|
|
2019
|
-
|
|
2020
|
-
|
|
2021
|
-
text: `Message sent to ${targetEntity.names[0]} on ${source}.`,
|
|
2022
|
-
source: message.content.source
|
|
2023
|
-
},
|
|
2024
|
-
roomId: message.roomId,
|
|
2025
|
-
createdAt: Date.now()
|
|
2026
|
-
};
|
|
2027
|
-
await runtime.createMemory(
|
|
2028
|
-
{
|
|
2029
|
-
...successMessage,
|
|
2030
|
-
content: {
|
|
2031
|
-
...successMessage.content,
|
|
2032
|
-
actions: ["SEND_MESSAGE"]
|
|
2033
|
-
}
|
|
2034
|
-
},
|
|
2035
|
-
"messages"
|
|
2036
|
-
);
|
|
2037
|
-
responses?.push(successMessage);
|
|
1761
|
+
await callback({
|
|
1762
|
+
text: `Message sent to ${targetEntity.names[0]} on ${source}.`,
|
|
1763
|
+
actions: ["SEND_MESSAGE"],
|
|
1764
|
+
source: message.content.source
|
|
1765
|
+
});
|
|
2038
1766
|
} catch (error) {
|
|
2039
1767
|
logger5.error(`Failed to send direct message: ${error.message}`);
|
|
2040
|
-
|
|
2041
|
-
|
|
2042
|
-
|
|
2043
|
-
|
|
2044
|
-
|
|
2045
|
-
text: "I encountered an error trying to send the message. Please try again.",
|
|
2046
|
-
actions: ["SEND_MESSAGE_ERROR"],
|
|
2047
|
-
source: message.content.source
|
|
2048
|
-
},
|
|
2049
|
-
roomId: message.roomId,
|
|
2050
|
-
createdAt: Date.now()
|
|
2051
|
-
};
|
|
2052
|
-
responses?.push(errorMessage);
|
|
1768
|
+
await callback({
|
|
1769
|
+
text: "I encountered an error trying to send the message. Please try again.",
|
|
1770
|
+
actions: ["SEND_MESSAGE_ERROR"],
|
|
1771
|
+
source: message.content.source
|
|
1772
|
+
});
|
|
2053
1773
|
}
|
|
2054
1774
|
} else if (targetData.targetType === "room") {
|
|
2055
1775
|
const rooms = await runtime.getRooms(worldId);
|
|
@@ -2057,85 +1777,45 @@ var sendMessageAction = {
|
|
|
2057
1777
|
return r.name?.toLowerCase() === targetData.identifiers.roomName?.toLowerCase();
|
|
2058
1778
|
});
|
|
2059
1779
|
if (!targetRoom) {
|
|
2060
|
-
|
|
2061
|
-
|
|
2062
|
-
|
|
2063
|
-
|
|
2064
|
-
|
|
2065
|
-
text: "I couldn't find the room you want me to send a message to. Could you please specify the exact room name?",
|
|
2066
|
-
actions: ["SEND_MESSAGE_ERROR"],
|
|
2067
|
-
source: message.content.source
|
|
2068
|
-
},
|
|
2069
|
-
roomId: message.roomId,
|
|
2070
|
-
createdAt: Date.now()
|
|
2071
|
-
};
|
|
2072
|
-
responses?.push(errorMessage);
|
|
1780
|
+
await callback({
|
|
1781
|
+
text: "I couldn't find the room you want me to send a message to. Could you please specify the exact room name?",
|
|
1782
|
+
actions: ["SEND_MESSAGE_ERROR"],
|
|
1783
|
+
source: message.content.source
|
|
1784
|
+
});
|
|
2073
1785
|
return;
|
|
2074
1786
|
}
|
|
2075
1787
|
const sendRoomMessage = runtime.getService(source)?.sendRoomMessage;
|
|
2076
1788
|
if (!sendRoomMessage) {
|
|
2077
|
-
|
|
2078
|
-
|
|
2079
|
-
|
|
2080
|
-
|
|
2081
|
-
|
|
2082
|
-
text: "I couldn't find the room you want me to send a message to. Could you please specify the exact room name?",
|
|
2083
|
-
actions: ["SEND_MESSAGE_ERROR"],
|
|
2084
|
-
source: message.content.source
|
|
2085
|
-
},
|
|
2086
|
-
roomId: message.roomId,
|
|
2087
|
-
createdAt: Date.now()
|
|
2088
|
-
};
|
|
2089
|
-
responses?.push(errorMessage);
|
|
1789
|
+
await callback({
|
|
1790
|
+
text: "I couldn't find the room you want me to send a message to. Could you please specify the exact room name?",
|
|
1791
|
+
actions: ["SEND_MESSAGE_ERROR"],
|
|
1792
|
+
source: message.content.source
|
|
1793
|
+
});
|
|
2090
1794
|
return;
|
|
2091
1795
|
}
|
|
2092
1796
|
try {
|
|
2093
1797
|
await sendRoomMessage(runtime, targetRoom.id, source, message.content.text, worldId);
|
|
2094
|
-
|
|
2095
|
-
|
|
2096
|
-
|
|
2097
|
-
|
|
2098
|
-
|
|
2099
|
-
text: `Message sent to ${targetRoom.name} on ${source}.`,
|
|
2100
|
-
actions: ["SEND_MESSAGE"],
|
|
2101
|
-
source: message.content.source
|
|
2102
|
-
},
|
|
2103
|
-
roomId: message.roomId,
|
|
2104
|
-
createdAt: Date.now()
|
|
2105
|
-
};
|
|
2106
|
-
responses?.push(successMessage);
|
|
1798
|
+
await callback({
|
|
1799
|
+
text: `Message sent to ${targetRoom.name} on ${source}.`,
|
|
1800
|
+
actions: ["SEND_MESSAGE"],
|
|
1801
|
+
source: message.content.source
|
|
1802
|
+
});
|
|
2107
1803
|
} catch (error) {
|
|
2108
1804
|
logger5.error(`Failed to send room message: ${error.message}`);
|
|
2109
|
-
|
|
2110
|
-
|
|
2111
|
-
|
|
2112
|
-
|
|
2113
|
-
|
|
2114
|
-
text: "I encountered an error trying to send the message to the room. Please try again.",
|
|
2115
|
-
actions: ["SEND_MESSAGE_ERROR"],
|
|
2116
|
-
source: message.content.source
|
|
2117
|
-
},
|
|
2118
|
-
roomId: message.roomId,
|
|
2119
|
-
createdAt: Date.now()
|
|
2120
|
-
};
|
|
2121
|
-
responses?.push(errorMessage);
|
|
1805
|
+
await callback({
|
|
1806
|
+
text: "I encountered an error trying to send the message to the room. Please try again.",
|
|
1807
|
+
actions: ["SEND_MESSAGE_ERROR"],
|
|
1808
|
+
source: message.content.source
|
|
1809
|
+
});
|
|
2122
1810
|
}
|
|
2123
1811
|
}
|
|
2124
1812
|
} catch (error) {
|
|
2125
1813
|
logger5.error(`Error in sendMessage handler: ${error}`);
|
|
2126
|
-
|
|
2127
|
-
|
|
2128
|
-
|
|
2129
|
-
|
|
2130
|
-
|
|
2131
|
-
text: "There was an error processing your message request.",
|
|
2132
|
-
actions: ["SEND_MESSAGE_ERROR"],
|
|
2133
|
-
source: message.content.source
|
|
2134
|
-
},
|
|
2135
|
-
roomId: message.roomId,
|
|
2136
|
-
createdAt: Date.now()
|
|
2137
|
-
};
|
|
2138
|
-
responses?.push(errorMessage);
|
|
1814
|
+
await callback?.({
|
|
1815
|
+
text: "There was an error processing your message request.",
|
|
1816
|
+
actions: ["SEND_MESSAGE_ERROR"],
|
|
1817
|
+
source: message.content.source
|
|
1818
|
+
});
|
|
2139
1819
|
}
|
|
2140
1820
|
},
|
|
2141
1821
|
examples: [
|
|
@@ -2197,8 +1877,7 @@ import {
|
|
|
2197
1877
|
findWorldsForOwner,
|
|
2198
1878
|
logger as logger6,
|
|
2199
1879
|
ModelType as ModelType7,
|
|
2200
|
-
parseJSONObjectFromText as parseJSONObjectFromText3
|
|
2201
|
-
asUUID as asUUID9
|
|
1880
|
+
parseJSONObjectFromText as parseJSONObjectFromText3
|
|
2202
1881
|
} from "@elizaos/core";
|
|
2203
1882
|
var messageCompletionFooter = `
|
|
2204
1883
|
# Instructions: Write the next message for {{agentName}}. Include the appropriate action from the list: {{actionNames}}
|
|
@@ -2467,7 +2146,7 @@ async function processSettingUpdates(runtime, serverId, worldSettings, updates)
|
|
|
2467
2146
|
};
|
|
2468
2147
|
}
|
|
2469
2148
|
}
|
|
2470
|
-
async function handleOnboardingComplete(runtime, worldSettings, state, callback
|
|
2149
|
+
async function handleOnboardingComplete(runtime, worldSettings, state, callback) {
|
|
2471
2150
|
try {
|
|
2472
2151
|
const prompt = composePrompt3({
|
|
2473
2152
|
state: {
|
|
@@ -2479,41 +2158,25 @@ async function handleOnboardingComplete(runtime, worldSettings, state, callback,
|
|
|
2479
2158
|
prompt
|
|
2480
2159
|
});
|
|
2481
2160
|
const responseContent = parseJSONObjectFromText3(response);
|
|
2482
|
-
|
|
2483
|
-
|
|
2484
|
-
|
|
2485
|
-
|
|
2486
|
-
|
|
2487
|
-
text: responseContent.text,
|
|
2488
|
-
actions: ["ONBOARDING_COMPLETE"],
|
|
2489
|
-
source: "discord"
|
|
2490
|
-
},
|
|
2491
|
-
roomId: state.roomId || "",
|
|
2492
|
-
createdAt: Date.now()
|
|
2493
|
-
};
|
|
2494
|
-
responses?.push(completionMessage);
|
|
2161
|
+
await callback({
|
|
2162
|
+
text: responseContent.text,
|
|
2163
|
+
actions: ["ONBOARDING_COMPLETE"],
|
|
2164
|
+
source: "discord"
|
|
2165
|
+
});
|
|
2495
2166
|
} catch (error) {
|
|
2496
2167
|
logger6.error(`Error handling settings completion: ${error}`);
|
|
2497
|
-
|
|
2498
|
-
|
|
2499
|
-
|
|
2500
|
-
|
|
2501
|
-
|
|
2502
|
-
text: "Great! All required settings have been configured. Your server is now fully set up and ready to use.",
|
|
2503
|
-
actions: ["ONBOARDING_COMPLETE"],
|
|
2504
|
-
source: "discord"
|
|
2505
|
-
},
|
|
2506
|
-
roomId: state.roomId || "",
|
|
2507
|
-
createdAt: Date.now()
|
|
2508
|
-
};
|
|
2509
|
-
responses?.push(errorMessage);
|
|
2168
|
+
await callback({
|
|
2169
|
+
text: "Great! All required settings have been configured. Your server is now fully set up and ready to use.",
|
|
2170
|
+
actions: ["ONBOARDING_COMPLETE"],
|
|
2171
|
+
source: "discord"
|
|
2172
|
+
});
|
|
2510
2173
|
}
|
|
2511
2174
|
}
|
|
2512
|
-
async function generateSuccessResponse(runtime, worldSettings, state, messages, callback
|
|
2175
|
+
async function generateSuccessResponse(runtime, worldSettings, state, messages, callback) {
|
|
2513
2176
|
try {
|
|
2514
2177
|
const { requiredUnconfigured } = categorizeSettings(worldSettings);
|
|
2515
2178
|
if (requiredUnconfigured.length === 0) {
|
|
2516
|
-
await handleOnboardingComplete(runtime, worldSettings, state, callback
|
|
2179
|
+
await handleOnboardingComplete(runtime, worldSettings, state, callback);
|
|
2517
2180
|
return;
|
|
2518
2181
|
}
|
|
2519
2182
|
const requiredUnconfiguredString = requiredUnconfigured.map(([key, setting]) => `${key}: ${setting.name}`).join("\n");
|
|
@@ -2529,50 +2192,25 @@ async function generateSuccessResponse(runtime, worldSettings, state, messages,
|
|
|
2529
2192
|
prompt
|
|
2530
2193
|
});
|
|
2531
2194
|
const responseContent = parseJSONObjectFromText3(response);
|
|
2532
|
-
|
|
2533
|
-
|
|
2534
|
-
|
|
2535
|
-
|
|
2536
|
-
|
|
2537
|
-
text: responseContent.text,
|
|
2538
|
-
source: "discord"
|
|
2539
|
-
},
|
|
2540
|
-
roomId: state.roomId || "",
|
|
2541
|
-
createdAt: Date.now()
|
|
2542
|
-
};
|
|
2543
|
-
await runtime.createMemory(
|
|
2544
|
-
{
|
|
2545
|
-
...successMessage,
|
|
2546
|
-
content: {
|
|
2547
|
-
...successMessage.content,
|
|
2548
|
-
actions: ["SETTING_UPDATED"]
|
|
2549
|
-
}
|
|
2550
|
-
},
|
|
2551
|
-
"messages"
|
|
2552
|
-
);
|
|
2553
|
-
responses?.push(successMessage);
|
|
2195
|
+
await callback({
|
|
2196
|
+
text: responseContent.text,
|
|
2197
|
+
actions: ["SETTING_UPDATED"],
|
|
2198
|
+
source: "discord"
|
|
2199
|
+
});
|
|
2554
2200
|
} catch (error) {
|
|
2555
2201
|
logger6.error(`Error generating success response: ${error}`);
|
|
2556
|
-
|
|
2557
|
-
|
|
2558
|
-
|
|
2559
|
-
|
|
2560
|
-
|
|
2561
|
-
text: "Settings updated successfully. Please continue with the remaining configuration.",
|
|
2562
|
-
actions: ["SETTING_UPDATED"],
|
|
2563
|
-
source: "discord"
|
|
2564
|
-
},
|
|
2565
|
-
roomId: state.roomId || "",
|
|
2566
|
-
createdAt: Date.now()
|
|
2567
|
-
};
|
|
2568
|
-
responses?.push(errorMessage);
|
|
2202
|
+
await callback({
|
|
2203
|
+
text: "Settings updated successfully. Please continue with the remaining configuration.",
|
|
2204
|
+
actions: ["SETTING_UPDATED"],
|
|
2205
|
+
source: "discord"
|
|
2206
|
+
});
|
|
2569
2207
|
}
|
|
2570
2208
|
}
|
|
2571
|
-
async function generateFailureResponse(runtime, worldSettings, state, callback
|
|
2209
|
+
async function generateFailureResponse(runtime, worldSettings, state, callback) {
|
|
2572
2210
|
try {
|
|
2573
2211
|
const { requiredUnconfigured } = categorizeSettings(worldSettings);
|
|
2574
2212
|
if (requiredUnconfigured.length === 0) {
|
|
2575
|
-
await handleOnboardingComplete(runtime, worldSettings, state, callback
|
|
2213
|
+
await handleOnboardingComplete(runtime, worldSettings, state, callback);
|
|
2576
2214
|
return;
|
|
2577
2215
|
}
|
|
2578
2216
|
const requiredUnconfiguredString = requiredUnconfigured.map(([key, setting]) => `${key}: ${setting.name}`).join("\n");
|
|
@@ -2587,37 +2225,21 @@ async function generateFailureResponse(runtime, worldSettings, state, callback,
|
|
|
2587
2225
|
prompt
|
|
2588
2226
|
});
|
|
2589
2227
|
const responseContent = parseJSONObjectFromText3(response);
|
|
2590
|
-
|
|
2591
|
-
|
|
2592
|
-
|
|
2593
|
-
|
|
2594
|
-
|
|
2595
|
-
text: responseContent.text,
|
|
2596
|
-
actions: ["SETTING_UPDATE_FAILED"],
|
|
2597
|
-
source: "discord"
|
|
2598
|
-
},
|
|
2599
|
-
roomId: state.roomId || "",
|
|
2600
|
-
createdAt: Date.now()
|
|
2601
|
-
};
|
|
2602
|
-
responses?.push(failureMessage);
|
|
2228
|
+
await callback({
|
|
2229
|
+
text: responseContent.text,
|
|
2230
|
+
actions: ["SETTING_UPDATE_FAILED"],
|
|
2231
|
+
source: "discord"
|
|
2232
|
+
});
|
|
2603
2233
|
} catch (error) {
|
|
2604
2234
|
logger6.error(`Error generating failure response: ${error}`);
|
|
2605
|
-
|
|
2606
|
-
|
|
2607
|
-
|
|
2608
|
-
|
|
2609
|
-
|
|
2610
|
-
text: "I couldn't understand your settings update. Please try again with a clearer format.",
|
|
2611
|
-
actions: ["SETTING_UPDATE_FAILED"],
|
|
2612
|
-
source: "discord"
|
|
2613
|
-
},
|
|
2614
|
-
roomId: state.roomId || "",
|
|
2615
|
-
createdAt: Date.now()
|
|
2616
|
-
};
|
|
2617
|
-
responses?.push(errorMessage);
|
|
2235
|
+
await callback({
|
|
2236
|
+
text: "I couldn't understand your settings update. Please try again with a clearer format.",
|
|
2237
|
+
actions: ["SETTING_UPDATE_FAILED"],
|
|
2238
|
+
source: "discord"
|
|
2239
|
+
});
|
|
2618
2240
|
}
|
|
2619
2241
|
}
|
|
2620
|
-
async function generateErrorResponse(runtime, state, callback
|
|
2242
|
+
async function generateErrorResponse(runtime, state, callback) {
|
|
2621
2243
|
try {
|
|
2622
2244
|
const prompt = composePromptFromState5({
|
|
2623
2245
|
state,
|
|
@@ -2627,34 +2249,18 @@ async function generateErrorResponse(runtime, state, callback, responses) {
|
|
|
2627
2249
|
prompt
|
|
2628
2250
|
});
|
|
2629
2251
|
const responseContent = parseJSONObjectFromText3(response);
|
|
2630
|
-
|
|
2631
|
-
|
|
2632
|
-
|
|
2633
|
-
|
|
2634
|
-
|
|
2635
|
-
text: responseContent.text,
|
|
2636
|
-
actions: ["SETTING_UPDATE_ERROR"],
|
|
2637
|
-
source: "discord"
|
|
2638
|
-
},
|
|
2639
|
-
roomId: state.roomId || "",
|
|
2640
|
-
createdAt: Date.now()
|
|
2641
|
-
};
|
|
2642
|
-
responses?.push(errorMessage);
|
|
2252
|
+
await callback({
|
|
2253
|
+
text: responseContent.text,
|
|
2254
|
+
actions: ["SETTING_UPDATE_ERROR"],
|
|
2255
|
+
source: "discord"
|
|
2256
|
+
});
|
|
2643
2257
|
} catch (error) {
|
|
2644
2258
|
logger6.error(`Error generating error response: ${error}`);
|
|
2645
|
-
|
|
2646
|
-
|
|
2647
|
-
|
|
2648
|
-
|
|
2649
|
-
|
|
2650
|
-
text: "I'm sorry, but I encountered an error while processing your request. Please try again or contact support if the issue persists.",
|
|
2651
|
-
actions: ["SETTING_UPDATE_ERROR"],
|
|
2652
|
-
source: "discord"
|
|
2653
|
-
},
|
|
2654
|
-
roomId: state.roomId || "",
|
|
2655
|
-
createdAt: Date.now()
|
|
2656
|
-
};
|
|
2657
|
-
responses?.push(defaultErrorMessage);
|
|
2259
|
+
await callback({
|
|
2260
|
+
text: "I'm sorry, but I encountered an error while processing your request. Please try again or contact support if the issue persists.",
|
|
2261
|
+
actions: ["SETTING_UPDATE_ERROR"],
|
|
2262
|
+
source: "discord"
|
|
2263
|
+
});
|
|
2658
2264
|
}
|
|
2659
2265
|
}
|
|
2660
2266
|
var updateSettingsAction = {
|
|
@@ -2685,7 +2291,7 @@ var updateSettingsAction = {
|
|
|
2685
2291
|
return false;
|
|
2686
2292
|
}
|
|
2687
2293
|
},
|
|
2688
|
-
handler: async (runtime, message, state, _options, callback
|
|
2294
|
+
handler: async (runtime, message, state, _options, callback) => {
|
|
2689
2295
|
try {
|
|
2690
2296
|
if (!state) {
|
|
2691
2297
|
logger6.error("State is required for settings handler");
|
|
@@ -2704,7 +2310,7 @@ var updateSettingsAction = {
|
|
|
2704
2310
|
const serverOwnership = worlds?.find((world) => world.metadata?.settings);
|
|
2705
2311
|
if (!serverOwnership) {
|
|
2706
2312
|
logger6.error(`No server found for user ${message.entityId} in handler`);
|
|
2707
|
-
await generateErrorResponse(runtime, state, callback
|
|
2313
|
+
await generateErrorResponse(runtime, state, callback);
|
|
2708
2314
|
return;
|
|
2709
2315
|
}
|
|
2710
2316
|
const serverId = serverOwnership?.serverId;
|
|
@@ -2716,7 +2322,7 @@ var updateSettingsAction = {
|
|
|
2716
2322
|
const worldSettings = await getWorldSettings(runtime, serverId);
|
|
2717
2323
|
if (!worldSettings) {
|
|
2718
2324
|
logger6.error(`No settings state found for server ${serverId} in handler`);
|
|
2719
|
-
await generateErrorResponse(runtime, state, callback
|
|
2325
|
+
await generateErrorResponse(runtime, state, callback);
|
|
2720
2326
|
return;
|
|
2721
2327
|
}
|
|
2722
2328
|
logger6.info(`Extracting settings from message: ${message.content.text}`);
|
|
@@ -2733,7 +2339,7 @@ var updateSettingsAction = {
|
|
|
2733
2339
|
const updatedWorldSettings = await getWorldSettings(runtime, serverId);
|
|
2734
2340
|
if (!updatedWorldSettings) {
|
|
2735
2341
|
logger6.error("Failed to retrieve updated settings state");
|
|
2736
|
-
await generateErrorResponse(runtime, state, callback
|
|
2342
|
+
await generateErrorResponse(runtime, state, callback);
|
|
2737
2343
|
return;
|
|
2738
2344
|
}
|
|
2739
2345
|
await generateSuccessResponse(
|
|
@@ -2741,17 +2347,16 @@ var updateSettingsAction = {
|
|
|
2741
2347
|
updatedWorldSettings,
|
|
2742
2348
|
state,
|
|
2743
2349
|
updateResults.messages,
|
|
2744
|
-
callback
|
|
2745
|
-
responses
|
|
2350
|
+
callback
|
|
2746
2351
|
);
|
|
2747
2352
|
} else {
|
|
2748
2353
|
logger6.info("No settings were updated");
|
|
2749
|
-
await generateFailureResponse(runtime, worldSettings, state, callback
|
|
2354
|
+
await generateFailureResponse(runtime, worldSettings, state, callback);
|
|
2750
2355
|
}
|
|
2751
2356
|
} catch (error) {
|
|
2752
2357
|
logger6.error(`Error in settings handler: ${error}`);
|
|
2753
2358
|
if (state && callback) {
|
|
2754
|
-
await generateErrorResponse(runtime, state, callback
|
|
2359
|
+
await generateErrorResponse(runtime, state, callback);
|
|
2755
2360
|
}
|
|
2756
2361
|
}
|
|
2757
2362
|
},
|
|
@@ -2934,8 +2539,7 @@ import {
|
|
|
2934
2539
|
booleanFooter as booleanFooter3,
|
|
2935
2540
|
composePromptFromState as composePromptFromState6,
|
|
2936
2541
|
ModelType as ModelType8,
|
|
2937
|
-
parseBooleanFromText
|
|
2938
|
-
asUUID as asUUID10
|
|
2542
|
+
parseBooleanFromText
|
|
2939
2543
|
} from "@elizaos/core";
|
|
2940
2544
|
var shouldUnfollowTemplate = `# Task: Decide if {{agentName}} should stop closely following this previously followed room and only respond when mentioned.
|
|
2941
2545
|
|
|
@@ -2958,7 +2562,7 @@ var unfollowRoomAction = {
|
|
|
2958
2562
|
const roomState = await runtime.getParticipantUserState(roomId, runtime.agentId);
|
|
2959
2563
|
return roomState === "FOLLOWED";
|
|
2960
2564
|
},
|
|
2961
|
-
handler: async (runtime, message, state, _options, _callback,
|
|
2565
|
+
handler: async (runtime, message, state, _options, _callback, _responses) => {
|
|
2962
2566
|
async function _shouldUnfollow(state2) {
|
|
2963
2567
|
const shouldUnfollowPrompt = composePromptFromState6({
|
|
2964
2568
|
state: state2,
|
|
@@ -2986,20 +2590,6 @@ var unfollowRoomAction = {
|
|
|
2986
2590
|
},
|
|
2987
2591
|
"messages"
|
|
2988
2592
|
);
|
|
2989
|
-
const unfollowMessage = {
|
|
2990
|
-
id: asUUID10(v4_default()),
|
|
2991
|
-
entityId: runtime.agentId,
|
|
2992
|
-
agentId: runtime.agentId,
|
|
2993
|
-
content: {
|
|
2994
|
-
text: "",
|
|
2995
|
-
// Empty text since this is just an action
|
|
2996
|
-
thought: `I unfollowed the room ${room.name}`,
|
|
2997
|
-
source: message.content.source
|
|
2998
|
-
},
|
|
2999
|
-
roomId: message.roomId,
|
|
3000
|
-
createdAt: Date.now()
|
|
3001
|
-
};
|
|
3002
|
-
responses?.push(unfollowMessage);
|
|
3003
2593
|
} else {
|
|
3004
2594
|
await runtime.createMemory(
|
|
3005
2595
|
{
|
|
@@ -3237,7 +2827,7 @@ var unfollowRoomAction = {
|
|
|
3237
2827
|
{
|
|
3238
2828
|
name: "{{name1}}",
|
|
3239
2829
|
content: {
|
|
3240
|
-
text: "{{name2}} stahp
|
|
2830
|
+
text: "{{name2}} stahp following dis room plz"
|
|
3241
2831
|
}
|
|
3242
2832
|
},
|
|
3243
2833
|
{
|
|
@@ -3271,8 +2861,7 @@ import {
|
|
|
3271
2861
|
booleanFooter as booleanFooter4,
|
|
3272
2862
|
composePromptFromState as composePromptFromState7,
|
|
3273
2863
|
logger as logger7,
|
|
3274
|
-
ModelType as ModelType9
|
|
3275
|
-
asUUID as asUUID11
|
|
2864
|
+
ModelType as ModelType9
|
|
3276
2865
|
} from "@elizaos/core";
|
|
3277
2866
|
var shouldUnmuteTemplate = `# Task: Decide if {{agentName}} should unmute this previously muted room and start considering it for responses again.
|
|
3278
2867
|
|
|
@@ -3295,7 +2884,7 @@ var unmuteRoomAction = {
|
|
|
3295
2884
|
const roomState = await runtime.getParticipantUserState(roomId, runtime.agentId);
|
|
3296
2885
|
return roomState === "MUTED";
|
|
3297
2886
|
},
|
|
3298
|
-
handler: async (runtime, message, state, _options, _callback,
|
|
2887
|
+
handler: async (runtime, message, state, _options, _callback, _responses) => {
|
|
3299
2888
|
async function _shouldUnmute(state2) {
|
|
3300
2889
|
const shouldUnmutePrompt = composePromptFromState7({
|
|
3301
2890
|
state: state2,
|
|
@@ -3369,20 +2958,6 @@ var unmuteRoomAction = {
|
|
|
3369
2958
|
},
|
|
3370
2959
|
"messages"
|
|
3371
2960
|
);
|
|
3372
|
-
const unmuteMessage = {
|
|
3373
|
-
id: asUUID11(v4_default()),
|
|
3374
|
-
entityId: runtime.agentId,
|
|
3375
|
-
agentId: runtime.agentId,
|
|
3376
|
-
content: {
|
|
3377
|
-
text: "",
|
|
3378
|
-
// Empty text since this is just an action
|
|
3379
|
-
thought: `I unmuted the room ${room.name}`,
|
|
3380
|
-
source: message.content.source
|
|
3381
|
-
},
|
|
3382
|
-
roomId: message.roomId,
|
|
3383
|
-
createdAt: Date.now()
|
|
3384
|
-
};
|
|
3385
|
-
responses?.push(unmuteMessage);
|
|
3386
2961
|
},
|
|
3387
2962
|
examples: [
|
|
3388
2963
|
[
|
|
@@ -3480,8 +3055,7 @@ import {
|
|
|
3480
3055
|
composePromptFromState as composePromptFromState8,
|
|
3481
3056
|
findEntityByName as findEntityByName2,
|
|
3482
3057
|
logger as logger8,
|
|
3483
|
-
ModelType as ModelType10
|
|
3484
|
-
asUUID as asUUID12
|
|
3058
|
+
ModelType as ModelType10
|
|
3485
3059
|
} from "@elizaos/core";
|
|
3486
3060
|
var componentTemplate = `# Task: Extract Source and Update Component Data
|
|
3487
3061
|
|
|
@@ -3564,6 +3138,7 @@ var updateEntityAction = {
|
|
|
3564
3138
|
throw new Error("Message is required for the updateEntity action");
|
|
3565
3139
|
}
|
|
3566
3140
|
for (const response of responses) {
|
|
3141
|
+
await callback(response.content);
|
|
3567
3142
|
}
|
|
3568
3143
|
const sourceEntityId = message.entityId;
|
|
3569
3144
|
const _roomId = message.roomId;
|
|
@@ -3572,19 +3147,11 @@ var updateEntityAction = {
|
|
|
3572
3147
|
const worldId = room.worldId;
|
|
3573
3148
|
const entity = await findEntityByName2(runtime, message, state);
|
|
3574
3149
|
if (!entity) {
|
|
3575
|
-
|
|
3576
|
-
|
|
3577
|
-
|
|
3578
|
-
|
|
3579
|
-
|
|
3580
|
-
text: "I'm not sure which entity you're trying to update. Could you please specify who you're talking about?",
|
|
3581
|
-
actions: ["UPDATE_ENTITY_ERROR"],
|
|
3582
|
-
source: message.content.source
|
|
3583
|
-
},
|
|
3584
|
-
roomId: message.roomId,
|
|
3585
|
-
createdAt: Date.now()
|
|
3586
|
-
};
|
|
3587
|
-
responses?.push(errorMessage);
|
|
3150
|
+
await callback({
|
|
3151
|
+
text: "I'm not sure which entity you're trying to update. Could you please specify who you're talking about?",
|
|
3152
|
+
actions: ["UPDATE_ENTITY_ERROR"],
|
|
3153
|
+
source: message.content.source
|
|
3154
|
+
});
|
|
3588
3155
|
return;
|
|
3589
3156
|
}
|
|
3590
3157
|
let existingComponent = null;
|
|
@@ -3608,19 +3175,11 @@ var updateEntityAction = {
|
|
|
3608
3175
|
}
|
|
3609
3176
|
} catch (error) {
|
|
3610
3177
|
logger8.error(`Failed to parse component data: ${error.message}`);
|
|
3611
|
-
|
|
3612
|
-
|
|
3613
|
-
|
|
3614
|
-
|
|
3615
|
-
|
|
3616
|
-
text: "I couldn't properly understand the component information. Please try again with more specific information.",
|
|
3617
|
-
actions: ["UPDATE_ENTITY_ERROR"],
|
|
3618
|
-
source: message.content.source
|
|
3619
|
-
},
|
|
3620
|
-
roomId: message.roomId,
|
|
3621
|
-
createdAt: Date.now()
|
|
3622
|
-
};
|
|
3623
|
-
responses?.push(errorMessage);
|
|
3178
|
+
await callback({
|
|
3179
|
+
text: "I couldn't properly understand the component information. Please try again with more specific information.",
|
|
3180
|
+
actions: ["UPDATE_ENTITY_ERROR"],
|
|
3181
|
+
source: message.content.source
|
|
3182
|
+
});
|
|
3624
3183
|
return;
|
|
3625
3184
|
}
|
|
3626
3185
|
const componentType = parsedResult.source.toLowerCase();
|
|
@@ -3643,19 +3202,11 @@ var updateEntityAction = {
|
|
|
3643
3202
|
sourceEntityId,
|
|
3644
3203
|
createdAt: existingComponent.createdAt
|
|
3645
3204
|
});
|
|
3646
|
-
|
|
3647
|
-
|
|
3648
|
-
|
|
3649
|
-
|
|
3650
|
-
|
|
3651
|
-
text: `I've updated the ${componentType} information for ${entity.names[0]}.`,
|
|
3652
|
-
actions: ["UPDATE_ENTITY"],
|
|
3653
|
-
source: message.content.source
|
|
3654
|
-
},
|
|
3655
|
-
roomId: message.roomId,
|
|
3656
|
-
createdAt: Date.now()
|
|
3657
|
-
};
|
|
3658
|
-
responses?.push(successMessage);
|
|
3205
|
+
await callback({
|
|
3206
|
+
text: `I've updated the ${componentType} information for ${entity.names[0]}.`,
|
|
3207
|
+
actions: ["UPDATE_ENTITY"],
|
|
3208
|
+
source: message.content.source
|
|
3209
|
+
});
|
|
3659
3210
|
} else {
|
|
3660
3211
|
await runtime.createComponent({
|
|
3661
3212
|
id: v4_default(),
|
|
@@ -3668,35 +3219,19 @@ var updateEntityAction = {
|
|
|
3668
3219
|
sourceEntityId,
|
|
3669
3220
|
createdAt: Date.now()
|
|
3670
3221
|
});
|
|
3671
|
-
|
|
3672
|
-
|
|
3673
|
-
|
|
3674
|
-
|
|
3675
|
-
|
|
3676
|
-
text: `I've added new ${componentType} information for ${entity.names[0]}.`,
|
|
3677
|
-
actions: ["UPDATE_ENTITY"],
|
|
3678
|
-
source: message.content.source
|
|
3679
|
-
},
|
|
3680
|
-
roomId: message.roomId,
|
|
3681
|
-
createdAt: Date.now()
|
|
3682
|
-
};
|
|
3683
|
-
responses?.push(successMessage);
|
|
3222
|
+
await callback({
|
|
3223
|
+
text: `I've added new ${componentType} information for ${entity.names[0]}.`,
|
|
3224
|
+
actions: ["UPDATE_ENTITY"],
|
|
3225
|
+
source: message.content.source
|
|
3226
|
+
});
|
|
3684
3227
|
}
|
|
3685
3228
|
} catch (error) {
|
|
3686
3229
|
logger8.error(`Error in updateEntity handler: ${error}`);
|
|
3687
|
-
|
|
3688
|
-
|
|
3689
|
-
|
|
3690
|
-
|
|
3691
|
-
|
|
3692
|
-
text: "There was an error processing the entity information.",
|
|
3693
|
-
actions: ["UPDATE_ENTITY_ERROR"],
|
|
3694
|
-
source: message.content.source
|
|
3695
|
-
},
|
|
3696
|
-
roomId: message.roomId,
|
|
3697
|
-
createdAt: Date.now()
|
|
3698
|
-
};
|
|
3699
|
-
responses?.push(errorMessage);
|
|
3230
|
+
await callback?.({
|
|
3231
|
+
text: "There was an error processing the entity information.",
|
|
3232
|
+
actions: ["UPDATE_ENTITY_ERROR"],
|
|
3233
|
+
source: message.content.source
|
|
3234
|
+
});
|
|
3700
3235
|
}
|
|
3701
3236
|
},
|
|
3702
3237
|
examples: [
|
|
@@ -4171,11 +3706,13 @@ var actionsProvider = {
|
|
|
4171
3706
|
const resolvedActions = await Promise.all(actionPromises);
|
|
4172
3707
|
const actionsData = resolvedActions.filter(Boolean);
|
|
4173
3708
|
const actionNames = `Possible response actions: ${formatActionNames(actionsData)}`;
|
|
4174
|
-
const
|
|
4175
|
-
|
|
4176
|
-
|
|
4177
|
-
|
|
3709
|
+
const actionsWithDescriptions = actionsData.length > 0 ? addHeader(
|
|
3710
|
+
"# Available Actions",
|
|
3711
|
+
actionsData.map(
|
|
3712
|
+
(action) => `- **${action.name}**: ${action.description || "No description available"}`
|
|
3713
|
+
).join("\n")
|
|
4178
3714
|
) : "";
|
|
3715
|
+
const actions = actionsData.length > 0 ? addHeader("# Available Actions", formatActions(actionsData)) : "";
|
|
4179
3716
|
const actionExamples = actionsData.length > 0 ? addHeader("# Action Examples", composeActionExamples(actionsData, 10)) : "";
|
|
4180
3717
|
const data = {
|
|
4181
3718
|
actionsData
|
|
@@ -4183,10 +3720,10 @@ var actionsProvider = {
|
|
|
4183
3720
|
const values = {
|
|
4184
3721
|
actions,
|
|
4185
3722
|
actionNames,
|
|
4186
|
-
|
|
4187
|
-
|
|
3723
|
+
actionExamples,
|
|
3724
|
+
actionsWithDescriptions
|
|
4188
3725
|
};
|
|
4189
|
-
const text = [actionNames,
|
|
3726
|
+
const text = [actionNames, actionsWithDescriptions, actionExamples, actions].filter(Boolean).join("\n\n");
|
|
4190
3727
|
return {
|
|
4191
3728
|
data,
|
|
4192
3729
|
values,
|
|
@@ -5984,7 +5521,7 @@ var messageReceivedHandler = async ({
|
|
|
5984
5521
|
throw new Error("Agent responses map not found");
|
|
5985
5522
|
}
|
|
5986
5523
|
agentResponses.set(message.roomId, responseId);
|
|
5987
|
-
const runId =
|
|
5524
|
+
const runId = runtime.startRun();
|
|
5988
5525
|
const startTime = Date.now();
|
|
5989
5526
|
await runtime.emitEvent(EventType.RUN_STARTED, {
|
|
5990
5527
|
runtime,
|
|
@@ -6136,16 +5673,15 @@ ${response}`
|
|
|
6136
5673
|
responseContent.inReplyTo = createUniqueUuid3(runtime, message.id);
|
|
6137
5674
|
const isSimple = responseContent.actions?.length === 1 && responseContent.actions[0].toUpperCase() === "REPLY" && (!responseContent.providers || responseContent.providers.length === 0);
|
|
6138
5675
|
responseContent.simple = isSimple;
|
|
6139
|
-
const
|
|
6140
|
-
id:
|
|
5676
|
+
const responseMessage = {
|
|
5677
|
+
id: asUUID(v4_default()),
|
|
6141
5678
|
entityId: runtime.agentId,
|
|
6142
5679
|
agentId: runtime.agentId,
|
|
6143
5680
|
content: responseContent,
|
|
6144
5681
|
roomId: message.roomId,
|
|
6145
|
-
isPlan: true,
|
|
6146
5682
|
createdAt: Date.now()
|
|
6147
5683
|
};
|
|
6148
|
-
responseMessages = [
|
|
5684
|
+
responseMessages = [responseMessage];
|
|
6149
5685
|
}
|
|
6150
5686
|
agentResponses.delete(message.roomId);
|
|
6151
5687
|
if (agentResponses.size === 0) {
|
|
@@ -6160,41 +5696,9 @@ ${response}`
|
|
|
6160
5696
|
}
|
|
6161
5697
|
await callback(responseContent);
|
|
6162
5698
|
} else {
|
|
6163
|
-
await runtime.processActions(
|
|
6164
|
-
message,
|
|
6165
|
-
responseMessages,
|
|
6166
|
-
state,
|
|
6167
|
-
async (memory) => {
|
|
6168
|
-
return [];
|
|
6169
|
-
}
|
|
6170
|
-
);
|
|
6171
|
-
if (responseMessages.length) {
|
|
6172
|
-
for (const responseMessage of responseMessages) {
|
|
6173
|
-
if (responseMessage.content.providers && responseMessage.content.providers.length > 0) {
|
|
6174
|
-
logger18.debug(
|
|
6175
|
-
"[Bootstrap] Complex response used providers",
|
|
6176
|
-
responseMessage.content.providers
|
|
6177
|
-
);
|
|
6178
|
-
}
|
|
6179
|
-
}
|
|
6180
|
-
for (const memory of responseMessages) {
|
|
6181
|
-
if ("isPlan" in memory && memory.isPlan) {
|
|
6182
|
-
logger18.debug("[Bootstrap] Skipping agent plan in callback - internal use only");
|
|
6183
|
-
continue;
|
|
6184
|
-
}
|
|
6185
|
-
await callback(memory.content);
|
|
6186
|
-
}
|
|
6187
|
-
}
|
|
5699
|
+
await runtime.processActions(message, responseMessages, state, callback);
|
|
6188
5700
|
}
|
|
6189
|
-
await runtime.evaluate(
|
|
6190
|
-
message,
|
|
6191
|
-
state,
|
|
6192
|
-
shouldRespond,
|
|
6193
|
-
async (memory) => {
|
|
6194
|
-
return [];
|
|
6195
|
-
},
|
|
6196
|
-
responseMessages
|
|
6197
|
-
);
|
|
5701
|
+
await runtime.evaluate(message, state, shouldRespond, callback, responseMessages);
|
|
6198
5702
|
} else {
|
|
6199
5703
|
logger18.debug("[Bootstrap] Agent decided not to respond (shouldRespond is false).");
|
|
6200
5704
|
const currentResponseId = agentResponses.get(message.roomId);
|
|
@@ -6218,7 +5722,7 @@ ${response}`
|
|
|
6218
5722
|
};
|
|
6219
5723
|
await callback(ignoreContent);
|
|
6220
5724
|
const ignoreMemory = {
|
|
6221
|
-
id:
|
|
5725
|
+
id: asUUID(v4_default()),
|
|
6222
5726
|
entityId: runtime.agentId,
|
|
6223
5727
|
agentId: runtime.agentId,
|
|
6224
5728
|
content: ignoreContent,
|