@elizaos/plugin-bootstrap 1.0.0-beta.76 → 1.0.0

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.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { Action, Evaluator, Provider, Plugin, Media, IAgentRuntime } from '@elizaos/core';
1
+ import { Action, Evaluator, Provider, Plugin, Media, IAgentRuntime, Room } from '@elizaos/core';
2
2
 
3
3
  /**
4
4
  * Represents an action that allows selecting an option for a pending task that has multiple options.
@@ -434,6 +434,11 @@ declare function fetchMediaData(attachments: Media[]): Promise<MediaData[]>;
434
434
  * @returns {Promise<Media[]>} - Returns a new array of processed attachments with added description, title, and text properties
435
435
  */
436
436
  declare function processAttachments(attachments: Media[], runtime: IAgentRuntime): Promise<Media[]>;
437
+ /**
438
+ * Determines whether to skip the shouldRespond logic based on room type and message source.
439
+ * Supports both default values and runtime-configurable overrides via env settings.
440
+ */
441
+ declare function shouldBypassShouldRespond(runtime: IAgentRuntime, room?: Room, source?: string): boolean;
437
442
  declare const bootstrapPlugin: Plugin;
438
443
 
439
- export { actionsProvider, anxietyProvider, attachmentsProvider, bootstrapPlugin, capabilitiesProvider, characterProvider, choiceAction, choiceProvider, bootstrapPlugin as default, entitiesProvider, evaluatorsProvider, factsProvider, fetchMediaData, followRoomAction, ignoreAction, muteRoomAction, noneAction, processAttachments, providersProvider, recentMessagesProvider, reflectionEvaluator, relationshipsProvider, replyAction, roleProvider, sendMessageAction, settingsProvider, timeProvider, unfollowRoomAction, unmuteRoomAction, updateEntityAction, updateRoleAction, updateSettingsAction, worldProvider };
444
+ export { actionsProvider, anxietyProvider, attachmentsProvider, bootstrapPlugin, capabilitiesProvider, characterProvider, choiceAction, choiceProvider, bootstrapPlugin as default, entitiesProvider, evaluatorsProvider, factsProvider, fetchMediaData, followRoomAction, ignoreAction, muteRoomAction, noneAction, processAttachments, providersProvider, recentMessagesProvider, reflectionEvaluator, relationshipsProvider, replyAction, roleProvider, sendMessageAction, settingsProvider, shouldBypassShouldRespond, timeProvider, unfollowRoomAction, unmuteRoomAction, updateEntityAction, updateRoleAction, updateSettingsAction, worldProvider };
package/dist/index.js CHANGED
@@ -3705,9 +3705,13 @@ var actionsProvider = {
3705
3705
  position: -1,
3706
3706
  get: async (runtime, message, state) => {
3707
3707
  const actionPromises = runtime.actions.map(async (action) => {
3708
- const result = await action.validate(runtime, message, state);
3709
- if (result) {
3710
- return action;
3708
+ try {
3709
+ const result = await action.validate(runtime, message, state);
3710
+ if (result) {
3711
+ return action;
3712
+ }
3713
+ } catch (e2) {
3714
+ console.error("ACTIONS GET -> validate err", action, e2);
3711
3715
  }
3712
3716
  return null;
3713
3717
  });
@@ -5015,7 +5019,7 @@ var worldProvider = {
5015
5019
  dynamic: true,
5016
5020
  get: async (runtime, message) => {
5017
5021
  try {
5018
- logger16.debug("\u{1F310} World provider activated for roomId:", message.roomId);
5022
+ logger16.debug("[\u{1F310}] World provider activated for roomId:", message.roomId);
5019
5023
  const currentRoom = await runtime.getRoom(message.roomId);
5020
5024
  if (!currentRoom) {
5021
5025
  logger16.warn(`World provider: Room not found for roomId ${message.roomId}`);
@@ -5028,7 +5032,7 @@ var worldProvider = {
5028
5032
  text: "Unable to retrieve world information - room not found"
5029
5033
  };
5030
5034
  }
5031
- logger16.debug(`\u{1F310} World provider: Found room "${currentRoom.name}" (${currentRoom.type})`);
5035
+ logger16.debug(`[\u{1F310}] World provider: Found room "${currentRoom.name}" (${currentRoom.type})`);
5032
5036
  const worldId = currentRoom.worldId;
5033
5037
  if (!worldId) {
5034
5038
  logger16.warn(`World provider: World ID not found for roomId ${message.roomId}`);
@@ -5053,12 +5057,14 @@ var worldProvider = {
5053
5057
  text: "Unable to retrieve world information - world not found"
5054
5058
  };
5055
5059
  }
5056
- logger16.debug(`\u{1F310} World provider: Found world "${world.name}" (ID: ${world.id})`);
5060
+ logger16.debug(`[\u{1F310}] World provider: Found world "${world.name}" (ID: ${world.id})`);
5057
5061
  const worldRooms = await runtime.getRooms(worldId);
5058
- logger16.debug(`\u{1F310} World provider: Found ${worldRooms.length} rooms in world "${world.name}"`);
5062
+ logger16.debug(
5063
+ `[\u{1F310}] World provider: Found ${worldRooms.length} rooms in world "${world.name}"`
5064
+ );
5059
5065
  const participants = await runtime.getParticipantsForRoom(message.roomId);
5060
5066
  logger16.debug(
5061
- `\u{1F310} World provider: Found ${participants.length} participants in room "${currentRoom.name}"`
5067
+ `[\u{1F310}] World provider: Found ${participants.length} participants in room "${currentRoom.name}"`
5062
5068
  );
5063
5069
  const channelsByType = {
5064
5070
  text: [],
@@ -5139,7 +5145,7 @@ var worldProvider = {
5139
5145
  worldInfo: worldInfoText
5140
5146
  };
5141
5147
  const formattedText = addHeader9("# World Information", worldInfoText);
5142
- logger16.debug("\u{1F310} World provider completed successfully");
5148
+ logger16.debug("[\u{1F310}] World provider completed successfully");
5143
5149
  return {
5144
5150
  data,
5145
5151
  values,
@@ -5701,6 +5707,36 @@ async function processAttachments(attachments, runtime) {
5701
5707
  }
5702
5708
  return processedAttachments;
5703
5709
  }
5710
+ function shouldBypassShouldRespond(runtime, room, source) {
5711
+ if (!room) return false;
5712
+ function normalizeEnvList(value) {
5713
+ if (!value || typeof value !== "string") return [];
5714
+ const cleaned = value.trim().replace(/^\[|\]$/g, "");
5715
+ return cleaned.split(",").map((v) => v.trim()).filter(Boolean);
5716
+ }
5717
+ const defaultBypassTypes = [
5718
+ ChannelType10.DM,
5719
+ ChannelType10.VOICE_DM,
5720
+ ChannelType10.SELF,
5721
+ ChannelType10.API
5722
+ ];
5723
+ const defaultBypassSources = ["client_chat"];
5724
+ const bypassTypesSetting = normalizeEnvList(runtime.getSetting("SHOULD_RESPOND_BYPASS_TYPES"));
5725
+ const bypassSourcesSetting = normalizeEnvList(
5726
+ runtime.getSetting("SHOULD_RESPOND_BYPASS_SOURCES")
5727
+ );
5728
+ const bypassTypes = new Set(
5729
+ [...defaultBypassTypes.map((t) => t.toString()), ...bypassTypesSetting].map(
5730
+ (s) => s.trim().toLowerCase()
5731
+ )
5732
+ );
5733
+ const bypassSources = [...defaultBypassSources, ...bypassSourcesSetting].map(
5734
+ (s) => s.trim().toLowerCase()
5735
+ );
5736
+ const roomType = room.type?.toString().toLowerCase();
5737
+ const sourceStr = source?.toLowerCase() || "";
5738
+ return bypassTypes.has(roomType) || bypassSources.some((pattern) => sourceStr.includes(pattern));
5739
+ }
5704
5740
  var messageReceivedHandler = async ({
5705
5741
  runtime,
5706
5742
  message,
@@ -5719,7 +5755,6 @@ var messageReceivedHandler = async ({
5719
5755
  if (!agentResponses) {
5720
5756
  throw new Error("Agent responses map not found");
5721
5757
  }
5722
- console.log("agentResponses is", agentResponses);
5723
5758
  agentResponses.set(message.roomId, responseId);
5724
5759
  const runId = asUUID(v4_default());
5725
5760
  const startTime = Date.now();
@@ -5733,7 +5768,6 @@ var messageReceivedHandler = async ({
5733
5768
  status: "started",
5734
5769
  source: "messageHandler"
5735
5770
  });
5736
- console.log("runId is", runId);
5737
5771
  const timeoutPromise = new Promise((_, reject) => {
5738
5772
  timeoutId = setTimeout(async () => {
5739
5773
  await runtime.emitEvent(EventType2.RUN_TIMEOUT, {
@@ -5752,9 +5786,7 @@ var messageReceivedHandler = async ({
5752
5786
  reject(new Error("Run exceeded 60 minute timeout"));
5753
5787
  }, timeoutDuration);
5754
5788
  });
5755
- console.log("message is", message);
5756
5789
  const processingPromise = (async () => {
5757
- console.log("processingPromise");
5758
5790
  try {
5759
5791
  if (message.entityId === runtime.agentId) {
5760
5792
  logger19.debug(`[Bootstrap] Skipping message from self (${runtime.agentId})`);
@@ -5778,15 +5810,14 @@ var messageReceivedHandler = async ({
5778
5810
  }
5779
5811
  let state = await runtime.composeState(
5780
5812
  message,
5781
- ["ANXIETY", "SHOULD_RESPOND", "ENTITIES", "CHARACTER", "RECENT_MESSAGES"],
5813
+ ["ANXIETY", "SHOULD_RESPOND", "ENTITIES", "CHARACTER", "RECENT_MESSAGES", "ACTIONS"],
5782
5814
  true
5783
5815
  );
5784
5816
  const room = await runtime.getRoom(message.roomId);
5785
- console.log("room is", room);
5786
- console.log("message is", message);
5787
- const shouldSkipShouldRespond = room?.type === ChannelType10.DM || room?.type === ChannelType10.VOICE_DM || room?.type === ChannelType10.SELF || room?.type === ChannelType10.API || message.content.source?.includes("client_chat");
5788
- logger19.debug(
5789
- `[Bootstrap] Skipping shouldRespond check for ${runtime.character.name} because ${room?.type} ${room?.source}`
5817
+ const shouldSkipShouldRespond = shouldBypassShouldRespond(
5818
+ runtime,
5819
+ room ?? void 0,
5820
+ message.content.source
5790
5821
  );
5791
5822
  if (message.content.attachments && message.content.attachments.length > 0) {
5792
5823
  message.content.attachments = await processAttachments(
@@ -5816,13 +5847,19 @@ ${response}`
5816
5847
  logger19.debug("[Bootstrap] Parsed response:", responseObject);
5817
5848
  shouldRespond = responseObject?.action && responseObject.action === "RESPOND";
5818
5849
  } else {
5850
+ logger19.debug(
5851
+ `[Bootstrap] Skipping shouldRespond check for ${runtime.character.name} because ${room?.type} ${room?.source}`
5852
+ );
5819
5853
  shouldRespond = true;
5820
5854
  }
5821
5855
  let responseMessages = [];
5822
5856
  console.log("shouldRespond is", shouldRespond);
5823
5857
  console.log("shouldSkipShouldRespond", shouldSkipShouldRespond);
5824
5858
  if (shouldRespond) {
5825
- state = await runtime.composeState(message);
5859
+ state = await runtime.composeState(message, ["ACTIONS"]);
5860
+ if (!state.values.actionNames) {
5861
+ logger19.warn("actionNames data missing from state, even though it was requested");
5862
+ }
5826
5863
  const prompt = composePromptFromState9({
5827
5864
  state,
5828
5865
  template: runtime.character.templates?.messageHandlerTemplate || messageHandlerTemplate
@@ -5888,11 +5925,42 @@ ${response}`
5888
5925
  state = await runtime.composeState(message, responseContent?.providers || []);
5889
5926
  }
5890
5927
  if (responseContent && responseContent.simple && responseContent.text) {
5928
+ if (responseContent.providers && responseContent.providers.length > 0) {
5929
+ logger19.debug("[Bootstrap] Simple response used providers", responseContent.providers);
5930
+ }
5891
5931
  await callback(responseContent);
5892
5932
  } else {
5893
- await runtime.processActions(message, responseMessages, state, callback);
5933
+ await runtime.processActions(
5934
+ message,
5935
+ responseMessages,
5936
+ state,
5937
+ async (memory) => {
5938
+ return [];
5939
+ }
5940
+ );
5941
+ if (responseMessages.length) {
5942
+ for (const responseMessage of responseMessages) {
5943
+ if (responseMessage.content.providers && responseMessage.content.providers.length > 0) {
5944
+ logger19.debug(
5945
+ "[Bootstrap] Complex response used providers",
5946
+ responseMessage.content.providers
5947
+ );
5948
+ }
5949
+ }
5950
+ for (const memory of responseMessages) {
5951
+ await callback(memory.content);
5952
+ }
5953
+ }
5894
5954
  }
5895
- await runtime.evaluate(message, state, shouldRespond, callback, responseMessages);
5955
+ await runtime.evaluate(
5956
+ message,
5957
+ state,
5958
+ shouldRespond,
5959
+ async (memory) => {
5960
+ return [];
5961
+ },
5962
+ responseMessages
5963
+ );
5896
5964
  } else {
5897
5965
  logger19.debug("[Bootstrap] Agent decided not to respond (shouldRespond is false).");
5898
5966
  const currentResponseId = agentResponses.get(message.roomId);
@@ -5961,8 +6029,6 @@ ${response}`
5961
6029
  });
5962
6030
  }
5963
6031
  })();
5964
- console.log("processingPromise is", processingPromise);
5965
- console.log("timeoutPromise is", timeoutPromise);
5966
6032
  await Promise.race([processingPromise, timeoutPromise]);
5967
6033
  } finally {
5968
6034
  clearTimeout(timeoutId);
@@ -6479,6 +6545,7 @@ export {
6479
6545
  roleProvider,
6480
6546
  sendMessageAction,
6481
6547
  settingsProvider,
6548
+ shouldBypassShouldRespond,
6482
6549
  timeProvider,
6483
6550
  unfollowRoomAction,
6484
6551
  unmuteRoomAction,