@elizaos/core 1.5.12 → 1.5.13-alpha.2
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 +141 -119
- package/dist/browser/index.browser.js.map +74 -16
- package/dist/elizaos.d.ts +153 -0
- package/dist/elizaos.d.ts.map +1 -0
- 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 +2 -2
- package/dist/index.node.d.ts.map +1 -1
- package/dist/node/index.node.js +319 -102
- package/dist/node/index.node.js.map +14 -13
- package/dist/runtime.d.ts.map +1 -1
- package/dist/schemas/character.d.ts +21 -179
- package/dist/schemas/character.d.ts.map +1 -1
- package/dist/utils/node.d.ts +6 -0
- package/dist/utils/node.d.ts.map +1 -0
- package/dist/utils/paths.d.ts.map +1 -1
- package/package.json +3 -3
package/dist/node/index.node.js
CHANGED
|
@@ -10054,12 +10054,13 @@ var require_algorithms = __commonJS((exports, module) => {
|
|
|
10054
10054
|
|
|
10055
10055
|
// ../../node_modules/pbkdf2/lib/precondition.js
|
|
10056
10056
|
var require_precondition = __commonJS((exports, module) => {
|
|
10057
|
+
var $isFinite = isFinite;
|
|
10057
10058
|
var MAX_ALLOC = Math.pow(2, 30) - 1;
|
|
10058
10059
|
module.exports = function(iterations, keylen) {
|
|
10059
10060
|
if (typeof iterations !== "number") {
|
|
10060
10061
|
throw new TypeError("Iterations not a number");
|
|
10061
10062
|
}
|
|
10062
|
-
if (iterations < 0) {
|
|
10063
|
+
if (iterations < 0 || !$isFinite(iterations)) {
|
|
10063
10064
|
throw new TypeError("Bad iterations");
|
|
10064
10065
|
}
|
|
10065
10066
|
if (typeof keylen !== "number") {
|
|
@@ -11317,7 +11318,10 @@ var require_to_buffer = __commonJS((exports, module) => {
|
|
|
11317
11318
|
var useArrayBuffer = typeof ArrayBuffer !== "undefined" && typeof Uint8Array !== "undefined";
|
|
11318
11319
|
var useFromArrayBuffer = useArrayBuffer && (Buffer2.prototype instanceof Uint8Array || Buffer2.TYPED_ARRAY_SUPPORT);
|
|
11319
11320
|
module.exports = function toBuffer(data2, encoding) {
|
|
11320
|
-
if (data2
|
|
11321
|
+
if (Buffer2.isBuffer(data2)) {
|
|
11322
|
+
if (data2.constructor && !("isBuffer" in data2)) {
|
|
11323
|
+
return Buffer2.from(data2);
|
|
11324
|
+
}
|
|
11321
11325
|
return data2;
|
|
11322
11326
|
}
|
|
11323
11327
|
if (typeof data2 === "string") {
|
|
@@ -11521,6 +11525,12 @@ var require_async = __commonJS((exports, module) => {
|
|
|
11521
11525
|
callback = digest;
|
|
11522
11526
|
digest = undefined;
|
|
11523
11527
|
}
|
|
11528
|
+
checkParameters(iterations, keylen);
|
|
11529
|
+
password = toBuffer(password, defaultEncoding, "Password");
|
|
11530
|
+
salt = toBuffer(salt, defaultEncoding, "Salt");
|
|
11531
|
+
if (typeof callback !== "function") {
|
|
11532
|
+
throw new Error("No callback provided to pbkdf2");
|
|
11533
|
+
}
|
|
11524
11534
|
digest = digest || "sha1";
|
|
11525
11535
|
var algo = toBrowser[digest.toLowerCase()];
|
|
11526
11536
|
if (!algo || typeof global.Promise !== "function") {
|
|
@@ -11536,12 +11546,6 @@ var require_async = __commonJS((exports, module) => {
|
|
|
11536
11546
|
});
|
|
11537
11547
|
return;
|
|
11538
11548
|
}
|
|
11539
|
-
checkParameters(iterations, keylen);
|
|
11540
|
-
password = toBuffer(password, defaultEncoding, "Password");
|
|
11541
|
-
salt = toBuffer(salt, defaultEncoding, "Salt");
|
|
11542
|
-
if (typeof callback !== "function") {
|
|
11543
|
-
throw new Error("No callback provided to pbkdf2");
|
|
11544
|
-
}
|
|
11545
11549
|
resolvePromise(checkNative(algo).then(function(resp) {
|
|
11546
11550
|
if (resp) {
|
|
11547
11551
|
return browserPbkdf2(password, salt, iterations, keylen, algo);
|
|
@@ -19680,8 +19684,8 @@ var require_reporter = __commonJS((exports) => {
|
|
|
19680
19684
|
errors: state.errors
|
|
19681
19685
|
};
|
|
19682
19686
|
};
|
|
19683
|
-
function ReporterError(
|
|
19684
|
-
this.path =
|
|
19687
|
+
function ReporterError(path, msg) {
|
|
19688
|
+
this.path = path;
|
|
19685
19689
|
this.rethrow(msg);
|
|
19686
19690
|
}
|
|
19687
19691
|
inherits(ReporterError, Error);
|
|
@@ -21391,7 +21395,7 @@ var require_parse_asn1 = __commonJS((exports, module) => {
|
|
|
21391
21395
|
var aesid = require_aesid();
|
|
21392
21396
|
var fixProc = require_fixProc();
|
|
21393
21397
|
var ciphers = require_browserify_aes();
|
|
21394
|
-
var
|
|
21398
|
+
var pbkdf2Sync = require_pbkdf2().pbkdf2Sync;
|
|
21395
21399
|
var Buffer2 = require_safe_buffer().Buffer;
|
|
21396
21400
|
function decrypt(data2, password) {
|
|
21397
21401
|
var salt = data2.algorithm.decrypt.kde.kdeparams.salt;
|
|
@@ -21400,7 +21404,7 @@ var require_parse_asn1 = __commonJS((exports, module) => {
|
|
|
21400
21404
|
var iv = data2.algorithm.decrypt.cipher.iv;
|
|
21401
21405
|
var cipherText = data2.subjectPrivateKey;
|
|
21402
21406
|
var keylen = parseInt(algo.split("-")[1], 10) / 8;
|
|
21403
|
-
var key =
|
|
21407
|
+
var key = pbkdf2Sync(password, salt, iters, keylen, "sha1");
|
|
21404
21408
|
var cipher = ciphers.createDecipheriv(algo, key, iv);
|
|
21405
21409
|
var out = [];
|
|
21406
21410
|
out.push(cipher.update(cipherText));
|
|
@@ -25878,7 +25882,7 @@ var getDefaultProjectName = () => {
|
|
|
25878
25882
|
};
|
|
25879
25883
|
|
|
25880
25884
|
// ../../node_modules/langsmith/dist/index.js
|
|
25881
|
-
var __version__ = "0.3.
|
|
25885
|
+
var __version__ = "0.3.69";
|
|
25882
25886
|
|
|
25883
25887
|
// ../../node_modules/langsmith/dist/utils/env.js
|
|
25884
25888
|
var globalEnv;
|
|
@@ -41884,7 +41888,7 @@ function parseBooleanFromText2(value) {
|
|
|
41884
41888
|
}
|
|
41885
41889
|
return false;
|
|
41886
41890
|
}
|
|
41887
|
-
var uuidSchema = z2.string().
|
|
41891
|
+
var uuidSchema = z2.string().regex(/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i, "Invalid UUID format");
|
|
41888
41892
|
function validateUuid(value) {
|
|
41889
41893
|
const result = uuidSchema.safeParse(value);
|
|
41890
41894
|
return result.success ? result.data : null;
|
|
@@ -42110,14 +42114,14 @@ var styleSchema = z3.object({
|
|
|
42110
42114
|
chat: z3.array(z3.string()).optional(),
|
|
42111
42115
|
post: z3.array(z3.string()).optional()
|
|
42112
42116
|
}).optional();
|
|
42113
|
-
var settingsSchema = z3.record(z3.union([z3.string(), z3.boolean(), z3.number(), z3.any()])).optional();
|
|
42114
|
-
var secretsSchema = z3.record(z3.union([z3.string(), z3.boolean(), z3.number()])).optional();
|
|
42117
|
+
var settingsSchema = z3.record(z3.string(), z3.union([z3.string(), z3.boolean(), z3.number(), z3.any()])).optional();
|
|
42118
|
+
var secretsSchema = z3.record(z3.string(), z3.union([z3.string(), z3.boolean(), z3.number()])).optional();
|
|
42115
42119
|
var characterSchema = z3.object({
|
|
42116
42120
|
id: uuidSchema2.optional(),
|
|
42117
42121
|
name: z3.string().min(1, "Character name is required"),
|
|
42118
42122
|
username: z3.string().optional(),
|
|
42119
42123
|
system: z3.string().optional(),
|
|
42120
|
-
templates: z3.record(templateTypeSchema).optional(),
|
|
42124
|
+
templates: z3.record(z3.string(), templateTypeSchema).optional(),
|
|
42121
42125
|
bio: z3.union([z3.string(), z3.array(z3.string())]),
|
|
42122
42126
|
messageExamples: z3.array(z3.array(messageExampleSchema)).optional(),
|
|
42123
42127
|
postExamples: z3.array(z3.string()).optional(),
|
|
@@ -42315,85 +42319,16 @@ var BufferUtils = {
|
|
|
42315
42319
|
byteLength,
|
|
42316
42320
|
randomBytes
|
|
42317
42321
|
};
|
|
42318
|
-
// src/utils/
|
|
42319
|
-
|
|
42320
|
-
|
|
42321
|
-
port,
|
|
42322
|
-
endpoint = "/api/agents",
|
|
42323
|
-
maxWaitTime = 30000,
|
|
42324
|
-
pollInterval = 1000,
|
|
42325
|
-
requestTimeout = 2000,
|
|
42326
|
-
host = "localhost",
|
|
42327
|
-
protocol = "http"
|
|
42328
|
-
} = options;
|
|
42329
|
-
const url = `${protocol}://${host}:${port}${endpoint}`;
|
|
42330
|
-
const startTime = Date.now();
|
|
42331
|
-
while (Date.now() - startTime < maxWaitTime) {
|
|
42332
|
-
let controller;
|
|
42333
|
-
let timeoutId;
|
|
42322
|
+
// src/utils/paths.ts
|
|
42323
|
+
var pathJoin = (...parts) => {
|
|
42324
|
+
if (typeof process !== "undefined" && process.platform) {
|
|
42334
42325
|
try {
|
|
42335
|
-
|
|
42336
|
-
|
|
42337
|
-
|
|
42338
|
-
controller.abort();
|
|
42339
|
-
}
|
|
42340
|
-
}, requestTimeout);
|
|
42341
|
-
const response = await fetch(url, {
|
|
42342
|
-
signal: controller.signal
|
|
42343
|
-
});
|
|
42344
|
-
if (timeoutId) {
|
|
42345
|
-
clearTimeout(timeoutId);
|
|
42346
|
-
timeoutId = undefined;
|
|
42347
|
-
}
|
|
42348
|
-
if (response.ok) {
|
|
42349
|
-
await new Promise((resolve) => setTimeout(resolve, 1000));
|
|
42350
|
-
return;
|
|
42351
|
-
}
|
|
42352
|
-
} catch (error) {} finally {
|
|
42353
|
-
if (timeoutId) {
|
|
42354
|
-
clearTimeout(timeoutId);
|
|
42355
|
-
}
|
|
42356
|
-
}
|
|
42357
|
-
await new Promise((resolve) => setTimeout(resolve, pollInterval));
|
|
42358
|
-
}
|
|
42359
|
-
throw new Error(`Server failed to become ready at ${url} within ${maxWaitTime}ms`);
|
|
42360
|
-
}
|
|
42361
|
-
async function pingServer(options) {
|
|
42362
|
-
const {
|
|
42363
|
-
port,
|
|
42364
|
-
endpoint = "/api/agents",
|
|
42365
|
-
requestTimeout = 2000,
|
|
42366
|
-
host = "localhost",
|
|
42367
|
-
protocol = "http"
|
|
42368
|
-
} = options;
|
|
42369
|
-
const url = `${protocol}://${host}:${port}${endpoint}`;
|
|
42370
|
-
let controller;
|
|
42371
|
-
let timeoutId;
|
|
42372
|
-
try {
|
|
42373
|
-
controller = new AbortController;
|
|
42374
|
-
timeoutId = setTimeout(() => {
|
|
42375
|
-
if (controller) {
|
|
42376
|
-
controller.abort();
|
|
42377
|
-
}
|
|
42378
|
-
}, requestTimeout);
|
|
42379
|
-
const response = await fetch(url, {
|
|
42380
|
-
signal: controller.signal
|
|
42381
|
-
});
|
|
42382
|
-
if (timeoutId) {
|
|
42383
|
-
clearTimeout(timeoutId);
|
|
42384
|
-
timeoutId = undefined;
|
|
42385
|
-
}
|
|
42386
|
-
return response.ok;
|
|
42387
|
-
} catch (error) {
|
|
42388
|
-
return false;
|
|
42389
|
-
} finally {
|
|
42390
|
-
if (timeoutId) {
|
|
42391
|
-
clearTimeout(timeoutId);
|
|
42392
|
-
}
|
|
42326
|
+
const path = __require("node:path");
|
|
42327
|
+
return path.join(...parts);
|
|
42328
|
+
} catch {}
|
|
42393
42329
|
}
|
|
42394
|
-
|
|
42395
|
-
|
|
42396
|
-
import path from "node:path";
|
|
42330
|
+
return parts.filter((part) => part).join("/").replace(/\/+/g, "/").replace(/\/$/, "");
|
|
42331
|
+
};
|
|
42397
42332
|
|
|
42398
42333
|
class ElizaPaths {
|
|
42399
42334
|
cache = new Map;
|
|
@@ -42401,7 +42336,7 @@ class ElizaPaths {
|
|
|
42401
42336
|
const cached = this.cache.get("dataDir");
|
|
42402
42337
|
if (cached)
|
|
42403
42338
|
return cached;
|
|
42404
|
-
const dir = process.env
|
|
42339
|
+
const dir = typeof process !== "undefined" && process.env?.ELIZA_DATA_DIR || (typeof process !== "undefined" && process.cwd ? pathJoin(process.cwd(), ".eliza") : ".eliza");
|
|
42405
42340
|
this.cache.set("dataDir", dir);
|
|
42406
42341
|
return dir;
|
|
42407
42342
|
}
|
|
@@ -42409,7 +42344,7 @@ class ElizaPaths {
|
|
|
42409
42344
|
const cached = this.cache.get("databaseDir");
|
|
42410
42345
|
if (cached)
|
|
42411
42346
|
return cached;
|
|
42412
|
-
const dir = process.env
|
|
42347
|
+
const dir = typeof process !== "undefined" && process.env?.ELIZA_DATABASE_DIR || typeof process !== "undefined" && process.env?.PGLITE_DATA_DIR || pathJoin(this.getDataDir(), ".elizadb");
|
|
42413
42348
|
this.cache.set("databaseDir", dir);
|
|
42414
42349
|
return dir;
|
|
42415
42350
|
}
|
|
@@ -42417,7 +42352,7 @@ class ElizaPaths {
|
|
|
42417
42352
|
const cached = this.cache.get("charactersDir");
|
|
42418
42353
|
if (cached)
|
|
42419
42354
|
return cached;
|
|
42420
|
-
const dir = process.env
|
|
42355
|
+
const dir = typeof process !== "undefined" && process.env?.ELIZA_DATA_DIR_CHARACTERS || pathJoin(this.getDataDir(), "data", "characters");
|
|
42421
42356
|
this.cache.set("charactersDir", dir);
|
|
42422
42357
|
return dir;
|
|
42423
42358
|
}
|
|
@@ -42425,7 +42360,7 @@ class ElizaPaths {
|
|
|
42425
42360
|
const cached = this.cache.get("generatedDir");
|
|
42426
42361
|
if (cached)
|
|
42427
42362
|
return cached;
|
|
42428
|
-
const dir = process.env
|
|
42363
|
+
const dir = typeof process !== "undefined" && process.env?.ELIZA_DATA_DIR_GENERATED || pathJoin(this.getDataDir(), "data", "generated");
|
|
42429
42364
|
this.cache.set("generatedDir", dir);
|
|
42430
42365
|
return dir;
|
|
42431
42366
|
}
|
|
@@ -42433,7 +42368,7 @@ class ElizaPaths {
|
|
|
42433
42368
|
const cached = this.cache.get("uploadsAgentsDir");
|
|
42434
42369
|
if (cached)
|
|
42435
42370
|
return cached;
|
|
42436
|
-
const dir = process.env
|
|
42371
|
+
const dir = typeof process !== "undefined" && process.env?.ELIZA_DATA_DIR_UPLOADS_AGENTS || pathJoin(this.getDataDir(), "data", "uploads", "agents");
|
|
42437
42372
|
this.cache.set("uploadsAgentsDir", dir);
|
|
42438
42373
|
return dir;
|
|
42439
42374
|
}
|
|
@@ -42441,7 +42376,7 @@ class ElizaPaths {
|
|
|
42441
42376
|
const cached = this.cache.get("uploadsChannelsDir");
|
|
42442
42377
|
if (cached)
|
|
42443
42378
|
return cached;
|
|
42444
|
-
const dir = process.env
|
|
42379
|
+
const dir = typeof process !== "undefined" && process.env?.ELIZA_DATA_DIR_UPLOADS_CHANNELS || pathJoin(this.getDataDir(), "data", "uploads", "channels");
|
|
42445
42380
|
this.cache.set("uploadsChannelsDir", dir);
|
|
42446
42381
|
return dir;
|
|
42447
42382
|
}
|
|
@@ -42493,6 +42428,84 @@ function resetPaths() {
|
|
|
42493
42428
|
}
|
|
42494
42429
|
pathsInstance = null;
|
|
42495
42430
|
}
|
|
42431
|
+
|
|
42432
|
+
// src/utils/server-health.ts
|
|
42433
|
+
async function waitForServerReady(options) {
|
|
42434
|
+
const {
|
|
42435
|
+
port,
|
|
42436
|
+
endpoint = "/api/agents",
|
|
42437
|
+
maxWaitTime = 30000,
|
|
42438
|
+
pollInterval = 1000,
|
|
42439
|
+
requestTimeout = 2000,
|
|
42440
|
+
host = "localhost",
|
|
42441
|
+
protocol = "http"
|
|
42442
|
+
} = options;
|
|
42443
|
+
const url = `${protocol}://${host}:${port}${endpoint}`;
|
|
42444
|
+
const startTime = Date.now();
|
|
42445
|
+
while (Date.now() - startTime < maxWaitTime) {
|
|
42446
|
+
let controller;
|
|
42447
|
+
let timeoutId;
|
|
42448
|
+
try {
|
|
42449
|
+
controller = new AbortController;
|
|
42450
|
+
timeoutId = setTimeout(() => {
|
|
42451
|
+
if (controller) {
|
|
42452
|
+
controller.abort();
|
|
42453
|
+
}
|
|
42454
|
+
}, requestTimeout);
|
|
42455
|
+
const response = await fetch(url, {
|
|
42456
|
+
signal: controller.signal
|
|
42457
|
+
});
|
|
42458
|
+
if (timeoutId) {
|
|
42459
|
+
clearTimeout(timeoutId);
|
|
42460
|
+
timeoutId = undefined;
|
|
42461
|
+
}
|
|
42462
|
+
if (response.ok) {
|
|
42463
|
+
await new Promise((resolve) => setTimeout(resolve, 1000));
|
|
42464
|
+
return;
|
|
42465
|
+
}
|
|
42466
|
+
} catch (error) {} finally {
|
|
42467
|
+
if (timeoutId) {
|
|
42468
|
+
clearTimeout(timeoutId);
|
|
42469
|
+
}
|
|
42470
|
+
}
|
|
42471
|
+
await new Promise((resolve) => setTimeout(resolve, pollInterval));
|
|
42472
|
+
}
|
|
42473
|
+
throw new Error(`Server failed to become ready at ${url} within ${maxWaitTime}ms`);
|
|
42474
|
+
}
|
|
42475
|
+
async function pingServer(options) {
|
|
42476
|
+
const {
|
|
42477
|
+
port,
|
|
42478
|
+
endpoint = "/api/agents",
|
|
42479
|
+
requestTimeout = 2000,
|
|
42480
|
+
host = "localhost",
|
|
42481
|
+
protocol = "http"
|
|
42482
|
+
} = options;
|
|
42483
|
+
const url = `${protocol}://${host}:${port}${endpoint}`;
|
|
42484
|
+
let controller;
|
|
42485
|
+
let timeoutId;
|
|
42486
|
+
try {
|
|
42487
|
+
controller = new AbortController;
|
|
42488
|
+
timeoutId = setTimeout(() => {
|
|
42489
|
+
if (controller) {
|
|
42490
|
+
controller.abort();
|
|
42491
|
+
}
|
|
42492
|
+
}, requestTimeout);
|
|
42493
|
+
const response = await fetch(url, {
|
|
42494
|
+
signal: controller.signal
|
|
42495
|
+
});
|
|
42496
|
+
if (timeoutId) {
|
|
42497
|
+
clearTimeout(timeoutId);
|
|
42498
|
+
timeoutId = undefined;
|
|
42499
|
+
}
|
|
42500
|
+
return response.ok;
|
|
42501
|
+
} catch (error) {
|
|
42502
|
+
return false;
|
|
42503
|
+
} finally {
|
|
42504
|
+
if (timeoutId) {
|
|
42505
|
+
clearTimeout(timeoutId);
|
|
42506
|
+
}
|
|
42507
|
+
}
|
|
42508
|
+
}
|
|
42496
42509
|
// src/actions.ts
|
|
42497
42510
|
var import_unique_names_generator2 = __toESM(require_dist4(), 1);
|
|
42498
42511
|
var composeActionExamples = (actionsData, count) => {
|
|
@@ -45106,7 +45119,9 @@ class AgentRuntime {
|
|
|
45106
45119
|
await this.adapter.init();
|
|
45107
45120
|
}
|
|
45108
45121
|
async close() {
|
|
45109
|
-
|
|
45122
|
+
if (this.adapter) {
|
|
45123
|
+
await this.adapter.close();
|
|
45124
|
+
}
|
|
45110
45125
|
}
|
|
45111
45126
|
async getAgent(agentId) {
|
|
45112
45127
|
return await this.adapter.getAgent(agentId);
|
|
@@ -45798,6 +45813,207 @@ function defineService(definition) {
|
|
|
45798
45813
|
return createService(definition.serviceType).withDescription(definition.description).withStart(definition.start).withStop(definition.stop || (() => Promise.resolve())).build();
|
|
45799
45814
|
}
|
|
45800
45815
|
|
|
45816
|
+
// src/elizaos.ts
|
|
45817
|
+
class ElizaOS extends EventTarget {
|
|
45818
|
+
runtimes = new Map;
|
|
45819
|
+
editableMode = false;
|
|
45820
|
+
async addAgents(agents) {
|
|
45821
|
+
const promises = agents.map(async (agent) => {
|
|
45822
|
+
const runtime = new AgentRuntime({
|
|
45823
|
+
character: agent.character,
|
|
45824
|
+
plugins: agent.plugins || [],
|
|
45825
|
+
settings: agent.settings || {}
|
|
45826
|
+
});
|
|
45827
|
+
this.runtimes.set(runtime.agentId, runtime);
|
|
45828
|
+
this.dispatchEvent(new CustomEvent("agent:added", {
|
|
45829
|
+
detail: { agentId: runtime.agentId, character: agent.character }
|
|
45830
|
+
}));
|
|
45831
|
+
return runtime.agentId;
|
|
45832
|
+
});
|
|
45833
|
+
const ids = await Promise.all(promises);
|
|
45834
|
+
this.dispatchEvent(new CustomEvent("agents:added", {
|
|
45835
|
+
detail: { agentIds: ids, count: ids.length }
|
|
45836
|
+
}));
|
|
45837
|
+
return ids;
|
|
45838
|
+
}
|
|
45839
|
+
registerAgent(runtime) {
|
|
45840
|
+
if (this.runtimes.has(runtime.agentId)) {
|
|
45841
|
+
throw new Error(`Agent ${runtime.agentId} already registered`);
|
|
45842
|
+
}
|
|
45843
|
+
this.runtimes.set(runtime.agentId, runtime);
|
|
45844
|
+
this.dispatchEvent(new CustomEvent("agent:registered", {
|
|
45845
|
+
detail: { agentId: runtime.agentId, runtime }
|
|
45846
|
+
}));
|
|
45847
|
+
}
|
|
45848
|
+
async updateAgent(agentId, updates) {
|
|
45849
|
+
if (!this.editableMode) {
|
|
45850
|
+
throw new Error("Editable mode not enabled");
|
|
45851
|
+
}
|
|
45852
|
+
const runtime = this.runtimes.get(agentId);
|
|
45853
|
+
if (!runtime) {
|
|
45854
|
+
throw new Error(`Agent ${agentId} not found`);
|
|
45855
|
+
}
|
|
45856
|
+
Object.assign(runtime.character, updates);
|
|
45857
|
+
this.dispatchEvent(new CustomEvent("agent:updated", {
|
|
45858
|
+
detail: { agentId, updates }
|
|
45859
|
+
}));
|
|
45860
|
+
}
|
|
45861
|
+
async deleteAgents(agentIds) {
|
|
45862
|
+
await this.stopAgents(agentIds);
|
|
45863
|
+
for (const id of agentIds) {
|
|
45864
|
+
this.runtimes.delete(id);
|
|
45865
|
+
}
|
|
45866
|
+
this.dispatchEvent(new CustomEvent("agents:deleted", {
|
|
45867
|
+
detail: { agentIds, count: agentIds.length }
|
|
45868
|
+
}));
|
|
45869
|
+
}
|
|
45870
|
+
async startAgents(agentIds) {
|
|
45871
|
+
const ids = agentIds || Array.from(this.runtimes.keys());
|
|
45872
|
+
await Promise.all(ids.map(async (id) => {
|
|
45873
|
+
const runtime = this.runtimes.get(id);
|
|
45874
|
+
if (!runtime) {
|
|
45875
|
+
throw new Error(`Agent ${id} not found`);
|
|
45876
|
+
}
|
|
45877
|
+
await runtime.initialize();
|
|
45878
|
+
this.dispatchEvent(new CustomEvent("agent:started", {
|
|
45879
|
+
detail: { agentId: id }
|
|
45880
|
+
}));
|
|
45881
|
+
}));
|
|
45882
|
+
this.dispatchEvent(new CustomEvent("agents:started", {
|
|
45883
|
+
detail: { agentIds: ids, count: ids.length }
|
|
45884
|
+
}));
|
|
45885
|
+
}
|
|
45886
|
+
async stopAgents(agentIds) {
|
|
45887
|
+
const ids = agentIds || Array.from(this.runtimes.keys());
|
|
45888
|
+
await Promise.all(ids.map(async (id) => {
|
|
45889
|
+
const runtime = this.runtimes.get(id);
|
|
45890
|
+
if (runtime) {
|
|
45891
|
+
await runtime.stop();
|
|
45892
|
+
}
|
|
45893
|
+
}));
|
|
45894
|
+
this.dispatchEvent(new CustomEvent("agents:stopped", {
|
|
45895
|
+
detail: { agentIds: ids, count: ids.length }
|
|
45896
|
+
}));
|
|
45897
|
+
}
|
|
45898
|
+
getAgent(id) {
|
|
45899
|
+
return this.runtimes.get(id);
|
|
45900
|
+
}
|
|
45901
|
+
getAgents() {
|
|
45902
|
+
return Array.from(this.runtimes.values());
|
|
45903
|
+
}
|
|
45904
|
+
getAgentsByIds(ids) {
|
|
45905
|
+
return ids.map((id) => this.runtimes.get(id)).filter((runtime) => runtime !== undefined);
|
|
45906
|
+
}
|
|
45907
|
+
getAgentsByNames(names3) {
|
|
45908
|
+
const nameSet = new Set(names3.map((n) => n.toLowerCase()));
|
|
45909
|
+
return this.getAgents().filter((runtime) => nameSet.has(runtime.character.name.toLowerCase()));
|
|
45910
|
+
}
|
|
45911
|
+
getAgentById(id) {
|
|
45912
|
+
return this.getAgent(id);
|
|
45913
|
+
}
|
|
45914
|
+
getAgentByName(name) {
|
|
45915
|
+
const lowercaseName = name.toLowerCase();
|
|
45916
|
+
return this.getAgents().find((runtime) => runtime.character.name.toLowerCase() === lowercaseName);
|
|
45917
|
+
}
|
|
45918
|
+
getAgentByCharacterName(name) {
|
|
45919
|
+
return this.getAgentByName(name);
|
|
45920
|
+
}
|
|
45921
|
+
getAgentByCharacterId(characterId) {
|
|
45922
|
+
return this.getAgents().find((runtime) => runtime.character.id === characterId);
|
|
45923
|
+
}
|
|
45924
|
+
async sendMessage(agentId, message, options) {
|
|
45925
|
+
const runtime = this.runtimes.get(agentId);
|
|
45926
|
+
if (!runtime) {
|
|
45927
|
+
throw new Error(`Agent ${agentId} not found`);
|
|
45928
|
+
}
|
|
45929
|
+
const memory = typeof message === "string" ? {
|
|
45930
|
+
id: v4_default(),
|
|
45931
|
+
entityId: options?.userId || "system",
|
|
45932
|
+
agentId,
|
|
45933
|
+
roomId: options?.roomId || agentId,
|
|
45934
|
+
content: { text: message },
|
|
45935
|
+
createdAt: Date.now(),
|
|
45936
|
+
metadata: options?.metadata
|
|
45937
|
+
} : message;
|
|
45938
|
+
const responses = [];
|
|
45939
|
+
await runtime.processActions(memory, responses);
|
|
45940
|
+
this.dispatchEvent(new CustomEvent("message:sent", {
|
|
45941
|
+
detail: { agentId, message: memory, responses }
|
|
45942
|
+
}));
|
|
45943
|
+
return responses;
|
|
45944
|
+
}
|
|
45945
|
+
async sendMessages(messages) {
|
|
45946
|
+
const results = await Promise.all(messages.map(async ({ agentId, message, options }) => {
|
|
45947
|
+
try {
|
|
45948
|
+
const responses = await this.sendMessage(agentId, message, options);
|
|
45949
|
+
return { agentId, responses };
|
|
45950
|
+
} catch (error) {
|
|
45951
|
+
return {
|
|
45952
|
+
agentId,
|
|
45953
|
+
responses: [],
|
|
45954
|
+
error: error instanceof Error ? error : new Error(String(error))
|
|
45955
|
+
};
|
|
45956
|
+
}
|
|
45957
|
+
}));
|
|
45958
|
+
this.dispatchEvent(new CustomEvent("messages:sent", {
|
|
45959
|
+
detail: { results, count: messages.length }
|
|
45960
|
+
}));
|
|
45961
|
+
return results;
|
|
45962
|
+
}
|
|
45963
|
+
async validateApiKeys(agents) {
|
|
45964
|
+
const results = new Map;
|
|
45965
|
+
const ids = agents || Array.from(this.runtimes.keys());
|
|
45966
|
+
for (const id of ids) {
|
|
45967
|
+
const runtime = this.runtimes.get(id);
|
|
45968
|
+
if (runtime) {
|
|
45969
|
+
const hasKeys = !!(runtime.getSetting("OPENAI_API_KEY") || runtime.getSetting("ANTHROPIC_API_KEY"));
|
|
45970
|
+
results.set(id, hasKeys);
|
|
45971
|
+
}
|
|
45972
|
+
}
|
|
45973
|
+
return results;
|
|
45974
|
+
}
|
|
45975
|
+
async healthCheck(agents) {
|
|
45976
|
+
const results = new Map;
|
|
45977
|
+
const ids = agents || Array.from(this.runtimes.keys());
|
|
45978
|
+
for (const id of ids) {
|
|
45979
|
+
const runtime = this.runtimes.get(id);
|
|
45980
|
+
const status = {
|
|
45981
|
+
alive: !!runtime,
|
|
45982
|
+
responsive: true
|
|
45983
|
+
};
|
|
45984
|
+
if (typeof process !== "undefined") {
|
|
45985
|
+
status.memoryUsage = process.memoryUsage().heapUsed;
|
|
45986
|
+
status.uptime = process.uptime();
|
|
45987
|
+
}
|
|
45988
|
+
results.set(id, status);
|
|
45989
|
+
}
|
|
45990
|
+
return results;
|
|
45991
|
+
}
|
|
45992
|
+
getRuntimeAccessor() {
|
|
45993
|
+
return {
|
|
45994
|
+
getAgent: (id) => this.getAgent(id),
|
|
45995
|
+
getAgents: () => this.getAgents(),
|
|
45996
|
+
getState: (agentId) => {
|
|
45997
|
+
const agent = this.getAgent(agentId);
|
|
45998
|
+
if (!agent)
|
|
45999
|
+
return;
|
|
46000
|
+
const agentRuntime = agent;
|
|
46001
|
+
if (agentRuntime.stateCache && agentRuntime.stateCache.size > 0) {
|
|
46002
|
+
const states = Array.from(agentRuntime.stateCache.values());
|
|
46003
|
+
return states[states.length - 1];
|
|
46004
|
+
}
|
|
46005
|
+
return;
|
|
46006
|
+
}
|
|
46007
|
+
};
|
|
46008
|
+
}
|
|
46009
|
+
enableEditableMode() {
|
|
46010
|
+
this.editableMode = true;
|
|
46011
|
+
this.dispatchEvent(new CustomEvent("mode:editable", {
|
|
46012
|
+
detail: { editable: true }
|
|
46013
|
+
}));
|
|
46014
|
+
}
|
|
46015
|
+
}
|
|
46016
|
+
|
|
45801
46017
|
// src/entities.ts
|
|
45802
46018
|
var entityResolutionTemplate = `# Task: Resolve Entity Name
|
|
45803
46019
|
Message Sender: {{senderName}} (ID: {{senderId}})
|
|
@@ -46162,6 +46378,7 @@ export {
|
|
|
46162
46378
|
IBrowserService,
|
|
46163
46379
|
EventType,
|
|
46164
46380
|
Environment,
|
|
46381
|
+
ElizaOS,
|
|
46165
46382
|
DatabaseAdapter,
|
|
46166
46383
|
ContentType,
|
|
46167
46384
|
ChannelType,
|
|
@@ -46172,5 +46389,5 @@ export {
|
|
|
46172
46389
|
AgentRuntime
|
|
46173
46390
|
};
|
|
46174
46391
|
|
|
46175
|
-
//# debugId=
|
|
46392
|
+
//# debugId=4E86C04C1312961F64756E2164756E21
|
|
46176
46393
|
//# sourceMappingURL=index.node.js.map
|