@elizaos/cli 1.2.4 → 1.2.7

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.
Files changed (82) hide show
  1. package/dist/bun-exec-KJOLGZOL.js +21 -0
  2. package/dist/{chunk-2XI6N7KN.js → chunk-2ZF5OAMV.js} +322 -69
  3. package/dist/chunk-3YTIOEFK.js +202 -0
  4. package/dist/chunk-AQ6OMR2A.js +14 -0
  5. package/dist/{chunk-JZG5QBNT.js → chunk-E54G6FI7.js} +32 -6
  6. package/dist/{chunk-PSSTO76B.js → chunk-KKAK7OQA.js} +100 -104
  7. package/dist/chunk-Y5IA2UZ2.js +154 -0
  8. package/dist/commands/agent/actions/index.js +4 -3
  9. package/dist/commands/agent/index.js +4 -3
  10. package/dist/commands/create/actions/index.d.ts +6 -2
  11. package/dist/commands/create/actions/index.js +8 -7
  12. package/dist/commands/create/index.js +6 -6
  13. package/dist/commands/shared/index.js +1 -1
  14. package/dist/index.js +323 -258
  15. package/dist/{plugin-creator-5CER524N.js → plugin-creator-Y2NWASXI.js} +16 -15
  16. package/dist/{registry-SN5V2VXR.js → registry-K2OCCRXO.js} +4 -3
  17. package/dist/templates/plugin-quick-starter/README.md +214 -0
  18. package/dist/templates/plugin-quick-starter/bunfig.toml +10 -0
  19. package/dist/templates/plugin-quick-starter/package.json +76 -0
  20. package/dist/templates/plugin-quick-starter/scripts/install-test-deps.js +53 -0
  21. package/dist/templates/plugin-quick-starter/src/__tests__/plugin.test.ts +209 -0
  22. package/dist/templates/plugin-quick-starter/src/__tests__/test-utils.ts +162 -0
  23. package/dist/templates/plugin-quick-starter/src/index.ts +4 -0
  24. package/dist/templates/plugin-quick-starter/src/plugin.ts +272 -0
  25. package/dist/templates/plugin-quick-starter/tsconfig.build.json +11 -0
  26. package/dist/templates/plugin-quick-starter/tsconfig.json +28 -0
  27. package/dist/templates/plugin-quick-starter/tsup.config.ts +20 -0
  28. package/dist/templates/plugin-starter/package.json +2 -2
  29. package/dist/templates/plugin-starter/scripts/install-test-deps.js +7 -3
  30. package/dist/templates/plugin-starter/src/__tests__/build-order.test.ts +51 -0
  31. package/dist/templates/plugin-starter/src/__tests__/vite-config-utils.ts +33 -0
  32. package/dist/templates/plugin-starter/src/plugin.ts +13 -15
  33. package/dist/templates/plugin-starter/tsup.config.ts +1 -1
  34. package/dist/templates/plugin-starter/vite.config.ts +1 -1
  35. package/dist/templates/project-starter/package.json +4 -4
  36. package/dist/templates/project-starter/scripts/install-test-deps.js +7 -3
  37. package/dist/templates/project-starter/src/__tests__/build-order.test.ts +59 -0
  38. package/dist/templates/project-starter/src/__tests__/character-plugin-ordering.test.ts +11 -110
  39. package/dist/templates/project-starter/src/__tests__/vite-config-utils.ts +33 -0
  40. package/dist/templates/project-starter/src/character.ts +14 -17
  41. package/dist/templates/project-starter/tsup.config.ts +1 -1
  42. package/dist/templates/project-tee-starter/package.json +3 -3
  43. package/dist/templates/project-tee-starter/src/character.ts +3 -0
  44. package/dist/{utils-DTW3XU6O.js → utils-QSRUVLAT.js} +4 -3
  45. package/package.json +6 -6
  46. package/templates/plugin-quick-starter/README.md +214 -0
  47. package/templates/plugin-quick-starter/bunfig.toml +10 -0
  48. package/templates/plugin-quick-starter/package.json +76 -0
  49. package/templates/plugin-quick-starter/scripts/install-test-deps.js +53 -0
  50. package/templates/plugin-quick-starter/src/__tests__/plugin.test.ts +209 -0
  51. package/templates/plugin-quick-starter/src/__tests__/test-utils.ts +162 -0
  52. package/templates/plugin-quick-starter/src/index.ts +4 -0
  53. package/templates/plugin-quick-starter/src/plugin.ts +272 -0
  54. package/templates/plugin-quick-starter/tsconfig.build.json +11 -0
  55. package/templates/plugin-quick-starter/tsconfig.json +28 -0
  56. package/templates/plugin-quick-starter/tsup.config.ts +20 -0
  57. package/templates/plugin-starter/package.json +2 -2
  58. package/templates/plugin-starter/scripts/install-test-deps.js +7 -3
  59. package/templates/plugin-starter/src/__tests__/build-order.test.ts +51 -0
  60. package/templates/plugin-starter/src/__tests__/vite-config-utils.ts +33 -0
  61. package/templates/plugin-starter/src/plugin.ts +13 -15
  62. package/templates/plugin-starter/tsup.config.ts +1 -1
  63. package/templates/plugin-starter/vite.config.ts +1 -1
  64. package/templates/project-starter/package.json +4 -4
  65. package/templates/project-starter/scripts/install-test-deps.js +7 -3
  66. package/templates/project-starter/src/__tests__/build-order.test.ts +59 -0
  67. package/templates/project-starter/src/__tests__/character-plugin-ordering.test.ts +11 -110
  68. package/templates/project-starter/src/__tests__/vite-config-utils.ts +33 -0
  69. package/templates/project-starter/src/character.ts +14 -17
  70. package/templates/project-starter/tsup.config.ts +1 -1
  71. package/templates/project-tee-starter/package.json +3 -3
  72. package/templates/project-tee-starter/src/character.ts +3 -0
  73. package/dist/chunk-5DYKNYEY.js +0 -2262
  74. package/dist/chunk-XB5JBFO6.js +0 -41
  75. package/dist/chunk-ZWDXDKSA.js +0 -281
  76. package/dist/setup-UQOWDHFN.js +0 -20
  77. package/dist/templates/plugin-starter/dist/index.js +0 -391
  78. package/dist/templates/plugin-starter/dist/index.js.map +0 -1
  79. package/templates/plugin-starter/dist/.vite/manifest.json +0 -11
  80. package/templates/plugin-starter/dist/index.d.ts +0 -14
  81. package/templates/plugin-starter/dist/index.js +0 -391
  82. package/templates/plugin-starter/dist/index.js.map +0 -1
package/dist/index.js CHANGED
@@ -5,11 +5,10 @@ const require = createRequire(import.meta.url);
5
5
 
6
6
  import {
7
7
  create
8
- } from "./chunk-JZG5QBNT.js";
8
+ } from "./chunk-E54G6FI7.js";
9
9
  import {
10
10
  getElizaCharacter
11
- } from "./chunk-2XI6N7KN.js";
12
- import "./chunk-ZWDXDKSA.js";
11
+ } from "./chunk-2ZF5OAMV.js";
13
12
  import {
14
13
  TestRunner,
15
14
  UserEnvironment,
@@ -46,29 +45,19 @@ import {
46
45
  testPublishToGitHub,
47
46
  testPublishToNpm,
48
47
  validateDataDir
49
- } from "./chunk-PSSTO76B.js";
48
+ } from "./chunk-KKAK7OQA.js";
50
49
  import {
51
- bunExec,
52
- bunExecInherit,
53
- bunExecSimple,
54
50
  configureEmojis,
55
51
  emoji,
56
- require_execa,
57
52
  runBunCommand
58
- } from "./chunk-5DYKNYEY.js";
53
+ } from "./chunk-Y5IA2UZ2.js";
59
54
  import "./chunk-F24MS2YR.js";
60
55
  import {
61
- __toESM
62
- } from "./chunk-XB5JBFO6.js";
63
-
64
- // src/utils/port-validation.ts
65
- function validatePort(value) {
66
- const port = Number.parseInt(value, 10);
67
- if (Number.isNaN(port) || port <= 0 || port > 65535) {
68
- throw new Error("Port must be a number between 1 and 65535");
69
- }
70
- return port;
71
- }
56
+ bunExec,
57
+ bunExecInherit,
58
+ bunExecSimple
59
+ } from "./chunk-3YTIOEFK.js";
60
+ import "./chunk-AQ6OMR2A.js";
72
61
 
73
62
  // src/commands/dev/index.ts
74
63
  import { Command, Option } from "commander";
