@elizaos/plugin-bootstrap 1.0.0-beta.26 → 1.0.0-beta.28

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
@@ -81,6 +81,7 @@ import {
81
81
  ModelType as ModelType13,
82
82
  parseJSONObjectFromText as parseJSONObjectFromText4,
83
83
  postCreationTemplate,
84
+ providersTemplate,
84
85
  shouldRespondTemplate,
85
86
  truncateToCompleteSentence
86
87
  } from "@elizaos/core";
@@ -1278,15 +1279,12 @@ import {
1278
1279
  composePromptFromState as composePromptFromState3,
1279
1280
  ModelType as ModelType4
1280
1281
  } from "@elizaos/core";
1281
- var replyTemplate = `# Task: Generate dialog and actions for the character {{agentName}}.
1282
+ var replyTemplate = `# Task: Generate dialog for the character {{agentName}}.
1282
1283
  {{providers}}
1283
1284
  # Instructions: Write the next message for {{agentName}}.
1284
- First, think about what you want to do next and plan your actions. Then, write the next message and include the actions you plan to take.
1285
1285
  "thought" should be a short description of what the agent is thinking about and planning.
1286
1286
  "message" should be the next message for {{agentName}} which they will send to the conversation.
1287
1287
 
1288
- These are the available valid actions: {{actionNames}}
1289
-
1290
1288
  Response format should be formatted in a valid JSON block like this:
1291
1289
  \`\`\`json
1292
1290
  {
@@ -1303,7 +1301,21 @@ var replyAction = {
1303
1301
  validate: async (_runtime) => {
1304
1302
  return true;
1305
1303
  },
1306
- handler: async (runtime, message, state, _options, callback) => {
1304
+ handler: async (runtime, message, state, _options, callback, responses) => {
1305
+ const existingResponses = responses?.filter(
1306
+ (response2) => response2.content.actions?.includes("REPLY") && response2.content.message
1307
+ );
1308
+ if (existingResponses && existingResponses.length > 0) {
1309
+ for (const response2 of existingResponses) {
1310
+ const responseContent2 = {
1311
+ thought: response2.content.thought || "Using provided text for reply",
1312
+ text: response2.content.message,
1313
+ actions: ["REPLY"]
1314
+ };
1315
+ await callback(responseContent2);
1316
+ }
1317
+ return;
1318
+ }
1307
1319
  state = await runtime.composeState(message, [
1308
1320
  ...message.content.providers ?? [],
1309
1321
  "RECENT_MESSAGES"
@@ -5396,33 +5408,49 @@ var messageReceivedHandler = async ({
5396
5408
  "RECENT_MESSAGES",
5397
5409
  "ENTITIES"
5398
5410
  ]);
5399
- const shouldRespondPrompt = composePromptFromState9({
5400
- state,
5401
- template: runtime.character.templates?.shouldRespondTemplate || shouldRespondTemplate
5402
- });
5403
- logger16.debug(
5404
- `*** Should Respond Prompt for ${runtime.character.name} ***
5411
+ const room = await runtime.getRoom(message.roomId);
5412
+ const shouldSkipShouldRespond = room?.type === ChannelType9.DM || room?.type === ChannelType9.VOICE_DM || room?.type === ChannelType9.SELF;
5413
+ let shouldRespond = true;
5414
+ let providers = [];
5415
+ if (!shouldSkipShouldRespond) {
5416
+ const shouldRespondPrompt = composePromptFromState9({
5417
+ state,
5418
+ template: runtime.character.templates?.shouldRespondTemplate || shouldRespondTemplate
5419
+ });
5420
+ logger16.debug(
5421
+ `*** Should Respond Prompt for ${runtime.character.name} ***
5405
5422
  `,
5406
- shouldRespondPrompt
5407
- );
5408
- const response = await runtime.useModel(ModelType13.TEXT_SMALL, {
5409
- prompt: shouldRespondPrompt
5410
- });
5411
- logger16.debug(`*** Should Respond Response for ${runtime.character.name} ***
5423
+ shouldRespondPrompt
5424
+ );
5425
+ const response = await runtime.useModel(ModelType13.TEXT_SMALL, {
5426
+ prompt: shouldRespondPrompt
5427
+ });
5428
+ logger16.debug(`*** Should Respond Response for ${runtime.character.name} ***
5412
5429
  `, response);
5413
- logger16.debug(`*** Raw Response Type: ${typeof response} ***`);
5414
- let processedResponse = response;
5415
- if (typeof response === "string" && response.includes("```")) {
5416
- logger16.debug("*** Response contains code block markers, attempting to clean up ***");
5417
- processedResponse = response.replace(/```json\n|\n```|```/g, "");
5418
- logger16.debug("*** Processed Response ***\n", processedResponse);
5419
- }
5420
- const responseObject = parseJSONObjectFromText4(processedResponse);
5421
- logger16.debug("*** Parsed Response Object ***", responseObject);
5422
- const providers = responseObject?.providers;
5423
- logger16.debug("*** Providers Value ***", providers);
5424
- const shouldRespond = responseObject?.action && responseObject.action === "RESPOND";
5430
+ logger16.debug(`*** Raw Response Type: ${typeof response} ***`);
5431
+ let processedResponse = response;
5432
+ if (typeof response === "string" && response.includes("```")) {
5433
+ logger16.debug("*** Response contains code block markers, attempting to clean up ***");
5434
+ processedResponse = response.replace(/```json\n|\n```|```/g, "");
5435
+ logger16.debug("*** Processed Response ***\n", processedResponse);
5436
+ }
5437
+ const responseObject = parseJSONObjectFromText4(processedResponse);
5438
+ logger16.debug("*** Parsed Response Object ***", responseObject);
5439
+ shouldRespond = responseObject?.action && responseObject.action === "RESPOND";
5440
+ providers = responseObject?.providers || [];
5441
+ } else {
5442
+ const providersPrompt = composePromptFromState9({
5443
+ state,
5444
+ template: runtime.character.templates?.providersTemplate || providersTemplate
5445
+ });
5446
+ const response = await runtime.useModel(ModelType13.TEXT_SMALL, {
5447
+ prompt: providersPrompt
5448
+ });
5449
+ const responseObject = parseJSONObjectFromText4(response);
5450
+ providers = responseObject?.providers || [];
5451
+ }
5425
5452
  logger16.debug("*** Should Respond ***", shouldRespond);
5453
+ logger16.debug("*** Providers Value ***", providers);
5426
5454
  state = await runtime.composeState(message, null, providers);
5427
5455
  let responseMessages = [];
5428
5456
  if (shouldRespond) {
@@ -5434,10 +5462,10 @@ var messageReceivedHandler = async ({
5434
5462
  let retries = 0;
5435
5463
  const maxRetries = 3;
5436
5464
  while (retries < maxRetries && (!responseContent?.thought || !responseContent?.actions)) {
5437
- const response2 = await runtime.useModel(ModelType13.TEXT_SMALL, {
5465
+ const response = await runtime.useModel(ModelType13.TEXT_LARGE, {
5438
5466
  prompt
5439
5467
  });
5440
- responseContent = parseJSONObjectFromText4(response2);
5468
+ responseContent = parseJSONObjectFromText4(response);
5441
5469
  retries++;
5442
5470
  if (!responseContent?.thought && !responseContent?.actions) {
5443
5471
  logger16.warn("*** Missing required fields, retrying... ***");