@elizaos/plugin-bootstrap 1.6.2-alpha.1 → 1.6.2-alpha.11
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 +46 -107
- package/dist/index.js.map +4 -5
- package/package.json +4 -4
package/dist/index.js
CHANGED
|
@@ -6550,77 +6550,6 @@ var settingsProvider = {
|
|
|
6550
6550
|
}
|
|
6551
6551
|
}
|
|
6552
6552
|
};
|
|
6553
|
-
// src/providers/shouldRespond.ts
|
|
6554
|
-
var import_unique_names_generator2 = __toESM(require_dist(), 1);
|
|
6555
|
-
import { addHeader as addHeader10 } from "@elizaos/core";
|
|
6556
|
-
var nameConfig = {
|
|
6557
|
-
dictionaries: [import_unique_names_generator2.adjectives, import_unique_names_generator2.names],
|
|
6558
|
-
separator: "",
|
|
6559
|
-
length: 2,
|
|
6560
|
-
style: "capital"
|
|
6561
|
-
};
|
|
6562
|
-
var messageExamples = [
|
|
6563
|
-
`// {{name1}}: Hey {{agentName}}, can you help me with something
|
|
6564
|
-
// Response: RESPOND`,
|
|
6565
|
-
`// {{name1}}: Hey {{agentName}}, can I ask you a question
|
|
6566
|
-
// {{agentName}}: Sure, what is it
|
|
6567
|
-
// {{name1}}: can you help me create a basic react module that demonstrates a counter
|
|
6568
|
-
// Response: RESPOND`,
|
|
6569
|
-
`// {{name1}}: {{agentName}} can you tell me a story
|
|
6570
|
-
// {{name1}}: about a girl named {{characterName}}
|
|
6571
|
-
// {{agentName}}: Sure.
|
|
6572
|
-
// {{agentName}}: Once upon a time, in a quaint little village, there was a curious girl named {{characterName}}.
|
|
6573
|
-
// {{agentName}}: {{characterName}} was known for her adventurous spirit and her knack for finding beauty in the mundane.
|
|
6574
|
-
// {{name1}}: I'm loving it, keep going
|
|
6575
|
-
// Response: RESPOND`,
|
|
6576
|
-
`// {{name1}}: okay, i want to test something. can you say marco?
|
|
6577
|
-
// {{agentName}}: marco
|
|
6578
|
-
// {{name1}}: great. okay, now do it again
|
|
6579
|
-
// Response: RESPOND`,
|
|
6580
|
-
`// {{name1}}: what do you think about artificial intelligence?
|
|
6581
|
-
// Response: RESPOND`,
|
|
6582
|
-
`// {{name1}}: I just saw a really great movie
|
|
6583
|
-
// {{name2}}: Oh? Which movie?
|
|
6584
|
-
// Response: IGNORE`,
|
|
6585
|
-
`// {{name1}}: i need help
|
|
6586
|
-
// {{agentName}}: how can I help you?
|
|
6587
|
-
// {{name1}}: no. i need help from {{name2}}
|
|
6588
|
-
// Response: IGNORE`,
|
|
6589
|
-
`// {{name1}}: {{name2}} can you answer a question for me?
|
|
6590
|
-
// Response: IGNORE`,
|
|
6591
|
-
`// {{agentName}}: Oh, this is my favorite scene
|
|
6592
|
-
// {{name1}}: sick
|
|
6593
|
-
// {{name2}}: wait, why is it your favorite scene
|
|
6594
|
-
// Response: RESPOND`,
|
|
6595
|
-
`// {{name1}}: {{agentName}} stop responding plz
|
|
6596
|
-
// Response: STOP`,
|
|
6597
|
-
`// {{name1}}: stfu bot
|
|
6598
|
-
// Response: STOP`,
|
|
6599
|
-
`// {{name1}}: {{agentName}} stfu plz
|
|
6600
|
-
// Response: STOP`
|
|
6601
|
-
];
|
|
6602
|
-
var shouldRespondProvider = {
|
|
6603
|
-
name: "SHOULD_RESPOND",
|
|
6604
|
-
description: "Examples of when the agent should respond, ignore, or stop responding",
|
|
6605
|
-
position: -1,
|
|
6606
|
-
get: async (runtime, _message) => {
|
|
6607
|
-
const agentName = runtime.character.name;
|
|
6608
|
-
const name1 = import_unique_names_generator2.uniqueNamesGenerator(nameConfig);
|
|
6609
|
-
const name2 = import_unique_names_generator2.uniqueNamesGenerator(nameConfig);
|
|
6610
|
-
const characterName = import_unique_names_generator2.uniqueNamesGenerator(nameConfig);
|
|
6611
|
-
const shuffledExamples = [...messageExamples].sort(() => 0.5 - Math.random()).slice(0, 7);
|
|
6612
|
-
const formattedExamples = shuffledExamples.map((example) => {
|
|
6613
|
-
return example.replace(/{{name1}}/g, name1).replace(/{{name2}}/g, name2).replace(/{{agentName}}/g, agentName).replace(/{{characterName}}/g, characterName);
|
|
6614
|
-
});
|
|
6615
|
-
const examplesText = formattedExamples.join(`
|
|
6616
|
-
|
|
6617
|
-
`);
|
|
6618
|
-
const text = addHeader10("# RESPONSE EXAMPLES", examplesText);
|
|
6619
|
-
return {
|
|
6620
|
-
text
|
|
6621
|
-
};
|
|
6622
|
-
}
|
|
6623
|
-
};
|
|
6624
6553
|
// src/providers/time.ts
|
|
6625
6554
|
var timeProvider = {
|
|
6626
6555
|
name: "TIME",
|
|
@@ -6646,7 +6575,7 @@ var timeProvider = {
|
|
|
6646
6575
|
// src/providers/world.ts
|
|
6647
6576
|
import {
|
|
6648
6577
|
logger as logger19,
|
|
6649
|
-
addHeader as
|
|
6578
|
+
addHeader as addHeader10,
|
|
6650
6579
|
ChannelType as ChannelType8
|
|
6651
6580
|
} from "@elizaos/core";
|
|
6652
6581
|
var worldProvider = {
|
|
@@ -6777,7 +6706,7 @@ var worldProvider = {
|
|
|
6777
6706
|
currentChannelName: currentRoom.name,
|
|
6778
6707
|
worldInfo: worldInfoText
|
|
6779
6708
|
};
|
|
6780
|
-
const formattedText =
|
|
6709
|
+
const formattedText = addHeader10("# World Information", worldInfoText);
|
|
6781
6710
|
logger19.debug("[\uD83C\uDF10] World provider completed successfully");
|
|
6782
6711
|
return {
|
|
6783
6712
|
data,
|
|
@@ -7317,29 +7246,41 @@ async function processAttachments(attachments, runtime) {
|
|
|
7317
7246
|
}
|
|
7318
7247
|
return processedAttachments;
|
|
7319
7248
|
}
|
|
7320
|
-
function
|
|
7321
|
-
if (!room)
|
|
7322
|
-
return false;
|
|
7249
|
+
function shouldRespond(runtime, message, room, mentionContext) {
|
|
7250
|
+
if (!room) {
|
|
7251
|
+
return { shouldRespond: false, skipEvaluation: true, reason: "no room context" };
|
|
7252
|
+
}
|
|
7323
7253
|
function normalizeEnvList(value) {
|
|
7324
7254
|
if (!value || typeof value !== "string")
|
|
7325
7255
|
return [];
|
|
7326
7256
|
const cleaned = value.trim().replace(/^\[|\]$/g, "");
|
|
7327
7257
|
return cleaned.split(",").map((v) => v.trim()).filter(Boolean);
|
|
7328
7258
|
}
|
|
7329
|
-
const
|
|
7259
|
+
const alwaysRespondChannels = [
|
|
7330
7260
|
ChannelType9.DM,
|
|
7331
7261
|
ChannelType9.VOICE_DM,
|
|
7332
7262
|
ChannelType9.SELF,
|
|
7333
7263
|
ChannelType9.API
|
|
7334
7264
|
];
|
|
7335
|
-
const
|
|
7336
|
-
const
|
|
7337
|
-
const
|
|
7338
|
-
const
|
|
7339
|
-
const
|
|
7265
|
+
const alwaysRespondSources = ["client_chat"];
|
|
7266
|
+
const customChannels = normalizeEnvList(runtime.getSetting("ALWAYS_RESPOND_CHANNELS") || runtime.getSetting("SHOULD_RESPOND_BYPASS_TYPES"));
|
|
7267
|
+
const customSources = normalizeEnvList(runtime.getSetting("ALWAYS_RESPOND_SOURCES") || runtime.getSetting("SHOULD_RESPOND_BYPASS_SOURCES"));
|
|
7268
|
+
const respondChannels = new Set([...alwaysRespondChannels.map((t) => t.toString()), ...customChannels].map((s) => s.trim().toLowerCase()));
|
|
7269
|
+
const respondSources = [...alwaysRespondSources, ...customSources].map((s) => s.trim().toLowerCase());
|
|
7340
7270
|
const roomType = room.type?.toString().toLowerCase();
|
|
7341
|
-
const sourceStr = source?.toLowerCase() || "";
|
|
7342
|
-
|
|
7271
|
+
const sourceStr = message.content.source?.toLowerCase() || "";
|
|
7272
|
+
if (respondChannels.has(roomType)) {
|
|
7273
|
+
return { shouldRespond: true, skipEvaluation: true, reason: `private channel: ${roomType}` };
|
|
7274
|
+
}
|
|
7275
|
+
if (respondSources.some((pattern) => sourceStr.includes(pattern))) {
|
|
7276
|
+
return { shouldRespond: true, skipEvaluation: true, reason: `whitelisted source: ${sourceStr}` };
|
|
7277
|
+
}
|
|
7278
|
+
const hasPlatformMention = !!(mentionContext?.isMention || mentionContext?.isReply);
|
|
7279
|
+
if (hasPlatformMention) {
|
|
7280
|
+
const mentionType = mentionContext?.isMention ? "mention" : "reply";
|
|
7281
|
+
return { shouldRespond: true, skipEvaluation: true, reason: `platform ${mentionType}` };
|
|
7282
|
+
}
|
|
7283
|
+
return { shouldRespond: false, skipEvaluation: false, reason: "needs LLM evaluation" };
|
|
7343
7284
|
}
|
|
7344
7285
|
var messageReceivedHandler = async ({
|
|
7345
7286
|
runtime,
|
|
@@ -7454,46 +7395,47 @@ var messageReceivedHandler = async ({
|
|
|
7454
7395
|
});
|
|
7455
7396
|
return;
|
|
7456
7397
|
}
|
|
7457
|
-
let state = await runtime.composeState(message, ["ANXIETY", "
|
|
7398
|
+
let state = await runtime.composeState(message, ["ANXIETY", "ENTITIES", "CHARACTER", "RECENT_MESSAGES", "ACTIONS"], true);
|
|
7399
|
+
const mentionContext = message.content.mentionContext;
|
|
7458
7400
|
const room = await runtime.getRoom(message.roomId);
|
|
7459
|
-
const shouldSkipShouldRespond = shouldBypassShouldRespond(runtime, room ?? undefined, message.content.source);
|
|
7460
7401
|
if (message.content.attachments && message.content.attachments.length > 0) {
|
|
7461
7402
|
message.content.attachments = await processAttachments(message.content.attachments, runtime);
|
|
7462
7403
|
if (message.id) {
|
|
7463
7404
|
await runtime.updateMemory({ id: message.id, content: message.content });
|
|
7464
7405
|
}
|
|
7465
7406
|
}
|
|
7466
|
-
|
|
7467
|
-
|
|
7407
|
+
const responseDecision = shouldRespond(runtime, message, room ?? undefined, mentionContext);
|
|
7408
|
+
runtime.logger.debug(`[Bootstrap] Response decision: ${JSON.stringify(responseDecision)}`);
|
|
7409
|
+
let shouldRespondToMessage = true;
|
|
7410
|
+
if (responseDecision.skipEvaluation) {
|
|
7411
|
+
runtime.logger.debug(`[Bootstrap] Skipping evaluation for ${runtime.character.name} (${responseDecision.reason})`);
|
|
7412
|
+
shouldRespondToMessage = responseDecision.shouldRespond;
|
|
7413
|
+
} else {
|
|
7468
7414
|
const shouldRespondPrompt = composePromptFromState10({
|
|
7469
7415
|
state,
|
|
7470
7416
|
template: runtime.character.templates?.shouldRespondTemplate || shouldRespondTemplate
|
|
7471
7417
|
});
|
|
7472
|
-
runtime.logger.debug(`[Bootstrap]
|
|
7473
|
-
Prompt: ${shouldRespondPrompt}`);
|
|
7418
|
+
runtime.logger.debug(`[Bootstrap] Using LLM evaluation for ${runtime.character.name} (${responseDecision.reason})`);
|
|
7474
7419
|
const response = await runtime.useModel(ModelType15.TEXT_SMALL, {
|
|
7475
7420
|
prompt: shouldRespondPrompt
|
|
7476
7421
|
});
|
|
7477
|
-
runtime.logger.debug(`[Bootstrap]
|
|
7422
|
+
runtime.logger.debug(`[Bootstrap] LLM evaluation result:
|
|
7478
7423
|
${response}`);
|
|
7479
|
-
runtime.logger.debug(`[Bootstrap] Response type: ${typeof response}`);
|
|
7480
7424
|
const responseObject = parseKeyValueXml9(response);
|
|
7481
|
-
runtime.logger.debug({ responseObject }, "[Bootstrap] Parsed
|
|
7425
|
+
runtime.logger.debug({ responseObject }, "[Bootstrap] Parsed evaluation result:");
|
|
7482
7426
|
const nonResponseActions = ["IGNORE", "NONE"];
|
|
7483
|
-
|
|
7484
|
-
} else {
|
|
7485
|
-
runtime.logger.debug(`[Bootstrap] Skipping shouldRespond check for ${runtime.character.name} because ${room?.type} ${room?.source}`);
|
|
7486
|
-
shouldRespond = true;
|
|
7427
|
+
shouldRespondToMessage = responseObject?.action && !nonResponseActions.includes(responseObject.action.toUpperCase());
|
|
7487
7428
|
}
|
|
7488
7429
|
let responseContent = null;
|
|
7489
7430
|
let responseMessages = [];
|
|
7490
|
-
|
|
7431
|
+
const keepResp = parseBooleanFromText2(runtime.getSetting("BOOTSTRAP_KEEP_RESP"));
|
|
7432
|
+
if (shouldRespondToMessage) {
|
|
7491
7433
|
const result = useMultiStep ? await runMultiStepCore({ runtime, message, state, callback }) : await runSingleShotCore({ runtime, message, state });
|
|
7492
7434
|
responseContent = result.responseContent;
|
|
7493
7435
|
responseMessages = result.responseMessages;
|
|
7494
7436
|
state = result.state;
|
|
7495
7437
|
const currentResponseId = agentResponses.get(message.roomId);
|
|
7496
|
-
if (currentResponseId !== responseId) {
|
|
7438
|
+
if (currentResponseId !== responseId && !keepResp) {
|
|
7497
7439
|
runtime.logger.info(`Response discarded - newer message being processed for agent: ${runtime.agentId}, room: ${message.roomId}`);
|
|
7498
7440
|
return;
|
|
7499
7441
|
}
|
|
@@ -7526,7 +7468,6 @@ ${response}`);
|
|
|
7526
7468
|
} else {
|
|
7527
7469
|
runtime.logger.debug("[Bootstrap] Agent decided not to respond (shouldRespond is false).");
|
|
7528
7470
|
const currentResponseId = agentResponses.get(message.roomId);
|
|
7529
|
-
const keepResp = parseBooleanFromText2(runtime.getSetting("BOOTSTRAP_KEEP_RESP"));
|
|
7530
7471
|
if (currentResponseId !== responseId && !keepResp) {
|
|
7531
7472
|
runtime.logger.info(`Ignore response discarded - newer message being processed for agent: ${runtime.agentId}, room: ${message.roomId}`);
|
|
7532
7473
|
await runtime.emitEvent(EventType2.RUN_ENDED, {
|
|
@@ -7583,7 +7524,7 @@ ${response}`);
|
|
|
7583
7524
|
if (agentResponses.size === 0) {
|
|
7584
7525
|
latestResponseIds.delete(runtime.agentId);
|
|
7585
7526
|
}
|
|
7586
|
-
await runtime.evaluate(message, state,
|
|
7527
|
+
await runtime.evaluate(message, state, shouldRespondToMessage, async (content) => {
|
|
7587
7528
|
runtime.logger.debug({ content }, "evaluate callback");
|
|
7588
7529
|
if (responseContent) {
|
|
7589
7530
|
responseContent.evalCallbacks = content;
|
|
@@ -7807,7 +7748,7 @@ async function runMultiStepCore({ runtime, message, state, callback }) {
|
|
|
7807
7748
|
data: { actionName: providerName },
|
|
7808
7749
|
success,
|
|
7809
7750
|
text: success ? providerResult.text : undefined,
|
|
7810
|
-
error: success ? undefined : providerResult?.
|
|
7751
|
+
error: success ? undefined : providerResult?.text
|
|
7811
7752
|
});
|
|
7812
7753
|
if (callback) {
|
|
7813
7754
|
await callback({
|
|
@@ -8047,7 +7988,7 @@ $2`);
|
|
|
8047
7988
|
return cleanedText2;
|
|
8048
7989
|
}
|
|
8049
7990
|
const cleanedText = cleanupPostText(parsedXmlResponse.post || "");
|
|
8050
|
-
const RM = state.
|
|
7991
|
+
const RM = state.data?.providers?.RECENT_MESSAGES;
|
|
8051
7992
|
if (RM) {
|
|
8052
7993
|
for (const m of RM.data.recentMessages) {
|
|
8053
7994
|
if (cleanedText === m.content.text) {
|
|
@@ -8445,7 +8386,6 @@ var bootstrapPlugin = {
|
|
|
8445
8386
|
providers: [
|
|
8446
8387
|
evaluatorsProvider,
|
|
8447
8388
|
anxietyProvider,
|
|
8448
|
-
shouldRespondProvider,
|
|
8449
8389
|
timeProvider,
|
|
8450
8390
|
entitiesProvider,
|
|
8451
8391
|
relationshipsProvider,
|
|
@@ -8472,8 +8412,7 @@ export {
|
|
|
8472
8412
|
unmuteRoomAction,
|
|
8473
8413
|
unfollowRoomAction,
|
|
8474
8414
|
timeProvider,
|
|
8475
|
-
|
|
8476
|
-
shouldBypassShouldRespond,
|
|
8415
|
+
shouldRespond,
|
|
8477
8416
|
settingsProvider,
|
|
8478
8417
|
sendMessageAction,
|
|
8479
8418
|
roleProvider,
|
|
@@ -8504,5 +8443,5 @@ export {
|
|
|
8504
8443
|
actionStateProvider
|
|
8505
8444
|
};
|
|
8506
8445
|
|
|
8507
|
-
//# debugId=
|
|
8446
|
+
//# debugId=3D49F89DB441356C64756E2164756E21
|
|
8508
8447
|
//# sourceMappingURL=index.js.map
|