@elizaos/cli 1.3.0 → 1.3.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/{chunk-2CUIHNPL.js → chunk-5GUS4CFO.js} +7 -2
- package/dist/{chunk-2ALAPQLV.js → chunk-E6XYTE3A.js} +296 -311
- package/dist/chunk-GXWWPFBO.js +39 -0
- package/dist/{chunk-I77ZRNYO.js → chunk-T2QDIXGU.js} +2 -2
- package/dist/commands/agent/actions/index.d.ts +5 -0
- package/dist/commands/agent/actions/index.js +2 -2
- package/dist/commands/agent/index.d.ts +2 -2
- package/dist/commands/agent/index.js +2 -2
- package/dist/commands/create/actions/index.js +3 -3
- package/dist/commands/create/index.js +4 -4
- package/dist/commands/shared/index.d.ts +11 -28
- package/dist/commands/shared/index.js +7 -3
- package/dist/index.js +541 -450
- package/dist/{registry-N626N4VG.js → registry-433S5F3Y.js} +2 -2
- package/dist/templates/plugin-quick-starter/.gitignore +66 -0
- package/dist/templates/plugin-quick-starter/.npmignore +5 -0
- package/dist/templates/plugin-quick-starter/package.json +11 -3
- package/dist/templates/plugin-quick-starter/src/__tests__/plugin.test.ts +499 -146
- package/dist/templates/plugin-quick-starter/src/__tests__/test-utils.ts +316 -115
- package/dist/templates/plugin-quick-starter/src/plugin.ts +7 -13
- package/dist/templates/plugin-starter/.gitignore +66 -0
- package/dist/templates/plugin-starter/.npmignore +5 -0
- package/dist/templates/plugin-starter/README.md +1 -1
- package/dist/templates/plugin-starter/package.json +11 -3
- package/dist/templates/plugin-starter/src/__tests__/integration.test.ts +13 -13
- package/dist/templates/plugin-starter/src/__tests__/plugin.test.ts +556 -129
- package/dist/templates/plugin-starter/src/__tests__/test-utils.ts +347 -115
- package/dist/templates/plugin-starter/src/plugin.ts +18 -22
- package/dist/templates/project-starter/.gitignore +57 -0
- package/dist/templates/project-starter/.npmignore +11 -0
- package/dist/templates/project-starter/README.md +1 -1
- package/dist/templates/project-starter/package.json +4 -4
- package/dist/templates/project-starter/src/__tests__/env.test.ts +3 -1
- package/dist/templates/project-starter/src/__tests__/file-structure.test.ts +3 -2
- package/dist/templates/project-starter/src/__tests__/integration.test.ts +1 -1
- package/dist/templates/project-starter/tsup.config.ts +2 -1
- package/dist/templates/project-tee-starter/.dockerignore +64 -14
- package/dist/templates/project-tee-starter/.gitignore +57 -0
- package/dist/templates/project-tee-starter/.npmignore +6 -0
- package/dist/templates/project-tee-starter/Dockerfile +9 -5
- package/dist/templates/project-tee-starter/GUIDE.md +103 -42
- package/dist/templates/project-tee-starter/README.md +39 -19
- package/dist/templates/project-tee-starter/__tests__/build-order.test.ts +62 -0
- package/dist/templates/project-tee-starter/__tests__/character.test.ts +19 -17
- package/dist/templates/project-tee-starter/__tests__/config.test.ts +10 -3
- package/dist/templates/project-tee-starter/__tests__/env.test.ts +2 -1
- package/dist/templates/project-tee-starter/__tests__/file-structure.test.ts +14 -3
- package/dist/templates/project-tee-starter/__tests__/frontend.test.ts +459 -0
- package/dist/templates/project-tee-starter/__tests__/plugin.test.ts +4 -2
- package/dist/templates/project-tee-starter/__tests__/routes.test.ts +15 -6
- package/dist/templates/project-tee-starter/__tests__/tee-validation.test.ts +295 -0
- package/dist/templates/project-tee-starter/__tests__/vite-config-utils.ts +39 -0
- package/dist/templates/project-tee-starter/docker-compose.yaml +5 -2
- package/dist/templates/{plugin-starter/dist → project-tee-starter}/index.html +3 -3
- package/dist/templates/project-tee-starter/package.json +34 -14
- package/dist/templates/project-tee-starter/postcss.config.js +3 -0
- package/dist/templates/project-tee-starter/scripts/install-test-deps.js +52 -0
- package/dist/templates/project-tee-starter/scripts/test-all.sh +82 -0
- package/dist/templates/project-tee-starter/src/frontend/index.css +106 -0
- package/dist/templates/project-tee-starter/src/frontend/index.html +20 -0
- package/dist/templates/project-tee-starter/src/frontend/index.tsx +370 -0
- package/dist/templates/project-tee-starter/src/frontend/panels.tsx +17 -0
- package/dist/templates/project-tee-starter/src/frontend/utils.ts +6 -0
- package/dist/templates/project-tee-starter/src/index.ts +6 -6
- package/dist/templates/project-tee-starter/src/plugin.ts +209 -59
- package/dist/templates/project-tee-starter/tailwind.config.js +62 -0
- package/dist/templates/project-tee-starter/tsconfig.build.json +2 -2
- package/dist/templates/project-tee-starter/tsconfig.json +8 -5
- package/dist/templates/project-tee-starter/tsup.config.ts +3 -2
- package/dist/templates/project-tee-starter/vite.config.ts +39 -0
- package/dist/url-utils-CKc_Ebt_.d.ts +35 -0
- package/dist/{utils-H66532NB.js → utils-DBLSDYBF.js} +2 -2
- package/package.json +12 -7
- package/templates/plugin-quick-starter/.gitignore +66 -0
- package/templates/plugin-quick-starter/.npmignore +5 -0
- package/templates/plugin-quick-starter/package.json +11 -3
- package/templates/plugin-quick-starter/src/__tests__/plugin.test.ts +499 -146
- package/templates/plugin-quick-starter/src/__tests__/test-utils.ts +316 -115
- package/templates/plugin-quick-starter/src/plugin.ts +7 -13
- package/templates/plugin-starter/.gitignore +66 -0
- package/templates/plugin-starter/.npmignore +5 -0
- package/templates/plugin-starter/README.md +1 -1
- package/templates/plugin-starter/package.json +11 -3
- package/templates/plugin-starter/src/__tests__/integration.test.ts +13 -13
- package/templates/plugin-starter/src/__tests__/plugin.test.ts +556 -129
- package/templates/plugin-starter/src/__tests__/test-utils.ts +347 -115
- package/templates/plugin-starter/src/plugin.ts +18 -22
- package/templates/project-starter/.gitignore +57 -0
- package/templates/project-starter/.npmignore +11 -0
- package/templates/project-starter/README.md +1 -1
- package/templates/project-starter/package.json +4 -4
- package/templates/project-starter/src/__tests__/env.test.ts +3 -1
- package/templates/project-starter/src/__tests__/file-structure.test.ts +3 -2
- package/templates/project-starter/src/__tests__/integration.test.ts +1 -1
- package/templates/project-starter/tsup.config.ts +2 -1
- package/templates/project-tee-starter/.dockerignore +64 -14
- package/templates/project-tee-starter/.gitignore +57 -0
- package/templates/project-tee-starter/.npmignore +6 -0
- package/templates/project-tee-starter/Dockerfile +9 -5
- package/templates/project-tee-starter/GUIDE.md +103 -42
- package/templates/project-tee-starter/README.md +39 -19
- package/templates/project-tee-starter/__tests__/build-order.test.ts +62 -0
- package/templates/project-tee-starter/__tests__/character.test.ts +19 -17
- package/templates/project-tee-starter/__tests__/config.test.ts +10 -3
- package/templates/project-tee-starter/__tests__/env.test.ts +2 -1
- package/templates/project-tee-starter/__tests__/file-structure.test.ts +14 -3
- package/templates/project-tee-starter/__tests__/frontend.test.ts +459 -0
- package/templates/project-tee-starter/__tests__/plugin.test.ts +4 -2
- package/templates/project-tee-starter/__tests__/routes.test.ts +15 -6
- package/templates/project-tee-starter/__tests__/tee-validation.test.ts +295 -0
- package/templates/project-tee-starter/__tests__/vite-config-utils.ts +39 -0
- package/templates/project-tee-starter/docker-compose.yaml +5 -2
- package/templates/{plugin-starter/dist → project-tee-starter}/index.html +3 -3
- package/templates/project-tee-starter/package.json +34 -14
- package/templates/project-tee-starter/postcss.config.js +3 -0
- package/templates/project-tee-starter/scripts/install-test-deps.js +52 -0
- package/templates/project-tee-starter/scripts/test-all.sh +82 -0
- package/templates/project-tee-starter/src/frontend/index.css +106 -0
- package/templates/project-tee-starter/src/frontend/index.html +20 -0
- package/templates/project-tee-starter/src/frontend/index.tsx +370 -0
- package/templates/project-tee-starter/src/frontend/panels.tsx +17 -0
- package/templates/project-tee-starter/src/frontend/utils.ts +6 -0
- package/templates/project-tee-starter/src/index.ts +6 -6
- package/templates/project-tee-starter/src/plugin.ts +209 -59
- package/templates/project-tee-starter/tailwind.config.js +62 -0
- package/templates/project-tee-starter/tsconfig.build.json +2 -2
- package/templates/project-tee-starter/tsconfig.json +8 -5
- package/templates/project-tee-starter/tsup.config.ts +3 -2
- package/templates/project-tee-starter/vite.config.ts +39 -0
- package/dist/chunk-4O6EZU37.js +0 -14
- package/dist/migration-guides/advanced-migration-guide.md +0 -459
- package/dist/migration-guides/completion-requirements.md +0 -379
- package/dist/migration-guides/integrated-migration-loop.md +0 -392
- package/dist/migration-guides/migration-guide.md +0 -712
- package/dist/migration-guides/prompt-and-generation-guide.md +0 -702
- package/dist/migration-guides/state-and-providers-guide.md +0 -544
- package/dist/migration-guides/testing-guide.md +0 -1021
- package/dist/templates/plugin-starter/dist/assets/index-CgkejLs_.css +0 -1
- package/dist/templates/plugin-starter/dist/assets/index-D1cHX53P.js +0 -49
- package/dist/templates/plugin-starter/dist/index.js +0 -387
- package/dist/templates/plugin-starter/dist/index.js.map +0 -1
- package/templates/plugin-starter/dist/.vite/manifest.json +0 -11
- package/templates/plugin-starter/dist/assets/index-CgkejLs_.css +0 -1
- package/templates/plugin-starter/dist/assets/index-D1cHX53P.js +0 -49
- package/templates/plugin-starter/dist/index.d.ts +0 -14
- package/templates/plugin-starter/dist/index.js +0 -387
- package/templates/plugin-starter/dist/index.js.map +0 -1
package/dist/index.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
#!/usr/bin/env bun
|
|
2
2
|
import {
|
|
3
3
|
create
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-T2QDIXGU.js";
|
|
5
5
|
import {
|
|
6
6
|
getElizaCharacter
|
|
7
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-5GUS4CFO.js";
|
|
8
8
|
import {
|
|
9
9
|
TestRunner,
|
|
10
10
|
UserEnvironment,
|
|
@@ -38,18 +38,19 @@ import {
|
|
|
38
38
|
provideLocalPluginGuidance,
|
|
39
39
|
publishToGitHub,
|
|
40
40
|
resolvePgliteDir,
|
|
41
|
+
runBunWithSpinner,
|
|
41
42
|
saveRegistrySettings,
|
|
42
43
|
testPublishToGitHub,
|
|
43
44
|
testPublishToNpm,
|
|
44
45
|
tryDelegateToLocalCli,
|
|
45
46
|
validateDataDir
|
|
46
|
-
} from "./chunk-
|
|
47
|
+
} from "./chunk-E6XYTE3A.js";
|
|
47
48
|
import {
|
|
48
49
|
configureEmojis,
|
|
49
50
|
emoji,
|
|
50
51
|
runBunCommand
|
|
51
52
|
} from "./chunk-FDEDLANP.js";
|
|
52
|
-
import "./chunk-
|
|
53
|
+
import "./chunk-GXWWPFBO.js";
|
|
53
54
|
import {
|
|
54
55
|
bunExec,
|
|
55
56
|
bunExecInherit,
|
|
@@ -263,8 +264,8 @@ async function getLocalCliPath() {
|
|
|
263
264
|
"index.js"
|
|
264
265
|
);
|
|
265
266
|
try {
|
|
266
|
-
const
|
|
267
|
-
return
|
|
267
|
+
const fs15 = await import("fs");
|
|
268
|
+
return fs15.existsSync(localCliPath) ? localCliPath : null;
|
|
268
269
|
} catch {
|
|
269
270
|
return null;
|
|
270
271
|
}
|
|
@@ -410,10 +411,95 @@ async function stopServer() {
|
|
|
410
411
|
return stopServerProcess();
|
|
411
412
|
}
|
|
412
413
|
|
|
413
|
-
// src/
|
|
414
|
+
// src/utils/dependency-manager.ts
|
|
415
|
+
import * as fs from "fs";
|
|
416
|
+
import * as path4 from "path";
|
|
414
417
|
import { logger } from "@elizaos/core";
|
|
418
|
+
function hasElizaOSCli(packageJsonPath) {
|
|
419
|
+
try {
|
|
420
|
+
if (!fs.existsSync(packageJsonPath)) {
|
|
421
|
+
return false;
|
|
422
|
+
}
|
|
423
|
+
let packageJson;
|
|
424
|
+
try {
|
|
425
|
+
packageJson = JSON.parse(fs.readFileSync(packageJsonPath, "utf8"));
|
|
426
|
+
} catch (parseError) {
|
|
427
|
+
logger.debug(`Error parsing JSON in package.json at ${packageJsonPath}:`, parseError);
|
|
428
|
+
return false;
|
|
429
|
+
}
|
|
430
|
+
const dependencies = packageJson.dependencies || {};
|
|
431
|
+
const devDependencies = packageJson.devDependencies || {};
|
|
432
|
+
return "@elizaos/cli" in dependencies || "@elizaos/cli" in devDependencies;
|
|
433
|
+
} catch (error) {
|
|
434
|
+
logger.debug(`Error reading package.json at ${packageJsonPath}:`, error);
|
|
435
|
+
return false;
|
|
436
|
+
}
|
|
437
|
+
}
|
|
438
|
+
function shouldAutoInstallCli(cwd = process.cwd()) {
|
|
439
|
+
if (process.env.ELIZA_NO_AUTO_INSTALL === "true") {
|
|
440
|
+
logger.debug("Auto-install disabled via ELIZA_NO_AUTO_INSTALL");
|
|
441
|
+
return false;
|
|
442
|
+
}
|
|
443
|
+
if (process.env.CI === "true" || process.env.ELIZA_TEST_MODE === "true") {
|
|
444
|
+
logger.debug("Skipping auto-install in CI/test environment");
|
|
445
|
+
return false;
|
|
446
|
+
}
|
|
447
|
+
const dirInfo = detectDirectoryType(cwd);
|
|
448
|
+
if (dirInfo.type === "elizaos-monorepo" || dirInfo.monorepoRoot) {
|
|
449
|
+
logger.debug("Skipping auto-install in monorepo");
|
|
450
|
+
return false;
|
|
451
|
+
}
|
|
452
|
+
if (!dirInfo.hasPackageJson) {
|
|
453
|
+
logger.debug("No package.json found, skipping auto-install");
|
|
454
|
+
return false;
|
|
455
|
+
}
|
|
456
|
+
const packageJsonPath = path4.join(cwd, "package.json");
|
|
457
|
+
if (hasElizaOSCli(packageJsonPath)) {
|
|
458
|
+
logger.debug("@elizaos/cli already present, skipping auto-install");
|
|
459
|
+
return false;
|
|
460
|
+
}
|
|
461
|
+
return true;
|
|
462
|
+
}
|
|
463
|
+
async function installElizaOSCli(cwd = process.cwd()) {
|
|
464
|
+
try {
|
|
465
|
+
logger.info("Adding @elizaos/cli as dev dependency for enhanced development experience...");
|
|
466
|
+
const result = await runBunWithSpinner(["add", "--dev", "@elizaos/cli"], cwd, {
|
|
467
|
+
spinnerText: "Installing @elizaos/cli with bun...",
|
|
468
|
+
successText: "\u2713 @elizaos/cli installed successfully",
|
|
469
|
+
errorText: "Failed to install @elizaos/cli",
|
|
470
|
+
showOutputOnError: false
|
|
471
|
+
// Don't show verbose output for this
|
|
472
|
+
});
|
|
473
|
+
if (result.success) {
|
|
474
|
+
logger.info("\u2713 @elizaos/cli added as dev dependency");
|
|
475
|
+
return true;
|
|
476
|
+
} else {
|
|
477
|
+
logger.warn("\u26A0 Failed to install @elizaos/cli as dev dependency (optional)");
|
|
478
|
+
logger.debug("Installation error:", result.error);
|
|
479
|
+
return false;
|
|
480
|
+
}
|
|
481
|
+
} catch (error) {
|
|
482
|
+
logger.warn("\u26A0 Failed to install @elizaos/cli as dev dependency (optional)");
|
|
483
|
+
logger.debug("Installation error:", error);
|
|
484
|
+
return false;
|
|
485
|
+
}
|
|
486
|
+
}
|
|
487
|
+
async function ensureElizaOSCli(cwd = process.cwd()) {
|
|
488
|
+
if (!shouldAutoInstallCli(cwd)) {
|
|
489
|
+
return;
|
|
490
|
+
}
|
|
491
|
+
logger.debug("Auto-installing @elizaos/cli for enhanced development experience");
|
|
492
|
+
const success = await installElizaOSCli(cwd);
|
|
493
|
+
if (success) {
|
|
494
|
+
logger.info("Next time you can use the local CLI for better performance and consistency");
|
|
495
|
+
}
|
|
496
|
+
}
|
|
497
|
+
|
|
498
|
+
// src/commands/dev/actions/dev-server.ts
|
|
499
|
+
import { logger as logger2 } from "@elizaos/core";
|
|
415
500
|
async function startDevMode(options) {
|
|
416
501
|
const cwd = process.cwd();
|
|
502
|
+
await ensureElizaOSCli(cwd);
|
|
417
503
|
const context = createDevContext(cwd);
|
|
418
504
|
const serverManager2 = getServerManager();
|
|
419
505
|
const { directoryType } = context;
|
|
@@ -444,13 +530,13 @@ async function startDevMode(options) {
|
|
|
444
530
|
try {
|
|
445
531
|
availablePort = await findNextAvailablePort(desiredPort);
|
|
446
532
|
if (availablePort !== desiredPort) {
|
|
447
|
-
|
|
533
|
+
logger2.warn(`Port ${desiredPort} is in use, using port ${availablePort} instead`);
|
|
448
534
|
}
|
|
449
535
|
} catch (error) {
|
|
450
|
-
|
|
536
|
+
logger2.error(
|
|
451
537
|
`Failed to find available port starting from ${desiredPort}: ${error instanceof Error ? error.message : String(error)}`
|
|
452
538
|
);
|
|
453
|
-
|
|
539
|
+
logger2.error("Please specify a different port using --port option");
|
|
454
540
|
throw new Error(`No available ports found starting from ${desiredPort}`);
|
|
455
541
|
}
|
|
456
542
|
cliArgs.push("--port", availablePort.toString());
|
|
@@ -524,15 +610,15 @@ import colors3 from "yoctocolors";
|
|
|
524
610
|
|
|
525
611
|
// src/commands/env/actions/edit.ts
|
|
526
612
|
import * as clack from "@clack/prompts";
|
|
527
|
-
import { existsSync as
|
|
528
|
-
import
|
|
613
|
+
import { existsSync as existsSync5 } from "fs";
|
|
614
|
+
import path6 from "path";
|
|
529
615
|
|
|
530
616
|
// src/commands/env/utils/file-operations.ts
|
|
531
|
-
import { existsSync as
|
|
532
|
-
import
|
|
617
|
+
import { existsSync as existsSync4 } from "fs";
|
|
618
|
+
import path5 from "path";
|
|
533
619
|
async function getLocalEnvPath() {
|
|
534
|
-
const localEnvPath =
|
|
535
|
-
return
|
|
620
|
+
const localEnvPath = path5.join(process.cwd(), ".env");
|
|
621
|
+
return existsSync4(localEnvPath) ? localEnvPath : null;
|
|
536
622
|
}
|
|
537
623
|
async function parseEnvFile(filePath) {
|
|
538
624
|
const service = createEnvFileService(filePath);
|
|
@@ -547,7 +633,7 @@ async function writeEnvFile(filePath, envVars) {
|
|
|
547
633
|
}
|
|
548
634
|
async function resetEnvFile(filePath) {
|
|
549
635
|
try {
|
|
550
|
-
if (!
|
|
636
|
+
if (!existsSync4(filePath)) {
|
|
551
637
|
return false;
|
|
552
638
|
}
|
|
553
639
|
const service = createEnvFileService(filePath);
|
|
@@ -586,9 +672,9 @@ function maskedValue(value) {
|
|
|
586
672
|
async function editEnvVars(options, fromMainMenu = false) {
|
|
587
673
|
const { yes } = options;
|
|
588
674
|
const localEnvPath = await getLocalEnvPath();
|
|
589
|
-
if (!localEnvPath || !
|
|
590
|
-
const exampleEnvPath =
|
|
591
|
-
const hasExample =
|
|
675
|
+
if (!localEnvPath || !existsSync5(localEnvPath)) {
|
|
676
|
+
const exampleEnvPath = path6.join(process.cwd(), ".env.example");
|
|
677
|
+
const hasExample = existsSync5(exampleEnvPath);
|
|
592
678
|
if (hasExample) {
|
|
593
679
|
console.log("No local .env file found. Create one with:");
|
|
594
680
|
console.log(" cp .env.example .env");
|
|
@@ -739,8 +825,8 @@ async function addNewVariable(envPath, envVars, yes = false) {
|
|
|
739
825
|
import * as clack3 from "@clack/prompts";
|
|
740
826
|
|
|
741
827
|
// src/commands/env/actions/list.ts
|
|
742
|
-
import { existsSync as
|
|
743
|
-
import
|
|
828
|
+
import { existsSync as existsSync6 } from "fs";
|
|
829
|
+
import path7 from "path";
|
|
744
830
|
import colors from "yoctocolors";
|
|
745
831
|
async function listEnvVars() {
|
|
746
832
|
const envInfo = await UserEnvironment.getInstanceInfo();
|
|
@@ -753,11 +839,11 @@ async function listEnvVars() {
|
|
|
753
839
|
);
|
|
754
840
|
console.info(colors.bold("\nLocal Environment Variables:"));
|
|
755
841
|
const localEnvFilePath = await getLocalEnvPath();
|
|
756
|
-
console.info(`Path: ${localEnvFilePath ??
|
|
757
|
-
if (!localEnvFilePath || !
|
|
842
|
+
console.info(`Path: ${localEnvFilePath ?? path7.join(process.cwd(), ".env")}`);
|
|
843
|
+
if (!localEnvFilePath || !existsSync6(localEnvFilePath)) {
|
|
758
844
|
console.info(colors.yellow(" No local .env file found"));
|
|
759
|
-
const exampleEnvPath =
|
|
760
|
-
if (
|
|
845
|
+
const exampleEnvPath = path7.join(process.cwd(), ".env.example");
|
|
846
|
+
if (existsSync6(exampleEnvPath)) {
|
|
761
847
|
console.info(colors.red(" [X] Missing .env file. Create one with:"));
|
|
762
848
|
console.info(` ${colors.bold(colors.green("cp .env.example .env"))}`);
|
|
763
849
|
} else {
|
|
@@ -797,7 +883,7 @@ async function handleListCommand(options) {
|
|
|
797
883
|
} else if (options.local) {
|
|
798
884
|
console.info(colors.bold("\nLocal Environment Variables:"));
|
|
799
885
|
const localEnvPath = await getLocalEnvPath();
|
|
800
|
-
if (!localEnvPath || !
|
|
886
|
+
if (!localEnvPath || !existsSync6(localEnvPath)) {
|
|
801
887
|
console.info(" No local .env file found in the current directory");
|
|
802
888
|
return;
|
|
803
889
|
}
|
|
@@ -816,21 +902,21 @@ async function handleListCommand(options) {
|
|
|
816
902
|
|
|
817
903
|
// src/commands/env/actions/reset.ts
|
|
818
904
|
import * as clack2 from "@clack/prompts";
|
|
819
|
-
import { existsSync as
|
|
820
|
-
import
|
|
905
|
+
import { existsSync as existsSync8 } from "fs";
|
|
906
|
+
import path8 from "path";
|
|
821
907
|
import colors2 from "yoctocolors";
|
|
822
908
|
|
|
823
909
|
// src/commands/env/utils/directory-operations.ts
|
|
824
|
-
import { existsSync as
|
|
910
|
+
import { existsSync as existsSync7 } from "fs";
|
|
825
911
|
import { rimraf } from "rimraf";
|
|
826
912
|
async function safeDeleteDirectory(dir, actions, label) {
|
|
827
|
-
if (!
|
|
913
|
+
if (!existsSync7(dir)) {
|
|
828
914
|
actions.skipped.push(`${label} (not found)`);
|
|
829
915
|
return false;
|
|
830
916
|
}
|
|
831
917
|
try {
|
|
832
918
|
await rimraf(dir);
|
|
833
|
-
if (!
|
|
919
|
+
if (!existsSync7(dir)) {
|
|
834
920
|
actions.deleted.push(label);
|
|
835
921
|
return true;
|
|
836
922
|
} else {
|
|
@@ -845,36 +931,36 @@ async function safeDeleteDirectory(dir, actions, label) {
|
|
|
845
931
|
|
|
846
932
|
// src/commands/env/actions/reset.ts
|
|
847
933
|
async function resolvePgliteDir2() {
|
|
848
|
-
return
|
|
934
|
+
return path8.join(process.cwd(), ".eliza", "db");
|
|
849
935
|
}
|
|
850
936
|
async function resetEnv(options) {
|
|
851
937
|
const { yes } = options;
|
|
852
|
-
const elizaDir =
|
|
853
|
-
const cacheDir =
|
|
854
|
-
const localEnvPath = await getLocalEnvPath() ??
|
|
938
|
+
const elizaDir = path8.join(process.cwd(), ".eliza");
|
|
939
|
+
const cacheDir = path8.join(elizaDir, "cache");
|
|
940
|
+
const localEnvPath = await getLocalEnvPath() ?? path8.join(process.cwd(), ".env");
|
|
855
941
|
const localDbDir = await resolvePgliteDir2();
|
|
856
942
|
const resetItems = [
|
|
857
943
|
{
|
|
858
944
|
title: "Local environment variables",
|
|
859
945
|
value: "localEnv",
|
|
860
|
-
description:
|
|
861
|
-
selected:
|
|
946
|
+
description: existsSync8(localEnvPath) ? "Reset values in local .env file" : "Local .env file not found, nothing to reset",
|
|
947
|
+
selected: existsSync8(localEnvPath)
|
|
862
948
|
},
|
|
863
949
|
{
|
|
864
950
|
title: "Cache folder",
|
|
865
951
|
value: "cache",
|
|
866
|
-
description:
|
|
867
|
-
selected:
|
|
952
|
+
description: existsSync8(cacheDir) ? "Delete the cache folder" : "Cache folder not found, nothing to delete",
|
|
953
|
+
selected: existsSync8(cacheDir)
|
|
868
954
|
},
|
|
869
955
|
{
|
|
870
956
|
title: "Local database files",
|
|
871
957
|
value: "localDb",
|
|
872
|
-
description:
|
|
873
|
-
selected:
|
|
958
|
+
description: existsSync8(localDbDir) ? "Delete local database files" : "Local database folder not found, nothing to delete",
|
|
959
|
+
selected: existsSync8(localDbDir)
|
|
874
960
|
}
|
|
875
961
|
];
|
|
876
962
|
const validResetItems = resetItems.filter(
|
|
877
|
-
(item) => item.value === "localEnv" &&
|
|
963
|
+
(item) => item.value === "localEnv" && existsSync8(localEnvPath) || item.value === "cache" && existsSync8(cacheDir) || item.value === "localDb" && existsSync8(localDbDir)
|
|
878
964
|
);
|
|
879
965
|
let selectedValues = [];
|
|
880
966
|
if (yes) {
|
|
@@ -1052,7 +1138,7 @@ env.action(() => {
|
|
|
1052
1138
|
import { Command as Command3 } from "commander";
|
|
1053
1139
|
|
|
1054
1140
|
// src/commands/plugins/actions/install.ts
|
|
1055
|
-
import { logger as
|
|
1141
|
+
import { logger as logger5 } from "@elizaos/core";
|
|
1056
1142
|
|
|
1057
1143
|
// src/commands/plugins/utils/naming.ts
|
|
1058
1144
|
var findPluginPackageName = (pluginInput, allDependencies) => {
|
|
@@ -1094,55 +1180,55 @@ var extractPackageName = (pluginInput) => {
|
|
|
1094
1180
|
};
|
|
1095
1181
|
|
|
1096
1182
|
// src/commands/plugins/utils/env-vars.ts
|
|
1097
|
-
import { logger as
|
|
1098
|
-
import { existsSync as
|
|
1099
|
-
import
|
|
1183
|
+
import { logger as logger3 } from "@elizaos/core";
|
|
1184
|
+
import { existsSync as existsSync9, readFileSync as readFileSync2, readdirSync as readdirSync2 } from "fs";
|
|
1185
|
+
import path9 from "path";
|
|
1100
1186
|
import * as clack4 from "@clack/prompts";
|
|
1101
1187
|
var extractPluginEnvRequirements = async (packageName, cwd) => {
|
|
1102
1188
|
try {
|
|
1103
1189
|
const possiblePaths = [
|
|
1104
1190
|
// Direct path
|
|
1105
|
-
|
|
1191
|
+
path9.join(cwd, "node_modules", packageName, "package.json"),
|
|
1106
1192
|
// Scoped package path (e.g., @elizaos/plugin-discord)
|
|
1107
|
-
|
|
1193
|
+
path9.join(cwd, "node_modules", packageName.replace("/", path9.sep), "package.json")
|
|
1108
1194
|
];
|
|
1109
1195
|
if (!packageName.startsWith("@elizaos/")) {
|
|
1110
1196
|
possiblePaths.push(
|
|
1111
|
-
|
|
1112
|
-
|
|
1197
|
+
path9.join(cwd, "node_modules", "@elizaos", packageName, "package.json"),
|
|
1198
|
+
path9.join(cwd, "node_modules", "@elizaos", `plugin-${packageName}`, "package.json")
|
|
1113
1199
|
);
|
|
1114
1200
|
}
|
|
1115
1201
|
let currentDir = cwd;
|
|
1116
1202
|
for (let i = 0; i < 5; i++) {
|
|
1117
|
-
const parentNodeModules =
|
|
1118
|
-
if (
|
|
1203
|
+
const parentNodeModules = path9.join(currentDir, "node_modules");
|
|
1204
|
+
if (existsSync9(parentNodeModules)) {
|
|
1119
1205
|
possiblePaths.push(
|
|
1120
|
-
|
|
1121
|
-
|
|
1206
|
+
path9.join(parentNodeModules, packageName, "package.json"),
|
|
1207
|
+
path9.join(parentNodeModules, packageName.replace("/", path9.sep), "package.json")
|
|
1122
1208
|
);
|
|
1123
1209
|
}
|
|
1124
|
-
const parentDir =
|
|
1210
|
+
const parentDir = path9.dirname(currentDir);
|
|
1125
1211
|
if (parentDir === currentDir) break;
|
|
1126
1212
|
currentDir = parentDir;
|
|
1127
1213
|
}
|
|
1128
1214
|
let packageJsonPath = null;
|
|
1129
1215
|
for (const possiblePath of possiblePaths) {
|
|
1130
|
-
if (
|
|
1216
|
+
if (existsSync9(possiblePath)) {
|
|
1131
1217
|
packageJsonPath = possiblePath;
|
|
1132
|
-
|
|
1218
|
+
logger3.debug(`Found plugin package.json at: ${packageJsonPath}`);
|
|
1133
1219
|
break;
|
|
1134
1220
|
}
|
|
1135
1221
|
}
|
|
1136
1222
|
if (!packageJsonPath) {
|
|
1137
|
-
const nodeModulesPath =
|
|
1138
|
-
if (
|
|
1223
|
+
const nodeModulesPath = path9.join(cwd, "node_modules");
|
|
1224
|
+
if (existsSync9(nodeModulesPath)) {
|
|
1139
1225
|
const packages = readdirSync2(nodeModulesPath);
|
|
1140
1226
|
for (const pkg of packages) {
|
|
1141
1227
|
if (pkg.includes(packageName.replace("@elizaos/", "").replace("plugin-", ""))) {
|
|
1142
|
-
const pkgJsonPath =
|
|
1143
|
-
if (
|
|
1228
|
+
const pkgJsonPath = path9.join(nodeModulesPath, pkg, "package.json");
|
|
1229
|
+
if (existsSync9(pkgJsonPath)) {
|
|
1144
1230
|
packageJsonPath = pkgJsonPath;
|
|
1145
|
-
|
|
1231
|
+
logger3.debug(`Found matching plugin package.json at: ${packageJsonPath}`);
|
|
1146
1232
|
break;
|
|
1147
1233
|
}
|
|
1148
1234
|
}
|
|
@@ -1150,30 +1236,30 @@ var extractPluginEnvRequirements = async (packageName, cwd) => {
|
|
|
1150
1236
|
}
|
|
1151
1237
|
}
|
|
1152
1238
|
if (!packageJsonPath) {
|
|
1153
|
-
|
|
1154
|
-
|
|
1239
|
+
logger3.debug(`Plugin package.json not found for: ${packageName}`);
|
|
1240
|
+
logger3.debug(`Searched paths: ${possiblePaths.join(", ")}`);
|
|
1155
1241
|
return {};
|
|
1156
1242
|
}
|
|
1157
|
-
const packageJsonContent =
|
|
1243
|
+
const packageJsonContent = readFileSync2(packageJsonPath, "utf-8");
|
|
1158
1244
|
const packageJson = JSON.parse(packageJsonContent);
|
|
1159
1245
|
const agentConfig = packageJson.agentConfig;
|
|
1160
1246
|
if (!agentConfig || !agentConfig.pluginParameters) {
|
|
1161
|
-
|
|
1247
|
+
logger3.debug(`No agentConfig.pluginParameters found in ${packageName} at ${packageJsonPath}`);
|
|
1162
1248
|
return {};
|
|
1163
1249
|
}
|
|
1164
|
-
|
|
1250
|
+
logger3.debug(
|
|
1165
1251
|
`Found environment variables for ${packageName}: ${Object.keys(agentConfig.pluginParameters).join(", ")}`
|
|
1166
1252
|
);
|
|
1167
1253
|
return agentConfig.pluginParameters;
|
|
1168
1254
|
} catch (error) {
|
|
1169
|
-
|
|
1255
|
+
logger3.debug(
|
|
1170
1256
|
`Error reading plugin package.json for ${packageName}: ${error instanceof Error ? error.message : String(error)}`
|
|
1171
1257
|
);
|
|
1172
1258
|
return {};
|
|
1173
1259
|
}
|
|
1174
1260
|
};
|
|
1175
1261
|
var readEnvFile = async (cwd) => {
|
|
1176
|
-
const envPath =
|
|
1262
|
+
const envPath = path9.join(cwd, ".env");
|
|
1177
1263
|
const envService = createEnvFileService(envPath);
|
|
1178
1264
|
return envService.read();
|
|
1179
1265
|
};
|
|
@@ -1360,7 +1446,7 @@ var promptForEnvVar = async (varName, config2) => {
|
|
|
1360
1446
|
return finalValue.trim();
|
|
1361
1447
|
};
|
|
1362
1448
|
var updateEnvFile = async (cwd, varName, value) => {
|
|
1363
|
-
const envPath =
|
|
1449
|
+
const envPath = path9.join(cwd, ".env");
|
|
1364
1450
|
const envService = createEnvFileService(envPath);
|
|
1365
1451
|
await envService.update(varName, value, {
|
|
1366
1452
|
preserveComments: true,
|
|
@@ -1378,7 +1464,7 @@ var promptForPluginEnvVars = async (packageName, cwd) => {
|
|
|
1378
1464
|
}
|
|
1379
1465
|
}
|
|
1380
1466
|
if (Object.keys(envRequirements).length === 0) {
|
|
1381
|
-
const nodeModulesPath =
|
|
1467
|
+
const nodeModulesPath = path9.join(cwd, "node_modules");
|
|
1382
1468
|
const possiblePackages = [
|
|
1383
1469
|
packageName,
|
|
1384
1470
|
`@elizaos/${packageName.replace("plugin-", "")}`,
|
|
@@ -1386,17 +1472,17 @@ var promptForPluginEnvVars = async (packageName, cwd) => {
|
|
|
1386
1472
|
];
|
|
1387
1473
|
let packageFound = false;
|
|
1388
1474
|
for (const pkg of possiblePackages) {
|
|
1389
|
-
const pkgPath =
|
|
1390
|
-
if (
|
|
1475
|
+
const pkgPath = path9.join(nodeModulesPath, ...pkg.split("/"));
|
|
1476
|
+
if (existsSync9(path9.join(pkgPath, "package.json"))) {
|
|
1391
1477
|
packageFound = true;
|
|
1392
1478
|
break;
|
|
1393
1479
|
}
|
|
1394
1480
|
}
|
|
1395
1481
|
if (packageFound) {
|
|
1396
|
-
|
|
1482
|
+
logger3.debug(`Package ${packageName} found but has no environment variables defined`);
|
|
1397
1483
|
clack4.log.success(`No environment variables required for ${packageName}`);
|
|
1398
1484
|
} else {
|
|
1399
|
-
|
|
1485
|
+
logger3.debug(`Package ${packageName} not found in node_modules`);
|
|
1400
1486
|
clack4.log.warn(
|
|
1401
1487
|
`Could not find ${packageName} in node_modules. Environment variables may need to be configured manually.`
|
|
1402
1488
|
);
|
|
@@ -1537,26 +1623,26 @@ Restart your application after adding the variables.`
|
|
|
1537
1623
|
};
|
|
1538
1624
|
|
|
1539
1625
|
// src/commands/plugins/utils/directory.ts
|
|
1540
|
-
import { logger as
|
|
1541
|
-
import { readFileSync as
|
|
1542
|
-
import
|
|
1626
|
+
import { logger as logger4 } from "@elizaos/core";
|
|
1627
|
+
import { readFileSync as readFileSync3 } from "fs";
|
|
1628
|
+
import path10 from "path";
|
|
1543
1629
|
var getDependenciesFromDirectory = (cwd) => {
|
|
1544
1630
|
const directoryInfo = detectDirectoryType(cwd);
|
|
1545
1631
|
if (!directoryInfo.hasPackageJson) {
|
|
1546
1632
|
return null;
|
|
1547
1633
|
}
|
|
1548
1634
|
try {
|
|
1549
|
-
const packageJsonPath =
|
|
1550
|
-
const packageJsonContent =
|
|
1635
|
+
const packageJsonPath = path10.join(cwd, "package.json");
|
|
1636
|
+
const packageJsonContent = readFileSync3(packageJsonPath, "utf-8");
|
|
1551
1637
|
const packageJson = JSON.parse(packageJsonContent);
|
|
1552
1638
|
const dependencies = packageJson.dependencies || {};
|
|
1553
1639
|
const devDependencies = packageJson.devDependencies || {};
|
|
1554
1640
|
return { ...dependencies, ...devDependencies };
|
|
1555
1641
|
} catch (error) {
|
|
1556
1642
|
if (error instanceof SyntaxError) {
|
|
1557
|
-
|
|
1643
|
+
logger4.warn(`Could not parse package.json: ${error.message}`);
|
|
1558
1644
|
} else {
|
|
1559
|
-
|
|
1645
|
+
logger4.warn(
|
|
1560
1646
|
`Error reading package.json: ${error instanceof Error ? error.message : String(error)}`
|
|
1561
1647
|
);
|
|
1562
1648
|
}
|
|
@@ -1591,7 +1677,7 @@ async function installPluginFromGitHub(plugin, cwd, opts) {
|
|
|
1591
1677
|
const pluginNameForPostInstall = repo;
|
|
1592
1678
|
const success = await installPlugin(githubSpecifier, cwd, void 0, opts.skipVerification);
|
|
1593
1679
|
if (success) {
|
|
1594
|
-
|
|
1680
|
+
logger5.info(`Successfully installed ${pluginNameForPostInstall} from ${githubSpecifier}.`);
|
|
1595
1681
|
const packageName = extractPackageName(plugin);
|
|
1596
1682
|
if (!opts.skipEnvPrompt) {
|
|
1597
1683
|
await new Promise((resolve2) => setTimeout(resolve2, 500));
|
|
@@ -1600,7 +1686,7 @@ async function installPluginFromGitHub(plugin, cwd, opts) {
|
|
|
1600
1686
|
try {
|
|
1601
1687
|
await promptForPluginEnvVars(packageName, cwd);
|
|
1602
1688
|
} catch (error) {
|
|
1603
|
-
|
|
1689
|
+
logger5.warn(
|
|
1604
1690
|
`Warning: Could not prompt for environment variables: ${error instanceof Error ? error.message : String(error)}`
|
|
1605
1691
|
);
|
|
1606
1692
|
}
|
|
@@ -1611,14 +1697,14 @@ async function installPluginFromGitHub(plugin, cwd, opts) {
|
|
|
1611
1697
|
showInstallationSuccess(packageName);
|
|
1612
1698
|
process.exit(0);
|
|
1613
1699
|
} else {
|
|
1614
|
-
|
|
1700
|
+
logger5.error(`Failed to install plugin from ${githubSpecifier}.`);
|
|
1615
1701
|
process.exit(1);
|
|
1616
1702
|
}
|
|
1617
1703
|
}
|
|
1618
1704
|
async function installPluginFromRegistry(plugin, cwd, opts) {
|
|
1619
1705
|
const cachedRegistry = await fetchPluginRegistry();
|
|
1620
1706
|
if (!cachedRegistry || !cachedRegistry.registry) {
|
|
1621
|
-
|
|
1707
|
+
logger5.error('Plugin registry cache not found. Please run "elizaos plugins update" first.');
|
|
1622
1708
|
process.exit(1);
|
|
1623
1709
|
}
|
|
1624
1710
|
const possibleNames = normalizePluginName(plugin);
|
|
@@ -1641,7 +1727,7 @@ async function installPluginFromRegistry(plugin, cwd, opts) {
|
|
|
1641
1727
|
try {
|
|
1642
1728
|
await promptForPluginEnvVars(actualPackageName, cwd);
|
|
1643
1729
|
} catch (error) {
|
|
1644
|
-
|
|
1730
|
+
logger5.warn(
|
|
1645
1731
|
`Warning: Could not prompt for environment variables: ${error instanceof Error ? error.message : String(error)}`
|
|
1646
1732
|
);
|
|
1647
1733
|
}
|
|
@@ -1657,8 +1743,8 @@ async function installPluginFromRegistry(plugin, cwd, opts) {
|
|
|
1657
1743
|
}
|
|
1658
1744
|
async function addPlugin(pluginArg, opts) {
|
|
1659
1745
|
if (!pluginArg || !pluginArg.trim()) {
|
|
1660
|
-
|
|
1661
|
-
|
|
1746
|
+
logger5.error("Plugin name cannot be empty or whitespace-only.");
|
|
1747
|
+
logger5.info(
|
|
1662
1748
|
'Please provide a valid plugin name (e.g., "openai", "plugin-anthropic", "@elizaos/plugin-sql")'
|
|
1663
1749
|
);
|
|
1664
1750
|
process.exit(1);
|
|
@@ -1666,14 +1752,14 @@ async function addPlugin(pluginArg, opts) {
|
|
|
1666
1752
|
const cwd = process.cwd();
|
|
1667
1753
|
const directoryInfo = detectDirectoryType(cwd);
|
|
1668
1754
|
if (!directoryInfo || !directoryInfo.hasPackageJson) {
|
|
1669
|
-
|
|
1755
|
+
logger5.error(
|
|
1670
1756
|
`Command must be run inside an ElizaOS project directory. This directory is: ${directoryInfo?.type || "invalid or inaccessible"}`
|
|
1671
1757
|
);
|
|
1672
1758
|
process.exit(1);
|
|
1673
1759
|
}
|
|
1674
1760
|
const allDependencies = getDependenciesFromDirectory(cwd);
|
|
1675
1761
|
if (!allDependencies) {
|
|
1676
|
-
|
|
1762
|
+
logger5.error("Could not read dependencies from package.json");
|
|
1677
1763
|
process.exit(1);
|
|
1678
1764
|
}
|
|
1679
1765
|
let plugin = pluginArg;
|
|
@@ -1688,7 +1774,7 @@ async function addPlugin(pluginArg, opts) {
|
|
|
1688
1774
|
}
|
|
1689
1775
|
const installedPluginName = findPluginPackageName(plugin, allDependencies);
|
|
1690
1776
|
if (installedPluginName) {
|
|
1691
|
-
|
|
1777
|
+
logger5.info(`Plugin "${installedPluginName}" is already added to this project.`);
|
|
1692
1778
|
process.exit(0);
|
|
1693
1779
|
}
|
|
1694
1780
|
const githubRegex = /^(?:github:)?([a-zA-Z0-9_-]+)\/([a-zA-Z0-9_.-]+)(?:#([a-zA-Z0-9_.-]+))?$/;
|
|
@@ -1700,9 +1786,9 @@ async function addPlugin(pluginArg, opts) {
|
|
|
1700
1786
|
}
|
|
1701
1787
|
|
|
1702
1788
|
// src/commands/plugins/actions/remove.ts
|
|
1703
|
-
import { logger as
|
|
1704
|
-
import { existsSync as
|
|
1705
|
-
import
|
|
1789
|
+
import { logger as logger6 } from "@elizaos/core";
|
|
1790
|
+
import { existsSync as existsSync10, rmSync } from "fs";
|
|
1791
|
+
import path11 from "path";
|
|
1706
1792
|
async function removePlugin(plugin) {
|
|
1707
1793
|
const cwd = process.cwd();
|
|
1708
1794
|
const directoryInfo = detectDirectoryType(cwd);
|
|
@@ -1721,7 +1807,7 @@ async function removePlugin(plugin) {
|
|
|
1721
1807
|
}
|
|
1722
1808
|
const packageNameToRemove = findPluginPackageName(plugin, allDependencies);
|
|
1723
1809
|
if (!packageNameToRemove) {
|
|
1724
|
-
|
|
1810
|
+
logger6.warn(`Plugin matching "${plugin}" not found in project dependencies.`);
|
|
1725
1811
|
console.info("\nCheck installed plugins using: elizaos plugins installed-plugins");
|
|
1726
1812
|
process.exit(0);
|
|
1727
1813
|
}
|
|
@@ -1731,11 +1817,11 @@ async function removePlugin(plugin) {
|
|
|
1731
1817
|
cwd
|
|
1732
1818
|
});
|
|
1733
1819
|
} catch (execError) {
|
|
1734
|
-
|
|
1820
|
+
logger6.error(
|
|
1735
1821
|
`Failed to run 'bun remove ${packageNameToRemove}': ${execError instanceof Error ? execError.message : String(execError)}`
|
|
1736
1822
|
);
|
|
1737
1823
|
if (execError && typeof execError === "object" && "stderr" in execError && typeof execError.stderr === "string" && execError.stderr.includes("not found")) {
|
|
1738
|
-
|
|
1824
|
+
logger6.info(
|
|
1739
1825
|
`'bun remove' indicated package was not found. Continuing with directory removal attempt.`
|
|
1740
1826
|
);
|
|
1741
1827
|
} else {
|
|
@@ -1750,22 +1836,22 @@ async function removePlugin(plugin) {
|
|
|
1750
1836
|
}
|
|
1751
1837
|
baseName = baseName.replace(/^plugin-/, "");
|
|
1752
1838
|
const dirNameToRemove = `plugin-${baseName}`;
|
|
1753
|
-
const pluginDir =
|
|
1754
|
-
if (
|
|
1839
|
+
const pluginDir = path11.join(cwd, dirNameToRemove);
|
|
1840
|
+
if (existsSync10(pluginDir)) {
|
|
1755
1841
|
try {
|
|
1756
1842
|
rmSync(pluginDir, { recursive: true, force: true });
|
|
1757
1843
|
} catch (rmError) {
|
|
1758
|
-
|
|
1844
|
+
logger6.error(
|
|
1759
1845
|
`Failed to remove directory ${pluginDir}: ${rmError instanceof Error ? rmError.message : String(rmError)}`
|
|
1760
1846
|
);
|
|
1761
1847
|
}
|
|
1762
1848
|
} else {
|
|
1763
|
-
const nonPrefixedDir =
|
|
1764
|
-
if (
|
|
1849
|
+
const nonPrefixedDir = path11.join(cwd, baseName);
|
|
1850
|
+
if (existsSync10(nonPrefixedDir)) {
|
|
1765
1851
|
try {
|
|
1766
1852
|
rmSync(nonPrefixedDir, { recursive: true, force: true });
|
|
1767
1853
|
} catch (rmError) {
|
|
1768
|
-
|
|
1854
|
+
logger6.error(
|
|
1769
1855
|
`Failed to remove directory ${nonPrefixedDir}: ${rmError instanceof Error ? rmError.message : String(rmError)}`
|
|
1770
1856
|
);
|
|
1771
1857
|
}
|
|
@@ -1775,11 +1861,11 @@ async function removePlugin(plugin) {
|
|
|
1775
1861
|
}
|
|
1776
1862
|
|
|
1777
1863
|
// src/commands/plugins/actions/list.ts
|
|
1778
|
-
import { logger as
|
|
1864
|
+
import { logger as logger7 } from "@elizaos/core";
|
|
1779
1865
|
async function listAvailablePlugins(opts) {
|
|
1780
1866
|
const cachedRegistry = await fetchPluginRegistry();
|
|
1781
1867
|
if (!cachedRegistry || !cachedRegistry.registry || Object.keys(cachedRegistry.registry).length === 0) {
|
|
1782
|
-
|
|
1868
|
+
logger7.info("Plugin cache is empty or not found.");
|
|
1783
1869
|
console.log('\nPlease run "elizaos plugins update" to fetch the latest plugin registry.');
|
|
1784
1870
|
return;
|
|
1785
1871
|
}
|
|
@@ -1857,20 +1943,20 @@ async function listInstalledPlugins() {
|
|
|
1857
1943
|
}
|
|
1858
1944
|
|
|
1859
1945
|
// src/commands/plugins/actions/upgrade.ts
|
|
1860
|
-
import { logger as
|
|
1861
|
-
import
|
|
1862
|
-
import { existsSync as
|
|
1946
|
+
import { logger as logger10 } from "@elizaos/core";
|
|
1947
|
+
import path13 from "path";
|
|
1948
|
+
import { existsSync as existsSync12 } from "fs";
|
|
1863
1949
|
import { fileURLToPath as fileURLToPath2 } from "url";
|
|
1864
|
-
import
|
|
1950
|
+
import fs2 from "fs-extra";
|
|
1865
1951
|
|
|
1866
1952
|
// src/utils/upgrade/simple-migration-agent.ts
|
|
1867
1953
|
import { query } from "@anthropic-ai/claude-code";
|
|
1868
1954
|
|
|
1869
1955
|
// src/utils/upgrade/migration-guide-loader.ts
|
|
1870
|
-
import { existsSync as
|
|
1871
|
-
import
|
|
1956
|
+
import { existsSync as existsSync11, readFileSync as readFileSync4 } from "fs";
|
|
1957
|
+
import path12 from "path";
|
|
1872
1958
|
import { fileURLToPath } from "url";
|
|
1873
|
-
import { logger as
|
|
1959
|
+
import { logger as logger8 } from "@elizaos/core";
|
|
1874
1960
|
var MigrationGuideLoader = class {
|
|
1875
1961
|
guides = [];
|
|
1876
1962
|
guidesDir;
|
|
@@ -1880,33 +1966,33 @@ var MigrationGuideLoader = class {
|
|
|
1880
1966
|
}
|
|
1881
1967
|
findGuidesDirectory(projectRoot) {
|
|
1882
1968
|
if (projectRoot) {
|
|
1883
|
-
const guidesPath =
|
|
1884
|
-
if (
|
|
1969
|
+
const guidesPath = path12.join(projectRoot, "packages/docs/docs/plugins/migration/claude-code");
|
|
1970
|
+
if (existsSync11(guidesPath)) {
|
|
1885
1971
|
return guidesPath;
|
|
1886
1972
|
}
|
|
1887
1973
|
}
|
|
1888
1974
|
let currentRoot = process.cwd();
|
|
1889
1975
|
let previousRoot = "";
|
|
1890
|
-
while (currentRoot !== previousRoot && !
|
|
1976
|
+
while (currentRoot !== previousRoot && !existsSync11(path12.join(currentRoot, "packages/docs"))) {
|
|
1891
1977
|
previousRoot = currentRoot;
|
|
1892
|
-
currentRoot =
|
|
1978
|
+
currentRoot = path12.dirname(currentRoot);
|
|
1893
1979
|
}
|
|
1894
|
-
const monorepoGuidesPath =
|
|
1980
|
+
const monorepoGuidesPath = path12.join(
|
|
1895
1981
|
currentRoot,
|
|
1896
1982
|
"packages/docs/docs/plugins/migration/claude-code"
|
|
1897
1983
|
);
|
|
1898
|
-
if (
|
|
1984
|
+
if (existsSync11(monorepoGuidesPath)) {
|
|
1899
1985
|
return monorepoGuidesPath;
|
|
1900
1986
|
}
|
|
1901
|
-
const workingDirGuides =
|
|
1902
|
-
if (
|
|
1987
|
+
const workingDirGuides = path12.join(process.cwd(), "migration-guides");
|
|
1988
|
+
if (existsSync11(workingDirGuides)) {
|
|
1903
1989
|
return workingDirGuides;
|
|
1904
1990
|
}
|
|
1905
1991
|
const currentFileUrl = import.meta.url;
|
|
1906
1992
|
const currentFilePath = fileURLToPath(currentFileUrl);
|
|
1907
|
-
const cliPackageRoot =
|
|
1908
|
-
const bundledGuidesPath =
|
|
1909
|
-
if (
|
|
1993
|
+
const cliPackageRoot = path12.dirname(path12.dirname(path12.dirname(path12.dirname(currentFilePath))));
|
|
1994
|
+
const bundledGuidesPath = path12.join(cliPackageRoot, "migration-guides");
|
|
1995
|
+
if (existsSync11(bundledGuidesPath)) {
|
|
1910
1996
|
return bundledGuidesPath;
|
|
1911
1997
|
}
|
|
1912
1998
|
return "";
|
|
@@ -2019,16 +2105,16 @@ var MigrationGuideLoader = class {
|
|
|
2019
2105
|
]
|
|
2020
2106
|
}
|
|
2021
2107
|
];
|
|
2022
|
-
if (!this.guidesDir || !
|
|
2023
|
-
|
|
2108
|
+
if (!this.guidesDir || !existsSync11(this.guidesDir)) {
|
|
2109
|
+
logger8.info("Using embedded migration guidance (external CLI mode)");
|
|
2024
2110
|
this.createEmbeddedGuides(guideConfigs);
|
|
2025
2111
|
return;
|
|
2026
2112
|
}
|
|
2027
2113
|
for (const config2 of guideConfigs) {
|
|
2028
|
-
const guidePath =
|
|
2029
|
-
if (
|
|
2114
|
+
const guidePath = path12.join(this.guidesDir, config2.name);
|
|
2115
|
+
if (existsSync11(guidePath)) {
|
|
2030
2116
|
try {
|
|
2031
|
-
const content =
|
|
2117
|
+
const content = readFileSync4(guidePath, "utf-8");
|
|
2032
2118
|
this.guides.push({
|
|
2033
2119
|
name: config2.name,
|
|
2034
2120
|
path: guidePath,
|
|
@@ -2037,13 +2123,13 @@ var MigrationGuideLoader = class {
|
|
|
2037
2123
|
keywords: config2.keywords
|
|
2038
2124
|
});
|
|
2039
2125
|
} catch (error) {
|
|
2040
|
-
|
|
2126
|
+
logger8.warn(`Failed to load migration guide: ${config2.name}`, error);
|
|
2041
2127
|
}
|
|
2042
2128
|
} else {
|
|
2043
|
-
|
|
2129
|
+
logger8.warn(`Migration guide not found: ${guidePath}`);
|
|
2044
2130
|
}
|
|
2045
2131
|
}
|
|
2046
|
-
|
|
2132
|
+
logger8.info(`Loaded ${this.guides.length} migration guides from ${this.guidesDir}`);
|
|
2047
2133
|
}
|
|
2048
2134
|
createEmbeddedGuides(guideConfigs) {
|
|
2049
2135
|
const embeddedGuides = {
|
|
@@ -2291,7 +2377,7 @@ function createMigrationGuideLoader(projectRoot) {
|
|
|
2291
2377
|
}
|
|
2292
2378
|
|
|
2293
2379
|
// src/utils/upgrade/simple-migration-agent.ts
|
|
2294
|
-
import { logger as
|
|
2380
|
+
import { logger as logger9 } from "@elizaos/core";
|
|
2295
2381
|
var SimpleMigrationAgent = class extends EventTarget {
|
|
2296
2382
|
handlers = /* @__PURE__ */ new Map();
|
|
2297
2383
|
repoPath;
|
|
@@ -2315,10 +2401,10 @@ var SimpleMigrationAgent = class extends EventTarget {
|
|
|
2315
2401
|
try {
|
|
2316
2402
|
this.guideLoader = createMigrationGuideLoader();
|
|
2317
2403
|
if (this.verbose) {
|
|
2318
|
-
|
|
2404
|
+
logger9.info("Migration guide loader initialized successfully");
|
|
2319
2405
|
}
|
|
2320
2406
|
} catch (error) {
|
|
2321
|
-
|
|
2407
|
+
logger9.warn("Failed to initialize migration guide loader", error);
|
|
2322
2408
|
throw new Error("Cannot initialize migration system without guide access");
|
|
2323
2409
|
}
|
|
2324
2410
|
}
|
|
@@ -2926,13 +3012,13 @@ async function upgradePlugin(pluginPath, opts) {
|
|
|
2926
3012
|
process.env.ANTHROPIC_API_KEY = opts.apiKey;
|
|
2927
3013
|
}
|
|
2928
3014
|
if (!process.env.ANTHROPIC_API_KEY) {
|
|
2929
|
-
|
|
3015
|
+
logger10.error("ANTHROPIC_API_KEY is required for plugin upgrade.");
|
|
2930
3016
|
console.log("\nPlease set ANTHROPIC_API_KEY environment variable or use --api-key option.");
|
|
2931
3017
|
console.log("Get your API key from: https://console.anthropic.com/");
|
|
2932
3018
|
process.exit(1);
|
|
2933
3019
|
}
|
|
2934
3020
|
if (!process.env.ANTHROPIC_API_KEY.startsWith("sk-ant-")) {
|
|
2935
|
-
|
|
3021
|
+
logger10.error("Invalid ANTHROPIC_API_KEY format.");
|
|
2936
3022
|
console.log('\nThe API key should start with "sk-ant-"');
|
|
2937
3023
|
console.log("Get your API key from: https://console.anthropic.com/");
|
|
2938
3024
|
process.exit(1);
|
|
@@ -2952,41 +3038,41 @@ async function upgradePlugin(pluginPath, opts) {
|
|
|
2952
3038
|
console.log("\nInstall the SDK: bun add @anthropic-ai/claude-code");
|
|
2953
3039
|
process.exit(1);
|
|
2954
3040
|
}
|
|
2955
|
-
const workingDir =
|
|
2956
|
-
if (!
|
|
3041
|
+
const workingDir = path13.resolve(pluginPath);
|
|
3042
|
+
if (!existsSync12(workingDir)) {
|
|
2957
3043
|
throw new Error(`Plugin directory not found: ${workingDir}`);
|
|
2958
3044
|
}
|
|
2959
3045
|
console.log(chalk.cyan("\u{1F527} Setting up migration environment..."));
|
|
2960
3046
|
let projectRoot = process.cwd();
|
|
2961
3047
|
let guidesSource;
|
|
2962
3048
|
let previousRoot = "";
|
|
2963
|
-
while (projectRoot !== previousRoot && !
|
|
3049
|
+
while (projectRoot !== previousRoot && !existsSync12(path13.join(projectRoot, "packages/docs"))) {
|
|
2964
3050
|
previousRoot = projectRoot;
|
|
2965
|
-
projectRoot =
|
|
3051
|
+
projectRoot = path13.dirname(projectRoot);
|
|
2966
3052
|
}
|
|
2967
|
-
const monorepoGuidesPath =
|
|
3053
|
+
const monorepoGuidesPath = path13.join(
|
|
2968
3054
|
projectRoot,
|
|
2969
3055
|
"packages/docs/docs/plugins/migration/claude-code"
|
|
2970
3056
|
);
|
|
2971
|
-
if (
|
|
3057
|
+
if (existsSync12(monorepoGuidesPath)) {
|
|
2972
3058
|
guidesSource = monorepoGuidesPath;
|
|
2973
3059
|
} else {
|
|
2974
3060
|
const currentFileUrl = import.meta.url;
|
|
2975
3061
|
const currentFilePath = fileURLToPath2(currentFileUrl);
|
|
2976
|
-
const cliPackageRoot =
|
|
2977
|
-
|
|
3062
|
+
const cliPackageRoot = path13.dirname(
|
|
3063
|
+
path13.dirname(path13.dirname(path13.dirname(currentFilePath)))
|
|
2978
3064
|
);
|
|
2979
|
-
const bundledGuidesPath =
|
|
2980
|
-
if (
|
|
3065
|
+
const bundledGuidesPath = path13.join(cliPackageRoot, "migration-guides");
|
|
3066
|
+
if (existsSync12(bundledGuidesPath)) {
|
|
2981
3067
|
guidesSource = bundledGuidesPath;
|
|
2982
3068
|
} else {
|
|
2983
3069
|
guidesSource = "";
|
|
2984
3070
|
}
|
|
2985
3071
|
}
|
|
2986
|
-
const guidesTarget =
|
|
2987
|
-
await
|
|
2988
|
-
if (guidesSource &&
|
|
2989
|
-
await
|
|
3072
|
+
const guidesTarget = path13.join(workingDir, "migration-guides");
|
|
3073
|
+
await fs2.ensureDir(guidesTarget);
|
|
3074
|
+
if (guidesSource && existsSync12(guidesSource)) {
|
|
3075
|
+
await fs2.copy(guidesSource, guidesTarget, { overwrite: true });
|
|
2990
3076
|
if (opts.debug) {
|
|
2991
3077
|
console.log(chalk.gray(`Copied guides from: ${guidesSource}`));
|
|
2992
3078
|
}
|
|
@@ -3022,8 +3108,8 @@ Plugin: ${pluginPath}`));
|
|
|
3022
3108
|
});
|
|
3023
3109
|
const result = await agent2.migrate();
|
|
3024
3110
|
try {
|
|
3025
|
-
if (
|
|
3026
|
-
await
|
|
3111
|
+
if (existsSync12(guidesTarget)) {
|
|
3112
|
+
await fs2.remove(guidesTarget);
|
|
3027
3113
|
if (opts.debug) {
|
|
3028
3114
|
console.log(chalk.gray("Cleaned up migration guides"));
|
|
3029
3115
|
}
|
|
@@ -3036,7 +3122,7 @@ Plugin: ${pluginPath}`));
|
|
|
3036
3122
|
if (result.success) {
|
|
3037
3123
|
console.log(chalk.green("\nMigration completed successfully!"));
|
|
3038
3124
|
console.log(chalk.gray("\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500"));
|
|
3039
|
-
console.log(`Location: ${chalk.cyan(
|
|
3125
|
+
console.log(`Location: ${chalk.cyan(path13.basename(result.repoPath))}`);
|
|
3040
3126
|
console.log(`Duration: ${chalk.yellow(Math.round(result.duration / 1e3) + "s")}`);
|
|
3041
3127
|
console.log(`AI Operations: ${chalk.blue(result.messageCount)}`);
|
|
3042
3128
|
if (result.guidesUsed && result.guidesUsed.length > 0) {
|
|
@@ -3046,7 +3132,7 @@ Plugin: ${pluginPath}`));
|
|
|
3046
3132
|
}
|
|
3047
3133
|
}
|
|
3048
3134
|
console.log(chalk.bold("\nNext Steps:"));
|
|
3049
|
-
console.log(`${chalk.gray("1.")} cd ${chalk.cyan(
|
|
3135
|
+
console.log(`${chalk.gray("1.")} cd ${chalk.cyan(path13.basename(result.repoPath))}`);
|
|
3050
3136
|
console.log(
|
|
3051
3137
|
`${chalk.gray("2.")} git checkout 1.x ${chalk.gray("# Review the migrated code")}`
|
|
3052
3138
|
);
|
|
@@ -3075,9 +3161,9 @@ Plugin: ${pluginPath}`));
|
|
|
3075
3161
|
}
|
|
3076
3162
|
} catch (error) {
|
|
3077
3163
|
try {
|
|
3078
|
-
const guidesTarget =
|
|
3079
|
-
if (
|
|
3080
|
-
await
|
|
3164
|
+
const guidesTarget = path13.join(path13.resolve(pluginPath), "migration-guides");
|
|
3165
|
+
if (existsSync12(guidesTarget)) {
|
|
3166
|
+
await fs2.remove(guidesTarget);
|
|
3081
3167
|
if (opts.debug) {
|
|
3082
3168
|
console.log(chalk.gray("Cleaned up migration guides after error"));
|
|
3083
3169
|
}
|
|
@@ -3103,9 +3189,9 @@ Error: ${error instanceof Error ? error.message : String(error)}`));
|
|
|
3103
3189
|
}
|
|
3104
3190
|
|
|
3105
3191
|
// src/commands/plugins/actions/generate.ts
|
|
3106
|
-
import { logger as
|
|
3107
|
-
import { readFileSync as
|
|
3108
|
-
import
|
|
3192
|
+
import { logger as logger11 } from "@elizaos/core";
|
|
3193
|
+
import { readFileSync as readFileSync5 } from "fs";
|
|
3194
|
+
import path14 from "path";
|
|
3109
3195
|
async function generatePlugin(opts) {
|
|
3110
3196
|
try {
|
|
3111
3197
|
const { PluginCreator } = await import("./plugin-creator-H26ZLR6H.js");
|
|
@@ -3113,23 +3199,23 @@ async function generatePlugin(opts) {
|
|
|
3113
3199
|
process.env.ANTHROPIC_API_KEY = opts.apiKey;
|
|
3114
3200
|
}
|
|
3115
3201
|
if (!process.env.ANTHROPIC_API_KEY) {
|
|
3116
|
-
|
|
3202
|
+
logger11.error("ANTHROPIC_API_KEY is required for plugin generation.");
|
|
3117
3203
|
console.log("\nPlease set ANTHROPIC_API_KEY environment variable or use --api-key option.");
|
|
3118
3204
|
process.exit(1);
|
|
3119
3205
|
}
|
|
3120
3206
|
let spec = void 0;
|
|
3121
3207
|
if (opts.specFile) {
|
|
3122
3208
|
try {
|
|
3123
|
-
const specContent =
|
|
3209
|
+
const specContent = readFileSync5(opts.specFile, "utf-8");
|
|
3124
3210
|
spec = JSON.parse(specContent);
|
|
3125
3211
|
} catch (error) {
|
|
3126
|
-
|
|
3212
|
+
logger11.error(
|
|
3127
3213
|
`Failed to read or parse spec file: ${error instanceof Error ? error.message : String(error)}`
|
|
3128
3214
|
);
|
|
3129
3215
|
process.exit(1);
|
|
3130
3216
|
}
|
|
3131
3217
|
} else if (opts.skipPrompts) {
|
|
3132
|
-
|
|
3218
|
+
logger11.error("--skip-prompts requires --spec-file to be provided");
|
|
3133
3219
|
process.exit(1);
|
|
3134
3220
|
}
|
|
3135
3221
|
const creator = new PluginCreator({
|
|
@@ -3151,12 +3237,12 @@ ${emoji.success("Plugin successfully generated!")}`);
|
|
|
3151
3237
|
The plugin has been created in your current directory.`);
|
|
3152
3238
|
console.log(`
|
|
3153
3239
|
Next steps:`);
|
|
3154
|
-
console.log(`1. cd ${
|
|
3240
|
+
console.log(`1. cd ${path14.basename(result.pluginPath ?? "")}`);
|
|
3155
3241
|
console.log(`2. Review the generated code`);
|
|
3156
3242
|
console.log(`3. Test the plugin: bun test`);
|
|
3157
3243
|
console.log(`4. Add to your ElizaOS project`);
|
|
3158
3244
|
} else {
|
|
3159
|
-
|
|
3245
|
+
logger11.error(`Plugin generation failed: ${result.error?.message}`);
|
|
3160
3246
|
process.exit(1);
|
|
3161
3247
|
}
|
|
3162
3248
|
} catch (error) {
|
|
@@ -3214,20 +3300,20 @@ plugins.command("generate").description("Generate a new plugin using AI-powered
|
|
|
3214
3300
|
|
|
3215
3301
|
// src/commands/publish/index.ts
|
|
3216
3302
|
import { Command as Command5 } from "commander";
|
|
3217
|
-
import { promises as
|
|
3218
|
-
import
|
|
3303
|
+
import { promises as fs9 } from "fs";
|
|
3304
|
+
import path20 from "path";
|
|
3219
3305
|
import * as clack10 from "@clack/prompts";
|
|
3220
3306
|
|
|
3221
3307
|
// src/commands/publish/actions/npm-publish.ts
|
|
3222
|
-
import { promises as
|
|
3223
|
-
import
|
|
3308
|
+
import { promises as fs3 } from "fs";
|
|
3309
|
+
import path15 from "path";
|
|
3224
3310
|
async function publishToNpm(cwd, packageJson, npmUsername) {
|
|
3225
3311
|
console.info(`Publishing as npm user: ${npmUsername}`);
|
|
3226
3312
|
if (!packageJson.npmPackage || packageJson.npmPackage === "${NPM_PACKAGE}") {
|
|
3227
3313
|
packageJson.npmPackage = packageJson.name;
|
|
3228
3314
|
console.info(`Set npmPackage to: ${packageJson.npmPackage}`);
|
|
3229
|
-
const packageJsonPath =
|
|
3230
|
-
await
|
|
3315
|
+
const packageJsonPath = path15.join(cwd, "package.json");
|
|
3316
|
+
await fs3.writeFile(packageJsonPath, JSON.stringify(packageJson, null, 2), "utf-8");
|
|
3231
3317
|
}
|
|
3232
3318
|
console.info("Building package...");
|
|
3233
3319
|
await bunExecInherit("npm", ["run", "build"], { cwd });
|
|
@@ -3256,21 +3342,21 @@ async function publishToGitHubAction(cwd, packageJson, credentials, skipRegistry
|
|
|
3256
3342
|
}
|
|
3257
3343
|
|
|
3258
3344
|
// src/commands/publish/actions/registry-publish.ts
|
|
3259
|
-
import { promises as
|
|
3260
|
-
import
|
|
3345
|
+
import { promises as fs4 } from "fs";
|
|
3346
|
+
import path16 from "path";
|
|
3261
3347
|
var REGISTRY_PACKAGES_PATH = "packages";
|
|
3262
3348
|
var LOCAL_REGISTRY_PATH = "packages/registry";
|
|
3263
3349
|
async function updateRegistryIndex(packageMetadata, dryRun = false) {
|
|
3264
3350
|
try {
|
|
3265
|
-
const indexPath = dryRun ?
|
|
3351
|
+
const indexPath = dryRun ? path16.join(process.cwd(), LOCAL_REGISTRY_PATH, "index.json") : path16.join(process.cwd(), "temp-registry", "index.json");
|
|
3266
3352
|
try {
|
|
3267
|
-
await
|
|
3353
|
+
await fs4.access(path16.dirname(indexPath));
|
|
3268
3354
|
} catch {
|
|
3269
|
-
await
|
|
3355
|
+
await fs4.mkdir(path16.dirname(indexPath), { recursive: true });
|
|
3270
3356
|
try {
|
|
3271
|
-
await
|
|
3357
|
+
await fs4.access(indexPath);
|
|
3272
3358
|
} catch {
|
|
3273
|
-
await
|
|
3359
|
+
await fs4.writeFile(
|
|
3274
3360
|
indexPath,
|
|
3275
3361
|
JSON.stringify(
|
|
3276
3362
|
{
|
|
@@ -3285,7 +3371,7 @@ async function updateRegistryIndex(packageMetadata, dryRun = false) {
|
|
|
3285
3371
|
}
|
|
3286
3372
|
let indexContent;
|
|
3287
3373
|
try {
|
|
3288
|
-
indexContent = await
|
|
3374
|
+
indexContent = await fs4.readFile(indexPath, "utf-8");
|
|
3289
3375
|
} catch (error) {
|
|
3290
3376
|
indexContent = JSON.stringify({
|
|
3291
3377
|
v1: { packages: {} },
|
|
@@ -3317,7 +3403,7 @@ async function updateRegistryIndex(packageMetadata, dryRun = false) {
|
|
|
3317
3403
|
publishedAt: packageMetadata.publishedAt,
|
|
3318
3404
|
published: !dryRun
|
|
3319
3405
|
};
|
|
3320
|
-
await
|
|
3406
|
+
await fs4.writeFile(indexPath, JSON.stringify(index, null, 2));
|
|
3321
3407
|
console.info(
|
|
3322
3408
|
`Registry index ${dryRun ? "(dry run) " : ""}updated with ${packageMetadata.name}@${packageMetadata.version}`
|
|
3323
3409
|
);
|
|
@@ -3331,10 +3417,10 @@ async function updateRegistryIndex(packageMetadata, dryRun = false) {
|
|
|
3331
3417
|
}
|
|
3332
3418
|
async function savePackageToRegistry(packageMetadata, dryRun = false) {
|
|
3333
3419
|
try {
|
|
3334
|
-
const packageDir = dryRun ?
|
|
3335
|
-
const metadataPath =
|
|
3336
|
-
await
|
|
3337
|
-
await
|
|
3420
|
+
const packageDir = dryRun ? path16.join(process.cwd(), LOCAL_REGISTRY_PATH, REGISTRY_PACKAGES_PATH, packageMetadata.name) : path16.join(process.cwd(), "temp-registry", REGISTRY_PACKAGES_PATH, packageMetadata.name);
|
|
3421
|
+
const metadataPath = path16.join(packageDir, `${packageMetadata.version}.json`);
|
|
3422
|
+
await fs4.mkdir(packageDir, { recursive: true });
|
|
3423
|
+
await fs4.writeFile(metadataPath, JSON.stringify(packageMetadata, null, 2));
|
|
3338
3424
|
console.info(`Package metadata ${dryRun ? "(dry run) " : ""}saved to ${metadataPath}`);
|
|
3339
3425
|
await updateRegistryIndex(packageMetadata, dryRun);
|
|
3340
3426
|
return true;
|
|
@@ -3347,8 +3433,8 @@ async function savePackageToRegistry(packageMetadata, dryRun = false) {
|
|
|
3347
3433
|
}
|
|
3348
3434
|
|
|
3349
3435
|
// src/commands/publish/utils/validation.ts
|
|
3350
|
-
import { promises as
|
|
3351
|
-
import
|
|
3436
|
+
import { promises as fs5 } from "fs";
|
|
3437
|
+
import path17 from "path";
|
|
3352
3438
|
import * as clack6 from "@clack/prompts";
|
|
3353
3439
|
async function validatePluginRequirements(cwd, packageJson) {
|
|
3354
3440
|
const errors = [];
|
|
@@ -3359,23 +3445,23 @@ async function validatePluginRequirements(cwd, packageJson) {
|
|
|
3359
3445
|
'Plugin name must start with "plugin-". Please update your package name and try again.'
|
|
3360
3446
|
);
|
|
3361
3447
|
}
|
|
3362
|
-
const pluginDirName =
|
|
3448
|
+
const pluginDirName = path17.basename(cwd);
|
|
3363
3449
|
const expectedDefaultDesc = `ElizaOS plugin for ${pluginDirName.replace("plugin-", "")}`;
|
|
3364
3450
|
if (packageJson.description === expectedDefaultDesc || packageJson.description === "${PLUGINDESCRIPTION}") {
|
|
3365
3451
|
warnings.push(
|
|
3366
3452
|
"Description appears to be the default generated description. Consider writing a custom description."
|
|
3367
3453
|
);
|
|
3368
3454
|
}
|
|
3369
|
-
const imagesDir =
|
|
3370
|
-
const logoPath =
|
|
3371
|
-
const bannerPath =
|
|
3455
|
+
const imagesDir = path17.join(cwd, "images");
|
|
3456
|
+
const logoPath = path17.join(imagesDir, "logo.jpg");
|
|
3457
|
+
const bannerPath = path17.join(imagesDir, "banner.jpg");
|
|
3372
3458
|
try {
|
|
3373
|
-
await
|
|
3459
|
+
await fs5.access(logoPath);
|
|
3374
3460
|
} catch {
|
|
3375
3461
|
warnings.push("Missing required logo.jpg in images/ directory (400x400px, max 500KB).");
|
|
3376
3462
|
}
|
|
3377
3463
|
try {
|
|
3378
|
-
await
|
|
3464
|
+
await fs5.access(bannerPath);
|
|
3379
3465
|
} catch {
|
|
3380
3466
|
warnings.push("Missing required banner.jpg in images/ directory (1280x640px, max 1MB).");
|
|
3381
3467
|
}
|
|
@@ -3513,20 +3599,20 @@ async function getNpmUsername() {
|
|
|
3513
3599
|
}
|
|
3514
3600
|
|
|
3515
3601
|
// src/commands/publish/utils/version-check.ts
|
|
3516
|
-
import { promises as
|
|
3517
|
-
import
|
|
3602
|
+
import { promises as fs8 } from "fs";
|
|
3603
|
+
import path19 from "path";
|
|
3518
3604
|
import { fileURLToPath as fileURLToPath3 } from "url";
|
|
3519
3605
|
import * as clack9 from "@clack/prompts";
|
|
3520
3606
|
|
|
3521
3607
|
// src/commands/update/index.ts
|
|
3522
|
-
import { logger as
|
|
3608
|
+
import { logger as logger15 } from "@elizaos/core";
|
|
3523
3609
|
import { Command as Command4 } from "commander";
|
|
3524
3610
|
|
|
3525
3611
|
// src/commands/update/actions/cli-update.ts
|
|
3526
|
-
import { logger as
|
|
3612
|
+
import { logger as logger13 } from "@elizaos/core";
|
|
3527
3613
|
|
|
3528
3614
|
// src/commands/update/utils/version-utils.ts
|
|
3529
|
-
import { logger as
|
|
3615
|
+
import { logger as logger12 } from "@elizaos/core";
|
|
3530
3616
|
import * as semver from "semver";
|
|
3531
3617
|
var SPECIAL_VERSION_TAGS = ["latest", "next", "canary", "rc", "dev", "nightly", "alpha"];
|
|
3532
3618
|
var ELIZAOS_ORG = "@elizaos";
|
|
@@ -3536,7 +3622,7 @@ async function getVersion2() {
|
|
|
3536
3622
|
const envInfo = await UserEnvironment.getInstance().getInfo();
|
|
3537
3623
|
return envInfo.cli.version;
|
|
3538
3624
|
} catch (error) {
|
|
3539
|
-
|
|
3625
|
+
logger12.error("Error getting CLI version:", error);
|
|
3540
3626
|
return FALLBACK_VERSION;
|
|
3541
3627
|
}
|
|
3542
3628
|
}
|
|
@@ -3576,10 +3662,10 @@ async function fetchLatestVersion(packageName) {
|
|
|
3576
3662
|
env: { NODE_ENV: "production" }
|
|
3577
3663
|
});
|
|
3578
3664
|
const version = stdout.trim();
|
|
3579
|
-
|
|
3665
|
+
logger12.debug(`Latest version of ${packageName} from npm: ${version}`);
|
|
3580
3666
|
return version;
|
|
3581
3667
|
} catch (error) {
|
|
3582
|
-
|
|
3668
|
+
logger12.error(
|
|
3583
3669
|
`Failed to fetch version for ${packageName}: ${error instanceof Error ? error.message : String(error)}`
|
|
3584
3670
|
);
|
|
3585
3671
|
return null;
|
|
@@ -3610,14 +3696,14 @@ async function performCliUpdate(options = {}) {
|
|
|
3610
3696
|
if (!options.skipBunMigration) {
|
|
3611
3697
|
const npmInstallation = await isCliInstalledViaNpm();
|
|
3612
3698
|
if (npmInstallation) {
|
|
3613
|
-
|
|
3699
|
+
logger13.info("Detected npm installation, migrating to bun...");
|
|
3614
3700
|
try {
|
|
3615
3701
|
await migrateCliToBun(latestVersion);
|
|
3616
3702
|
console.log(`CLI updated successfully to version ${latestVersion} [\u2713]`);
|
|
3617
3703
|
return true;
|
|
3618
3704
|
} catch (migrationError) {
|
|
3619
|
-
|
|
3620
|
-
|
|
3705
|
+
logger13.warn("Migration to bun failed, falling back to npm update...");
|
|
3706
|
+
logger13.debug(
|
|
3621
3707
|
"Migration error:",
|
|
3622
3708
|
migrationError instanceof Error ? migrationError.message : String(migrationError)
|
|
3623
3709
|
);
|
|
@@ -3642,7 +3728,7 @@ async function performCliUpdate(options = {}) {
|
|
|
3642
3728
|
console.error(" curl -fsSL https://bun.sh/install | bash");
|
|
3643
3729
|
console.error(" # or");
|
|
3644
3730
|
console.error(" npm install -g bun");
|
|
3645
|
-
|
|
3731
|
+
logger13.debug("Bun error:", bunError instanceof Error ? bunError.message : String(bunError));
|
|
3646
3732
|
return false;
|
|
3647
3733
|
}
|
|
3648
3734
|
} catch (error) {
|
|
@@ -3653,12 +3739,12 @@ async function performCliUpdate(options = {}) {
|
|
|
3653
3739
|
|
|
3654
3740
|
// src/commands/update/actions/dependency-update.ts
|
|
3655
3741
|
import * as clack8 from "@clack/prompts";
|
|
3656
|
-
import { promises as
|
|
3657
|
-
import * as
|
|
3742
|
+
import { promises as fs7 } from "fs";
|
|
3743
|
+
import * as path18 from "path";
|
|
3658
3744
|
|
|
3659
3745
|
// src/commands/update/utils/package-utils.ts
|
|
3660
|
-
import
|
|
3661
|
-
import { logger as
|
|
3746
|
+
import fs6 from "fs/promises";
|
|
3747
|
+
import { logger as logger14 } from "@elizaos/core";
|
|
3662
3748
|
async function checkForUpdates(dependencies) {
|
|
3663
3749
|
const updates = {};
|
|
3664
3750
|
const elizaPackages = Object.entries(dependencies).filter(([pkg]) => pkg.startsWith(ELIZAOS_ORG)).filter(([, version]) => !isWorkspaceVersion(version));
|
|
@@ -3669,7 +3755,7 @@ async function checkForUpdates(dependencies) {
|
|
|
3669
3755
|
if (needsUpdate) {
|
|
3670
3756
|
updates[pkg] = { current: currentVersion, latest: latestVersion };
|
|
3671
3757
|
} else if (error) {
|
|
3672
|
-
|
|
3758
|
+
logger14.debug(`${pkg}: ${error}`);
|
|
3673
3759
|
}
|
|
3674
3760
|
}
|
|
3675
3761
|
return { hasUpdates: Object.keys(updates).length > 0, updates };
|
|
@@ -3683,7 +3769,7 @@ function displayUpdateSummary(updates) {
|
|
|
3683
3769
|
});
|
|
3684
3770
|
}
|
|
3685
3771
|
async function updatePackageJson(packageJsonPath, updates) {
|
|
3686
|
-
const content = await
|
|
3772
|
+
const content = await fs6.readFile(packageJsonPath, "utf8");
|
|
3687
3773
|
const packageJson = JSON.parse(content);
|
|
3688
3774
|
let modified = false;
|
|
3689
3775
|
for (const [pkg, { latest }] of Object.entries(updates)) {
|
|
@@ -3697,7 +3783,7 @@ async function updatePackageJson(packageJsonPath, updates) {
|
|
|
3697
3783
|
}
|
|
3698
3784
|
}
|
|
3699
3785
|
if (modified) {
|
|
3700
|
-
await
|
|
3786
|
+
await fs6.writeFile(packageJsonPath, JSON.stringify(packageJson, null, 2) + "\n");
|
|
3701
3787
|
console.log("Updated package.json with new versions");
|
|
3702
3788
|
}
|
|
3703
3789
|
}
|
|
@@ -3717,8 +3803,8 @@ async function installDependencies(cwd) {
|
|
|
3717
3803
|
// src/commands/update/actions/dependency-update.ts
|
|
3718
3804
|
async function updateDependencies(cwd, isPlugin2, options = {}) {
|
|
3719
3805
|
const { dryRun = false, skipBuild = false } = options;
|
|
3720
|
-
const packageJsonPath =
|
|
3721
|
-
const content = await
|
|
3806
|
+
const packageJsonPath = path18.join(cwd, "package.json");
|
|
3807
|
+
const content = await fs7.readFile(packageJsonPath, "utf8");
|
|
3722
3808
|
const packageJson = JSON.parse(content);
|
|
3723
3809
|
const allDependencies = {
|
|
3724
3810
|
...packageJson.dependencies,
|
|
@@ -3788,7 +3874,7 @@ var update = new Command4().name("update").description("Update ElizaOS CLI and p
|
|
|
3788
3874
|
try {
|
|
3789
3875
|
await displayBanner(true);
|
|
3790
3876
|
} catch {
|
|
3791
|
-
|
|
3877
|
+
logger15.debug("Banner display failed, continuing with update");
|
|
3792
3878
|
}
|
|
3793
3879
|
}).action(async (options) => {
|
|
3794
3880
|
try {
|
|
@@ -3820,7 +3906,7 @@ var update = new Command4().name("update").description("Update ElizaOS CLI and p
|
|
|
3820
3906
|
console.info("To create a new ElizaOS project, use: elizaos create <project-name>");
|
|
3821
3907
|
return;
|
|
3822
3908
|
}
|
|
3823
|
-
|
|
3909
|
+
logger15.debug(`Detected ${directoryInfo.type}`);
|
|
3824
3910
|
if (!isInProject) {
|
|
3825
3911
|
handleInvalidDirectory(directoryInfo);
|
|
3826
3912
|
return;
|
|
@@ -3857,11 +3943,11 @@ var update = new Command4().name("update").description("Update ElizaOS CLI and p
|
|
|
3857
3943
|
// src/commands/publish/utils/version-check.ts
|
|
3858
3944
|
async function checkCliVersion() {
|
|
3859
3945
|
try {
|
|
3860
|
-
const cliPackageJsonPath =
|
|
3861
|
-
|
|
3946
|
+
const cliPackageJsonPath = path19.resolve(
|
|
3947
|
+
path19.dirname(fileURLToPath3(import.meta.url)),
|
|
3862
3948
|
"../package.json"
|
|
3863
3949
|
);
|
|
3864
|
-
const cliPackageJsonContent = await
|
|
3950
|
+
const cliPackageJsonContent = await fs8.readFile(cliPackageJsonPath, "utf-8");
|
|
3865
3951
|
const cliPackageJson = JSON.parse(cliPackageJsonContent);
|
|
3866
3952
|
const currentVersion = cliPackageJson.version || "0.0.0";
|
|
3867
3953
|
const { stdout } = await bunExecSimple("npm", ["view", "@elizaos/cli", "time", "--json"]);
|
|
@@ -3919,7 +4005,7 @@ var publish = new Command5().name("publish").description("Publish a plugin to np
|
|
|
3919
4005
|
process.exit(1);
|
|
3920
4006
|
}
|
|
3921
4007
|
const cliVersion = await checkCliVersion();
|
|
3922
|
-
const pluginDirName =
|
|
4008
|
+
const pluginDirName = path20.basename(process.cwd());
|
|
3923
4009
|
if (!pluginDirName.startsWith("plugin-")) {
|
|
3924
4010
|
console.error("This command must be run from a plugin directory (plugin-*)");
|
|
3925
4011
|
process.exit(1);
|
|
@@ -3945,8 +4031,8 @@ var publish = new Command5().name("publish").description("Publish a plugin to np
|
|
|
3945
4031
|
}
|
|
3946
4032
|
}
|
|
3947
4033
|
}
|
|
3948
|
-
const packageJsonPath =
|
|
3949
|
-
const packageJsonContent = await
|
|
4034
|
+
const packageJsonPath = path20.join(cwd, "package.json");
|
|
4035
|
+
const packageJsonContent = await fs9.readFile(packageJsonPath, "utf-8");
|
|
3950
4036
|
const packageJson = JSON.parse(packageJsonContent);
|
|
3951
4037
|
if (!packageJson.name || !packageJson.version) {
|
|
3952
4038
|
console.error("Invalid package.json: missing name or version.");
|
|
@@ -4087,7 +4173,7 @@ var publish = new Command5().name("publish").description("Publish a plugin to np
|
|
|
4087
4173
|
}
|
|
4088
4174
|
});
|
|
4089
4175
|
const finalPluginName = packageJson.name.startsWith("@") ? packageJson.name.split("/")[1] : packageJson.name;
|
|
4090
|
-
await
|
|
4176
|
+
await fs9.writeFile(packageJsonPath, JSON.stringify(packageJson, null, 2), "utf-8");
|
|
4091
4177
|
await validatePluginRequirements(cwd, packageJson);
|
|
4092
4178
|
const settings = await getRegistrySettings();
|
|
4093
4179
|
const publishUsername = credentials ? credentials.username : npmUsername;
|
|
@@ -4211,8 +4297,8 @@ var publish = new Command5().name("publish").description("Publish a plugin to np
|
|
|
4211
4297
|
import { Command as Command6 } from "commander";
|
|
4212
4298
|
|
|
4213
4299
|
// src/commands/monorepo/actions/clone.ts
|
|
4214
|
-
import { existsSync as
|
|
4215
|
-
import
|
|
4300
|
+
import { existsSync as existsSync13, readdirSync as readdirSync3, mkdirSync } from "fs";
|
|
4301
|
+
import path21 from "path";
|
|
4216
4302
|
async function cloneRepository(repo, branch, destination) {
|
|
4217
4303
|
try {
|
|
4218
4304
|
const repoUrl = `https://github.com/${repo}`;
|
|
@@ -4236,8 +4322,8 @@ For a complete list of branches, visit: https://github.com/elizaOS/eliza/branche
|
|
|
4236
4322
|
}
|
|
4237
4323
|
}
|
|
4238
4324
|
function prepareDestination(dir) {
|
|
4239
|
-
const destinationDir =
|
|
4240
|
-
if (
|
|
4325
|
+
const destinationDir = path21.resolve(process.cwd(), dir);
|
|
4326
|
+
if (existsSync13(destinationDir)) {
|
|
4241
4327
|
const files = readdirSync3(destinationDir);
|
|
4242
4328
|
if (files.length > 0) {
|
|
4243
4329
|
throw new Error(`Destination directory ${destinationDir} already exists and is not empty`);
|
|
@@ -4255,7 +4341,7 @@ async function cloneMonorepo(cloneInfo) {
|
|
|
4255
4341
|
}
|
|
4256
4342
|
|
|
4257
4343
|
// src/commands/monorepo/utils/setup-instructions.ts
|
|
4258
|
-
import
|
|
4344
|
+
import path22 from "path";
|
|
4259
4345
|
function getBunInstallInstructions() {
|
|
4260
4346
|
const platform = process.platform;
|
|
4261
4347
|
if (platform === "win32") {
|
|
@@ -4310,7 +4396,7 @@ ${emoji.rocket("If you don't have Bun installed:")}`);
|
|
|
4310
4396
|
console.log(" After installation, restart your terminal");
|
|
4311
4397
|
}
|
|
4312
4398
|
function displayNextSteps(targetDir) {
|
|
4313
|
-
const cdPath =
|
|
4399
|
+
const cdPath = path22.relative(process.cwd(), targetDir);
|
|
4314
4400
|
displayBasicSteps(cdPath);
|
|
4315
4401
|
displayPrerequisites();
|
|
4316
4402
|
displayBunInstructions();
|
|
@@ -4337,11 +4423,11 @@ var monorepo = new Command6().name("monorepo").description("Clone ElizaOS monore
|
|
|
4337
4423
|
|
|
4338
4424
|
// src/project.ts
|
|
4339
4425
|
import {
|
|
4340
|
-
logger as
|
|
4426
|
+
logger as logger16
|
|
4341
4427
|
} from "@elizaos/core";
|
|
4342
4428
|
import { stringToUuid } from "@elizaos/core";
|
|
4343
|
-
import * as
|
|
4344
|
-
import
|
|
4429
|
+
import * as fs10 from "fs";
|
|
4430
|
+
import path23 from "path";
|
|
4345
4431
|
function isPlugin(module) {
|
|
4346
4432
|
if (module && typeof module === "object" && typeof module.name === "string" && typeof module.description === "string") {
|
|
4347
4433
|
return true;
|
|
@@ -4376,10 +4462,10 @@ async function loadProject(dir) {
|
|
|
4376
4462
|
if (!dirInfo.hasPackageJson) {
|
|
4377
4463
|
throw new Error(`No package.json found in ${dir}`);
|
|
4378
4464
|
}
|
|
4379
|
-
const packageJson = JSON.parse(
|
|
4465
|
+
const packageJson = JSON.parse(fs10.readFileSync(path23.join(dir, "package.json"), "utf8"));
|
|
4380
4466
|
const main2 = packageJson.main;
|
|
4381
4467
|
if (!main2) {
|
|
4382
|
-
|
|
4468
|
+
logger16.warn("No main field found in package.json, using default character");
|
|
4383
4469
|
const defaultCharacterName = "Eliza (Default)";
|
|
4384
4470
|
const elizaCharacter = getElizaCharacter();
|
|
4385
4471
|
const defaultAgent = {
|
|
@@ -4389,7 +4475,7 @@ async function loadProject(dir) {
|
|
|
4389
4475
|
name: defaultCharacterName
|
|
4390
4476
|
},
|
|
4391
4477
|
init: async () => {
|
|
4392
|
-
|
|
4478
|
+
logger16.info("Initializing default Eliza character");
|
|
4393
4479
|
}
|
|
4394
4480
|
};
|
|
4395
4481
|
return {
|
|
@@ -4398,32 +4484,32 @@ async function loadProject(dir) {
|
|
|
4398
4484
|
};
|
|
4399
4485
|
}
|
|
4400
4486
|
const entryPoints = [
|
|
4401
|
-
|
|
4402
|
-
|
|
4403
|
-
|
|
4404
|
-
|
|
4405
|
-
|
|
4406
|
-
|
|
4487
|
+
path23.join(dir, main2),
|
|
4488
|
+
path23.join(dir, "dist/index.js"),
|
|
4489
|
+
path23.join(dir, "src/index.ts"),
|
|
4490
|
+
path23.join(dir, "src/index.js"),
|
|
4491
|
+
path23.join(dir, "index.ts"),
|
|
4492
|
+
path23.join(dir, "index.js")
|
|
4407
4493
|
];
|
|
4408
4494
|
let projectModule = null;
|
|
4409
4495
|
for (const entryPoint of entryPoints) {
|
|
4410
|
-
if (
|
|
4496
|
+
if (fs10.existsSync(entryPoint)) {
|
|
4411
4497
|
try {
|
|
4412
|
-
const importPath =
|
|
4498
|
+
const importPath = path23.resolve(entryPoint);
|
|
4413
4499
|
const importUrl = process.platform === "win32" ? "file:///" + importPath.replace(/\\/g, "/") : "file://" + importPath;
|
|
4414
4500
|
projectModule = await import(importUrl);
|
|
4415
|
-
|
|
4501
|
+
logger16.info(`Loaded project from ${entryPoint}`);
|
|
4416
4502
|
const exportKeys = Object.keys(projectModule);
|
|
4417
|
-
|
|
4503
|
+
logger16.debug(`Module exports: ${exportKeys.join(", ")}`);
|
|
4418
4504
|
if (exportKeys.includes("default")) {
|
|
4419
|
-
|
|
4505
|
+
logger16.debug(`Default export type: ${typeof projectModule.default}`);
|
|
4420
4506
|
if (typeof projectModule.default === "object" && projectModule.default !== null) {
|
|
4421
|
-
|
|
4507
|
+
logger16.debug(`Default export keys: ${Object.keys(projectModule.default).join(", ")}`);
|
|
4422
4508
|
}
|
|
4423
4509
|
}
|
|
4424
4510
|
break;
|
|
4425
4511
|
} catch (error) {
|
|
4426
|
-
|
|
4512
|
+
logger16.warn(`Failed to import project from ${entryPoint}:`, error);
|
|
4427
4513
|
}
|
|
4428
4514
|
}
|
|
4429
4515
|
}
|
|
@@ -4431,13 +4517,13 @@ async function loadProject(dir) {
|
|
|
4431
4517
|
throw new Error("Could not find project entry point");
|
|
4432
4518
|
}
|
|
4433
4519
|
const moduleIsPlugin = isPlugin(projectModule);
|
|
4434
|
-
|
|
4520
|
+
logger16.debug(`Is this a plugin? ${moduleIsPlugin}`);
|
|
4435
4521
|
if (moduleIsPlugin) {
|
|
4436
|
-
|
|
4522
|
+
logger16.info("Detected plugin module instead of project");
|
|
4437
4523
|
try {
|
|
4438
4524
|
const plugin = extractPlugin(projectModule);
|
|
4439
|
-
|
|
4440
|
-
|
|
4525
|
+
logger16.debug(`Found plugin: ${plugin.name} - ${plugin.description}`);
|
|
4526
|
+
logger16.debug(`Plugin has the following properties: ${Object.keys(plugin).join(", ")}`);
|
|
4441
4527
|
const completePlugin = {
|
|
4442
4528
|
// Copy all other properties from the original plugin first
|
|
4443
4529
|
...plugin,
|
|
@@ -4445,7 +4531,7 @@ async function loadProject(dir) {
|
|
|
4445
4531
|
name: plugin.name || "unknown-plugin",
|
|
4446
4532
|
description: plugin.description || "No description",
|
|
4447
4533
|
init: plugin.init || (async () => {
|
|
4448
|
-
|
|
4534
|
+
logger16.info(`Dummy init for plugin: ${plugin.name}`);
|
|
4449
4535
|
})
|
|
4450
4536
|
};
|
|
4451
4537
|
const characterName = "Eliza (Test Mode)";
|
|
@@ -4456,13 +4542,13 @@ async function loadProject(dir) {
|
|
|
4456
4542
|
name: characterName,
|
|
4457
4543
|
system: `${elizaCharacter.system} Testing the plugin: ${completePlugin.name}.`
|
|
4458
4544
|
};
|
|
4459
|
-
|
|
4545
|
+
logger16.info(`Using Eliza character as test agent for plugin: ${completePlugin.name}`);
|
|
4460
4546
|
const testAgent = {
|
|
4461
4547
|
character: testCharacter,
|
|
4462
4548
|
plugins: [completePlugin],
|
|
4463
4549
|
// Only include the plugin being tested
|
|
4464
4550
|
init: async () => {
|
|
4465
|
-
|
|
4551
|
+
logger16.info(`Initializing Eliza test agent for plugin: ${completePlugin.name}`);
|
|
4466
4552
|
}
|
|
4467
4553
|
};
|
|
4468
4554
|
return {
|
|
@@ -4472,24 +4558,24 @@ async function loadProject(dir) {
|
|
|
4472
4558
|
pluginModule: completePlugin
|
|
4473
4559
|
};
|
|
4474
4560
|
} catch (error) {
|
|
4475
|
-
|
|
4561
|
+
logger16.error("Error extracting plugin from module:", error);
|
|
4476
4562
|
throw error;
|
|
4477
4563
|
}
|
|
4478
4564
|
}
|
|
4479
4565
|
const agents = [];
|
|
4480
4566
|
if (projectModule.default && typeof projectModule.default === "object" && Array.isArray(projectModule.default.agents)) {
|
|
4481
4567
|
agents.push(...projectModule.default.agents);
|
|
4482
|
-
|
|
4568
|
+
logger16.debug(`Found ${agents.length} agents in default export's agents array`);
|
|
4483
4569
|
} else {
|
|
4484
4570
|
for (const [key, value] of Object.entries(projectModule)) {
|
|
4485
4571
|
if (key === "default" && value && typeof value === "object") {
|
|
4486
4572
|
if (value.character && value.init) {
|
|
4487
4573
|
agents.push(value);
|
|
4488
|
-
|
|
4574
|
+
logger16.debug(`Found agent in default export (single agent)`);
|
|
4489
4575
|
}
|
|
4490
4576
|
} else if (value && typeof value === "object" && value.character && value.init) {
|
|
4491
4577
|
agents.push(value);
|
|
4492
|
-
|
|
4578
|
+
logger16.debug(`Found agent in named export: ${key}`);
|
|
4493
4579
|
}
|
|
4494
4580
|
}
|
|
4495
4581
|
}
|
|
@@ -4502,7 +4588,7 @@ async function loadProject(dir) {
|
|
|
4502
4588
|
};
|
|
4503
4589
|
return project;
|
|
4504
4590
|
} catch (error) {
|
|
4505
|
-
|
|
4591
|
+
logger16.error("Error loading project:", error);
|
|
4506
4592
|
throw error;
|
|
4507
4593
|
}
|
|
4508
4594
|
}
|
|
@@ -4517,19 +4603,19 @@ function validatePort(value) {
|
|
|
4517
4603
|
}
|
|
4518
4604
|
|
|
4519
4605
|
// src/commands/start/index.ts
|
|
4520
|
-
import { logger as
|
|
4606
|
+
import { logger as logger21 } from "@elizaos/core";
|
|
4521
4607
|
import { Command as Command7 } from "commander";
|
|
4522
|
-
import * as
|
|
4523
|
-
import * as
|
|
4608
|
+
import * as fs11 from "fs";
|
|
4609
|
+
import * as path25 from "path";
|
|
4524
4610
|
|
|
4525
4611
|
// src/commands/start/actions/server-start.ts
|
|
4526
|
-
import { logger as
|
|
4612
|
+
import { logger as logger20 } from "@elizaos/core";
|
|
4527
4613
|
|
|
4528
4614
|
// src/commands/start/actions/agent-start.ts
|
|
4529
4615
|
import {
|
|
4530
4616
|
AgentRuntime as AgentRuntime2,
|
|
4531
4617
|
encryptedCharacter,
|
|
4532
|
-
logger as
|
|
4618
|
+
logger as logger19,
|
|
4533
4619
|
stringToUuid as stringToUuid2
|
|
4534
4620
|
} from "@elizaos/core";
|
|
4535
4621
|
import { plugin as sqlPlugin } from "@elizaos/plugin-sql";
|
|
@@ -4572,19 +4658,19 @@ async function setDefaultSecretsFromEnv(character) {
|
|
|
4572
4658
|
}
|
|
4573
4659
|
|
|
4574
4660
|
// src/commands/start/utils/dependency-resolver.ts
|
|
4575
|
-
import { logger as
|
|
4661
|
+
import { logger as logger17 } from "@elizaos/core";
|
|
4576
4662
|
function resolvePluginDependencies(availablePlugins, isTestMode = false) {
|
|
4577
4663
|
const resolutionOrder = [];
|
|
4578
4664
|
const visited = /* @__PURE__ */ new Set();
|
|
4579
4665
|
const visiting = /* @__PURE__ */ new Set();
|
|
4580
4666
|
function visit(pluginName) {
|
|
4581
4667
|
if (!availablePlugins.has(pluginName)) {
|
|
4582
|
-
|
|
4668
|
+
logger17.warn(`Plugin dependency "${pluginName}" not found and will be skipped.`);
|
|
4583
4669
|
return;
|
|
4584
4670
|
}
|
|
4585
4671
|
if (visited.has(pluginName)) return;
|
|
4586
4672
|
if (visiting.has(pluginName)) {
|
|
4587
|
-
|
|
4673
|
+
logger17.error(`Circular dependency detected involving plugin: ${pluginName}`);
|
|
4588
4674
|
return;
|
|
4589
4675
|
}
|
|
4590
4676
|
visiting.add(pluginName);
|
|
@@ -4608,12 +4694,12 @@ function resolvePluginDependencies(availablePlugins, isTestMode = false) {
|
|
|
4608
4694
|
}
|
|
4609
4695
|
}
|
|
4610
4696
|
const finalPlugins = resolutionOrder.map((name) => availablePlugins.get(name)).filter((p) => p);
|
|
4611
|
-
|
|
4697
|
+
logger17.info(`Final plugins being loaded: ${finalPlugins.map((p) => p.name).join(", ")}`);
|
|
4612
4698
|
return finalPlugins;
|
|
4613
4699
|
}
|
|
4614
4700
|
|
|
4615
4701
|
// src/commands/start/utils/plugin-utils.ts
|
|
4616
|
-
import { logger as
|
|
4702
|
+
import { logger as logger18 } from "@elizaos/core";
|
|
4617
4703
|
function isValidPluginShape(obj) {
|
|
4618
4704
|
if (!obj || typeof obj !== "object" || !obj.name) {
|
|
4619
4705
|
return false;
|
|
@@ -4628,12 +4714,12 @@ async function loadAndPreparePlugin(pluginName) {
|
|
|
4628
4714
|
try {
|
|
4629
4715
|
pluginModule = await loadPluginModule(pluginName);
|
|
4630
4716
|
if (!pluginModule) {
|
|
4631
|
-
|
|
4717
|
+
logger18.error(`Failed to load local plugin ${pluginName}.`);
|
|
4632
4718
|
provideLocalPluginGuidance(pluginName, context);
|
|
4633
4719
|
return null;
|
|
4634
4720
|
}
|
|
4635
4721
|
} catch (error) {
|
|
4636
|
-
|
|
4722
|
+
logger18.error(`Error loading local plugin ${pluginName}: ${error}`);
|
|
4637
4723
|
provideLocalPluginGuidance(pluginName, context);
|
|
4638
4724
|
return null;
|
|
4639
4725
|
}
|
|
@@ -4641,17 +4727,17 @@ async function loadAndPreparePlugin(pluginName) {
|
|
|
4641
4727
|
try {
|
|
4642
4728
|
pluginModule = await loadPluginModule(pluginName);
|
|
4643
4729
|
if (!pluginModule) {
|
|
4644
|
-
|
|
4730
|
+
logger18.info(`Plugin ${pluginName} not available, installing...`);
|
|
4645
4731
|
await installPlugin(pluginName, process.cwd(), version);
|
|
4646
4732
|
pluginModule = await loadPluginModule(pluginName);
|
|
4647
4733
|
}
|
|
4648
4734
|
} catch (error) {
|
|
4649
|
-
|
|
4735
|
+
logger18.error(`Failed to process plugin ${pluginName}: ${error}`);
|
|
4650
4736
|
return null;
|
|
4651
4737
|
}
|
|
4652
4738
|
}
|
|
4653
4739
|
if (!pluginModule) {
|
|
4654
|
-
|
|
4740
|
+
logger18.error(`Failed to load module for plugin ${pluginName}.`);
|
|
4655
4741
|
return null;
|
|
4656
4742
|
}
|
|
4657
4743
|
const expectedFunctionName = `${pluginName.replace(/^@elizaos\/plugin-/, "").replace(/^@elizaos\//, "").replace(/-./g, (match) => match[1].toUpperCase())}Plugin`;
|
|
@@ -4665,7 +4751,7 @@ async function loadAndPreparePlugin(pluginName) {
|
|
|
4665
4751
|
return potentialPlugin;
|
|
4666
4752
|
}
|
|
4667
4753
|
}
|
|
4668
|
-
|
|
4754
|
+
logger18.warn(`Could not find a valid plugin export in ${pluginName}.`);
|
|
4669
4755
|
return null;
|
|
4670
4756
|
}
|
|
4671
4757
|
|
|
@@ -4717,32 +4803,32 @@ async function startAgent(character, server, init, plugins2 = [], options = {})
|
|
|
4717
4803
|
try {
|
|
4718
4804
|
const migrationService = runtime.getService("database_migration");
|
|
4719
4805
|
if (migrationService) {
|
|
4720
|
-
|
|
4806
|
+
logger19.info("Discovering plugin schemas for dynamic migration...");
|
|
4721
4807
|
migrationService.discoverAndRegisterPluginSchemas(finalPlugins);
|
|
4722
|
-
|
|
4808
|
+
logger19.info("Running all plugin migrations...");
|
|
4723
4809
|
await migrationService.runAllPluginMigrations();
|
|
4724
|
-
|
|
4810
|
+
logger19.info("All plugin migrations completed successfully");
|
|
4725
4811
|
} else {
|
|
4726
|
-
|
|
4812
|
+
logger19.warn("DatabaseMigrationService not found - plugin schema migrations skipped");
|
|
4727
4813
|
}
|
|
4728
4814
|
} catch (error) {
|
|
4729
|
-
|
|
4815
|
+
logger19.error("Failed to run plugin migrations:", error);
|
|
4730
4816
|
throw error;
|
|
4731
4817
|
}
|
|
4732
4818
|
server.registerAgent(runtime);
|
|
4733
|
-
|
|
4819
|
+
logger19.log(`Started ${runtime.character.name} as ${runtime.agentId}`);
|
|
4734
4820
|
return runtime;
|
|
4735
4821
|
}
|
|
4736
4822
|
async function stopAgent(runtime, server) {
|
|
4737
4823
|
await runtime.close();
|
|
4738
4824
|
server.unregisterAgent(runtime.agentId);
|
|
4739
|
-
|
|
4825
|
+
logger19.success(`Agent ${runtime.character.name} stopped successfully!`);
|
|
4740
4826
|
}
|
|
4741
4827
|
|
|
4742
4828
|
// src/commands/start/actions/server-start.ts
|
|
4743
|
-
import
|
|
4829
|
+
import path24 from "path";
|
|
4744
4830
|
import { fileURLToPath as fileURLToPath4 } from "url";
|
|
4745
|
-
import { existsSync as
|
|
4831
|
+
import { existsSync as existsSync15, readFileSync as readFileSync7 } from "fs";
|
|
4746
4832
|
async function startAgents(options) {
|
|
4747
4833
|
const postgresUrl = await configureDatabaseSettings(options.configure);
|
|
4748
4834
|
if (postgresUrl) process.env.POSTGRES_URL = postgresUrl;
|
|
@@ -4751,19 +4837,19 @@ async function startAgents(options) {
|
|
|
4751
4837
|
const serverModule = await moduleLoader.load("@elizaos/server");
|
|
4752
4838
|
const { AgentServer, jsonToCharacter, loadCharacterTryPath } = serverModule;
|
|
4753
4839
|
const __filename = fileURLToPath4(import.meta.url);
|
|
4754
|
-
const __dirname =
|
|
4755
|
-
let cliDistPath =
|
|
4756
|
-
const indexPath =
|
|
4757
|
-
if (!
|
|
4840
|
+
const __dirname = path24.dirname(__filename);
|
|
4841
|
+
let cliDistPath = path24.resolve(__dirname, "../../../");
|
|
4842
|
+
const indexPath = path24.join(cliDistPath, "index.html");
|
|
4843
|
+
if (!existsSync15(indexPath)) {
|
|
4758
4844
|
let currentDir = __dirname;
|
|
4759
|
-
while (currentDir !==
|
|
4760
|
-
const packageJsonPath =
|
|
4761
|
-
if (
|
|
4845
|
+
while (currentDir !== path24.dirname(currentDir)) {
|
|
4846
|
+
const packageJsonPath = path24.join(currentDir, "package.json");
|
|
4847
|
+
if (existsSync15(packageJsonPath)) {
|
|
4762
4848
|
try {
|
|
4763
|
-
const packageJson = JSON.parse(
|
|
4849
|
+
const packageJson = JSON.parse(readFileSync7(packageJsonPath, "utf-8"));
|
|
4764
4850
|
if (packageJson.name === "@elizaos/cli") {
|
|
4765
|
-
const distPath =
|
|
4766
|
-
if (
|
|
4851
|
+
const distPath = path24.join(currentDir, "dist");
|
|
4852
|
+
if (existsSync15(path24.join(distPath, "index.html"))) {
|
|
4767
4853
|
cliDistPath = distPath;
|
|
4768
4854
|
break;
|
|
4769
4855
|
}
|
|
@@ -4771,7 +4857,7 @@ async function startAgents(options) {
|
|
|
4771
4857
|
} catch {
|
|
4772
4858
|
}
|
|
4773
4859
|
}
|
|
4774
|
-
currentDir =
|
|
4860
|
+
currentDir = path24.dirname(currentDir);
|
|
4775
4861
|
}
|
|
4776
4862
|
}
|
|
4777
4863
|
const server = new AgentServer();
|
|
@@ -4786,13 +4872,13 @@ async function startAgents(options) {
|
|
|
4786
4872
|
const desiredPort = options.port || Number.parseInt(process.env.SERVER_PORT || "3000");
|
|
4787
4873
|
const serverPort = await findNextAvailablePort(desiredPort);
|
|
4788
4874
|
if (serverPort !== desiredPort) {
|
|
4789
|
-
|
|
4875
|
+
logger20.warn(`Port ${desiredPort} is in use, using port ${serverPort} instead`);
|
|
4790
4876
|
}
|
|
4791
4877
|
process.env.SERVER_PORT = serverPort.toString();
|
|
4792
4878
|
try {
|
|
4793
4879
|
await server.start(serverPort);
|
|
4794
4880
|
} catch (error) {
|
|
4795
|
-
|
|
4881
|
+
logger20.error(`Failed to start server on port ${serverPort}:`, error);
|
|
4796
4882
|
throw error;
|
|
4797
4883
|
}
|
|
4798
4884
|
if (options.projectAgents && options.projectAgents.length > 0) {
|
|
@@ -4820,15 +4906,16 @@ var start = new Command7().name("start").description("Build and start the Eliza
|
|
|
4820
4906
|
}).action(async (options) => {
|
|
4821
4907
|
try {
|
|
4822
4908
|
await loadEnvConfig();
|
|
4823
|
-
|
|
4909
|
+
await ensureElizaOSCli();
|
|
4910
|
+
const localModulesPath = path25.join(process.cwd(), "node_modules");
|
|
4824
4911
|
if (process.env.NODE_PATH) {
|
|
4825
|
-
process.env.NODE_PATH = `${localModulesPath}${
|
|
4912
|
+
process.env.NODE_PATH = `${localModulesPath}${path25.delimiter}${process.env.NODE_PATH}`;
|
|
4826
4913
|
} else {
|
|
4827
4914
|
process.env.NODE_PATH = localModulesPath;
|
|
4828
4915
|
}
|
|
4829
|
-
const localBinPath =
|
|
4916
|
+
const localBinPath = path25.join(process.cwd(), "node_modules", ".bin");
|
|
4830
4917
|
if (process.env.PATH) {
|
|
4831
|
-
process.env.PATH = `${localBinPath}${
|
|
4918
|
+
process.env.PATH = `${localBinPath}${path25.delimiter}${process.env.PATH}`;
|
|
4832
4919
|
} else {
|
|
4833
4920
|
process.env.PATH = localBinPath;
|
|
4834
4921
|
}
|
|
@@ -4839,8 +4926,8 @@ var start = new Command7().name("start").description("Build and start the Eliza
|
|
|
4839
4926
|
try {
|
|
4840
4927
|
await buildProject(cwd, false);
|
|
4841
4928
|
} catch (error) {
|
|
4842
|
-
|
|
4843
|
-
|
|
4929
|
+
logger21.error(`Build error: ${error instanceof Error ? error.message : String(error)}`);
|
|
4930
|
+
logger21.warn(
|
|
4844
4931
|
"Build failed, but continuing with start. Some features may not work correctly."
|
|
4845
4932
|
);
|
|
4846
4933
|
}
|
|
@@ -4852,24 +4939,24 @@ var start = new Command7().name("start").description("Build and start the Eliza
|
|
|
4852
4939
|
const serverModule = await moduleLoader.load("@elizaos/server");
|
|
4853
4940
|
const { loadCharacterTryPath } = serverModule;
|
|
4854
4941
|
for (const charPath of options.character) {
|
|
4855
|
-
const resolvedPath =
|
|
4856
|
-
if (!
|
|
4857
|
-
|
|
4942
|
+
const resolvedPath = path25.resolve(charPath);
|
|
4943
|
+
if (!fs11.existsSync(resolvedPath)) {
|
|
4944
|
+
logger21.error(`Character file not found: ${resolvedPath}`);
|
|
4858
4945
|
throw new Error(`Character file not found: ${resolvedPath}`);
|
|
4859
4946
|
}
|
|
4860
4947
|
try {
|
|
4861
4948
|
const character = await loadCharacterTryPath(resolvedPath);
|
|
4862
4949
|
if (character) {
|
|
4863
4950
|
characters.push(character);
|
|
4864
|
-
|
|
4951
|
+
logger21.info(`Successfully loaded character: ${character.name}`);
|
|
4865
4952
|
} else {
|
|
4866
|
-
|
|
4953
|
+
logger21.error(
|
|
4867
4954
|
`Failed to load character from ${resolvedPath}: Invalid or empty character file`
|
|
4868
4955
|
);
|
|
4869
4956
|
throw new Error(`Invalid character file: ${resolvedPath}`);
|
|
4870
4957
|
}
|
|
4871
4958
|
} catch (e) {
|
|
4872
|
-
|
|
4959
|
+
logger21.error(`Failed to load character from ${resolvedPath}:`, e);
|
|
4873
4960
|
throw new Error(`Invalid character file: ${resolvedPath}`);
|
|
4874
4961
|
}
|
|
4875
4962
|
}
|
|
@@ -4878,20 +4965,20 @@ var start = new Command7().name("start").description("Build and start the Eliza
|
|
|
4878
4965
|
const cwd2 = process.cwd();
|
|
4879
4966
|
const dirInfo2 = detectDirectoryType(cwd2);
|
|
4880
4967
|
if (dirInfo2.hasPackageJson && dirInfo2.type !== "non-elizaos-dir") {
|
|
4881
|
-
|
|
4968
|
+
logger21.info("No character files specified, attempting to load project agents...");
|
|
4882
4969
|
const project = await loadProject(cwd2);
|
|
4883
4970
|
if (project.agents && project.agents.length > 0) {
|
|
4884
|
-
|
|
4971
|
+
logger21.info(`Found ${project.agents.length} agent(s) in project configuration`);
|
|
4885
4972
|
projectAgents = project.agents;
|
|
4886
4973
|
for (const agent2 of project.agents) {
|
|
4887
4974
|
if (agent2.character) {
|
|
4888
|
-
|
|
4975
|
+
logger21.info(`Loaded character: ${agent2.character.name}`);
|
|
4889
4976
|
}
|
|
4890
4977
|
}
|
|
4891
4978
|
}
|
|
4892
4979
|
}
|
|
4893
4980
|
} catch (e) {
|
|
4894
|
-
|
|
4981
|
+
logger21.debug("Failed to load project agents, will use default character:", e);
|
|
4895
4982
|
}
|
|
4896
4983
|
}
|
|
4897
4984
|
await startAgents({ ...options, characters, projectAgents });
|
|
@@ -4970,18 +5057,18 @@ ${emoji.error("Error: Failed to run Phala CLI")}`);
|
|
|
4970
5057
|
var teeCommand = new Command9("tee").description("Manage TEE deployments").addCommand(phalaCliCommand);
|
|
4971
5058
|
|
|
4972
5059
|
// src/commands/test/index.ts
|
|
4973
|
-
import { logger as
|
|
5060
|
+
import { logger as logger28 } from "@elizaos/core";
|
|
4974
5061
|
import { Command as Command10, Option as Option2 } from "commander";
|
|
4975
5062
|
|
|
4976
5063
|
// src/commands/test/actions/run-all-tests.ts
|
|
4977
|
-
import { logger as
|
|
5064
|
+
import { logger as logger26 } from "@elizaos/core";
|
|
4978
5065
|
|
|
4979
5066
|
// src/commands/test/utils/project-utils.ts
|
|
4980
|
-
import { logger as
|
|
4981
|
-
import * as
|
|
4982
|
-
import
|
|
5067
|
+
import { logger as logger22 } from "@elizaos/core";
|
|
5068
|
+
import * as fs12 from "fs";
|
|
5069
|
+
import path26 from "path";
|
|
4983
5070
|
function getProjectType(testPath) {
|
|
4984
|
-
const targetPath = testPath ?
|
|
5071
|
+
const targetPath = testPath ? path26.resolve(process.cwd(), testPath) : process.cwd();
|
|
4985
5072
|
return detectDirectoryType(targetPath);
|
|
4986
5073
|
}
|
|
4987
5074
|
function processFilterName(name) {
|
|
@@ -5000,29 +5087,29 @@ async function installPluginDependencies(projectInfo) {
|
|
|
5000
5087
|
}
|
|
5001
5088
|
const project = await loadProject(process.cwd());
|
|
5002
5089
|
if (project.isPlugin && project.pluginModule?.dependencies && project.pluginModule.dependencies.length > 0) {
|
|
5003
|
-
const pluginsDir =
|
|
5004
|
-
if (!
|
|
5005
|
-
await
|
|
5090
|
+
const pluginsDir = path26.join(process.cwd(), ".eliza", "plugins");
|
|
5091
|
+
if (!fs12.existsSync(pluginsDir)) {
|
|
5092
|
+
await fs12.promises.mkdir(pluginsDir, { recursive: true });
|
|
5006
5093
|
}
|
|
5007
|
-
const packageJsonPath =
|
|
5008
|
-
if (!
|
|
5094
|
+
const packageJsonPath = path26.join(pluginsDir, "package.json");
|
|
5095
|
+
if (!fs12.existsSync(packageJsonPath)) {
|
|
5009
5096
|
const packageJsonContent = {
|
|
5010
5097
|
name: "test-plugin-dependencies",
|
|
5011
5098
|
version: "1.0.0",
|
|
5012
5099
|
description: "A temporary package for installing test plugin dependencies",
|
|
5013
5100
|
dependencies: {}
|
|
5014
5101
|
};
|
|
5015
|
-
await
|
|
5102
|
+
await fs12.promises.writeFile(packageJsonPath, JSON.stringify(packageJsonContent, null, 2));
|
|
5016
5103
|
}
|
|
5017
|
-
const { installPlugin: installPlugin2 } = await import("./utils-
|
|
5104
|
+
const { installPlugin: installPlugin2 } = await import("./utils-DBLSDYBF.js");
|
|
5018
5105
|
for (const dependency of project.pluginModule.dependencies) {
|
|
5019
5106
|
await installPlugin2(dependency, pluginsDir);
|
|
5020
|
-
const dependencyPath =
|
|
5021
|
-
if (
|
|
5107
|
+
const dependencyPath = path26.join(pluginsDir, "node_modules", dependency);
|
|
5108
|
+
if (fs12.existsSync(dependencyPath)) {
|
|
5022
5109
|
try {
|
|
5023
5110
|
await runBunCommand(["install"], dependencyPath);
|
|
5024
5111
|
} catch (error) {
|
|
5025
|
-
|
|
5112
|
+
logger22.warn(
|
|
5026
5113
|
`[Test Command] Failed to install devDependencies for ${dependency}: ${error}`
|
|
5027
5114
|
);
|
|
5028
5115
|
}
|
|
@@ -5032,17 +5119,17 @@ async function installPluginDependencies(projectInfo) {
|
|
|
5032
5119
|
}
|
|
5033
5120
|
|
|
5034
5121
|
// src/commands/test/actions/component-tests.ts
|
|
5035
|
-
import { logger as
|
|
5122
|
+
import { logger as logger24 } from "@elizaos/core";
|
|
5036
5123
|
import { spawn as spawn2 } from "child_process";
|
|
5037
|
-
import
|
|
5124
|
+
import path28 from "path";
|
|
5038
5125
|
|
|
5039
5126
|
// src/utils/testing/tsc-validator.ts
|
|
5040
|
-
import { logger as
|
|
5041
|
-
import
|
|
5042
|
-
import { existsSync as
|
|
5127
|
+
import { logger as logger23 } from "@elizaos/core";
|
|
5128
|
+
import path27 from "path";
|
|
5129
|
+
import { existsSync as existsSync18 } from "fs";
|
|
5043
5130
|
async function runTypeCheck(projectPath, strict = true) {
|
|
5044
|
-
const tsconfigPath =
|
|
5045
|
-
if (!
|
|
5131
|
+
const tsconfigPath = path27.join(projectPath, "tsconfig.json");
|
|
5132
|
+
if (!existsSync18(tsconfigPath)) {
|
|
5046
5133
|
return {
|
|
5047
5134
|
success: false,
|
|
5048
5135
|
errors: [`No tsconfig.json found at ${tsconfigPath}`],
|
|
@@ -5054,7 +5141,7 @@ async function runTypeCheck(projectPath, strict = true) {
|
|
|
5054
5141
|
if (strict) {
|
|
5055
5142
|
args.push("--strict");
|
|
5056
5143
|
}
|
|
5057
|
-
const result = await bunExec("tsc", args, {
|
|
5144
|
+
const result = await bunExec("bun", ["x", "tsc", ...args], {
|
|
5058
5145
|
cwd: projectPath
|
|
5059
5146
|
});
|
|
5060
5147
|
const { stdout, stderr } = result;
|
|
@@ -5065,7 +5152,7 @@ async function runTypeCheck(projectPath, strict = true) {
|
|
|
5065
5152
|
warnings: stderr.includes("warning") ? [stderr] : []
|
|
5066
5153
|
};
|
|
5067
5154
|
} catch (error) {
|
|
5068
|
-
|
|
5155
|
+
logger23.error("TypeScript validation failed:", error);
|
|
5069
5156
|
return {
|
|
5070
5157
|
success: false,
|
|
5071
5158
|
errors: [`TypeScript validation error: ${error.message}`],
|
|
@@ -5079,39 +5166,39 @@ async function runComponentTests(testPath, options, projectInfo) {
|
|
|
5079
5166
|
const cwd = process.cwd();
|
|
5080
5167
|
const isPlugin2 = projectInfo.type === "elizaos-plugin";
|
|
5081
5168
|
if (!options.skipTypeCheck) {
|
|
5082
|
-
|
|
5169
|
+
logger24.info("Running TypeScript validation...");
|
|
5083
5170
|
const typeCheckResult = await runTypeCheck(cwd, true);
|
|
5084
5171
|
if (!typeCheckResult.success) {
|
|
5085
|
-
|
|
5086
|
-
typeCheckResult.errors.forEach((error) =>
|
|
5172
|
+
logger24.error("TypeScript validation failed:");
|
|
5173
|
+
typeCheckResult.errors.forEach((error) => logger24.error(error));
|
|
5087
5174
|
return { failed: true };
|
|
5088
5175
|
}
|
|
5089
|
-
|
|
5176
|
+
logger24.success("TypeScript validation passed");
|
|
5090
5177
|
}
|
|
5091
5178
|
if (!options.skipBuild) {
|
|
5092
5179
|
try {
|
|
5093
|
-
|
|
5180
|
+
logger24.info(`Building ${isPlugin2 ? "plugin" : "project"}...`);
|
|
5094
5181
|
await buildProject(cwd, isPlugin2);
|
|
5095
|
-
|
|
5182
|
+
logger24.success(`Build completed successfully`);
|
|
5096
5183
|
} catch (buildError) {
|
|
5097
|
-
|
|
5184
|
+
logger24.error(`Build failed: ${buildError}`);
|
|
5098
5185
|
return { failed: true };
|
|
5099
5186
|
}
|
|
5100
5187
|
}
|
|
5101
|
-
|
|
5188
|
+
logger24.info("Running component tests...");
|
|
5102
5189
|
return new Promise((resolve2) => {
|
|
5103
5190
|
const args = ["test", "--passWithNoTests"];
|
|
5104
5191
|
if (options.name) {
|
|
5105
5192
|
const baseName = processFilterName(options.name);
|
|
5106
5193
|
if (baseName) {
|
|
5107
|
-
|
|
5194
|
+
logger24.info(`Using test filter: ${baseName}`);
|
|
5108
5195
|
args.push("-t", baseName);
|
|
5109
5196
|
}
|
|
5110
5197
|
}
|
|
5111
5198
|
const monorepoRoot = UserEnvironment.getInstance().findMonorepoRoot(process.cwd());
|
|
5112
5199
|
const baseDir = monorepoRoot ?? process.cwd();
|
|
5113
|
-
const targetPath = testPath ?
|
|
5114
|
-
|
|
5200
|
+
const targetPath = testPath ? path28.resolve(baseDir, testPath) : process.cwd();
|
|
5201
|
+
logger24.info(`Executing: bun ${args.join(" ")} in ${targetPath}`);
|
|
5115
5202
|
const child = spawn2("bun", args, {
|
|
5116
5203
|
stdio: "inherit",
|
|
5117
5204
|
shell: false,
|
|
@@ -5120,37 +5207,37 @@ async function runComponentTests(testPath, options, projectInfo) {
|
|
|
5120
5207
|
...process.env,
|
|
5121
5208
|
FORCE_COLOR: "1",
|
|
5122
5209
|
// Force color output
|
|
5123
|
-
CI: "
|
|
5124
|
-
//
|
|
5210
|
+
CI: ""
|
|
5211
|
+
// Override CI to empty string (some tools check existence, but most check truthiness)
|
|
5125
5212
|
}
|
|
5126
5213
|
});
|
|
5127
5214
|
child.on("close", (code) => {
|
|
5128
|
-
|
|
5215
|
+
logger24.info("Component tests completed");
|
|
5129
5216
|
resolve2({ failed: code !== 0 });
|
|
5130
5217
|
});
|
|
5131
5218
|
child.on("error", (error) => {
|
|
5132
|
-
|
|
5219
|
+
logger24.error("Error running component tests:", error);
|
|
5133
5220
|
resolve2({ failed: true });
|
|
5134
5221
|
});
|
|
5135
5222
|
});
|
|
5136
5223
|
}
|
|
5137
5224
|
|
|
5138
5225
|
// src/commands/test/actions/e2e-tests.ts
|
|
5139
|
-
import { logger as
|
|
5226
|
+
import { logger as logger25 } from "@elizaos/core";
|
|
5140
5227
|
import * as dotenv2 from "dotenv";
|
|
5141
|
-
import * as
|
|
5142
|
-
import
|
|
5228
|
+
import * as fs13 from "fs";
|
|
5229
|
+
import path29 from "path";
|
|
5143
5230
|
async function runE2eTests(testPath, options, projectInfo) {
|
|
5144
5231
|
if (!options.skipBuild) {
|
|
5145
5232
|
try {
|
|
5146
5233
|
const cwd = process.cwd();
|
|
5147
5234
|
const isPlugin2 = projectInfo.type === "elizaos-plugin";
|
|
5148
|
-
|
|
5235
|
+
logger25.info(`Building ${isPlugin2 ? "plugin" : "project"}...`);
|
|
5149
5236
|
await buildProject(cwd, isPlugin2);
|
|
5150
|
-
|
|
5237
|
+
logger25.info(`Build completed successfully`);
|
|
5151
5238
|
} catch (buildError) {
|
|
5152
|
-
|
|
5153
|
-
|
|
5239
|
+
logger25.error(`Build error: ${buildError}`);
|
|
5240
|
+
logger25.warn(`Attempting to continue with tests despite build error`);
|
|
5154
5241
|
}
|
|
5155
5242
|
}
|
|
5156
5243
|
let server;
|
|
@@ -5160,10 +5247,10 @@ async function runE2eTests(testPath, options, projectInfo) {
|
|
|
5160
5247
|
const moduleLoader = getModuleLoader();
|
|
5161
5248
|
const serverModule = await moduleLoader.load("@elizaos/server");
|
|
5162
5249
|
const { AgentServer, jsonToCharacter, loadCharacterTryPath } = serverModule;
|
|
5163
|
-
const elizaDir =
|
|
5164
|
-
const packageName =
|
|
5250
|
+
const elizaDir = path29.join(process.cwd(), ".eliza");
|
|
5251
|
+
const packageName = path29.basename(process.cwd());
|
|
5165
5252
|
const timestamp = Date.now();
|
|
5166
|
-
const uniqueDbDir =
|
|
5253
|
+
const uniqueDbDir = path29.join(process.cwd(), ".elizadb-test", `${packageName}-${timestamp}`);
|
|
5167
5254
|
const elizaDbDir = uniqueDbDir;
|
|
5168
5255
|
const envInfo = await UserEnvironment.getInstanceInfo();
|
|
5169
5256
|
const envFilePath = envInfo.paths.envFilePath;
|
|
@@ -5172,88 +5259,88 @@ async function runE2eTests(testPath, options, projectInfo) {
|
|
|
5172
5259
|
console.info(`Database directory: ${elizaDbDir}`);
|
|
5173
5260
|
console.info(`Environment file: ${envFilePath}`);
|
|
5174
5261
|
console.info(`Package name: ${packageName}, Timestamp: ${timestamp}`);
|
|
5175
|
-
if (
|
|
5262
|
+
if (fs13.existsSync(elizaDbDir)) {
|
|
5176
5263
|
console.info(`Cleaning up existing database directory: ${elizaDbDir}`);
|
|
5177
5264
|
try {
|
|
5178
|
-
|
|
5265
|
+
fs13.rmSync(elizaDbDir, { recursive: true, force: true });
|
|
5179
5266
|
console.info(`Successfully cleaned up existing database directory`);
|
|
5180
5267
|
} catch (error) {
|
|
5181
5268
|
console.warn(`Failed to clean up existing database directory: ${error}`);
|
|
5182
5269
|
}
|
|
5183
5270
|
}
|
|
5184
5271
|
console.info(`Creating fresh database directory: ${elizaDbDir}`);
|
|
5185
|
-
|
|
5272
|
+
fs13.mkdirSync(elizaDbDir, { recursive: true });
|
|
5186
5273
|
console.info(`Created database directory: ${elizaDbDir}`);
|
|
5187
5274
|
process.env.PGLITE_DATA_DIR = elizaDbDir;
|
|
5188
5275
|
console.info(`Set PGLITE_DATA_DIR to: ${elizaDbDir}`);
|
|
5189
|
-
if (
|
|
5190
|
-
|
|
5276
|
+
if (fs13.existsSync(envFilePath)) {
|
|
5277
|
+
logger25.info(`Loading environment variables from: ${envFilePath}`);
|
|
5191
5278
|
dotenv2.config({ path: envFilePath });
|
|
5192
|
-
|
|
5279
|
+
logger25.info("Environment variables loaded");
|
|
5193
5280
|
} else {
|
|
5194
|
-
|
|
5281
|
+
logger25.warn(`Environment file not found: ${envFilePath}`);
|
|
5195
5282
|
}
|
|
5196
5283
|
const postgresUrl = process.env.POSTGRES_URL;
|
|
5197
|
-
|
|
5284
|
+
logger25.info(
|
|
5198
5285
|
`PostgreSQL URL for e2e tests: ${postgresUrl ? "found" : "not found (will use PGlite)"}`
|
|
5199
5286
|
);
|
|
5200
|
-
|
|
5287
|
+
logger25.info("Creating server instance...");
|
|
5201
5288
|
server = new AgentServer();
|
|
5202
|
-
|
|
5203
|
-
|
|
5289
|
+
logger25.info("Server instance created");
|
|
5290
|
+
logger25.info("Initializing server...");
|
|
5204
5291
|
try {
|
|
5205
5292
|
await server.initialize({
|
|
5206
5293
|
dataDir: elizaDbDir,
|
|
5207
5294
|
postgresUrl
|
|
5208
5295
|
});
|
|
5209
|
-
|
|
5296
|
+
logger25.info("Server initialized successfully");
|
|
5210
5297
|
} catch (initError) {
|
|
5211
|
-
|
|
5298
|
+
logger25.error("Server initialization failed:", initError);
|
|
5212
5299
|
throw initError;
|
|
5213
5300
|
}
|
|
5214
5301
|
let project;
|
|
5215
5302
|
try {
|
|
5216
|
-
|
|
5303
|
+
logger25.info("Attempting to load project or plugin...");
|
|
5217
5304
|
const monorepoRoot = UserEnvironment.getInstance().findMonorepoRoot(process.cwd());
|
|
5218
5305
|
const baseDir = monorepoRoot ?? process.cwd();
|
|
5219
|
-
const targetPath = testPath ?
|
|
5306
|
+
const targetPath = testPath ? path29.resolve(baseDir, testPath) : process.cwd();
|
|
5220
5307
|
project = await loadProject(targetPath);
|
|
5221
5308
|
if (!project || !project.agents || project.agents.length === 0) {
|
|
5222
5309
|
throw new Error("No agents found in project configuration");
|
|
5223
5310
|
}
|
|
5224
|
-
|
|
5225
|
-
|
|
5311
|
+
logger25.info(`Found ${project.agents.length} agents`);
|
|
5312
|
+
logger25.info("Setting up server properties...");
|
|
5226
5313
|
server.startAgent = async (character) => {
|
|
5227
|
-
|
|
5314
|
+
logger25.info(`Starting agent for character ${character.name}`);
|
|
5228
5315
|
return startAgent(character, server, void 0, [], { isTestMode: true });
|
|
5229
5316
|
};
|
|
5230
5317
|
server.loadCharacterTryPath = loadCharacterTryPath;
|
|
5231
5318
|
server.jsonToCharacter = jsonToCharacter;
|
|
5232
|
-
|
|
5319
|
+
logger25.info("Server properties set up");
|
|
5233
5320
|
const desiredPort = options.port || Number.parseInt(process.env.SERVER_PORT || "3000");
|
|
5234
5321
|
const serverPort = await findNextAvailablePort(desiredPort);
|
|
5235
5322
|
if (serverPort !== desiredPort) {
|
|
5236
|
-
|
|
5323
|
+
logger25.warn(`Port ${desiredPort} is in use for testing, using port ${serverPort} instead.`);
|
|
5237
5324
|
}
|
|
5238
|
-
|
|
5325
|
+
logger25.info("Starting server...");
|
|
5239
5326
|
try {
|
|
5240
5327
|
await server.start(serverPort);
|
|
5241
|
-
|
|
5328
|
+
logger25.info("Server started successfully on port", serverPort);
|
|
5242
5329
|
} catch (error) {
|
|
5243
|
-
|
|
5330
|
+
logger25.error("Error starting server:", error);
|
|
5244
5331
|
if (error instanceof Error) {
|
|
5245
|
-
|
|
5246
|
-
|
|
5332
|
+
logger25.error("Error details:", error.message);
|
|
5333
|
+
logger25.error("Stack trace:", error.stack);
|
|
5247
5334
|
}
|
|
5248
5335
|
throw error;
|
|
5249
5336
|
}
|
|
5250
5337
|
try {
|
|
5251
|
-
|
|
5338
|
+
logger25.info(
|
|
5252
5339
|
`Found ${project.agents.length} agents in ${project.isPlugin ? "plugin" : "project"}`
|
|
5253
5340
|
);
|
|
5254
5341
|
if (project.isPlugin || project.agents.length === 0) {
|
|
5255
5342
|
process.env.ELIZA_TESTING_PLUGIN = "true";
|
|
5256
|
-
|
|
5343
|
+
logger25.info("Using default Eliza character as test agent");
|
|
5257
5344
|
try {
|
|
5258
5345
|
const pluginUnderTest = project.pluginModule;
|
|
5259
5346
|
if (!pluginUnderTest) {
|
|
@@ -5276,16 +5363,16 @@ async function runE2eTests(testPath, options, projectInfo) {
|
|
|
5276
5363
|
plugins: runtime.plugins
|
|
5277
5364
|
// Pass all plugins, not just the one under test
|
|
5278
5365
|
});
|
|
5279
|
-
|
|
5366
|
+
logger25.info("Default test agent started successfully");
|
|
5280
5367
|
} catch (pluginError) {
|
|
5281
|
-
|
|
5368
|
+
logger25.error(`Error starting plugin test agent: ${pluginError}`);
|
|
5282
5369
|
throw pluginError;
|
|
5283
5370
|
}
|
|
5284
5371
|
} else {
|
|
5285
5372
|
for (const agent2 of project.agents) {
|
|
5286
5373
|
try {
|
|
5287
5374
|
const originalCharacter = { ...agent2.character };
|
|
5288
|
-
|
|
5375
|
+
logger25.debug(`Starting agent: ${originalCharacter.name}`);
|
|
5289
5376
|
const runtime = await startAgent(
|
|
5290
5377
|
originalCharacter,
|
|
5291
5378
|
server,
|
|
@@ -5298,28 +5385,28 @@ async function runE2eTests(testPath, options, projectInfo) {
|
|
|
5298
5385
|
projectAgents.push(agent2);
|
|
5299
5386
|
await new Promise((resolve2) => setTimeout(resolve2, 1e3));
|
|
5300
5387
|
} catch (agentError) {
|
|
5301
|
-
|
|
5388
|
+
logger25.error(`Error starting agent ${agent2.character.name}:`, agentError);
|
|
5302
5389
|
if (agentError instanceof Error) {
|
|
5303
|
-
|
|
5304
|
-
|
|
5390
|
+
logger25.error("Error details:", agentError.message);
|
|
5391
|
+
logger25.error("Stack trace:", agentError.stack);
|
|
5305
5392
|
}
|
|
5306
|
-
|
|
5393
|
+
logger25.warn(`Skipping agent ${agent2.character.name} due to startup error`);
|
|
5307
5394
|
}
|
|
5308
5395
|
}
|
|
5309
5396
|
}
|
|
5310
5397
|
if (runtimes.length === 0) {
|
|
5311
5398
|
throw new Error("Failed to start any agents from project");
|
|
5312
5399
|
}
|
|
5313
|
-
|
|
5400
|
+
logger25.debug(`Successfully started ${runtimes.length} agents for testing`);
|
|
5314
5401
|
let totalFailed = 0;
|
|
5315
5402
|
let anyTestsFound = false;
|
|
5316
5403
|
for (let i = 0; i < runtimes.length; i++) {
|
|
5317
5404
|
const runtime = runtimes[i];
|
|
5318
5405
|
const projectAgent = projectAgents[i];
|
|
5319
5406
|
if (project.isPlugin) {
|
|
5320
|
-
|
|
5407
|
+
logger25.debug(`Running tests for plugin: ${project.pluginModule?.name}`);
|
|
5321
5408
|
} else {
|
|
5322
|
-
|
|
5409
|
+
logger25.debug(`Running tests for agent: ${runtime.character.name}`);
|
|
5323
5410
|
}
|
|
5324
5411
|
const testRunner = new TestRunner(runtime, projectAgent);
|
|
5325
5412
|
const currentDirInfo = projectInfo;
|
|
@@ -5340,17 +5427,17 @@ async function runE2eTests(testPath, options, projectInfo) {
|
|
|
5340
5427
|
}
|
|
5341
5428
|
return { failed: anyTestsFound ? totalFailed > 0 : false };
|
|
5342
5429
|
} catch (error) {
|
|
5343
|
-
|
|
5430
|
+
logger25.error("Error in runE2eTests:", error);
|
|
5344
5431
|
if (error instanceof Error) {
|
|
5345
|
-
|
|
5346
|
-
|
|
5432
|
+
logger25.error("Error details:", error.message);
|
|
5433
|
+
logger25.error("Stack trace:", error.stack);
|
|
5347
5434
|
} else {
|
|
5348
|
-
|
|
5349
|
-
|
|
5435
|
+
logger25.error("Unknown error type:", typeof error);
|
|
5436
|
+
logger25.error("Error value:", error);
|
|
5350
5437
|
try {
|
|
5351
|
-
|
|
5438
|
+
logger25.error("Stringified error:", JSON.stringify(error, null, 2));
|
|
5352
5439
|
} catch (e) {
|
|
5353
|
-
|
|
5440
|
+
logger25.error("Could not stringify error:", e);
|
|
5354
5441
|
}
|
|
5355
5442
|
}
|
|
5356
5443
|
return { failed: true };
|
|
@@ -5359,47 +5446,47 @@ async function runE2eTests(testPath, options, projectInfo) {
|
|
|
5359
5446
|
delete process.env.ELIZA_TESTING_PLUGIN;
|
|
5360
5447
|
}
|
|
5361
5448
|
try {
|
|
5362
|
-
if (
|
|
5449
|
+
if (fs13.existsSync(elizaDbDir)) {
|
|
5363
5450
|
console.info(`Cleaning up test database directory: ${elizaDbDir}`);
|
|
5364
|
-
|
|
5451
|
+
fs13.rmSync(elizaDbDir, { recursive: true, force: true });
|
|
5365
5452
|
console.info(`Successfully cleaned up test database directory`);
|
|
5366
5453
|
}
|
|
5367
|
-
const testDir =
|
|
5368
|
-
if (
|
|
5369
|
-
|
|
5454
|
+
const testDir = path29.dirname(elizaDbDir);
|
|
5455
|
+
if (fs13.existsSync(testDir) && fs13.readdirSync(testDir).length === 0) {
|
|
5456
|
+
fs13.rmSync(testDir, { recursive: true, force: true });
|
|
5370
5457
|
}
|
|
5371
5458
|
} catch (cleanupError) {
|
|
5372
5459
|
console.warn(`Failed to clean up test database directory: ${cleanupError}`);
|
|
5373
5460
|
}
|
|
5374
5461
|
}
|
|
5375
5462
|
} catch (error) {
|
|
5376
|
-
|
|
5463
|
+
logger25.error("Error in runE2eTests:", error);
|
|
5377
5464
|
if (error instanceof Error) {
|
|
5378
|
-
|
|
5379
|
-
|
|
5465
|
+
logger25.error("Error details:", error.message);
|
|
5466
|
+
logger25.error("Stack trace:", error.stack);
|
|
5380
5467
|
} else {
|
|
5381
|
-
|
|
5382
|
-
|
|
5468
|
+
logger25.error("Unknown error type:", typeof error);
|
|
5469
|
+
logger25.error("Error value:", error);
|
|
5383
5470
|
try {
|
|
5384
|
-
|
|
5471
|
+
logger25.error("Stringified error:", JSON.stringify(error, null, 2));
|
|
5385
5472
|
} catch (e) {
|
|
5386
|
-
|
|
5473
|
+
logger25.error("Could not stringify error:", e);
|
|
5387
5474
|
}
|
|
5388
5475
|
}
|
|
5389
5476
|
return { failed: true };
|
|
5390
5477
|
}
|
|
5391
5478
|
} catch (error) {
|
|
5392
|
-
|
|
5479
|
+
logger25.error("Error in runE2eTests:", error);
|
|
5393
5480
|
if (error instanceof Error) {
|
|
5394
|
-
|
|
5395
|
-
|
|
5481
|
+
logger25.error("Error details:", error.message);
|
|
5482
|
+
logger25.error("Stack trace:", error.stack);
|
|
5396
5483
|
} else {
|
|
5397
|
-
|
|
5398
|
-
|
|
5484
|
+
logger25.error("Unknown error type:", typeof error);
|
|
5485
|
+
logger25.error("Error value:", error);
|
|
5399
5486
|
try {
|
|
5400
|
-
|
|
5487
|
+
logger25.error("Stringified error:", JSON.stringify(error, null, 2));
|
|
5401
5488
|
} catch (e) {
|
|
5402
|
-
|
|
5489
|
+
logger25.error("Could not stringify error:", e);
|
|
5403
5490
|
}
|
|
5404
5491
|
}
|
|
5405
5492
|
return { failed: true };
|
|
@@ -5412,15 +5499,15 @@ async function runAllTests(testPath, options) {
|
|
|
5412
5499
|
if (!options.skipBuild) {
|
|
5413
5500
|
const componentResult = await runComponentTests(testPath, options, projectInfo);
|
|
5414
5501
|
if (componentResult.failed) {
|
|
5415
|
-
|
|
5502
|
+
logger26.error("Component tests failed. Continuing to e2e tests...");
|
|
5416
5503
|
}
|
|
5417
5504
|
}
|
|
5418
5505
|
const e2eResult = await runE2eTests(testPath, options, projectInfo);
|
|
5419
5506
|
if (e2eResult.failed) {
|
|
5420
|
-
|
|
5507
|
+
logger26.error("E2E tests failed.");
|
|
5421
5508
|
process.exit(1);
|
|
5422
5509
|
}
|
|
5423
|
-
|
|
5510
|
+
logger26.success("All tests passed successfully!");
|
|
5424
5511
|
process.exit(0);
|
|
5425
5512
|
}
|
|
5426
5513
|
|
|
@@ -5428,43 +5515,47 @@ async function runAllTests(testPath, options) {
|
|
|
5428
5515
|
import * as net from "net";
|
|
5429
5516
|
|
|
5430
5517
|
// src/commands/test/utils/plugin-utils.ts
|
|
5431
|
-
import { logger as
|
|
5432
|
-
import * as
|
|
5433
|
-
import
|
|
5518
|
+
import { logger as logger27 } from "@elizaos/core";
|
|
5519
|
+
import * as fs14 from "fs";
|
|
5520
|
+
import path30 from "path";
|
|
5434
5521
|
|
|
5435
5522
|
// src/commands/test/index.ts
|
|
5436
5523
|
var test = new Command10().name("test").description("Run tests for the current project or a specified plugin").argument("[path]", "Optional path to the project or plugin to test").addOption(
|
|
5437
5524
|
new Option2("-t, --type <type>", "the type of test to run").choices(["component", "e2e", "all"]).default("all")
|
|
5438
5525
|
).option("--port <port>", "The port to run e2e tests on", validatePort).option("--name <name>", "Filter tests by name").option("--skip-build", "Skip building before running tests").option("--skip-type-check", "Skip TypeScript validation before running tests").hook("preAction", async (thisCommand) => {
|
|
5439
5526
|
const testPath = thisCommand.args[0];
|
|
5527
|
+
const options = thisCommand.opts();
|
|
5528
|
+
if (options.type === "component") {
|
|
5529
|
+
return;
|
|
5530
|
+
}
|
|
5440
5531
|
const projectInfo = getProjectType(testPath);
|
|
5441
5532
|
await installPluginDependencies(projectInfo);
|
|
5442
5533
|
}).action(async (testPath, options) => {
|
|
5443
|
-
|
|
5534
|
+
logger28.info("Starting tests...");
|
|
5444
5535
|
try {
|
|
5445
5536
|
const projectInfo = getProjectType(testPath);
|
|
5446
5537
|
switch (options.type) {
|
|
5447
5538
|
case "component":
|
|
5448
|
-
|
|
5539
|
+
logger28.info("Running component tests only...");
|
|
5449
5540
|
const componentResult = await runComponentTests(testPath, options, projectInfo);
|
|
5450
5541
|
if (componentResult.failed) {
|
|
5451
|
-
|
|
5542
|
+
logger28.error("Component tests failed.");
|
|
5452
5543
|
process.exit(1);
|
|
5453
5544
|
}
|
|
5454
|
-
|
|
5545
|
+
logger28.success("Component tests passed successfully!");
|
|
5455
5546
|
break;
|
|
5456
5547
|
case "e2e":
|
|
5457
|
-
|
|
5548
|
+
logger28.info("Running e2e tests only...");
|
|
5458
5549
|
const e2eResult = await runE2eTests(testPath, options, projectInfo);
|
|
5459
5550
|
if (e2eResult.failed) {
|
|
5460
|
-
|
|
5551
|
+
logger28.error("E2E tests failed.");
|
|
5461
5552
|
process.exit(1);
|
|
5462
5553
|
}
|
|
5463
|
-
|
|
5554
|
+
logger28.success("E2E tests passed successfully!");
|
|
5464
5555
|
break;
|
|
5465
5556
|
case "all":
|
|
5466
5557
|
default:
|
|
5467
|
-
|
|
5558
|
+
logger28.info("Running all tests...");
|
|
5468
5559
|
await runAllTests(testPath, options);
|
|
5469
5560
|
break;
|
|
5470
5561
|
}
|
|
@@ -5475,7 +5566,7 @@ var test = new Command10().name("test").description("Run tests for the current p
|
|
|
5475
5566
|
});
|
|
5476
5567
|
|
|
5477
5568
|
// src/index.ts
|
|
5478
|
-
import { logger as
|
|
5569
|
+
import { logger as logger29 } from "@elizaos/core";
|
|
5479
5570
|
import { Command as Command11 } from "commander";
|
|
5480
5571
|
process.env.NODE_OPTIONS = "--no-deprecation";
|
|
5481
5572
|
process.env.NODE_NO_WARNINGS = "1";
|
|
@@ -5496,19 +5587,19 @@ var shutdownState = {
|
|
|
5496
5587
|
};
|
|
5497
5588
|
async function gracefulShutdown(signal) {
|
|
5498
5589
|
if (!shutdownState.tryInitiateShutdown()) {
|
|
5499
|
-
|
|
5590
|
+
logger29.debug(`Ignoring ${signal} - shutdown already in progress`);
|
|
5500
5591
|
return;
|
|
5501
5592
|
}
|
|
5502
|
-
|
|
5593
|
+
logger29.info(`Received ${signal}, shutting down gracefully...`);
|
|
5503
5594
|
try {
|
|
5504
5595
|
const serverWasStopped = await stopServer();
|
|
5505
5596
|
if (serverWasStopped) {
|
|
5506
|
-
|
|
5597
|
+
logger29.info("Server stopped successfully");
|
|
5507
5598
|
}
|
|
5508
5599
|
} catch (error) {
|
|
5509
5600
|
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
5510
|
-
|
|
5511
|
-
|
|
5601
|
+
logger29.error(`Error stopping server: ${errorMessage}`);
|
|
5602
|
+
logger29.debug("Full error details:", error);
|
|
5512
5603
|
}
|
|
5513
5604
|
const exitCode = signal === "SIGINT" ? 130 : signal === "SIGTERM" ? 143 : 0;
|
|
5514
5605
|
process.exit(exitCode);
|
|
@@ -5542,6 +5633,6 @@ async function main() {
|
|
|
5542
5633
|
await program.parseAsync();
|
|
5543
5634
|
}
|
|
5544
5635
|
main().catch((error) => {
|
|
5545
|
-
|
|
5636
|
+
logger29.error("An error occurred:", error);
|
|
5546
5637
|
process.exit(1);
|
|
5547
5638
|
});
|