@elizaos/cli 1.0.18 → 1.0.20
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-BtIQw5Dh.js → index-B1BYc3c_.js} +6175 -678
- package/dist/assets/index-B1BYc3c_.js.br +0 -0
- package/dist/assets/{index-BtIQw5Dh.js.map → index-B1BYc3c_.js.map} +1 -1
- package/dist/assets/{index-Dgo_cOqK.js → index-CX0KZCt7.js} +2 -2
- package/dist/assets/index-CX0KZCt7.js.br +0 -0
- package/dist/assets/{index-Dgo_cOqK.js.map → index-CX0KZCt7.js.map} +1 -1
- package/dist/chunk-77IXJDDC.js +281 -0
- package/dist/{chunk-W4NJVJQV.js → chunk-7PPBVSWE.js} +21 -3
- package/dist/{chunk-ED42YJZA.js → chunk-GILK2M6Z.js} +327 -177
- package/dist/{chunk-JVEHLVLY.js → chunk-ME4CPLVT.js} +7 -8
- package/dist/{chunk-OEHDDUQ4.js → chunk-RJ7XRVPG.js} +83 -363
- 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 +10 -1
- package/dist/index.js +71 -38
- package/dist/{plugin-creator-4QMSSR4X.js → plugin-creator-35CAJF4O.js} +1 -1
- package/dist/{registry-NIGTUGFP.js → registry-FOS35FQH.js} +2 -2
- package/dist/setup-6XRSST5O.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-QBGEZZ4I.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-BtIQw5Dh.js.br +0 -0
- package/dist/assets/index-Dgo_cOqK.js.br +0 -0
|
@@ -12,11 +12,11 @@ import {
|
|
|
12
12
|
selectEmbeddingModel,
|
|
13
13
|
validateCreateOptions,
|
|
14
14
|
validateProjectName
|
|
15
|
-
} from "./chunk-
|
|
15
|
+
} from "./chunk-RJ7XRVPG.js";
|
|
16
16
|
import {
|
|
17
17
|
displayBanner,
|
|
18
18
|
handleError
|
|
19
|
-
} from "./chunk-
|
|
19
|
+
} from "./chunk-GILK2M6Z.js";
|
|
20
20
|
|
|
21
21
|
// src/commands/create/index.ts
|
|
22
22
|
import { Command } from "commander";
|
|
@@ -26,7 +26,7 @@ import { logger } from "@elizaos/core";
|
|
|
26
26
|
function formatProjectType(type) {
|
|
27
27
|
return type === "tee" ? "TEE Project" : type.charAt(0).toUpperCase() + type.slice(1);
|
|
28
28
|
}
|
|
29
|
-
var create = new Command("create").description("Create a new ElizaOS project, plugin, agent, or TEE project").argument("[name]", "name of the project/plugin/agent to create").option("--
|
|
29
|
+
var create = new Command("create").description("Create a new ElizaOS project, plugin, agent, or TEE project").argument("[name]", "name of the project/plugin/agent to create").option("--yes, -y", "skip prompts and use defaults").option("--type <type>", "type of project to create (project, plugin, agent, tee)", "project").action(async (name, opts) => {
|
|
30
30
|
let projectType;
|
|
31
31
|
try {
|
|
32
32
|
if (process.env.ELIZA_NONINTERACTIVE === "1" || process.env.ELIZA_NONINTERACTIVE === "true" || process.argv.includes("-y") || process.argv.includes("--yes")) {
|
|
@@ -113,13 +113,12 @@ var create = new Command("create").description("Create a new ElizaOS project, pl
|
|
|
113
113
|
const introType = formatProjectType(projectType);
|
|
114
114
|
clack.intro(colors.inverse(` Creating ElizaOS ${introType} `));
|
|
115
115
|
}
|
|
116
|
-
const targetDir = options.dir;
|
|
117
116
|
switch (projectType) {
|
|
118
117
|
case "plugin":
|
|
119
|
-
await createPlugin(projectName,
|
|
118
|
+
await createPlugin(projectName, process.cwd(), isNonInteractive);
|
|
120
119
|
break;
|
|
121
120
|
case "agent":
|
|
122
|
-
await createAgent(projectName,
|
|
121
|
+
await createAgent(projectName, process.cwd(), isNonInteractive);
|
|
123
122
|
break;
|
|
124
123
|
case "tee": {
|
|
125
124
|
let database = "pglite";
|
|
@@ -134,7 +133,7 @@ var create = new Command("create").description("Create a new ElizaOS project, pl
|
|
|
134
133
|
}
|
|
135
134
|
await createTEEProject(
|
|
136
135
|
projectName,
|
|
137
|
-
|
|
136
|
+
process.cwd(),
|
|
138
137
|
database,
|
|
139
138
|
aiModel,
|
|
140
139
|
embeddingModel,
|
|
@@ -156,7 +155,7 @@ var create = new Command("create").description("Create a new ElizaOS project, pl
|
|
|
156
155
|
}
|
|
157
156
|
await createProject(
|
|
158
157
|
projectName,
|
|
159
|
-
|
|
158
|
+
process.cwd(),
|
|
160
159
|
database,
|
|
161
160
|
aiModel,
|
|
162
161
|
embeddingModel,
|
|
@@ -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-77IXJDDC.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-GILK2M6Z.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...`));
|
|
@@ -837,8 +522,10 @@ async function createPlugin(pluginName, targetDir, isNonInteractive = false) {
|
|
|
837
522
|
}
|
|
838
523
|
}
|
|
839
524
|
await withCleanupOnInterrupt(pluginTargetDir, pluginDirName, async () => {
|
|
840
|
-
await
|
|
841
|
-
|
|
525
|
+
await runTasks([
|
|
526
|
+
createTask("Copying plugin template", () => copyTemplate("plugin", pluginTargetDir)),
|
|
527
|
+
createTask("Installing dependencies", () => installDependenciesWithSpinner(pluginTargetDir))
|
|
528
|
+
]);
|
|
842
529
|
console.info(`
|
|
843
530
|
${colors.green("\u2713")} Plugin "${pluginDirName}" created successfully!`);
|
|
844
531
|
console.info(`
|
|
@@ -852,7 +539,7 @@ Next steps:`);
|
|
|
852
539
|
async function createAgent(agentName, targetDir, isNonInteractive = false) {
|
|
853
540
|
const agentFilePath = join(targetDir, `${agentName}.json`);
|
|
854
541
|
try {
|
|
855
|
-
await
|
|
542
|
+
await fs2.access(agentFilePath);
|
|
856
543
|
throw new Error(`Agent file ${agentFilePath} already exists`);
|
|
857
544
|
} catch (error) {
|
|
858
545
|
if (error.code !== "ENOENT") {
|
|
@@ -877,11 +564,9 @@ async function createAgent(agentName, targetDir, isNonInteractive = false) {
|
|
|
877
564
|
`${agentName} is knowledgeable, creative, and always eager to help users with their questions and tasks.`
|
|
878
565
|
]
|
|
879
566
|
};
|
|
880
|
-
await
|
|
881
|
-
|
|
882
|
-
console.info(`
|
|
567
|
+
await fs2.writeFile(agentFilePath, JSON.stringify(agentCharacter, null, 2));
|
|
568
|
+
console.info(`
|
|
883
569
|
${colors.green("\u2713")} Agent "${agentName}" created successfully!`);
|
|
884
|
-
}
|
|
885
570
|
console.info(`Agent character created successfully at: ${agentFilePath}`);
|
|
886
571
|
console.info(`
|
|
887
572
|
To use this agent:`);
|
|
@@ -905,16 +590,35 @@ async function createTEEProject(projectName, targetDir, database, aiModel, embed
|
|
|
905
590
|
}
|
|
906
591
|
}
|
|
907
592
|
await withCleanupOnInterrupt(teeTargetDir, projectName, async () => {
|
|
908
|
-
await
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
593
|
+
await fs2.mkdir(teeTargetDir, { recursive: true });
|
|
594
|
+
if (!isNonInteractive) {
|
|
595
|
+
const { setupAIModelConfig, setupEmbeddingModelConfig } = await import("./setup-6XRSST5O.js");
|
|
596
|
+
const { promptAndStorePostgresUrl } = await import("./utils-QBGEZZ4I.js");
|
|
597
|
+
const envFilePath = `${teeTargetDir}/.env`;
|
|
598
|
+
if (database === "postgres") {
|
|
599
|
+
await promptAndStorePostgresUrl(envFilePath);
|
|
600
|
+
}
|
|
601
|
+
if (aiModel !== "local" || embeddingModel) {
|
|
602
|
+
if (aiModel !== "local") {
|
|
603
|
+
await setupAIModelConfig(aiModel, envFilePath, false);
|
|
604
|
+
}
|
|
605
|
+
if (embeddingModel) {
|
|
606
|
+
await setupEmbeddingModelConfig(embeddingModel, envFilePath, false);
|
|
607
|
+
}
|
|
608
|
+
}
|
|
609
|
+
}
|
|
610
|
+
await runTasks([
|
|
611
|
+
createTask(
|
|
612
|
+
"Copying TEE template",
|
|
613
|
+
() => copyTemplate("project-tee-starter", teeTargetDir)
|
|
614
|
+
),
|
|
615
|
+
createTask(
|
|
616
|
+
"Setting up project environment",
|
|
617
|
+
() => setupProjectEnvironment(teeTargetDir, database, aiModel, embeddingModel, true)
|
|
618
|
+
),
|
|
619
|
+
createTask("Installing dependencies", () => installDependenciesWithSpinner(teeTargetDir)),
|
|
620
|
+
createTask("Building project", () => buildProjectWithSpinner(teeTargetDir, false))
|
|
621
|
+
]);
|
|
918
622
|
console.info(`
|
|
919
623
|
${colors.green("\u2713")} TEE project "${projectName}" created successfully!`);
|
|
920
624
|
console.info(`
|
|
@@ -942,16 +646,37 @@ async function createProject(projectName, targetDir, database, aiModel, embeddin
|
|
|
942
646
|
}
|
|
943
647
|
}
|
|
944
648
|
const createFn = async () => {
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
649
|
+
if (projectName !== ".") {
|
|
650
|
+
await fs2.mkdir(projectTargetDir, { recursive: true });
|
|
651
|
+
}
|
|
652
|
+
if (!isNonInteractive) {
|
|
653
|
+
const { setupAIModelConfig, setupEmbeddingModelConfig } = await import("./setup-6XRSST5O.js");
|
|
654
|
+
const { promptAndStorePostgresUrl } = await import("./utils-QBGEZZ4I.js");
|
|
655
|
+
const envFilePath = `${projectTargetDir}/.env`;
|
|
656
|
+
if (database === "postgres") {
|
|
657
|
+
await promptAndStorePostgresUrl(envFilePath);
|
|
658
|
+
}
|
|
659
|
+
if (aiModel !== "local" || embeddingModel) {
|
|
660
|
+
if (aiModel !== "local") {
|
|
661
|
+
await setupAIModelConfig(aiModel, envFilePath, false);
|
|
662
|
+
}
|
|
663
|
+
if (embeddingModel) {
|
|
664
|
+
await setupEmbeddingModelConfig(embeddingModel, envFilePath, false);
|
|
665
|
+
}
|
|
666
|
+
}
|
|
667
|
+
}
|
|
668
|
+
await runTasks([
|
|
669
|
+
createTask(
|
|
670
|
+
"Copying project template",
|
|
671
|
+
() => copyTemplate("project-starter", projectTargetDir)
|
|
672
|
+
),
|
|
673
|
+
createTask(
|
|
674
|
+
"Setting up project environment",
|
|
675
|
+
() => setupProjectEnvironment(projectTargetDir, database, aiModel, embeddingModel, true)
|
|
676
|
+
),
|
|
677
|
+
createTask("Installing dependencies", () => installDependenciesWithSpinner(projectTargetDir)),
|
|
678
|
+
createTask("Building project", () => buildProjectWithSpinner(projectTargetDir, false))
|
|
679
|
+
]);
|
|
955
680
|
const displayName = projectName === "." ? "Project" : `Project "${projectName}"`;
|
|
956
681
|
console.info(`
|
|
957
682
|
${colors.green("\u2713")} ${displayName} initialized successfully!`);
|
|
@@ -975,11 +700,6 @@ export {
|
|
|
975
700
|
selectAIModel,
|
|
976
701
|
selectEmbeddingModel,
|
|
977
702
|
getElizaCharacter,
|
|
978
|
-
createProjectDirectories,
|
|
979
|
-
setupAIModelConfig,
|
|
980
|
-
setupEmbeddingModelConfig,
|
|
981
|
-
installDependencies,
|
|
982
|
-
setupProjectEnvironment,
|
|
983
703
|
createPlugin,
|
|
984
704
|
createAgent,
|
|
985
705
|
createTEEProject,
|
|
@@ -9,8 +9,8 @@ import {
|
|
|
9
9
|
setAgentConfig,
|
|
10
10
|
startAgent,
|
|
11
11
|
stopAgent
|
|
12
|
-
} from "../../../chunk-
|
|
13
|
-
import "../../../chunk-
|
|
12
|
+
} from "../../../chunk-GILK2M6Z.js";
|
|
13
|
+
import "../../../chunk-7PPBVSWE.js";
|
|
14
14
|
import "../../../chunk-F24MS2YR.js";
|
|
15
15
|
import "../../../chunk-AQ6OMR2A.js";
|
|
16
16
|
export {
|
|
@@ -27,16 +27,9 @@ declare function setupAIModelConfig(aiModel: string, envFilePath: string, isNonI
|
|
|
27
27
|
* Sets up embedding model configuration when the primary AI model doesn't support embeddings.
|
|
28
28
|
*/
|
|
29
29
|
declare function setupEmbeddingModelConfig(embeddingModel: string, envFilePath: string, isNonInteractive?: boolean): Promise<void>;
|
|
30
|
-
/**
|
|
31
|
-
* Installs dependencies for the specified target directory.
|
|
32
|
-
*
|
|
33
|
-
* note: cleanup on ctrl-c is handled by the calling function (creators.ts)
|
|
34
|
-
* we use stdio: 'inherit' here so the user sees the install progress in real-time
|
|
35
|
-
*/
|
|
36
|
-
declare function installDependencies(targetDir: string): Promise<void>;
|
|
37
30
|
/**
|
|
38
31
|
* Sets up the project environment including database and AI model configuration.
|
|
39
32
|
*/
|
|
40
33
|
declare function setupProjectEnvironment(targetDir: string, database: string, aiModel: string, embeddingModel?: string, isNonInteractive?: boolean): Promise<void>;
|
|
41
34
|
|
|
42
|
-
export { createAgent, createPlugin, createProject, createProjectDirectories, createTEEProject,
|
|
35
|
+
export { createAgent, createPlugin, createProject, createProjectDirectories, createTEEProject, setupAIModelConfig, setupEmbeddingModelConfig, setupProjectEnvironment };
|
|
@@ -6,15 +6,16 @@ import {
|
|
|
6
6
|
createAgent,
|
|
7
7
|
createPlugin,
|
|
8
8
|
createProject,
|
|
9
|
+
createTEEProject
|
|
10
|
+
} from "../../../chunk-RJ7XRVPG.js";
|
|
11
|
+
import {
|
|
9
12
|
createProjectDirectories,
|
|
10
|
-
createTEEProject,
|
|
11
|
-
installDependencies,
|
|
12
13
|
setupAIModelConfig,
|
|
13
14
|
setupEmbeddingModelConfig,
|
|
14
15
|
setupProjectEnvironment
|
|
15
|
-
} from "../../../chunk-
|
|
16
|
-
import "../../../chunk-
|
|
17
|
-
import "../../../chunk-
|
|
16
|
+
} from "../../../chunk-77IXJDDC.js";
|
|
17
|
+
import "../../../chunk-GILK2M6Z.js";
|
|
18
|
+
import "../../../chunk-7PPBVSWE.js";
|
|
18
19
|
import "../../../chunk-F24MS2YR.js";
|
|
19
20
|
import "../../../chunk-AQ6OMR2A.js";
|
|
20
21
|
export {
|
|
@@ -23,7 +24,6 @@ export {
|
|
|
23
24
|
createProject,
|
|
24
25
|
createProjectDirectories,
|
|
25
26
|
createTEEProject,
|
|
26
|
-
installDependencies,
|
|
27
27
|
setupAIModelConfig,
|
|
28
28
|
setupEmbeddingModelConfig,
|
|
29
29
|
setupProjectEnvironment
|