@@ -266,6 +255,7 @@ var DevServerManager = class {
266
255
  process = null;
267
256
  /**
268
257
  * Stops the currently running server process
258
+ * @returns true if a server was stopped, false if no server was running
269
259
  */
270
260
  async stop() {
271
261
  if (this.process) {
@@ -277,7 +267,9 @@ var DevServerManager = class {
277
267
  }
278
268
  this.process = null;
279
269
  await new Promise((resolve2) => setTimeout(resolve2, 500));
270
+ return true;
280
271
  }
272
+ return false;
281
273
  }
282
274
  /**
283
275
  * Starts the server process with the given arguments
@@ -326,8 +318,13 @@ function getServerManager() {
326
318
  }
327
319
  return serverInstance;
328
320
  }
321
+ async function stopServer() {
322
+ const server = getServerManager();
323
+ return await server.stop();
324
+ }
329
325
 
330
326
  // src/commands/dev/actions/dev-server.ts
327
+ import { logger } from "@elizaos/core";
331
328
  async function startDevMode(options) {
332
329
  const cwd = process.cwd();
333
330
  const context = createDevContext(cwd);
@@ -348,9 +345,28 @@ async function startDevMode(options) {
348
345
  );
349
346
  }
350
347
  const cliArgs = [];
351
- if (options.port) {
352
- cliArgs.push("--port", options.port.toString());
348
+ let desiredPort;
349
+ if (options.port !== void 0) {
350
+ desiredPort = options.port;
351
+ } else {
352
+ const serverPort = process.env.SERVER_PORT;
353
+ const parsedPort = serverPort ? Number.parseInt(serverPort, 10) : NaN;
354
+ desiredPort = Number.isNaN(parsedPort) ? 3e3 : parsedPort;
355
+ }
356
+ let availablePort;
357
+ try {
358
+ availablePort = await findNextAvailablePort(desiredPort);
359
+ if (availablePort !== desiredPort) {
360
+ logger.warn(`Port ${desiredPort} is in use, using port ${availablePort} instead`);
361
+ }
362
+ } catch (error) {
363
+ logger.error(
364
+ `Failed to find available port starting from ${desiredPort}: ${error instanceof Error ? error.message : String(error)}`
365
+ );
366
+ logger.error("Please specify a different port using --port option");
367
+ throw new Error(`No available ports found starting from ${desiredPort}`);
353
368
  }
369
+ cliArgs.push("--port", availablePort.toString());
354
370
  if (options.configure) {
355
371
  cliArgs.push("--configure");
356
372
  }
@@ -397,7 +413,13 @@ async function startDevMode(options) {
397
413
  var dev = new Command().name("dev").description(
398
414
  "Start the project or plugin in development mode with auto-rebuild, detailed logging, and file change detection"
399
415
  ).option("-c, --configure", "Reconfigure services and AI models (skips using saved configuration)").option("--character [paths...]", "Character file(s) to use - accepts paths or URLs").option("-b, --build", "Build the project before starting").addOption(
400
- new Option("-p, --port <port>", "Port to listen on (default: 3000)").argParser(validatePort)
416
+ new Option("-p, --port <port>", "Port to listen on (default: 3000)").argParser((value) => {
417
+ const port = Number.parseInt(value, 10);
418
+ if (Number.isNaN(port) || port < 0 || port > 65535) {
419
+ throw new Error("Port must be a number between 0 and 65535");
420
+ }
421
+ return port;
422
+ })
401
423
  ).action(async (options) => {
402
424
  try {
403
425
  await startDevMode(options);
@@ -940,7 +962,7 @@ env.action(() => {
940
962
  import { Command as Command3 } from "commander";
941
963
 
942
964
  // src/commands/plugins/actions/install.ts
943
- import { logger as logger3 } from "@elizaos/core";
965
+ import { logger as logger4 } from "@elizaos/core";
944
966
 
945
967
  // src/commands/plugins/utils/naming.ts
946
968
  var findPluginPackageName = (pluginInput, allDependencies) => {
@@ -982,7 +1004,7 @@ var extractPackageName = (pluginInput) => {
982
1004
  };
983
1005
 
984
1006
  // src/commands/plugins/utils/env-vars.ts
985
- import { logger } from "@elizaos/core";
1007
+ import { logger as logger2 } from "@elizaos/core";
986
1008
  import { existsSync as existsSync8, readFileSync, readdirSync as readdirSync2 } from "fs";
987
1009
  import path7 from "path";
988
1010
  import * as clack4 from "@clack/prompts";
@@ -1017,7 +1039,7 @@ var extractPluginEnvRequirements = async (packageName, cwd) => {
1017
1039
  for (const possiblePath of possiblePaths) {
1018
1040
  if (existsSync8(possiblePath)) {
1019
1041
  packageJsonPath = possiblePath;
1020
- logger.debug(`Found plugin package.json at: ${packageJsonPath}`);
1042
+ logger2.debug(`Found plugin package.json at: ${packageJsonPath}`);
1021
1043
  break;
1022
1044
  }
1023
1045
  }
@@ -1030,7 +1052,7 @@ var extractPluginEnvRequirements = async (packageName, cwd) => {
1030
1052
  const pkgJsonPath = path7.join(nodeModulesPath, pkg, "package.json");
1031
1053
  if (existsSync8(pkgJsonPath)) {
1032
1054
  packageJsonPath = pkgJsonPath;
1033
- logger.debug(`Found matching plugin package.json at: ${packageJsonPath}`);
1055
+ logger2.debug(`Found matching plugin package.json at: ${packageJsonPath}`);
1034
1056
  break;
1035
1057
  }
1036
1058
  }
@@ -1038,23 +1060,23 @@ var extractPluginEnvRequirements = async (packageName, cwd) => {
1038
1060
  }
1039
1061
  }
1040
1062
  if (!packageJsonPath) {
1041
- logger.debug(`Plugin package.json not found for: ${packageName}`);
1042
- logger.debug(`Searched paths: ${possiblePaths.join(", ")}`);
1063
+ logger2.debug(`Plugin package.json not found for: ${packageName}`);
1064
+ logger2.debug(`Searched paths: ${possiblePaths.join(", ")}`);
1043
1065
  return {};
1044
1066
  }
1045
1067
  const packageJsonContent = readFileSync(packageJsonPath, "utf-8");
1046
1068
  const packageJson = JSON.parse(packageJsonContent);
1047
1069
  const agentConfig = packageJson.agentConfig;
1048
1070
  if (!agentConfig || !agentConfig.pluginParameters) {
1049
- logger.debug(`No agentConfig.pluginParameters found in ${packageName} at ${packageJsonPath}`);
1071
+ logger2.debug(`No agentConfig.pluginParameters found in ${packageName} at ${packageJsonPath}`);
1050
1072
  return {};
1051
1073
  }
1052
- logger.debug(
1074
+ logger2.debug(
1053
1075
  `Found environment variables for ${packageName}: ${Object.keys(agentConfig.pluginParameters).join(", ")}`
1054
1076
  );
1055
1077
  return agentConfig.pluginParameters;
1056
1078
  } catch (error) {
1057
- logger.debug(
1079
+ logger2.debug(
1058
1080
  `Error reading plugin package.json for ${packageName}: ${error instanceof Error ? error.message : String(error)}`
1059
1081
  );
1060
1082
  return {};
@@ -1281,10 +1303,10 @@ var promptForPluginEnvVars = async (packageName, cwd) => {
1281
1303
  }
1282
1304
  }
1283
1305
  if (packageFound) {
1284
- logger.debug(`Package ${packageName} found but has no environment variables defined`);
1306
+ logger2.debug(`Package ${packageName} found but has no environment variables defined`);
1285
1307
  clack4.log.success(`No environment variables required for ${packageName}`);
1286
1308
  } else {
1287
- logger.debug(`Package ${packageName} not found in node_modules`);
1309
+ logger2.debug(`Package ${packageName} not found in node_modules`);
1288
1310
  clack4.log.warn(
1289
1311
  `Could not find ${packageName} in node_modules. Environment variables may need to be configured manually.`
1290
1312
  );
@@ -1425,7 +1447,7 @@ Restart your application after adding the variables.`
1425
1447
  };
1426
1448
 
1427
1449
  // src/commands/plugins/utils/directory.ts
1428
- import { logger as logger2 } from "@elizaos/core";
1450
+ import { logger as logger3 } from "@elizaos/core";
1429
1451
  import { readFileSync as readFileSync2 } from "fs";
1430
1452
  import path8 from "path";
1431
1453
  var getDependenciesFromDirectory = (cwd) => {
@@ -1442,9 +1464,9 @@ var getDependenciesFromDirectory = (cwd) => {
1442
1464
  return { ...dependencies, ...devDependencies };
1443
1465
  } catch (error) {
1444
1466
  if (error instanceof SyntaxError) {
1445
- logger2.warn(`Could not parse package.json: ${error.message}`);
1467
+ logger3.warn(`Could not parse package.json: ${error.message}`);
1446
1468
  } else {
1447
- logger2.warn(
1469
+ logger3.warn(
1448
1470
  `Error reading package.json: ${error instanceof Error ? error.message : String(error)}`
1449
1471
  );
1450
1472
  }
@@ -1479,7 +1501,7 @@ async function installPluginFromGitHub(plugin, cwd, opts) {
1479
1501
  const pluginNameForPostInstall = repo;
1480
1502
  const success = await installPlugin(githubSpecifier, cwd, void 0, opts.skipVerification);
1481
1503
  if (success) {
1482
- logger3.info(`Successfully installed ${pluginNameForPostInstall} from ${githubSpecifier}.`);
1504
+ logger4.info(`Successfully installed ${pluginNameForPostInstall} from ${githubSpecifier}.`);
1483
1505
  const packageName = extractPackageName(plugin);
1484
1506
  if (!opts.skipEnvPrompt) {
1485
1507
  await new Promise((resolve2) => setTimeout(resolve2, 500));
@@ -1488,7 +1510,7 @@ async function installPluginFromGitHub(plugin, cwd, opts) {
1488
1510
  try {
1489
1511
  await promptForPluginEnvVars(packageName, cwd);
1490
1512
  } catch (error) {
1491
- logger3.warn(
1513
+ logger4.warn(
1492
1514
  `Warning: Could not prompt for environment variables: ${error instanceof Error ? error.message : String(error)}`
1493
1515
  );
1494
1516
  }
@@ -1499,14 +1521,14 @@ async function installPluginFromGitHub(plugin, cwd, opts) {
1499
1521
  showInstallationSuccess(packageName);
1500
1522
  process.exit(0);
1501
1523
  } else {
1502
- logger3.error(`Failed to install plugin from ${githubSpecifier}.`);
1524
+ logger4.error(`Failed to install plugin from ${githubSpecifier}.`);
1503
1525
  process.exit(1);
1504
1526
  }
1505
1527
  }
1506
1528
  async function installPluginFromRegistry(plugin, cwd, opts) {
1507
1529
  const cachedRegistry = await fetchPluginRegistry();
1508
1530
  if (!cachedRegistry || !cachedRegistry.registry) {
1509
- logger3.error('Plugin registry cache not found. Please run "elizaos plugins update" first.');
1531
+ logger4.error('Plugin registry cache not found. Please run "elizaos plugins update" first.');
1510
1532
  process.exit(1);
1511
1533
  }
1512
1534
  const possibleNames = normalizePluginName(plugin);
@@ -1529,7 +1551,7 @@ async function installPluginFromRegistry(plugin, cwd, opts) {
1529
1551
  try {
1530
1552
  await promptForPluginEnvVars(actualPackageName, cwd);
1531
1553
  } catch (error) {
1532
- logger3.warn(
1554
+ logger4.warn(
1533
1555
  `Warning: Could not prompt for environment variables: ${error instanceof Error ? error.message : String(error)}`
1534
1556
  );
1535
1557
  }
@@ -1545,8 +1567,8 @@ async function installPluginFromRegistry(plugin, cwd, opts) {
1545
1567
  }
1546
1568
  async function addPlugin(pluginArg, opts) {
1547
1569
  if (!pluginArg || !pluginArg.trim()) {
1548
- logger3.error("Plugin name cannot be empty or whitespace-only.");
1549
- logger3.info(
1570
+ logger4.error("Plugin name cannot be empty or whitespace-only.");
1571
+ logger4.info(
1550
1572
  'Please provide a valid plugin name (e.g., "openai", "plugin-anthropic", "@elizaos/plugin-sql")'
1551
1573
  );
1552
1574
  process.exit(1);
@@ -1554,14 +1576,14 @@ async function addPlugin(pluginArg, opts) {
1554
1576
  const cwd = process.cwd();
1555
1577
  const directoryInfo = detectDirectoryType(cwd);
1556
1578
  if (!directoryInfo || !directoryInfo.hasPackageJson) {
1557
- logger3.error(
1579
+ logger4.error(
1558
1580
  `Command must be run inside an ElizaOS project directory. This directory is: ${directoryInfo?.type || "invalid or inaccessible"}`
1559
1581
  );
1560
1582
  process.exit(1);
1561
1583
  }
1562
1584
  const allDependencies = getDependenciesFromDirectory(cwd);
1563
1585
  if (!allDependencies) {
1564
- logger3.error("Could not read dependencies from package.json");
1586
+ logger4.error("Could not read dependencies from package.json");
1565
1587
  process.exit(1);
1566
1588
  }
1567
1589
  let plugin = pluginArg;
@@ -1576,7 +1598,7 @@ async function addPlugin(pluginArg, opts) {
1576
1598
  }
1577
1599
  const installedPluginName = findPluginPackageName(plugin, allDependencies);
1578
1600
  if (installedPluginName) {
1579
- logger3.info(`Plugin "${installedPluginName}" is already added to this project.`);
1601
+ logger4.info(`Plugin "${installedPluginName}" is already added to this project.`);
1580
1602
  process.exit(0);
1581
1603
  }
1582
1604
  const githubRegex = /^(?:github:)?([a-zA-Z0-9_-]+)\/([a-zA-Z0-9_.-]+)(?:#([a-zA-Z0-9_.-]+))?$/;
@@ -1588,7 +1610,7 @@ async function addPlugin(pluginArg, opts) {
1588
1610
  }
1589
1611
 
1590
1612
  // src/commands/plugins/actions/remove.ts
1591
- import { logger as logger4 } from "@elizaos/core";
1613
+ import { logger as logger5 } from "@elizaos/core";
1592
1614
  import { existsSync as existsSync9, rmSync } from "fs";
1593
1615
  import path9 from "path";
1594
1616
  async function removePlugin(plugin) {
@@ -1609,7 +1631,7 @@ async function removePlugin(plugin) {
1609
1631
  }
1610
1632
  const packageNameToRemove = findPluginPackageName(plugin, allDependencies);
1611
1633
  if (!packageNameToRemove) {
1612
- logger4.warn(`Plugin matching "${plugin}" not found in project dependencies.`);
1634
+ logger5.warn(`Plugin matching "${plugin}" not found in project dependencies.`);
1613
1635
  console.info("\nCheck installed plugins using: elizaos plugins installed-plugins");
1614
1636
  process.exit(0);
1615
1637
  }
@@ -1619,11 +1641,11 @@ async function removePlugin(plugin) {
1619
1641
  cwd
1620
1642
  });
1621
1643
  } catch (execError) {
1622
- logger4.error(
1644
+ logger5.error(
1623
1645
  `Failed to run 'bun remove ${packageNameToRemove}': ${execError instanceof Error ? execError.message : String(execError)}`
1624
1646
  );
1625
1647
  if (execError && typeof execError === "object" && "stderr" in execError && typeof execError.stderr === "string" && execError.stderr.includes("not found")) {
1626
- logger4.info(
1648
+ logger5.info(
1627
1649
  `'bun remove' indicated package was not found. Continuing with directory removal attempt.`
1628
1650
  );
1629
1651
  } else {
@@ -1643,7 +1665,7 @@ async function removePlugin(plugin) {
1643
1665
  try {
1644
1666
  rmSync(pluginDir, { recursive: true, force: true });
1645
1667
  } catch (rmError) {
1646
- logger4.error(
1668
+ logger5.error(
1647
1669
  `Failed to remove directory ${pluginDir}: ${rmError instanceof Error ? rmError.message : String(rmError)}`
1648
1670
  );
1649
1671
  }
@@ -1653,7 +1675,7 @@ async function removePlugin(plugin) {
1653
1675
  try {
1654
1676
  rmSync(nonPrefixedDir, { recursive: true, force: true });
1655
1677
  } catch (rmError) {
1656
- logger4.error(
1678
+ logger5.error(
1657
1679
  `Failed to remove directory ${nonPrefixedDir}: ${rmError instanceof Error ? rmError.message : String(rmError)}`
1658
1680
  );
1659
1681
  }
@@ -1663,11 +1685,11 @@ async function removePlugin(plugin) {
1663
1685
  }
1664
1686
 
1665
1687
  // src/commands/plugins/actions/list.ts
1666
- import { logger as logger5 } from "@elizaos/core";
1688
+ import { logger as logger6 } from "@elizaos/core";
1667
1689
  async function listAvailablePlugins(opts) {
1668
1690
  const cachedRegistry = await fetchPluginRegistry();
1669
1691
  if (!cachedRegistry || !cachedRegistry.registry || Object.keys(cachedRegistry.registry).length === 0) {
1670
- logger5.info("Plugin cache is empty or not found.");
1692
+ logger6.info("Plugin cache is empty or not found.");
1671
1693
  console.log('\nPlease run "elizaos plugins update" to fetch the latest plugin registry.');
1672
1694
  return;
1673
1695
  }
@@ -1745,7 +1767,7 @@ async function listInstalledPlugins() {
1745
1767
  }
1746
1768
 
1747
1769
  // src/commands/plugins/actions/upgrade.ts
1748
- import { logger as logger8 } from "@elizaos/core";
1770
+ import { logger as logger9 } from "@elizaos/core";
1749
1771
  import path11 from "path";
1750
1772
  import { existsSync as existsSync11 } from "fs";
1751
1773
  import { fileURLToPath as fileURLToPath2 } from "url";
@@ -1759,7 +1781,7 @@ import { EventEmitter } from "events";
1759
1781
  import { existsSync as existsSync10, readFileSync as readFileSync3 } from "fs";
1760
1782
  import path10 from "path";
1761
1783
  import { fileURLToPath } from "url";
1762
- import { logger as logger6 } from "@elizaos/core";
1784
+ import { logger as logger7 } from "@elizaos/core";
1763
1785
  var MigrationGuideLoader = class {
1764
1786
  guides = [];
1765
1787
  guidesDir;
@@ -1909,7 +1931,7 @@ var MigrationGuideLoader = class {
1909
1931
  }
1910
1932
  ];
1911
1933
  if (!this.guidesDir || !existsSync10(this.guidesDir)) {
1912
- logger6.info("Using embedded migration guidance (external CLI mode)");
1934
+ logger7.info("Using embedded migration guidance (external CLI mode)");
1913
1935
  this.createEmbeddedGuides(guideConfigs);
1914
1936
  return;
1915
1937
  }
@@ -1926,13 +1948,13 @@ var MigrationGuideLoader = class {
1926
1948
  keywords: config2.keywords
1927
1949
  });
1928
1950
  } catch (error) {
1929
- logger6.warn(`Failed to load migration guide: ${config2.name}`, error);
1951
+ logger7.warn(`Failed to load migration guide: ${config2.name}`, error);
1930
1952
  }
1931
1953
  } else {
1932
- logger6.warn(`Migration guide not found: ${guidePath}`);
1954
+ logger7.warn(`Migration guide not found: ${guidePath}`);
1933
1955
  }
1934
1956
  }
1935
- logger6.info(`Loaded ${this.guides.length} migration guides from ${this.guidesDir}`);
1957
+ logger7.info(`Loaded ${this.guides.length} migration guides from ${this.guidesDir}`);
1936
1958
  }
1937
1959
  createEmbeddedGuides(guideConfigs) {
1938
1960
  const embeddedGuides = {
@@ -2180,7 +2202,7 @@ function createMigrationGuideLoader(projectRoot) {
2180
2202
  }
2181
2203
 
2182
2204
  // src/utils/upgrade/simple-migration-agent.ts
2183
- import { logger as logger7 } from "@elizaos/core";
2205
+ import { logger as logger8 } from "@elizaos/core";
2184
2206
  var SimpleMigrationAgent = class extends EventEmitter {
2185
2207
  repoPath;
2186
2208
  abortController;
@@ -2203,10 +2225,10 @@ var SimpleMigrationAgent = class extends EventEmitter {
2203
2225
  try {
2204
2226
  this.guideLoader = createMigrationGuideLoader();
2205
2227
  if (this.verbose) {
2206
- logger7.info("Migration guide loader initialized successfully");
2228
+ logger8.info("Migration guide loader initialized successfully");
2207
2229
  }
2208
2230
  } catch (error) {
2209
- logger7.warn("Failed to initialize migration guide loader", error);
2231
+ logger8.warn("Failed to initialize migration guide loader", error);
2210
2232
  throw new Error("Cannot initialize migration system without guide access");
2211
2233
  }
2212
2234
  }
@@ -2751,13 +2773,13 @@ async function upgradePlugin(pluginPath, opts) {
2751
2773
  process.env.ANTHROPIC_API_KEY = opts.apiKey;
2752
2774
  }
2753
2775
  if (!process.env.ANTHROPIC_API_KEY) {
2754
- logger8.error("ANTHROPIC_API_KEY is required for plugin upgrade.");
2776
+ logger9.error("ANTHROPIC_API_KEY is required for plugin upgrade.");
2755
2777
  console.log("\nPlease set ANTHROPIC_API_KEY environment variable or use --api-key option.");
2756
2778
  console.log("Get your API key from: https://console.anthropic.com/");
2757
2779
  process.exit(1);
2758
2780
  }
2759
2781
  if (!process.env.ANTHROPIC_API_KEY.startsWith("sk-ant-")) {
2760
- logger8.error("Invalid ANTHROPIC_API_KEY format.");
2782
+ logger9.error("Invalid ANTHROPIC_API_KEY format.");
2761
2783
  console.log('\nThe API key should start with "sk-ant-"');
2762
2784
  console.log("Get your API key from: https://console.anthropic.com/");
2763
2785
  process.exit(1);
@@ -2928,17 +2950,17 @@ Error: ${error instanceof Error ? error.message : String(error)}`));
2928
2950
  }
2929
2951
 
2930
2952
  // src/commands/plugins/actions/generate.ts
2931
- import { logger as logger9 } from "@elizaos/core";
2953
+ import { logger as logger10 } from "@elizaos/core";
2932
2954
  import { readFileSync as readFileSync4 } from "fs";
2933
2955
  import path12 from "path";
2934
2956
  async function generatePlugin(opts) {
2935
2957
  try {
2936
- const { PluginCreator } = await import("./plugin-creator-5CER524N.js");
2958
+ const { PluginCreator } = await import("./plugin-creator-Y2NWASXI.js");
2937
2959
  if (opts.apiKey) {
2938
2960
  process.env.ANTHROPIC_API_KEY = opts.apiKey;
2939
2961
  }
2940
2962
  if (!process.env.ANTHROPIC_API_KEY) {
2941
- logger9.error("ANTHROPIC_API_KEY is required for plugin generation.");
2963
+ logger10.error("ANTHROPIC_API_KEY is required for plugin generation.");
2942
2964
  console.log("\nPlease set ANTHROPIC_API_KEY environment variable or use --api-key option.");
2943
2965
  process.exit(1);
2944
2966
  }
@@ -2948,13 +2970,13 @@ async function generatePlugin(opts) {
2948
2970
  const specContent = readFileSync4(opts.specFile, "utf-8");
2949
2971
  spec = JSON.parse(specContent);
2950
2972
  } catch (error) {
2951
- logger9.error(
2973
+ logger10.error(
2952
2974
  `Failed to read or parse spec file: ${error instanceof Error ? error.message : String(error)}`
2953
2975
  );
2954
2976
  process.exit(1);
2955
2977
  }
2956
2978
  } else if (opts.skipPrompts) {
2957
- logger9.error("--skip-prompts requires --spec-file to be provided");
2979
+ logger10.error("--skip-prompts requires --spec-file to be provided");
2958
2980
  process.exit(1);
2959
2981
  }
2960
2982
  const creator = new PluginCreator({
@@ -2981,7 +3003,7 @@ Next steps:`);
2981
3003
  console.log(`3. Test the plugin: bun test`);
2982
3004
  console.log(`4. Add to your ElizaOS project`);
2983
3005
  } else {
2984
- logger9.error(`Plugin generation failed: ${result.error?.message}`);
3006
+ logger10.error(`Plugin generation failed: ${result.error?.message}`);
2985
3007
  process.exit(1);
2986
3008
  }
2987
3009
  } catch (error) {
@@ -3344,16 +3366,14 @@ import { fileURLToPath as fileURLToPath3 } from "url";
3344
3366
  import * as clack9 from "@clack/prompts";
3345
3367
 
3346
3368
  // src/commands/update/index.ts
3347
- import { logger as logger13 } from "@elizaos/core";
3369
+ import { logger as logger14 } from "@elizaos/core";
3348
3370
  import { Command as Command4 } from "commander";
3349
3371
 
3350
3372
  // src/commands/update/actions/cli-update.ts
3351
- var import_execa2 = __toESM(require_execa(), 1);
3352
- import { logger as logger11 } from "@elizaos/core";
3373
+ import { logger as logger12 } from "@elizaos/core";
3353
3374
 
3354
3375
  // src/commands/update/utils/version-utils.ts
3355
- var import_execa = __toESM(require_execa(), 1);
3356
- import { logger as logger10 } from "@elizaos/core";
3376
+ import { logger as logger11 } from "@elizaos/core";
3357
3377
  import * as semver from "semver";
3358
3378
  var SPECIAL_VERSION_TAGS = ["latest", "next", "canary", "rc", "dev", "nightly", "alpha"];
3359
3379
  var ELIZAOS_ORG = "@elizaos";
@@ -3363,7 +3383,7 @@ async function getVersion2() {
3363
3383
  const envInfo = await UserEnvironment.getInstance().getInfo();
3364
3384
  return envInfo.cli.version;
3365
3385
  } catch (error) {
3366
- logger10.error("Error getting CLI version:", error);
3386
+ logger11.error("Error getting CLI version:", error);
3367
3387
  return FALLBACK_VERSION;
3368
3388
  }
3369
3389
  }
@@ -3399,14 +3419,14 @@ function isMajorUpdate(currentVersion, targetVersion) {
3399
3419
  }
3400
3420
  async function fetchLatestVersion(packageName) {
3401
3421
  try {
3402
- const { stdout } = await (0, import_execa.execa)("npm", ["view", packageName, "version"], {
3422
+ const { stdout } = await bunExecSimple("npm", ["view", packageName, "version"], {
3403
3423
  env: { NODE_ENV: "production" }
3404
3424
  });
3405
3425
  const version = stdout.trim();
3406
- logger10.debug(`Latest version of ${packageName} from npm: ${version}`);
3426
+ logger11.debug(`Latest version of ${packageName} from npm: ${version}`);
3407
3427
  return version;
3408
3428
  } catch (error) {
3409
- logger10.error(
3429
+ logger11.error(
3410
3430
  `Failed to fetch version for ${packageName}: ${error instanceof Error ? error.message : String(error)}`
3411
3431
  );
3412
3432
  return null;
@@ -3437,21 +3457,19 @@ async function performCliUpdate(options = {}) {
3437
3457
  if (!options.skipBunMigration) {
3438
3458
  const npmInstallation = await isCliInstalledViaNpm();
3439
3459
  if (npmInstallation) {
3440
- logger11.info("Detected npm installation, migrating to bun...");
3460
+ logger12.info("Detected npm installation, migrating to bun...");
3441
3461
  try {
3442
3462
  await migrateCliToBun(latestVersion);
3443
3463
  console.log(`CLI updated successfully to version ${latestVersion} [\u2713]`);
3444
3464
  return true;
3445
3465
  } catch (migrationError) {
3446
- logger11.warn("Migration to bun failed, falling back to npm update...");
3447
- logger11.debug(
3466
+ logger12.warn("Migration to bun failed, falling back to npm update...");
3467
+ logger12.debug(
3448
3468
  "Migration error:",
3449
3469
  migrationError instanceof Error ? migrationError.message : String(migrationError)
3450
3470
  );
3451
3471
  try {
3452
- await (0, import_execa2.execa)("npm", ["install", "-g", `@elizaos/cli@${latestVersion}`], {
3453
- stdio: "inherit"
3454
- });
3472
+ await bunExecInherit("npm", ["install", "-g", `@elizaos/cli@${latestVersion}`]);
3455
3473
  console.log(`CLI updated successfully to version ${latestVersion} [\u2713]`);
3456
3474
  return true;
3457
3475
  } catch (npmError) {
@@ -3463,7 +3481,7 @@ async function performCliUpdate(options = {}) {
3463
3481
  }
3464
3482
  }
3465
3483
  try {
3466
- await (0, import_execa2.execa)("bun", ["add", "-g", `@elizaos/cli@${latestVersion}`], { stdio: "inherit" });
3484
+ await bunExecInherit("bun", ["add", "-g", `@elizaos/cli@${latestVersion}`]);
3467
3485
  console.log(`CLI updated successfully to version ${latestVersion} [\u2713]`);
3468
3486
  return true;
3469
3487
  } catch (bunError) {
@@ -3471,7 +3489,7 @@ async function performCliUpdate(options = {}) {
3471
3489
  console.error(" curl -fsSL https://bun.sh/install | bash");
3472
3490
  console.error(" # or");
3473
3491
  console.error(" npm install -g bun");
3474
- logger11.debug("Bun error:", bunError instanceof Error ? bunError.message : String(bunError));
3492
+ logger12.debug("Bun error:", bunError instanceof Error ? bunError.message : String(bunError));
3475
3493
  return false;
3476
3494
  }
3477
3495
  } catch (error) {
@@ -3486,9 +3504,8 @@ import { promises as fs6 } from "fs";
3486
3504
  import * as path16 from "path";
3487
3505
 
3488
3506
  // src/commands/update/utils/package-utils.ts
3489
- var import_execa3 = __toESM(require_execa(), 1);
3490
3507
  import fs5 from "fs/promises";
3491
- import { logger as logger12 } from "@elizaos/core";
3508
+ import { logger as logger13 } from "@elizaos/core";
3492
3509
  async function checkForUpdates(dependencies) {
3493
3510
  const updates = {};
3494
3511
  const elizaPackages = Object.entries(dependencies).filter(([pkg]) => pkg.startsWith(ELIZAOS_ORG)).filter(([, version]) => !isWorkspaceVersion(version));
@@ -3499,7 +3516,7 @@ async function checkForUpdates(dependencies) {
3499
3516
  if (needsUpdate) {
3500
3517
  updates[pkg] = { current: currentVersion, latest: latestVersion };
3501
3518
  } else if (error) {
3502
- logger12.debug(`${pkg}: ${error}`);
3519
+ logger13.debug(`${pkg}: ${error}`);
3503
3520
  }
3504
3521
  }
3505
3522
  return { hasUpdates: Object.keys(updates).length > 0, updates };
@@ -3535,7 +3552,7 @@ async function installDependencies(cwd) {
3535
3552
  console.log("\nInstalling updated packages...");
3536
3553
  try {
3537
3554
  const packageManager = await getPackageManager();
3538
- await (0, import_execa3.execa)(packageManager, ["install"], { cwd, stdio: "inherit" });
3555
+ await bunExecInherit(packageManager, ["install"], { cwd });
3539
3556
  console.log("Dependencies installed successfully [\u2713]");
3540
3557
  } catch (error) {
3541
3558
  throw new Error(
@@ -3616,9 +3633,9 @@ function handleInvalidDirectory(directoryInfo) {
3616
3633
  // src/commands/update/index.ts
3617
3634
  var update = new Command4().name("update").description("Update ElizaOS CLI and project dependencies").option("-c, --check", "Check for available updates without applying them").option("--skip-build", "Skip building after updating").option("--cli", "Update only the CLI").option("--packages", "Update only packages").hook("preAction", async () => {
3618
3635
  try {
3619
- await displayBanner();
3636
+ await displayBanner(true);
3620
3637
  } catch {
3621
- logger13.debug("Banner display failed, continuing with update");
3638
+ logger14.debug("Banner display failed, continuing with update");
3622
3639
  }
3623
3640
  }).action(async (options) => {
3624
3641
  try {
@@ -3633,9 +3650,7 @@ var update = new Command4().name("update").description("Update ElizaOS CLI and p
3633
3650
  if (isNpx || isBunx) {
3634
3651
  console.warn("CLI update is not available when running via npx or bunx.");
3635
3652
  console.info("Please install the CLI globally:");
3636
- console.info(" bun install -g @elizaos/cli");
3637
- console.info(" # or");
3638
- console.info(" npm install -g @elizaos/cli");
3653
+ console.info(" bun install -g @elizaos/cli");
3639
3654
  if (!updatePackages) return;
3640
3655
  } else {
3641
3656
  const success = await performCliUpdate();
@@ -3652,7 +3667,7 @@ var update = new Command4().name("update").description("Update ElizaOS CLI and p
3652
3667
  console.info("To create a new ElizaOS project, use: elizaos create <project-name>");
3653
3668
  return;
3654
3669
  }
3655
- logger13.debug(`Detected ${directoryInfo.type}`);
3670
+ logger14.debug(`Detected ${directoryInfo.type}`);
3656
3671
  if (!isInProject) {
3657
3672
  handleInvalidDirectory(directoryInfo);
3658
3673
  return;
@@ -4043,15 +4058,12 @@ var publish = new Command5().name("publish").description("Publish a plugin to np
4043
4058
  import { Command as Command6 } from "commander";
4044
4059
 
4045
4060
  // src/commands/monorepo/actions/clone.ts
4046
- var import_execa4 = __toESM(require_execa(), 1);
4047
4061
  import { existsSync as existsSync12, readdirSync as readdirSync3, mkdirSync } from "fs";
4048
4062
  import path19 from "path";
4049
4063
  async function cloneRepository(repo, branch, destination) {
4050
4064
  try {
4051
4065
  const repoUrl = `https://github.com/${repo}`;
4052
- await (0, import_execa4.execa)("git", ["clone", "-b", branch, repoUrl, destination], {
4053
- stdio: "inherit"
4054
- });
4066
+ await bunExecInherit("git", ["clone", "-b", branch, repoUrl, destination]);
4055
4067
  } catch (error) {
4056
4068
  if (error instanceof Error && error.message.includes("exit code 128")) {
4057
4069
  console.error(`
@@ -4170,12 +4182,9 @@ var monorepo = new Command6().name("monorepo").description("Clone ElizaOS monore
4170
4182
  }
4171
4183
  });
4172
4184
 
4173
- // src/commands/start/index.ts
4174
- import { loadCharacterTryPath as loadCharacterTryPath2 } from "@elizaos/server";
4175
-
4176
4185
  // src/project.ts
4177
4186
  import {
4178
- logger as logger14
4187
+ logger as logger15
4179
4188
  } from "@elizaos/core";
4180
4189
  import { stringToUuid } from "@elizaos/core";
4181
4190
  import * as fs9 from "fs";
@@ -4217,7 +4226,7 @@ async function loadProject(dir) {
4217
4226
  const packageJson = JSON.parse(fs9.readFileSync(path21.join(dir, "package.json"), "utf8"));
4218
4227
  const main2 = packageJson.main;
4219
4228
  if (!main2) {
4220
- logger14.warn("No main field found in package.json, using default character");
4229
+ logger15.warn("No main field found in package.json, using default character");
4221
4230
  const defaultCharacterName = "Eliza (Default)";
4222
4231
  const elizaCharacter = getElizaCharacter();
4223
4232
  const defaultAgent = {
@@ -4227,7 +4236,7 @@ async function loadProject(dir) {
4227
4236
  name: defaultCharacterName
4228
4237
  },
4229
4238
  init: async () => {
4230
- logger14.info("Initializing default Eliza character");
4239
+ logger15.info("Initializing default Eliza character");
4231
4240
  }
4232
4241
  };
4233
4242
  return {
@@ -4250,18 +4259,18 @@ async function loadProject(dir) {
4250
4259
  const importPath = path21.resolve(entryPoint);
4251
4260
  const importUrl = process.platform === "win32" ? "file:///" + importPath.replace(/\\/g, "/") : "file://" + importPath;
4252
4261
  projectModule = await import(importUrl);
4253
- logger14.info(`Loaded project from ${entryPoint}`);
4262
+ logger15.info(`Loaded project from ${entryPoint}`);
4254
4263
  const exportKeys = Object.keys(projectModule);
4255
- logger14.debug(`Module exports: ${exportKeys.join(", ")}`);
4264
+ logger15.debug(`Module exports: ${exportKeys.join(", ")}`);
4256
4265
  if (exportKeys.includes("default")) {
4257
- logger14.debug(`Default export type: ${typeof projectModule.default}`);
4266
+ logger15.debug(`Default export type: ${typeof projectModule.default}`);
4258
4267
  if (typeof projectModule.default === "object" && projectModule.default !== null) {
4259
- logger14.debug(`Default export keys: ${Object.keys(projectModule.default).join(", ")}`);
4268
+ logger15.debug(`Default export keys: ${Object.keys(projectModule.default).join(", ")}`);
4260
4269
  }
4261
4270
  }
4262
4271
  break;
4263
4272
  } catch (error) {
4264
- logger14.warn(`Failed to import project from ${entryPoint}:`, error);
4273
+ logger15.warn(`Failed to import project from ${entryPoint}:`, error);
4265
4274
  }
4266
4275
  }
4267
4276
  }
@@ -4269,13 +4278,13 @@ async function loadProject(dir) {
4269
4278
  throw new Error("Could not find project entry point");
4270
4279
  }
4271
4280
  const moduleIsPlugin = isPlugin(projectModule);
4272
- logger14.debug(`Is this a plugin? ${moduleIsPlugin}`);
4281
+ logger15.debug(`Is this a plugin? ${moduleIsPlugin}`);
4273
4282
  if (moduleIsPlugin) {
4274
- logger14.info("Detected plugin module instead of project");
4283
+ logger15.info("Detected plugin module instead of project");
4275
4284
  try {
4276
4285
  const plugin = extractPlugin(projectModule);
4277
- logger14.debug(`Found plugin: ${plugin.name} - ${plugin.description}`);
4278
- logger14.debug(`Plugin has the following properties: ${Object.keys(plugin).join(", ")}`);
4286
+ logger15.debug(`Found plugin: ${plugin.name} - ${plugin.description}`);
4287
+ logger15.debug(`Plugin has the following properties: ${Object.keys(plugin).join(", ")}`);
4279
4288
  const completePlugin = {
4280
4289
  // Copy all other properties from the original plugin first
4281
4290
  ...plugin,
@@ -4283,7 +4292,7 @@ async function loadProject(dir) {
4283
4292
  name: plugin.name || "unknown-plugin",
4284
4293
  description: plugin.description || "No description",
4285
4294
  init: plugin.init || (async () => {
4286
- logger14.info(`Dummy init for plugin: ${plugin.name}`);
4295
+ logger15.info(`Dummy init for plugin: ${plugin.name}`);
4287
4296
  })
4288
4297
  };
4289
4298
  const characterName = "Eliza (Test Mode)";
@@ -4294,13 +4303,13 @@ async function loadProject(dir) {
4294
4303
  name: characterName,
4295
4304
  system: `${elizaCharacter.system} Testing the plugin: ${completePlugin.name}.`
4296
4305
  };
4297
- logger14.info(`Using Eliza character as test agent for plugin: ${completePlugin.name}`);
4306
+ logger15.info(`Using Eliza character as test agent for plugin: ${completePlugin.name}`);
4298
4307
  const testAgent = {
4299
4308
  character: testCharacter,
4300
4309
  plugins: [completePlugin],
4301
4310
  // Only include the plugin being tested
4302
4311
  init: async () => {
4303
- logger14.info(`Initializing Eliza test agent for plugin: ${completePlugin.name}`);
4312
+ logger15.info(`Initializing Eliza test agent for plugin: ${completePlugin.name}`);
4304
4313
  }
4305
4314
  };
4306
4315
  return {
@@ -4310,24 +4319,24 @@ async function loadProject(dir) {
4310
4319
  pluginModule: completePlugin
4311
4320
  };
4312
4321
  } catch (error) {
4313
- logger14.error("Error extracting plugin from module:", error);
4322
+ logger15.error("Error extracting plugin from module:", error);
4314
4323
  throw error;
4315
4324
  }
4316
4325
  }
4317
4326
  const agents = [];
4318
4327
  if (projectModule.default && typeof projectModule.default === "object" && Array.isArray(projectModule.default.agents)) {
4319
4328
  agents.push(...projectModule.default.agents);
4320
- logger14.debug(`Found ${agents.length} agents in default export's agents array`);
4329
+ logger15.debug(`Found ${agents.length} agents in default export's agents array`);
4321
4330
  } else {
4322
4331
  for (const [key, value] of Object.entries(projectModule)) {
4323
4332
  if (key === "default" && value && typeof value === "object") {
4324
4333
  if (value.character && value.init) {
4325
4334
  agents.push(value);
4326
- logger14.debug(`Found agent in default export (single agent)`);
4335
+ logger15.debug(`Found agent in default export (single agent)`);
4327
4336
  }
4328
4337
  } else if (value && typeof value === "object" && value.character && value.init) {
4329
4338
  agents.push(value);
4330
- logger14.debug(`Found agent in named export: ${key}`);
4339
+ logger15.debug(`Found agent in named export: ${key}`);
4331
4340
  }
4332
4341
  }
4333
4342
  }
@@ -4340,24 +4349,36 @@ async function loadProject(dir) {
4340
4349
  };
4341
4350
  return project;
4342
4351
  } catch (error) {
4343
- logger14.error("Error loading project:", error);
4352
+ logger15.error("Error loading project:", error);
4344
4353
  throw error;
4345
4354
  }
4346
4355
  }
4347
4356
 
4357
+ // src/utils/port-validation.ts
4358
+ function validatePort(value) {
4359
+ const port = Number.parseInt(value, 10);
4360
+ if (Number.isNaN(port) || port <= 0 || port > 65535) {
4361
+ throw new Error("Port must be a number between 1 and 65535");
4362
+ }
4363
+ return port;
4364
+ }
4365
+
4348
4366
  // src/commands/start/index.ts
4349
- import { logger as logger19 } from "@elizaos/core";
4367
+ import { logger as logger20 } from "@elizaos/core";
4368
+ import { loadCharacterTryPath as loadCharacterTryPath2 } from "@elizaos/server";
4350
4369
  import { Command as Command7 } from "commander";
4370
+ import * as fs10 from "fs";
4371
+ import * as path23 from "path";
4351
4372
 
4352
4373
  // src/commands/start/actions/server-start.ts
4353
4374
  import { AgentServer, jsonToCharacter, loadCharacterTryPath } from "@elizaos/server";
4354
- import { logger as logger18 } from "@elizaos/core";
4375
+ import { logger as logger19 } from "@elizaos/core";
4355
4376
 
4356
4377
  // src/commands/start/actions/agent-start.ts
4357
4378
  import {
4358
4379
  AgentRuntime as AgentRuntime2,
4359
4380
  encryptedCharacter,
4360
- logger as logger17,
4381
+ logger as logger18,
4361
4382
  stringToUuid as stringToUuid2
4362
4383
  } from "@elizaos/core";
4363
4384
  import { plugin as sqlPlugin } from "@elizaos/plugin-sql";
@@ -4400,19 +4421,19 @@ async function setDefaultSecretsFromEnv(character) {
4400
4421
  }
4401
4422
 
4402
4423
  // src/commands/start/utils/dependency-resolver.ts
4403
- import { logger as logger15 } from "@elizaos/core";
4424
+ import { logger as logger16 } from "@elizaos/core";
4404
4425
  function resolvePluginDependencies(availablePlugins, isTestMode = false) {
4405
4426
  const resolutionOrder = [];
4406
4427
  const visited = /* @__PURE__ */ new Set();
4407
4428
  const visiting = /* @__PURE__ */ new Set();
4408
4429
  function visit(pluginName) {
4409
4430
  if (!availablePlugins.has(pluginName)) {
4410
- logger15.warn(`Plugin dependency "${pluginName}" not found and will be skipped.`);
4431
+ logger16.warn(`Plugin dependency "${pluginName}" not found and will be skipped.`);
4411
4432
  return;
4412
4433
  }
4413
4434
  if (visited.has(pluginName)) return;
4414
4435
  if (visiting.has(pluginName)) {
4415
- logger15.error(`Circular dependency detected involving plugin: ${pluginName}`);
4436
+ logger16.error(`Circular dependency detected involving plugin: ${pluginName}`);
4416
4437
  return;
4417
4438
  }
4418
4439
  visiting.add(pluginName);
@@ -4436,12 +4457,12 @@ function resolvePluginDependencies(availablePlugins, isTestMode = false) {
4436
4457
  }
4437
4458
  }
4438
4459
  const finalPlugins = resolutionOrder.map((name) => availablePlugins.get(name)).filter((p) => p);
4439
- logger15.info(`Final plugins being loaded: ${finalPlugins.map((p) => p.name).join(", ")}`);
4460
+ logger16.info(`Final plugins being loaded: ${finalPlugins.map((p) => p.name).join(", ")}`);
4440
4461
  return finalPlugins;
4441
4462
  }
