@elizaos/plugin-bootstrap 1.3.2 → 1.4.3

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 CHANGED
@@ -338,7 +338,7 @@ var choiceAction = {
338
338
  }
339
339
  return pendingTasks && pendingTasks.length > 0 && pendingTasks.some((task) => task.metadata?.options);
340
340
  } catch (error) {
341
- logger.error("Error validating choice action:", error);
341
+ logger.error({ error }, "Error validating choice action");
342
342
  return false;
343
343
  }
344
344
  },
@@ -519,7 +519,7 @@ ${task.options?.map((opt) => `- ${opt.name}: ${opt.description}`).join("\n")}`;
519
519
  success: true
520
520
  };
521
521
  } catch (error) {
522
- logger.error("Error executing task with option:", error);
522
+ logger.error({ error }, "Error executing task with option");
523
523
  await callback?.({
524
524
  text: "There was an error processing your selection.",
525
525
  actions: ["SELECT_OPTION_ERROR"],
@@ -745,7 +745,7 @@ var followRoomAction = {
745
745
  success: true
746
746
  };
747
747
  } catch (error) {
748
- logger2.error("Error following room:", error);
748
+ logger2.error({ error }, "Error following room");
749
749
  return {
750
750
  text: "Failed to follow room",
751
751
  values: {
@@ -1410,7 +1410,7 @@ var muteRoomAction = {
1410
1410
  success: true
1411
1411
  };
1412
1412
  } catch (error) {
1413
- logger3.error("Error muting room:", error);
1413
+ logger3.error({ error }, "Error muting room");
1414
1414
  return {
1415
1415
  text: "Failed to mute room",
1416
1416
  values: {
@@ -2060,7 +2060,7 @@ IMPORTANT: Your response must ONLY contain the <response></response> XML block a
2060
2060
  await runtime.updateWorld(world);
2061
2061
  logger5.info(`Updated roles in world metadata for server ${serverId}`);
2062
2062
  } catch (error) {
2063
- logger5.error("Failed to save world updates:", error);
2063
+ logger5.error({ error }, "Failed to save world updates");
2064
2064
  return {
2065
2065
  text: "Failed to save role updates",
2066
2066
  values: {
@@ -2901,7 +2901,7 @@ async function processSettingUpdates(runtime, serverId, worldSettings, updates)
2901
2901
  }
2902
2902
  return { updatedAny, messages };
2903
2903
  } catch (error) {
2904
- logger7.error("Error processing setting updates:", error);
2904
+ logger7.error({ error }, "Error processing setting updates:");
2905
2905
  return {
2906
2906
  updatedAny: false,
2907
2907
  messages: ["Error occurred while updating settings"]
@@ -4083,7 +4083,7 @@ var unmuteRoomAction = {
4083
4083
  success: true
4084
4084
  };
4085
4085
  } catch (error) {
4086
- logger8.error("Error unmuting room:", error);
4086
+ logger8.error({ error }, "Error unmuting room:");
4087
4087
  return {
4088
4088
  text: "Failed to unmute room",
4089
4089
  values: {
@@ -4667,7 +4667,7 @@ function resolveEntity(entityId, entities) {
4667
4667
  async function handler(runtime, message, state) {
4668
4668
  const { agentId, roomId } = message;
4669
4669
  if (!agentId || !roomId) {
4670
- logger10.warn("Missing agentId or roomId in message", message);
4670
+ logger10.warn({ message }, "Missing agentId or roomId in message");
4671
4671
  return;
4672
4672
  }
4673
4673
  const [existingRelationships, entities, knownFacts] = await Promise.all([
@@ -4698,20 +4698,20 @@ async function handler(runtime, message, state) {
4698
4698
  prompt
4699
4699
  });
4700
4700
  if (!response) {
4701
- logger10.warn("Getting reflection failed - empty response", prompt);
4701
+ logger10.warn({ prompt }, "Getting reflection failed - empty response");
4702
4702
  return;
4703
4703
  }
4704
4704
  const reflection = parseKeyValueXml8(response);
4705
4705
  if (!reflection) {
4706
- logger10.warn("Getting reflection failed - failed to parse XML", response);
4706
+ logger10.warn({ response }, "Getting reflection failed - failed to parse XML");
4707
4707
  return;
4708
4708
  }
4709
4709
  if (!reflection.facts) {
4710
- logger10.warn("Getting reflection failed - invalid facts structure", reflection);
4710
+ logger10.warn({ reflection }, "Getting reflection failed - invalid facts structure");
4711
4711
  return;
4712
4712
  }
4713
4713
  if (!reflection.relationships) {
4714
- logger10.warn("Getting reflection failed - invalid relationships structure", reflection);
4714
+ logger10.warn({ reflection }, "Getting reflection failed - invalid relationships structure");
4715
4715
  return;
4716
4716
  }
4717
4717
  let factsArray = [];
@@ -4780,7 +4780,7 @@ async function handler(runtime, message, state) {
4780
4780
  message?.id || ""
4781
4781
  );
4782
4782
  } catch (error) {
4783
- logger10.error("Error in reflection handler:", error);
4783
+ logger10.error({ error }, "Error in reflection handler:");
4784
4784
  return;
4785
4785
  }
4786
4786
  }
@@ -5106,7 +5106,7 @@ ${values}`;
5106
5106
  (msg) => msg.content?.type === "action_result" && msg.metadata?.type === "action_result"
