@elizaos/plugin-bootstrap 1.4.3 → 1.4.5
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 +297 -55
- package/dist/index.js.map +1 -1
- package/package.json +4 -4
package/dist/index.js
CHANGED
|
@@ -71,16 +71,16 @@ var require_dedent = __commonJS({
|
|
|
71
71
|
|
|
72
72
|
// src/index.ts
|
|
73
73
|
import {
|
|
74
|
-
asUUID,
|
|
74
|
+
asUUID as asUUID2,
|
|
75
75
|
ChannelType as ChannelType9,
|
|
76
76
|
composePromptFromState as composePromptFromState10,
|
|
77
77
|
ContentType as ContentType2,
|
|
78
78
|
createUniqueUuid as createUniqueUuid3,
|
|
79
|
-
EventType,
|
|
79
|
+
EventType as EventType2,
|
|
80
80
|
imageDescriptionTemplate,
|
|
81
|
-
logger as
|
|
81
|
+
logger as logger21,
|
|
82
82
|
messageHandlerTemplate,
|
|
83
|
-
ModelType as
|
|
83
|
+
ModelType as ModelType15,
|
|
84
84
|
parseKeyValueXml as parseKeyValueXml9,
|
|
85
85
|
postCreationTemplate,
|
|
86
86
|
parseBooleanFromText as parseBooleanFromText2,
|
|
@@ -4561,7 +4561,7 @@ var updateEntityAction = {
|
|
|
4561
4561
|
|
|
4562
4562
|
// src/evaluators/reflection.ts
|
|
4563
4563
|
import { z } from "zod";
|
|
4564
|
-
import { getEntityDetails, logger as logger10, parseKeyValueXml as parseKeyValueXml8 } from "@elizaos/core";
|
|
4564
|
+
import { asUUID, getEntityDetails, logger as logger10, parseKeyValueXml as parseKeyValueXml8 } from "@elizaos/core";
|
|
4565
4565
|
import { composePrompt as composePrompt4 } from "@elizaos/core";
|
|
4566
4566
|
import {
|
|
4567
4567
|
ModelType as ModelType12
|
|
@@ -4723,14 +4723,18 @@ async function handler(runtime, message, state) {
|
|
|
4723
4723
|
) || [];
|
|
4724
4724
|
await Promise.all(
|
|
4725
4725
|
newFacts.map(async (fact) => {
|
|
4726
|
-
const factMemory =
|
|
4726
|
+
const factMemory = {
|
|
4727
|
+
id: asUUID(v4_default()),
|
|
4727
4728
|
entityId: agentId,
|
|
4728
4729
|
agentId,
|
|
4729
4730
|
content: { text: fact.claim },
|
|
4730
4731
|
roomId,
|
|
4731
4732
|
createdAt: Date.now()
|
|
4732
|
-
}
|
|
4733
|
-
|
|
4733
|
+
};
|
|
4734
|
+
const createdMemoryId = await runtime.createMemory(factMemory, "facts", true);
|
|
4735
|
+
const createdMemory = { ...factMemory, id: createdMemoryId };
|
|
4736
|
+
await runtime.queueEmbeddingGeneration(createdMemory, "low");
|
|
4737
|
+
return createdMemory;
|
|
4734
4738
|
})
|
|
4735
4739
|
);
|
|
4736
4740
|
let relationshipsArray = [];
|
|
@@ -6895,6 +6899,245 @@ var TaskService = class _TaskService extends Service {
|
|
|
6895
6899
|
}
|
|
6896
6900
|
};
|
|
6897
6901
|
|
|
6902
|
+
// src/services/embedding.ts
|
|
6903
|
+
import {
|
|
6904
|
+
Service as Service2,
|
|
6905
|
+
EventType,
|
|
6906
|
+
ModelType as ModelType14,
|
|
6907
|
+
logger as logger20
|
|
6908
|
+
} from "@elizaos/core";
|
|
6909
|
+
var EmbeddingGenerationService = class _EmbeddingGenerationService extends Service2 {
|
|
6910
|
+
static serviceType = "embedding-generation";
|
|
6911
|
+
capabilityDescription = "Handles asynchronous embedding generation for memories";
|
|
6912
|
+
queue = [];
|
|
6913
|
+
isProcessing = false;
|
|
6914
|
+
processingInterval = null;
|
|
6915
|
+
maxQueueSize = 1e3;
|
|
6916
|
+
batchSize = 10;
|
|
6917
|
+
// Process up to 10 embeddings at a time
|
|
6918
|
+
processingIntervalMs = 100;
|
|
6919
|
+
// Check queue every 100ms
|
|
6920
|
+
static async start(runtime) {
|
|
6921
|
+
logger20.info("[EmbeddingService] Starting embedding generation service");
|
|
6922
|
+
const service = new _EmbeddingGenerationService(runtime);
|
|
6923
|
+
await service.initialize();
|
|
6924
|
+
return service;
|
|
6925
|
+
}
|
|
6926
|
+
async initialize() {
|
|
6927
|
+
logger20.info("[EmbeddingService] Initializing embedding generation service");
|
|
6928
|
+
this.runtime.registerEvent(
|
|
6929
|
+
EventType.EMBEDDING_GENERATION_REQUESTED,
|
|
6930
|
+
this.handleEmbeddingRequest.bind(this)
|
|
6931
|
+
);
|
|
6932
|
+
this.startProcessing();
|
|
6933
|
+
}
|
|
6934
|
+
async handleEmbeddingRequest(payload) {
|
|
6935
|
+
const { memory, priority = "normal", retryCount = 0, maxRetries = 3 } = payload;
|
|
6936
|
+
if (memory.embedding) {
|
|
6937
|
+
logger20.debug("[EmbeddingService] Memory already has embeddings, skipping");
|
|
6938
|
+
return;
|
|
6939
|
+
}
|
|
6940
|
+
if (this.queue.length >= this.maxQueueSize) {
|
|
6941
|
+
logger20.warn(
|
|
6942
|
+
`[EmbeddingService] Queue is full (${this.queue.length}/${this.maxQueueSize}), making room`
|
|
6943
|
+
);
|
|
6944
|
+
this.makeRoomInQueue();
|
|
6945
|
+
}
|
|
6946
|
+
const queueItem = {
|
|
6947
|
+
memory,
|
|
6948
|
+
priority,
|
|
6949
|
+
retryCount,
|
|
6950
|
+
maxRetries,
|
|
6951
|
+
addedAt: Date.now()
|
|
6952
|
+
};
|
|
6953
|
+
this.insertItemByPriority(queueItem);
|
|
6954
|
+
logger20.debug(`[EmbeddingService] Added memory to queue. Queue size: ${this.queue.length}`);
|
|
6955
|
+
}
|
|
6956
|
+
/**
|
|
6957
|
+
* Make room in the queue by removing items based on priority and age
|
|
6958
|
+
* Removes 10% of the queue (minimum 1, maximum 10 items)
|
|
6959
|
+
*/
|
|
6960
|
+
makeRoomInQueue() {
|
|
6961
|
+
const tenPercent = Math.floor(this.maxQueueSize * 0.1);
|
|
6962
|
+
const itemsToRemove = Math.min(10, Math.max(1, tenPercent));
|
|
6963
|
+
const itemsWithIndex = this.queue.map((item, index) => ({ item, originalIndex: index }));
|
|
6964
|
+
itemsWithIndex.sort((a2, b) => {
|
|
6965
|
+
const priorityOrder = { low: 0, normal: 1, high: 2 };
|
|
6966
|
+
const priorityDiff = priorityOrder[a2.item.priority] - priorityOrder[b.item.priority];
|
|
6967
|
+
if (priorityDiff !== 0) return priorityDiff;
|
|
6968
|
+
return a2.item.addedAt - b.item.addedAt;
|
|
6969
|
+
});
|
|
6970
|
+
const indicesToRemove = new Set(
|
|
6971
|
+
itemsWithIndex.slice(0, Math.min(itemsToRemove, itemsWithIndex.length)).map(({ originalIndex }) => originalIndex)
|
|
6972
|
+
);
|
|
6973
|
+
const newQueue = this.queue.filter((_, index) => !indicesToRemove.has(index));
|
|
6974
|
+
const removedCount = this.queue.length - newQueue.length;
|
|
6975
|
+
this.queue = newQueue;
|
|
6976
|
+
logger20.info(
|
|
6977
|
+
`[EmbeddingService] Removed ${removedCount} items from queue. New size: ${this.queue.length}`
|
|
6978
|
+
);
|
|
6979
|
+
}
|
|
6980
|
+
/**
|
|
6981
|
+
* Insert an item into the queue based on its priority
|
|
6982
|
+
* High priority items go to the front, normal in the middle, low at the end
|
|
6983
|
+
*/
|
|
6984
|
+
insertItemByPriority(queueItem) {
|
|
6985
|
+
if (queueItem.priority === "high") {
|
|
6986
|
+
let insertIndex = 0;
|
|
6987
|
+
for (let i2 = 0; i2 < this.queue.length; i2++) {
|
|
6988
|
+
if (this.queue[i2].priority !== "high") break;
|
|
6989
|
+
insertIndex = i2 + 1;
|
|
6990
|
+
}
|
|
6991
|
+
this.queue.splice(insertIndex, 0, queueItem);
|
|
6992
|
+
} else if (queueItem.priority === "low") {
|
|
6993
|
+
this.queue.push(queueItem);
|
|
6994
|
+
} else {
|
|
6995
|
+
let insertIndex = 0;
|
|
6996
|
+
for (let i2 = 0; i2 < this.queue.length; i2++) {
|
|
6997
|
+
if (this.queue[i2].priority !== "high") {
|
|
6998
|
+
insertIndex = i2;
|
|
6999
|
+
break;
|
|
7000
|
+
}
|
|
7001
|
+
insertIndex = i2 + 1;
|
|
7002
|
+
}
|
|
7003
|
+
for (let i2 = insertIndex; i2 < this.queue.length; i2++) {
|
|
7004
|
+
if (this.queue[i2].priority === "low") {
|
|
7005
|
+
insertIndex = i2;
|
|
7006
|
+
break;
|
|
7007
|
+
}
|
|
7008
|
+
insertIndex = i2 + 1;
|
|
7009
|
+
}
|
|
7010
|
+
this.queue.splice(insertIndex, 0, queueItem);
|
|
7011
|
+
}
|
|
7012
|
+
}
|
|
7013
|
+
startProcessing() {
|
|
7014
|
+
if (this.processingInterval) {
|
|
7015
|
+
return;
|
|
7016
|
+
}
|
|
7017
|
+
this.processingInterval = setInterval(async () => {
|
|
7018
|
+
if (!this.isProcessing && this.queue.length > 0) {
|
|
7019
|
+
await this.processQueue();
|
|
7020
|
+
}
|
|
7021
|
+
}, this.processingIntervalMs);
|
|
7022
|
+
logger20.info("[EmbeddingService] Started processing loop");
|
|
7023
|
+
}
|
|
7024
|
+
async processQueue() {
|
|
7025
|
+
if (this.isProcessing || this.queue.length === 0) {
|
|
7026
|
+
return;
|
|
7027
|
+
}
|
|
7028
|
+
this.isProcessing = true;
|
|
7029
|
+
try {
|
|
7030
|
+
const batch = this.queue.splice(0, Math.min(this.batchSize, this.queue.length));
|
|
7031
|
+
logger20.debug(
|
|
7032
|
+
`[EmbeddingService] Processing batch of ${batch.length} items. Remaining in queue: ${this.queue.length}`
|
|
7033
|
+
);
|
|
7034
|
+
const promises = batch.map(async (item) => {
|
|
7035
|
+
try {
|
|
7036
|
+
await this.generateEmbedding(item);
|
|
7037
|
+
} catch (error) {
|
|
7038
|
+
logger20.error(
|
|
7039
|
+
{ error, memoryId: item.memory.id },
|
|
7040
|
+
"[EmbeddingService] Error processing item:"
|
|
7041
|
+
);
|
|
7042
|
+
if (item.retryCount < item.maxRetries) {
|
|
7043
|
+
item.retryCount++;
|
|
7044
|
+
this.insertItemByPriority(item);
|
|
7045
|
+
logger20.debug(
|
|
7046
|
+
`[EmbeddingService] Re-queued item for retry (${item.retryCount}/${item.maxRetries})`
|
|
7047
|
+
);
|
|
7048
|
+
} else {
|
|
7049
|
+
await this.runtime.emitEvent(EventType.EMBEDDING_GENERATION_FAILED, {
|
|
7050
|
+
runtime: this.runtime,
|
|
7051
|
+
memory: item.memory,
|
|
7052
|
+
error: error instanceof Error ? error.message : String(error),
|
|
7053
|
+
source: "embeddingService"
|
|
7054
|
+
});
|
|
7055
|
+
}
|
|
7056
|
+
}
|
|
7057
|
+
});
|
|
7058
|
+
await Promise.all(promises);
|
|
7059
|
+
} finally {
|
|
7060
|
+
this.isProcessing = false;
|
|
7061
|
+
}
|
|
7062
|
+
}
|
|
7063
|
+
async generateEmbedding(item) {
|
|
7064
|
+
const { memory } = item;
|
|
7065
|
+
if (!memory.content?.text) {
|
|
7066
|
+
logger20.warn({ memoryId: memory.id }, "[EmbeddingService] Memory has no text content");
|
|
7067
|
+
return;
|
|
7068
|
+
}
|
|
7069
|
+
try {
|
|
7070
|
+
const startTime = Date.now();
|
|
7071
|
+
const embedding = await this.runtime.useModel(ModelType14.TEXT_EMBEDDING, {
|
|
7072
|
+
text: memory.content.text
|
|
7073
|
+
});
|
|
7074
|
+
const duration = Date.now() - startTime;
|
|
7075
|
+
logger20.debug(
|
|
7076
|
+
`[EmbeddingService] Generated embedding in ${duration}ms for memory ${memory.id}`
|
|
7077
|
+
);
|
|
7078
|
+
if (memory.id) {
|
|
7079
|
+
await this.runtime.updateMemory({
|
|
7080
|
+
id: memory.id,
|
|
7081
|
+
embedding
|
|
7082
|
+
});
|
|
7083
|
+
await this.runtime.emitEvent(EventType.EMBEDDING_GENERATION_COMPLETED, {
|
|
7084
|
+
runtime: this.runtime,
|
|
7085
|
+
memory: { ...memory, embedding },
|
|
7086
|
+
source: "embeddingService"
|
|
7087
|
+
});
|
|
7088
|
+
}
|
|
7089
|
+
} catch (error) {
|
|
7090
|
+
logger20.error(
|
|
7091
|
+
{ error, memoryId: memory.id },
|
|
7092
|
+
"[EmbeddingService] Failed to generate embedding:"
|
|
7093
|
+
);
|
|
7094
|
+
throw error;
|
|
7095
|
+
}
|
|
7096
|
+
}
|
|
7097
|
+
async stop() {
|
|
7098
|
+
logger20.info("[EmbeddingService] Stopping embedding generation service");
|
|
7099
|
+
if (this.processingInterval) {
|
|
7100
|
+
clearInterval(this.processingInterval);
|
|
7101
|
+
this.processingInterval = null;
|
|
7102
|
+
}
|
|
7103
|
+
const highPriorityItems = this.queue.filter((item) => item.priority === "high");
|
|
7104
|
+
if (highPriorityItems.length > 0) {
|
|
7105
|
+
logger20.info(
|
|
7106
|
+
`[EmbeddingService] Processing ${highPriorityItems.length} high priority items before shutdown`
|
|
7107
|
+
);
|
|
7108
|
+
for (const item of highPriorityItems) {
|
|
7109
|
+
try {
|
|
7110
|
+
await this.generateEmbedding(item);
|
|
7111
|
+
} catch (error) {
|
|
7112
|
+
logger20.error({ error }, "[EmbeddingService] Error during shutdown processing:");
|
|
7113
|
+
}
|
|
7114
|
+
}
|
|
7115
|
+
}
|
|
7116
|
+
logger20.info(`[EmbeddingService] Stopped. ${this.queue.length} items remaining in queue`);
|
|
7117
|
+
}
|
|
7118
|
+
// Public methods for monitoring
|
|
7119
|
+
getQueueSize() {
|
|
7120
|
+
return this.queue.length;
|
|
7121
|
+
}
|
|
7122
|
+
getQueueStats() {
|
|
7123
|
+
const stats = {
|
|
7124
|
+
high: 0,
|
|
7125
|
+
normal: 0,
|
|
7126
|
+
low: 0,
|
|
7127
|
+
total: this.queue.length
|
|
7128
|
+
};
|
|
7129
|
+
for (const item of this.queue) {
|
|
7130
|
+
stats[item.priority]++;
|
|
7131
|
+
}
|
|
7132
|
+
return stats;
|
|
7133
|
+
}
|
|
7134
|
+
clearQueue() {
|
|
7135
|
+
const size = this.queue.length;
|
|
7136
|
+
this.queue = [];
|
|
7137
|
+
logger20.info(`[EmbeddingService] Cleared ${size} items from queue`);
|
|
7138
|
+
}
|
|
7139
|
+
};
|
|
7140
|
+
|
|
6898
7141
|
// src/index.ts
|
|
6899
7142
|
var latestResponseIds = /* @__PURE__ */ new Map();
|
|
6900
7143
|
async function fetchMediaData(attachments) {
|
|
@@ -6936,7 +7179,7 @@ async function processAttachments(attachments, runtime) {
|
|
|
6936
7179
|
imageUrl = `data:${contentType};base64,${buffer.toString("base64")}`;
|
|
6937
7180
|
}
|
|
6938
7181
|
try {
|
|
6939
|
-
const response = await runtime.useModel(
|
|
7182
|
+
const response = await runtime.useModel(ModelType15.IMAGE_DESCRIPTION, {
|
|
6940
7183
|
prompt: imageDescriptionTemplate,
|
|
6941
7184
|
imageUrl
|
|
6942
7185
|
});
|
|
@@ -7060,14 +7303,14 @@ var messageReceivedHandler = async ({
|
|
|
7060
7303
|
}
|
|
7061
7304
|
const previousResponseId = agentResponses.get(message.roomId);
|
|
7062
7305
|
if (previousResponseId) {
|
|
7063
|
-
|
|
7306
|
+
logger21.warn(
|
|
7064
7307
|
`[Bootstrap] Updating response ID for room ${message.roomId} from ${previousResponseId} to ${responseId} - this may discard in-progress responses`
|
|
7065
7308
|
);
|
|
7066
7309
|
}
|
|
7067
7310
|
agentResponses.set(message.roomId, responseId);
|
|
7068
7311
|
const runId = runtime.startRun();
|
|
7069
7312
|
const startTime = Date.now();
|
|
7070
|
-
await runtime.emitEvent(
|
|
7313
|
+
await runtime.emitEvent(EventType2.RUN_STARTED, {
|
|
7071
7314
|
runtime,
|
|
7072
7315
|
runId,
|
|
7073
7316
|
messageId: message.id,
|
|
@@ -7082,7 +7325,7 @@ var messageReceivedHandler = async ({
|
|
|
7082
7325
|
});
|
|
7083
7326
|
const timeoutPromise = new Promise((_, reject) => {
|
|
7084
7327
|
timeoutId = setTimeout(async () => {
|
|
7085
|
-
await runtime.emitEvent(
|
|
7328
|
+
await runtime.emitEvent(EventType2.RUN_TIMEOUT, {
|
|
7086
7329
|
runtime,
|
|
7087
7330
|
runId,
|
|
7088
7331
|
messageId: message.id,
|
|
@@ -7107,23 +7350,23 @@ var messageReceivedHandler = async ({
|
|
|
7107
7350
|
runtime.logger.debug(
|
|
7108
7351
|
`[Bootstrap] Processing message: ${truncateToCompleteSentence(message.content.text || "", 50)}...`
|
|
7109
7352
|
);
|
|
7110
|
-
runtime.logger.debug("[Bootstrap] Saving message to memory and embeddings");
|
|
7353
|
+
runtime.logger.debug("[Bootstrap] Saving message to memory and queueing embeddings");
|
|
7354
|
+
let memoryToQueue;
|
|
7111
7355
|
if (message.id) {
|
|
7112
7356
|
const existingMemory = await runtime.getMemoryById(message.id);
|
|
7113
7357
|
if (existingMemory) {
|
|
7114
7358
|
runtime.logger.debug("[Bootstrap] Memory already exists, skipping creation");
|
|
7115
|
-
|
|
7359
|
+
memoryToQueue = existingMemory;
|
|
7116
7360
|
} else {
|
|
7117
|
-
await
|
|
7118
|
-
|
|
7119
|
-
runtime.createMemory(message, "messages")
|
|
7120
|
-
]);
|
|
7361
|
+
const createdMemoryId = await runtime.createMemory(message, "messages");
|
|
7362
|
+
memoryToQueue = { ...message, id: createdMemoryId };
|
|
7121
7363
|
}
|
|
7364
|
+
await runtime.queueEmbeddingGeneration(memoryToQueue, "high");
|
|
7122
7365
|
} else {
|
|
7123
|
-
await
|
|
7124
|
-
|
|
7125
|
-
|
|
7126
|
-
|
|
7366
|
+
const memoryId = await runtime.createMemory(message, "messages");
|
|
7367
|
+
message.id = memoryId;
|
|
7368
|
+
memoryToQueue = { ...message, id: memoryId };
|
|
7369
|
+
await runtime.queueEmbeddingGeneration(memoryToQueue, "normal");
|
|
7127
7370
|
}
|
|
7128
7371
|
const agentUserState = await runtime.getParticipantUserState(
|
|
7129
7372
|
message.roomId,
|
|
@@ -7132,7 +7375,7 @@ var messageReceivedHandler = async ({
|
|
|
7132
7375
|
const defLllmOff = parseBooleanFromText2(runtime.getSetting("BOOTSTRAP_DEFLLMOFF"));
|
|
7133
7376
|
if (defLllmOff && agentUserState === null) {
|
|
7134
7377
|
runtime.logger.debug("bootstrap - LLM is off by default");
|
|
7135
|
-
await runtime.emitEvent(
|
|
7378
|
+
await runtime.emitEvent(EventType2.RUN_ENDED, {
|
|
7136
7379
|
runtime,
|
|
7137
7380
|
runId,
|
|
7138
7381
|
messageId: message.id,
|
|
@@ -7148,7 +7391,7 @@ var messageReceivedHandler = async ({
|
|
|
7148
7391
|
}
|
|
7149
7392
|
if (agentUserState === "MUTED" && !message.content.text?.toLowerCase().includes(runtime.character.name.toLowerCase())) {
|
|
7150
7393
|
runtime.logger.debug(`[Bootstrap] Ignoring muted room ${message.roomId}`);
|
|
7151
|
-
await runtime.emitEvent(
|
|
7394
|
+
await runtime.emitEvent(EventType2.RUN_ENDED, {
|
|
7152
7395
|
runtime,
|
|
7153
7396
|
runId,
|
|
7154
7397
|
messageId: message.id,
|
|
@@ -7195,7 +7438,7 @@ var messageReceivedHandler = async ({
|
|
|
7195
7438
|
`[Bootstrap] Evaluating response for ${runtime.character.name}
|
|
7196
7439
|
Prompt: ${shouldRespondPrompt}`
|
|
7197
7440
|
);
|
|
7198
|
-
const response = await runtime.useModel(
|
|
7441
|
+
const response = await runtime.useModel(ModelType15.TEXT_SMALL, {
|
|
7199
7442
|
prompt: shouldRespondPrompt
|
|
7200
7443
|
});
|
|
7201
7444
|
runtime.logger.debug(
|
|
@@ -7229,7 +7472,7 @@ ${response}`
|
|
|
7229
7472
|
let retries = 0;
|
|
7230
7473
|
const maxRetries = 3;
|
|
7231
7474
|
while (retries < maxRetries && (!responseContent?.thought || !responseContent?.actions)) {
|
|
7232
|
-
let response = await runtime.useModel(
|
|
7475
|
+
let response = await runtime.useModel(ModelType15.TEXT_LARGE, {
|
|
7233
7476
|
prompt
|
|
7234
7477
|
});
|
|
7235
7478
|
runtime.logger.debug({ response }, "[Bootstrap] *** Raw LLM Response ***");
|
|
@@ -7287,7 +7530,7 @@ ${response}`
|
|
|
7287
7530
|
const isSimple = responseContent.actions?.length === 1 && typeof responseContent.actions[0] === "string" && responseContent.actions[0].toUpperCase() === "REPLY" && (!responseContent.providers || responseContent.providers.length === 0);
|
|
7288
7531
|
responseContent.simple = isSimple;
|
|
7289
7532
|
const responseMessage = {
|
|
7290
|
-
id:
|
|
7533
|
+
id: asUUID2(v4_default()),
|
|
7291
7534
|
entityId: runtime.agentId,
|
|
7292
7535
|
agentId: runtime.agentId,
|
|
7293
7536
|
content: responseContent,
|
|
@@ -7343,7 +7586,7 @@ ${response}`
|
|
|
7343
7586
|
runtime.logger.info(
|
|
7344
7587
|
`Ignore response discarded - newer message being processed for agent: ${runtime.agentId}, room: ${message.roomId}`
|
|
7345
7588
|
);
|
|
7346
|
-
await runtime.emitEvent(
|
|
7589
|
+
await runtime.emitEvent(EventType2.RUN_ENDED, {
|
|
7347
7590
|
runtime,
|
|
7348
7591
|
runId,
|
|
7349
7592
|
messageId: message.id,
|
|
@@ -7361,7 +7604,7 @@ ${response}`
|
|
|
7361
7604
|
runtime.logger.error(
|
|
7362
7605
|
"[Bootstrap] Message ID is missing, cannot create ignore response."
|
|
7363
7606
|
);
|
|
7364
|
-
await runtime.emitEvent(
|
|
7607
|
+
await runtime.emitEvent(EventType2.RUN_ENDED, {
|
|
7365
7608
|
runtime,
|
|
7366
7609
|
runId,
|
|
7367
7610
|
messageId: message.id,
|
|
@@ -7385,7 +7628,7 @@ ${response}`
|
|
|
7385
7628
|
};
|
|
7386
7629
|
await callback(ignoreContent);
|
|
7387
7630
|
const ignoreMemory = {
|
|
7388
|
-
id:
|
|
7631
|
+
id: asUUID2(v4_default()),
|
|
7389
7632
|
entityId: runtime.agentId,
|
|
7390
7633
|
agentId: runtime.agentId,
|
|
7391
7634
|
content: ignoreContent,
|
|
@@ -7446,7 +7689,7 @@ ${response}`
|
|
|
7446
7689
|
channelType: message.content.channelType,
|
|
7447
7690
|
roomName
|
|
7448
7691
|
};
|
|
7449
|
-
await runtime.emitEvent(
|
|
7692
|
+
await runtime.emitEvent(EventType2.RUN_ENDED, {
|
|
7450
7693
|
runtime,
|
|
7451
7694
|
runId,
|
|
7452
7695
|
messageId: message.id,
|
|
@@ -7463,7 +7706,7 @@ ${response}`
|
|
|
7463
7706
|
});
|
|
7464
7707
|
} catch (error) {
|
|
7465
7708
|
console.error("error is", error);
|
|
7466
|
-
await runtime.emitEvent(
|
|
7709
|
+
await runtime.emitEvent(EventType2.RUN_ENDED, {
|
|
7467
7710
|
runtime,
|
|
7468
7711
|
runId,
|
|
7469
7712
|
messageId: message.id,
|
|
@@ -7610,7 +7853,7 @@ var postGeneratedHandler = async ({
|
|
|
7610
7853
|
let retries = 0;
|
|
7611
7854
|
const maxRetries = 3;
|
|
7612
7855
|
while (retries < maxRetries && (!responseContent?.thought || !responseContent?.actions)) {
|
|
7613
|
-
const response = await runtime.useModel(
|
|
7856
|
+
const response = await runtime.useModel(ModelType15.TEXT_SMALL, {
|
|
7614
7857
|
prompt
|
|
7615
7858
|
});
|
|
7616
7859
|
console.log("prompt is", prompt);
|
|
@@ -7642,7 +7885,7 @@ var postGeneratedHandler = async ({
|
|
|
7642
7885
|
state,
|
|
7643
7886
|
template: runtime.character.templates?.postCreationTemplate || postCreationTemplate
|
|
7644
7887
|
});
|
|
7645
|
-
const xmlResponseText = await runtime.useModel(
|
|
7888
|
+
const xmlResponseText = await runtime.useModel(ModelType15.TEXT_LARGE, {
|
|
7646
7889
|
prompt: postPrompt
|
|
7647
7890
|
});
|
|
7648
7891
|
const parsedXmlResponse = parseKeyValueXml9(xmlResponseText);
|
|
@@ -7822,7 +8065,7 @@ var controlMessageHandler = async ({
|
|
|
7822
8065
|
}
|
|
7823
8066
|
};
|
|
7824
8067
|
var events = {
|
|
7825
|
-
[
|
|
8068
|
+
[EventType2.MESSAGE_RECEIVED]: [
|
|
7826
8069
|
async (payload) => {
|
|
7827
8070
|
if (!payload.callback) {
|
|
7828
8071
|
payload.runtime.logger.error("No callback provided for message");
|
|
@@ -7836,7 +8079,7 @@ var events = {
|
|
|
7836
8079
|
});
|
|
7837
8080
|
}
|
|
7838
8081
|
],
|
|
7839
|
-
[
|
|
8082
|
+
[EventType2.VOICE_MESSAGE_RECEIVED]: [
|
|
7840
8083
|
async (payload) => {
|
|
7841
8084
|
if (!payload.callback) {
|
|
7842
8085
|
payload.runtime.logger.error("No callback provided for voice message");
|
|
@@ -7850,7 +8093,7 @@ var events = {
|
|
|
7850
8093
|
});
|
|
7851
8094
|
}
|
|
7852
8095
|
],
|
|
7853
|
-
[
|
|
8096
|
+
[EventType2.REACTION_RECEIVED]: [
|
|
7854
8097
|
async (payload) => {
|
|
7855
8098
|
await reactionReceivedHandler({
|
|
7856
8099
|
runtime: payload.runtime,
|
|
@@ -7858,17 +8101,17 @@ var events = {
|
|
|
7858
8101
|
});
|
|
7859
8102
|
}
|
|
7860
8103
|
],
|
|
7861
|
-
[
|
|
8104
|
+
[EventType2.POST_GENERATED]: [
|
|
7862
8105
|
async (payload) => {
|
|
7863
8106
|
await postGeneratedHandler(payload);
|
|
7864
8107
|
}
|
|
7865
8108
|
],
|
|
7866
|
-
[
|
|
8109
|
+
[EventType2.MESSAGE_SENT]: [
|
|
7867
8110
|
async (payload) => {
|
|
7868
8111
|
payload.runtime.logger.debug(`[Bootstrap] Message sent: ${payload.message.content.text}`);
|
|
7869
8112
|
}
|
|
7870
8113
|
],
|
|
7871
|
-
[
|
|
8114
|
+
[EventType2.MESSAGE_DELETED]: [
|
|
7872
8115
|
async (payload) => {
|
|
7873
8116
|
await messageDeletedHandler({
|
|
7874
8117
|
runtime: payload.runtime,
|
|
@@ -7876,7 +8119,7 @@ var events = {
|
|
|
7876
8119
|
});
|
|
7877
8120
|
}
|
|
7878
8121
|
],
|
|
7879
|
-
[
|
|
8122
|
+
[EventType2.CHANNEL_CLEARED]: [
|
|
7880
8123
|
async (payload) => {
|
|
7881
8124
|
await channelClearedHandler({
|
|
7882
8125
|
runtime: payload.runtime,
|
|
@@ -7886,17 +8129,17 @@ var events = {
|
|
|
7886
8129
|
});
|
|
7887
8130
|
}
|
|
7888
8131
|
],
|
|
7889
|
-
[
|
|
8132
|
+
[EventType2.WORLD_JOINED]: [
|
|
7890
8133
|
async (payload) => {
|
|
7891
8134
|
await handleServerSync(payload);
|
|
7892
8135
|
}
|
|
7893
8136
|
],
|
|
7894
|
-
[
|
|
8137
|
+
[EventType2.WORLD_CONNECTED]: [
|
|
7895
8138
|
async (payload) => {
|
|
7896
8139
|
await handleServerSync(payload);
|
|
7897
8140
|
}
|
|
7898
8141
|
],
|
|
7899
|
-
[
|
|
8142
|
+
[EventType2.ENTITY_JOINED]: [
|
|
7900
8143
|
async (payload) => {
|
|
7901
8144
|
payload.runtime.logger.debug(
|
|
7902
8145
|
`[Bootstrap] ENTITY_JOINED event received for entity ${payload.entityId}`
|
|
@@ -7923,7 +8166,7 @@ var events = {
|
|
|
7923
8166
|
);
|
|
7924
8167
|
}
|
|
7925
8168
|
],
|
|
7926
|
-
[
|
|
8169
|
+
[EventType2.ENTITY_LEFT]: [
|
|
7927
8170
|
async (payload) => {
|
|
7928
8171
|
try {
|
|
7929
8172
|
const entity = await payload.runtime.getEntityById(payload.entityId);
|
|
@@ -7943,28 +8186,28 @@ var events = {
|
|
|
7943
8186
|
}
|
|
7944
8187
|
}
|
|
7945
8188
|
],
|
|
7946
|
-
[
|
|
8189
|
+
[EventType2.ACTION_STARTED]: [
|
|
7947
8190
|
async (payload) => {
|
|
7948
|
-
|
|
8191
|
+
logger21.debug(`[Bootstrap] Action started: ${payload.actionName} (${payload.actionId})`);
|
|
7949
8192
|
}
|
|
7950
8193
|
],
|
|
7951
|
-
[
|
|
8194
|
+
[EventType2.ACTION_COMPLETED]: [
|
|
7952
8195
|
async (payload) => {
|
|
7953
8196
|
const status = payload.error ? `failed: ${payload.error.message}` : "completed";
|
|
7954
|
-
|
|
8197
|
+
logger21.debug(`[Bootstrap] Action ${status}: ${payload.actionName} (${payload.actionId})`);
|
|
7955
8198
|
}
|
|
7956
8199
|
],
|
|
7957
|
-
[
|
|
8200
|
+
[EventType2.EVALUATOR_STARTED]: [
|
|
7958
8201
|
async (payload) => {
|
|
7959
|
-
|
|
8202
|
+
logger21.debug(
|
|
7960
8203
|
`[Bootstrap] Evaluator started: ${payload.evaluatorName} (${payload.evaluatorId})`
|
|
7961
8204
|
);
|
|
7962
8205
|
}
|
|
7963
8206
|
],
|
|
7964
|
-
[
|
|
8207
|
+
[EventType2.EVALUATOR_COMPLETED]: [
|
|
7965
8208
|
async (payload) => {
|
|
7966
8209
|
const status = payload.error ? `failed: ${payload.error.message}` : "completed";
|
|
7967
|
-
|
|
8210
|
+
logger21.debug(
|
|
7968
8211
|
`[Bootstrap] Evaluator ${status}: ${payload.evaluatorName} (${payload.evaluatorId})`
|
|
7969
8212
|
);
|
|
7970
8213
|
}
|
|
@@ -8002,7 +8245,6 @@ var bootstrapPlugin = {
|
|
|
8002
8245
|
factsProvider,
|
|
8003
8246
|
roleProvider,
|
|
8004
8247
|
settingsProvider,
|
|
8005
|
-
capabilitiesProvider,
|
|
8006
8248
|
attachmentsProvider,
|
|
8007
8249
|
providersProvider,
|
|
8008
8250
|
actionsProvider,
|
|
@@ -8011,7 +8253,7 @@ var bootstrapPlugin = {
|
|
|
8011
8253
|
recentMessagesProvider,
|
|
8012
8254
|
worldProvider
|
|
8013
8255
|
],
|
|
8014
|
-
services: [TaskService]
|
|
8256
|
+
services: [TaskService, EmbeddingGenerationService]
|
|
8015
8257
|
};
|
|
8016
8258
|
var index_default = bootstrapPlugin;
|
|
8017
8259
|
export {
|