@elizaos/plugin-bootstrap 1.0.0-beta.49 → 1.0.0-beta.50
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 +526 -463
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -76,7 +76,7 @@ import {
|
|
|
76
76
|
composePromptFromState as composePromptFromState9,
|
|
77
77
|
createUniqueUuid as createUniqueUuid4,
|
|
78
78
|
EventType as EventType2,
|
|
79
|
-
logger as
|
|
79
|
+
logger as logger19,
|
|
80
80
|
messageHandlerTemplate,
|
|
81
81
|
ModelType as ModelType13,
|
|
82
82
|
postCreationTemplate,
|
|
@@ -190,61 +190,69 @@ var choiceAction = {
|
|
|
190
190
|
return pendingTasks && pendingTasks.length > 0 && pendingTasks.some((task) => task.metadata?.options);
|
|
191
191
|
},
|
|
192
192
|
handler: async (runtime, message, state, _options, callback, responses) => {
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
const
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
return `Task ID: ${task.taskId} - ${task.name}
|
|
193
|
+
const pendingTasks = await runtime.getTasks({
|
|
194
|
+
roomId: message.roomId,
|
|
195
|
+
tags: ["AWAITING_CHOICE"]
|
|
196
|
+
});
|
|
197
|
+
if (!pendingTasks?.length) {
|
|
198
|
+
throw new Error("No pending tasks with options found");
|
|
199
|
+
}
|
|
200
|
+
const tasksWithOptions = pendingTasks.filter((task) => task.metadata?.options);
|
|
201
|
+
if (!tasksWithOptions.length) {
|
|
202
|
+
throw new Error("No tasks currently have options to select from.");
|
|
203
|
+
}
|
|
204
|
+
const formattedTasks = tasksWithOptions.map((task) => {
|
|
205
|
+
const shortId = task.id?.substring(0, 8);
|
|
206
|
+
return {
|
|
207
|
+
taskId: shortId,
|
|
208
|
+
fullId: task.id,
|
|
209
|
+
name: task.name,
|
|
210
|
+
options: task.metadata?.options?.map((opt) => ({
|
|
211
|
+
name: typeof opt === "string" ? opt : opt.name,
|
|
212
|
+
description: typeof opt === "string" ? opt : opt.description || opt.name
|
|
213
|
+
}))
|
|
214
|
+
};
|
|
215
|
+
});
|
|
216
|
+
const tasksString = formattedTasks.map((task) => {
|
|
217
|
+
return `Task ID: ${task.taskId} - ${task.name}
|
|
219
218
|
Available options:
|
|
220
219
|
${task.options?.map((opt) => `- ${opt.name}: ${opt.description}`).join("\n")}`;
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
220
|
+
}).join("\n");
|
|
221
|
+
const prompt = composePrompt({
|
|
222
|
+
state: {
|
|
223
|
+
tasks: tasksString,
|
|
224
|
+
recentMessages: message.content.text || ""
|
|
225
|
+
},
|
|
226
|
+
template: optionExtractionTemplate
|
|
227
|
+
});
|
|
228
|
+
const result = await runtime.useModel(ModelType.TEXT_SMALL, {
|
|
229
|
+
prompt,
|
|
230
|
+
stopSequences: []
|
|
231
|
+
});
|
|
232
|
+
const parsed = parseJSONObjectFromText(result);
|
|
233
|
+
const { taskId, selectedOption } = parsed;
|
|
234
|
+
if (taskId && selectedOption) {
|
|
235
|
+
const taskMap = new Map(formattedTasks.map((task) => [task.taskId, task]));
|
|
236
|
+
const taskInfo = taskMap.get(taskId);
|
|
237
|
+
if (!taskInfo) {
|
|
238
|
+
await callback?.({
|
|
239
|
+
text: `Could not find a task matching ID: ${taskId}. Please try again.`,
|
|
240
|
+
actions: ["SELECT_OPTION_ERROR"],
|
|
241
|
+
source: message.content.source
|
|
242
|
+
});
|
|
243
|
+
return;
|
|
244
|
+
}
|
|
245
|
+
const selectedTask = tasksWithOptions.find((task) => task.id === taskInfo.fullId);
|
|
246
|
+
if (!selectedTask) {
|
|
247
|
+
await callback?.({
|
|
248
|
+
text: "Error locating the selected task. Please try again.",
|
|
249
|
+
actions: ["SELECT_OPTION_ERROR"],
|
|
250
|
+
source: message.content.source
|
|
251
|
+
});
|
|
252
|
+
return;
|
|
253
|
+
}
|
|
254
|
+
if (selectedOption === "ABORT") {
|
|
255
|
+
if (!selectedTask?.id) {
|
|
248
256
|
await callback?.({
|
|
249
257
|
text: "Error locating the selected task. Please try again.",
|
|
250
258
|
actions: ["SELECT_OPTION_ERROR"],
|
|
@@ -252,67 +260,50 @@ ${task.options?.map((opt) => `- ${opt.name}: ${opt.description}`).join("\n")}`;
|
|
|
252
260
|
});
|
|
253
261
|
return;
|
|
254
262
|
}
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
return;
|
|
281
|
-
} catch (error) {
|
|
282
|
-
logger.error("Error executing task with option:", error);
|
|
283
|
-
await callback?.({
|
|
284
|
-
text: "There was an error processing your selection.",
|
|
285
|
-
actions: ["SELECT_OPTION_ERROR"],
|
|
286
|
-
source: message.content.source
|
|
287
|
-
});
|
|
288
|
-
return;
|
|
289
|
-
}
|
|
263
|
+
await runtime.deleteTask(selectedTask.id);
|
|
264
|
+
await callback?.({
|
|
265
|
+
text: `Task "${selectedTask.name}" has been cancelled.`,
|
|
266
|
+
actions: ["CHOOSE_OPTION_CANCELLED"],
|
|
267
|
+
source: message.content.source
|
|
268
|
+
});
|
|
269
|
+
return;
|
|
270
|
+
}
|
|
271
|
+
try {
|
|
272
|
+
const taskWorker = runtime.getTaskWorker(selectedTask.name);
|
|
273
|
+
await taskWorker?.execute(runtime, { option: selectedOption }, selectedTask);
|
|
274
|
+
await callback?.({
|
|
275
|
+
text: `Selected option: ${selectedOption} for task: ${selectedTask.name}`,
|
|
276
|
+
actions: ["CHOOSE_OPTION"],
|
|
277
|
+
source: message.content.source
|
|
278
|
+
});
|
|
279
|
+
return;
|
|
280
|
+
} catch (error) {
|
|
281
|
+
logger.error("Error executing task with option:", error);
|
|
282
|
+
await callback?.({
|
|
283
|
+
text: "There was an error processing your selection.",
|
|
284
|
+
actions: ["SELECT_OPTION_ERROR"],
|
|
285
|
+
source: message.content.source
|
|
286
|
+
});
|
|
287
|
+
return;
|
|
290
288
|
}
|
|
291
|
-
let optionsText = "Please select a valid option from one of these tasks:\n\n";
|
|
292
|
-
tasksWithOptions.forEach((task) => {
|
|
293
|
-
const shortId = task.id?.substring(0, 8);
|
|
294
|
-
optionsText += `**${task.name}** (ID: ${shortId}):
|
|
295
|
-
`;
|
|
296
|
-
const options = task.metadata?.options?.map(
|
|
297
|
-
(opt) => typeof opt === "string" ? opt : opt.name
|
|
298
|
-
);
|
|
299
|
-
options?.push("ABORT");
|
|
300
|
-
optionsText += options?.map((opt) => `- ${opt}`).join("\n");
|
|
301
|
-
optionsText += "\n\n";
|
|
302
|
-
});
|
|
303
|
-
await callback?.({
|
|
304
|
-
text: optionsText,
|
|
305
|
-
actions: ["SELECT_OPTION_INVALID"],
|
|
306
|
-
source: message.content.source
|
|
307
|
-
});
|
|
308
|
-
} catch (error) {
|
|
309
|
-
logger.error("Error in select option handler:", error);
|
|
310
|
-
await callback?.({
|
|
311
|
-
text: "There was an error processing the option selection.",
|
|
312
|
-
actions: ["SELECT_OPTION_ERROR"],
|
|
313
|
-
source: message.content.source
|
|
314
|
-
});
|
|
315
289
|
}
|
|
290
|
+
let optionsText = "Please select a valid option from one of these tasks:\n\n";
|
|
291
|
+
tasksWithOptions.forEach((task) => {
|
|
292
|
+
const shortId = task.id?.substring(0, 8);
|
|
293
|
+
optionsText += `**${task.name}** (ID: ${shortId}):
|
|
294
|
+
`;
|
|
295
|
+
const options = task.metadata?.options?.map(
|
|
296
|
+
(opt) => typeof opt === "string" ? opt : opt.name
|
|
297
|
+
);
|
|
298
|
+
options?.push("ABORT");
|
|
299
|
+
optionsText += options?.map((opt) => `- ${opt}`).join("\n");
|
|
300
|
+
optionsText += "\n\n";
|
|
301
|
+
});
|
|
302
|
+
await callback?.({
|
|
303
|
+
text: optionsText,
|
|
304
|
+
actions: ["SELECT_OPTION_INVALID"],
|
|
305
|
+
source: message.content.source
|
|
306
|
+
});
|
|
316
307
|
},
|
|
317
308
|
examples: [
|
|
318
309
|
[
|
|
@@ -4247,6 +4238,7 @@ var evaluatorsProvider = {
|
|
|
4247
4238
|
|
|
4248
4239
|
// src/providers/facts.ts
|
|
4249
4240
|
import { ModelType as ModelType12 } from "@elizaos/core";
|
|
4241
|
+
import { logger as logger12 } from "@elizaos/core";
|
|
4250
4242
|
function formatFacts2(facts) {
|
|
4251
4243
|
return facts.reverse().map((fact) => fact.content.text).join("\n");
|
|
4252
4244
|
}
|
|
@@ -4255,59 +4247,72 @@ var factsProvider = {
|
|
|
4255
4247
|
description: "Key facts that the agent knows",
|
|
4256
4248
|
dynamic: true,
|
|
4257
4249
|
get: async (runtime, message, _state) => {
|
|
4258
|
-
|
|
4259
|
-
|
|
4260
|
-
|
|
4261
|
-
count: 10,
|
|
4262
|
-
unique: false
|
|
4263
|
-
});
|
|
4264
|
-
const last5Messages = recentMessages.slice(-5).map((message2) => message2.content.text).join("\n");
|
|
4265
|
-
const embedding = await runtime.useModel(ModelType12.TEXT_EMBEDDING, {
|
|
4266
|
-
text: last5Messages
|
|
4267
|
-
});
|
|
4268
|
-
const [relevantFacts, recentFactsData] = await Promise.all([
|
|
4269
|
-
runtime.searchMemories({
|
|
4270
|
-
tableName: "facts",
|
|
4271
|
-
embedding,
|
|
4272
|
-
roomId: message.roomId,
|
|
4273
|
-
worldId: message.worldId,
|
|
4274
|
-
count: 6,
|
|
4275
|
-
query: message.content.text
|
|
4276
|
-
}),
|
|
4277
|
-
runtime.searchMemories({
|
|
4278
|
-
embedding,
|
|
4279
|
-
query: message.content.text,
|
|
4280
|
-
tableName: "facts",
|
|
4250
|
+
try {
|
|
4251
|
+
const recentMessages = await runtime.getMemories({
|
|
4252
|
+
tableName: "messages",
|
|
4281
4253
|
roomId: message.roomId,
|
|
4282
|
-
|
|
4283
|
-
|
|
4284
|
-
})
|
|
4285
|
-
|
|
4286
|
-
|
|
4287
|
-
|
|
4288
|
-
|
|
4289
|
-
|
|
4254
|
+
count: 10,
|
|
4255
|
+
unique: false
|
|
4256
|
+
});
|
|
4257
|
+
const last5Messages = recentMessages.slice(-5).map((message2) => message2.content.text).join("\n");
|
|
4258
|
+
const embedding = await runtime.useModel(ModelType12.TEXT_EMBEDDING, {
|
|
4259
|
+
text: last5Messages
|
|
4260
|
+
});
|
|
4261
|
+
const [relevantFacts, recentFactsData] = await Promise.all([
|
|
4262
|
+
runtime.searchMemories({
|
|
4263
|
+
tableName: "facts",
|
|
4264
|
+
embedding,
|
|
4265
|
+
roomId: message.roomId,
|
|
4266
|
+
worldId: message.worldId,
|
|
4267
|
+
count: 6,
|
|
4268
|
+
query: message.content.text
|
|
4269
|
+
}),
|
|
4270
|
+
runtime.searchMemories({
|
|
4271
|
+
embedding,
|
|
4272
|
+
query: message.content.text,
|
|
4273
|
+
tableName: "facts",
|
|
4274
|
+
roomId: message.roomId,
|
|
4275
|
+
entityId: message.entityId,
|
|
4276
|
+
count: 6
|
|
4277
|
+
})
|
|
4278
|
+
]);
|
|
4279
|
+
const allFacts = [...relevantFacts, ...recentFactsData].filter(
|
|
4280
|
+
(fact, index, self) => index === self.findIndex((t) => t.id === fact.id)
|
|
4281
|
+
);
|
|
4282
|
+
if (allFacts.length === 0) {
|
|
4283
|
+
return {
|
|
4284
|
+
values: {
|
|
4285
|
+
facts: ""
|
|
4286
|
+
},
|
|
4287
|
+
data: {
|
|
4288
|
+
facts: allFacts
|
|
4289
|
+
},
|
|
4290
|
+
text: "No facts available."
|
|
4291
|
+
};
|
|
4292
|
+
}
|
|
4293
|
+
const formattedFacts = formatFacts2(allFacts);
|
|
4294
|
+
const text = "Key facts that {{agentName}} knows:\n{{formattedFacts}}".replace("{{agentName}}", runtime.character.name).replace("{{formattedFacts}}", formattedFacts);
|
|
4290
4295
|
return {
|
|
4291
4296
|
values: {
|
|
4292
|
-
facts:
|
|
4297
|
+
facts: formattedFacts
|
|
4293
4298
|
},
|
|
4294
4299
|
data: {
|
|
4295
4300
|
facts: allFacts
|
|
4296
4301
|
},
|
|
4297
|
-
text
|
|
4302
|
+
text
|
|
4303
|
+
};
|
|
4304
|
+
} catch (error) {
|
|
4305
|
+
logger12.error("Error in factsProvider:", error);
|
|
4306
|
+
return {
|
|
4307
|
+
values: {
|
|
4308
|
+
facts: ""
|
|
4309
|
+
},
|
|
4310
|
+
data: {
|
|
4311
|
+
facts: []
|
|
4312
|
+
},
|
|
4313
|
+
text: "Error retrieving facts."
|
|
4298
4314
|
};
|
|
4299
4315
|
}
|
|
4300
|
-
const formattedFacts = formatFacts2(allFacts);
|
|
4301
|
-
const text = "Key facts that {{agentName}} knows:\n{{formattedFacts}}".replace("{{agentName}}", runtime.character.name).replace("{{formattedFacts}}", formattedFacts);
|
|
4302
|
-
return {
|
|
4303
|
-
values: {
|
|
4304
|
-
facts: formattedFacts
|
|
4305
|
-
},
|
|
4306
|
-
data: {
|
|
4307
|
-
facts: allFacts
|
|
4308
|
-
},
|
|
4309
|
-
text
|
|
4310
|
-
};
|
|
4311
4316
|
}
|
|
4312
4317
|
};
|
|
4313
4318
|
|
|
@@ -4377,7 +4382,8 @@ import {
|
|
|
4377
4382
|
ChannelType as ChannelType5,
|
|
4378
4383
|
formatMessages,
|
|
4379
4384
|
formatPosts,
|
|
4380
|
-
getEntityDetails as getEntityDetails3
|
|
4385
|
+
getEntityDetails as getEntityDetails3,
|
|
4386
|
+
logger as logger13
|
|
4381
4387
|
} from "@elizaos/core";
|
|
4382
4388
|
var getRecentInteractions = async (runtime, sourceEntityId, targetEntityId, excludeRoomId) => {
|
|
4383
4389
|
const rooms = await runtime.getRoomsForParticipants([sourceEntityId, targetEntityId]);
|
|
@@ -4393,120 +4399,158 @@ var recentMessagesProvider = {
|
|
|
4393
4399
|
description: "Recent messages, interactions and other memories",
|
|
4394
4400
|
position: 100,
|
|
4395
4401
|
get: async (runtime, message) => {
|
|
4396
|
-
|
|
4397
|
-
|
|
4398
|
-
|
|
4399
|
-
|
|
4400
|
-
|
|
4401
|
-
|
|
4402
|
-
|
|
4403
|
-
|
|
4404
|
-
|
|
4405
|
-
|
|
4406
|
-
|
|
4407
|
-
|
|
4408
|
-
|
|
4409
|
-
|
|
4410
|
-
|
|
4411
|
-
|
|
4412
|
-
|
|
4413
|
-
|
|
4414
|
-
|
|
4415
|
-
|
|
4416
|
-
|
|
4417
|
-
|
|
4418
|
-
|
|
4419
|
-
|
|
4420
|
-
|
|
4421
|
-
|
|
4422
|
-
|
|
4423
|
-
|
|
4424
|
-
|
|
4425
|
-
|
|
4426
|
-
|
|
4427
|
-
|
|
4428
|
-
|
|
4429
|
-
|
|
4430
|
-
|
|
4431
|
-
|
|
4432
|
-
|
|
4433
|
-
|
|
4434
|
-
|
|
4435
|
-
|
|
4436
|
-
|
|
4437
|
-
|
|
4438
|
-
|
|
4439
|
-
|
|
4440
|
-
|
|
4441
|
-
const
|
|
4442
|
-
const
|
|
4443
|
-
|
|
4444
|
-
|
|
4445
|
-
|
|
4446
|
-
|
|
4447
|
-
}
|
|
4448
|
-
|
|
4449
|
-
const
|
|
4450
|
-
if (
|
|
4451
|
-
const
|
|
4452
|
-
|
|
4453
|
-
|
|
4454
|
-
|
|
4455
|
-
|
|
4456
|
-
|
|
4402
|
+
try {
|
|
4403
|
+
const { roomId } = message;
|
|
4404
|
+
const conversationLength = runtime.getConversationLength();
|
|
4405
|
+
const [entitiesData, room, recentMessagesData, recentInteractionsData] = await Promise.all([
|
|
4406
|
+
getEntityDetails3({ runtime, roomId }),
|
|
4407
|
+
runtime.getRoom(roomId),
|
|
4408
|
+
runtime.getMemories({
|
|
4409
|
+
tableName: "messages",
|
|
4410
|
+
roomId,
|
|
4411
|
+
count: conversationLength,
|
|
4412
|
+
unique: false
|
|
4413
|
+
}),
|
|
4414
|
+
message.entityId !== runtime.agentId ? getRecentInteractions(runtime, message.entityId, runtime.agentId, roomId) : Promise.resolve([])
|
|
4415
|
+
]);
|
|
4416
|
+
const isPostFormat = room?.type ? room.type === ChannelType5.FEED || room.type === ChannelType5.THREAD : false;
|
|
4417
|
+
const [formattedRecentMessages, formattedRecentPosts] = await Promise.all([
|
|
4418
|
+
formatMessages({
|
|
4419
|
+
messages: recentMessagesData,
|
|
4420
|
+
entities: entitiesData
|
|
4421
|
+
}),
|
|
4422
|
+
formatPosts({
|
|
4423
|
+
messages: recentMessagesData,
|
|
4424
|
+
entities: entitiesData,
|
|
4425
|
+
conversationHeader: false
|
|
4426
|
+
})
|
|
4427
|
+
]);
|
|
4428
|
+
const recentPosts = formattedRecentPosts && formattedRecentPosts.length > 0 ? addHeader9("# Posts in Thread", formattedRecentPosts) : "";
|
|
4429
|
+
const recentMessages = formattedRecentMessages && formattedRecentMessages.length > 0 ? addHeader9("# Conversation Messages", formattedRecentMessages) : "";
|
|
4430
|
+
if (!recentPosts && !recentMessages && recentMessagesData.length === 0 && !message.content.text) {
|
|
4431
|
+
return {
|
|
4432
|
+
data: {
|
|
4433
|
+
recentMessages: [],
|
|
4434
|
+
recentInteractions: []
|
|
4435
|
+
},
|
|
4436
|
+
values: {
|
|
4437
|
+
recentPosts: "",
|
|
4438
|
+
recentMessages: "",
|
|
4439
|
+
recentMessageInteractions: "",
|
|
4440
|
+
recentPostInteractions: "",
|
|
4441
|
+
recentInteractions: ""
|
|
4442
|
+
},
|
|
4443
|
+
text: "No recent messages available"
|
|
4444
|
+
};
|
|
4445
|
+
}
|
|
4446
|
+
const metaData = message.metadata;
|
|
4447
|
+
const senderName = metaData?.entityName || "unknown";
|
|
4448
|
+
const receivedMessageContent = message.content.text;
|
|
4449
|
+
const hasReceivedMessage = !!receivedMessageContent?.trim();
|
|
4450
|
+
const receivedMessageHeader = hasReceivedMessage ? addHeader9("# Received Message", `${senderName}: ${receivedMessageContent}`) : "";
|
|
4451
|
+
const focusHeader = hasReceivedMessage ? addHeader9(
|
|
4452
|
+
"# Focus your response",
|
|
4453
|
+
`You are replying to the above message from **${senderName}**. Keep your answer relevant to that message. Do not repeat earlier replies unless the sender asks again.`
|
|
4454
|
+
) : "";
|
|
4455
|
+
const interactionEntityMap = /* @__PURE__ */ new Map();
|
|
4456
|
+
if (recentInteractionsData.length > 0) {
|
|
4457
|
+
const uniqueEntityIds = [
|
|
4458
|
+
...new Set(
|
|
4459
|
+
recentInteractionsData.map((message2) => message2.entityId).filter((id) => id !== runtime.agentId)
|
|
4460
|
+
)
|
|
4461
|
+
];
|
|
4462
|
+
const uniqueEntityIdSet = new Set(uniqueEntityIds);
|
|
4463
|
+
const entitiesDataIdSet = /* @__PURE__ */ new Set();
|
|
4464
|
+
entitiesData.forEach((entity) => {
|
|
4465
|
+
if (uniqueEntityIdSet.has(entity.id)) {
|
|
4466
|
+
interactionEntityMap.set(entity.id, entity);
|
|
4467
|
+
entitiesDataIdSet.add(entity.id);
|
|
4457
4468
|
}
|
|
4458
4469
|
});
|
|
4470
|
+
const remainingEntityIds = uniqueEntityIds.filter((id) => !entitiesDataIdSet.has(id));
|
|
4471
|
+
if (remainingEntityIds.length > 0) {
|
|
4472
|
+
const entities = await Promise.all(
|
|
4473
|
+
remainingEntityIds.map((entityId) => runtime.getEntityById(entityId))
|
|
4474
|
+
);
|
|
4475
|
+
entities.forEach((entity, index) => {
|
|
4476
|
+
if (entity) {
|
|
4477
|
+
interactionEntityMap.set(remainingEntityIds[index], entity);
|
|
4478
|
+
}
|
|
4479
|
+
});
|
|
4480
|
+
}
|
|
4459
4481
|
}
|
|
4460
|
-
|
|
4461
|
-
|
|
4462
|
-
|
|
4463
|
-
|
|
4464
|
-
|
|
4465
|
-
|
|
4466
|
-
|
|
4467
|
-
|
|
4468
|
-
|
|
4482
|
+
const getRecentMessageInteractions = async (recentInteractionsData2) => {
|
|
4483
|
+
const formattedInteractions = recentInteractionsData2.map((message2) => {
|
|
4484
|
+
const isSelf = message2.entityId === runtime.agentId;
|
|
4485
|
+
let sender;
|
|
4486
|
+
if (isSelf) {
|
|
4487
|
+
sender = runtime.character.name;
|
|
4488
|
+
} else {
|
|
4489
|
+
sender = interactionEntityMap.get(message2.entityId)?.metadata?.username || "unknown";
|
|
4490
|
+
}
|
|
4491
|
+
return `${sender}: ${message2.content.text}`;
|
|
4492
|
+
});
|
|
4493
|
+
return formattedInteractions.join("\n");
|
|
4494
|
+
};
|
|
4495
|
+
const getRecentPostInteractions = async (recentInteractionsData2, entities) => {
|
|
4496
|
+
const combinedEntities = [...entities];
|
|
4497
|
+
const actorIds = new Set(entities.map((entity) => entity.id));
|
|
4498
|
+
for (const [id, entity] of interactionEntityMap.entries()) {
|
|
4499
|
+
if (!actorIds.has(id)) {
|
|
4500
|
+
combinedEntities.push(entity);
|
|
4501
|
+
}
|
|
4469
4502
|
}
|
|
4470
|
-
|
|
4471
|
-
|
|
4472
|
-
|
|
4473
|
-
|
|
4474
|
-
|
|
4475
|
-
|
|
4476
|
-
|
|
4477
|
-
|
|
4478
|
-
|
|
4479
|
-
|
|
4480
|
-
|
|
4481
|
-
|
|
4482
|
-
|
|
4483
|
-
|
|
4484
|
-
|
|
4485
|
-
|
|
4486
|
-
|
|
4487
|
-
|
|
4488
|
-
|
|
4489
|
-
|
|
4490
|
-
|
|
4491
|
-
|
|
4492
|
-
|
|
4493
|
-
|
|
4494
|
-
|
|
4495
|
-
|
|
4496
|
-
|
|
4497
|
-
|
|
4498
|
-
|
|
4499
|
-
|
|
4500
|
-
|
|
4501
|
-
|
|
4502
|
-
|
|
4503
|
-
}
|
|
4504
|
-
|
|
4505
|
-
|
|
4506
|
-
|
|
4507
|
-
|
|
4508
|
-
|
|
4509
|
-
|
|
4503
|
+
const formattedInteractions = formatPosts({
|
|
4504
|
+
messages: recentInteractionsData2,
|
|
4505
|
+
entities: combinedEntities,
|
|
4506
|
+
conversationHeader: true
|
|
4507
|
+
});
|
|
4508
|
+
return formattedInteractions;
|
|
4509
|
+
};
|
|
4510
|
+
const [recentMessageInteractions, recentPostInteractions] = await Promise.all([
|
|
4511
|
+
getRecentMessageInteractions(recentInteractionsData),
|
|
4512
|
+
getRecentPostInteractions(recentInteractionsData, entitiesData)
|
|
4513
|
+
]);
|
|
4514
|
+
const data = {
|
|
4515
|
+
recentMessages: recentMessagesData,
|
|
4516
|
+
recentInteractions: recentInteractionsData
|
|
4517
|
+
};
|
|
4518
|
+
const values = {
|
|
4519
|
+
recentPosts,
|
|
4520
|
+
recentMessages,
|
|
4521
|
+
recentMessageInteractions,
|
|
4522
|
+
recentPostInteractions,
|
|
4523
|
+
recentInteractions: isPostFormat ? recentPostInteractions : recentMessageInteractions
|
|
4524
|
+
};
|
|
4525
|
+
const text = [
|
|
4526
|
+
isPostFormat ? recentPosts : recentMessages,
|
|
4527
|
+
// Only add received message and focus headers if there are messages or a current message to process
|
|
4528
|
+
recentMessages || recentPosts || message.content.text ? receivedMessageHeader : "",
|
|
4529
|
+
recentMessages || recentPosts || message.content.text ? focusHeader : ""
|
|
4530
|
+
].filter(Boolean).join("\n\n");
|
|
4531
|
+
return {
|
|
4532
|
+
data,
|
|
4533
|
+
values,
|
|
4534
|
+
text
|
|
4535
|
+
};
|
|
4536
|
+
} catch (error) {
|
|
4537
|
+
logger13.error("Error in recentMessagesProvider:", error);
|
|
4538
|
+
return {
|
|
4539
|
+
data: {
|
|
4540
|
+
recentMessages: [],
|
|
4541
|
+
recentInteractions: []
|
|
4542
|
+
},
|
|
4543
|
+
values: {
|
|
4544
|
+
recentPosts: "",
|
|
4545
|
+
recentMessages: "",
|
|
4546
|
+
recentMessageInteractions: "",
|
|
4547
|
+
recentPostInteractions: "",
|
|
4548
|
+
recentInteractions: ""
|
|
4549
|
+
},
|
|
4550
|
+
text: "Error retrieving recent messages."
|
|
4551
|
+
// Or 'No recent messages available' as the test expects
|
|
4552
|
+
};
|
|
4553
|
+
}
|
|
4510
4554
|
}
|
|
4511
4555
|
};
|
|
4512
4556
|
|
|
@@ -4595,7 +4639,7 @@ ${formattedRelationships}`
|
|
|
4595
4639
|
import {
|
|
4596
4640
|
ChannelType as ChannelType6,
|
|
4597
4641
|
createUniqueUuid as createUniqueUuid2,
|
|
4598
|
-
logger as
|
|
4642
|
+
logger as logger14
|
|
4599
4643
|
} from "@elizaos/core";
|
|
4600
4644
|
var roleProvider = {
|
|
4601
4645
|
name: "ROLES",
|
|
@@ -4620,110 +4664,108 @@ var roleProvider = {
|
|
|
4620
4664
|
if (!serverId) {
|
|
4621
4665
|
throw new Error("No server ID found");
|
|
4622
4666
|
}
|
|
4623
|
-
|
|
4624
|
-
|
|
4625
|
-
|
|
4626
|
-
|
|
4627
|
-
|
|
4628
|
-
|
|
4629
|
-
|
|
4630
|
-
);
|
|
4631
|
-
return {
|
|
4632
|
-
data: {
|
|
4633
|
-
roles: []
|
|
4634
|
-
},
|
|
4635
|
-
values: {
|
|
4636
|
-
roles: "No role information available for this server."
|
|
4637
|
-
},
|
|
4638
|
-
text: "No role information available for this server."
|
|
4639
|
-
};
|
|
4640
|
-
}
|
|
4641
|
-
const roles = world.metadata.roles || {};
|
|
4642
|
-
if (Object.keys(roles).length === 0) {
|
|
4643
|
-
logger12.info(`No roles found for server ${serverId}`);
|
|
4644
|
-
return {
|
|
4645
|
-
data: {
|
|
4646
|
-
roles: []
|
|
4647
|
-
},
|
|
4648
|
-
values: {
|
|
4649
|
-
roles: "No role information available for this server."
|
|
4650
|
-
}
|
|
4651
|
-
};
|
|
4652
|
-
}
|
|
4653
|
-
logger12.info(`Found ${Object.keys(roles).length} roles`);
|
|
4654
|
-
const owners = [];
|
|
4655
|
-
const admins = [];
|
|
4656
|
-
const members = [];
|
|
4657
|
-
for (const entityId of Object.keys(roles)) {
|
|
4658
|
-
const userRole = roles[entityId];
|
|
4659
|
-
const user = await runtime.getEntityById(entityId);
|
|
4660
|
-
const name = user?.metadata?.[room.source]?.name;
|
|
4661
|
-
const username = user?.metadata?.[room.source]?.username;
|
|
4662
|
-
const names = user?.names;
|
|
4663
|
-
if (owners.some((owner) => owner.username === username) || admins.some((admin) => admin.username === username) || members.some((member) => member.username === username)) {
|
|
4664
|
-
continue;
|
|
4665
|
-
}
|
|
4666
|
-
if (!name || !username || !names) {
|
|
4667
|
-
logger12.warn(`User ${entityId} has no name or username, skipping`);
|
|
4668
|
-
continue;
|
|
4669
|
-
}
|
|
4670
|
-
switch (userRole) {
|
|
4671
|
-
case "OWNER":
|
|
4672
|
-
owners.push({ name, username, names });
|
|
4673
|
-
break;
|
|
4674
|
-
case "ADMIN":
|
|
4675
|
-
admins.push({ name, username, names });
|
|
4676
|
-
break;
|
|
4677
|
-
default:
|
|
4678
|
-
members.push({ name, username, names });
|
|
4679
|
-
break;
|
|
4680
|
-
}
|
|
4681
|
-
}
|
|
4682
|
-
let response = "# Server Role Hierarchy\n\n";
|
|
4683
|
-
if (owners.length > 0) {
|
|
4684
|
-
response += "## Owners\n";
|
|
4685
|
-
owners.forEach((owner) => {
|
|
4686
|
-
response += `${owner.name} (${owner.names.join(", ")})
|
|
4687
|
-
`;
|
|
4688
|
-
});
|
|
4689
|
-
response += "\n";
|
|
4690
|
-
}
|
|
4691
|
-
if (admins.length > 0) {
|
|
4692
|
-
response += "## Administrators\n";
|
|
4693
|
-
admins.forEach((admin) => {
|
|
4694
|
-
response += `${admin.name} (${admin.names.join(", ")}) (${admin.username})
|
|
4695
|
-
`;
|
|
4696
|
-
});
|
|
4697
|
-
response += "\n";
|
|
4698
|
-
}
|
|
4699
|
-
if (members.length > 0) {
|
|
4700
|
-
response += "## Members\n";
|
|
4701
|
-
members.forEach((member) => {
|
|
4702
|
-
response += `${member.name} (${member.names.join(", ")}) (${member.username})
|
|
4703
|
-
`;
|
|
4704
|
-
});
|
|
4705
|
-
}
|
|
4667
|
+
logger14.info(`Using server ID: ${serverId}`);
|
|
4668
|
+
const worldId = createUniqueUuid2(runtime, serverId);
|
|
4669
|
+
const world = await runtime.getWorld(worldId);
|
|
4670
|
+
if (!world || !world.metadata?.ownership?.ownerId) {
|
|
4671
|
+
logger14.info(
|
|
4672
|
+
`No ownership data found for server ${serverId}, initializing empty role hierarchy`
|
|
4673
|
+
);
|
|
4706
4674
|
return {
|
|
4707
4675
|
data: {
|
|
4708
|
-
roles:
|
|
4676
|
+
roles: []
|
|
4709
4677
|
},
|
|
4710
4678
|
values: {
|
|
4711
|
-
roles:
|
|
4679
|
+
roles: "No role information available for this server."
|
|
4712
4680
|
},
|
|
4713
|
-
text:
|
|
4681
|
+
text: "No role information available for this server."
|
|
4714
4682
|
};
|
|
4715
|
-
}
|
|
4716
|
-
|
|
4683
|
+
}
|
|
4684
|
+
const roles = world.metadata.roles || {};
|
|
4685
|
+
if (Object.keys(roles).length === 0) {
|
|
4686
|
+
logger14.info(`No roles found for server ${serverId}`);
|
|
4687
|
+
return {
|
|
4688
|
+
data: {
|
|
4689
|
+
roles: []
|
|
4690
|
+
},
|
|
4691
|
+
values: {
|
|
4692
|
+
roles: "No role information available for this server."
|
|
4693
|
+
}
|
|
4694
|
+
};
|
|
4695
|
+
}
|
|
4696
|
+
logger14.info(`Found ${Object.keys(roles).length} roles`);
|
|
4697
|
+
const owners = [];
|
|
4698
|
+
const admins = [];
|
|
4699
|
+
const members = [];
|
|
4700
|
+
for (const entityId of Object.keys(roles)) {
|
|
4701
|
+
const userRole = roles[entityId];
|
|
4702
|
+
const user = await runtime.getEntityById(entityId);
|
|
4703
|
+
const name = user?.metadata?.[room.source]?.name;
|
|
4704
|
+
const username = user?.metadata?.[room.source]?.username;
|
|
4705
|
+
const names = user?.names;
|
|
4706
|
+
if (owners.some((owner) => owner.username === username) || admins.some((admin) => admin.username === username) || members.some((member) => member.username === username)) {
|
|
4707
|
+
continue;
|
|
4708
|
+
}
|
|
4709
|
+
if (!name || !username || !names) {
|
|
4710
|
+
logger14.warn(`User ${entityId} has no name or username, skipping`);
|
|
4711
|
+
continue;
|
|
4712
|
+
}
|
|
4713
|
+
switch (userRole) {
|
|
4714
|
+
case "OWNER":
|
|
4715
|
+
owners.push({ name, username, names });
|
|
4716
|
+
break;
|
|
4717
|
+
case "ADMIN":
|
|
4718
|
+
admins.push({ name, username, names });
|
|
4719
|
+
break;
|
|
4720
|
+
default:
|
|
4721
|
+
members.push({ name, username, names });
|
|
4722
|
+
break;
|
|
4723
|
+
}
|
|
4724
|
+
}
|
|
4725
|
+
let response = "# Server Role Hierarchy\n\n";
|
|
4726
|
+
if (owners.length > 0) {
|
|
4727
|
+
response += "## Owners\n";
|
|
4728
|
+
owners.forEach((owner) => {
|
|
4729
|
+
response += `${owner.name} (${owner.names.join(", ")})
|
|
4730
|
+
`;
|
|
4731
|
+
});
|
|
4732
|
+
response += "\n";
|
|
4733
|
+
}
|
|
4734
|
+
if (admins.length > 0) {
|
|
4735
|
+
response += "## Administrators\n";
|
|
4736
|
+
admins.forEach((admin) => {
|
|
4737
|
+
response += `${admin.name} (${admin.names.join(", ")}) (${admin.username})
|
|
4738
|
+
`;
|
|
4739
|
+
});
|
|
4740
|
+
response += "\n";
|
|
4741
|
+
}
|
|
4742
|
+
if (members.length > 0) {
|
|
4743
|
+
response += "## Members\n";
|
|
4744
|
+
members.forEach((member) => {
|
|
4745
|
+
response += `${member.name} (${member.names.join(", ")}) (${member.username})
|
|
4746
|
+
`;
|
|
4747
|
+
});
|
|
4748
|
+
}
|
|
4749
|
+
if (owners.length === 0 && admins.length === 0 && members.length === 0) {
|
|
4717
4750
|
return {
|
|
4718
4751
|
data: {
|
|
4719
4752
|
roles: []
|
|
4720
4753
|
},
|
|
4721
4754
|
values: {
|
|
4722
|
-
roles: "
|
|
4755
|
+
roles: "No role information available for this server."
|
|
4723
4756
|
},
|
|
4724
|
-
text: "
|
|
4757
|
+
text: "No role information available for this server."
|
|
4725
4758
|
};
|
|
4726
4759
|
}
|
|
4760
|
+
return {
|
|
4761
|
+
data: {
|
|
4762
|
+
roles: response
|
|
4763
|
+
},
|
|
4764
|
+
values: {
|
|
4765
|
+
roles: response
|
|
4766
|
+
},
|
|
4767
|
+
text: response
|
|
4768
|
+
};
|
|
4727
4769
|
}
|
|
4728
4770
|
};
|
|
4729
4771
|
|
|
@@ -4732,7 +4774,7 @@ import {
|
|
|
4732
4774
|
ChannelType as ChannelType7,
|
|
4733
4775
|
findWorldsForOwner as findWorldsForOwner2,
|
|
4734
4776
|
getWorldSettings as getWorldSettings2,
|
|
4735
|
-
logger as
|
|
4777
|
+
logger as logger15
|
|
4736
4778
|
} from "@elizaos/core";
|
|
4737
4779
|
var formatSettingValue = (setting, isOnboarding) => {
|
|
4738
4780
|
if (setting.value === null) return "Not set";
|
|
@@ -4803,7 +4845,7 @@ ${requiredUnconfigured > 0 ? `IMPORTANT!: ${requiredUnconfigured} required setti
|
|
|
4803
4845
|
**Value:** ${s?.value}
|
|
4804
4846
|
**Description:** ${s?.description}`).join("\n\n")}`;
|
|
4805
4847
|
} catch (error) {
|
|
4806
|
-
|
|
4848
|
+
logger15.error(`Error generating status message: ${error}`);
|
|
4807
4849
|
return "Error generating configuration status.";
|
|
4808
4850
|
}
|
|
4809
4851
|
}
|
|
@@ -4816,11 +4858,11 @@ var settingsProvider = {
|
|
|
4816
4858
|
runtime.getRoom(message.roomId),
|
|
4817
4859
|
findWorldsForOwner2(runtime, message.entityId)
|
|
4818
4860
|
]).catch((error) => {
|
|
4819
|
-
|
|
4861
|
+
logger15.error(`Error fetching initial data: ${error}`);
|
|
4820
4862
|
throw new Error("Failed to retrieve room or user world information");
|
|
4821
4863
|
});
|
|
4822
4864
|
if (!room) {
|
|
4823
|
-
|
|
4865
|
+
logger15.error("No room found for settings provider");
|
|
4824
4866
|
return {
|
|
4825
4867
|
data: {
|
|
4826
4868
|
settings: []
|
|
@@ -4832,7 +4874,7 @@ var settingsProvider = {
|
|
|
4832
4874
|
};
|
|
4833
4875
|
}
|
|
4834
4876
|
if (!room.worldId) {
|
|
4835
|
-
|
|
4877
|
+
logger15.debug("No world found for settings provider -- settings provider will be skipped");
|
|
4836
4878
|
return {
|
|
4837
4879
|
data: {
|
|
4838
4880
|
settings: []
|
|
@@ -4851,36 +4893,36 @@ var settingsProvider = {
|
|
|
4851
4893
|
if (isOnboarding) {
|
|
4852
4894
|
world = userWorlds?.find((world2) => world2.metadata?.settings);
|
|
4853
4895
|
if (!world) {
|
|
4854
|
-
|
|
4896
|
+
logger15.error("No world found for user during onboarding");
|
|
4855
4897
|
throw new Error("No server ownership found for onboarding");
|
|
4856
4898
|
}
|
|
4857
4899
|
serverId = world.serverId;
|
|
4858
4900
|
try {
|
|
4859
4901
|
worldSettings = await getWorldSettings2(runtime, serverId);
|
|
4860
4902
|
} catch (error) {
|
|
4861
|
-
|
|
4903
|
+
logger15.error(`Error fetching world settings: ${error}`);
|
|
4862
4904
|
throw new Error(`Failed to retrieve settings for server ${serverId}`);
|
|
4863
4905
|
}
|
|
4864
4906
|
} else {
|
|
4865
4907
|
try {
|
|
4866
4908
|
world = await runtime.getWorld(room.worldId);
|
|
4867
4909
|
if (!world) {
|
|
4868
|
-
|
|
4910
|
+
logger15.error(`No world found for room ${room.worldId}`);
|
|
4869
4911
|
throw new Error(`No world found for room ${room.worldId}`);
|
|
4870
4912
|
}
|
|
4871
4913
|
serverId = world.serverId;
|
|
4872
4914
|
if (serverId) {
|
|
4873
4915
|
worldSettings = await getWorldSettings2(runtime, serverId);
|
|
4874
4916
|
} else {
|
|
4875
|
-
|
|
4917
|
+
logger15.error(`No server ID found for world ${room.worldId}`);
|
|
4876
4918
|
}
|
|
4877
4919
|
} catch (error) {
|
|
4878
|
-
|
|
4920
|
+
logger15.error(`Error processing world data: ${error}`);
|
|
4879
4921
|
throw new Error("Failed to process world information");
|
|
4880
4922
|
}
|
|
4881
4923
|
}
|
|
4882
4924
|
if (!serverId) {
|
|
4883
|
-
|
|
4925
|
+
logger15.info(
|
|
4884
4926
|
`No server ownership found for user ${message.entityId} after recovery attempt`
|
|
4885
4927
|
);
|
|
4886
4928
|
return isOnboarding ? {
|
|
@@ -4902,7 +4944,7 @@ var settingsProvider = {
|
|
|
4902
4944
|
};
|
|
4903
4945
|
}
|
|
4904
4946
|
if (!worldSettings) {
|
|
4905
|
-
|
|
4947
|
+
logger15.info(`No settings state found for server ${serverId}`);
|
|
4906
4948
|
return isOnboarding ? {
|
|
4907
4949
|
data: {
|
|
4908
4950
|
settings: []
|
|
@@ -4932,7 +4974,7 @@ var settingsProvider = {
|
|
|
4932
4974
|
text: output
|
|
4933
4975
|
};
|
|
4934
4976
|
} catch (error) {
|
|
4935
|
-
|
|
4977
|
+
logger15.error(`Critical error in settings provider: ${error}`);
|
|
4936
4978
|
return {
|
|
4937
4979
|
data: {
|
|
4938
4980
|
settings: []
|
|
@@ -4971,7 +5013,7 @@ var timeProvider = {
|
|
|
4971
5013
|
|
|
4972
5014
|
// src/providers/world.ts
|
|
4973
5015
|
import {
|
|
4974
|
-
logger as
|
|
5016
|
+
logger as logger16,
|
|
4975
5017
|
addHeader as addHeader10,
|
|
4976
5018
|
ChannelType as ChannelType8
|
|
4977
5019
|
} from "@elizaos/core";
|
|
@@ -4981,10 +5023,10 @@ var worldProvider = {
|
|
|
4981
5023
|
dynamic: true,
|
|
4982
5024
|
get: async (runtime, message) => {
|
|
4983
5025
|
try {
|
|
4984
|
-
|
|
5026
|
+
logger16.debug("\u{1F310} World provider activated for roomId:", message.roomId);
|
|
4985
5027
|
const currentRoom = await runtime.getRoom(message.roomId);
|
|
4986
5028
|
if (!currentRoom) {
|
|
4987
|
-
|
|
5029
|
+
logger16.warn(`World provider: Room not found for roomId ${message.roomId}`);
|
|
4988
5030
|
return {
|
|
4989
5031
|
data: {
|
|
4990
5032
|
world: {
|
|
@@ -4994,10 +5036,10 @@ var worldProvider = {
|
|
|
4994
5036
|
text: "Unable to retrieve world information - room not found"
|
|
4995
5037
|
};
|
|
4996
5038
|
}
|
|
4997
|
-
|
|
5039
|
+
logger16.debug(`\u{1F310} World provider: Found room "${currentRoom.name}" (${currentRoom.type})`);
|
|
4998
5040
|
const worldId = currentRoom.worldId;
|
|
4999
5041
|
if (!worldId) {
|
|
5000
|
-
|
|
5042
|
+
logger16.warn(`World provider: World ID not found for roomId ${message.roomId}`);
|
|
5001
5043
|
return {
|
|
5002
5044
|
data: {
|
|
5003
5045
|
world: {
|
|
@@ -5009,7 +5051,7 @@ var worldProvider = {
|
|
|
5009
5051
|
}
|
|
5010
5052
|
const world = await runtime.getWorld(worldId);
|
|
5011
5053
|
if (!world) {
|
|
5012
|
-
|
|
5054
|
+
logger16.warn(`World provider: World not found for worldId ${worldId}`);
|
|
5013
5055
|
return {
|
|
5014
5056
|
data: {
|
|
5015
5057
|
world: {
|
|
@@ -5019,11 +5061,11 @@ var worldProvider = {
|
|
|
5019
5061
|
text: "Unable to retrieve world information - world not found"
|
|
5020
5062
|
};
|
|
5021
5063
|
}
|
|
5022
|
-
|
|
5064
|
+
logger16.debug(`\u{1F310} World provider: Found world "${world.name}" (ID: ${world.id})`);
|
|
5023
5065
|
const worldRooms = await runtime.getRooms(worldId);
|
|
5024
|
-
|
|
5066
|
+
logger16.debug(`\u{1F310} World provider: Found ${worldRooms.length} rooms in world "${world.name}"`);
|
|
5025
5067
|
const participants = await runtime.getParticipantsForRoom(message.roomId);
|
|
5026
|
-
|
|
5068
|
+
logger16.debug(
|
|
5027
5069
|
`\u{1F310} World provider: Found ${participants.length} participants in room "${currentRoom.name}"`
|
|
5028
5070
|
);
|
|
5029
5071
|
const channelsByType = {
|
|
@@ -5036,7 +5078,7 @@ var worldProvider = {
|
|
|
5036
5078
|
};
|
|
5037
5079
|
for (const room of worldRooms) {
|
|
5038
5080
|
if (!room?.id || !room.name) {
|
|
5039
|
-
|
|
5081
|
+
logger16.warn(`World provider: Room ID or name is missing for room ${room.id}`);
|
|
5040
5082
|
continue;
|
|
5041
5083
|
}
|
|
5042
5084
|
const roomInfo = {
|
|
@@ -5105,14 +5147,14 @@ var worldProvider = {
|
|
|
5105
5147
|
worldInfo: worldInfoText
|
|
5106
5148
|
};
|
|
5107
5149
|
const formattedText = addHeader10("# World Information", worldInfoText);
|
|
5108
|
-
|
|
5150
|
+
logger16.debug("\u{1F310} World provider completed successfully");
|
|
5109
5151
|
return {
|
|
5110
5152
|
data,
|
|
5111
5153
|
values,
|
|
5112
5154
|
text: formattedText
|
|
5113
5155
|
};
|
|
5114
5156
|
} catch (error) {
|
|
5115
|
-
|
|
5157
|
+
logger16.error(
|
|
5116
5158
|
`Error in world provider: ${error instanceof Error ? error.message : String(error)}`
|
|
5117
5159
|
);
|
|
5118
5160
|
return {
|
|
@@ -5134,7 +5176,7 @@ import {
|
|
|
5134
5176
|
EventType,
|
|
5135
5177
|
Service,
|
|
5136
5178
|
createUniqueUuid as createUniqueUuid3,
|
|
5137
|
-
logger as
|
|
5179
|
+
logger as logger17
|
|
5138
5180
|
} from "@elizaos/core";
|
|
5139
5181
|
var ScenarioService = class _ScenarioService extends Service {
|
|
5140
5182
|
/**
|
|
@@ -5178,7 +5220,7 @@ var ScenarioService = class _ScenarioService extends Service {
|
|
|
5178
5220
|
startTime: Date.now(),
|
|
5179
5221
|
completed: false
|
|
5180
5222
|
});
|
|
5181
|
-
|
|
5223
|
+
logger17.debug("[Bootstrap] Evaluator started", data);
|
|
5182
5224
|
return Promise.resolve();
|
|
5183
5225
|
});
|
|
5184
5226
|
this.runtime.registerEvent(
|
|
@@ -5189,7 +5231,7 @@ var ScenarioService = class _ScenarioService extends Service {
|
|
|
5189
5231
|
evaluator.completed = true;
|
|
5190
5232
|
evaluator.error = data.error;
|
|
5191
5233
|
}
|
|
5192
|
-
|
|
5234
|
+
logger17.debug("[Bootstrap] Evaluator completed", data);
|
|
5193
5235
|
return Promise.resolve();
|
|
5194
5236
|
}
|
|
5195
5237
|
);
|
|
@@ -5270,7 +5312,8 @@ var ScenarioService = class _ScenarioService extends Service {
|
|
|
5270
5312
|
source: "scenario",
|
|
5271
5313
|
type: ChannelType9.GROUP,
|
|
5272
5314
|
channelId: roomId,
|
|
5273
|
-
serverId: worldId
|
|
5315
|
+
serverId: worldId,
|
|
5316
|
+
worldId
|
|
5274
5317
|
});
|
|
5275
5318
|
return roomId;
|
|
5276
5319
|
}
|
|
@@ -5370,7 +5413,7 @@ var ScenarioService = class _ScenarioService extends Service {
|
|
|
5370
5413
|
|
|
5371
5414
|
// src/services/task.ts
|
|
5372
5415
|
import {
|
|
5373
|
-
logger as
|
|
5416
|
+
logger as logger18,
|
|
5374
5417
|
Service as Service2,
|
|
5375
5418
|
ServiceType
|
|
5376
5419
|
} from "@elizaos/core";
|
|
@@ -5398,21 +5441,21 @@ var TaskService = class _TaskService extends Service2 {
|
|
|
5398
5441
|
this.runtime.registerTaskWorker({
|
|
5399
5442
|
name: "REPEATING_TEST_TASK",
|
|
5400
5443
|
validate: async (_runtime, _message, _state) => {
|
|
5401
|
-
|
|
5444
|
+
logger18.debug("[Bootstrap] Validating repeating test task");
|
|
5402
5445
|
return true;
|
|
5403
5446
|
},
|
|
5404
5447
|
execute: async (_runtime, _options) => {
|
|
5405
|
-
|
|
5448
|
+
logger18.debug("[Bootstrap] Executing repeating test task");
|
|
5406
5449
|
}
|
|
5407
5450
|
});
|
|
5408
5451
|
this.runtime.registerTaskWorker({
|
|
5409
5452
|
name: "ONETIME_TEST_TASK",
|
|
5410
5453
|
validate: async (_runtime, _message, _state) => {
|
|
5411
|
-
|
|
5454
|
+
logger18.debug("[Bootstrap] Validating one-time test task");
|
|
5412
5455
|
return true;
|
|
5413
5456
|
},
|
|
5414
5457
|
execute: async (_runtime, _options) => {
|
|
5415
|
-
|
|
5458
|
+
logger18.debug("[Bootstrap] Executing one-time test task");
|
|
5416
5459
|
}
|
|
5417
5460
|
});
|
|
5418
5461
|
const tasks = await this.runtime.getTasksByName("REPEATING_TEST_TASK");
|
|
@@ -5449,7 +5492,7 @@ var TaskService = class _TaskService extends Service2 {
|
|
|
5449
5492
|
try {
|
|
5450
5493
|
await this.checkTasks();
|
|
5451
5494
|
} catch (error) {
|
|
5452
|
-
|
|
5495
|
+
logger18.error("[Bootstrap] Error checking tasks:", error);
|
|
5453
5496
|
}
|
|
5454
5497
|
}, this.TICK_INTERVAL);
|
|
5455
5498
|
}
|
|
@@ -5478,7 +5521,7 @@ var TaskService = class _TaskService extends Service2 {
|
|
|
5478
5521
|
continue;
|
|
5479
5522
|
}
|
|
5480
5523
|
} catch (error) {
|
|
5481
|
-
|
|
5524
|
+
logger18.error(`[Bootstrap] Error validating task ${task.name}:`, error);
|
|
5482
5525
|
continue;
|
|
5483
5526
|
}
|
|
5484
5527
|
}
|
|
@@ -5520,20 +5563,20 @@ var TaskService = class _TaskService extends Service2 {
|
|
|
5520
5563
|
}
|
|
5521
5564
|
if (task.metadata?.updatedAt === task.metadata?.createdAt) {
|
|
5522
5565
|
if (task.tags?.includes("immediate")) {
|
|
5523
|
-
|
|
5566
|
+
logger18.debug("[Bootstrap] Immediately running task", task.name);
|
|
5524
5567
|
await this.executeTask(task);
|
|
5525
5568
|
continue;
|
|
5526
5569
|
}
|
|
5527
5570
|
}
|
|
5528
5571
|
if (now - taskStartTime >= updateIntervalMs) {
|
|
5529
|
-
|
|
5530
|
-
`Executing task ${task.name} - interval of ${updateIntervalMs}ms has elapsed`
|
|
5572
|
+
logger18.debug(
|
|
5573
|
+
`[Bootstrap] Executing task ${task.name} - interval of ${updateIntervalMs}ms has elapsed`
|
|
5531
5574
|
);
|
|
5532
5575
|
await this.executeTask(task);
|
|
5533
5576
|
}
|
|
5534
5577
|
}
|
|
5535
5578
|
} catch (error) {
|
|
5536
|
-
|
|
5579
|
+
logger18.error("[Bootstrap] Error checking tasks:", error);
|
|
5537
5580
|
}
|
|
5538
5581
|
}
|
|
5539
5582
|
/**
|
|
@@ -5544,12 +5587,12 @@ var TaskService = class _TaskService extends Service2 {
|
|
|
5544
5587
|
async executeTask(task) {
|
|
5545
5588
|
try {
|
|
5546
5589
|
if (!task || !task.id) {
|
|
5547
|
-
|
|
5590
|
+
logger18.debug(`[Bootstrap] Task not found`);
|
|
5548
5591
|
return;
|
|
5549
5592
|
}
|
|
5550
5593
|
const worker = this.runtime.getTaskWorker(task.name);
|
|
5551
5594
|
if (!worker) {
|
|
5552
|
-
|
|
5595
|
+
logger18.debug(`[Bootstrap] No worker found for task type: ${task.name}`);
|
|
5553
5596
|
return;
|
|
5554
5597
|
}
|
|
5555
5598
|
if (task.tags?.includes("repeat")) {
|
|
@@ -5559,16 +5602,20 @@ var TaskService = class _TaskService extends Service2 {
|
|
|
5559
5602
|
updatedAt: Date.now()
|
|
5560
5603
|
}
|
|
5561
5604
|
});
|
|
5562
|
-
|
|
5605
|
+
logger18.debug(
|
|
5606
|
+
`[Bootstrap] Updated repeating task ${task.name} (${task.id}) with new timestamp`
|
|
5607
|
+
);
|
|
5563
5608
|
}
|
|
5564
|
-
|
|
5609
|
+
logger18.debug(`[Bootstrap] Executing task ${task.name} (${task.id})`);
|
|
5565
5610
|
await worker.execute(this.runtime, task.metadata || {}, task);
|
|
5566
5611
|
if (!task.tags?.includes("repeat")) {
|
|
5567
5612
|
await this.runtime.deleteTask(task.id);
|
|
5568
|
-
|
|
5613
|
+
logger18.debug(
|
|
5614
|
+
`[Bootstrap] Deleted non-repeating task ${task.name} (${task.id}) after execution`
|
|
5615
|
+
);
|
|
5569
5616
|
}
|
|
5570
5617
|
} catch (error) {
|
|
5571
|
-
|
|
5618
|
+
logger18.error(`[Bootstrap] Error executing task ${task.id}:`, error);
|
|
5572
5619
|
}
|
|
5573
5620
|
}
|
|
5574
5621
|
/**
|
|
@@ -5618,6 +5665,7 @@ var messageReceivedHandler = async ({
|
|
|
5618
5665
|
callback,
|
|
5619
5666
|
onComplete
|
|
5620
5667
|
}) => {
|
|
5668
|
+
logger19.info(`[Bootstrap] Message received from ${message.entityId} in room ${message.roomId}`);
|
|
5621
5669
|
const responseId = v4_default();
|
|
5622
5670
|
if (!latestResponseIds.has(runtime.agentId)) {
|
|
5623
5671
|
latestResponseIds.set(runtime.agentId, /* @__PURE__ */ new Map());
|
|
@@ -5662,15 +5710,20 @@ var messageReceivedHandler = async ({
|
|
|
5662
5710
|
const processingPromise = (async () => {
|
|
5663
5711
|
try {
|
|
5664
5712
|
if (message.entityId === runtime.agentId) {
|
|
5713
|
+
logger19.debug(`[Bootstrap] Skipping message from self (${runtime.agentId})`);
|
|
5665
5714
|
throw new Error("Message is from the agent itself");
|
|
5666
5715
|
}
|
|
5716
|
+
logger19.debug(
|
|
5717
|
+
`[Bootstrap] Processing message: ${truncateToCompleteSentence(message.content.text || "", 50)}...`
|
|
5718
|
+
);
|
|
5719
|
+
logger19.debug("[Bootstrap] Saving message to memory and embeddings");
|
|
5667
5720
|
await Promise.all([
|
|
5668
5721
|
runtime.addEmbeddingToMemory(message),
|
|
5669
5722
|
runtime.createMemory(message, "messages")
|
|
5670
5723
|
]);
|
|
5671
5724
|
const agentUserState = await runtime.getParticipantUserState(message.roomId, runtime.agentId);
|
|
5672
5725
|
if (agentUserState === "MUTED" && !message.content.text?.toLowerCase().includes(runtime.character.name.toLowerCase())) {
|
|
5673
|
-
|
|
5726
|
+
logger19.debug(`[Bootstrap] Ignoring muted room ${message.roomId}`);
|
|
5674
5727
|
return;
|
|
5675
5728
|
}
|
|
5676
5729
|
let state = await runtime.composeState(message, [
|
|
@@ -5681,26 +5734,25 @@ var messageReceivedHandler = async ({
|
|
|
5681
5734
|
"RECENT_MESSAGES"
|
|
5682
5735
|
]);
|
|
5683
5736
|
const room = await runtime.getRoom(message.roomId);
|
|
5684
|
-
const shouldSkipShouldRespond = room?.type === ChannelType10.DM || room?.type === ChannelType10.VOICE_DM || room?.type === ChannelType10.SELF;
|
|
5737
|
+
const shouldSkipShouldRespond = room?.type === ChannelType10.DM || room?.type === ChannelType10.VOICE_DM || room?.type === ChannelType10.SELF || room?.type === ChannelType10.API;
|
|
5685
5738
|
let shouldRespond = true;
|
|
5686
5739
|
if (!shouldSkipShouldRespond) {
|
|
5687
5740
|
const shouldRespondPrompt = composePromptFromState9({
|
|
5688
5741
|
state,
|
|
5689
5742
|
template: runtime.character.templates?.shouldRespondTemplate || shouldRespondTemplate
|
|
5690
5743
|
});
|
|
5691
|
-
|
|
5692
|
-
|
|
5693
|
-
|
|
5694
|
-
shouldRespondPrompt
|
|
5744
|
+
logger19.debug(
|
|
5745
|
+
`[Bootstrap] Evaluating response for ${runtime.character.name}
|
|
5746
|
+
Prompt: ${shouldRespondPrompt}`
|
|
5695
5747
|
);
|
|
5696
5748
|
const response = await runtime.useModel(ModelType13.TEXT_SMALL, {
|
|
5697
5749
|
prompt: shouldRespondPrompt
|
|
5698
5750
|
});
|
|
5699
|
-
|
|
5700
|
-
|
|
5701
|
-
|
|
5751
|
+
logger19.debug(`[Bootstrap] Response evaluation for ${runtime.character.name}:
|
|
5752
|
+
${response}`);
|
|
5753
|
+
logger19.debug(`[Bootstrap] Response type: ${typeof response}`);
|
|
5702
5754
|
const responseObject = parseKeyValueXml(response);
|
|
5703
|
-
|
|
5755
|
+
logger19.debug("[Bootstrap] Parsed response:", responseObject);
|
|
5704
5756
|
shouldRespond = responseObject?.action && responseObject.action === "RESPOND";
|
|
5705
5757
|
} else {
|
|
5706
5758
|
shouldRespond = true;
|
|
@@ -5719,11 +5771,12 @@ var messageReceivedHandler = async ({
|
|
|
5719
5771
|
let response = await runtime.useModel(ModelType13.TEXT_LARGE, {
|
|
5720
5772
|
prompt
|
|
5721
5773
|
});
|
|
5722
|
-
|
|
5774
|
+
logger19.debug("[Bootstrap] *** Raw LLM Response ***\n", response);
|
|
5723
5775
|
const parsedXml = parseKeyValueXml(response);
|
|
5724
|
-
|
|
5776
|
+
logger19.debug("[Bootstrap] *** Parsed XML Content ***\n", parsedXml);
|
|
5725
5777
|
if (parsedXml) {
|
|
5726
5778
|
responseContent = {
|
|
5779
|
+
...parsedXml,
|
|
5727
5780
|
thought: parsedXml.thought || "",
|
|
5728
5781
|
actions: parsedXml.actions || ["IGNORE"],
|
|
5729
5782
|
providers: parsedXml.providers || [],
|
|
@@ -5735,12 +5788,14 @@ var messageReceivedHandler = async ({
|
|
|
5735
5788
|
}
|
|
5736
5789
|
retries++;
|
|
5737
5790
|
if (!responseContent?.thought || !responseContent?.actions) {
|
|
5738
|
-
|
|
5791
|
+
logger19.warn(
|
|
5792
|
+
"[Bootstrap] *** Missing required fields (thought or actions), retrying... ***"
|
|
5793
|
+
);
|
|
5739
5794
|
}
|
|
5740
5795
|
}
|
|
5741
5796
|
const currentResponseId = agentResponses.get(message.roomId);
|
|
5742
5797
|
if (currentResponseId !== responseId) {
|
|
5743
|
-
|
|
5798
|
+
logger19.info(
|
|
5744
5799
|
`Response discarded - newer message being processed for agent: ${runtime.agentId}, room: ${message.roomId}`
|
|
5745
5800
|
);
|
|
5746
5801
|
return;
|
|
@@ -5761,8 +5816,8 @@ var messageReceivedHandler = async ({
|
|
|
5761
5816
|
if (agentResponses.size === 0) {
|
|
5762
5817
|
latestResponseIds.delete(runtime.agentId);
|
|
5763
5818
|
}
|
|
5764
|
-
if (responseContent?.providers?.length && responseContent
|
|
5765
|
-
state = await runtime.composeState(message,
|
|
5819
|
+
if (responseContent?.providers?.length && responseContent?.providers?.length > 0) {
|
|
5820
|
+
state = await runtime.composeState(message, responseContent?.providers || []);
|
|
5766
5821
|
}
|
|
5767
5822
|
if (responseContent && responseContent.simple && responseContent.text && (responseContent.actions?.length === 0 || responseContent.actions?.length === 1 && responseContent.actions[0].toUpperCase() === "REPLY")) {
|
|
5768
5823
|
await callback(responseContent);
|
|
@@ -5771,16 +5826,16 @@ var messageReceivedHandler = async ({
|
|
|
5771
5826
|
}
|
|
5772
5827
|
await runtime.evaluate(message, state, shouldRespond, callback, responseMessages);
|
|
5773
5828
|
} else {
|
|
5774
|
-
|
|
5829
|
+
logger19.debug("[Bootstrap] Agent decided not to respond (shouldRespond is false).");
|
|
5775
5830
|
const currentResponseId = agentResponses.get(message.roomId);
|
|
5776
5831
|
if (currentResponseId !== responseId) {
|
|
5777
|
-
|
|
5832
|
+
logger19.info(
|
|
5778
5833
|
`Ignore response discarded - newer message being processed for agent: ${runtime.agentId}, room: ${message.roomId}`
|
|
5779
5834
|
);
|
|
5780
5835
|
return;
|
|
5781
5836
|
}
|
|
5782
5837
|
if (!message.id) {
|
|
5783
|
-
|
|
5838
|
+
logger19.error("[Bootstrap] Message ID is missing, cannot create ignore response.");
|
|
5784
5839
|
return;
|
|
5785
5840
|
}
|
|
5786
5841
|
const ignoreContent = {
|
|
@@ -5801,7 +5856,7 @@ var messageReceivedHandler = async ({
|
|
|
5801
5856
|
createdAt: Date.now()
|
|
5802
5857
|
};
|
|
5803
5858
|
await runtime.createMemory(ignoreMemory, "messages");
|
|
5804
|
-
|
|
5859
|
+
logger19.debug("[Bootstrap] Saved ignore response to memory", { memoryId: ignoreMemory.id });
|
|
5805
5860
|
agentResponses.delete(message.roomId);
|
|
5806
5861
|
if (agentResponses.size === 0) {
|
|
5807
5862
|
latestResponseIds.delete(runtime.agentId);
|
|
@@ -5829,13 +5884,12 @@ var messageReceivedHandler = async ({
|
|
|
5829
5884
|
roomId: message.roomId,
|
|
5830
5885
|
entityId: message.entityId,
|
|
5831
5886
|
startTime,
|
|
5832
|
-
status: "
|
|
5887
|
+
status: "error",
|
|
5833
5888
|
endTime: Date.now(),
|
|
5834
5889
|
duration: Date.now() - startTime,
|
|
5835
5890
|
error: error.message,
|
|
5836
5891
|
source: "messageHandler"
|
|
5837
5892
|
});
|
|
5838
|
-
throw error;
|
|
5839
5893
|
}
|
|
5840
5894
|
})();
|
|
5841
5895
|
try {
|
|
@@ -5852,10 +5906,10 @@ var reactionReceivedHandler = async ({
|
|
|
5852
5906
|
await runtime.createMemory(message, "messages");
|
|
5853
5907
|
} catch (error) {
|
|
5854
5908
|
if (error.code === "23505") {
|
|
5855
|
-
|
|
5909
|
+
logger19.warn("[Bootstrap] Duplicate reaction memory, skipping");
|
|
5856
5910
|
return;
|
|
5857
5911
|
}
|
|
5858
|
-
|
|
5912
|
+
logger19.error("[Bootstrap] Error in reaction handler:", error);
|
|
5859
5913
|
}
|
|
5860
5914
|
};
|
|
5861
5915
|
var postGeneratedHandler = async ({
|
|
@@ -5866,7 +5920,7 @@ var postGeneratedHandler = async ({
|
|
|
5866
5920
|
roomId,
|
|
5867
5921
|
source
|
|
5868
5922
|
}) => {
|
|
5869
|
-
|
|
5923
|
+
logger19.info("[Bootstrap] Generating new post...");
|
|
5870
5924
|
await runtime.ensureWorldExists({
|
|
5871
5925
|
id: worldId,
|
|
5872
5926
|
name: `${runtime.character.name}'s Feed`,
|
|
@@ -5893,10 +5947,10 @@ var postGeneratedHandler = async ({
|
|
|
5893
5947
|
type: "message"
|
|
5894
5948
|
}
|
|
5895
5949
|
};
|
|
5896
|
-
let state = await runtime.composeState(message,
|
|
5950
|
+
let state = await runtime.composeState(message, [
|
|
5897
5951
|
"PROVIDERS",
|
|
5898
5952
|
"CHARACTER",
|
|
5899
|
-
|
|
5953
|
+
"RECENT_MESSAGES",
|
|
5900
5954
|
"ENTITIES"
|
|
5901
5955
|
]);
|
|
5902
5956
|
const entity = await runtime.getEntityById(runtime.agentId);
|
|
@@ -5928,7 +5982,7 @@ var postGeneratedHandler = async ({
|
|
|
5928
5982
|
}
|
|
5929
5983
|
retries++;
|
|
5930
5984
|
if (!responseContent?.thought || !responseContent?.actions) {
|
|
5931
|
-
|
|
5985
|
+
logger19.warn("[Bootstrap] *** Missing required fields, retrying... ***");
|
|
5932
5986
|
}
|
|
5933
5987
|
}
|
|
5934
5988
|
state = await runtime.composeState(message, responseContent?.providers);
|
|
@@ -5941,7 +5995,10 @@ var postGeneratedHandler = async ({
|
|
|
5941
5995
|
});
|
|
5942
5996
|
const parsedXmlResponse = parseKeyValueXml(xmlResponseText);
|
|
5943
5997
|
if (!parsedXmlResponse) {
|
|
5944
|
-
|
|
5998
|
+
logger19.error(
|
|
5999
|
+
"[Bootstrap] Failed to parse XML response for post creation. Raw response:",
|
|
6000
|
+
xmlResponseText
|
|
6001
|
+
);
|
|
5945
6002
|
return;
|
|
5946
6003
|
}
|
|
5947
6004
|
function cleanupPostText(text) {
|
|
@@ -5957,7 +6014,7 @@ var postGeneratedHandler = async ({
|
|
|
5957
6014
|
if (RM) {
|
|
5958
6015
|
for (const m of RM.data.recentMessages) {
|
|
5959
6016
|
if (cleanedText === m.content.text) {
|
|
5960
|
-
|
|
6017
|
+
logger19.log("[Bootstrap] Already recently posted that, retrying", cleanedText);
|
|
5961
6018
|
postGeneratedHandler({
|
|
5962
6019
|
runtime,
|
|
5963
6020
|
callback,
|
|
@@ -5975,7 +6032,7 @@ var postGeneratedHandler = async ({
|
|
|
5975
6032
|
const googleRefusalRegex = /(i\s+can'?t\s+help\s+with\s+that|that\s+goes\s+against\s+(our\s+)?(policy|policies)|i'?m\s+still\s+learning|response\s+must\s+follow\s+(usage|safety)\s+policies|i'?ve\s+been\s+designed\s+to\s+avoid\s+that)/i;
|
|
5976
6033
|
const generalRefusalRegex = /(response\s+was\s+withheld|content\s+was\s+filtered|this\s+request\s+cannot\s+be\s+completed|violates\s+our\s+safety\s+policy|content\s+is\s+not\s+available)/i;
|
|
5977
6034
|
if (oaiRefusalRegex.test(cleanedText) || anthropicRefusalRegex.test(cleanedText) || googleRefusalRegex.test(cleanedText) || generalRefusalRegex.test(cleanedText)) {
|
|
5978
|
-
|
|
6035
|
+
logger19.log("[Bootstrap] Got prompt moderation refusal, retrying", cleanedText);
|
|
5979
6036
|
postGeneratedHandler({
|
|
5980
6037
|
runtime,
|
|
5981
6038
|
callback,
|
|
@@ -6009,9 +6066,9 @@ var postGeneratedHandler = async ({
|
|
|
6009
6066
|
var syncSingleUser = async (entityId, runtime, serverId, channelId, type, source) => {
|
|
6010
6067
|
try {
|
|
6011
6068
|
const entity = await runtime.getEntityById(entityId);
|
|
6012
|
-
|
|
6069
|
+
logger19.info(`[Bootstrap] Syncing user: ${entity?.metadata?.[source]?.username || entityId}`);
|
|
6013
6070
|
if (!channelId) {
|
|
6014
|
-
|
|
6071
|
+
logger19.warn(`[Bootstrap] Cannot sync user ${entity?.id} without a valid channelId`);
|
|
6015
6072
|
return;
|
|
6016
6073
|
}
|
|
6017
6074
|
const roomId = createUniqueUuid4(runtime, channelId);
|
|
@@ -6027,9 +6084,11 @@ var syncSingleUser = async (entityId, runtime, serverId, channelId, type, source
|
|
|
6027
6084
|
type,
|
|
6028
6085
|
worldId
|
|
6029
6086
|
});
|
|
6030
|
-
|
|
6087
|
+
logger19.success(`[Bootstrap] Successfully synced user: ${entity?.id}`);
|
|
6031
6088
|
} catch (error) {
|
|
6032
|
-
|
|
6089
|
+
logger19.error(
|
|
6090
|
+
`[Bootstrap] Error syncing user: ${error instanceof Error ? error.message : String(error)}`
|
|
6091
|
+
);
|
|
6033
6092
|
}
|
|
6034
6093
|
};
|
|
6035
6094
|
var handleServerSync = async ({
|
|
@@ -6040,7 +6099,7 @@ var handleServerSync = async ({
|
|
|
6040
6099
|
source,
|
|
6041
6100
|
onComplete
|
|
6042
6101
|
}) => {
|
|
6043
|
-
|
|
6102
|
+
logger19.debug(`[Bootstrap] Handling server sync event for server: ${world.name}`);
|
|
6044
6103
|
try {
|
|
6045
6104
|
await runtime.ensureWorldExists({
|
|
6046
6105
|
id: world.id,
|
|
@@ -6070,14 +6129,14 @@ var handleServerSync = async ({
|
|
|
6070
6129
|
const entityBatch = entities.slice(i2, i2 + batchSize);
|
|
6071
6130
|
const firstRoomUserIsIn = rooms.length > 0 ? rooms[0] : null;
|
|
6072
6131
|
if (!firstRoomUserIsIn) {
|
|
6073
|
-
|
|
6132
|
+
logger19.warn(`[Bootstrap] No rooms found for syncing users`);
|
|
6074
6133
|
continue;
|
|
6075
6134
|
}
|
|
6076
6135
|
await Promise.all(
|
|
6077
6136
|
entityBatch.map(async (entity) => {
|
|
6078
6137
|
try {
|
|
6079
6138
|
if (!entity?.id) {
|
|
6080
|
-
|
|
6139
|
+
logger19.warn(`[Bootstrap] No entity ID found for syncing users`);
|
|
6081
6140
|
return;
|
|
6082
6141
|
}
|
|
6083
6142
|
await runtime.ensureConnection({
|
|
@@ -6092,7 +6151,7 @@ var handleServerSync = async ({
|
|
|
6092
6151
|
worldId: world.id
|
|
6093
6152
|
});
|
|
6094
6153
|
} catch (err) {
|
|
6095
|
-
|
|
6154
|
+
logger19.warn(`[Bootstrap] Failed to sync user ${entity.metadata?.username}: ${err}`);
|
|
6096
6155
|
}
|
|
6097
6156
|
})
|
|
6098
6157
|
);
|
|
@@ -6101,10 +6160,10 @@ var handleServerSync = async ({
|
|
|
6101
6160
|
}
|
|
6102
6161
|
}
|
|
6103
6162
|
}
|
|
6104
|
-
|
|
6163
|
+
logger19.debug(`Successfully synced standardized world structure for ${world.name}`);
|
|
6105
6164
|
onComplete?.();
|
|
6106
6165
|
} catch (error) {
|
|
6107
|
-
|
|
6166
|
+
logger19.error(
|
|
6108
6167
|
`Error processing standardized server data: ${error instanceof Error ? error.message : String(error)}`
|
|
6109
6168
|
);
|
|
6110
6169
|
}
|
|
@@ -6115,7 +6174,7 @@ var controlMessageHandler = async ({
|
|
|
6115
6174
|
source
|
|
6116
6175
|
}) => {
|
|
6117
6176
|
try {
|
|
6118
|
-
|
|
6177
|
+
logger19.debug(
|
|
6119
6178
|
`[controlMessageHandler] Processing control message: ${message.payload.action} for room ${message.roomId}`
|
|
6120
6179
|
);
|
|
6121
6180
|
const serviceNames = Array.from(runtime.getAllServices().keys());
|
|
@@ -6133,24 +6192,24 @@ var controlMessageHandler = async ({
|
|
|
6133
6192
|
roomId: message.roomId
|
|
6134
6193
|
}
|
|
6135
6194
|
});
|
|
6136
|
-
|
|
6195
|
+
logger19.debug(
|
|
6137
6196
|
`[controlMessageHandler] Control message ${message.payload.action} sent successfully`
|
|
6138
6197
|
);
|
|
6139
6198
|
} else {
|
|
6140
|
-
|
|
6199
|
+
logger19.error("[controlMessageHandler] WebSocket service does not have sendMessage method");
|
|
6141
6200
|
}
|
|
6142
6201
|
} else {
|
|
6143
|
-
|
|
6202
|
+
logger19.error("[controlMessageHandler] No WebSocket service found to send control message");
|
|
6144
6203
|
}
|
|
6145
6204
|
} catch (error) {
|
|
6146
|
-
|
|
6205
|
+
logger19.error(`[controlMessageHandler] Error processing control message: ${error}`);
|
|
6147
6206
|
}
|
|
6148
6207
|
};
|
|
6149
6208
|
var events = {
|
|
6150
6209
|
[EventType2.MESSAGE_RECEIVED]: [
|
|
6151
6210
|
async (payload) => {
|
|
6152
6211
|
if (!payload.callback) {
|
|
6153
|
-
|
|
6212
|
+
logger19.error("No callback provided for message");
|
|
6154
6213
|
return;
|
|
6155
6214
|
}
|
|
6156
6215
|
await messageReceivedHandler({
|
|
@@ -6164,7 +6223,7 @@ var events = {
|
|
|
6164
6223
|
[EventType2.VOICE_MESSAGE_RECEIVED]: [
|
|
6165
6224
|
async (payload) => {
|
|
6166
6225
|
if (!payload.callback) {
|
|
6167
|
-
|
|
6226
|
+
logger19.error("No callback provided for voice message");
|
|
6168
6227
|
return;
|
|
6169
6228
|
}
|
|
6170
6229
|
await messageReceivedHandler({
|
|
@@ -6189,7 +6248,7 @@ var events = {
|
|
|
6189
6248
|
],
|
|
6190
6249
|
[EventType2.MESSAGE_SENT]: [
|
|
6191
6250
|
async (payload) => {
|
|
6192
|
-
|
|
6251
|
+
logger19.debug(`[Bootstrap] Message sent: ${payload.message.content.text}`);
|
|
6193
6252
|
}
|
|
6194
6253
|
],
|
|
6195
6254
|
[EventType2.WORLD_JOINED]: [
|
|
@@ -6205,15 +6264,15 @@ var events = {
|
|
|
6205
6264
|
[EventType2.ENTITY_JOINED]: [
|
|
6206
6265
|
async (payload) => {
|
|
6207
6266
|
if (!payload.worldId) {
|
|
6208
|
-
|
|
6267
|
+
logger19.error("[Bootstrap] No callback provided for entity joined");
|
|
6209
6268
|
return;
|
|
6210
6269
|
}
|
|
6211
6270
|
if (!payload.roomId) {
|
|
6212
|
-
|
|
6271
|
+
logger19.error("[Bootstrap] No roomId provided for entity joined");
|
|
6213
6272
|
return;
|
|
6214
6273
|
}
|
|
6215
6274
|
if (!payload.metadata?.type) {
|
|
6216
|
-
|
|
6275
|
+
logger19.error("[Bootstrap] No type provided for entity joined");
|
|
6217
6276
|
return;
|
|
6218
6277
|
}
|
|
6219
6278
|
await syncSingleUser(
|
|
@@ -6238,32 +6297,36 @@ var events = {
|
|
|
6238
6297
|
};
|
|
6239
6298
|
await payload.runtime.updateEntity(entity);
|
|
6240
6299
|
}
|
|
6241
|
-
|
|
6300
|
+
logger19.info(`[Bootstrap] User ${payload.entityId} left world ${payload.worldId}`);
|
|
6242
6301
|
} catch (error) {
|
|
6243
|
-
|
|
6302
|
+
logger19.error(`[Bootstrap] Error handling user left: ${error.message}`);
|
|
6244
6303
|
}
|
|
6245
6304
|
}
|
|
6246
6305
|
],
|
|
6247
6306
|
[EventType2.ACTION_STARTED]: [
|
|
6248
6307
|
async (payload) => {
|
|
6249
|
-
|
|
6308
|
+
logger19.debug(`[Bootstrap] Action started: ${payload.actionName} (${payload.actionId})`);
|
|
6250
6309
|
}
|
|
6251
6310
|
],
|
|
6252
6311
|
[EventType2.ACTION_COMPLETED]: [
|
|
6253
6312
|
async (payload) => {
|
|
6254
6313
|
const status = payload.error ? `failed: ${payload.error.message}` : "completed";
|
|
6255
|
-
|
|
6314
|
+
logger19.debug(`[Bootstrap] Action ${status}: ${payload.actionName} (${payload.actionId})`);
|
|
6256
6315
|
}
|
|
6257
6316
|
],
|
|
6258
6317
|
[EventType2.EVALUATOR_STARTED]: [
|
|
6259
6318
|
async (payload) => {
|
|
6260
|
-
|
|
6319
|
+
logger19.debug(
|
|
6320
|
+
`[Bootstrap] Evaluator started: ${payload.evaluatorName} (${payload.evaluatorId})`
|
|
6321
|
+
);
|
|
6261
6322
|
}
|
|
6262
6323
|
],
|
|
6263
6324
|
[EventType2.EVALUATOR_COMPLETED]: [
|
|
6264
6325
|
async (payload) => {
|
|
6265
6326
|
const status = payload.error ? `failed: ${payload.error.message}` : "completed";
|
|
6266
|
-
|
|
6327
|
+
logger19.debug(
|
|
6328
|
+
`[Bootstrap] Evaluator ${status}: ${payload.evaluatorName} (${payload.evaluatorId})`
|
|
6329
|
+
);
|
|
6267
6330
|
}
|
|
6268
6331
|
],
|
|
6269
6332
|
CONTROL_MESSAGE: [controlMessageHandler]
|