@elizaos/cli 1.0.12 → 1.0.13

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (39) hide show
  1. package/README.md +89 -54
  2. package/dist/assets/{index-CtxA4ev_.js → index-D7iwnDvJ.js} +28832 -26151
  3. package/dist/assets/{index-CtxA4ev_.js.map → index-D7iwnDvJ.js.map} +1 -1
  4. package/dist/assets/index-Hst_nvMK.css +1 -0
  5. package/dist/assets/index-Hst_nvMK.css.br +0 -0
  6. package/dist/assets/{index-xhCgCbS4.js → index-ojKLjt7K.js} +2 -2
  7. package/dist/assets/index-ojKLjt7K.js.br +0 -0
  8. package/dist/assets/{index-xhCgCbS4.js.map → index-ojKLjt7K.js.map} +1 -1
  9. package/dist/{chunk-PYMK3ECE.js → chunk-ELCESP3O.js} +199 -6
  10. package/dist/{chunk-YDVNTQX3.js → chunk-RTJ2B547.js} +27 -4
  11. package/dist/{chunk-Y76S7TNK.js → chunk-WP6OGNZE.js} +625 -138
  12. package/dist/commands/agent/actions/index.d.ts +2 -2
  13. package/dist/commands/agent/actions/index.js +1 -1
  14. package/dist/commands/agent/index.js +1 -1
  15. package/dist/commands/create/actions/index.d.ts +8 -4
  16. package/dist/commands/create/actions/index.js +4 -2
  17. package/dist/commands/create/index.js +3 -3
  18. package/dist/index.html +2 -2
  19. package/dist/index.js +563 -328
  20. package/dist/{registry-7PBDJL64.js → registry-MJQMACYE.js} +1 -1
  21. package/dist/templates/plugin-starter/src/index.ts +2 -272
  22. package/dist/templates/plugin-starter/src/plugin.ts +274 -0
  23. package/dist/templates/project-starter/package.json +0 -2
  24. package/dist/templates/project-starter/src/character.ts +134 -0
  25. package/dist/templates/project-starter/src/index.ts +3 -133
  26. package/dist/templates/project-starter/tsconfig.json +2 -2
  27. package/dist/templates/project-tee-starter/src/index.ts +2 -15
  28. package/dist/{utils-WRGBZBAJ.js → utils-JWYJVLQ4.js} +7 -1
  29. package/package.json +6 -7
  30. package/templates/plugin-starter/src/index.ts +2 -272
  31. package/templates/plugin-starter/src/plugin.ts +274 -0
  32. package/templates/project-starter/package.json +0 -2
  33. package/templates/project-starter/src/character.ts +134 -0
  34. package/templates/project-starter/src/index.ts +3 -133
  35. package/templates/project-starter/tsconfig.json +2 -2
  36. package/templates/project-tee-starter/src/index.ts +2 -15
  37. package/dist/assets/index-Df1AFSuJ.css +0 -1
  38. package/dist/assets/index-Df1AFSuJ.css.br +0 -0
  39. package/dist/assets/index-xhCgCbS4.js.br +0 -0
@@ -10,9 +10,10 @@ import {
10
10
  promptAndStoreGoogleKey,
11
11
  promptAndStoreOllamaConfig,
12
12
  promptAndStoreOpenAIKey,
13
+ promptAndStoreOpenRouterKey,
13
14
  promptAndStorePostgresUrl,
14
15
  setupPgLite
15
- } from "./chunk-Y76S7TNK.js";
16
+ } from "./chunk-WP6OGNZE.js";
16
17
  import {
17
18
  runBunCommand
18
19
  } from "./chunk-RIAWNDYI.js";
@@ -341,6 +342,11 @@ function getAvailableAIModels() {
341
342
  value: "claude",
342
343
  description: "Claude models"
343
344
  },
345
+ {
346
+ title: "OpenRouter",
347
+ value: "openrouter",
348
+ description: "Access multiple AI models"
349
+ },
344
350
  {
345
351
  title: "Ollama",
346
352
  value: "ollama",
@@ -401,6 +407,47 @@ async function selectAIModel() {
401
407
  }
402
408
  return aiModel;
403
409
  }
