@elizaos/core 1.5.13-alpha.3 → 1.5.13-alpha.4
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/browser/index.browser.js +68 -68
- package/dist/browser/index.browser.js.map +11 -23
- package/dist/index.browser.d.ts +1 -0
- package/dist/index.browser.d.ts.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.node.d.ts +1 -0
- package/dist/index.node.d.ts.map +1 -1
- package/dist/memory.d.ts +64 -0
- package/dist/memory.d.ts.map +1 -0
- package/dist/node/index.node.js +179 -218
- package/dist/node/index.node.js.map +11 -23
- package/dist/runtime.d.ts +23 -18
- package/dist/runtime.d.ts.map +1 -1
- package/dist/schemas/character.d.ts +2 -1
- package/dist/schemas/character.d.ts.map +1 -1
- package/dist/types/components.d.ts +32 -13
- package/dist/types/components.d.ts.map +1 -1
- package/dist/types/events.d.ts +1 -16
- package/dist/types/events.d.ts.map +1 -1
- package/dist/types/index.d.ts +0 -11
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/knowledge.d.ts +0 -29
- package/dist/types/knowledge.d.ts.map +1 -1
- package/dist/types/memory.d.ts +0 -62
- package/dist/types/memory.d.ts.map +1 -1
- package/dist/types/model.d.ts +23 -58
- package/dist/types/model.d.ts.map +1 -1
- package/dist/types/primitives.d.ts +2 -1
- package/dist/types/primitives.d.ts.map +1 -1
- package/dist/types/runtime.d.ts +7 -6
- package/dist/types/runtime.d.ts.map +1 -1
- package/dist/types/state.d.ts +1 -38
- package/dist/types/state.d.ts.map +1 -1
- package/package.json +2 -2
- package/dist/types/browser.d.ts +0 -127
- package/dist/types/browser.d.ts.map +0 -1
- package/dist/types/email.d.ts +0 -143
- package/dist/types/email.d.ts.map +0 -1
- package/dist/types/lp.d.ts +0 -115
- package/dist/types/lp.d.ts.map +0 -1
- package/dist/types/message.d.ts +0 -202
- package/dist/types/message.d.ts.map +0 -1
- package/dist/types/pdf.d.ts +0 -68
- package/dist/types/pdf.d.ts.map +0 -1
- package/dist/types/post.d.ts +0 -242
- package/dist/types/post.d.ts.map +0 -1
- package/dist/types/token.d.ts +0 -73
- package/dist/types/token.d.ts.map +0 -1
- package/dist/types/transcription.d.ts +0 -108
- package/dist/types/transcription.d.ts.map +0 -1
- package/dist/types/video.d.ts +0 -93
- package/dist/types/video.d.ts.map +0 -1
- package/dist/types/wallet.d.ts +0 -49
- package/dist/types/wallet.d.ts.map +0 -1
- package/dist/types/web-search.d.ts +0 -112
- package/dist/types/web-search.d.ts.map +0 -1
package/dist/node/index.node.js
CHANGED
|
@@ -24912,52 +24912,6 @@ var MemoryType;
|
|
|
24912
24912
|
MemoryType2["DESCRIPTION"] = "description";
|
|
24913
24913
|
MemoryType2["CUSTOM"] = "custom";
|
|
24914
24914
|
})(MemoryType ||= {});
|
|
24915
|
-
function createMessageMemory(params) {
|
|
24916
|
-
return {
|
|
24917
|
-
...params,
|
|
24918
|
-
createdAt: Date.now(),
|
|
24919
|
-
metadata: {
|
|
24920
|
-
type: "message" /* MESSAGE */,
|
|
24921
|
-
timestamp: Date.now(),
|
|
24922
|
-
scope: params.agentId ? "private" : "shared"
|
|
24923
|
-
}
|
|
24924
|
-
};
|
|
24925
|
-
}
|
|
24926
|
-
function isDocumentMetadata(metadata) {
|
|
24927
|
-
return metadata.type === "document" /* DOCUMENT */;
|
|
24928
|
-
}
|
|
24929
|
-
function isFragmentMetadata(metadata) {
|
|
24930
|
-
return metadata.type === "fragment" /* FRAGMENT */;
|
|
24931
|
-
}
|
|
24932
|
-
function isMessageMetadata(metadata) {
|
|
24933
|
-
return metadata.type === "message" /* MESSAGE */;
|
|
24934
|
-
}
|
|
24935
|
-
function isDescriptionMetadata(metadata) {
|
|
24936
|
-
return metadata.type === "description" /* DESCRIPTION */;
|
|
24937
|
-
}
|
|
24938
|
-
function isCustomMetadata(metadata) {
|
|
24939
|
-
return metadata.type !== "document" /* DOCUMENT */ && metadata.type !== "fragment" /* FRAGMENT */ && metadata.type !== "message" /* MESSAGE */ && metadata.type !== "description" /* DESCRIPTION */;
|
|
24940
|
-
}
|
|
24941
|
-
function isDocumentMemory(memory) {
|
|
24942
|
-
return memory.metadata?.type === "document" /* DOCUMENT */;
|
|
24943
|
-
}
|
|
24944
|
-
function isFragmentMemory(memory) {
|
|
24945
|
-
return memory.metadata?.type === "fragment" /* FRAGMENT */;
|
|
24946
|
-
}
|
|
24947
|
-
function getMemoryText(memory, defaultValue = "") {
|
|
24948
|
-
return memory.content.text ?? defaultValue;
|
|
24949
|
-
}
|
|
24950
|
-
|
|
24951
|
-
// src/types/knowledge.ts
|
|
24952
|
-
var KnowledgeScope;
|
|
24953
|
-
((KnowledgeScope2) => {
|
|
24954
|
-
KnowledgeScope2["SHARED"] = "shared";
|
|
24955
|
-
KnowledgeScope2["PRIVATE"] = "private";
|
|
24956
|
-
})(KnowledgeScope ||= {});
|
|
24957
|
-
var CacheKeyPrefix;
|
|
24958
|
-
((CacheKeyPrefix2) => {
|
|
24959
|
-
CacheKeyPrefix2["KNOWLEDGE"] = "knowledge";
|
|
24960
|
-
})(CacheKeyPrefix ||= {});
|
|
24961
24915
|
|
|
24962
24916
|
// src/types/environment.ts
|
|
24963
24917
|
var Role;
|
|
@@ -24987,14 +24941,6 @@ var AgentStatus;
|
|
|
24987
24941
|
AgentStatus2["INACTIVE"] = "inactive";
|
|
24988
24942
|
})(AgentStatus ||= {});
|
|
24989
24943
|
|
|
24990
|
-
// src/types/components.ts
|
|
24991
|
-
function createActionResult(partial = {}) {
|
|
24992
|
-
return {
|
|
24993
|
-
success: true,
|
|
24994
|
-
...partial
|
|
24995
|
-
};
|
|
24996
|
-
}
|
|
24997
|
-
|
|
24998
24944
|
// src/types/service.ts
|
|
24999
24945
|
var ServiceType = {
|
|
25000
24946
|
TRANSCRIPTION: "transcription",
|
|
@@ -25095,13 +25041,6 @@ var MODEL_SETTINGS = {
|
|
|
25095
25041
|
MODEL_FREQ_PENALTY: "MODEL_FREQ_PENALTY",
|
|
25096
25042
|
MODEL_PRESENCE_PENALTY: "MODEL_PRESENCE_PENALTY"
|
|
25097
25043
|
};
|
|
25098
|
-
function getModelSpecificSettingKey(modelType, param) {
|
|
25099
|
-
const supportedModelTypes = ["TEXT_SMALL", "TEXT_LARGE", "OBJECT_SMALL", "OBJECT_LARGE"];
|
|
25100
|
-
if (!supportedModelTypes.includes(modelType)) {
|
|
25101
|
-
return null;
|
|
25102
|
-
}
|
|
25103
|
-
return `${modelType}_${param}`;
|
|
25104
|
-
}
|
|
25105
25044
|
|
|
25106
25045
|
// src/types/database.ts
|
|
25107
25046
|
var VECTOR_DIMS = {
|
|
@@ -25165,12 +25104,6 @@ var TeeType;
|
|
|
25165
25104
|
TeeType2["TDX_DSTACK"] = "tdx_dstack";
|
|
25166
25105
|
})(TeeType ||= {});
|
|
25167
25106
|
|
|
25168
|
-
// src/types/token.ts
|
|
25169
|
-
class ITokenDataService extends Service {
|
|
25170
|
-
static serviceType = ServiceType.TOKEN_DATA;
|
|
25171
|
-
capabilityDescription = "Provides standardized access to token market data.";
|
|
25172
|
-
}
|
|
25173
|
-
|
|
25174
25107
|
// src/types/messaging.ts
|
|
25175
25108
|
var SOCKET_MESSAGE_TYPE;
|
|
25176
25109
|
((SOCKET_MESSAGE_TYPE2) => {
|
|
@@ -25181,66 +25114,6 @@ var SOCKET_MESSAGE_TYPE;
|
|
|
25181
25114
|
SOCKET_MESSAGE_TYPE2[SOCKET_MESSAGE_TYPE2["THINKING"] = 5] = "THINKING";
|
|
25182
25115
|
SOCKET_MESSAGE_TYPE2[SOCKET_MESSAGE_TYPE2["CONTROL"] = 6] = "CONTROL";
|
|
25183
25116
|
})(SOCKET_MESSAGE_TYPE ||= {});
|
|
25184
|
-
|
|
25185
|
-
// src/types/wallet.ts
|
|
25186
|
-
class IWalletService extends Service {
|
|
25187
|
-
static serviceType = ServiceType.WALLET;
|
|
25188
|
-
capabilityDescription = "Provides standardized access to wallet balances and portfolios.";
|
|
25189
|
-
}
|
|
25190
|
-
|
|
25191
|
-
// src/types/lp.ts
|
|
25192
|
-
class ILpService extends Service {
|
|
25193
|
-
static serviceType = "lp";
|
|
25194
|
-
capabilityDescription = "Provides standardized access to DEX liquidity pools.";
|
|
25195
|
-
}
|
|
25196
|
-
|
|
25197
|
-
// src/types/pdf.ts
|
|
25198
|
-
class IPdfService extends Service {
|
|
25199
|
-
static serviceType = ServiceType.PDF;
|
|
25200
|
-
capabilityDescription = "PDF processing, extraction, and generation capabilities";
|
|
25201
|
-
}
|
|
25202
|
-
|
|
25203
|
-
// src/types/video.ts
|
|
25204
|
-
class IVideoService extends Service {
|
|
25205
|
-
static serviceType = ServiceType.VIDEO;
|
|
25206
|
-
capabilityDescription = "Video download, processing, and conversion capabilities";
|
|
25207
|
-
}
|
|
25208
|
-
|
|
25209
|
-
// src/types/browser.ts
|
|
25210
|
-
class IBrowserService extends Service {
|
|
25211
|
-
static serviceType = ServiceType.BROWSER;
|
|
25212
|
-
capabilityDescription = "Web browser automation and scraping capabilities";
|
|
25213
|
-
}
|
|
25214
|
-
|
|
25215
|
-
// src/types/transcription.ts
|
|
25216
|
-
class ITranscriptionService extends Service {
|
|
25217
|
-
static serviceType = ServiceType.TRANSCRIPTION;
|
|
25218
|
-
capabilityDescription = "Audio transcription and speech processing capabilities";
|
|
25219
|
-
}
|
|
25220
|
-
|
|
25221
|
-
// src/types/web-search.ts
|
|
25222
|
-
class IWebSearchService extends Service {
|
|
25223
|
-
static serviceType = ServiceType.WEB_SEARCH;
|
|
25224
|
-
capabilityDescription = "Web search and content discovery capabilities";
|
|
25225
|
-
}
|
|
25226
|
-
|
|
25227
|
-
// src/types/email.ts
|
|
25228
|
-
class IEmailService extends Service {
|
|
25229
|
-
static serviceType = ServiceType.EMAIL;
|
|
25230
|
-
capabilityDescription = "Email sending, receiving, and management capabilities";
|
|
25231
|
-
}
|
|
25232
|
-
|
|
25233
|
-
// src/types/message.ts
|
|
25234
|
-
class IMessageService extends Service {
|
|
25235
|
-
static serviceType = ServiceType.MESSAGE;
|
|
25236
|
-
capabilityDescription = "Message sending, receiving, and management capabilities";
|
|
25237
|
-
}
|
|
25238
|
-
|
|
25239
|
-
// src/types/post.ts
|
|
25240
|
-
class IPostService extends Service {
|
|
25241
|
-
static serviceType = ServiceType.POST;
|
|
25242
|
-
capabilityDescription = "Social media posting and content management capabilities";
|
|
25243
|
-
}
|
|
25244
25117
|
// ../../node_modules/@langchain/core/dist/documents/document.js
|
|
25245
25118
|
class Document {
|
|
25246
25119
|
constructor(fields) {
|
|
@@ -42087,7 +41960,7 @@ var contentSchema = z3.object({
|
|
|
42087
41960
|
url: z3.string().optional(),
|
|
42088
41961
|
inReplyTo: uuidSchema2.optional(),
|
|
42089
41962
|
attachments: z3.array(z3.any()).optional(),
|
|
42090
|
-
channelType: z3.
|
|
41963
|
+
channelType: z3.nativeEnum(ChannelType).optional()
|
|
42091
41964
|
}).passthrough();
|
|
42092
41965
|
var messageExampleSchema = z3.object({
|
|
42093
41966
|
name: z3.string(),
|
|
@@ -42565,6 +42438,43 @@ function formatActions(actions) {
|
|
|
42565
42438
|
class DatabaseAdapter {
|
|
42566
42439
|
db;
|
|
42567
42440
|
}
|
|
42441
|
+
// src/memory.ts
|
|
42442
|
+
function createMessageMemory(params) {
|
|
42443
|
+
return {
|
|
42444
|
+
...params,
|
|
42445
|
+
createdAt: Date.now(),
|
|
42446
|
+
metadata: {
|
|
42447
|
+
type: "message" /* MESSAGE */,
|
|
42448
|
+
timestamp: Date.now(),
|
|
42449
|
+
scope: params.agentId ? "private" : "shared"
|
|
42450
|
+
}
|
|
42451
|
+
};
|
|
42452
|
+
}
|
|
42453
|
+
function isDocumentMetadata(metadata) {
|
|
42454
|
+
return metadata.type === "document" /* DOCUMENT */;
|
|
42455
|
+
}
|
|
42456
|
+
function isFragmentMetadata(metadata) {
|
|
42457
|
+
return metadata.type === "fragment" /* FRAGMENT */;
|
|
42458
|
+
}
|
|
42459
|
+
function isMessageMetadata(metadata) {
|
|
42460
|
+
return metadata.type === "message" /* MESSAGE */;
|
|
42461
|
+
}
|
|
42462
|
+
function isDescriptionMetadata(metadata) {
|
|
42463
|
+
return metadata.type === "description" /* DESCRIPTION */;
|
|
42464
|
+
}
|
|
42465
|
+
function isCustomMetadata(metadata) {
|
|
42466
|
+
return metadata.type !== "document" /* DOCUMENT */ && metadata.type !== "fragment" /* FRAGMENT */ && metadata.type !== "message" /* MESSAGE */ && metadata.type !== "description" /* DESCRIPTION */;
|
|
42467
|
+
}
|
|
42468
|
+
function isDocumentMemory(memory) {
|
|
42469
|
+
return memory.metadata?.type === "document" /* DOCUMENT */;
|
|
42470
|
+
}
|
|
42471
|
+
function isFragmentMemory(memory) {
|
|
42472
|
+
return memory.metadata?.type === "fragment" /* FRAGMENT */;
|
|
42473
|
+
}
|
|
42474
|
+
function getMemoryText(memory, defaultValue = "") {
|
|
42475
|
+
return memory.content.text ?? defaultValue;
|
|
42476
|
+
}
|
|
42477
|
+
|
|
42568
42478
|
// src/prompts.ts
|
|
42569
42479
|
var shouldRespondTemplate = `<task>Decide on behalf of {{agentName}} whether they should respond to the message, ignore it or stop the conversation.</task>
|
|
42570
42480
|
|
|
@@ -43740,8 +43650,7 @@ class AgentRuntime {
|
|
|
43740
43650
|
evaluators = [];
|
|
43741
43651
|
providers = [];
|
|
43742
43652
|
plugins = [];
|
|
43743
|
-
|
|
43744
|
-
events = new Map;
|
|
43653
|
+
events = {};
|
|
43745
43654
|
stateCache = new Map;
|
|
43746
43655
|
fetch = fetch;
|
|
43747
43656
|
services = new Map;
|
|
@@ -43755,19 +43664,22 @@ class AgentRuntime {
|
|
|
43755
43664
|
characterPlugins = [];
|
|
43756
43665
|
logger;
|
|
43757
43666
|
settings;
|
|
43758
|
-
|
|
43759
|
-
servicePromiseHandles = new Map;
|
|
43667
|
+
servicePromiseHandlers = new Map;
|
|
43760
43668
|
servicePromises = new Map;
|
|
43669
|
+
serviceRegistrationStatus = new Map;
|
|
43761
43670
|
initPromise;
|
|
43762
43671
|
initResolver;
|
|
43672
|
+
initRejecter;
|
|
43673
|
+
migratedPlugins = new Set;
|
|
43763
43674
|
currentRunId;
|
|
43764
43675
|
currentActionContext;
|
|
43765
43676
|
maxWorkingMemoryEntries = 50;
|
|
43766
43677
|
constructor(opts) {
|
|
43767
43678
|
this.agentId = opts.character?.id ?? opts?.agentId ?? stringToUuid(opts.character?.name ?? v4_default() + opts.character?.username);
|
|
43768
43679
|
this.character = opts.character;
|
|
43769
|
-
this.initPromise = new Promise((resolve) => {
|
|
43680
|
+
this.initPromise = new Promise((resolve, reject) => {
|
|
43770
43681
|
this.initResolver = resolve;
|
|
43682
|
+
this.initRejecter = reject;
|
|
43771
43683
|
});
|
|
43772
43684
|
this.logger = createLogger({
|
|
43773
43685
|
namespace: this.character?.name
|
|
@@ -43881,11 +43793,18 @@ class AgentRuntime {
|
|
|
43881
43793
|
if (!this.servicePromises.has(service.serviceType)) {
|
|
43882
43794
|
this._createServiceResolver(service.serviceType);
|
|
43883
43795
|
}
|
|
43884
|
-
|
|
43885
|
-
|
|
43886
|
-
|
|
43887
|
-
this.
|
|
43888
|
-
|
|
43796
|
+
this.serviceRegistrationStatus.set(service.serviceType, "pending");
|
|
43797
|
+
this.registerService(service).catch((error) => {
|
|
43798
|
+
this.logger.error(`Service registration failed for ${service.serviceType}: ${error instanceof Error ? error.message : String(error)}`);
|
|
43799
|
+
const handler = this.servicePromiseHandlers.get(service.serviceType);
|
|
43800
|
+
if (handler) {
|
|
43801
|
+
const serviceError = new Error(`Service ${service.serviceType} failed to register: ${error instanceof Error ? error.message : String(error)}`);
|
|
43802
|
+
handler.reject(serviceError);
|
|
43803
|
+
this.servicePromiseHandlers.delete(service.serviceType);
|
|
43804
|
+
this.servicePromises.delete(service.serviceType);
|
|
43805
|
+
}
|
|
43806
|
+
this.serviceRegistrationStatus.set(service.serviceType, "failed");
|
|
43807
|
+
});
|
|
43889
43808
|
}
|
|
43890
43809
|
}
|
|
43891
43810
|
}
|
|
@@ -43902,24 +43821,23 @@ class AgentRuntime {
|
|
|
43902
43821
|
}
|
|
43903
43822
|
}
|
|
43904
43823
|
async initialize() {
|
|
43905
|
-
if (this.isInitialized) {
|
|
43906
|
-
this.logger.warn("Agent already initialized");
|
|
43907
|
-
return;
|
|
43908
|
-
}
|
|
43909
|
-
const pluginRegistrationPromises = [];
|
|
43910
|
-
const pluginsToLoad = this.characterPlugins;
|
|
43911
|
-
for (const plugin of pluginsToLoad) {
|
|
43912
|
-
if (plugin) {
|
|
43913
|
-
pluginRegistrationPromises.push(this.registerPlugin(plugin));
|
|
43914
|
-
}
|
|
43915
|
-
}
|
|
43916
|
-
await Promise.all(pluginRegistrationPromises);
|
|
43917
|
-
if (!this.adapter) {
|
|
43918
|
-
this.logger.error("Database adapter not initialized. Make sure @elizaos/plugin-sql is included in your plugins.");
|
|
43919
|
-
throw new Error("Database adapter not initialized. The SQL plugin (@elizaos/plugin-sql) is required for agent initialization. Please ensure it is included in your character configuration.");
|
|
43920
|
-
}
|
|
43921
43824
|
try {
|
|
43922
|
-
|
|
43825
|
+
const pluginRegistrationPromises = [];
|
|
43826
|
+
const pluginsToLoad = this.characterPlugins;
|
|
43827
|
+
for (const plugin of pluginsToLoad) {
|
|
43828
|
+
if (plugin) {
|
|
43829
|
+
pluginRegistrationPromises.push(this.registerPlugin(plugin));
|
|
43830
|
+
}
|
|
43831
|
+
}
|
|
43832
|
+
await Promise.all(pluginRegistrationPromises);
|
|
43833
|
+
if (!this.adapter) {
|
|
43834
|
+
const errorMsg = "Database adapter not initialized. Make sure @elizaos/plugin-sql is included in your plugins.";
|
|
43835
|
+
this.logger.error(errorMsg);
|
|
43836
|
+
throw new Error("Database adapter not initialized. The SQL plugin (@elizaos/plugin-sql) is required for agent initialization. Please ensure it is included in your character configuration.");
|
|
43837
|
+
}
|
|
43838
|
+
if (!await this.adapter.isReady()) {
|
|
43839
|
+
await this.adapter.init();
|
|
43840
|
+
}
|
|
43923
43841
|
this.logger.info("Running plugin migrations...");
|
|
43924
43842
|
await this.runPluginMigrations();
|
|
43925
43843
|
this.logger.info("Plugin migrations completed.");
|
|
@@ -43945,12 +43863,6 @@ class AgentRuntime {
|
|
|
43945
43863
|
throw new Error(`Agent entity not found for ${this.agentId}`);
|
|
43946
43864
|
this.logger.debug(`Success: Agent entity created successfully for ${this.character.name}`);
|
|
43947
43865
|
}
|
|
43948
|
-
} catch (error) {
|
|
43949
|
-
const errorMsg = error instanceof Error ? error.message : String(error);
|
|
43950
|
-
this.logger.error(`Failed to create agent entity: ${errorMsg}`);
|
|
43951
|
-
throw error;
|
|
43952
|
-
}
|
|
43953
|
-
try {
|
|
43954
43866
|
const room = await this.getRoom(this.agentId);
|
|
43955
43867
|
if (!room) {
|
|
43956
43868
|
await this.createRoom({
|
|
@@ -43972,24 +43884,35 @@ class AgentRuntime {
|
|
|
43972
43884
|
}
|
|
43973
43885
|
this.logger.debug(`Agent ${this.character.name} linked to its own room successfully`);
|
|
43974
43886
|
}
|
|
43887
|
+
const embeddingModel = this.getModel(ModelType.TEXT_EMBEDDING);
|
|
43888
|
+
if (!embeddingModel) {
|
|
43889
|
+
this.logger.warn(`[AgentRuntime][${this.character.name}] No TEXT_EMBEDDING model registered. Skipping embedding dimension setup.`);
|
|
43890
|
+
} else {
|
|
43891
|
+
await this.ensureEmbeddingDimension();
|
|
43892
|
+
}
|
|
43893
|
+
if (this.initResolver) {
|
|
43894
|
+
this.initResolver();
|
|
43895
|
+
this.initResolver = undefined;
|
|
43896
|
+
}
|
|
43975
43897
|
} catch (error) {
|
|
43976
43898
|
const errorMsg = error instanceof Error ? error.message : String(error);
|
|
43977
|
-
this.logger.error(`
|
|
43899
|
+
this.logger.error(`Runtime initialization failed: ${errorMsg}`);
|
|
43900
|
+
if (this.initRejecter) {
|
|
43901
|
+
this.initRejecter(error);
|
|
43902
|
+
this.initRejecter = undefined;
|
|
43903
|
+
}
|
|
43904
|
+
for (const [serviceType, promise2] of this.servicePromises) {
|
|
43905
|
+
const handler = this.servicePromiseHandlers.get(serviceType);
|
|
43906
|
+
if (handler) {
|
|
43907
|
+
const serviceError = new Error(`Service ${serviceType} failed to start due to runtime initialization failure: ${errorMsg}`);
|
|
43908
|
+
handler.reject(serviceError);
|
|
43909
|
+
this.servicePromiseHandlers.delete(serviceType);
|
|
43910
|
+
this.servicePromises.delete(serviceType);
|
|
43911
|
+
this.serviceRegistrationStatus.set(serviceType, "failed");
|
|
43912
|
+
}
|
|
43913
|
+
}
|
|
43978
43914
|
throw error;
|
|
43979
43915
|
}
|
|
43980
|
-
const embeddingModel = this.getModel(ModelType.TEXT_EMBEDDING);
|
|
43981
|
-
if (!embeddingModel) {
|
|
43982
|
-
this.logger.warn(`[AgentRuntime][${this.character.name}] No TEXT_EMBEDDING model registered. Skipping embedding dimension setup.`);
|
|
43983
|
-
} else {
|
|
43984
|
-
await this.ensureEmbeddingDimension();
|
|
43985
|
-
}
|
|
43986
|
-
for (const service of this.servicesInitQueue) {
|
|
43987
|
-
await this.registerService(service);
|
|
43988
|
-
}
|
|
43989
|
-
this.isInitialized = true;
|
|
43990
|
-
if (this.initResolver) {
|
|
43991
|
-
this.initResolver();
|
|
43992
|
-
}
|
|
43993
43916
|
}
|
|
43994
43917
|
async runPluginMigrations() {
|
|
43995
43918
|
const drizzle = this.adapter?.db;
|
|
@@ -44001,10 +43924,15 @@ class AgentRuntime {
|
|
|
44001
43924
|
this.logger.info(`Found ${pluginsWithSchemas.length} plugins with schemas to migrate.`);
|
|
44002
43925
|
for (const p of pluginsWithSchemas) {
|
|
44003
43926
|
if (p.schema) {
|
|
43927
|
+
if (this.migratedPlugins.has(p.name)) {
|
|
43928
|
+
this.logger.debug(`Plugin ${p.name} migrations already run, skipping`);
|
|
43929
|
+
continue;
|
|
43930
|
+
}
|
|
44004
43931
|
this.logger.info(`Running migrations for plugin: ${p.name}`);
|
|
44005
43932
|
try {
|
|
44006
43933
|
if (this.adapter && "runMigrations" in this.adapter) {
|
|
44007
43934
|
await this.adapter.runMigrations(p.schema, p.name);
|
|
43935
|
+
this.migratedPlugins.add(p.name);
|
|
44008
43936
|
this.logger.info(`Successfully migrated plugin: ${p.name}`);
|
|
44009
43937
|
}
|
|
44010
43938
|
} catch (error) {
|
|
@@ -44212,7 +44140,7 @@ class AgentRuntime {
|
|
|
44212
44140
|
}
|
|
44213
44141
|
};
|
|
44214
44142
|
const options = {
|
|
44215
|
-
|
|
44143
|
+
actionContext
|
|
44216
44144
|
};
|
|
44217
44145
|
if (actionPlan) {
|
|
44218
44146
|
options.actionPlan = {
|
|
@@ -44243,8 +44171,8 @@ class AgentRuntime {
|
|
|
44243
44171
|
this.logger.error("Failed to create action start message:", String(error));
|
|
44244
44172
|
}
|
|
44245
44173
|
let storedCallbackData = [];
|
|
44246
|
-
const storageCallback = async (response2
|
|
44247
|
-
storedCallbackData.push(
|
|
44174
|
+
const storageCallback = async (response2) => {
|
|
44175
|
+
storedCallbackData.push(response2);
|
|
44248
44176
|
return [];
|
|
44249
44177
|
};
|
|
44250
44178
|
const result = await action.handler(this, message, accumulatedState, options, storageCallback, responses);
|
|
@@ -44328,8 +44256,8 @@ class AgentRuntime {
|
|
|
44328
44256
|
this.logger.error(`Failed to emit ACTION_COMPLETED event for action ${action.name} (${actionId}): ${errorMessage}`);
|
|
44329
44257
|
}
|
|
44330
44258
|
if (callback) {
|
|
44331
|
-
for (const
|
|
44332
|
-
await callback(
|
|
44259
|
+
for (const content of storedCallbackData) {
|
|
44260
|
+
await callback(content);
|
|
44333
44261
|
}
|
|
44334
44262
|
}
|
|
44335
44263
|
const actionMemory = {
|
|
@@ -44850,6 +44778,29 @@ class AgentRuntime {
|
|
|
44850
44778
|
const serviceInstances = this.services.get(serviceType);
|
|
44851
44779
|
return serviceInstances !== undefined && serviceInstances.length > 0;
|
|
44852
44780
|
}
|
|
44781
|
+
getServiceRegistrationStatus(serviceType) {
|
|
44782
|
+
return this.serviceRegistrationStatus.get(serviceType) || "unknown";
|
|
44783
|
+
}
|
|
44784
|
+
getServiceHealth() {
|
|
44785
|
+
const health = {};
|
|
44786
|
+
for (const [serviceType, instances] of this.services) {
|
|
44787
|
+
health[serviceType] = {
|
|
44788
|
+
status: this.getServiceRegistrationStatus(serviceType),
|
|
44789
|
+
instances: instances.length,
|
|
44790
|
+
hasPromise: this.servicePromises.has(serviceType)
|
|
44791
|
+
};
|
|
44792
|
+
}
|
|
44793
|
+
for (const [serviceType, status] of this.serviceRegistrationStatus) {
|
|
44794
|
+
if (!health[serviceType]) {
|
|
44795
|
+
health[serviceType] = {
|
|
44796
|
+
status,
|
|
44797
|
+
instances: 0,
|
|
44798
|
+
hasPromise: this.servicePromises.has(serviceType)
|
|
44799
|
+
};
|
|
44800
|
+
}
|
|
44801
|
+
}
|
|
44802
|
+
return health;
|
|
44803
|
+
}
|
|
44853
44804
|
async registerService(serviceDef) {
|
|
44854
44805
|
const serviceType = serviceDef.serviceType;
|
|
44855
44806
|
if (!serviceType) {
|
|
@@ -44857,7 +44808,16 @@ class AgentRuntime {
|
|
|
44857
44808
|
return;
|
|
44858
44809
|
}
|
|
44859
44810
|
this.logger.debug(`${this.character.name}(${this.agentId}) - Registering service:`, serviceType);
|
|
44811
|
+
this.serviceRegistrationStatus.set(serviceType, "registering");
|
|
44860
44812
|
try {
|
|
44813
|
+
this.logger.debug(`Service ${serviceType} waiting for initialization...`);
|
|
44814
|
+
const initTimeout = new Promise((_, reject) => {
|
|
44815
|
+
setTimeout(() => {
|
|
44816
|
+
reject(new Error(`Service ${serviceType} registration timed out waiting for runtime initialization (30s timeout)`));
|
|
44817
|
+
}, 30000);
|
|
44818
|
+
});
|
|
44819
|
+
await Promise.race([this.initPromise, initTimeout]);
|
|
44820
|
+
this.logger.debug(`Service ${serviceType} proceeding - initialization complete`);
|
|
44861
44821
|
const serviceInstance = await serviceDef.start(this);
|
|
44862
44822
|
if (!this.services.has(serviceType)) {
|
|
44863
44823
|
this.services.set(serviceType, []);
|
|
@@ -44867,31 +44827,50 @@ class AgentRuntime {
|
|
|
44867
44827
|
}
|
|
44868
44828
|
this.services.get(serviceType).push(serviceInstance);
|
|
44869
44829
|
this.serviceTypes.get(serviceType).push(serviceDef);
|
|
44870
|
-
const
|
|
44871
|
-
if (
|
|
44872
|
-
resolve(serviceInstance);
|
|
44830
|
+
const handler = this.servicePromiseHandlers.get(serviceType);
|
|
44831
|
+
if (handler) {
|
|
44832
|
+
handler.resolve(serviceInstance);
|
|
44833
|
+
this.servicePromiseHandlers.delete(serviceType);
|
|
44873
44834
|
} else {
|
|
44874
|
-
this.logger.debug(`${this.character.name} - Service ${serviceType} has no
|
|
44835
|
+
this.logger.debug(`${this.character.name} - Service ${serviceType} has no servicePromiseHandler`);
|
|
44875
44836
|
}
|
|
44876
44837
|
if (typeof serviceDef.registerSendHandlers === "function") {
|
|
44877
44838
|
serviceDef.registerSendHandlers(this, serviceInstance);
|
|
44878
44839
|
}
|
|
44840
|
+
this.serviceRegistrationStatus.set(serviceType, "registered");
|
|
44879
44841
|
this.logger.debug(`${this.character.name}(${this.agentId}) - Service ${serviceType} registered successfully`);
|
|
44880
44842
|
} catch (error) {
|
|
44881
44843
|
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
44882
44844
|
this.logger.error(`${this.character.name}(${this.agentId}) - Failed to register service ${serviceType}: ${errorMessage}`);
|
|
44845
|
+
if (error?.message?.includes("timed out waiting for runtime initialization")) {
|
|
44846
|
+
this.logger.error(`Service ${serviceType} failed due to runtime initialization timeout. Check if runtime.initialize() is being called and completing successfully.`);
|
|
44847
|
+
} else if (error?.message?.includes("Service") && error?.message?.includes("failed to start")) {
|
|
44848
|
+
this.logger.error(`Service ${serviceType} failed to start. Check service implementation and dependencies.`);
|
|
44849
|
+
}
|
|
44850
|
+
this.serviceRegistrationStatus.set(serviceType, "failed");
|
|
44851
|
+
const handler = this.servicePromiseHandlers.get(serviceType);
|
|
44852
|
+
if (handler) {
|
|
44853
|
+
handler.reject(error);
|
|
44854
|
+
this.servicePromiseHandlers.delete(serviceType);
|
|
44855
|
+
this.servicePromises.delete(serviceType);
|
|
44856
|
+
}
|
|
44883
44857
|
throw error;
|
|
44884
44858
|
}
|
|
44885
44859
|
}
|
|
44886
44860
|
_createServiceResolver(serviceType) {
|
|
44887
44861
|
let resolver;
|
|
44888
|
-
|
|
44862
|
+
let rejecter;
|
|
44863
|
+
this.servicePromises.set(serviceType, new Promise((resolve, reject) => {
|
|
44889
44864
|
resolver = resolve;
|
|
44865
|
+
rejecter = reject;
|
|
44890
44866
|
}));
|
|
44891
44867
|
if (!resolver) {
|
|
44892
44868
|
throw new Error(`Failed to create resolver for service ${serviceType}`);
|
|
44893
44869
|
}
|
|
44894
|
-
|
|
44870
|
+
if (!rejecter) {
|
|
44871
|
+
throw new Error(`Failed to create rejecter for service ${serviceType}`);
|
|
44872
|
+
}
|
|
44873
|
+
this.servicePromiseHandlers.set(serviceType, { resolve: resolver, reject: rejecter });
|
|
44895
44874
|
return this.servicePromises.get(serviceType);
|
|
44896
44875
|
}
|
|
44897
44876
|
getServiceLoadPromise(serviceType) {
|
|
@@ -44992,27 +44971,23 @@ class AgentRuntime {
|
|
|
44992
44971
|
}
|
|
44993
44972
|
this.logger.debug(`[useModel] ${modelKey} input: ` + JSON.stringify(params, safeReplacer(), 2).replace(/\\n/g, `
|
|
44994
44973
|
`));
|
|
44995
|
-
let
|
|
44974
|
+
let modelParams;
|
|
44996
44975
|
if (params === null || params === undefined || typeof params !== "object" || Array.isArray(params) || BufferUtils.isBuffer(params)) {
|
|
44997
|
-
|
|
44976
|
+
modelParams = params;
|
|
44998
44977
|
} else {
|
|
44999
44978
|
const modelSettings = this.getModelSettings(modelKey);
|
|
45000
44979
|
if (modelSettings) {
|
|
45001
|
-
|
|
44980
|
+
modelParams = {
|
|
45002
44981
|
...modelSettings,
|
|
45003
|
-
...params
|
|
45004
|
-
runtime: this
|
|
44982
|
+
...params
|
|
45005
44983
|
};
|
|
45006
44984
|
} else {
|
|
45007
|
-
|
|
45008
|
-
...params,
|
|
45009
|
-
runtime: this
|
|
45010
|
-
};
|
|
44985
|
+
modelParams = params;
|
|
45011
44986
|
}
|
|
45012
44987
|
}
|
|
45013
44988
|
const startTime = typeof performance !== "undefined" && typeof performance.now === "function" ? performance.now() : Date.now();
|
|
45014
44989
|
try {
|
|
45015
|
-
const response = await model(this,
|
|
44990
|
+
const response = await model(this, modelParams);
|
|
45016
44991
|
const elapsedTime = (typeof performance !== "undefined" && typeof performance.now === "function" ? performance.now() : Date.now()) - startTime;
|
|
45017
44992
|
this.logger.debug(`[useModel] ${modelKey} output (took ${Number(elapsedTime.toFixed(2)).toLocaleString()}ms):`, Array.isArray(response) ? `${JSON.stringify(response.slice(0, 5))}...${JSON.stringify(response.slice(-5))} (${response.length} items)` : JSON.stringify(response, safeReplacer(), 2).replace(/\\n/g, `
|
|
45018
44993
|
`));
|
|
@@ -45054,18 +45029,18 @@ class AgentRuntime {
|
|
|
45054
45029
|
}
|
|
45055
45030
|
}
|
|
45056
45031
|
registerEvent(event, handler) {
|
|
45057
|
-
if (!this.events
|
|
45058
|
-
this.events
|
|
45032
|
+
if (!this.events[event]) {
|
|
45033
|
+
this.events[event] = [];
|
|
45059
45034
|
}
|
|
45060
|
-
this.events.
|
|
45035
|
+
this.events[event].push(handler);
|
|
45061
45036
|
}
|
|
45062
45037
|
getEvent(event) {
|
|
45063
|
-
return this.events
|
|
45038
|
+
return this.events[event];
|
|
45064
45039
|
}
|
|
45065
45040
|
async emitEvent(event, params) {
|
|
45066
45041
|
const events = Array.isArray(event) ? event : [event];
|
|
45067
45042
|
for (const eventName of events) {
|
|
45068
|
-
const eventHandlers = this.events
|
|
45043
|
+
const eventHandlers = this.events[eventName];
|
|
45069
45044
|
if (!eventHandlers) {
|
|
45070
45045
|
continue;
|
|
45071
45046
|
}
|
|
@@ -45229,7 +45204,8 @@ class AgentRuntime {
|
|
|
45229
45204
|
}
|
|
45230
45205
|
return memory;
|
|
45231
45206
|
}
|
|
45232
|
-
async queueEmbeddingGeneration(memory, priority
|
|
45207
|
+
async queueEmbeddingGeneration(memory, priority) {
|
|
45208
|
+
priority = priority || "normal";
|
|
45233
45209
|
if (!memory) {
|
|
45234
45210
|
return;
|
|
45235
45211
|
}
|
|
@@ -46294,7 +46270,6 @@ export {
|
|
|
46294
46270
|
getTypedService,
|
|
46295
46271
|
getSalt,
|
|
46296
46272
|
getNumberEnv,
|
|
46297
|
-
getModelSpecificSettingKey,
|
|
46298
46273
|
getMemoryText,
|
|
46299
46274
|
getLocalServerUrl,
|
|
46300
46275
|
getGeneratedDir,
|
|
@@ -46338,7 +46313,6 @@ export {
|
|
|
46338
46313
|
createService,
|
|
46339
46314
|
createMessageMemory,
|
|
46340
46315
|
createLogger,
|
|
46341
|
-
createActionResult,
|
|
46342
46316
|
concat2 as concat,
|
|
46343
46317
|
composePromptFromState,
|
|
46344
46318
|
composePrompt,
|
|
@@ -46364,30 +46338,17 @@ export {
|
|
|
46364
46338
|
ModelType,
|
|
46365
46339
|
MemoryType,
|
|
46366
46340
|
MODEL_SETTINGS,
|
|
46367
|
-
KnowledgeScope,
|
|
46368
|
-
IWebSearchService,
|
|
46369
|
-
IWalletService,
|
|
46370
|
-
IVideoService,
|
|
46371
|
-
ITranscriptionService,
|
|
46372
|
-
ITokenDataService,
|
|
46373
|
-
IPostService,
|
|
46374
|
-
IPdfService,
|
|
46375
|
-
IMessageService,
|
|
46376
|
-
ILpService,
|
|
46377
|
-
IEmailService,
|
|
46378
|
-
IBrowserService,
|
|
46379
46341
|
EventType,
|
|
46380
46342
|
Environment,
|
|
46381
46343
|
ElizaOS,
|
|
46382
46344
|
DatabaseAdapter,
|
|
46383
46345
|
ContentType,
|
|
46384
46346
|
ChannelType,
|
|
46385
|
-
CacheKeyPrefix,
|
|
46386
46347
|
BufferUtils,
|
|
46387
46348
|
BM25,
|
|
46388
46349
|
AgentStatus,
|
|
46389
46350
|
AgentRuntime
|
|
46390
46351
|
};
|
|
46391
46352
|
|
|
46392
|
-
//# debugId=
|
|
46353
|
+
//# debugId=7AD07AFE80EE1A4264756E2164756E21
|
|
46393
46354
|
//# sourceMappingURL=index.node.js.map
|