5107
5107
  );
5108
5108
  } catch (error) {
5109
- logger11?.error("Failed to retrieve action memories:", error);
5109
+ logger11?.error({ error }, "Failed to retrieve action memories:");
5110
5110
  }
5111
5111
  let actionMemoriesText = "";
5112
5112
  if (recentActionMemories.length > 0) {
@@ -5352,7 +5352,7 @@ var capabilitiesProvider = {
5352
5352
  ${formattedCapabilities}`
5353
5353
  };
5354
5354
  } catch (error) {
5355
- logger12.error("Error in capabilities provider:", error);
5355
+ logger12.error({ error }, "Error in capabilities provider:");
5356
5356
  return {
5357
5357
  text: "Error retrieving capabilities from services."
5358
5358
  };
@@ -5531,7 +5531,7 @@ var choiceProvider = {
5531
5531
  text: output
5532
5532
  };
5533
5533
  } catch (error) {
5534
- logger13.error("Error in options provider:", error);
5534
+ logger13.error({ error }, "Error in options provider:");
5535
5535
  return {
5536
5536
  data: {
5537
5537
  tasks: []
@@ -5757,7 +5757,7 @@ var factsProvider = {
5757
5757
  text
5758
5758
  };
5759
5759
  } catch (error) {
5760
- logger14.error("Error in factsProvider:", error);
5760
+ logger14.error({ error }, "Error in factsProvider:");
5761
5761
  return {
5762
5762
  values: {
5763
5763
  facts: ""
@@ -6010,7 +6010,7 @@ ${runText}`;
6010
6010
  text
6011
6011
  };
6012
6012
  } catch (error) {
6013
- logger15.error("Error in recentMessagesProvider:", error);
6013
+ logger15.error({ error }, "Error in recentMessagesProvider:");
6014
6014
  return {
6015
6015
  data: {
6016
6016
  recentMessages: [],
@@ -6513,7 +6513,7 @@ var worldProvider = {
6513
6513
  dynamic: true,
6514
6514
  get: async (runtime, message) => {
6515
6515
  try {
6516
- logger18.debug("[\u{1F310}] World provider activated for roomId:", message.roomId);
6516
+ logger18.debug({ roomId: message.roomId }, "[\u{1F310}] World provider activated for roomId:");
6517
6517
  const currentRoom = await runtime.getRoom(message.roomId);
6518
6518
  if (!currentRoom) {
6519
6519
  logger18.warn(`World provider: Room not found for roomId ${message.roomId}`);
@@ -6743,7 +6743,7 @@ var TaskService = class _TaskService extends Service {
6743
6743
  try {
6744
6744
  await this.checkTasks();
6745
6745
  } catch (error) {
6746
- logger19.error("[Bootstrap] Error checking tasks:", error);
6746
+ logger19.error({ error }, "[Bootstrap] Error checking tasks:");
6747
6747
  }
6748
6748
  }, this.TICK_INTERVAL);
6749
6749
  }
@@ -6772,7 +6772,10 @@ var TaskService = class _TaskService extends Service {
6772
6772
  continue;
6773
6773
  }
6774
6774
  } catch (error) {
6775
- logger19.error(`[Bootstrap] Error validating task ${task.name}:`, error);
6775
+ logger19.error(
6776
+ { error, taskName: task.name },
6777
+ `[Bootstrap] Error validating task ${task.name}:`
6778
+ );
6776
6779
  continue;
6777
6780
  }
6778
6781
  }
@@ -6827,7 +6830,7 @@ var TaskService = class _TaskService extends Service {
6827
6830
  }
6828
6831
  }
6829
6832
  } catch (error) {
6830
- logger19.error("[Bootstrap] Error checking tasks:", error);
6833
+ logger19.error({ error }, "[Bootstrap] Error checking tasks:");
6831
6834
  }
6832
6835
  }
