@elizaos/core 1.5.12-alpha.2 → 1.5.12

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.
@@ -19,7 +19,6 @@ export * from './runtime';
19
19
  export * from './settings';
20
20
  export * from './services';
21
21
  export * from './search';
22
- export * from './elizaos';
23
22
  export declare const isBrowser = true;
24
23
  export declare const isNode = false;
25
24
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"index.browser.d.ts","sourceRoot":"","sources":["../src/index.browser.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,cAAc,SAAS,CAAC;AAGxB,cAAc,SAAS,CAAC;AAGxB,cAAc,qBAAqB,CAAC;AAGpC,cAAc,qBAAqB,CAAC;AACpC,cAAc,gBAAgB,CAAC;AAI/B,cAAc,WAAW,CAAC;AAC1B,cAAc,YAAY,CAAC;AAC3B,cAAc,YAAY,CAAC;AAC3B,cAAc,UAAU,CAAC;AACzB,cAAc,WAAW,CAAC;AAC1B,cAAc,SAAS,CAAC;AACxB,cAAc,WAAW,CAAC;AAC1B,cAAc,YAAY,CAAC;AAC3B,cAAc,YAAY,CAAC;AAC3B,cAAc,UAAU,CAAC;AACzB,cAAc,WAAW,CAAC;AAG1B,eAAO,MAAM,SAAS,OAAO,CAAC;AAC9B,eAAO,MAAM,MAAM,QAAQ,CAAC;AAE5B;;;GAGG;AACH,eAAO,MAAM,YAAY;;;;;;CAGxB,CAAC"}
1
+ {"version":3,"file":"index.browser.d.ts","sourceRoot":"","sources":["../src/index.browser.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,cAAc,SAAS,CAAC;AAGxB,cAAc,SAAS,CAAC;AAGxB,cAAc,qBAAqB,CAAC;AAGpC,cAAc,qBAAqB,CAAC;AACpC,cAAc,gBAAgB,CAAC;AAI/B,cAAc,WAAW,CAAC;AAC1B,cAAc,YAAY,CAAC;AAC3B,cAAc,YAAY,CAAC;AAC3B,cAAc,UAAU,CAAC;AACzB,cAAc,WAAW,CAAC;AAC1B,cAAc,SAAS,CAAC;AACxB,cAAc,WAAW,CAAC;AAC1B,cAAc,YAAY,CAAC;AAC3B,cAAc,YAAY,CAAC;AAC3B,cAAc,UAAU,CAAC;AAGzB,eAAO,MAAM,SAAS,OAAO,CAAC;AAC9B,eAAO,MAAM,MAAM,QAAQ,CAAC;AAE5B;;;GAGG;AACH,eAAO,MAAM,YAAY;;;;;;CAGxB,CAAC"}
package/dist/index.d.ts CHANGED
@@ -21,7 +21,6 @@ export * from './runtime';
21
21
  export * from './settings';
22
22
  export * from './services';
23
23
  export * from './search';
24
- export * from './elizaos';
25
24
  export declare const isBrowser: boolean;
26
25
  export declare const isNode: boolean;
27
26
  export * from './utils/server-health';
@@ -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,cAAc,gBAAgB,CAAC;AAI/B,cAAc,eAAe,CAAC;AAG9B,cAAc,WAAW,CAAC;AAC1B,cAAc,YAAY,CAAC;AAC3B,cAAc,YAAY,CAAC;AAC3B,cAAc,UAAU,CAAC;AACzB,cAAc,WAAW,CAAC;AAC1B,cAAc,SAAS,CAAC;AACxB,cAAc,WAAW,CAAC;AAC1B,cAAc,YAAY,CAAC;AAC3B,cAAc,YAAY,CAAC;AAC3B,cAAc,UAAU,CAAC;AAGzB,cAAc,WAAW,CAAC;AAG1B,eAAO,MAAM,SAAS,SAG+B,CAAC;AACtD,eAAO,MAAM,MAAM,SAG2B,CAAC;AAG/C,cAAc,uBAAuB,CAAC"}
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,cAAc,gBAAgB,CAAC;AAI/B,cAAc,eAAe,CAAC;AAG9B,cAAc,WAAW,CAAC;AAC1B,cAAc,YAAY,CAAC;AAC3B,cAAc,YAAY,CAAC;AAC3B,cAAc,UAAU,CAAC;AACzB,cAAc,WAAW,CAAC;AAC1B,cAAc,SAAS,CAAC;AACxB,cAAc,WAAW,CAAC;AAC1B,cAAc,YAAY,CAAC;AAC3B,cAAc,YAAY,CAAC;AAC3B,cAAc,UAAU,CAAC;AAGzB,eAAO,MAAM,SAAS,SAG+B,CAAC;AACtD,eAAO,MAAM,MAAM,SAG2B,CAAC;AAG/C,cAAc,uBAAuB,CAAC"}
@@ -9,7 +9,8 @@ export * from './utils';
9
9
  export * from './schemas/character';
10
10
  export * from './utils/environment';
11
11
  export * from './utils/buffer';
12
- export * from './utils/node';
12
+ export * from './utils/server-health';
13
+ export * from './utils/paths';
13
14
  export * from './actions';
14
15
  export * from './database';
15
16
  export * from './entities';
@@ -20,7 +21,6 @@ export * from './runtime';
20
21
  export * from './settings';
21
22
  export * from './services';
22
23
  export * from './search';
23
- export * from './elizaos';
24
24
  export declare const isBrowser = false;
25
25
  export declare const isNode = true;
26
26
  //# sourceMappingURL=index.node.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.node.d.ts","sourceRoot":"","sources":["../src/index.node.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,cAAc,SAAS,CAAC;AAGxB,cAAc,SAAS,CAAC;AAGxB,cAAc,qBAAqB,CAAC;AAGpC,cAAc,qBAAqB,CAAC;AACpC,cAAc,gBAAgB,CAAC;AAE/B,cAAc,cAAc,CAAC;AAG7B,cAAc,WAAW,CAAC;AAC1B,cAAc,YAAY,CAAC;AAC3B,cAAc,YAAY,CAAC;AAC3B,cAAc,UAAU,CAAC;AACzB,cAAc,WAAW,CAAC;AAC1B,cAAc,SAAS,CAAC;AACxB,cAAc,WAAW,CAAC;AAC1B,cAAc,YAAY,CAAC;AAC3B,cAAc,YAAY,CAAC;AAC3B,cAAc,UAAU,CAAC;AACzB,cAAc,WAAW,CAAC;AAG1B,eAAO,MAAM,SAAS,QAAQ,CAAC;AAC/B,eAAO,MAAM,MAAM,OAAO,CAAC"}
1
+ {"version":3,"file":"index.node.d.ts","sourceRoot":"","sources":["../src/index.node.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,cAAc,SAAS,CAAC;AAGxB,cAAc,SAAS,CAAC;AAGxB,cAAc,qBAAqB,CAAC;AAGpC,cAAc,qBAAqB,CAAC;AACpC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,uBAAuB,CAAC;AACtC,cAAc,eAAe,CAAC;AAG9B,cAAc,WAAW,CAAC;AAC1B,cAAc,YAAY,CAAC;AAC3B,cAAc,YAAY,CAAC;AAC3B,cAAc,UAAU,CAAC;AACzB,cAAc,WAAW,CAAC;AAC1B,cAAc,SAAS,CAAC;AACxB,cAAc,WAAW,CAAC;AAC1B,cAAc,YAAY,CAAC;AAC3B,cAAc,YAAY,CAAC;AAC3B,cAAc,UAAU,CAAC;AAGzB,eAAO,MAAM,SAAS,QAAQ,CAAC;AAC/B,eAAO,MAAM,MAAM,OAAO,CAAC"}
@@ -10054,13 +10054,12 @@ 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;
10058
10057
  var MAX_ALLOC = Math.pow(2, 30) - 1;
10059
10058
  module.exports = function(iterations, keylen) {
10060
10059
  if (typeof iterations !== "number") {
10061
10060
  throw new TypeError("Iterations not a number");
10062
10061
  }
10063
- if (iterations < 0 || !$isFinite(iterations)) {
10062
+ if (iterations < 0) {
10064
10063
  throw new TypeError("Bad iterations");
10065
10064
  }
10066
10065
  if (typeof keylen !== "number") {
@@ -11318,10 +11317,7 @@ var require_to_buffer = __commonJS((exports, module) => {
11318
11317
  var useArrayBuffer = typeof ArrayBuffer !== "undefined" && typeof Uint8Array !== "undefined";
11319
11318
  var useFromArrayBuffer = useArrayBuffer && (Buffer2.prototype instanceof Uint8Array || Buffer2.TYPED_ARRAY_SUPPORT);
11320
11319
  module.exports = function toBuffer(data2, encoding) {
11321
- if (Buffer2.isBuffer(data2)) {
11322
- if (data2.constructor && !("isBuffer" in data2)) {
11323
- return Buffer2.from(data2);
11324
- }
11320
+ if (data2 instanceof Buffer2) {
11325
11321
  return data2;
11326
11322
  }
11327
11323
  if (typeof data2 === "string") {
@@ -11525,12 +11521,6 @@ var require_async = __commonJS((exports, module) => {
11525
11521
  callback = digest;
11526
11522
  digest = undefined;
11527
11523
  }
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
- }
11534
11524
  digest = digest || "sha1";
11535
11525
  var algo = toBrowser[digest.toLowerCase()];
11536
11526
  if (!algo || typeof global.Promise !== "function") {
@@ -11546,6 +11536,12 @@ var require_async = __commonJS((exports, module) => {
11546
11536
  });
11547
11537
  return;
11548
11538
  }
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
+ }
11549
11545
  resolvePromise(checkNative(algo).then(function(resp) {
11550
11546
  if (resp) {
11551
11547
  return browserPbkdf2(password, salt, iterations, keylen, algo);
@@ -19684,8 +19680,8 @@ var require_reporter = __commonJS((exports) => {
19684
19680
  errors: state.errors
19685
19681
  };
19686
19682
  };
19687
- function ReporterError(path, msg) {
19688
- this.path = path;
19683
+ function ReporterError(path2, msg) {
19684
+ this.path = path2;
19689
19685
  this.rethrow(msg);
19690
19686
  }
19691
19687
  inherits(ReporterError, Error);
@@ -21395,7 +21391,7 @@ var require_parse_asn1 = __commonJS((exports, module) => {
21395
21391
  var aesid = require_aesid();
21396
21392
  var fixProc = require_fixProc();
21397
21393
  var ciphers = require_browserify_aes();
21398
- var pbkdf2Sync = require_pbkdf2().pbkdf2Sync;
21394
+ var compat = require_pbkdf2();
21399
21395
  var Buffer2 = require_safe_buffer().Buffer;
21400
21396
  function decrypt(data2, password) {
21401
21397
  var salt = data2.algorithm.decrypt.kde.kdeparams.salt;
@@ -21404,7 +21400,7 @@ var require_parse_asn1 = __commonJS((exports, module) => {
21404
21400
  var iv = data2.algorithm.decrypt.cipher.iv;
21405
21401
  var cipherText = data2.subjectPrivateKey;
21406
21402
  var keylen = parseInt(algo.split("-")[1], 10) / 8;
21407
- var key = pbkdf2Sync(password, salt, iters, keylen, "sha1");
21403
+ var key = compat.pbkdf2Sync(password, salt, iters, keylen, "sha1");
21408
21404
  var cipher = ciphers.createDecipheriv(algo, key, iv);
21409
21405
  var out = [];
21410
21406
  out.push(cipher.update(cipherText));
@@ -25882,7 +25878,7 @@ var getDefaultProjectName = () => {
25882
25878
  };
25883
25879
 
25884
25880
  // ../../node_modules/langsmith/dist/index.js
25885
- var __version__ = "0.3.69";
25881
+ var __version__ = "0.3.68";
25886
25882
 
25887
25883
  // ../../node_modules/langsmith/dist/utils/env.js
25888
25884
  var globalEnv;
@@ -41888,7 +41884,7 @@ function parseBooleanFromText2(value) {
41888
41884
  }
41889
41885
  return false;
41890
41886
  }
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");
41887
+ var uuidSchema = z2.string().uuid();
41892
41888
  function validateUuid(value) {
41893
41889
  const result = uuidSchema.safeParse(value);
41894
41890
  return result.success ? result.data : null;
@@ -42114,14 +42110,14 @@ var styleSchema = z3.object({
42114
42110
  chat: z3.array(z3.string()).optional(),
42115
42111
  post: z3.array(z3.string()).optional()
42116
42112
  }).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();
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();
42119
42115
  var characterSchema = z3.object({
42120
42116
  id: uuidSchema2.optional(),
42121
42117
  name: z3.string().min(1, "Character name is required"),
42122
42118
  username: z3.string().optional(),
42123
42119
  system: z3.string().optional(),
42124
- templates: z3.record(z3.string(), templateTypeSchema).optional(),
42120
+ templates: z3.record(templateTypeSchema).optional(),
42125
42121
  bio: z3.union([z3.string(), z3.array(z3.string())]),
42126
42122
  messageExamples: z3.array(z3.array(messageExampleSchema)).optional(),
42127
42123
  postExamples: z3.array(z3.string()).optional(),
@@ -42319,16 +42315,85 @@ var BufferUtils = {
42319
42315
  byteLength,
42320
42316
  randomBytes
42321
42317
  };
42322
- // src/utils/paths.ts
42323
- var pathJoin = (...parts) => {
42324
- if (typeof process !== "undefined" && process.platform) {
42318
+ // src/utils/server-health.ts
42319
+ async function waitForServerReady(options) {
42320
+ const {
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;
42325
42334
  try {
42326
- const path = __require("node:path");
42327
- return path.join(...parts);
42328
- } catch {}
42335
+ controller = new AbortController;
42336
+ timeoutId = setTimeout(() => {
42337
+ if (controller) {
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));
42329
42358
  }
42330
- return parts.filter((part) => part).join("/").replace(/\/+/g, "/").replace(/\/$/, "");
42331
- };
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
+ }
42393
+ }
42394
+ }
42395
+ // src/utils/paths.ts
42396
+ import path from "node:path";
42332
42397
 
42333
42398
  class ElizaPaths {
42334
42399
  cache = new Map;
@@ -42336,7 +42401,7 @@ class ElizaPaths {
42336
42401
  const cached = this.cache.get("dataDir");
42337
42402
  if (cached)
42338
42403
  return cached;
42339
- const dir = typeof process !== "undefined" && process.env?.ELIZA_DATA_DIR || (typeof process !== "undefined" && process.cwd ? pathJoin(process.cwd(), ".eliza") : ".eliza");
42404
+ const dir = process.env.ELIZA_DATA_DIR || path.join(process.cwd(), ".eliza");
42340
42405
  this.cache.set("dataDir", dir);
42341
42406
  return dir;
42342
42407
  }
@@ -42344,7 +42409,7 @@ class ElizaPaths {
42344
42409
  const cached = this.cache.get("databaseDir");
42345
42410
  if (cached)
42346
42411
  return cached;
42347
- const dir = typeof process !== "undefined" && process.env?.ELIZA_DATABASE_DIR || typeof process !== "undefined" && process.env?.PGLITE_DATA_DIR || pathJoin(this.getDataDir(), ".elizadb");
42412
+ const dir = process.env.ELIZA_DATABASE_DIR || process.env.PGLITE_DATA_DIR || path.join(this.getDataDir(), ".elizadb");
42348
42413
  this.cache.set("databaseDir", dir);
42349
42414
  return dir;
42350
42415
  }
@@ -42352,7 +42417,7 @@ class ElizaPaths {
42352
42417
  const cached = this.cache.get("charactersDir");
42353
42418
  if (cached)
42354
42419
  return cached;
42355
- const dir = typeof process !== "undefined" && process.env?.ELIZA_DATA_DIR_CHARACTERS || pathJoin(this.getDataDir(), "data", "characters");
42420
+ const dir = process.env.ELIZA_DATA_DIR_CHARACTERS || path.join(this.getDataDir(), "data", "characters");
42356
42421
  this.cache.set("charactersDir", dir);
42357
42422
  return dir;
42358
42423
  }
@@ -42360,7 +42425,7 @@ class ElizaPaths {
42360
42425
  const cached = this.cache.get("generatedDir");
42361
42426
  if (cached)
42362
42427
  return cached;
42363
- const dir = typeof process !== "undefined" && process.env?.ELIZA_DATA_DIR_GENERATED || pathJoin(this.getDataDir(), "data", "generated");
42428
+ const dir = process.env.ELIZA_DATA_DIR_GENERATED || path.join(this.getDataDir(), "data", "generated");
42364
42429
  this.cache.set("generatedDir", dir);
42365
42430
  return dir;
42366
42431
  }
@@ -42368,7 +42433,7 @@ class ElizaPaths {
42368
42433
  const cached = this.cache.get("uploadsAgentsDir");
42369
42434
  if (cached)
42370
42435
  return cached;
42371
- const dir = typeof process !== "undefined" && process.env?.ELIZA_DATA_DIR_UPLOADS_AGENTS || pathJoin(this.getDataDir(), "data", "uploads", "agents");
42436
+ const dir = process.env.ELIZA_DATA_DIR_UPLOADS_AGENTS || path.join(this.getDataDir(), "data", "uploads", "agents");
42372
42437
  this.cache.set("uploadsAgentsDir", dir);
42373
42438
  return dir;
42374
42439
  }
@@ -42376,7 +42441,7 @@ class ElizaPaths {
42376
42441
  const cached = this.cache.get("uploadsChannelsDir");
42377
42442
  if (cached)
42378
42443
  return cached;
42379
- const dir = typeof process !== "undefined" && process.env?.ELIZA_DATA_DIR_UPLOADS_CHANNELS || pathJoin(this.getDataDir(), "data", "uploads", "channels");
42444
+ const dir = process.env.ELIZA_DATA_DIR_UPLOADS_CHANNELS || path.join(this.getDataDir(), "data", "uploads", "channels");
42380
42445
  this.cache.set("uploadsChannelsDir", dir);
42381
42446
  return dir;
42382
42447
  }
@@ -42428,84 +42493,6 @@ function resetPaths() {
42428
42493
  }
42429
42494
  pathsInstance = null;
42430
42495
  }
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
- }
42509
42496
  // src/actions.ts
42510
42497
  var import_unique_names_generator2 = __toESM(require_dist4(), 1);
42511
42498
  var composeActionExamples = (actionsData, count) => {
@@ -45119,9 +45106,7 @@ class AgentRuntime {
45119
45106
  await this.adapter.init();
45120
45107
  }
45121
45108
  async close() {
45122
- if (this.adapter) {
45123
- await this.adapter.close();
45124
- }
45109
+ await this.adapter.close();
45125
45110
  }
45126
45111
  async getAgent(agentId) {
45127
45112
  return await this.adapter.getAgent(agentId);
@@ -45813,206 +45798,6 @@ function defineService(definition) {
45813
45798
  return createService(definition.serviceType).withDescription(definition.description).withStart(definition.start).withStop(definition.stop || (() => Promise.resolve())).build();
45814
45799
  }
45815
45800
 
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
- });
45826
- this.runtimes.set(runtime.agentId, runtime);
45827
- this.dispatchEvent(new CustomEvent("agent:added", {
45828
- detail: { agentId: runtime.agentId, character: agent.character }
45829
- }));
45830
- return runtime.agentId;
45831
- });
45832
- const ids = await Promise.all(promises);
45833
- this.dispatchEvent(new CustomEvent("agents:added", {
45834
- detail: { agentIds: ids, count: ids.length }
45835
- }));
45836
- return ids;
45837
- }
45838
- registerAgent(runtime) {
45839
- if (this.runtimes.has(runtime.agentId)) {
45840
- throw new Error(`Agent ${runtime.agentId} already registered`);
45841
- }
45842
- this.runtimes.set(runtime.agentId, runtime);
45843
- this.dispatchEvent(new CustomEvent("agent:registered", {
45844
- detail: { agentId: runtime.agentId, runtime }
45845
- }));
45846
- }
45847
- async updateAgent(agentId, updates) {
45848
- if (!this.editableMode) {
45849
- throw new Error("Editable mode not enabled");
45850
- }
45851
- const runtime = this.runtimes.get(agentId);
45852
- if (!runtime) {
45853
- throw new Error(`Agent ${agentId} not found`);
45854
- }
45855
- Object.assign(runtime.character, updates);
45856
- this.dispatchEvent(new CustomEvent("agent:updated", {
45857
- detail: { agentId, updates }
45858
- }));
45859
- }
45860
- async deleteAgents(agentIds) {
45861
- await this.stopAgents(agentIds);
45862
- for (const id of agentIds) {
45863
- this.runtimes.delete(id);
45864
- }
45865
- this.dispatchEvent(new CustomEvent("agents:deleted", {
45866
- detail: { agentIds, count: agentIds.length }
45867
- }));
45868
- }
45869
- async startAgents(agentIds) {
45870
- const ids = agentIds || Array.from(this.runtimes.keys());
45871
- await Promise.all(ids.map(async (id) => {
45872
- const runtime = this.runtimes.get(id);
45873
- if (!runtime) {
45874
- throw new Error(`Agent ${id} not found`);
45875
- }
45876
- await runtime.initialize();
45877
- this.dispatchEvent(new CustomEvent("agent:started", {
45878
- detail: { agentId: id }
45879
- }));
45880
- }));
45881
- this.dispatchEvent(new CustomEvent("agents:started", {
45882
- detail: { agentIds: ids, count: ids.length }
45883
- }));
45884
- }
45885
- async stopAgents(agentIds) {
45886
- const ids = agentIds || Array.from(this.runtimes.keys());
45887
- await Promise.all(ids.map(async (id) => {
45888
- const runtime = this.runtimes.get(id);
45889
- if (runtime) {
45890
- await runtime.stop();
45891
- }
45892
- }));
45893
- this.dispatchEvent(new CustomEvent("agents:stopped", {
45894
- detail: { agentIds: ids, count: ids.length }
45895
- }));
45896
- }
45897
- getAgent(id) {
45898
- return this.runtimes.get(id);
45899
- }
45900
- getAgents() {
45901
- return Array.from(this.runtimes.values());
45902
- }
45903
- getAgentsByIds(ids) {
45904
- return ids.map((id) => this.runtimes.get(id)).filter((runtime) => runtime !== undefined);
45905
- }
45906
- getAgentsByNames(names3) {
45907
- const nameSet = new Set(names3.map((n) => n.toLowerCase()));
45908
- return this.getAgents().filter((runtime) => nameSet.has(runtime.character.name.toLowerCase()));
45909
- }
45910
- getAgentById(id) {
45911
- return this.getAgent(id);
45912
- }
45913
- getAgentByName(name) {
45914
- const lowercaseName = name.toLowerCase();
45915
- return this.getAgents().find((runtime) => runtime.character.name.toLowerCase() === lowercaseName);
45916
- }
45917
- getAgentByCharacterName(name) {
45918
- return this.getAgentByName(name);
45919
- }
45920
- getAgentByCharacterId(characterId) {
45921
- return this.getAgents().find((runtime) => runtime.character.id === characterId);
45922
- }
45923
- async sendMessage(agentId, message, options) {
45924
- const runtime = this.runtimes.get(agentId);
45925
- if (!runtime) {
45926
- throw new Error(`Agent ${agentId} not found`);
45927
- }
45928
- const memory = typeof message === "string" ? {
45929
- id: v4_default(),
45930
- entityId: options?.userId || "system",
45931
- agentId,
45932
- roomId: options?.roomId || agentId,
45933
- content: { text: message },
45934
- createdAt: Date.now(),
45935
- metadata: options?.metadata
45936
- } : message;
45937
- const responses = [];
45938
- await runtime.processActions(memory, responses);
45939
- this.dispatchEvent(new CustomEvent("message:sent", {
45940
- detail: { agentId, message: memory, responses }
45941
- }));
45942
- return responses;
45943
- }
45944
- async sendMessages(messages) {
45945
- const results = await Promise.all(messages.map(async ({ agentId, message, options }) => {
45946
- try {
45947
- const responses = await this.sendMessage(agentId, message, options);
45948
- return { agentId, responses };
45949
- } catch (error) {
45950
- return {
45951
- agentId,
45952
- responses: [],
45953
- error: error instanceof Error ? error : new Error(String(error))
45954
- };
45955
- }
45956
- }));
45957
- this.dispatchEvent(new CustomEvent("messages:sent", {
45958
- detail: { results, count: messages.length }
45959
- }));
45960
- return results;
45961
- }
45962
- async validateApiKeys(agents) {
45963
- const results = new Map;
45964
- const ids = agents || Array.from(this.runtimes.keys());
45965
- for (const id of ids) {
45966
- const runtime = this.runtimes.get(id);
45967
- if (runtime) {
45968
- const hasKeys = !!(runtime.getSetting("OPENAI_API_KEY") || runtime.getSetting("ANTHROPIC_API_KEY"));
45969
- results.set(id, hasKeys);
45970
- }
45971
- }
45972
- return results;
45973
- }
45974
- async healthCheck(agents) {
45975
- const results = new Map;
45976
- const ids = agents || Array.from(this.runtimes.keys());
45977
- for (const id of ids) {
45978
- const runtime = this.runtimes.get(id);
45979
- const status = {
45980
- alive: !!runtime,
45981
- responsive: true
45982
- };
45983
- if (typeof process !== "undefined") {
45984
- status.memoryUsage = process.memoryUsage().heapUsed;
45985
- status.uptime = process.uptime();
45986
- }
45987
- results.set(id, status);
45988
- }
45989
- return results;
45990
- }
45991
- getRuntimeAccessor() {
45992
- return {
45993
- getAgent: (id) => this.getAgent(id),
45994
- getAgents: () => this.getAgents(),
45995
- getState: (agentId) => {
45996
- const agent = this.getAgent(agentId);
45997
- if (!agent)
45998
- return;
45999
- const agentRuntime = agent;
46000
- if (agentRuntime.stateCache && agentRuntime.stateCache.size > 0) {
46001
- const states = Array.from(agentRuntime.stateCache.values());
46002
- return states[states.length - 1];
46003
- }
46004
- return;
46005
- }
46006
- };
46007
- }
46008
- enableEditableMode() {
46009
- this.editableMode = true;
46010
- this.dispatchEvent(new CustomEvent("mode:editable", {
46011
- detail: { editable: true }
46012
- }));
46013
- }
46014
- }
46015
-
46016
45801
  // src/entities.ts
46017
45802
  var entityResolutionTemplate = `# Task: Resolve Entity Name
46018
45803
  Message Sender: {{senderName}} (ID: {{senderId}})
@@ -46377,7 +46162,6 @@ export {
46377
46162
  IBrowserService,
46378
46163
  EventType,
46379
46164
  Environment,
46380
- ElizaOS,
46381
46165
  DatabaseAdapter,
46382
46166
  ContentType,
46383
46167
  ChannelType,
@@ -46388,5 +46172,5 @@ export {
46388
46172
  AgentRuntime
46389
46173
  };
46390
46174
 
46391
- //# debugId=4FA07E08EA54221C64756E2164756E21
46175
+ //# debugId=919E5D09308269D664756E2164756E21
46392
46176
  //# sourceMappingURL=index.node.js.map