410
+ function getAvailableEmbeddingModels() {
411
+ return [
412
+ {
413
+ title: "Local AI",
414
+ value: "local",
415
+ description: "Local embeddings, no API required"
416
+ },
417
+ {
418
+ title: "OpenAI",
419
+ value: "openai",
420
+ description: "OpenAI text-embedding-ada-002"
421
+ },
422
+ {
423
+ title: "Ollama",
424
+ value: "ollama",
425
+ description: "Self-hosted embedding models"
426
+ },
427
+ {
428
+ title: "Google Generative AI",
429
+ value: "google",
430
+ description: "Google embedding models"
431
+ }
432
+ ];
433
+ }
434
+ async function selectEmbeddingModel() {
435
+ const availableModels = getAvailableEmbeddingModels();
436
+ const embeddingModel = await clack.select({
437
+ message: "Select an embedding model (required since your AI model doesn't support embeddings):",
438
+ options: availableModels.map((model) => ({
439
+ label: model.title,
440
+ value: model.value,
441
+ hint: model.description
442
+ })),
443
+ initialValue: "local"
444
+ });
445
+ if (clack.isCancel(embeddingModel)) {
446
+ clack.cancel("Operation cancelled.");
447
+ process.exit(0);
448
+ }
449
+ return embeddingModel;
450
+ }
404
451
 
405
452
  // src/commands/create/actions/setup.ts
406
453
  import { existsSync as existsSync2 } from "fs";
@@ -455,6 +502,26 @@ async function setupAIModelConfig(aiModel, envFilePath, isNonInteractive = false
455
502
  }
456
503
  break;
457
504
  }
