@elizaos/cli 1.0.19 → 1.1.0
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 +0 -1
- package/dist/assets/{index-ZEZhrfaX.js → index-BfiDOOs1.js} +603 -462
- package/dist/assets/index-BfiDOOs1.js.br +0 -0
- package/dist/assets/{index-ZEZhrfaX.js.map → index-BfiDOOs1.js.map} +1 -1
- package/dist/assets/{index-hOfpSXIW.js → index-DPzwlf4B.js} +2 -2
- package/dist/assets/index-DPzwlf4B.js.br +0 -0
- package/dist/assets/{index-hOfpSXIW.js.map → index-DPzwlf4B.js.map} +1 -1
- package/dist/{chunk-JVEHLVLY.js → chunk-6NQXP77K.js} +7 -8
- package/dist/{chunk-W4NJVJQV.js → chunk-7PPBVSWE.js} +21 -3
- package/dist/{chunk-OEHDDUQ4.js → chunk-F3T7CP3N.js} +111 -370
- package/dist/chunk-SKZWKDJV.js +281 -0
- package/dist/{chunk-ED42YJZA.js → chunk-UJASHW4Z.js} +367 -232
- package/dist/commands/agent/actions/index.js +2 -2
- package/dist/commands/agent/index.js +2 -2
- package/dist/commands/create/actions/index.d.ts +1 -8
- package/dist/commands/create/actions/index.js +6 -6
- package/dist/commands/create/index.js +5 -4
- package/dist/index.html +1 -1
- package/dist/index.js +54 -30
- package/dist/{plugin-creator-4QMSSR4X.js → plugin-creator-35CAJF4O.js} +1 -1
- package/dist/{registry-NIGTUGFP.js → registry-URDUOPHD.js} +2 -2
- package/dist/setup-MMMQEN65.js +20 -0
- package/dist/templates/project-starter/package.json +4 -4
- package/dist/templates/project-starter/src/character.ts +1 -0
- package/dist/templates/project-tee-starter/package.json +3 -3
- package/dist/{utils-TW6X75NO.js → utils-3X6GHWTH.js} +18 -2
- package/package.json +5 -5
- package/templates/project-starter/package.json +4 -4
- package/templates/project-starter/src/character.ts +1 -0
- package/templates/project-tee-starter/package.json +3 -3
- package/dist/assets/index-ZEZhrfaX.js.br +0 -0
- package/dist/assets/index-hOfpSXIW.js.br +0 -0
|
@@ -3,35 +3,24 @@ import { createRequire } from 'module';
|
|
|
3
3
|
const require = createRequire(import.meta.url);
|
|
4
4
|
|
|
5
5
|
import {
|
|
6
|
-
|
|
6
|
+
setupProjectEnvironment
|
|
7
|
+
} from "./chunk-SKZWKDJV.js";
|
|
8
|
+
import {
|
|
9
|
+
buildProjectWithSpinner,
|
|
7
10
|
copyTemplate,
|
|
8
|
-
|
|
11
|
+
createTask,
|
|
9
12
|
getDisplayDirectory,
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
promptAndStoreOllamaConfig,
|
|
14
|
-
promptAndStoreOllamaEmbeddingConfig,
|
|
15
|
-
promptAndStoreOpenAIKey,
|
|
16
|
-
promptAndStoreOpenRouterKey,
|
|
17
|
-
promptAndStorePostgresUrl,
|
|
18
|
-
setupPgLite
|
|
19
|
-
} from "./chunk-ED42YJZA.js";
|
|
13
|
+
installDependenciesWithSpinner,
|
|
14
|
+
runTasks
|
|
15
|
+
} from "./chunk-UJASHW4Z.js";
|
|
20
16
|
|
|
21
17
|
// src/characters/eliza.ts
|
|
22
|
-
import { existsSync, readFileSync } from "fs";
|
|
23
|
-
import { resolve, dirname } from "path";
|
|
24
|
-
import { fileURLToPath } from "url";
|
|
25
|
-
var __filename = fileURLToPath(import.meta.url);
|
|
26
|
-
var __dirname = dirname(__filename);
|
|
27
|
-
var imagePath = resolve(__dirname, "./elizaos-avatar.png");
|
|
28
|
-
var avatar = existsSync(imagePath) ? `data:image/png;base64,${readFileSync(imagePath).toString("base64")}` : "";
|
|
29
18
|
var baseCharacter = {
|
|
30
19
|
name: "Eliza",
|
|
31
20
|
plugins: ["@elizaos/plugin-sql", "@elizaos/plugin-bootstrap"],
|
|
32
21
|
secrets: {},
|
|
33
22
|
settings: {
|
|
34
|
-
avatar
|
|
23
|
+
avatar: "https://elizaos.github.io/eliza-avatars/Eliza/portrait.png"
|
|
35
24
|
},
|
|
36
25
|
system: "Respond to all messages in a helpful, conversational manner. Provide assistance on a wide range of topics, using knowledge when needed. Be concise but thorough, friendly but professional. Use humor when appropriate and be empathetic to user needs. Provide valuable information and insights when questions are asked.",
|
|
37
26
|
bio: [
|
|
@@ -232,19 +221,18 @@ function getElizaCharacter() {
|
|
|
232
221
|
|
|
233
222
|
// src/commands/create/actions/creators.ts
|
|
234
223
|
import { join } from "path";
|
|
235
|
-
import
|
|
224
|
+
import fs2 from "fs/promises";
|
|
236
225
|
import * as clack2 from "@clack/prompts";
|
|
237
226
|
import colors from "yoctocolors";
|
|
238
227
|
|
|
239
228
|
// src/commands/create/utils/validation.ts
|
|
240
|
-
import { existsSync
|
|
229
|
+
import { existsSync } from "fs";
|
|
241
230
|
import fs from "fs/promises";
|
|
242
231
|
import { z as z2 } from "zod";
|
|
243
232
|
|
|
244
233
|
// src/commands/create/types.ts
|
|
245
234
|
import { z } from "zod";
|
|
246
235
|
var initOptionsSchema = z.object({
|
|
247
|
-
dir: z.string().default("."),
|
|
248
236
|
yes: z.boolean().default(false),
|
|
249
237
|
type: z.enum(["project", "plugin", "agent", "tee"]).default("project")
|
|
250
238
|
});
|
|
@@ -319,7 +307,7 @@ function processPluginName(name) {
|
|
|
319
307
|
}
|
|
320
308
|
async function validateTargetDirectory(targetDir) {
|
|
321
309
|
try {
|
|
322
|
-
if (!
|
|
310
|
+
if (!existsSync(targetDir)) {
|
|
323
311
|
return { isValid: true };
|
|
324
312
|
}
|
|
325
313
|
const entries = await fs.readdir(targetDir);
|
|
@@ -464,315 +452,12 @@ async function selectEmbeddingModel() {
|
|
|
464
452
|
return embeddingModel;
|
|
465
453
|
}
|
|
466
454
|
|
|
467
|
-
// src/commands/create/actions/setup.ts
|
|
468
|
-
import { existsSync as existsSync3 } from "fs";
|
|
469
|
-
import fs2 from "fs/promises";
|
|
470
|
-
import { execa } from "execa";
|
|
471
|
-
async function createProjectDirectories(targetDir) {
|
|
472
|
-
await ensureElizaDir(targetDir);
|
|
473
|
-
}
|
|
474
|
-
async function setupAIModelConfig(aiModel, envFilePath, isNonInteractive = false) {
|
|
475
|
-
try {
|
|
476
|
-
switch (aiModel) {
|
|
477
|
-
case "local": {
|
|
478
|
-
console.info("[\u221A] Using Local AI - no additional configuration needed");
|
|
479
|
-
break;
|
|
480
|
-
}
|
|
481
|
-
case "openai": {
|
|
482
|
-
if (isNonInteractive) {
|
|
483
|
-
let content = "";
|
|
484
|
-
if (existsSync3(envFilePath)) {
|
|
485
|
-
content = await fs2.readFile(envFilePath, "utf8");
|
|
486
|
-
}
|
|
487
|
-
if (content && !content.endsWith("\n")) {
|
|
488
|
-
content += "\n";
|
|
489
|
-
}
|
|
490
|
-
content += "\n# AI Model Configuration\n";
|
|
491
|
-
content += "# OpenAI Configuration\n";
|
|
492
|
-
content += "OPENAI_API_KEY=your_openai_api_key_here\n";
|
|
493
|
-
content += "# Get your API key from: https://platform.openai.com/api-keys\n";
|
|
494
|
-
await fs2.writeFile(envFilePath, content, "utf8");
|
|
495
|
-
console.info("[\u221A] OpenAI placeholder configuration added to .env file");
|
|
496
|
-
} else {
|
|
497
|
-
await promptAndStoreOpenAIKey(envFilePath);
|
|
498
|
-
}
|
|
499
|
-
break;
|
|
500
|
-
}
|
|
501
|
-
case "claude": {
|
|
502
|
-
if (isNonInteractive) {
|
|
503
|
-
let content = "";
|
|
504
|
-
if (existsSync3(envFilePath)) {
|
|
505
|
-
content = await fs2.readFile(envFilePath, "utf8");
|
|
506
|
-
}
|
|
507
|
-
if (content && !content.endsWith("\n")) {
|
|
508
|
-
content += "\n";
|
|
509
|
-
}
|
|
510
|
-
content += "\n# AI Model Configuration\n";
|
|
511
|
-
content += "# Anthropic API Configuration\n";
|
|
512
|
-
content += "ANTHROPIC_API_KEY=your_anthropic_api_key_here\n";
|
|
513
|
-
content += "# Get your API key from: https://console.anthropic.com/\n";
|
|
514
|
-
await fs2.writeFile(envFilePath, content, "utf8");
|
|
515
|
-
console.info("[\u221A] Anthropic API placeholder configuration added to .env file");
|
|
516
|
-
} else {
|
|
517
|
-
await promptAndStoreAnthropicKey(envFilePath);
|
|
518
|
-
}
|
|
519
|
-
break;
|
|
520
|
-
}
|
|
521
|
-
case "openrouter": {
|
|
522
|
-
if (isNonInteractive) {
|
|
523
|
-
let content = "";
|
|
524
|
-
if (existsSync3(envFilePath)) {
|
|
525
|
-
content = await fs2.readFile(envFilePath, "utf8");
|
|
526
|
-
}
|
|
527
|
-
if (content && !content.endsWith("\n")) {
|
|
528
|
-
content += "\n";
|
|
529
|
-
}
|
|
530
|
-
content += "\n# AI Model Configuration\n";
|
|
531
|
-
content += "# OpenRouter Configuration\n";
|
|
532
|
-
content += "OPENROUTER_API_KEY=your_openrouter_api_key_here\n";
|
|
533
|
-
content += "# Get your API key from: https://openrouter.ai/keys\n";
|
|
534
|
-
await fs2.writeFile(envFilePath, content, "utf8");
|
|
535
|
-
console.info("[\u221A] OpenRouter placeholder configuration added to .env file");
|
|
536
|
-
} else {
|
|
537
|
-
await promptAndStoreOpenRouterKey(envFilePath);
|
|
538
|
-
}
|
|
539
|
-
break;
|
|
540
|
-
}
|
|
541
|
-
case "ollama": {
|
|
542
|
-
if (isNonInteractive) {
|
|
543
|
-
let content = "";
|
|
544
|
-
if (existsSync3(envFilePath)) {
|
|
545
|
-
content = await fs2.readFile(envFilePath, "utf8");
|
|
546
|
-
}
|
|
547
|
-
if (content && !content.endsWith("\n")) {
|
|
548
|
-
content += "\n";
|
|
549
|
-
}
|
|
550
|
-
content += "\n# AI Model Configuration\n";
|
|
551
|
-
content += "# Ollama Configuration\n";
|
|
552
|
-
content += "OLLAMA_API_ENDPOINT=http://localhost:11434\n";
|
|
553
|
-
content += "OLLAMA_MODEL=llama2\n";
|
|
554
|
-
content += "USE_OLLAMA_TEXT_MODELS=true\n";
|
|
555
|
-
content += "# Make sure Ollama is installed and running: https://ollama.ai/\n";
|
|
556
|
-
await fs2.writeFile(envFilePath, content, "utf8");
|
|
557
|
-
console.info("[\u221A] Ollama placeholder configuration added to .env file");
|
|
558
|
-
} else {
|
|
559
|
-
await promptAndStoreOllamaConfig(envFilePath);
|
|
560
|
-
}
|
|
561
|
-
break;
|
|
562
|
-
}
|
|
563
|
-
case "google": {
|
|
564
|
-
if (isNonInteractive) {
|
|
565
|
-
let content = "";
|
|
566
|
-
if (existsSync3(envFilePath)) {
|
|
567
|
-
content = await fs2.readFile(envFilePath, "utf8");
|
|
568
|
-
}
|
|
569
|
-
if (content && !content.endsWith("\n")) {
|
|
570
|
-
content += "\n";
|
|
571
|
-
}
|
|
572
|
-
content += "\n# AI Model Configuration\n";
|
|
573
|
-
content += "# Google Generative AI Configuration\n";
|
|
574
|
-
content += "GOOGLE_GENERATIVE_AI_API_KEY=your_google_api_key_here\n";
|
|
575
|
-
content += "# Get your API key from: https://aistudio.google.com/apikey\n";
|
|
576
|
-
await fs2.writeFile(envFilePath, content, "utf8");
|
|
577
|
-
console.info("[\u221A] Google Generative AI placeholder configuration added to .env file");
|
|
578
|
-
} else {
|
|
579
|
-
await promptAndStoreGoogleKey(envFilePath);
|
|
580
|
-
}
|
|
581
|
-
break;
|
|
582
|
-
}
|
|
583
|
-
default:
|
|
584
|
-
console.warn(`Unknown AI model: ${aiModel}, skipping configuration`);
|
|
585
|
-
return;
|
|
586
|
-
}
|
|
587
|
-
} catch (error) {
|
|
588
|
-
const errorMessage = error instanceof Error ? error.message : "Unknown error";
|
|
589
|
-
console.error(`Failed to set up AI model configuration: ${errorMessage}`);
|
|
590
|
-
}
|
|
591
|
-
}
|
|
592
|
-
function hasValidApiKey(content, keyName) {
|
|
593
|
-
const regex = new RegExp(`^${keyName}=(.+)$`, "m");
|
|
594
|
-
const match = content.match(regex);
|
|
595
|
-
if (!match) return false;
|
|
596
|
-
const value = match[1].trim();
|
|
597
|
-
return value !== "" && !value.includes("your_") && !value.includes("_here") && !value.includes("PLACEHOLDER") && !value.includes("placeholder");
|
|
598
|
-
}
|
|
599
|
-
async function setupEmbeddingModelConfig(embeddingModel, envFilePath, isNonInteractive = false) {
|
|
600
|
-
try {
|
|
601
|
-
let content = "";
|
|
602
|
-
if (existsSync3(envFilePath)) {
|
|
603
|
-
content = await fs2.readFile(envFilePath, "utf8");
|
|
604
|
-
}
|
|
605
|
-
if (content && !content.endsWith("\n")) {
|
|
606
|
-
content += "\n";
|
|
607
|
-
}
|
|
608
|
-
switch (embeddingModel) {
|
|
609
|
-
case "local": {
|
|
610
|
-
content += "\n# Embedding Model Configuration (Fallback)\n";
|
|
611
|
-
content += "# Using local embeddings - no additional configuration needed\n";
|
|
612
|
-
await fs2.writeFile(envFilePath, content, "utf8");
|
|
613
|
-
console.info("[\u221A] Using Local embeddings - no additional configuration needed");
|
|
614
|
-
break;
|
|
615
|
-
}
|
|
616
|
-
case "openai": {
|
|
617
|
-
if (!hasValidApiKey(content, "OPENAI_API_KEY")) {
|
|
618
|
-
if (isNonInteractive) {
|
|
619
|
-
if (!content.includes("OPENAI_API_KEY=")) {
|
|
620
|
-
content += "\n# Embedding Model Configuration (Fallback)\n";
|
|
621
|
-
content += "# OpenAI Embeddings Configuration\n";
|
|
622
|
-
content += "OPENAI_API_KEY=your_openai_api_key_here\n";
|
|
623
|
-
content += "# Get your API key from: https://platform.openai.com/api-keys\n";
|
|
624
|
-
}
|
|
625
|
-
await fs2.writeFile(envFilePath, content, "utf8");
|
|
626
|
-
console.info("[\u221A] OpenAI embeddings placeholder configuration added to .env file");
|
|
627
|
-
} else {
|
|
628
|
-
console.info("\n[!] OpenAI API key is required for embeddings");
|
|
629
|
-
await promptAndStoreOpenAIKey(envFilePath);
|
|
630
|
-
}
|
|
631
|
-
} else {
|
|
632
|
-
console.info("[\u221A] OpenAI API key already configured - will use for embeddings");
|
|
633
|
-
}
|
|
634
|
-
break;
|
|
635
|
-
}
|
|
636
|
-
case "ollama": {
|
|
637
|
-
if (!hasValidApiKey(content, "OLLAMA_API_ENDPOINT")) {
|
|
638
|
-
if (isNonInteractive) {
|
|
639
|
-
if (!content.includes("OLLAMA_API_ENDPOINT=")) {
|
|
640
|
-
content += "\n# Embedding Model Configuration (Fallback)\n";
|
|
641
|
-
content += "# Ollama Embeddings Configuration\n";
|
|
642
|
-
content += "OLLAMA_API_ENDPOINT=http://localhost:11434\n";
|
|
643
|
-
content += "OLLAMA_EMBEDDING_MODEL=nomic-embed-text\n";
|
|
644
|
-
content += "USE_OLLAMA_EMBEDDINGS=true\n";
|
|
645
|
-
content += "# Make sure Ollama is installed and running: https://ollama.ai/\n";
|
|
646
|
-
}
|
|
647
|
-
await fs2.writeFile(envFilePath, content, "utf8");
|
|
648
|
-
console.info("[\u221A] Ollama embeddings placeholder configuration added to .env file");
|
|
649
|
-
} else {
|
|
650
|
-
console.info("\n[!] Ollama embedding model configuration is required");
|
|
651
|
-
await promptAndStoreOllamaEmbeddingConfig(envFilePath);
|
|
652
|
-
}
|
|
653
|
-
} else {
|
|
654
|
-
if (isNonInteractive) {
|
|
655
|
-
if (!content.includes("OLLAMA_EMBEDDING_MODEL")) {
|
|
656
|
-
content += "OLLAMA_EMBEDDING_MODEL=nomic-embed-text\n";
|
|
657
|
-
}
|
|
658
|
-
if (!content.includes("USE_OLLAMA_EMBEDDINGS")) {
|
|
659
|
-
content += "USE_OLLAMA_EMBEDDINGS=true\n";
|
|
660
|
-
}
|
|
661
|
-
await fs2.writeFile(envFilePath, content, "utf8");
|
|
662
|
-
console.info("[\u221A] Ollama embedding model configuration added to .env file");
|
|
663
|
-
} else {
|
|
664
|
-
console.info("\n[!] Please select an Ollama embedding model");
|
|
665
|
-
await promptAndStoreOllamaEmbeddingConfig(envFilePath);
|
|
666
|
-
}
|
|
667
|
-
}
|
|
668
|
-
break;
|
|
669
|
-
}
|
|
670
|
-
case "google": {
|
|
671
|
-
if (!hasValidApiKey(content, "GOOGLE_GENERATIVE_AI_API_KEY")) {
|
|
672
|
-
if (isNonInteractive) {
|
|
673
|
-
if (!content.includes("GOOGLE_GENERATIVE_AI_API_KEY=")) {
|
|
674
|
-
content += "\n# Embedding Model Configuration (Fallback)\n";
|
|
675
|
-
content += "# Google Generative AI Embeddings Configuration\n";
|
|
676
|
-
content += "GOOGLE_GENERATIVE_AI_API_KEY=your_google_api_key_here\n";
|
|
677
|
-
content += "# Get your API key from: https://aistudio.google.com/apikey\n";
|
|
678
|
-
}
|
|
679
|
-
await fs2.writeFile(envFilePath, content, "utf8");
|
|
680
|
-
console.info("[\u221A] Google embeddings placeholder configuration added to .env file");
|
|
681
|
-
} else {
|
|
682
|
-
console.info("\n[!] Google Generative AI API key is required for embeddings");
|
|
683
|
-
await promptAndStoreGoogleKey(envFilePath);
|
|
684
|
-
}
|
|
685
|
-
} else {
|
|
686
|
-
console.info("[\u221A] Google API key already configured - will use for embeddings");
|
|
687
|
-
}
|
|
688
|
-
break;
|
|
689
|
-
}
|
|
690
|
-
default:
|
|
691
|
-
console.warn(`Unknown embedding model: ${embeddingModel}, skipping configuration`);
|
|
692
|
-
return;
|
|
693
|
-
}
|
|
694
|
-
} catch (error) {
|
|
695
|
-
const errorMessage = error instanceof Error ? error.message : "Unknown error";
|
|
696
|
-
console.error(`Failed to set up embedding model configuration: ${errorMessage}`);
|
|
697
|
-
}
|
|
698
|
-
}
|
|
699
|
-
function resolveModelToPlugin(modelName) {
|
|
700
|
-
const modelToPlugin = {
|
|
701
|
-
openai: "openai",
|
|
702
|
-
claude: "anthropic",
|
|
703
|
-
anthropic: "anthropic",
|
|
704
|
-
openrouter: "openrouter",
|
|
705
|
-
ollama: "ollama",
|
|
706
|
-
google: "google"
|
|
707
|
-
};
|
|
708
|
-
return modelToPlugin[modelName] || null;
|
|
709
|
-
}
|
|
710
|
-
async function installModelPlugin(modelName, targetDir, purpose = "") {
|
|
711
|
-
const pluginName = resolveModelToPlugin(modelName);
|
|
712
|
-
if (!pluginName) {
|
|
713
|
-
console.warn(`\u26A0\uFE0F Unknown model: ${modelName}, skipping plugin installation`);
|
|
714
|
-
return;
|
|
715
|
-
}
|
|
716
|
-
const purposeText = purpose ? ` ${purpose}` : "";
|
|
717
|
-
try {
|
|
718
|
-
console.info(`
|
|
719
|
-
\u{1F4E6} Installing ${pluginName} plugin${purposeText}...`);
|
|
720
|
-
await installPlugin(pluginName, targetDir);
|
|
721
|
-
console.info(`\u2705 Installed plugin successfully!`);
|
|
722
|
-
} catch (error) {
|
|
723
|
-
console.warn(
|
|
724
|
-
`\u26A0\uFE0F Could not install plugin automatically: ${error instanceof Error ? error.message : "Unknown error"}`
|
|
725
|
-
);
|
|
726
|
-
console.info(`\u{1F4A1} You can install it manually with: elizaos plugins add ${pluginName}`);
|
|
727
|
-
}
|
|
728
|
-
}
|
|
729
|
-
async function installDependencies(targetDir) {
|
|
730
|
-
if (process.env.CI === "true" || process.env.ELIZA_TEST_MODE === "true") {
|
|
731
|
-
console.info("Skipping dependency installation in CI/test environment...");
|
|
732
|
-
return;
|
|
733
|
-
}
|
|
734
|
-
console.info("Installing dependencies...");
|
|
735
|
-
const subprocess = await execa("bun", ["install"], {
|
|
736
|
-
cwd: targetDir,
|
|
737
|
-
stdio: "inherit",
|
|
738
|
-
reject: false
|
|
739
|
-
});
|
|
740
|
-
const exitCode = subprocess.exitCode;
|
|
741
|
-
const isSignalTermination = exitCode == null || exitCode >= 128;
|
|
742
|
-
if (exitCode !== 0 && !isSignalTermination) {
|
|
743
|
-
throw new Error(`Dependency installation failed with exit code ${exitCode}`);
|
|
744
|
-
}
|
|
745
|
-
}
|
|
746
|
-
async function setupProjectEnvironment(targetDir, database, aiModel, embeddingModel, isNonInteractive = false) {
|
|
747
|
-
await createProjectDirectories(targetDir);
|
|
748
|
-
const envFilePath = `${targetDir}/.env`;
|
|
749
|
-
if (database === "postgres" && !isNonInteractive) {
|
|
750
|
-
await promptAndStorePostgresUrl(envFilePath);
|
|
751
|
-
} else if (database === "pglite") {
|
|
752
|
-
await setupPgLite(void 0, `${targetDir}/.env`, targetDir);
|
|
753
|
-
}
|
|
754
|
-
await setupAIModelConfig(aiModel, envFilePath, isNonInteractive);
|
|
755
|
-
if (embeddingModel) {
|
|
756
|
-
await setupEmbeddingModelConfig(embeddingModel, envFilePath, isNonInteractive);
|
|
757
|
-
}
|
|
758
|
-
if (aiModel !== "local") {
|
|
759
|
-
await installModelPlugin(aiModel, targetDir);
|
|
760
|
-
}
|
|
761
|
-
if (embeddingModel && embeddingModel !== "local") {
|
|
762
|
-
const aiPluginName = resolveModelToPlugin(aiModel);
|
|
763
|
-
const embeddingPluginName = resolveModelToPlugin(embeddingModel);
|
|
764
|
-
if (embeddingPluginName && embeddingPluginName !== aiPluginName) {
|
|
765
|
-
await installModelPlugin(embeddingModel, targetDir, "for embeddings");
|
|
766
|
-
}
|
|
767
|
-
}
|
|
768
|
-
}
|
|
769
|
-
|
|
770
455
|
// src/commands/create/actions/creators.ts
|
|
771
|
-
import { existsSync as
|
|
456
|
+
import { existsSync as existsSync2, rmSync } from "fs";
|
|
772
457
|
async function withCleanupOnInterrupt(targetDir, displayName, fn) {
|
|
773
|
-
const directoryExistedBefore =
|
|
458
|
+
const directoryExistedBefore = existsSync2(targetDir);
|
|
774
459
|
const cleanup = () => {
|
|
775
|
-
if (!directoryExistedBefore &&
|
|
460
|
+
if (!directoryExistedBefore && existsSync2(targetDir)) {
|
|
776
461
|
console.info(colors.red(`
|
|
777
462
|
|
|
778
463
|
Interrupted! Cleaning up ${displayName}...`));
|
|
@@ -803,7 +488,7 @@ Interrupted! Cleaning up ${displayName}...`));
|
|
|
803
488
|
process.removeListener("exit", cleanup);
|
|
804
489
|
process.removeListener("SIGINT", sigintHandler);
|
|
805
490
|
process.removeListener("SIGTERM", sigtermHandler);
|
|
806
|
-
if (!directoryExistedBefore &&
|
|
491
|
+
if (!directoryExistedBefore && existsSync2(targetDir)) {
|
|
807
492
|
try {
|
|
808
493
|
console.info(colors.red(`
|
|
809
494
|
Cleaning up due to error...`));
|
|
@@ -821,6 +506,13 @@ async function createPlugin(pluginName, targetDir, isNonInteractive = false) {
|
|
|
821
506
|
}
|
|
822
507
|
const processedName = nameResult.processedName;
|
|
823
508
|
const pluginDirName = processedName.startsWith("plugin-") ? processedName : `plugin-${processedName}`;
|
|
509
|
+
if (pluginDirName !== pluginName) {
|
|
510
|
+
console.warn(
|
|
511
|
+
`
|
|
512
|
+
Warning: changing "${pluginName}" to "${pluginDirName}" to conform to plugin naming conventions
|
|
513
|
+
`
|
|
514
|
+
);
|
|
515
|
+
}
|
|
824
516
|
const pluginTargetDir = join(targetDir, pluginDirName);
|
|
825
517
|
const dirResult = await validateTargetDirectory(pluginTargetDir);
|
|
826
518
|
if (!dirResult.isValid) {
|
|
@@ -837,22 +529,27 @@ async function createPlugin(pluginName, targetDir, isNonInteractive = false) {
|
|
|
837
529
|
}
|
|
838
530
|
}
|
|
839
531
|
await withCleanupOnInterrupt(pluginTargetDir, pluginDirName, async () => {
|
|
840
|
-
await
|
|
841
|
-
|
|
532
|
+
await runTasks([
|
|
533
|
+
createTask("Copying plugin template", () => copyTemplate("plugin", pluginTargetDir)),
|
|
534
|
+
createTask("Installing dependencies", () => installDependenciesWithSpinner(pluginTargetDir))
|
|
535
|
+
]);
|
|
842
536
|
console.info(`
|
|
843
537
|
${colors.green("\u2713")} Plugin "${pluginDirName}" created successfully!`);
|
|
844
538
|
console.info(`
|
|
845
539
|
Next steps:`);
|
|
846
540
|
console.info(` cd ${pluginDirName}`);
|
|
847
|
-
console.info(` bun run build`);
|
|
848
|
-
console.info(`
|
|
541
|
+
console.info(` bun run build # Build the plugin`);
|
|
542
|
+
console.info(`
|
|
543
|
+
Common commands:`);
|
|
544
|
+
console.info(` elizaos dev # Start development mode with hot reloading`);
|
|
545
|
+
console.info(` elizaos start # Start in production mode
|
|
849
546
|
`);
|
|
850
547
|
});
|
|
851
548
|
}
|
|
852
549
|
async function createAgent(agentName, targetDir, isNonInteractive = false) {
|
|
853
550
|
const agentFilePath = join(targetDir, `${agentName}.json`);
|
|
854
551
|
try {
|
|
855
|
-
await
|
|
552
|
+
await fs2.access(agentFilePath);
|
|
856
553
|
throw new Error(`Agent file ${agentFilePath} already exists`);
|
|
857
554
|
} catch (error) {
|
|
858
555
|
if (error.code !== "ENOENT") {
|
|
@@ -877,16 +574,17 @@ async function createAgent(agentName, targetDir, isNonInteractive = false) {
|
|
|
877
574
|
`${agentName} is knowledgeable, creative, and always eager to help users with their questions and tasks.`
|
|
878
575
|
]
|
|
879
576
|
};
|
|
880
|
-
await
|
|
881
|
-
|
|
882
|
-
console.info(`
|
|
577
|
+
await fs2.writeFile(agentFilePath, JSON.stringify(agentCharacter, null, 2));
|
|
578
|
+
console.info(`
|
|
883
579
|
${colors.green("\u2713")} Agent "${agentName}" created successfully!`);
|
|
884
|
-
}
|
|
885
580
|
console.info(`Agent character created successfully at: ${agentFilePath}`);
|
|
886
581
|
console.info(`
|
|
887
582
|
To use this agent:`);
|
|
888
|
-
console.info(`
|
|
889
|
-
`);
|
|
583
|
+
console.info(` 1. Start ElizaOS server with this character:`);
|
|
584
|
+
console.info(` elizaos start --character ${agentFilePath}`);
|
|
585
|
+
console.info(`
|
|
586
|
+
OR if a server is already running:`);
|
|
587
|
+
console.info(` elizaos agent start --path ${agentFilePath}`);
|
|
890
588
|
}
|
|
891
589
|
async function createTEEProject(projectName, targetDir, database, aiModel, embeddingModel, isNonInteractive = false) {
|
|
892
590
|
const teeTargetDir = join(targetDir, projectName);
|
|
@@ -905,22 +603,44 @@ async function createTEEProject(projectName, targetDir, database, aiModel, embed
|
|
|
905
603
|
}
|
|
906
604
|
}
|
|
907
605
|
await withCleanupOnInterrupt(teeTargetDir, projectName, async () => {
|
|
908
|
-
await
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
606
|
+
await fs2.mkdir(teeTargetDir, { recursive: true });
|
|
607
|
+
if (!isNonInteractive) {
|
|
608
|
+
const { setupAIModelConfig, setupEmbeddingModelConfig } = await import("./setup-MMMQEN65.js");
|
|
609
|
+
const { promptAndStorePostgresUrl } = await import("./utils-3X6GHWTH.js");
|
|
610
|
+
const envFilePath = `${teeTargetDir}/.env`;
|
|
611
|
+
if (database === "postgres") {
|
|
612
|
+
await promptAndStorePostgresUrl(envFilePath);
|
|
613
|
+
}
|
|
614
|
+
if (aiModel !== "local" || embeddingModel) {
|
|
615
|
+
if (aiModel !== "local") {
|
|
616
|
+
await setupAIModelConfig(aiModel, envFilePath, false);
|
|
617
|
+
}
|
|
618
|
+
if (embeddingModel) {
|
|
619
|
+
await setupEmbeddingModelConfig(embeddingModel, envFilePath, false);
|
|
620
|
+
}
|
|
621
|
+
}
|
|
622
|
+
}
|
|
623
|
+
await runTasks([
|
|
624
|
+
createTask(
|
|
625
|
+
"Copying TEE template",
|
|
626
|
+
() => copyTemplate("project-tee-starter", teeTargetDir)
|
|
627
|
+
),
|
|
628
|
+
createTask(
|
|
629
|
+
"Setting up project environment",
|
|
630
|
+
() => setupProjectEnvironment(teeTargetDir, database, aiModel, embeddingModel, true)
|
|
631
|
+
),
|
|
632
|
+
createTask("Installing dependencies", () => installDependenciesWithSpinner(teeTargetDir)),
|
|
633
|
+
createTask("Building project", () => buildProjectWithSpinner(teeTargetDir, false))
|
|
634
|
+
]);
|
|
918
635
|
console.info(`
|
|
919
636
|
${colors.green("\u2713")} TEE project "${projectName}" created successfully!`);
|
|
920
637
|
console.info(`
|
|
921
638
|
Next steps:`);
|
|
922
639
|
console.info(` cd ${projectName}`);
|
|
923
|
-
console.info(`
|
|
640
|
+
console.info(`
|
|
641
|
+
Common commands:`);
|
|
642
|
+
console.info(` elizaos dev # Start development mode with hot reloading`);
|
|
643
|
+
console.info(` elizaos start # Start in production mode
|
|
924
644
|
`);
|
|
925
645
|
});
|
|
926
646
|
}
|
|
@@ -942,23 +662,49 @@ async function createProject(projectName, targetDir, database, aiModel, embeddin
|
|
|
942
662
|
}
|
|
943
663
|
}
|
|
944
664
|
const createFn = async () => {
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
665
|
+
if (projectName !== ".") {
|
|
666
|
+
await fs2.mkdir(projectTargetDir, { recursive: true });
|
|
667
|
+
}
|
|
668
|
+
if (!isNonInteractive) {
|
|
669
|
+
const { setupAIModelConfig, setupEmbeddingModelConfig } = await import("./setup-MMMQEN65.js");
|
|
670
|
+
const { promptAndStorePostgresUrl } = await import("./utils-3X6GHWTH.js");
|
|
671
|
+
const envFilePath = `${projectTargetDir}/.env`;
|
|
672
|
+
if (database === "postgres") {
|
|
673
|
+
await promptAndStorePostgresUrl(envFilePath);
|
|
674
|
+
}
|
|
675
|
+
if (aiModel !== "local" || embeddingModel) {
|
|
676
|
+
if (aiModel !== "local") {
|
|
677
|
+
await setupAIModelConfig(aiModel, envFilePath, false);
|
|
678
|
+
}
|
|
679
|
+
if (embeddingModel) {
|
|
680
|
+
await setupEmbeddingModelConfig(embeddingModel, envFilePath, false);
|
|
681
|
+
}
|
|
682
|
+
}
|
|
683
|
+
}
|
|
684
|
+
await runTasks([
|
|
685
|
+
createTask(
|
|
686
|
+
"Copying project template",
|
|
687
|
+
() => copyTemplate("project-starter", projectTargetDir)
|
|
688
|
+
),
|
|
689
|
+
createTask(
|
|
690
|
+
"Setting up project environment",
|
|
691
|
+
() => setupProjectEnvironment(projectTargetDir, database, aiModel, embeddingModel, true)
|
|
692
|
+
),
|
|
693
|
+
createTask("Installing dependencies", () => installDependenciesWithSpinner(projectTargetDir)),
|
|
694
|
+
createTask("Building project", () => buildProjectWithSpinner(projectTargetDir, false))
|
|
695
|
+
]);
|
|
955
696
|
const displayName = projectName === "." ? "Project" : `Project "${projectName}"`;
|
|
956
697
|
console.info(`
|
|
957
698
|
${colors.green("\u2713")} ${displayName} initialized successfully!`);
|
|
958
699
|
console.info(`
|
|
959
700
|
Next steps:`);
|
|
960
|
-
|
|
961
|
-
|
|
701
|
+
if (projectName !== ".") {
|
|
702
|
+
console.info(` cd ${projectName}`);
|
|
703
|
+
}
|
|
704
|
+
console.info(`
|
|
705
|
+
Common commands:`);
|
|
706
|
+
console.info(` elizaos dev # Start development mode with hot reloading`);
|
|
707
|
+
console.info(` elizaos start # Start in production mode
|
|
962
708
|
`);
|
|
963
709
|
};
|
|
964
710
|
if (projectName === ".") {
|
|
@@ -975,11 +721,6 @@ export {
|
|
|
975
721
|
selectAIModel,
|
|
976
722
|
selectEmbeddingModel,
|
|
977
723
|
getElizaCharacter,
|
|
978
|
-
createProjectDirectories,
|
|
979
|
-
setupAIModelConfig,
|
|
980
|
-
setupEmbeddingModelConfig,
|
|
981
|
-
installDependencies,
|
|
982
|
-
setupProjectEnvironment,
|
|
983
724
|
createPlugin,
|
|
984
725
|
createAgent,
|
|
985
726
|
createTEEProject,
|