4442
4463
 
4443
4464
  // src/commands/start/utils/plugin-utils.ts
4444
- import { logger as logger16 } from "@elizaos/core";
4465
+ import { logger as logger17 } from "@elizaos/core";
4445
4466
  function isValidPluginShape(obj) {
4446
4467
  if (!obj || typeof obj !== "object" || !obj.name) {
4447
4468
  return false;
@@ -4456,12 +4477,12 @@ async function loadAndPreparePlugin(pluginName) {
4456
4477
  try {
4457
4478
  pluginModule = await loadPluginModule(pluginName);
4458
4479
  if (!pluginModule) {
4459
- logger16.error(`Failed to load local plugin ${pluginName}.`);
4480
+ logger17.error(`Failed to load local plugin ${pluginName}.`);
4460
4481
  provideLocalPluginGuidance(pluginName, context);
4461
4482
  return null;
4462
4483
  }
4463
4484
  } catch (error) {
4464
- logger16.error(`Error loading local plugin ${pluginName}: ${error}`);
4485
+ logger17.error(`Error loading local plugin ${pluginName}: ${error}`);
4465
4486
  provideLocalPluginGuidance(pluginName, context);
4466
4487
  return null;
4467
4488
  }
@@ -4469,17 +4490,17 @@ async function loadAndPreparePlugin(pluginName) {
4469
4490
  try {
4470
4491
  pluginModule = await loadPluginModule(pluginName);
4471
4492
  if (!pluginModule) {
4472
- logger16.info(`Plugin ${pluginName} not available, installing...`);
4493
+ logger17.info(`Plugin ${pluginName} not available, installing...`);
4473
4494
  await installPlugin(pluginName, process.cwd(), version);
4474
4495
  pluginModule = await loadPluginModule(pluginName);
4475
4496
  }
4476
4497
  } catch (error) {
4477
- logger16.error(`Failed to process plugin ${pluginName}: ${error}`);
4498
+ logger17.error(`Failed to process plugin ${pluginName}: ${error}`);
4478
4499
  return null;
4479
4500
  }
4480
4501
  }
4481
4502
  if (!pluginModule) {
4482
- logger16.error(`Failed to load module for plugin ${pluginName}.`);
4503
+ logger17.error(`Failed to load module for plugin ${pluginName}.`);
4483
4504
  return null;
4484
4505
  }
4485
4506
  const expectedFunctionName = `${pluginName.replace(/^@elizaos\/plugin-/, "").replace(/^@elizaos\//, "").replace(/-./g, (match) => match[1].toUpperCase())}Plugin`;
@@ -4493,7 +4514,7 @@ async function loadAndPreparePlugin(pluginName) {
4493
4514
  return potentialPlugin;
4494
4515
  }
4495
4516
  }
4496
- logger16.warn(`Could not find a valid plugin export in ${pluginName}.`);
4517
+ logger17.warn(`Could not find a valid plugin export in ${pluginName}.`);
4497
4518
  return null;
4498
4519
  }
4499
4520
 
@@ -4545,26 +4566,26 @@ async function startAgent(character, server, init, plugins2 = [], options = {})
4545
4566
  try {
4546
4567
  const migrationService = runtime.getService("database_migration");
4547
4568
  if (migrationService) {
4548
- logger17.info("Discovering plugin schemas for dynamic migration...");
4569
+ logger18.info("Discovering plugin schemas for dynamic migration...");
4549
4570
  migrationService.discoverAndRegisterPluginSchemas(finalPlugins);
4550
- logger17.info("Running all plugin migrations...");
4571
+ logger18.info("Running all plugin migrations...");
4551
4572
  await migrationService.runAllPluginMigrations();
4552
- logger17.info("All plugin migrations completed successfully");
4573
+ logger18.info("All plugin migrations completed successfully");
4553
4574
  } else {
4554
- logger17.warn("DatabaseMigrationService not found - plugin schema migrations skipped");
4575
+ logger18.warn("DatabaseMigrationService not found - plugin schema migrations skipped");
4555
4576
  }
4556
4577
  } catch (error) {
4557
- logger17.error("Failed to run plugin migrations:", error);
4578
+ logger18.error("Failed to run plugin migrations:", error);
4558
4579
  throw error;
4559
4580
  }
4560
4581
  server.registerAgent(runtime);
4561
- logger17.log(`Started ${runtime.character.name} as ${runtime.agentId}`);
4582
+ logger18.log(`Started ${runtime.character.name} as ${runtime.agentId}`);
4562
4583
  return runtime;
4563
4584
  }
