@elizaos/plugin-bootstrap 1.3.1 → 1.4.2
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 +284 -109
- package/dist/index.js.map +1 -1
- package/package.json +4 -4
package/dist/index.js
CHANGED
|
@@ -83,6 +83,7 @@ import {
|
|
|
83
83
|
ModelType as ModelType14,
|
|
84
84
|
parseKeyValueXml as parseKeyValueXml9,
|
|
85
85
|
postCreationTemplate,
|
|
86
|
+
parseBooleanFromText as parseBooleanFromText2,
|
|
86
87
|
Role as Role2,
|
|
87
88
|
shouldRespondTemplate,
|
|
88
89
|
truncateToCompleteSentence,
|
|
@@ -337,7 +338,7 @@ var choiceAction = {
|
|
|
337
338
|
}
|
|
338
339
|
return pendingTasks && pendingTasks.length > 0 && pendingTasks.some((task) => task.metadata?.options);
|
|
339
340
|
} catch (error) {
|
|
340
|
-
logger.error("Error validating choice action
|
|
341
|
+
logger.error({ error }, "Error validating choice action");
|
|
341
342
|
return false;
|
|
342
343
|
}
|
|
343
344
|
},
|
|
@@ -518,7 +519,7 @@ ${task.options?.map((opt) => `- ${opt.name}: ${opt.description}`).join("\n")}`;
|
|
|
518
519
|
success: true
|
|
519
520
|
};
|
|
520
521
|
} catch (error) {
|
|
521
|
-
logger.error("Error executing task with option
|
|
522
|
+
logger.error({ error }, "Error executing task with option");
|
|
522
523
|
await callback?.({
|
|
523
524
|
text: "There was an error processing your selection.",
|
|
524
525
|
actions: ["SELECT_OPTION_ERROR"],
|
|
@@ -744,7 +745,7 @@ var followRoomAction = {
|
|
|
744
745
|
success: true
|
|
745
746
|
};
|
|
746
747
|
} catch (error) {
|
|
747
|
-
logger2.error("Error following room
|
|
748
|
+
logger2.error({ error }, "Error following room");
|
|
748
749
|
return {
|
|
749
750
|
text: "Failed to follow room",
|
|
750
751
|
values: {
|
|
@@ -1409,7 +1410,7 @@ var muteRoomAction = {
|
|
|
1409
1410
|
success: true
|
|
1410
1411
|
};
|
|
1411
1412
|
} catch (error) {
|
|
1412
|
-
logger3.error("Error muting room
|
|
1413
|
+
logger3.error({ error }, "Error muting room");
|
|
1413
1414
|
return {
|
|
1414
1415
|
text: "Failed to mute room",
|
|
1415
1416
|
values: {
|
|
@@ -2059,7 +2060,7 @@ IMPORTANT: Your response must ONLY contain the <response></response> XML block a
|
|
|
2059
2060
|
await runtime.updateWorld(world);
|
|
2060
2061
|
logger5.info(`Updated roles in world metadata for server ${serverId}`);
|
|
2061
2062
|
} catch (error) {
|
|
2062
|
-
logger5.error("Failed to save world updates
|
|
2063
|
+
logger5.error({ error }, "Failed to save world updates");
|
|
2063
2064
|
return {
|
|
2064
2065
|
text: "Failed to save role updates",
|
|
2065
2066
|
values: {
|
|
@@ -2900,7 +2901,7 @@ async function processSettingUpdates(runtime, serverId, worldSettings, updates)
|
|
|
2900
2901
|
}
|
|
2901
2902
|
return { updatedAny, messages };
|
|
2902
2903
|
} catch (error) {
|
|
2903
|
-
logger7.error("Error processing setting updates:"
|
|
2904
|
+
logger7.error({ error }, "Error processing setting updates:");
|
|
2904
2905
|
return {
|
|
2905
2906
|
updatedAny: false,
|
|
2906
2907
|
messages: ["Error occurred while updating settings"]
|
|
@@ -4082,7 +4083,7 @@ var unmuteRoomAction = {
|
|
|
4082
4083
|
success: true
|
|
4083
4084
|
};
|
|
4084
4085
|
} catch (error) {
|
|
4085
|
-
logger8.error("Error unmuting room:"
|
|
4086
|
+
logger8.error({ error }, "Error unmuting room:");
|
|
4086
4087
|
return {
|
|
4087
4088
|
text: "Failed to unmute room",
|
|
4088
4089
|
values: {
|
|
@@ -4666,7 +4667,7 @@ function resolveEntity(entityId, entities) {
|
|
|
4666
4667
|
async function handler(runtime, message, state) {
|
|
4667
4668
|
const { agentId, roomId } = message;
|
|
4668
4669
|
if (!agentId || !roomId) {
|
|
4669
|
-
logger10.warn("Missing agentId or roomId in message"
|
|
4670
|
+
logger10.warn({ message }, "Missing agentId or roomId in message");
|
|
4670
4671
|
return;
|
|
4671
4672
|
}
|
|
4672
4673
|
const [existingRelationships, entities, knownFacts] = await Promise.all([
|
|
@@ -4697,20 +4698,20 @@ async function handler(runtime, message, state) {
|
|
|
4697
4698
|
prompt
|
|
4698
4699
|
});
|
|
4699
4700
|
if (!response) {
|
|
4700
|
-
logger10.warn("Getting reflection failed - empty response"
|
|
4701
|
+
logger10.warn({ prompt }, "Getting reflection failed - empty response");
|
|
4701
4702
|
return;
|
|
4702
4703
|
}
|
|
4703
4704
|
const reflection = parseKeyValueXml8(response);
|
|
4704
4705
|
if (!reflection) {
|
|
4705
|
-
logger10.warn("Getting reflection failed - failed to parse XML"
|
|
4706
|
+
logger10.warn({ response }, "Getting reflection failed - failed to parse XML");
|
|
4706
4707
|
return;
|
|
4707
4708
|
}
|
|
4708
4709
|
if (!reflection.facts) {
|
|
4709
|
-
logger10.warn("Getting reflection failed - invalid facts structure"
|
|
4710
|
+
logger10.warn({ reflection }, "Getting reflection failed - invalid facts structure");
|
|
4710
4711
|
return;
|
|
4711
4712
|
}
|
|
4712
4713
|
if (!reflection.relationships) {
|
|
4713
|
-
logger10.warn("Getting reflection failed - invalid relationships structure"
|
|
4714
|
+
logger10.warn({ reflection }, "Getting reflection failed - invalid relationships structure");
|
|
4714
4715
|
return;
|
|
4715
4716
|
}
|
|
4716
4717
|
let factsArray = [];
|
|
@@ -4779,7 +4780,7 @@ async function handler(runtime, message, state) {
|
|
|
4779
4780
|
message?.id || ""
|
|
4780
4781
|
);
|
|
4781
4782
|
} catch (error) {
|
|
4782
|
-
logger10.error("Error in reflection handler:"
|
|
4783
|
+
logger10.error({ error }, "Error in reflection handler:");
|
|
4783
4784
|
return;
|
|
4784
4785
|
}
|
|
4785
4786
|
}
|
|
@@ -5105,7 +5106,7 @@ ${values}`;
|
|
|
5105
5106
|
(msg) => msg.content?.type === "action_result" && msg.metadata?.type === "action_result"
|
|
5106
5107
|
);
|
|
5107
5108
|
} catch (error) {
|
|
5108
|
-
logger11?.error("Failed to retrieve action memories:"
|
|
5109
|
+
logger11?.error({ error }, "Failed to retrieve action memories:");
|
|
5109
5110
|
}
|
|
5110
5111
|
let actionMemoriesText = "";
|
|
5111
5112
|
if (recentActionMemories.length > 0) {
|
|
@@ -5351,7 +5352,7 @@ var capabilitiesProvider = {
|
|
|
5351
5352
|
${formattedCapabilities}`
|
|
5352
5353
|
};
|
|
5353
5354
|
} catch (error) {
|
|
5354
|
-
logger12.error("Error in capabilities provider:"
|
|
5355
|
+
logger12.error({ error }, "Error in capabilities provider:");
|
|
5355
5356
|
return {
|
|
5356
5357
|
text: "Error retrieving capabilities from services."
|
|
5357
5358
|
};
|
|
@@ -5530,7 +5531,7 @@ var choiceProvider = {
|
|
|
5530
5531
|
text: output
|
|
5531
5532
|
};
|
|
5532
5533
|
} catch (error) {
|
|
5533
|
-
logger13.error("Error in options provider:"
|
|
5534
|
+
logger13.error({ error }, "Error in options provider:");
|
|
5534
5535
|
return {
|
|
5535
5536
|
data: {
|
|
5536
5537
|
tasks: []
|
|
@@ -5756,7 +5757,7 @@ var factsProvider = {
|
|
|
5756
5757
|
text
|
|
5757
5758
|
};
|
|
5758
5759
|
} catch (error) {
|
|
5759
|
-
logger14.error("Error in factsProvider:"
|
|
5760
|
+
logger14.error({ error }, "Error in factsProvider:");
|
|
5760
5761
|
return {
|
|
5761
5762
|
values: {
|
|
5762
5763
|
facts: ""
|
|
@@ -6009,7 +6010,7 @@ ${runText}`;
|
|
|
6009
6010
|
text
|
|
6010
6011
|
};
|
|
6011
6012
|
} catch (error) {
|
|
6012
|
-
logger15.error("Error in recentMessagesProvider:"
|
|
6013
|
+
logger15.error({ error }, "Error in recentMessagesProvider:");
|
|
6013
6014
|
return {
|
|
6014
6015
|
data: {
|
|
6015
6016
|
recentMessages: [],
|
|
@@ -6512,7 +6513,7 @@ var worldProvider = {
|
|
|
6512
6513
|
dynamic: true,
|
|
6513
6514
|
get: async (runtime, message) => {
|
|
6514
6515
|
try {
|
|
6515
|
-
logger18.debug("[\u{1F310}] World provider activated for roomId:"
|
|
6516
|
+
logger18.debug({ roomId: message.roomId }, "[\u{1F310}] World provider activated for roomId:");
|
|
6516
6517
|
const currentRoom = await runtime.getRoom(message.roomId);
|
|
6517
6518
|
if (!currentRoom) {
|
|
6518
6519
|
logger18.warn(`World provider: Room not found for roomId ${message.roomId}`);
|
|
@@ -6742,7 +6743,7 @@ var TaskService = class _TaskService extends Service {
|
|
|
6742
6743
|
try {
|
|
6743
6744
|
await this.checkTasks();
|
|
6744
6745
|
} catch (error) {
|
|
6745
|
-
logger19.error("[Bootstrap] Error checking tasks:"
|
|
6746
|
+
logger19.error({ error }, "[Bootstrap] Error checking tasks:");
|
|
6746
6747
|
}
|
|
6747
6748
|
}, this.TICK_INTERVAL);
|
|
6748
6749
|
}
|
|
@@ -6771,7 +6772,10 @@ var TaskService = class _TaskService extends Service {
|
|
|
6771
6772
|
continue;
|
|
6772
6773
|
}
|
|
6773
6774
|
} catch (error) {
|
|
6774
|
-
logger19.error(
|
|
6775
|
+
logger19.error(
|
|
6776
|
+
{ error, taskName: task.name },
|
|
6777
|
+
`[Bootstrap] Error validating task ${task.name}:`
|
|
6778
|
+
);
|
|
6775
6779
|
continue;
|
|
6776
6780
|
}
|
|
6777
6781
|
}
|
|
@@ -6826,7 +6830,7 @@ var TaskService = class _TaskService extends Service {
|
|
|
6826
6830
|
}
|
|
6827
6831
|
}
|
|
6828
6832
|
} catch (error) {
|
|
6829
|
-
logger19.error("[Bootstrap] Error checking tasks:"
|
|
6833
|
+
logger19.error({ error }, "[Bootstrap] Error checking tasks:");
|
|
6830
6834
|
}
|
|
6831
6835
|
}
|
|
6832
6836
|
/**
|
|
@@ -6865,7 +6869,7 @@ var TaskService = class _TaskService extends Service {
|
|
|
6865
6869
|
);
|
|
6866
6870
|
}
|
|
6867
6871
|
} catch (error) {
|
|
6868
|
-
logger19.error(`[Bootstrap] Error executing task ${task.id}
|
|
6872
|
+
logger19.error({ error, taskId: task.id }, `[Bootstrap] Error executing task ${task.id}:`);
|
|
6869
6873
|
}
|
|
6870
6874
|
}
|
|
6871
6875
|
/**
|
|
@@ -6913,7 +6917,7 @@ async function processAttachments(attachments, runtime) {
|
|
|
6913
6917
|
if (!attachments || attachments.length === 0) {
|
|
6914
6918
|
return [];
|
|
6915
6919
|
}
|
|
6916
|
-
|
|
6920
|
+
runtime.logger.debug(`[Bootstrap] Processing ${attachments.length} attachment(s)`);
|
|
6917
6921
|
const processedAttachments = [];
|
|
6918
6922
|
for (const attachment of attachments) {
|
|
6919
6923
|
try {
|
|
@@ -6921,7 +6925,7 @@ async function processAttachments(attachments, runtime) {
|
|
|
6921
6925
|
const isRemote = /^(http|https):\/\//.test(attachment.url);
|
|
6922
6926
|
const url = isRemote ? attachment.url : getLocalServerUrl(attachment.url);
|
|
6923
6927
|
if (attachment.contentType === ContentType2.IMAGE && !attachment.description) {
|
|
6924
|
-
|
|
6928
|
+
runtime.logger.debug(`[Bootstrap] Generating description for image: ${attachment.url}`);
|
|
6925
6929
|
let imageUrl = url;
|
|
6926
6930
|
if (!isRemote) {
|
|
6927
6931
|
const res = await fetch(url);
|
|
@@ -6942,24 +6946,24 @@ async function processAttachments(attachments, runtime) {
|
|
|
6942
6946
|
processedAttachment.description = parsedXml.description;
|
|
6943
6947
|
processedAttachment.title = parsedXml.title || "Image";
|
|
6944
6948
|
processedAttachment.text = parsedXml.text;
|
|
6945
|
-
|
|
6949
|
+
runtime.logger.debug(
|
|
6946
6950
|
`[Bootstrap] Generated description: ${processedAttachment.description?.substring(0, 100)}...`
|
|
6947
6951
|
);
|
|
6948
6952
|
} else {
|
|
6949
|
-
|
|
6953
|
+
runtime.logger.warn(`[Bootstrap] Failed to parse XML response for image description`);
|
|
6950
6954
|
}
|
|
6951
6955
|
} else if (response && typeof response === "object" && "description" in response) {
|
|
6952
6956
|
processedAttachment.description = response.description;
|
|
6953
6957
|
processedAttachment.title = response.title || "Image";
|
|
6954
6958
|
processedAttachment.text = response.description;
|
|
6955
|
-
|
|
6959
|
+
runtime.logger.debug(
|
|
6956
6960
|
`[Bootstrap] Generated description: ${processedAttachment.description?.substring(0, 100)}...`
|
|
6957
6961
|
);
|
|
6958
6962
|
} else {
|
|
6959
|
-
|
|
6963
|
+
runtime.logger.warn(`[Bootstrap] Unexpected response format for image description`);
|
|
6960
6964
|
}
|
|
6961
6965
|
} catch (error) {
|
|
6962
|
-
|
|
6966
|
+
runtime.logger.error({ error }, `[Bootstrap] Error generating image description:`);
|
|
6963
6967
|
}
|
|
6964
6968
|
} else if (attachment.contentType === ContentType2.DOCUMENT && !attachment.text) {
|
|
6965
6969
|
const res = await fetch(url);
|
|
@@ -6967,20 +6971,23 @@ async function processAttachments(attachments, runtime) {
|
|
|
6967
6971
|
const contentType = res.headers.get("content-type") || "";
|
|
6968
6972
|
const isPlainText = contentType.startsWith("text/plain");
|
|
6969
6973
|
if (isPlainText) {
|
|
6970
|
-
|
|
6974
|
+
runtime.logger.debug(`[Bootstrap] Processing plain text document: ${attachment.url}`);
|
|
6971
6975
|
const textContent = await res.text();
|
|
6972
6976
|
processedAttachment.text = textContent;
|
|
6973
6977
|
processedAttachment.title = processedAttachment.title || "Text File";
|
|
6974
|
-
|
|
6978
|
+
runtime.logger.debug(
|
|
6975
6979
|
`[Bootstrap] Extracted text content (first 100 chars): ${processedAttachment.text?.substring(0, 100)}...`
|
|
6976
6980
|
);
|
|
6977
6981
|
} else {
|
|
6978
|
-
|
|
6982
|
+
runtime.logger.warn(`[Bootstrap] Skipping non-plain-text document: ${contentType}`);
|
|
6979
6983
|
}
|
|
6980
6984
|
}
|
|
6981
6985
|
processedAttachments.push(processedAttachment);
|
|
6982
6986
|
} catch (error) {
|
|
6983
|
-
|
|
6987
|
+
runtime.logger.error(
|
|
6988
|
+
{ error, attachmentUrl: attachment.url },
|
|
6989
|
+
`[Bootstrap] Failed to process attachment ${attachment.url}:`
|
|
6990
|
+
);
|
|
6984
6991
|
processedAttachments.push(attachment);
|
|
6985
6992
|
}
|
|
6986
6993
|
}
|
|
@@ -7025,7 +7032,9 @@ var messageReceivedHandler = async ({
|
|
|
7025
7032
|
const timeoutDuration = 60 * 60 * 1e3;
|
|
7026
7033
|
let timeoutId = void 0;
|
|
7027
7034
|
try {
|
|
7028
|
-
|
|
7035
|
+
runtime.logger.info(
|
|
7036
|
+
`[Bootstrap] Message received from ${message.entityId} in room ${message.roomId}`
|
|
7037
|
+
);
|
|
7029
7038
|
const responseId = v4_default();
|
|
7030
7039
|
if (!latestResponseIds.has(runtime.agentId)) {
|
|
7031
7040
|
latestResponseIds.set(runtime.agentId, /* @__PURE__ */ new Map());
|
|
@@ -7034,6 +7043,12 @@ var messageReceivedHandler = async ({
|
|
|
7034
7043
|
if (!agentResponses) {
|
|
7035
7044
|
throw new Error("Agent responses map not found");
|
|
7036
7045
|
}
|
|
7046
|
+
const previousResponseId = agentResponses.get(message.roomId);
|
|
7047
|
+
if (previousResponseId) {
|
|
7048
|
+
logger20.warn(
|
|
7049
|
+
`[Bootstrap] Updating response ID for room ${message.roomId} from ${previousResponseId} to ${responseId} - this may discard in-progress responses`
|
|
7050
|
+
);
|
|
7051
|
+
}
|
|
7037
7052
|
agentResponses.set(message.roomId, responseId);
|
|
7038
7053
|
const runId = runtime.startRun();
|
|
7039
7054
|
const startTime = Date.now();
|
|
@@ -7045,7 +7060,10 @@ var messageReceivedHandler = async ({
|
|
|
7045
7060
|
entityId: message.entityId,
|
|
7046
7061
|
startTime,
|
|
7047
7062
|
status: "started",
|
|
7048
|
-
source: "messageHandler"
|
|
7063
|
+
source: "messageHandler",
|
|
7064
|
+
// this shouldn't be a standard
|
|
7065
|
+
// but we need to expose content somewhere
|
|
7066
|
+
metadata: message.content
|
|
7049
7067
|
});
|
|
7050
7068
|
const timeoutPromise = new Promise((_, reject) => {
|
|
7051
7069
|
timeoutId = setTimeout(async () => {
|
|
@@ -7068,23 +7086,65 @@ var messageReceivedHandler = async ({
|
|
|
7068
7086
|
const processingPromise = (async () => {
|
|
7069
7087
|
try {
|
|
7070
7088
|
if (message.entityId === runtime.agentId) {
|
|
7071
|
-
|
|
7089
|
+
runtime.logger.debug(`[Bootstrap] Skipping message from self (${runtime.agentId})`);
|
|
7072
7090
|
throw new Error("Message is from the agent itself");
|
|
7073
7091
|
}
|
|
7074
|
-
|
|
7092
|
+
runtime.logger.debug(
|
|
7075
7093
|
`[Bootstrap] Processing message: ${truncateToCompleteSentence(message.content.text || "", 50)}...`
|
|
7076
7094
|
);
|
|
7077
|
-
|
|
7078
|
-
|
|
7079
|
-
runtime.
|
|
7080
|
-
|
|
7081
|
-
|
|
7095
|
+
runtime.logger.debug("[Bootstrap] Saving message to memory and embeddings");
|
|
7096
|
+
if (message.id) {
|
|
7097
|
+
const existingMemory = await runtime.getMemoryById(message.id);
|
|
7098
|
+
if (existingMemory) {
|
|
7099
|
+
runtime.logger.debug("[Bootstrap] Memory already exists, skipping creation");
|
|
7100
|
+
await runtime.addEmbeddingToMemory(message);
|
|
7101
|
+
} else {
|
|
7102
|
+
await Promise.all([
|
|
7103
|
+
runtime.addEmbeddingToMemory(message),
|
|
7104
|
+
runtime.createMemory(message, "messages")
|
|
7105
|
+
]);
|
|
7106
|
+
}
|
|
7107
|
+
} else {
|
|
7108
|
+
await Promise.all([
|
|
7109
|
+
runtime.addEmbeddingToMemory(message),
|
|
7110
|
+
runtime.createMemory(message, "messages")
|
|
7111
|
+
]);
|
|
7112
|
+
}
|
|
7082
7113
|
const agentUserState = await runtime.getParticipantUserState(
|
|
7083
7114
|
message.roomId,
|
|
7084
7115
|
runtime.agentId
|
|
7085
7116
|
);
|
|
7117
|
+
const defLllmOff = parseBooleanFromText2(runtime.getSetting("BOOTSTRAP_DEFLLMOFF"));
|
|
7118
|
+
if (defLllmOff && agentUserState === null) {
|
|
7119
|
+
runtime.logger.debug("bootstrap - LLM is off by default");
|
|
7120
|
+
await runtime.emitEvent(EventType.RUN_ENDED, {
|
|
7121
|
+
runtime,
|
|
7122
|
+
runId,
|
|
7123
|
+
messageId: message.id,
|
|
7124
|
+
roomId: message.roomId,
|
|
7125
|
+
entityId: message.entityId,
|
|
7126
|
+
startTime,
|
|
7127
|
+
status: "off",
|
|
7128
|
+
endTime: Date.now(),
|
|
7129
|
+
duration: Date.now() - startTime,
|
|
7130
|
+
source: "messageHandler"
|
|
7131
|
+
});
|
|
7132
|
+
return;
|
|
7133
|
+
}
|
|
7086
7134
|
if (agentUserState === "MUTED" && !message.content.text?.toLowerCase().includes(runtime.character.name.toLowerCase())) {
|
|
7087
|
-
|
|
7135
|
+
runtime.logger.debug(`[Bootstrap] Ignoring muted room ${message.roomId}`);
|
|
7136
|
+
await runtime.emitEvent(EventType.RUN_ENDED, {
|
|
7137
|
+
runtime,
|
|
7138
|
+
runId,
|
|
7139
|
+
messageId: message.id,
|
|
7140
|
+
roomId: message.roomId,
|
|
7141
|
+
entityId: message.entityId,
|
|
7142
|
+
startTime,
|
|
7143
|
+
status: "muted",
|
|
7144
|
+
endTime: Date.now(),
|
|
7145
|
+
duration: Date.now() - startTime,
|
|
7146
|
+
source: "messageHandler"
|
|
7147
|
+
});
|
|
7088
7148
|
return;
|
|
7089
7149
|
}
|
|
7090
7150
|
let state = await runtime.composeState(
|
|
@@ -7116,50 +7176,50 @@ var messageReceivedHandler = async ({
|
|
|
7116
7176
|
state,
|
|
7117
7177
|
template: runtime.character.templates?.shouldRespondTemplate || shouldRespondTemplate
|
|
7118
7178
|
});
|
|
7119
|
-
|
|
7179
|
+
runtime.logger.debug(
|
|
7120
7180
|
`[Bootstrap] Evaluating response for ${runtime.character.name}
|
|
7121
7181
|
Prompt: ${shouldRespondPrompt}`
|
|
7122
7182
|
);
|
|
7123
7183
|
const response = await runtime.useModel(ModelType14.TEXT_SMALL, {
|
|
7124
7184
|
prompt: shouldRespondPrompt
|
|
7125
7185
|
});
|
|
7126
|
-
|
|
7186
|
+
runtime.logger.debug(
|
|
7127
7187
|
`[Bootstrap] Response evaluation for ${runtime.character.name}:
|
|
7128
7188
|
${response}`
|
|
7129
7189
|
);
|
|
7130
|
-
|
|
7190
|
+
runtime.logger.debug(`[Bootstrap] Response type: ${typeof response}`);
|
|
7131
7191
|
const responseObject = parseKeyValueXml9(response);
|
|
7132
|
-
|
|
7192
|
+
runtime.logger.debug({ responseObject }, "[Bootstrap] Parsed response:");
|
|
7133
7193
|
const nonResponseActions = ["IGNORE", "NONE"];
|
|
7134
7194
|
shouldRespond = responseObject?.action && !nonResponseActions.includes(responseObject.action.toUpperCase());
|
|
7135
7195
|
} else {
|
|
7136
|
-
|
|
7196
|
+
runtime.logger.debug(
|
|
7137
7197
|
`[Bootstrap] Skipping shouldRespond check for ${runtime.character.name} because ${room?.type} ${room?.source}`
|
|
7138
7198
|
);
|
|
7139
7199
|
shouldRespond = true;
|
|
7140
7200
|
}
|
|
7141
7201
|
let responseMessages = [];
|
|
7142
|
-
|
|
7143
|
-
console.log("shouldSkipShouldRespond", shouldSkipShouldRespond);
|
|
7202
|
+
let responseContent = null;
|
|
7144
7203
|
if (shouldRespond) {
|
|
7145
7204
|
state = await runtime.composeState(message, ["ACTIONS"]);
|
|
7146
7205
|
if (!state.values.actionNames) {
|
|
7147
|
-
|
|
7206
|
+
runtime.logger.warn(
|
|
7207
|
+
"actionNames data missing from state, even though it was requested"
|
|
7208
|
+
);
|
|
7148
7209
|
}
|
|
7149
7210
|
const prompt = composePromptFromState10({
|
|
7150
7211
|
state,
|
|
7151
7212
|
template: runtime.character.templates?.messageHandlerTemplate || messageHandlerTemplate
|
|
7152
7213
|
});
|
|
7153
|
-
let responseContent = null;
|
|
7154
7214
|
let retries = 0;
|
|
7155
7215
|
const maxRetries = 3;
|
|
7156
7216
|
while (retries < maxRetries && (!responseContent?.thought || !responseContent?.actions)) {
|
|
7157
7217
|
let response = await runtime.useModel(ModelType14.TEXT_LARGE, {
|
|
7158
7218
|
prompt
|
|
7159
7219
|
});
|
|
7160
|
-
|
|
7220
|
+
runtime.logger.debug({ response }, "[Bootstrap] *** Raw LLM Response ***");
|
|
7161
7221
|
const parsedXml = parseKeyValueXml9(response);
|
|
7162
|
-
|
|
7222
|
+
runtime.logger.debug({ parsedXml }, "[Bootstrap] *** Parsed XML Content ***");
|
|
7163
7223
|
if (parsedXml) {
|
|
7164
7224
|
responseContent = {
|
|
7165
7225
|
...parsedXml,
|
|
@@ -7174,17 +7234,15 @@ ${response}`
|
|
|
7174
7234
|
}
|
|
7175
7235
|
retries++;
|
|
7176
7236
|
if (!responseContent?.thought || !responseContent?.actions) {
|
|
7177
|
-
|
|
7178
|
-
|
|
7179
|
-
|
|
7180
|
-
parsedXml,
|
|
7181
|
-
responseContent
|
|
7237
|
+
runtime.logger.warn(
|
|
7238
|
+
{ response, parsedXml, responseContent },
|
|
7239
|
+
"[Bootstrap] *** Missing required fields (thought or actions), retrying... ***"
|
|
7182
7240
|
);
|
|
7183
7241
|
}
|
|
7184
7242
|
}
|
|
7185
7243
|
const currentResponseId = agentResponses.get(message.roomId);
|
|
7186
7244
|
if (currentResponseId !== responseId) {
|
|
7187
|
-
|
|
7245
|
+
runtime.logger.info(
|
|
7188
7246
|
`Response discarded - newer message being processed for agent: ${runtime.agentId}, room: ${message.roomId}`
|
|
7189
7247
|
);
|
|
7190
7248
|
return;
|
|
@@ -7232,24 +7290,74 @@ ${response}`
|
|
|
7232
7290
|
}
|
|
7233
7291
|
if (responseContent && responseContent.simple && responseContent.text) {
|
|
7234
7292
|
if (responseContent.providers && responseContent.providers.length > 0) {
|
|
7235
|
-
|
|
7293
|
+
runtime.logger.debug(
|
|
7294
|
+
{ providers: responseContent.providers },
|
|
7295
|
+
"[Bootstrap] Simple response used providers"
|
|
7296
|
+
);
|
|
7236
7297
|
}
|
|
7237
7298
|
await callback(responseContent);
|
|
7238
7299
|
} else {
|
|
7239
|
-
await runtime.processActions(message, responseMessages, state,
|
|
7300
|
+
await runtime.processActions(message, responseMessages, state, async (content) => {
|
|
7301
|
+
runtime.logger.debug({ content }, "action callback");
|
|
7302
|
+
if (responseContent) {
|
|
7303
|
+
responseContent.actionCallbacks = content;
|
|
7304
|
+
}
|
|
7305
|
+
return callback(content);
|
|
7306
|
+
});
|
|
7240
7307
|
}
|
|
7241
|
-
await runtime.evaluate(
|
|
7308
|
+
await runtime.evaluate(
|
|
7309
|
+
message,
|
|
7310
|
+
state,
|
|
7311
|
+
shouldRespond,
|
|
7312
|
+
async (content) => {
|
|
7313
|
+
runtime.logger.debug({ content }, "evaluate callback");
|
|
7314
|
+
if (responseContent) {
|
|
7315
|
+
responseContent.evalCallbacks = content;
|
|
7316
|
+
}
|
|
7317
|
+
return callback(content);
|
|
7318
|
+
},
|
|
7319
|
+
responseMessages
|
|
7320
|
+
);
|
|
7242
7321
|
} else {
|
|
7243
|
-
|
|
7322
|
+
runtime.logger.debug(
|
|
7323
|
+
"[Bootstrap] Agent decided not to respond (shouldRespond is false)."
|
|
7324
|
+
);
|
|
7244
7325
|
const currentResponseId = agentResponses.get(message.roomId);
|
|
7245
|
-
|
|
7246
|
-
|
|
7326
|
+
const keepResp = parseBooleanFromText2(runtime.getSetting("BOOTSTRAP_KEEP_RESP"));
|
|
7327
|
+
if (currentResponseId !== responseId && !keepResp) {
|
|
7328
|
+
runtime.logger.info(
|
|
7247
7329
|
`Ignore response discarded - newer message being processed for agent: ${runtime.agentId}, room: ${message.roomId}`
|
|
7248
7330
|
);
|
|
7331
|
+
await runtime.emitEvent(EventType.RUN_ENDED, {
|
|
7332
|
+
runtime,
|
|
7333
|
+
runId,
|
|
7334
|
+
messageId: message.id,
|
|
7335
|
+
roomId: message.roomId,
|
|
7336
|
+
entityId: message.entityId,
|
|
7337
|
+
startTime,
|
|
7338
|
+
status: "replaced",
|
|
7339
|
+
endTime: Date.now(),
|
|
7340
|
+
duration: Date.now() - startTime,
|
|
7341
|
+
source: "messageHandler"
|
|
7342
|
+
});
|
|
7249
7343
|
return;
|
|
7250
7344
|
}
|
|
7251
7345
|
if (!message.id) {
|
|
7252
|
-
|
|
7346
|
+
runtime.logger.error(
|
|
7347
|
+
"[Bootstrap] Message ID is missing, cannot create ignore response."
|
|
7348
|
+
);
|
|
7349
|
+
await runtime.emitEvent(EventType.RUN_ENDED, {
|
|
7350
|
+
runtime,
|
|
7351
|
+
runId,
|
|
7352
|
+
messageId: message.id,
|
|
7353
|
+
roomId: message.roomId,
|
|
7354
|
+
entityId: message.entityId,
|
|
7355
|
+
startTime,
|
|
7356
|
+
status: "noMessageId",
|
|
7357
|
+
endTime: Date.now(),
|
|
7358
|
+
duration: Date.now() - startTime,
|
|
7359
|
+
source: "messageHandler"
|
|
7360
|
+
});
|
|
7253
7361
|
return;
|
|
7254
7362
|
}
|
|
7255
7363
|
const ignoreContent = {
|
|
@@ -7270,7 +7378,7 @@ ${response}`
|
|
|
7270
7378
|
createdAt: Date.now()
|
|
7271
7379
|
};
|
|
7272
7380
|
await runtime.createMemory(ignoreMemory, "messages");
|
|
7273
|
-
|
|
7381
|
+
runtime.logger.debug("[Bootstrap] Saved ignore response to memory", {
|
|
7274
7382
|
memoryId: ignoreMemory.id
|
|
7275
7383
|
});
|
|
7276
7384
|
agentResponses.delete(message.roomId);
|
|
@@ -7278,6 +7386,51 @@ ${response}`
|
|
|
7278
7386
|
latestResponseIds.delete(runtime.agentId);
|
|
7279
7387
|
}
|
|
7280
7388
|
}
|
|
7389
|
+
let entityName = "noname";
|
|
7390
|
+
if (message.metadata && "entityName" in message.metadata) {
|
|
7391
|
+
entityName = message.metadata.entityName;
|
|
7392
|
+
}
|
|
7393
|
+
const isDM = message.content?.channelType?.toUpperCase() === "DM";
|
|
7394
|
+
let roomName = entityName;
|
|
7395
|
+
if (!isDM) {
|
|
7396
|
+
const roomDatas = await runtime.getRoomsByIds([message.roomId]);
|
|
7397
|
+
if (roomDatas?.length) {
|
|
7398
|
+
const roomData = roomDatas[0];
|
|
7399
|
+
if (roomData.name) {
|
|
7400
|
+
roomName = roomData.name;
|
|
7401
|
+
}
|
|
7402
|
+
if (roomData.worldId) {
|
|
7403
|
+
const worldData = await runtime.getWorld(roomData.worldId);
|
|
7404
|
+
if (worldData) {
|
|
7405
|
+
roomName = worldData.name + "-" + roomName;
|
|
7406
|
+
}
|
|
7407
|
+
}
|
|
7408
|
+
}
|
|
7409
|
+
}
|
|
7410
|
+
const date = /* @__PURE__ */ new Date();
|
|
7411
|
+
const availableActions = state.data?.providers?.ACTIONS?.data?.actionsData?.map(
|
|
7412
|
+
(a2) => a2.name
|
|
7413
|
+
) || [-1];
|
|
7414
|
+
const logData = {
|
|
7415
|
+
at: date.toString(),
|
|
7416
|
+
timestamp: parseInt("" + date.getTime() / 1e3),
|
|
7417
|
+
messageId: message.id,
|
|
7418
|
+
// can extract roomId or whatever
|
|
7419
|
+
userEntityId: message.entityId,
|
|
7420
|
+
input: message.content.text,
|
|
7421
|
+
thought: responseContent?.thought,
|
|
7422
|
+
simple: responseContent?.simple,
|
|
7423
|
+
availableActions,
|
|
7424
|
+
actions: responseContent?.actions,
|
|
7425
|
+
providers: responseContent?.providers,
|
|
7426
|
+
irt: responseContent?.inReplyTo,
|
|
7427
|
+
output: responseContent?.text,
|
|
7428
|
+
// to strip out
|
|
7429
|
+
entityName,
|
|
7430
|
+
source: message.content.source,
|
|
7431
|
+
channelType: message.content.channelType,
|
|
7432
|
+
roomName
|
|
7433
|
+
};
|
|
7281
7434
|
await runtime.emitEvent(EventType.RUN_ENDED, {
|
|
7282
7435
|
runtime,
|
|
7283
7436
|
runId,
|
|
@@ -7288,7 +7441,10 @@ ${response}`
|
|
|
7288
7441
|
status: "completed",
|
|
7289
7442
|
endTime: Date.now(),
|
|
7290
7443
|
duration: Date.now() - startTime,
|
|
7291
|
-
source: "messageHandler"
|
|
7444
|
+
source: "messageHandler",
|
|
7445
|
+
entityName,
|
|
7446
|
+
responseContent,
|
|
7447
|
+
metadata: logData
|
|
7292
7448
|
});
|
|
7293
7449
|
} catch (error) {
|
|
7294
7450
|
console.error("error is", error);
|
|
@@ -7321,10 +7477,10 @@ var reactionReceivedHandler = async ({
|
|
|
7321
7477
|
await runtime.createMemory(message, "messages");
|
|
7322
7478
|
} catch (error) {
|
|
7323
7479
|
if (error.code === "23505") {
|
|
7324
|
-
|
|
7480
|
+
runtime.logger.warn("[Bootstrap] Duplicate reaction memory, skipping");
|
|
7325
7481
|
return;
|
|
7326
7482
|
}
|
|
7327
|
-
|
|
7483
|
+
runtime.logger.error({ error }, "[Bootstrap] Error in reaction handler:");
|
|
7328
7484
|
}
|
|
7329
7485
|
};
|
|
7330
7486
|
var messageDeletedHandler = async ({
|
|
@@ -7333,14 +7489,22 @@ var messageDeletedHandler = async ({
|
|
|
7333
7489
|
}) => {
|
|
7334
7490
|
try {
|
|
7335
7491
|
if (!message.id) {
|
|
7336
|
-
|
|
7492
|
+
runtime.logger.error("[Bootstrap] Cannot delete memory: message ID is missing");
|
|
7337
7493
|
return;
|
|
7338
7494
|
}
|
|
7339
|
-
|
|
7495
|
+
runtime.logger.info(
|
|
7496
|
+
"[Bootstrap] Deleting memory for message",
|
|
7497
|
+
message.id,
|
|
7498
|
+
"from room",
|
|
7499
|
+
message.roomId
|
|
7500
|
+
);
|
|
7340
7501
|
await runtime.deleteMemory(message.id);
|
|
7341
|
-
|
|
7502
|
+
runtime.logger.debug(
|
|
7503
|
+
{ messageId: message.id },
|
|
7504
|
+
"[Bootstrap] Successfully deleted memory for message"
|
|
7505
|
+
);
|
|
7342
7506
|
} catch (error) {
|
|
7343
|
-
|
|
7507
|
+
runtime.logger.error({ error }, "[Bootstrap] Error in message deleted handler:");
|
|
7344
7508
|
}
|
|
7345
7509
|
};
|
|
7346
7510
|
var channelClearedHandler = async ({
|
|
@@ -7350,7 +7514,7 @@ var channelClearedHandler = async ({
|
|
|
7350
7514
|
memoryCount
|
|
7351
7515
|
}) => {
|
|
7352
7516
|
try {
|
|
7353
|
-
|
|
7517
|
+
runtime.logger.info(
|
|
7354
7518
|
`[Bootstrap] Clearing ${memoryCount} message memories from channel ${channelId} -> room ${roomId}`
|
|
7355
7519
|
);
|
|
7356
7520
|
const memories = await runtime.getMemoriesByRoomIds({
|
|
@@ -7364,15 +7528,18 @@ var channelClearedHandler = async ({
|
|
|
7364
7528
|
await runtime.deleteMemory(memory.id);
|
|
7365
7529
|
deletedCount++;
|
|
7366
7530
|
} catch (error) {
|
|
7367
|
-
|
|
7531
|
+
runtime.logger.warn(
|
|
7532
|
+
{ error, memoryId: memory.id },
|
|
7533
|
+
`[Bootstrap] Failed to delete message memory ${memory.id}:`
|
|
7534
|
+
);
|
|
7368
7535
|
}
|
|
7369
7536
|
}
|
|
7370
7537
|
}
|
|
7371
|
-
|
|
7538
|
+
runtime.logger.info(
|
|
7372
7539
|
`[Bootstrap] Successfully cleared ${deletedCount}/${memories.length} message memories from channel ${channelId}`
|
|
7373
7540
|
);
|
|
7374
7541
|
} catch (error) {
|
|
7375
|
-
|
|
7542
|
+
runtime.logger.error({ error }, "[Bootstrap] Error in channel cleared handler:");
|
|
7376
7543
|
}
|
|
7377
7544
|
};
|
|
7378
7545
|
var postGeneratedHandler = async ({
|
|
@@ -7383,7 +7550,7 @@ var postGeneratedHandler = async ({
|
|
|
7383
7550
|
roomId,
|
|
7384
7551
|
source
|
|
7385
7552
|
}) => {
|
|
7386
|
-
|
|
7553
|
+
runtime.logger.info("[Bootstrap] Generating new post...");
|
|
7387
7554
|
await runtime.ensureWorldExists({
|
|
7388
7555
|
id: worldId,
|
|
7389
7556
|
name: `${runtime.character.name}'s Feed`,
|
|
@@ -7447,7 +7614,7 @@ var postGeneratedHandler = async ({
|
|
|
7447
7614
|
}
|
|
7448
7615
|
retries++;
|
|
7449
7616
|
if (!responseContent?.thought || !responseContent?.actions) {
|
|
7450
|
-
|
|
7617
|
+
runtime.logger.warn(
|
|
7451
7618
|
"[Bootstrap] *** Missing required fields, retrying... ***\n",
|
|
7452
7619
|
response,
|
|
7453
7620
|
parsedXml,
|
|
@@ -7465,7 +7632,7 @@ var postGeneratedHandler = async ({
|
|
|
7465
7632
|
});
|
|
7466
7633
|
const parsedXmlResponse = parseKeyValueXml9(xmlResponseText);
|
|
7467
7634
|
if (!parsedXmlResponse) {
|
|
7468
|
-
|
|
7635
|
+
runtime.logger.error(
|
|
7469
7636
|
"[Bootstrap] Failed to parse XML response for post creation. Raw response:",
|
|
7470
7637
|
xmlResponseText
|
|
7471
7638
|
);
|
|
@@ -7482,7 +7649,7 @@ var postGeneratedHandler = async ({
|
|
|
7482
7649
|
if (RM) {
|
|
7483
7650
|
for (const m of RM.data.recentMessages) {
|
|
7484
7651
|
if (cleanedText === m.content.text) {
|
|
7485
|
-
|
|
7652
|
+
runtime.logger.info({ cleanedText }, "[Bootstrap] Already recently posted that, retrying");
|
|
7486
7653
|
postGeneratedHandler({
|
|
7487
7654
|
runtime,
|
|
7488
7655
|
callback,
|
|
@@ -7500,7 +7667,7 @@ var postGeneratedHandler = async ({
|
|
|
7500
7667
|
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;
|
|
7501
7668
|
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;
|
|
7502
7669
|
if (oaiRefusalRegex.test(cleanedText) || anthropicRefusalRegex.test(cleanedText) || googleRefusalRegex.test(cleanedText) || generalRefusalRegex.test(cleanedText)) {
|
|
7503
|
-
|
|
7670
|
+
runtime.logger.info({ cleanedText }, "[Bootstrap] Got prompt moderation refusal, retrying");
|
|
7504
7671
|
postGeneratedHandler({
|
|
7505
7672
|
runtime,
|
|
7506
7673
|
callback,
|
|
@@ -7534,9 +7701,9 @@ var postGeneratedHandler = async ({
|
|
|
7534
7701
|
var syncSingleUser = async (entityId, runtime, serverId, channelId, type, source) => {
|
|
7535
7702
|
try {
|
|
7536
7703
|
const entity = await runtime.getEntityById(entityId);
|
|
7537
|
-
|
|
7704
|
+
runtime.logger.info(`[Bootstrap] Syncing user: ${entity?.metadata?.username || entityId}`);
|
|
7538
7705
|
if (!channelId) {
|
|
7539
|
-
|
|
7706
|
+
runtime.logger.warn(`[Bootstrap] Cannot sync user ${entity?.id} without a valid channelId`);
|
|
7540
7707
|
return;
|
|
7541
7708
|
}
|
|
7542
7709
|
const roomId = createUniqueUuid3(runtime, channelId);
|
|
@@ -7551,7 +7718,7 @@ var syncSingleUser = async (entityId, runtime, serverId, channelId, type, source
|
|
|
7551
7718
|
settings: {}
|
|
7552
7719
|
// Initialize empty settings for onboarding
|
|
7553
7720
|
} : void 0;
|
|
7554
|
-
|
|
7721
|
+
runtime.logger.info(
|
|
7555
7722
|
`[Bootstrap] syncSingleUser - type: ${type}, isDM: ${type === ChannelType9.DM}, worldMetadata: ${JSON.stringify(worldMetadata)}`
|
|
7556
7723
|
);
|
|
7557
7724
|
await runtime.ensureConnection({
|
|
@@ -7567,15 +7734,15 @@ var syncSingleUser = async (entityId, runtime, serverId, channelId, type, source
|
|
|
7567
7734
|
});
|
|
7568
7735
|
try {
|
|
7569
7736
|
const createdWorld = await runtime.getWorld(worldId);
|
|
7570
|
-
|
|
7737
|
+
runtime.logger.info(
|
|
7571
7738
|
`[Bootstrap] Created world check - ID: ${worldId}, metadata: ${JSON.stringify(createdWorld?.metadata)}`
|
|
7572
7739
|
);
|
|
7573
7740
|
} catch (error) {
|
|
7574
|
-
|
|
7741
|
+
runtime.logger.error(`[Bootstrap] Failed to verify created world: ${error}`);
|
|
7575
7742
|
}
|
|
7576
|
-
|
|
7743
|
+
runtime.logger.success(`[Bootstrap] Successfully synced user: ${entity?.id}`);
|
|
7577
7744
|
} catch (error) {
|
|
7578
|
-
|
|
7745
|
+
runtime.logger.error(
|
|
7579
7746
|
`[Bootstrap] Error syncing user: ${error instanceof Error ? error.message : String(error)}`
|
|
7580
7747
|
);
|
|
7581
7748
|
}
|
|
@@ -7588,13 +7755,13 @@ var handleServerSync = async ({
|
|
|
7588
7755
|
source,
|
|
7589
7756
|
onComplete
|
|
7590
7757
|
}) => {
|
|
7591
|
-
|
|
7758
|
+
runtime.logger.debug(`[Bootstrap] Handling server sync event for server: ${world.name}`);
|
|
7592
7759
|
try {
|
|
7593
7760
|
await runtime.ensureConnections(entities, rooms, source, world);
|
|
7594
|
-
|
|
7761
|
+
runtime.logger.debug(`Successfully synced standardized world structure for ${world.name}`);
|
|
7595
7762
|
onComplete?.();
|
|
7596
7763
|
} catch (error) {
|
|
7597
|
-
|
|
7764
|
+
runtime.logger.error(
|
|
7598
7765
|
`Error processing standardized server data: ${error instanceof Error ? error.message : String(error)}`
|
|
7599
7766
|
);
|
|
7600
7767
|
}
|
|
@@ -7604,7 +7771,7 @@ var controlMessageHandler = async ({
|
|
|
7604
7771
|
message
|
|
7605
7772
|
}) => {
|
|
7606
7773
|
try {
|
|
7607
|
-
|
|
7774
|
+
runtime.logger.debug(
|
|
7608
7775
|
`[controlMessageHandler] Processing control message: ${message.payload.action} for room ${message.roomId}`
|
|
7609
7776
|
);
|
|
7610
7777
|
const serviceNames = Array.from(runtime.getAllServices().keys());
|
|
@@ -7622,24 +7789,28 @@ var controlMessageHandler = async ({
|
|
|
7622
7789
|
roomId: message.roomId
|
|
7623
7790
|
}
|
|
7624
7791
|
});
|
|
7625
|
-
|
|
7792
|
+
runtime.logger.debug(
|
|
7626
7793
|
`[controlMessageHandler] Control message ${message.payload.action} sent successfully`
|
|
7627
7794
|
);
|
|
7628
7795
|
} else {
|
|
7629
|
-
|
|
7796
|
+
runtime.logger.error(
|
|
7797
|
+
"[controlMessageHandler] WebSocket service does not have sendMessage method"
|
|
7798
|
+
);
|
|
7630
7799
|
}
|
|
7631
7800
|
} else {
|
|
7632
|
-
|
|
7801
|
+
runtime.logger.error(
|
|
7802
|
+
"[controlMessageHandler] No WebSocket service found to send control message"
|
|
7803
|
+
);
|
|
7633
7804
|
}
|
|
7634
7805
|
} catch (error) {
|
|
7635
|
-
|
|
7806
|
+
runtime.logger.error(`[controlMessageHandler] Error processing control message: ${error}`);
|
|
7636
7807
|
}
|
|
7637
7808
|
};
|
|
7638
7809
|
var events = {
|
|
7639
7810
|
[EventType.MESSAGE_RECEIVED]: [
|
|
7640
7811
|
async (payload) => {
|
|
7641
7812
|
if (!payload.callback) {
|
|
7642
|
-
|
|
7813
|
+
payload.runtime.logger.error("No callback provided for message");
|
|
7643
7814
|
return;
|
|
7644
7815
|
}
|
|
7645
7816
|
await messageReceivedHandler({
|
|
@@ -7653,7 +7824,7 @@ var events = {
|
|
|
7653
7824
|
[EventType.VOICE_MESSAGE_RECEIVED]: [
|
|
7654
7825
|
async (payload) => {
|
|
7655
7826
|
if (!payload.callback) {
|
|
7656
|
-
|
|
7827
|
+
payload.runtime.logger.error("No callback provided for voice message");
|
|
7657
7828
|
return;
|
|
7658
7829
|
}
|
|
7659
7830
|
await messageReceivedHandler({
|
|
@@ -7679,7 +7850,7 @@ var events = {
|
|
|
7679
7850
|
],
|
|
7680
7851
|
[EventType.MESSAGE_SENT]: [
|
|
7681
7852
|
async (payload) => {
|
|
7682
|
-
|
|
7853
|
+
payload.runtime.logger.debug(`[Bootstrap] Message sent: ${payload.message.content.text}`);
|
|
7683
7854
|
}
|
|
7684
7855
|
],
|
|
7685
7856
|
[EventType.MESSAGE_DELETED]: [
|
|
@@ -7712,17 +7883,19 @@ var events = {
|
|
|
7712
7883
|
],
|
|
7713
7884
|
[EventType.ENTITY_JOINED]: [
|
|
7714
7885
|
async (payload) => {
|
|
7715
|
-
|
|
7886
|
+
payload.runtime.logger.debug(
|
|
7887
|
+
`[Bootstrap] ENTITY_JOINED event received for entity ${payload.entityId}`
|
|
7888
|
+
);
|
|
7716
7889
|
if (!payload.worldId) {
|
|
7717
|
-
|
|
7890
|
+
payload.runtime.logger.error("[Bootstrap] No worldId provided for entity joined");
|
|
7718
7891
|
return;
|
|
7719
7892
|
}
|
|
7720
7893
|
if (!payload.roomId) {
|
|
7721
|
-
|
|
7894
|
+
payload.runtime.logger.error("[Bootstrap] No roomId provided for entity joined");
|
|
7722
7895
|
return;
|
|
7723
7896
|
}
|
|
7724
7897
|
if (!payload.metadata?.type) {
|
|
7725
|
-
|
|
7898
|
+
payload.runtime.logger.error("[Bootstrap] No type provided for entity joined");
|
|
7726
7899
|
return;
|
|
7727
7900
|
}
|
|
7728
7901
|
await syncSingleUser(
|
|
@@ -7747,9 +7920,11 @@ var events = {
|
|
|
7747
7920
|
};
|
|
7748
7921
|
await payload.runtime.updateEntity(entity);
|
|
7749
7922
|
}
|
|
7750
|
-
|
|
7923
|
+
payload.runtime.logger.info(
|
|
7924
|
+
`[Bootstrap] User ${payload.entityId} left world ${payload.worldId}`
|
|
7925
|
+
);
|
|
7751
7926
|
} catch (error) {
|
|
7752
|
-
|
|
7927
|
+
payload.runtime.logger.error(`[Bootstrap] Error handling user left: ${error.message}`);
|
|
7753
7928
|
}
|
|
7754
7929
|
}
|
|
7755
7930
|
],
|