505
+ case "openrouter": {
506
+ if (isNonInteractive) {
507
+ let content = "";
508
+ if (existsSync2(envFilePath)) {
509
+ content = await fs2.readFile(envFilePath, "utf8");
510
+ }
511
+ if (content && !content.endsWith("\n")) {
512
+ content += "\n";
513
+ }
514
+ content += "\n# AI Model Configuration\n";
515
+ content += "# OpenRouter Configuration\n";
516
+ content += "OPENROUTER_API_KEY=your_openrouter_api_key_here\n";
517
+ content += "# Get your API key from: https://openrouter.ai/keys\n";
518
+ await fs2.writeFile(envFilePath, content, "utf8");
519
+ console.info("[\u221A] OpenRouter placeholder configuration added to .env file");
520
+ } else {
521
+ await promptAndStoreOpenRouterKey(envFilePath);
522
+ }
523
+ break;
524
+ }
458
525
  case "ollama": {
459
526
  if (isNonInteractive) {
460
527
  let content = "";
@@ -506,6 +573,121 @@ async function setupAIModelConfig(aiModel, envFilePath, isNonInteractive = false
506
573
  console.error(`Failed to set up AI model configuration: ${errorMessage}`);
507
574
  }
508
575
  }
576
+ function hasValidApiKey(content, keyName) {
577
+ const regex = new RegExp(`^${keyName}=(.+)$`, "m");
578
+ const match = content.match(regex);
579
+ if (!match) return false;
580
+ const value = match[1].trim();
581
+ return value !== "" && !value.includes("your_") && !value.includes("_here") && !value.includes("PLACEHOLDER") && !value.includes("placeholder");
582
+ }
583
+ async function setupEmbeddingModelConfig(embeddingModel, envFilePath, isNonInteractive = false) {
584
+ try {
585
+ let content = "";
586
+ if (existsSync2(envFilePath)) {
587
+ content = await fs2.readFile(envFilePath, "utf8");
588
+ }
589
+ if (content && !content.endsWith("\n")) {
590
+ content += "\n";
591
+ }
592
+ switch (embeddingModel) {
593
+ case "local": {
594
+ content += "\n# Embedding Model Configuration (Fallback)\n";
595
+ content += "# Using local embeddings - no additional configuration needed\n";
596
+ await fs2.writeFile(envFilePath, content, "utf8");
597
+ console.info("[\u221A] Using Local embeddings - no additional configuration needed");
598
+ break;
599
+ }
600
+ case "openai": {
601
+ if (!hasValidApiKey(content, "OPENAI_API_KEY")) {
602
+ if (isNonInteractive) {
603
+ if (!content.includes("OPENAI_API_KEY=")) {
604
+ content += "\n# Embedding Model Configuration (Fallback)\n";
605
+ content += "# OpenAI Embeddings Configuration\n";
606
+ content += "OPENAI_API_KEY=your_openai_api_key_here\n";
607
+ content += "# Get your API key from: https://platform.openai.com/api-keys\n";
608
+ }
609
+ await fs2.writeFile(envFilePath, content, "utf8");
610
+ console.info("[\u221A] OpenAI embeddings placeholder configuration added to .env file");
611
+ } else {
612
+ console.info("\n[!] OpenAI API key is required for embeddings");
613
+ await promptAndStoreOpenAIKey(envFilePath);
614
+ }
615
+ } else {
616
+ console.info("[\u221A] OpenAI API key already configured - will use for embeddings");
617
+ }
618
+ break;
619
+ }
620
+ case "ollama": {
621
+ if (!hasValidApiKey(content, "OLLAMA_API_ENDPOINT")) {
622
+ if (isNonInteractive) {
623
+ if (!content.includes("OLLAMA_API_ENDPOINT=")) {
624
+ content += "\n# Embedding Model Configuration (Fallback)\n";
625
+ content += "# Ollama Embeddings Configuration\n";
626
+ content += "OLLAMA_API_ENDPOINT=http://localhost:11434\n";
627
+ content += "OLLAMA_EMBEDDING_MODEL=nomic-embed-text\n";
628
+ content += "USE_OLLAMA_EMBEDDINGS=true\n";
629
+ content += "# Make sure Ollama is installed and running: https://ollama.ai/\n";
630
+ }
631
+ await fs2.writeFile(envFilePath, content, "utf8");
632
+ console.info("[\u221A] Ollama embeddings placeholder configuration added to .env file");
633
+ } else {
634
+ console.info("\n[!] Ollama configuration is required for embeddings");
635
+ await promptAndStoreOllamaConfig(envFilePath);
636
+ content = await fs2.readFile(envFilePath, "utf8");
637
+ if (!content.includes("OLLAMA_EMBEDDING_MODEL")) {
638
+ content += "OLLAMA_EMBEDDING_MODEL=nomic-embed-text\n";
639
+ }
640
+ if (!content.includes("USE_OLLAMA_EMBEDDINGS")) {
641
+ content += "USE_OLLAMA_EMBEDDINGS=true\n";
642
+ }
643
+ await fs2.writeFile(envFilePath, content, "utf8");
644
+ }
645
+ } else {
646
+ if (!content.includes("OLLAMA_EMBEDDING_MODEL") || !content.includes("USE_OLLAMA_EMBEDDINGS")) {
647
+ content = await fs2.readFile(envFilePath, "utf8");
648
+ if (!content.includes("OLLAMA_EMBEDDING_MODEL")) {
649
+ content += "OLLAMA_EMBEDDING_MODEL=nomic-embed-text\n";
650
+ }
651
+ if (!content.includes("USE_OLLAMA_EMBEDDINGS")) {
652
+ content += "USE_OLLAMA_EMBEDDINGS=true\n";
653
+ }
654
+ await fs2.writeFile(envFilePath, content, "utf8");
655
+ console.info("[\u221A] Ollama embedding model configuration added to .env file");
656
+ } else {
657
+ console.info("[\u221A] Ollama configuration already set - will use for embeddings");
658
+ }
659
+ }
660
+ break;
661
+ }
662
+ case "google": {
663
+ if (!hasValidApiKey(content, "GOOGLE_GENERATIVE_AI_API_KEY")) {
664
+ if (isNonInteractive) {
665
+ if (!content.includes("GOOGLE_GENERATIVE_AI_API_KEY=")) {
666
+ content += "\n# Embedding Model Configuration (Fallback)\n";
667
+ content += "# Google Generative AI Embeddings Configuration\n";
668
+ content += "GOOGLE_GENERATIVE_AI_API_KEY=your_google_api_key_here\n";
669
+ content += "# Get your API key from: https://aistudio.google.com/apikey\n";
670
+ }
671
+ await fs2.writeFile(envFilePath, content, "utf8");
672
+ console.info("[\u221A] Google embeddings placeholder configuration added to .env file");
673
+ } else {
674
+ console.info("\n[!] Google Generative AI API key is required for embeddings");
675
+ await promptAndStoreGoogleKey(envFilePath);
676
+ }
677
+ } else {
678
+ console.info("[\u221A] Google API key already configured - will use for embeddings");
679
+ }
680
+ break;
681
+ }
682
+ default:
683
+ console.warn(`Unknown embedding model: ${embeddingModel}, skipping configuration`);
684
+ return;
685
+ }
686
+ } catch (error) {
687
+ const errorMessage = error instanceof Error ? error.message : "Unknown error";
688
+ console.error(`Failed to set up embedding model configuration: ${errorMessage}`);
689
+ }
690
+ }
509
691
  async function installDependencies(targetDir) {
510
692
  if (process.env.CI === "true" || process.env.ELIZA_TEST_MODE === "true") {
511
693
  console.info("Skipping dependency installation in CI/test environment...");
@@ -514,7 +696,7 @@ async function installDependencies(targetDir) {
514
696
  console.info("Installing dependencies...");
515
697
  await runBunCommand(["install"], targetDir);
516
698
  }
517
- async function setupProjectEnvironment(targetDir, database, aiModel, isNonInteractive = false) {
699
+ async function setupProjectEnvironment(targetDir, database, aiModel, embeddingModel, isNonInteractive = false) {
518
700
  await createProjectDirectories(targetDir);
519
701
  const envFilePath = `${targetDir}/.env`;
520
702
  if (database === "postgres" && !isNonInteractive) {
@@ -523,6 +705,9 @@ async function setupProjectEnvironment(targetDir, database, aiModel, isNonIntera
523
705
  await setupPgLite(void 0, `${targetDir}/.env`, targetDir);
524
706
  }
525
707
  await setupAIModelConfig(aiModel, envFilePath, isNonInteractive);
708
+ if (embeddingModel) {
709
+ await setupEmbeddingModelConfig(embeddingModel, envFilePath, isNonInteractive);
710
+ }
526
711
  }
527
712
 
528
713
  // src/commands/create/actions/creators.ts
@@ -596,7 +781,7 @@ To use this agent:`);
596
781
  console.info(` elizaos agent start --path ${agentFilePath}
597
782
  `);
598
783
  }
599
- async function createTEEProject(projectName, targetDir, database, aiModel, isNonInteractive = false) {
784
+ async function createTEEProject(projectName, targetDir, database, aiModel, embeddingModel, isNonInteractive = false) {
600
785
  const teeTargetDir = join(targetDir, projectName);
601
786
  const dirResult = await validateTargetDirectory(teeTargetDir);
602
787
  if (!dirResult.isValid) {
@@ -612,7 +797,7 @@ async function createTEEProject(projectName, targetDir, database, aiModel, isNon
612
797
  }
613
798
  }
614
799
  await copyTemplate("project-tee-starter", teeTargetDir);
615
- await setupProjectEnvironment(teeTargetDir, database, aiModel, isNonInteractive);
800
+ await setupProjectEnvironment(teeTargetDir, database, aiModel, embeddingModel, isNonInteractive);
616
801
  await installDependencies(teeTargetDir);
617
802
  await buildProject(teeTargetDir);
618
803
  console.info(`
@@ -623,7 +808,7 @@ Next steps:`);
623
808
  console.info(` bun run dev
624
809
  `);
625
810
  }
626
- async function createProject(projectName, targetDir, database, aiModel, isNonInteractive = false) {
811
+ async function createProject(projectName, targetDir, database, aiModel, embeddingModel, isNonInteractive = false) {
627
812
  const projectTargetDir = projectName === "." ? targetDir : join(targetDir, projectName);
628
813
  const dirResult = await validateTargetDirectory(projectTargetDir);
629
814
  if (!dirResult.isValid) {
@@ -639,7 +824,13 @@ async function createProject(projectName, targetDir, database, aiModel, isNonInt
639
824
  }
640
825
  }
641
826
  await copyTemplate("project-starter", projectTargetDir);
642
- await setupProjectEnvironment(projectTargetDir, database, aiModel, isNonInteractive);
827
+ await setupProjectEnvironment(
828
+ projectTargetDir,
829
+ database,
830
+ aiModel,
831
+ embeddingModel,
832
+ isNonInteractive
833
+ );
643
834
  await installDependencies(projectTargetDir);
644
835
  await buildProject(projectTargetDir);
645
836
  const displayName = projectName === "." ? "Project" : `Project "${projectName}"`;
@@ -657,9 +848,11 @@ export {
657
848
  validateProjectName,
658
849
  selectDatabase,
659
850
  selectAIModel,
851
+ selectEmbeddingModel,
660
852
  getElizaCharacter,
661
853
  createProjectDirectories,
662
854
  setupAIModelConfig,
855
+ setupEmbeddingModelConfig,
663
856
  installDependencies,
664
857
  setupProjectEnvironment,
665
858
  createPlugin,
@@ -9,13 +9,14 @@ import {
9
9
  createTEEProject,
10
10
  selectAIModel,
11
11
  selectDatabase,
12
+ selectEmbeddingModel,
12
13
  validateCreateOptions,
13
14
  validateProjectName
14
- } from "./chunk-PYMK3ECE.js";
15
+ } from "./chunk-ELCESP3O.js";
15
16
  import {
16
17
  displayBanner,
17
18
  handleError
18
- } from "./chunk-Y76S7TNK.js";
19
+ } from "./chunk-WP6OGNZE.js";
19
20
 
20
21
  // src/commands/create/index.ts
21
22
  import { Command } from "commander";
@@ -112,22 +113,44 @@ var create = new Command("create").description("Create a new ElizaOS project, pl
112
113
  case "tee": {
113
114
  let database = "pglite";
114
115
  let aiModel = "local";
116
+ let embeddingModel;
115
117
  if (!isNonInteractive) {
116
118
  database = await selectDatabase();
117
119
  aiModel = await selectAIModel();
120
+ if (aiModel === "claude" || aiModel === "openrouter") {
121
+ embeddingModel = await selectEmbeddingModel();
122
+ }
118
123
  }
119
- await createTEEProject(projectName, targetDir, database, aiModel, isNonInteractive);
124
+ await createTEEProject(
125
+ projectName,
126
+ targetDir,
127
+ database,
128
+ aiModel,
129
+ embeddingModel,
130
+ isNonInteractive
131
+ );
120
132
  break;
121
133
  }
122
134
  case "project":
123
135
  default: {
124
136
  let database = "pglite";
125
137
  let aiModel = "local";
138
+ let embeddingModel;
126
139
  if (!isNonInteractive) {
127
140
  database = await selectDatabase();
128
141
  aiModel = await selectAIModel();
142
+ if (aiModel === "claude" || aiModel === "openrouter") {
143
+ embeddingModel = await selectEmbeddingModel();
144
+ }
129
145
  }
130
- await createProject(projectName, targetDir, database, aiModel, isNonInteractive);
146
+ await createProject(
147
+ projectName,
148
+ targetDir,
149
+ database,
150
+ aiModel,
151
+ embeddingModel,
152
+ isNonInteractive
153
+ );
131
154
  break;
132
155
  }
133
156
  }