4564
4585
  async function stopAgent(runtime, server) {
4565
4586
  await runtime.close();
4566
4587
  server.unregisterAgent(runtime.agentId);
4567
- logger17.success(`Agent ${runtime.character.name} stopped successfully!`);
4588
+ logger18.success(`Agent ${runtime.character.name} stopped successfully!`);
4568
4589
  }
4569
4590
 
4570
4591
  // src/commands/start/actions/server-start.ts
@@ -4611,13 +4632,13 @@ async function startAgents(options) {
4611
4632
  const desiredPort = options.port || Number.parseInt(process.env.SERVER_PORT || "3000");
4612
4633
  const serverPort = await findNextAvailablePort(desiredPort);
4613
4634
  if (serverPort !== desiredPort) {
4614
- logger18.warn(`Port ${desiredPort} is in use, using port ${serverPort} instead`);
4635
+ logger19.warn(`Port ${desiredPort} is in use, using port ${serverPort} instead`);
4615
4636
  }
4616
4637
  process.env.SERVER_PORT = serverPort.toString();
4617
4638
  try {
4618
4639
  await server.start(serverPort);
4619
4640
  } catch (error) {
4620
- logger18.error(`Failed to start server on port ${serverPort}:`, error);
4641
+ logger19.error(`Failed to start server on port ${serverPort}:`, error);
4621
4642
  throw error;
4622
4643
  }
4623
4644
  if (options.projectAgents && options.projectAgents.length > 0) {
@@ -4640,57 +4661,68 @@ async function startAgents(options) {
4640
4661
  }
4641
4662
 
4642
4663
  // src/commands/start/index.ts
4643
- import * as fs10 from "fs";
4644
- import * as path23 from "path";
4645
- var start = new Command7().name("start").description("Start the Eliza agent server").option("-c, --configure", "Reconfigure services and AI models").option("-p, --port <port>", "Port to listen on", validatePort).option("--character <paths...>", "Character file(s) to use").hook("preAction", async () => {
4664
+ var start = new Command7().name("start").description("Build and start the Eliza agent server").option("-c, --configure", "Reconfigure services and AI models").option("-p, --port <port>", "Port to listen on", validatePort).option("--character <paths...>", "Character file(s) to use").hook("preAction", async () => {
4646
4665
  await displayBanner();
4647
4666
  }).action(async (options) => {
4648
4667
  try {
4649
4668
  await loadEnvConfig();
4669
+ const cwd = process.cwd();
4670
+ const dirInfo = detectDirectoryType(cwd);
4671
+ const isMonorepo = dirInfo.type === "elizaos-monorepo";
4672
+ if (!isMonorepo && !process.env.ELIZA_TEST_MODE) {
4673
+ try {
4674
+ await buildProject(cwd, false);
4675
+ } catch (error) {
4676
+ logger20.error(`Build error: ${error instanceof Error ? error.message : String(error)}`);
4677
+ logger20.warn(
4678
+ "Build failed, but continuing with start. Some features may not work correctly."
4679
+ );
4680
+ }
4681
+ }
4650
4682
  let characters = [];
4651
4683
  let projectAgents = [];
4652
4684
  if (options.character && options.character.length > 0) {
4653
4685
  for (const charPath of options.character) {
4654
4686
  const resolvedPath = path23.resolve(charPath);
4655
4687
  if (!fs10.existsSync(resolvedPath)) {
4656
- logger19.error(`Character file not found: ${resolvedPath}`);
4688
+ logger20.error(`Character file not found: ${resolvedPath}`);
4657
4689
  throw new Error(`Character file not found: ${resolvedPath}`);
4658
4690
  }
4659
4691
  try {
4660
4692
  const character = await loadCharacterTryPath2(resolvedPath);
4661
4693
  if (character) {
4662
4694
  characters.push(character);
4663
- logger19.info(`Successfully loaded character: ${character.name}`);
4695
+ logger20.info(`Successfully loaded character: ${character.name}`);
4664
4696
  } else {
4665
- logger19.error(
4697
+ logger20.error(
4666
4698
  `Failed to load character from ${resolvedPath}: Invalid or empty character file`
4667
4699
  );
4668
4700
  throw new Error(`Invalid character file: ${resolvedPath}`);
4669
4701
  }
4670
4702
  } catch (e) {
4671
- logger19.error(`Failed to load character from ${resolvedPath}:`, e);
4703
+ logger20.error(`Failed to load character from ${resolvedPath}:`, e);
4672
4704
  throw new Error(`Invalid character file: ${resolvedPath}`);
4673
4705
  }
4674
4706
  }
4675
4707
  } else {
4676
4708
  try {
4677
- const cwd = process.cwd();
4678
- const dirInfo = detectDirectoryType(cwd);
4679
- if (dirInfo.hasPackageJson && dirInfo.type !== "non-elizaos-dir") {
4680
- logger19.info("No character files specified, attempting to load project agents...");
4681
- const project = await loadProject(cwd);
4709
+ const cwd2 = process.cwd();
4710
+ const dirInfo2 = detectDirectoryType(cwd2);
4711
+ if (dirInfo2.hasPackageJson && dirInfo2.type !== "non-elizaos-dir") {
4712
+ logger20.info("No character files specified, attempting to load project agents...");
4713
+ const project = await loadProject(cwd2);
4682
4714
  if (project.agents && project.agents.length > 0) {
4683
- logger19.info(`Found ${project.agents.length} agent(s) in project configuration`);
4715
+ logger20.info(`Found ${project.agents.length} agent(s) in project configuration`);
4684
4716
  projectAgents = project.agents;
4685
4717
  for (const agent2 of project.agents) {
4686
4718
  if (agent2.character) {
4687
- logger19.info(`Loaded character: ${agent2.character.name}`);
4719
+ logger20.info(`Loaded character: ${agent2.character.name}`);
4688
4720
  }
4689
4721
  }
4690
4722
  }
4691
4723
  }
4692
4724
  } catch (e) {
4693
- logger19.debug("Failed to load project agents, will use default character:", e);
4725
+ logger20.debug("Failed to load project agents, will use default character:", e);
4694
4726
  }
4695
4727
  }
4696
4728
  await startAgents({ ...options, characters, projectAgents });
@@ -4769,14 +4801,14 @@ ${emoji.error("Error: Failed to run Phala CLI")}`);
4769
4801
  var teeCommand = new Command9("tee").description("Manage TEE deployments").addCommand(phalaCliCommand);
4770
4802
 
4771
4803
  // src/commands/test/index.ts
4772
- import { logger as logger26 } from "@elizaos/core";
4804
+ import { logger as logger27 } from "@elizaos/core";
4773
4805
  import { Command as Command10, Option as Option2 } from "commander";
4774
4806
 
4775
4807
  // src/commands/test/actions/run-all-tests.ts
4776
- import { logger as logger24 } from "@elizaos/core";
4808
+ import { logger as logger25 } from "@elizaos/core";
4777
4809
 
4778
4810
  // src/commands/test/utils/project-utils.ts
4779
- import { logger as logger20 } from "@elizaos/core";
4811
+ import { logger as logger21 } from "@elizaos/core";
4780
4812
  import * as fs11 from "fs";
4781
4813
  import path24 from "path";
4782
4814
  function getProjectType(testPath) {
@@ -4813,7 +4845,7 @@ async function installPluginDependencies(projectInfo) {
4813
4845
  };
4814
4846
  await fs11.promises.writeFile(packageJsonPath, JSON.stringify(packageJsonContent, null, 2));
4815
4847
  }
4816
- const { installPlugin: installPlugin2 } = await import("./utils-DTW3XU6O.js");
4848
+ const { installPlugin: installPlugin2 } = await import("./utils-QSRUVLAT.js");
4817
4849
  for (const dependency of project.pluginModule.dependencies) {
4818
4850
  await installPlugin2(dependency, pluginsDir);
4819
4851
  const dependencyPath = path24.join(pluginsDir, "node_modules", dependency);
@@ -4821,7 +4853,7 @@ async function installPluginDependencies(projectInfo) {
4821
4853
  try {
4822
4854
  await runBunCommand(["install"], dependencyPath);
4823
4855
  } catch (error) {
4824
- logger20.warn(
4856
+ logger21.warn(
4825
4857
  `[Test Command] Failed to install devDependencies for ${dependency}: ${error}`
4826
4858
  );
4827
4859
  }
@@ -4831,12 +4863,12 @@ async function installPluginDependencies(projectInfo) {
4831
4863
  }
4832
4864
 
4833
4865
  // src/commands/test/actions/component-tests.ts
4834
- import { logger as logger22 } from "@elizaos/core";
4866
+ import { logger as logger23 } from "@elizaos/core";
4835
4867
  import { spawn as spawn3 } from "child_process";
4836
4868
  import path26 from "path";
4837
4869
 
4838
4870
  // src/utils/testing/tsc-validator.ts
4839
- import { logger as logger21 } from "@elizaos/core";
4871
+ import { logger as logger22 } from "@elizaos/core";
4840
4872
  import path25 from "path";
4841
4873
  import { existsSync as existsSync17 } from "fs";
4842
4874
  async function runTypeCheck(projectPath, strict = true) {
@@ -4864,7 +4896,7 @@ async function runTypeCheck(projectPath, strict = true) {
4864
4896
  warnings: stderr.includes("warning") ? [stderr] : []
4865
4897
  };
4866
4898
  } catch (error) {
4867
- logger21.error("TypeScript validation failed:", error);
4899
+ logger22.error("TypeScript validation failed:", error);
4868
4900
  return {
4869
4901
  success: false,
4870
4902
  errors: [`TypeScript validation error: ${error.message}`],
@@ -4878,39 +4910,39 @@ async function runComponentTests(testPath, options, projectInfo) {
4878
4910
  const cwd = process.cwd();
4879
4911
  const isPlugin2 = projectInfo.type === "elizaos-plugin";
4880
4912
  if (!options.skipTypeCheck) {
4881
- logger22.info("Running TypeScript validation...");
4913
+ logger23.info("Running TypeScript validation...");
4882
4914
  const typeCheckResult = await runTypeCheck(cwd, true);
4883
4915
  if (!typeCheckResult.success) {
4884
- logger22.error("TypeScript validation failed:");
4885
- typeCheckResult.errors.forEach((error) => logger22.error(error));
4916
+ logger23.error("TypeScript validation failed:");
4917
+ typeCheckResult.errors.forEach((error) => logger23.error(error));
4886
4918
  return { failed: true };
4887
4919
  }
4888
- logger22.success("TypeScript validation passed");
4920
+ logger23.success("TypeScript validation passed");
4889
4921
  }
4890
4922
  if (!options.skipBuild) {
4891
4923
  try {
4892
- logger22.info(`Building ${isPlugin2 ? "plugin" : "project"}...`);
4924
+ logger23.info(`Building ${isPlugin2 ? "plugin" : "project"}...`);
4893
4925
  await buildProject(cwd, isPlugin2);
4894
- logger22.success(`Build completed successfully`);
4926
+ logger23.success(`Build completed successfully`);
4895
4927
  } catch (buildError) {
4896
- logger22.error(`Build failed: ${buildError}`);
4928
+ logger23.error(`Build failed: ${buildError}`);
4897
4929
  return { failed: true };
4898
4930
  }
4899
4931
  }
4900
- logger22.info("Running component tests...");
4932
+ logger23.info("Running component tests...");
4901
4933
  return new Promise((resolve2) => {
4902
4934
  const args = ["test", "--passWithNoTests"];
4903
4935
  if (options.name) {
4904
4936
  const baseName = processFilterName(options.name);
4905
4937
  if (baseName) {
4906
- logger22.info(`Using test filter: ${baseName}`);
4938
+ logger23.info(`Using test filter: ${baseName}`);
4907
4939
  args.push("-t", baseName);
4908
4940
  }
4909
4941
  }
4910
4942
  const monorepoRoot = UserEnvironment.getInstance().findMonorepoRoot(process.cwd());
4911
4943
  const baseDir = monorepoRoot ?? process.cwd();
4912
4944
  const targetPath = testPath ? path26.resolve(baseDir, testPath) : process.cwd();
4913
- logger22.info(`Executing: bun ${args.join(" ")} in ${targetPath}`);
4945
+ logger23.info(`Executing: bun ${args.join(" ")} in ${targetPath}`);
4914
4946
  const child = spawn3("bun", args, {
4915
4947
  stdio: "inherit",
4916
4948
  shell: false,
@@ -4924,11 +4956,11 @@ async function runComponentTests(testPath, options, projectInfo) {
4924
4956
  }
4925
4957
  });
4926
4958
  child.on("close", (code) => {
4927
- logger22.info("Component tests completed");
4959
+ logger23.info("Component tests completed");
4928
4960
  resolve2({ failed: code !== 0 });
4929
4961
  });
4930
4962
  child.on("error", (error) => {
4931
- logger22.error("Error running component tests:", error);
4963
+ logger23.error("Error running component tests:", error);
4932
4964
  resolve2({ failed: true });
4933
4965
  });
4934
4966
  });
@@ -4936,7 +4968,7 @@ async function runComponentTests(testPath, options, projectInfo) {
4936
4968
 
4937
4969
  // src/commands/test/actions/e2e-tests.ts
4938
4970
  import { AgentServer as AgentServer2, jsonToCharacter as jsonToCharacter2, loadCharacterTryPath as loadCharacterTryPath3 } from "@elizaos/server";
4939
- import { logger as logger23 } from "@elizaos/core";
4971
+ import { logger as logger24 } from "@elizaos/core";
4940
4972
  import * as dotenv2 from "dotenv";
4941
4973
  import * as fs12 from "fs";
4942
4974
  import path27 from "path";
@@ -4945,12 +4977,12 @@ async function runE2eTests(testPath, options, projectInfo) {
4945
4977
  try {
4946
4978
  const cwd = process.cwd();
4947
4979
  const isPlugin2 = projectInfo.type === "elizaos-plugin";
4948
- logger23.info(`Building ${isPlugin2 ? "plugin" : "project"}...`);
4980
+ logger24.info(`Building ${isPlugin2 ? "plugin" : "project"}...`);
4949
4981
  await buildProject(cwd, isPlugin2);
4950
- logger23.info(`Build completed successfully`);
4982
+ logger24.info(`Build completed successfully`);
4951
4983
  } catch (buildError) {
4952
- logger23.error(`Build error: ${buildError}`);
4953
- logger23.warn(`Attempting to continue with tests despite build error`);
4984
+ logger24.error(`Build error: ${buildError}`);
4985
+ logger24.warn(`Attempting to continue with tests despite build error`);
4954
4986
  }
4955
4987
  }
4956
4988
  let server;
@@ -4984,33 +5016,33 @@ async function runE2eTests(testPath, options, projectInfo) {
4984
5016
  process.env.PGLITE_DATA_DIR = elizaDbDir;
4985
5017
  console.info(`Set PGLITE_DATA_DIR to: ${elizaDbDir}`);
4986
5018
  if (fs12.existsSync(envFilePath)) {
4987
- logger23.info(`Loading environment variables from: ${envFilePath}`);
5019
+ logger24.info(`Loading environment variables from: ${envFilePath}`);
4988
5020
  dotenv2.config({ path: envFilePath });
4989
- logger23.info("Environment variables loaded");
5021
+ logger24.info("Environment variables loaded");
4990
5022
  } else {
4991
- logger23.warn(`Environment file not found: ${envFilePath}`);
5023
+ logger24.warn(`Environment file not found: ${envFilePath}`);
4992
5024
  }
4993
5025
  const postgresUrl = process.env.POSTGRES_URL;
4994
- logger23.info(
5026
+ logger24.info(
4995
5027
  `PostgreSQL URL for e2e tests: ${postgresUrl ? "found" : "not found (will use PGlite)"}`
4996
5028
  );
4997
- logger23.info("Creating server instance...");
5029
+ logger24.info("Creating server instance...");
4998
5030
  server = new AgentServer2();
4999
- logger23.info("Server instance created");
5000
- logger23.info("Initializing server...");
5031
+ logger24.info("Server instance created");
5032
+ logger24.info("Initializing server...");
5001
5033
  try {
5002
5034
  await server.initialize({
5003
5035
  dataDir: elizaDbDir,
5004
5036
  postgresUrl
5005
5037
  });
5006
- logger23.info("Server initialized successfully");
5038
+ logger24.info("Server initialized successfully");
5007
5039
  } catch (initError) {
5008
- logger23.error("Server initialization failed:", initError);
5040
+ logger24.error("Server initialization failed:", initError);
5009
5041
  throw initError;
5010
5042
  }
5011
5043
  let project;
5012
5044
  try {
5013
- logger23.info("Attempting to load project or plugin...");
5045
+ logger24.info("Attempting to load project or plugin...");
5014
5046
  const monorepoRoot = UserEnvironment.getInstance().findMonorepoRoot(process.cwd());
5015
5047
  const baseDir = monorepoRoot ?? process.cwd();
5016
5048
  const targetPath = testPath ? path27.resolve(baseDir, testPath) : process.cwd();
@@ -5018,39 +5050,39 @@ async function runE2eTests(testPath, options, projectInfo) {
5018
5050
  if (!project || !project.agents || project.agents.length === 0) {
5019
5051
  throw new Error("No agents found in project configuration");
5020
5052
  }
5021
- logger23.info(`Found ${project.agents.length} agents`);
5022
- logger23.info("Setting up server properties...");
5053
+ logger24.info(`Found ${project.agents.length} agents`);
5054
+ logger24.info("Setting up server properties...");
5023
5055
  server.startAgent = async (character) => {
5024
- logger23.info(`Starting agent for character ${character.name}`);
5056
+ logger24.info(`Starting agent for character ${character.name}`);
5025
5057
  return startAgent(character, server, void 0, [], { isTestMode: true });
5026
5058
  };
5027
5059
  server.loadCharacterTryPath = loadCharacterTryPath3;
5028
5060
  server.jsonToCharacter = jsonToCharacter2;
5029
- logger23.info("Server properties set up");
5061
+ logger24.info("Server properties set up");
5030
5062
  const desiredPort = options.port || Number.parseInt(process.env.SERVER_PORT || "3000");
5031
5063
  const serverPort = await findNextAvailablePort(desiredPort);
5032
5064
  if (serverPort !== desiredPort) {
5033
- logger23.warn(`Port ${desiredPort} is in use for testing, using port ${serverPort} instead.`);
5065
+ logger24.warn(`Port ${desiredPort} is in use for testing, using port ${serverPort} instead.`);
5034
5066
  }
5035
- logger23.info("Starting server...");
5067
+ logger24.info("Starting server...");
5036
5068
  try {
5037
5069
  await server.start(serverPort);
5038
- logger23.info("Server started successfully on port", serverPort);
5070
+ logger24.info("Server started successfully on port", serverPort);
5039
5071
  } catch (error) {
5040
- logger23.error("Error starting server:", error);
5072
+ logger24.error("Error starting server:", error);
5041
5073
  if (error instanceof Error) {
5042
- logger23.error("Error details:", error.message);
5043
- logger23.error("Stack trace:", error.stack);
5074
+ logger24.error("Error details:", error.message);
5075
+ logger24.error("Stack trace:", error.stack);
5044
5076
  }
5045
5077
  throw error;
5046
5078
  }
5047
5079
  try {
5048
- logger23.info(
5080
+ logger24.info(
5049
5081
  `Found ${project.agents.length} agents in ${project.isPlugin ? "plugin" : "project"}`
5050
5082
  );
5051
5083
  if (project.isPlugin || project.agents.length === 0) {
5052
5084
  process.env.ELIZA_TESTING_PLUGIN = "true";
5053
- logger23.info("Using default Eliza character as test agent");
5085
+ logger24.info("Using default Eliza character as test agent");
5054
5086
  try {
5055
5087
  const pluginUnderTest = project.pluginModule;
5056
5088
  if (!pluginUnderTest) {
@@ -5073,16 +5105,16 @@ async function runE2eTests(testPath, options, projectInfo) {
5073
5105
  plugins: runtime.plugins
5074
5106
  // Pass all plugins, not just the one under test
5075
5107
  });
5076
- logger23.info("Default test agent started successfully");
5108
+ logger24.info("Default test agent started successfully");
5077
5109
  } catch (pluginError) {
5078
- logger23.error(`Error starting plugin test agent: ${pluginError}`);
5110
+ logger24.error(`Error starting plugin test agent: ${pluginError}`);
5079
5111
  throw pluginError;
5080
5112
  }
5081
5113
  } else {
5082
5114
  for (const agent2 of project.agents) {
5083
5115
  try {
5084
5116
  const originalCharacter = { ...agent2.character };
5085
- logger23.debug(`Starting agent: ${originalCharacter.name}`);
5117
+ logger24.debug(`Starting agent: ${originalCharacter.name}`);
5086
5118
  const runtime = await startAgent(
5087
5119
  originalCharacter,
5088
5120
  server,
@@ -5095,28 +5127,28 @@ async function runE2eTests(testPath, options, projectInfo) {
5095
5127
  projectAgents.push(agent2);
5096
5128
  await new Promise((resolve2) => setTimeout(resolve2, 1e3));
5097
5129
  } catch (agentError) {
5098
- logger23.error(`Error starting agent ${agent2.character.name}:`, agentError);
5130
+ logger24.error(`Error starting agent ${agent2.character.name}:`, agentError);
5099
5131
  if (agentError instanceof Error) {
5100
- logger23.error("Error details:", agentError.message);
5101
- logger23.error("Stack trace:", agentError.stack);
5132
+ logger24.error("Error details:", agentError.message);
5133
+ logger24.error("Stack trace:", agentError.stack);
5102
5134
  }
5103
- logger23.warn(`Skipping agent ${agent2.character.name} due to startup error`);
5135
+ logger24.warn(`Skipping agent ${agent2.character.name} due to startup error`);
5104
5136
  }
5105
5137
  }
5106
5138
  }
5107
5139
  if (runtimes.length === 0) {
5108
5140
  throw new Error("Failed to start any agents from project");
5109
5141
  }
5110
- logger23.debug(`Successfully started ${runtimes.length} agents for testing`);
5142
+ logger24.debug(`Successfully started ${runtimes.length} agents for testing`);
5111
5143
  let totalFailed = 0;
5112
5144
  let anyTestsFound = false;
5113
5145
  for (let i = 0; i < runtimes.length; i++) {
5114
5146
  const runtime = runtimes[i];
5115
5147
  const projectAgent = projectAgents[i];
5116
5148
  if (project.isPlugin) {
5117
- logger23.debug(`Running tests for plugin: ${project.pluginModule?.name}`);
5149
+ logger24.debug(`Running tests for plugin: ${project.pluginModule?.name}`);
5118
5150
  } else {
5119
- logger23.debug(`Running tests for agent: ${runtime.character.name}`);
5151
+ logger24.debug(`Running tests for agent: ${runtime.character.name}`);
5120
5152
  }
5121
5153
  const testRunner = new TestRunner(runtime, projectAgent);
5122
5154
  const currentDirInfo = projectInfo;
@@ -5137,17 +5169,17 @@ async function runE2eTests(testPath, options, projectInfo) {
5137
5169
  }
5138
5170
  return { failed: anyTestsFound ? totalFailed > 0 : false };
5139
5171
  } catch (error) {
5140
- logger23.error("Error in runE2eTests:", error);
5172
+ logger24.error("Error in runE2eTests:", error);
5141
5173
  if (error instanceof Error) {
5142
- logger23.error("Error details:", error.message);
5143
- logger23.error("Stack trace:", error.stack);
5174
+ logger24.error("Error details:", error.message);
5175
+ logger24.error("Stack trace:", error.stack);
5144
5176
  } else {
5145
- logger23.error("Unknown error type:", typeof error);
5146
- logger23.error("Error value:", error);
5177
+ logger24.error("Unknown error type:", typeof error);
5178
+ logger24.error("Error value:", error);
5147
5179
  try {
5148
- logger23.error("Stringified error:", JSON.stringify(error, null, 2));
5180
+ logger24.error("Stringified error:", JSON.stringify(error, null, 2));
5149
5181
  } catch (e) {
5150
- logger23.error("Could not stringify error:", e);
5182
+ logger24.error("Could not stringify error:", e);
5151
5183
  }
5152
5184
  }
5153
5185
  return { failed: true };
@@ -5170,33 +5202,33 @@ async function runE2eTests(testPath, options, projectInfo) {
5170
5202
  }
5171
5203
  }
5172
5204
  } catch (error) {
5173
- logger23.error("Error in runE2eTests:", error);
5205
+ logger24.error("Error in runE2eTests:", error);
5174
5206
  if (error instanceof Error) {
5175
- logger23.error("Error details:", error.message);
5176
- logger23.error("Stack trace:", error.stack);
5207
+ logger24.error("Error details:", error.message);
5208
+ logger24.error("Stack trace:", error.stack);
5177
5209
  } else {
5178
- logger23.error("Unknown error type:", typeof error);
5179
- logger23.error("Error value:", error);
5210
+ logger24.error("Unknown error type:", typeof error);
5211
+ logger24.error("Error value:", error);
5180
5212
  try {
5181
- logger23.error("Stringified error:", JSON.stringify(error, null, 2));
5213
+ logger24.error("Stringified error:", JSON.stringify(error, null, 2));
5182
5214
  } catch (e) {
5183
- logger23.error("Could not stringify error:", e);
5215
+ logger24.error("Could not stringify error:", e);
5184
5216
  }
5185
5217
  }
5186
5218
  return { failed: true };
5187
5219
  }
5188
5220
  } catch (error) {
5189
- logger23.error("Error in runE2eTests:", error);
5221
+ logger24.error("Error in runE2eTests:", error);
5190
5222
  if (error instanceof Error) {
5191
- logger23.error("Error details:", error.message);
5192
- logger23.error("Stack trace:", error.stack);
5223
+ logger24.error("Error details:", error.message);
5224
+ logger24.error("Stack trace:", error.stack);
5193
5225
  } else {
5194
- logger23.error("Unknown error type:", typeof error);
5195
- logger23.error("Error value:", error);
5226
+ logger24.error("Unknown error type:", typeof error);
5227
+ logger24.error("Error value:", error);
5196
5228
  try {
5197
- logger23.error("Stringified error:", JSON.stringify(error, null, 2));
5229
+ logger24.error("Stringified error:", JSON.stringify(error, null, 2));
5198
5230
  } catch (e) {
5199
- logger23.error("Could not stringify error:", e);
5231
+ logger24.error("Could not stringify error:", e);
5200
5232
  }
5201
5233
  }
5202
5234
  return { failed: true };
@@ -5209,15 +5241,15 @@ async function runAllTests(testPath, options) {
5209
5241
  if (!options.skipBuild) {
5210
5242
  const componentResult = await runComponentTests(testPath, options, projectInfo);
5211
5243
  if (componentResult.failed) {
5212
- logger24.error("Component tests failed. Continuing to e2e tests...");
5244
+ logger25.error("Component tests failed. Continuing to e2e tests...");
5213
5245
  }
5214
5246
  }
5215
5247
  const e2eResult = await runE2eTests(testPath, options, projectInfo);
5216
5248
  if (e2eResult.failed) {
5217
- logger24.error("E2E tests failed.");
5249
+ logger25.error("E2E tests failed.");
5218
5250
  process.exit(1);
5219
5251
  }
5220
- logger24.success("All tests passed successfully!");
5252
+ logger25.success("All tests passed successfully!");
5221
5253
  process.exit(0);
5222
5254
  }
5223
5255
 
@@ -5225,7 +5257,7 @@ async function runAllTests(testPath, options) {
5225
5257
  import * as net from "net";
5226
5258
 
5227
5259
  // src/commands/test/utils/plugin-utils.ts
5228
- import { logger as logger25 } from "@elizaos/core";
5260
+ import { logger as logger26 } from "@elizaos/core";
5229
5261
  import * as fs13 from "fs";
5230
5262
  import path28 from "path";
5231
5263
 
@@ -5237,31 +5269,31 @@ var test = new Command10().name("test").description("Run tests for the current p
5237
5269
  const projectInfo = getProjectType(testPath);
5238
5270
  await installPluginDependencies(projectInfo);
5239
5271
  }).action(async (testPath, options) => {
5240
- logger26.info("Starting tests...");
5272
+ logger27.info("Starting tests...");
5241
5273
  try {
5242
5274
  const projectInfo = getProjectType(testPath);
5243
5275
  switch (options.type) {
5244
5276
  case "component":
5245
- logger26.info("Running component tests only...");
5277
+ logger27.info("Running component tests only...");
5246
5278
  const componentResult = await runComponentTests(testPath, options, projectInfo);
5247
5279
  if (componentResult.failed) {
5248
- logger26.error("Component tests failed.");
5280
+ logger27.error("Component tests failed.");
5249
5281
  process.exit(1);
5250
5282
  }
5251
- logger26.success("Component tests passed successfully!");
5283
+ logger27.success("Component tests passed successfully!");
5252
5284
  break;
5253
5285
  case "e2e":
5254
- logger26.info("Running e2e tests only...");
5286
+ logger27.info("Running e2e tests only...");
5255
5287
  const e2eResult = await runE2eTests(testPath, options, projectInfo);
5256
5288
  if (e2eResult.failed) {
5257
- logger26.error("E2E tests failed.");
5289
+ logger27.error("E2E tests failed.");
5258
5290
  process.exit(1);
5259
5291
  }
5260
- logger26.success("E2E tests passed successfully!");
5292
+ logger27.success("E2E tests passed successfully!");
5261
5293
  break;
5262
5294
  case "all":
5263
5295
  default:
5264
- logger26.info("Running all tests...");
5296
+ logger27.info("Running all tests...");
5265
5297
  await runAllTests(testPath, options);
5266
5298
  break;
5267
5299
  }
@@ -5272,13 +5304,46 @@ var test = new Command10().name("test").description("Run tests for the current p
5272
5304
  });
5273
5305
 
5274
5306
  // src/index.ts
5275
- import { logger as logger27 } from "@elizaos/core";
5307
+ import { logger as logger28 } from "@elizaos/core";
5276
5308
  import { Command as Command11 } from "commander";
5277
5309
  process.env.NODE_OPTIONS = "--no-deprecation";
5278
5310
  process.env.NODE_NO_WARNINGS = "1";
5279
5311
  process.env.QUIET_MODE = process.env.QUIET_MODE || "true";
5280
- process.on("SIGINT", () => process.exit(0));
5281
- process.on("SIGTERM", () => process.exit(0));
5312
+ var shutdownState = {
5313
+ isShuttingDown: false,
5314
+ /**
5315
+ * Atomically check and set the shutdown flag
5316
+ * @returns true if shutdown was initiated, false if already in progress
5317
+ */
5318
+ tryInitiateShutdown() {
5319
+ if (this.isShuttingDown) {
5320
+ return false;
5321
+ }
5322
+ this.isShuttingDown = true;
5323
+ return true;
5324
+ }
5325
+ };
5326
+ async function gracefulShutdown(signal) {
5327
+ if (!shutdownState.tryInitiateShutdown()) {
5328
+ logger28.debug(`Ignoring ${signal} - shutdown already in progress`);
5329
+ return;
5330
+ }
5331
+ logger28.info(`Received ${signal}, shutting down gracefully...`);
5332
+ try {
5333
+ const serverWasStopped = await stopServer();
5334
+ if (serverWasStopped) {
5335
+ logger28.info("Server stopped successfully");
5336
+ }
5337
+ } catch (error) {
5338
+ const errorMessage = error instanceof Error ? error.message : String(error);
5339
+ logger28.error(`Error stopping server: ${errorMessage}`);
5340
+ logger28.debug("Full error details:", error);
5341
+ }
5342
+ const exitCode = signal === "SIGINT" ? 130 : signal === "SIGTERM" ? 143 : 0;
5343
+ process.exit(exitCode);
5344
+ }
5345
+ process.on("SIGINT", () => gracefulShutdown("SIGINT"));
5346
+ process.on("SIGTERM", () => gracefulShutdown("SIGTERM"));
5282
5347
  async function main() {
5283
5348
  if (process.argv.includes("--no-emoji")) {
5284
5349
  configureEmojis({ forceDisable: true });
@@ -5302,6 +5367,6 @@ async function main() {
5302
5367
  await program.parseAsync();
5303
5368
  }
5304
5369
  main().catch((error) => {
5305
- logger27.error("An error occurred:", error);
5370
+ logger28.error("An error occurred:", error);
5306
5371
  process.exit(1);
5307
5372
  });