6833
6836
  /**
@@ -6866,7 +6869,7 @@ var TaskService = class _TaskService extends Service {
6866
6869
  );
6867
6870
  }
6868
6871
  } catch (error) {
6869
- logger19.error(`[Bootstrap] Error executing task ${task.id}:`, error);
6872
+ logger19.error({ error, taskId: task.id }, `[Bootstrap] Error executing task ${task.id}:`);
6870
6873
  }
6871
6874
  }
6872
6875
  /**
@@ -6939,15 +6942,30 @@ async function processAttachments(attachments, runtime) {
6939
6942
  });
6940
6943
  if (typeof response === "string") {
6941
6944
  const parsedXml = parseKeyValueXml9(response);
6942
- if (parsedXml?.description && parsedXml?.text) {
6943
- processedAttachment.description = parsedXml.description;
6945
+ if (parsedXml && (parsedXml.description || parsedXml.text)) {
6946
+ processedAttachment.description = parsedXml.description || "";
6944
6947
  processedAttachment.title = parsedXml.title || "Image";
6945
- processedAttachment.text = parsedXml.text;
6948
+ processedAttachment.text = parsedXml.text || parsedXml.description || "";
6946
6949
  runtime.logger.debug(
6947
6950
  `[Bootstrap] Generated description: ${processedAttachment.description?.substring(0, 100)}...`
6948
6951
  );
6949
6952
  } else {
6950
- runtime.logger.warn(`[Bootstrap] Failed to parse XML response for image description`);
6953
+ const responseStr = response;
6954
+ const titleMatch = responseStr.match(/<title>([^<]+)<\/title>/);
6955
+ const descMatch = responseStr.match(/<description>([^<]+)<\/description>/);
6956
+ const textMatch = responseStr.match(/<text>([^<]+)<\/text>/);
6957
+ if (titleMatch || descMatch || textMatch) {
6958
+ processedAttachment.title = titleMatch?.[1] || "Image";
6959
+ processedAttachment.description = descMatch?.[1] || "";
6960
+ processedAttachment.text = textMatch?.[1] || descMatch?.[1] || "";
6961
+ runtime.logger.debug(
6962
+ `[Bootstrap] Used fallback XML parsing - description: ${processedAttachment.description?.substring(0, 100)}...`
6963
+ );
6964
+ } else {
6965
+ runtime.logger.warn(
6966
+ `[Bootstrap] Failed to parse XML response for image description`
6967
+ );
6968
+ }
6951
6969
  }
6952
6970
  } else if (response && typeof response === "object" && "description" in response) {
6953
6971
  processedAttachment.description = response.description;
@@ -6960,7 +6978,7 @@ async function processAttachments(attachments, runtime) {
6960
6978
  runtime.logger.warn(`[Bootstrap] Unexpected response format for image description`);
6961
6979
  }
6962
6980
  } catch (error) {
6963
- runtime.logger.error(`[Bootstrap] Error generating image description:`, error);
6981
+ runtime.logger.error({ error }, `[Bootstrap] Error generating image description:`);
6964
6982
  }
6965
6983
  } else if (attachment.contentType === ContentType2.DOCUMENT && !attachment.text) {
6966
6984
  const res = await fetch(url);
@@ -6981,7 +6999,10 @@ async function processAttachments(attachments, runtime) {
6981
6999
  }
6982
7000
  processedAttachments.push(processedAttachment);
6983
7001
  } catch (error) {
6984
- runtime.logger.error(`[Bootstrap] Failed to process attachment ${attachment.url}:`, error);
7002
+ runtime.logger.error(
7003
+ { error, attachmentUrl: attachment.url },
7004
+ `[Bootstrap] Failed to process attachment ${attachment.url}:`
7005
+ );
6985
7006
  processedAttachments.push(attachment);
6986
7007
  }
6987
7008
  }
@@ -7183,7 +7204,7 @@ ${response}`
7183
7204
  );
7184
7205
  runtime.logger.debug(`[Bootstrap] Response type: ${typeof response}`);
7185
7206
  const responseObject = parseKeyValueXml9(response);
7186
- runtime.logger.debug("[Bootstrap] Parsed response:", responseObject);
7207
+ runtime.logger.debug({ responseObject }, "[Bootstrap] Parsed response:");
7187
7208
  const nonResponseActions = ["IGNORE", "NONE"];
7188
7209
  shouldRespond = responseObject?.action && !nonResponseActions.includes(responseObject.action.toUpperCase());
7189
7210
  } else {
@@ -7211,9 +7232,9 @@ ${response}`
7211
7232
  let response = await runtime.useModel(ModelType14.TEXT_LARGE, {
7212
7233
  prompt
7213
7234
  });
7214
- runtime.logger.debug("[Bootstrap] *** Raw LLM Response ***\n", response);
7235
+ runtime.logger.debug({ response }, "[Bootstrap] *** Raw LLM Response ***");
7215
7236
  const parsedXml = parseKeyValueXml9(response);
7216
- runtime.logger.debug("[Bootstrap] *** Parsed XML Content ***\n", parsedXml);
7237
+ runtime.logger.debug({ parsedXml }, "[Bootstrap] *** Parsed XML Content ***");
7217
7238
  if (parsedXml) {
7218
7239
  responseContent = {
7219
7240
  ...parsedXml,
@@ -7229,10 +7250,8 @@ ${response}`
7229
7250
  retries++;
7230
7251
  if (!responseContent?.thought || !responseContent?.actions) {
7231
7252
  runtime.logger.warn(
7232
- "[Bootstrap] *** Missing required fields (thought or actions), retrying... ***\n",
7233
- response,
7234
- parsedXml,
7235
- responseContent
7253
+ { response, parsedXml, responseContent },
7254
+ "[Bootstrap] *** Missing required fields (thought or actions), retrying... ***"
7236
7255
  );
7237
7256
  }
7238
7257
  }
@@ -7287,14 +7306,14 @@ ${response}`
7287
7306
  if (responseContent && responseContent.simple && responseContent.text) {
7288
7307
  if (responseContent.providers && responseContent.providers.length > 0) {
7289
7308
  runtime.logger.debug(
7290
- "[Bootstrap] Simple response used providers",
7291
- responseContent.providers
7309
+ { providers: responseContent.providers },
7310
+ "[Bootstrap] Simple response used providers"
7292
7311
  );
7293
7312
  }
7294
7313
  await callback(responseContent);
7295
7314
  } else {
7296
7315
  await runtime.processActions(message, responseMessages, state, async (content) => {
7297
- runtime.logger.debug("action callback", content);
7316
+ runtime.logger.debug({ content }, "action callback");
7298
7317
  if (responseContent) {
7299
7318
  responseContent.actionCallbacks = content;
7300
7319
  }
@@ -7306,7 +7325,7 @@ ${response}`
7306
7325
  state,
7307
7326
  shouldRespond,
7308
7327
  async (content) => {
7309
- runtime.logger.debug("evaluate callback", content);
7328
+ runtime.logger.debug({ content }, "evaluate callback");
7310
7329
  if (responseContent) {
7311
7330
  responseContent.evalCallbacks = content;
7312
7331
  }
@@ -7476,7 +7495,7 @@ var reactionReceivedHandler = async ({
7476
7495
  runtime.logger.warn("[Bootstrap] Duplicate reaction memory, skipping");
7477
7496
  return;
7478
7497
  }
7479
- runtime.logger.error("[Bootstrap] Error in reaction handler:", error);
7498
+ runtime.logger.error({ error }, "[Bootstrap] Error in reaction handler:");
7480
7499
  }
7481
7500
  };
7482
7501
  var messageDeletedHandler = async ({
@@ -7495,9 +7514,12 @@ var messageDeletedHandler = async ({
7495
7514
  message.roomId
7496
7515
  );
7497
7516
  await runtime.deleteMemory(message.id);
7498
- runtime.logger.debug("[Bootstrap] Successfully deleted memory for message", message.id);
7517
+ runtime.logger.debug(
7518
+ { messageId: message.id },
7519
+ "[Bootstrap] Successfully deleted memory for message"
7520
+ );
7499
7521
  } catch (error) {
7500
- runtime.logger.error("[Bootstrap] Error in message deleted handler:", error);
7522
+ runtime.logger.error({ error }, "[Bootstrap] Error in message deleted handler:");
7501
7523
  }
7502
7524
  };
7503
7525
  var channelClearedHandler = async ({
@@ -7521,7 +7543,10 @@ var channelClearedHandler = async ({
7521
7543
  await runtime.deleteMemory(memory.id);
7522
7544
  deletedCount++;
7523
7545
  } catch (error) {
7524
- runtime.logger.warn(`[Bootstrap] Failed to delete message memory ${memory.id}:`, error);
7546
+ runtime.logger.warn(
7547
+ { error, memoryId: memory.id },
7548
+ `[Bootstrap] Failed to delete message memory ${memory.id}:`
7549
+ );
7525
7550
  }
7526
7551
  }
7527
7552
  }
@@ -7529,7 +7554,7 @@ var channelClearedHandler = async ({
7529
7554
  `[Bootstrap] Successfully cleared ${deletedCount}/${memories.length} message memories from channel ${channelId}`
7530
7555
  );
7531
7556
  } catch (error) {
7532
- runtime.logger.error("[Bootstrap] Error in channel cleared handler:", error);
7557
+ runtime.logger.error({ error }, "[Bootstrap] Error in channel cleared handler:");
7533
7558
  }
7534
7559
  };
7535
7560
  var postGeneratedHandler = async ({
@@ -7639,7 +7664,7 @@ var postGeneratedHandler = async ({
7639
7664
  if (RM) {
7640
7665
  for (const m of RM.data.recentMessages) {
7641
7666
  if (cleanedText === m.content.text) {
7642
- runtime.logger.info("[Bootstrap] Already recently posted that, retrying", cleanedText);
7667
+ runtime.logger.info({ cleanedText }, "[Bootstrap] Already recently posted that, retrying");
7643
7668
  postGeneratedHandler({
7644
7669
  runtime,
7645
7670
  callback,
@@ -7657,7 +7682,7 @@ var postGeneratedHandler = async ({
7657
7682
  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;
7658
7683
  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;
7659
7684
  if (oaiRefusalRegex.test(cleanedText) || anthropicRefusalRegex.test(cleanedText) || googleRefusalRegex.test(cleanedText) || generalRefusalRegex.test(cleanedText)) {
7660
- runtime.logger.info("[Bootstrap] Got prompt moderation refusal, retrying", cleanedText);
7685
+ runtime.logger.info({ cleanedText }, "[Bootstrap] Got prompt moderation refusal, retrying");
7661
7686
  postGeneratedHandler({
7662
7687
  runtime,
7663
7688
  callback,