@elizaos/core 1.6.2-alpha.20 → 1.6.2-alpha.22
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 +43 -43
- package/dist/browser/index.browser.js.map +3 -3
- package/dist/character.d.ts +15 -0
- package/dist/character.d.ts.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/node/index.node.js +130 -93
- package/dist/node/index.node.js.map +6 -6
- package/dist/runtime.d.ts.map +1 -1
- package/package.json +2 -2
package/dist/character.d.ts
CHANGED
|
@@ -22,4 +22,19 @@ export declare function validateCharacterConfig(character: Character): {
|
|
|
22
22
|
* @returns Complete character with defaults
|
|
23
23
|
*/
|
|
24
24
|
export declare function mergeCharacterDefaults(char: Partial<Character>): Character;
|
|
25
|
+
/**
|
|
26
|
+
* Build ordered plugin list based on available environment variables
|
|
27
|
+
*
|
|
28
|
+
* Plugin loading order:
|
|
29
|
+
* 1. Core plugins (@elizaos/plugin-sql)
|
|
30
|
+
* 2. Text-only LLM plugins (no embedding support)
|
|
31
|
+
* 3. Embedding-capable LLM plugins
|
|
32
|
+
* 4. Platform plugins (Discord, Twitter, Telegram)
|
|
33
|
+
* 5. Bootstrap plugin (unless IGNORE_BOOTSTRAP is set)
|
|
34
|
+
* 6. Ollama fallback (only if no other LLM providers configured)
|
|
35
|
+
*
|
|
36
|
+
* @param env - Environment object to check for API keys (defaults to process.env)
|
|
37
|
+
* @returns Ordered array of plugin names
|
|
38
|
+
*/
|
|
39
|
+
export declare function buildCharacterPlugins(env?: Record<string, string | undefined>): string[];
|
|
25
40
|
//# sourceMappingURL=character.d.ts.map
|
package/dist/character.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"character.d.ts","sourceRoot":"","sources":["../src/character.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,SAAS,EAAE,MAAM,SAAS,CAAC;AAGzC;;;;;GAKG;AACH,wBAAgB,cAAc,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,GAAG,SAAS,CAyB5E;AAED;;;;;GAKG;AACH,wBAAgB,uBAAuB,CAAC,SAAS,EAAE,SAAS,GAAG;IAC7D,OAAO,EAAE,OAAO,CAAC;IACjB,MAAM,EAAE,MAAM,EAAE,CAAC;CAClB,CAoBA;AAED;;;;GAIG;AACH,wBAAgB,sBAAsB,CAAC,IAAI,EAAE,OAAO,CAAC,SAAS,CAAC,GAAG,SAAS,CAY1E"}
|
|
1
|
+
{"version":3,"file":"character.d.ts","sourceRoot":"","sources":["../src/character.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,SAAS,EAAE,MAAM,SAAS,CAAC;AAGzC;;;;;GAKG;AACH,wBAAgB,cAAc,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,GAAG,SAAS,CAyB5E;AAED;;;;;GAKG;AACH,wBAAgB,uBAAuB,CAAC,SAAS,EAAE,SAAS,GAAG;IAC7D,OAAO,EAAE,OAAO,CAAC;IACjB,MAAM,EAAE,MAAM,EAAE,CAAC;CAClB,CAoBA;AAED;;;;GAIG;AACH,wBAAgB,sBAAsB,CAAC,IAAI,EAAE,OAAO,CAAC,SAAS,CAAC,GAAG,SAAS,CAY1E;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,qBAAqB,CACnC,GAAG,GAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAe,GACpD,MAAM,EAAE,CA0CV"}
|
package/dist/index.d.ts
CHANGED
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAGH,cAAc,SAAS,CAAC;AAGxB,cAAc,SAAS,CAAC;AAGxB,cAAc,qBAAqB,CAAC;AAGpC,cAAc,qBAAqB,CAAC;AAGpC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formatActions(actions) {
|
|
|
42568
42568
|
class DatabaseAdapter {
|
|
42569
42569
|
db;
|
|
42570
42570
|
}
|
|
42571
|
+
// src/character.ts
|
|
42572
|
+
function parseCharacter(input) {
|
|
42573
|
+
if (typeof input === "string") {
|
|
42574
|
+
throw new Error(`Character path provided but must be loaded first: ${input}`);
|
|
42575
|
+
}
|
|
42576
|
+
if (typeof input === "object") {
|
|
42577
|
+
const validationResult = validateCharacter(input);
|
|
42578
|
+
if (!validationResult.success) {
|
|
42579
|
+
const errorDetails = validationResult.error?.issues ? validationResult.error.issues.map((issue) => `${issue.path.join(".")}: ${issue.message}`).join("; ") : validationResult.error?.message || "Unknown validation error";
|
|
42580
|
+
throw new Error(`Character validation failed: ${errorDetails}`);
|
|
42581
|
+
}
|
|
42582
|
+
return validationResult.data;
|
|
42583
|
+
}
|
|
42584
|
+
throw new Error("Invalid character input format");
|
|
42585
|
+
}
|
|
42586
|
+
function validateCharacterConfig(character) {
|
|
42587
|
+
const validationResult = validateCharacter(character);
|
|
42588
|
+
if (validationResult.success) {
|
|
42589
|
+
return {
|
|
42590
|
+
isValid: true,
|
|
42591
|
+
errors: []
|
|
42592
|
+
};
|
|
42593
|
+
}
|
|
42594
|
+
const errors = validationResult.error?.issues ? validationResult.error.issues.map((issue) => `${issue.path.join(".")}: ${issue.message}`) : [validationResult.error?.message || "Unknown validation error"];
|
|
42595
|
+
return {
|
|
42596
|
+
isValid: false,
|
|
42597
|
+
errors
|
|
42598
|
+
};
|
|
42599
|
+
}
|
|
42600
|
+
function mergeCharacterDefaults(char) {
|
|
42601
|
+
const defaults = {
|
|
42602
|
+
settings: {},
|
|
42603
|
+
plugins: [],
|
|
42604
|
+
bio: []
|
|
42605
|
+
};
|
|
42606
|
+
return {
|
|
42607
|
+
...defaults,
|
|
42608
|
+
...char,
|
|
42609
|
+
name: char.name || "Unnamed Character"
|
|
42610
|
+
};
|
|
42611
|
+
}
|
|
42612
|
+
function buildCharacterPlugins(env2 = process.env) {
|
|
42613
|
+
const plugins = [
|
|
42614
|
+
"@elizaos/plugin-sql",
|
|
42615
|
+
...env2.ANTHROPIC_API_KEY?.trim() ? ["@elizaos/plugin-anthropic"] : [],
|
|
42616
|
+
...env2.OPENROUTER_API_KEY?.trim() ? ["@elizaos/plugin-openrouter"] : [],
|
|
42617
|
+
...env2.OPENAI_API_KEY?.trim() ? ["@elizaos/plugin-openai"] : [],
|
|
42618
|
+
...env2.GOOGLE_GENERATIVE_AI_API_KEY?.trim() ? ["@elizaos/plugin-google-genai"] : [],
|
|
42619
|
+
...env2.DISCORD_API_TOKEN?.trim() ? ["@elizaos/plugin-discord"] : [],
|
|
42620
|
+
...env2.TWITTER_API_KEY?.trim() && env2.TWITTER_API_SECRET_KEY?.trim() && env2.TWITTER_ACCESS_TOKEN?.trim() && env2.TWITTER_ACCESS_TOKEN_SECRET?.trim() ? ["@elizaos/plugin-twitter"] : [],
|
|
42621
|
+
...env2.TELEGRAM_BOT_TOKEN?.trim() ? ["@elizaos/plugin-telegram"] : [],
|
|
42622
|
+
...(() => {
|
|
42623
|
+
const ignore = env2.IGNORE_BOOTSTRAP?.trim().toLowerCase();
|
|
42624
|
+
const shouldIgnore = ignore === "true" || ignore === "1" || ignore === "yes";
|
|
42625
|
+
return shouldIgnore ? [] : ["@elizaos/plugin-bootstrap"];
|
|
42626
|
+
})(),
|
|
42627
|
+
...!env2.ANTHROPIC_API_KEY?.trim() && !env2.OPENROUTER_API_KEY?.trim() && !env2.OPENAI_API_KEY?.trim() && !env2.GOOGLE_GENERATIVE_AI_API_KEY?.trim() ? ["@elizaos/plugin-ollama"] : []
|
|
42628
|
+
];
|
|
42629
|
+
return plugins;
|
|
42630
|
+
}
|
|
42631
|
+
|
|
42571
42632
|
// src/memory.ts
|
|
42572
42633
|
function createMessageMemory(params) {
|
|
42573
42634
|
return {
|
|
@@ -43820,7 +43881,7 @@ class AgentRuntime {
|
|
|
43820
43881
|
currentActionContext;
|
|
43821
43882
|
maxWorkingMemoryEntries = 50;
|
|
43822
43883
|
constructor(opts) {
|
|
43823
|
-
this.agentId = opts.character?.id ?? opts?.agentId ?? stringToUuid(opts.character?.name ?? v4_default()
|
|
43884
|
+
this.agentId = opts.character?.id ?? opts?.agentId ?? stringToUuid(opts.character?.name ?? v4_default());
|
|
43824
43885
|
this.character = opts.character;
|
|
43825
43886
|
this.initPromise = new Promise((resolve, reject) => {
|
|
43826
43887
|
this.initResolver = resolve;
|
|
@@ -43986,9 +44047,12 @@ class AgentRuntime {
|
|
|
43986
44047
|
this.logger.info("Running plugin migrations...");
|
|
43987
44048
|
await this.runPluginMigrations();
|
|
43988
44049
|
this.logger.info("Plugin migrations completed.");
|
|
43989
|
-
const existingAgent = await this.ensureAgentExists(
|
|
44050
|
+
const existingAgent = await this.ensureAgentExists({
|
|
44051
|
+
...this.character,
|
|
44052
|
+
id: this.agentId
|
|
44053
|
+
});
|
|
43990
44054
|
if (!existingAgent) {
|
|
43991
|
-
const errorMsg = `Agent ${this.
|
|
44055
|
+
const errorMsg = `Agent ${this.agentId} does not exist in database after ensureAgentExists call`;
|
|
43992
44056
|
throw new Error(errorMsg);
|
|
43993
44057
|
}
|
|
43994
44058
|
let agentEntity = await this.getEntityById(this.agentId);
|
|
@@ -44536,42 +44600,56 @@ class AgentRuntime {
|
|
|
44536
44600
|
}
|
|
44537
44601
|
}
|
|
44538
44602
|
async evaluate(message, state, didRespond, callback, responses) {
|
|
44539
|
-
|
|
44540
|
-
|
|
44541
|
-
|
|
44542
|
-
|
|
44543
|
-
|
|
44544
|
-
|
|
44545
|
-
|
|
44546
|
-
|
|
44547
|
-
|
|
44548
|
-
|
|
44603
|
+
try {
|
|
44604
|
+
const evaluatorPromises = this.evaluators.map(async (evaluator) => {
|
|
44605
|
+
try {
|
|
44606
|
+
if (!evaluator.handler) {
|
|
44607
|
+
return null;
|
|
44608
|
+
}
|
|
44609
|
+
if (!didRespond && !evaluator.alwaysRun) {
|
|
44610
|
+
return null;
|
|
44611
|
+
}
|
|
44612
|
+
const result = await evaluator.validate(this, message, state);
|
|
44613
|
+
if (result) {
|
|
44614
|
+
return evaluator;
|
|
44615
|
+
}
|
|
44616
|
+
return null;
|
|
44617
|
+
} catch (error) {
|
|
44618
|
+
this.logger.error({ error, evaluatorName: evaluator.name }, `Error validating evaluator ${evaluator.name}`);
|
|
44619
|
+
return null;
|
|
44620
|
+
}
|
|
44621
|
+
});
|
|
44622
|
+
const evaluators = (await Promise.all(evaluatorPromises)).filter(Boolean);
|
|
44623
|
+
if (evaluators.length === 0) {
|
|
44624
|
+
return [];
|
|
44549
44625
|
}
|
|
44550
|
-
|
|
44551
|
-
|
|
44552
|
-
|
|
44553
|
-
|
|
44626
|
+
state = await this.composeState(message, ["RECENT_MESSAGES", "EVALUATORS"]);
|
|
44627
|
+
await Promise.all(evaluators.map(async (evaluator) => {
|
|
44628
|
+
try {
|
|
44629
|
+
if (evaluator.handler) {
|
|
44630
|
+
await evaluator.handler(this, message, state, {}, callback, responses);
|
|
44631
|
+
this.adapter.log({
|
|
44632
|
+
entityId: message.entityId,
|
|
44633
|
+
roomId: message.roomId,
|
|
44634
|
+
type: "evaluator",
|
|
44635
|
+
body: {
|
|
44636
|
+
evaluator: evaluator.name,
|
|
44637
|
+
messageId: message.id,
|
|
44638
|
+
message: message.content.text,
|
|
44639
|
+
state,
|
|
44640
|
+
runId: this.getCurrentRunId()
|
|
44641
|
+
}
|
|
44642
|
+
});
|
|
44643
|
+
}
|
|
44644
|
+
} catch (error) {
|
|
44645
|
+
this.logger.error({ error, evaluatorName: evaluator.name }, `Error executing evaluator ${evaluator.name}`);
|
|
44646
|
+
}
|
|
44647
|
+
}));
|
|
44648
|
+
return evaluators;
|
|
44649
|
+
} catch (error) {
|
|
44650
|
+
this.logger.error({ error, messageId: message.id, roomId: message.roomId }, "Error in evaluate method");
|
|
44554
44651
|
return [];
|
|
44555
44652
|
}
|
|
44556
|
-
state = await this.composeState(message, ["RECENT_MESSAGES", "EVALUATORS"]);
|
|
44557
|
-
await Promise.all(evaluators.map(async (evaluator) => {
|
|
44558
|
-
if (evaluator.handler) {
|
|
44559
|
-
await evaluator.handler(this, message, state, {}, callback, responses);
|
|
44560
|
-
this.adapter.log({
|
|
44561
|
-
entityId: message.entityId,
|
|
44562
|
-
roomId: message.roomId,
|
|
44563
|
-
type: "evaluator",
|
|
44564
|
-
body: {
|
|
44565
|
-
evaluator: evaluator.name,
|
|
44566
|
-
messageId: message.id,
|
|
44567
|
-
message: message.content.text,
|
|
44568
|
-
state,
|
|
44569
|
-
runId: this.getCurrentRunId()
|
|
44570
|
-
}
|
|
44571
|
-
});
|
|
44572
|
-
}
|
|
44573
|
-
}));
|
|
44574
|
-
return evaluators;
|
|
44575
44653
|
}
|
|
44576
44654
|
async ensureConnections(entities, rooms, source, world) {
|
|
44577
44655
|
if (!entities) {
|
|
@@ -45307,34 +45385,33 @@ ${input}`;
|
|
|
45307
45385
|
return await this.adapter.deleteAgent(agentId);
|
|
45308
45386
|
}
|
|
45309
45387
|
async ensureAgentExists(agent) {
|
|
45310
|
-
if (!agent.
|
|
45311
|
-
throw new Error("Agent
|
|
45388
|
+
if (!agent.id) {
|
|
45389
|
+
throw new Error("Agent id is required");
|
|
45312
45390
|
}
|
|
45313
|
-
const
|
|
45314
|
-
|
|
45315
|
-
if (existingAgentId) {
|
|
45391
|
+
const existingAgent = await this.adapter.getAgent(agent.id);
|
|
45392
|
+
if (existingAgent) {
|
|
45316
45393
|
const updatedAgent = {
|
|
45317
45394
|
...agent,
|
|
45318
|
-
id:
|
|
45395
|
+
id: agent.id,
|
|
45319
45396
|
updatedAt: Date.now()
|
|
45320
45397
|
};
|
|
45321
|
-
await this.adapter.updateAgent(
|
|
45322
|
-
const
|
|
45323
|
-
if (!
|
|
45324
|
-
throw new Error(`Failed to retrieve agent after update: ${
|
|
45398
|
+
await this.adapter.updateAgent(agent.id, updatedAgent);
|
|
45399
|
+
const refreshedAgent = await this.adapter.getAgent(agent.id);
|
|
45400
|
+
if (!refreshedAgent) {
|
|
45401
|
+
throw new Error(`Failed to retrieve agent after update: ${agent.id}`);
|
|
45325
45402
|
}
|
|
45326
|
-
this.logger.debug(`Updated existing agent ${agent.
|
|
45327
|
-
return
|
|
45403
|
+
this.logger.debug(`Updated existing agent ${agent.id} on restart`);
|
|
45404
|
+
return refreshedAgent;
|
|
45328
45405
|
}
|
|
45329
45406
|
const newAgent = {
|
|
45330
45407
|
...agent,
|
|
45331
|
-
id:
|
|
45408
|
+
id: agent.id
|
|
45332
45409
|
};
|
|
45333
45410
|
const created = await this.adapter.createAgent(newAgent);
|
|
45334
45411
|
if (!created) {
|
|
45335
|
-
throw new Error(`Failed to create agent: ${agent.
|
|
45412
|
+
throw new Error(`Failed to create agent: ${agent.id}`);
|
|
45336
45413
|
}
|
|
45337
|
-
this.logger.debug(`Created new agent ${agent.
|
|
45414
|
+
this.logger.debug(`Created new agent ${agent.id}`);
|
|
45338
45415
|
return newAgent;
|
|
45339
45416
|
}
|
|
45340
45417
|
async getEntityById(entityId) {
|
|
@@ -46723,47 +46800,6 @@ Data: ${JSON.stringify(entity.metadata)}
|
|
|
46723
46800
|
return entityStrings.join(`
|
|
46724
46801
|
`);
|
|
46725
46802
|
}
|
|
46726
|
-
// src/character.ts
|
|
46727
|
-
function parseCharacter(input) {
|
|
46728
|
-
if (typeof input === "string") {
|
|
46729
|
-
throw new Error(`Character path provided but must be loaded first: ${input}`);
|
|
46730
|
-
}
|
|
46731
|
-
if (typeof input === "object") {
|
|
46732
|
-
const validationResult = validateCharacter(input);
|
|
46733
|
-
if (!validationResult.success) {
|
|
46734
|
-
const errorDetails = validationResult.error?.issues ? validationResult.error.issues.map((issue) => `${issue.path.join(".")}: ${issue.message}`).join("; ") : validationResult.error?.message || "Unknown validation error";
|
|
46735
|
-
throw new Error(`Character validation failed: ${errorDetails}`);
|
|
46736
|
-
}
|
|
46737
|
-
return validationResult.data;
|
|
46738
|
-
}
|
|
46739
|
-
throw new Error("Invalid character input format");
|
|
46740
|
-
}
|
|
46741
|
-
function validateCharacterConfig(character) {
|
|
46742
|
-
const validationResult = validateCharacter(character);
|
|
46743
|
-
if (validationResult.success) {
|
|
46744
|
-
return {
|
|
46745
|
-
isValid: true,
|
|
46746
|
-
errors: []
|
|
46747
|
-
};
|
|
46748
|
-
}
|
|
46749
|
-
const errors = validationResult.error?.issues ? validationResult.error.issues.map((issue) => `${issue.path.join(".")}: ${issue.message}`) : [validationResult.error?.message || "Unknown validation error"];
|
|
46750
|
-
return {
|
|
46751
|
-
isValid: false,
|
|
46752
|
-
errors
|
|
46753
|
-
};
|
|
46754
|
-
}
|
|
46755
|
-
function mergeCharacterDefaults(char) {
|
|
46756
|
-
const defaults = {
|
|
46757
|
-
settings: {},
|
|
46758
|
-
plugins: [],
|
|
46759
|
-
bio: []
|
|
46760
|
-
};
|
|
46761
|
-
return {
|
|
46762
|
-
...defaults,
|
|
46763
|
-
...char,
|
|
46764
|
-
name: char.name || "Unnamed Character"
|
|
46765
|
-
};
|
|
46766
|
-
}
|
|
46767
46803
|
|
|
46768
46804
|
// src/index.node.ts
|
|
46769
46805
|
var isBrowser4 = false;
|
|
@@ -46898,6 +46934,7 @@ export {
|
|
|
46898
46934
|
clearSaltCache,
|
|
46899
46935
|
characterSchema,
|
|
46900
46936
|
byteLength,
|
|
46937
|
+
buildCharacterPlugins,
|
|
46901
46938
|
booleanFooter,
|
|
46902
46939
|
asUUID,
|
|
46903
46940
|
alloc,
|
|
@@ -46928,5 +46965,5 @@ export {
|
|
|
46928
46965
|
AgentRuntime
|
|
46929
46966
|
};
|
|
46930
46967
|
|
|
46931
|
-
//# debugId=
|
|
46968
|
+
//# debugId=5DD1578DC5F08BED64756E2164756E21
|
|
46932
46969
|
//# sourceMappingURL=index.node.js.map
|