@elizaos/cli 1.0.7 → 1.0.8
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/dist/assets/{index-zeG6Jws8.js → index-CZAd5zm2.js} +17 -17
- package/dist/assets/index-CZAd5zm2.js.br +0 -0
- package/dist/assets/{index-zeG6Jws8.js.map → index-CZAd5zm2.js.map} +1 -1
- package/dist/assets/{index-BMJNV7A7.js → index-CaEsCLCC.js} +772 -8056
- package/dist/assets/{index-BMJNV7A7.js.map → index-CaEsCLCC.js.map} +1 -1
- package/dist/assets/{vendor-BiCY-iVm.js → vendor-DSdxb8P-.js} +2 -2
- package/dist/assets/vendor-DSdxb8P-.js.br +0 -0
- package/dist/assets/{vendor-BiCY-iVm.js.map → vendor-DSdxb8P-.js.map} +1 -1
- package/dist/chunk-33BHGAF7.js +616 -0
- package/dist/{chunk-YTV6GDEJ.js → chunk-CVADLFW6.js} +100 -42
- package/dist/chunk-F24MS2YR.js +19 -0
- package/dist/{chunk-7HDCC22V.js → chunk-IEKLJDUU.js} +99 -0
- package/dist/chunk-MA2ZXPG6.js +260 -0
- package/dist/{chunk-YMXO6XZ5.js → chunk-REBZFQYE.js} +4890 -789
- package/dist/chunk-W3HS2NP6.js +154 -0
- package/dist/commands/agent/actions/index.d.ts +25 -0
- package/dist/commands/agent/actions/index.js +23 -0
- package/dist/commands/agent/index.d.ts +16 -0
- package/dist/commands/agent/index.js +24 -0
- package/dist/commands/create/actions/index.d.ts +35 -0
- package/dist/commands/create/actions/index.js +30 -0
- package/dist/commands/{create.d.ts → create/index.d.ts} +0 -3
- package/dist/commands/create/index.js +17 -0
- package/dist/commands/shared/index.d.ts +35 -0
- package/dist/commands/shared/index.js +13 -0
- package/dist/index.html +2 -2
- package/dist/index.js +103835 -56
- package/dist/{prompts-I4LK5NKX.js → lib-NAGYZHVV.js} +3 -3
- package/dist/{migrator-BQMHMHSG.js → migrator-KZLCVEIH.js} +117 -117
- package/dist/{plugin-creator-EUJNDFIB.js → plugin-creator-IC42XOHG.js} +3 -4
- package/dist/{registry-AV3SDTPW.js → registry-XFOSZFU4.js} +4 -5
- package/dist/utils-DIZZ3HNZ.js +218 -0
- package/package.json +18 -11
- package/templates/plugin-starter/package.json +1 -1
- package/templates/project-starter/package.json +1 -1
- package/templates/project-tee-starter/e2e/project.test.ts +1 -1
- package/templates/project-tee-starter/e2e/starter-plugin.test.ts +1 -1
- package/templates/project-tee-starter/package.json +2 -1
- package/dist/assets/index-zeG6Jws8.js.br +0 -0
- package/dist/assets/vendor-BiCY-iVm.js.br +0 -0
- package/dist/chunk-2RXF3FKA.js +0 -17
- package/dist/chunk-335PGADS.js +0 -207
- package/dist/chunk-3EAACNH2.js +0 -478
- package/dist/chunk-4OL6NNBI.js +0 -264
- package/dist/chunk-5J7S2CSH.js +0 -2771
- package/dist/chunk-APFJCFC6.js +0 -78
- package/dist/chunk-CEMRVVKO.js +0 -96
- package/dist/chunk-IYVGVCIB.js +0 -90156
- package/dist/chunk-JOHBW4FN.js +0 -576
- package/dist/chunk-JROMRXES.js +0 -711
- package/dist/chunk-KB3JDWUI.js +0 -106
- package/dist/chunk-LRSU7IN6.js +0 -4862
- package/dist/chunk-SCN6ZP4J.js +0 -315
- package/dist/chunk-V2MPQGYW.js +0 -613
- package/dist/chunk-WIPEH5RX.js +0 -7898
- package/dist/commands/agent.d.ts +0 -27
- package/dist/commands/agent.js +0 -22
- package/dist/commands/create.js +0 -18
- package/dist/commands/dev.d.ts +0 -8
- package/dist/commands/dev.js +0 -18
- package/dist/commands/env.d.ts +0 -16
- package/dist/commands/env.js +0 -21
- package/dist/commands/monorepo.d.ts +0 -5
- package/dist/commands/monorepo.js +0 -17
- package/dist/commands/plugins.d.ts +0 -19
- package/dist/commands/plugins.js +0 -25
- package/dist/commands/publish.d.ts +0 -5
- package/dist/commands/publish.js +0 -18
- package/dist/commands/start.d.ts +0 -198
- package/dist/commands/start.js +0 -26
- package/dist/commands/tee.d.ts +0 -5
- package/dist/commands/tee.js +0 -13
- package/dist/commands/test.d.ts +0 -6
- package/dist/commands/test.js +0 -25
- package/dist/commands/update.d.ts +0 -14
- package/dist/commands/update.js +0 -23
- package/dist/{chunk-NHI4RJD2.js → chunk-CEE6RKN5.js} +58 -58
package/dist/chunk-3EAACNH2.js
DELETED
|
@@ -1,478 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
import { createRequire } from 'module';
|
|
3
|
-
const require = createRequire(import.meta.url);
|
|
4
|
-
|
|
5
|
-
import {
|
|
6
|
-
character
|
|
7
|
-
} from "./chunk-335PGADS.js";
|
|
8
|
-
import {
|
|
9
|
-
base_exports,
|
|
10
|
-
buildProject,
|
|
11
|
-
copyTemplate,
|
|
12
|
-
displayBanner,
|
|
13
|
-
ensureElizaDir,
|
|
14
|
-
handleError,
|
|
15
|
-
promptAndStoreAnthropicKey,
|
|
16
|
-
promptAndStoreOpenAIKey,
|
|
17
|
-
promptAndStorePostgresUrl,
|
|
18
|
-
setupPgLite
|
|
19
|
-
} from "./chunk-YMXO6XZ5.js";
|
|
20
|
-
import {
|
|
21
|
-
runBunCommand
|
|
22
|
-
} from "./chunk-GYTAJJOD.js";
|
|
23
|
-
import {
|
|
24
|
-
Command
|
|
25
|
-
} from "./chunk-5J7S2CSH.js";
|
|
26
|
-
import {
|
|
27
|
-
require_prompts
|
|
28
|
-
} from "./chunk-LRSU7IN6.js";
|
|
29
|
-
import {
|
|
30
|
-
__toESM
|
|
31
|
-
} from "./chunk-567UPUC7.js";
|
|
32
|
-
|
|
33
|
-
// src/commands/create.ts
|
|
34
|
-
var import_prompts = __toESM(require_prompts(), 1);
|
|
35
|
-
import { existsSync } from "node:fs";
|
|
36
|
-
import fs from "node:fs/promises";
|
|
37
|
-
import path from "node:path";
|
|
38
|
-
import { z } from "zod";
|
|
39
|
-
import { logger } from "@elizaos/core";
|
|
40
|
-
var initOptionsSchema = z.object({
|
|
41
|
-
dir: z.string().default("."),
|
|
42
|
-
yes: z.boolean().default(false),
|
|
43
|
-
type: z.enum(["project", "plugin", "agent", "tee"]).default("project")
|
|
44
|
-
});
|
|
45
|
-
function getAvailableAIModels() {
|
|
46
|
-
return [
|
|
47
|
-
{
|
|
48
|
-
title: "Local AI (free to use, no API key required)",
|
|
49
|
-
value: "local",
|
|
50
|
-
description: "Use local AI models without external API requirements. Will download model to run locally - recommended if you have good internet connection."
|
|
51
|
-
},
|
|
52
|
-
{
|
|
53
|
-
title: "OpenAI (ChatGPT)",
|
|
54
|
-
value: "openai",
|
|
55
|
-
description: "Use OpenAI models like GPT-4"
|
|
56
|
-
},
|
|
57
|
-
{
|
|
58
|
-
title: "Anthropic (Claude)",
|
|
59
|
-
value: "claude",
|
|
60
|
-
description: "Use Anthropic Claude models"
|
|
61
|
-
}
|
|
62
|
-
];
|
|
63
|
-
}
|
|
64
|
-
function getAvailableDatabases() {
|
|
65
|
-
return [
|
|
66
|
-
{
|
|
67
|
-
title: "Pglite (Pglite) - Recommended for development",
|
|
68
|
-
value: "pglite",
|
|
69
|
-
description: "Fast, file-based database. Perfect for development and single-user deployments."
|
|
70
|
-
},
|
|
71
|
-
{
|
|
72
|
-
title: "PostgreSQL - Recommended for production",
|
|
73
|
-
value: "postgres",
|
|
74
|
-
description: "Full-featured database with vector search. Best for production and multi-user systems."
|
|
75
|
-
}
|
|
76
|
-
];
|
|
77
|
-
}
|
|
78
|
-
async function setupAIModelConfig(aiModel, envFilePath, isNonInteractive = false) {
|
|
79
|
-
try {
|
|
80
|
-
switch (aiModel) {
|
|
81
|
-
case "local": {
|
|
82
|
-
console.info("[\u221A] Using Local AI - no additional configuration needed");
|
|
83
|
-
break;
|
|
84
|
-
}
|
|
85
|
-
case "openai": {
|
|
86
|
-
if (isNonInteractive) {
|
|
87
|
-
let content = "";
|
|
88
|
-
if (existsSync(envFilePath)) {
|
|
89
|
-
content = await fs.readFile(envFilePath, "utf8");
|
|
90
|
-
}
|
|
91
|
-
if (content && !content.endsWith("\n")) {
|
|
92
|
-
content += "\n";
|
|
93
|
-
}
|
|
94
|
-
content += "\n# AI Model Configuration\n";
|
|
95
|
-
content += "# OpenAI Configuration\n";
|
|
96
|
-
content += "OPENAI_API_KEY=your_openai_api_key_here\n";
|
|
97
|
-
content += "# Get your API key from: https://platform.openai.com/api-keys\n";
|
|
98
|
-
await fs.writeFile(envFilePath, content, "utf8");
|
|
99
|
-
console.info("[\u221A] OpenAI placeholder configuration added to .env file");
|
|
100
|
-
} else {
|
|
101
|
-
await promptAndStoreOpenAIKey(envFilePath);
|
|
102
|
-
}
|
|
103
|
-
break;
|
|
104
|
-
}
|
|
105
|
-
case "claude": {
|
|
106
|
-
if (isNonInteractive) {
|
|
107
|
-
let content = "";
|
|
108
|
-
if (existsSync(envFilePath)) {
|
|
109
|
-
content = await fs.readFile(envFilePath, "utf8");
|
|
110
|
-
}
|
|
111
|
-
if (content && !content.endsWith("\n")) {
|
|
112
|
-
content += "\n";
|
|
113
|
-
}
|
|
114
|
-
content += "\n# AI Model Configuration\n";
|
|
115
|
-
content += "# Anthropic API Configuration\n";
|
|
116
|
-
content += "ANTHROPIC_API_KEY=your_anthropic_api_key_here\n";
|
|
117
|
-
content += "# Get your API key from: https://console.anthropic.com/\n";
|
|
118
|
-
await fs.writeFile(envFilePath, content, "utf8");
|
|
119
|
-
console.info("[\u221A] Anthropic API placeholder configuration added to .env file");
|
|
120
|
-
} else {
|
|
121
|
-
await promptAndStoreAnthropicKey(envFilePath);
|
|
122
|
-
}
|
|
123
|
-
break;
|
|
124
|
-
}
|
|
125
|
-
default:
|
|
126
|
-
console.warn(`Unknown AI model: ${aiModel}, skipping configuration`);
|
|
127
|
-
return;
|
|
128
|
-
}
|
|
129
|
-
} catch (error) {
|
|
130
|
-
const errorMessage = error instanceof Error ? error.message : "Unknown error";
|
|
131
|
-
console.error(`Failed to set up AI model configuration: ${errorMessage}`);
|
|
132
|
-
}
|
|
133
|
-
}
|
|
134
|
-
async function installDependencies(targetDir) {
|
|
135
|
-
console.info("Installing dependencies...");
|
|
136
|
-
try {
|
|
137
|
-
await runBunCommand(["install", "--no-optional"], targetDir);
|
|
138
|
-
console.log("Installed base dependencies");
|
|
139
|
-
} catch (error) {
|
|
140
|
-
console.warn(
|
|
141
|
-
"Failed to install dependencies automatically. Please run 'bun install' manually."
|
|
142
|
-
);
|
|
143
|
-
}
|
|
144
|
-
}
|
|
145
|
-
async function selectDatabase(isYes) {
|
|
146
|
-
const availableDatabases = getAvailableDatabases();
|
|
147
|
-
if (isYes) {
|
|
148
|
-
const database = "pglite";
|
|
149
|
-
console.info(`Using default database: ${database}`);
|
|
150
|
-
return database;
|
|
151
|
-
}
|
|
152
|
-
const response = await (0, import_prompts.default)({
|
|
153
|
-
type: "select",
|
|
154
|
-
name: "database",
|
|
155
|
-
message: "Select your database:",
|
|
156
|
-
choices: availableDatabases,
|
|
157
|
-
initial: 0
|
|
158
|
-
// Default to Pglite
|
|
159
|
-
});
|
|
160
|
-
if (!response.database) {
|
|
161
|
-
throw new Error("No database selected or provided");
|
|
162
|
-
}
|
|
163
|
-
return response.database;
|
|
164
|
-
}
|
|
165
|
-
async function selectAIModel(isYes) {
|
|
166
|
-
const availableAIModels = getAvailableAIModels();
|
|
167
|
-
if (isYes) {
|
|
168
|
-
const aiModel = "local";
|
|
169
|
-
console.info(`Using default AI model: ${aiModel}`);
|
|
170
|
-
return aiModel;
|
|
171
|
-
}
|
|
172
|
-
const response = await (0, import_prompts.default)({
|
|
173
|
-
type: "select",
|
|
174
|
-
name: "aiModel",
|
|
175
|
-
message: "Select your AI model:",
|
|
176
|
-
choices: availableAIModels,
|
|
177
|
-
initial: 0
|
|
178
|
-
// Default to local
|
|
179
|
-
});
|
|
180
|
-
if (!response.aiModel) {
|
|
181
|
-
throw new Error("No AI model selected or provided");
|
|
182
|
-
}
|
|
183
|
-
return response.aiModel;
|
|
184
|
-
}
|
|
185
|
-
async function createProjectDirectories(targetDir) {
|
|
186
|
-
if (!existsSync(targetDir)) {
|
|
187
|
-
await fs.mkdir(targetDir, { recursive: true });
|
|
188
|
-
}
|
|
189
|
-
const srcDir = path.join(targetDir, "src");
|
|
190
|
-
if (!existsSync(srcDir)) {
|
|
191
|
-
await fs.mkdir(srcDir);
|
|
192
|
-
}
|
|
193
|
-
await fs.mkdir(path.join(targetDir, "knowledge"), { recursive: true });
|
|
194
|
-
}
|
|
195
|
-
async function setupProjectEnvironment(targetDir, database, aiModel, isYes) {
|
|
196
|
-
const projectEnvFilePath = path.join(targetDir, ".env");
|
|
197
|
-
const dirs = await ensureElizaDir(targetDir);
|
|
198
|
-
logger.debug("Project directories set up:", dirs);
|
|
199
|
-
if (database === "pglite") {
|
|
200
|
-
const projectPgliteDbDir = path.join(targetDir, ".elizadb");
|
|
201
|
-
await setupPgLite(projectPgliteDbDir, projectEnvFilePath, targetDir);
|
|
202
|
-
console.debug(`Pglite database will be stored in project directory: ${projectPgliteDbDir}`);
|
|
203
|
-
} else if (database === "postgres") {
|
|
204
|
-
await promptAndStorePostgresUrl(projectEnvFilePath);
|
|
205
|
-
}
|
|
206
|
-
await setupAIModelConfig(aiModel, projectEnvFilePath, isYes);
|
|
207
|
-
}
|
|
208
|
-
function processPluginName(projectName) {
|
|
209
|
-
let processedName = projectName;
|
|
210
|
-
if (!processedName.startsWith("plugin-")) {
|
|
211
|
-
const prefixedName = `plugin-${processedName}`;
|
|
212
|
-
console.info(
|
|
213
|
-
`Note: Using "${prefixedName}" as the directory name to match plugin naming convention`
|
|
214
|
-
);
|
|
215
|
-
processedName = prefixedName;
|
|
216
|
-
}
|
|
217
|
-
const pluginNameRegex = /^plugin-[a-z0-9]+(-[a-z0-9]+)*$/;
|
|
218
|
-
if (!pluginNameRegex.test(processedName)) {
|
|
219
|
-
console.error(base_exports.red(`Error: Invalid plugin name "${processedName}".`));
|
|
220
|
-
console.error("Plugin names must follow the format: plugin-[alphanumeric]");
|
|
221
|
-
console.error("Examples: plugin-test, plugin-my-service, plugin-ai-tools");
|
|
222
|
-
process.exit(1);
|
|
223
|
-
}
|
|
224
|
-
return processedName;
|
|
225
|
-
}
|
|
226
|
-
function validateProjectName(name, type) {
|
|
227
|
-
if (name === ".") {
|
|
228
|
-
return;
|
|
229
|
-
}
|
|
230
|
-
if (name.includes(" ")) {
|
|
231
|
-
console.error(base_exports.red(`Error: Invalid ${type} name "${name}".`));
|
|
232
|
-
console.error(`${type} names must follow npm package naming conventions:`);
|
|
233
|
-
console.error("- Cannot contain spaces");
|
|
234
|
-
console.error("- Must contain only lowercase letters, numbers, hyphens, or underscores");
|
|
235
|
-
console.error("- Cannot start with a dot or underscore");
|
|
236
|
-
process.exit(1);
|
|
237
|
-
}
|
|
238
|
-
const validNameRegex = /^[a-z0-9][-a-z0-9._]*$/;
|
|
239
|
-
if (!validNameRegex.test(name)) {
|
|
240
|
-
console.error(base_exports.red(`Error: Invalid ${type} name "${name}".`));
|
|
241
|
-
console.error(`${type} names must follow npm package naming conventions:`);
|
|
242
|
-
console.error("- Cannot contain spaces");
|
|
243
|
-
console.error("- Must contain only lowercase letters, numbers, hyphens, or underscores");
|
|
244
|
-
console.error("- Cannot start with a dot or underscore");
|
|
245
|
-
process.exit(1);
|
|
246
|
-
}
|
|
247
|
-
}
|
|
248
|
-
async function validateTargetDirectory(targetDir, projectName) {
|
|
249
|
-
if (existsSync(targetDir)) {
|
|
250
|
-
const files = await fs.readdir(targetDir);
|
|
251
|
-
const isEmpty = files.length === 0 || files.every((f) => f.startsWith("."));
|
|
252
|
-
if (!isEmpty) {
|
|
253
|
-
console.error(
|
|
254
|
-
base_exports.red(`Error: Directory "${projectName}" already exists and is not empty.`)
|
|
255
|
-
);
|
|
256
|
-
console.error(
|
|
257
|
-
"Please choose a different name or manually remove the directory contents first."
|
|
258
|
-
);
|
|
259
|
-
handleError(new Error(`Directory "${projectName}" is not empty`));
|
|
260
|
-
throw new Error(`Directory "${projectName}" is not empty`);
|
|
261
|
-
}
|
|
262
|
-
console.info(`Note: Directory "${projectName}" already exists but is empty. Continuing...`);
|
|
263
|
-
}
|
|
264
|
-
}
|
|
265
|
-
async function createPlugin(options, projectName, targetDir) {
|
|
266
|
-
const processedName = processPluginName(projectName);
|
|
267
|
-
const finalTargetDir = path.join(path.dirname(targetDir), processedName);
|
|
268
|
-
await validateTargetDirectory(finalTargetDir, processedName);
|
|
269
|
-
if (!existsSync(finalTargetDir)) {
|
|
270
|
-
await fs.mkdir(finalTargetDir, { recursive: true });
|
|
271
|
-
}
|
|
272
|
-
const pluginName = processedName.startsWith("@elizaos/plugin-") ? processedName : `@elizaos/plugin-${processedName.replace("plugin-", "")}`;
|
|
273
|
-
await copyTemplate("plugin", finalTargetDir, pluginName);
|
|
274
|
-
console.info("Installing dependencies...");
|
|
275
|
-
try {
|
|
276
|
-
await runBunCommand(["install", "--no-optional"], finalTargetDir);
|
|
277
|
-
console.log("Dependencies installed successfully!");
|
|
278
|
-
if (process.env.ELIZA_NONINTERACTIVE === "1" || process.env.ELIZA_NONINTERACTIVE === "true") {
|
|
279
|
-
console.log("Skipping build in non-interactive mode");
|
|
280
|
-
} else {
|
|
281
|
-
await buildProject(finalTargetDir, true);
|
|
282
|
-
}
|
|
283
|
-
} catch (_error) {
|
|
284
|
-
console.warn(
|
|
285
|
-
"Failed to install dependencies automatically. Please run 'bun install' manually."
|
|
286
|
-
);
|
|
287
|
-
}
|
|
288
|
-
console.log("Plugin initialized successfully!");
|
|
289
|
-
const cdPath = options.dir === "." ? processedName : path.relative(process.cwd(), finalTargetDir);
|
|
290
|
-
console.info(
|
|
291
|
-
`
|
|
292
|
-
Your plugin is ready! Here's your development workflow:
|
|
293
|
-
|
|
294
|
-
[1] Development
|
|
295
|
-
cd ${cdPath}
|
|
296
|
-
${base_exports.cyan("elizaos dev")} # Start development with hot-reloading
|
|
297
|
-
|
|
298
|
-
[2] Testing
|
|
299
|
-
${base_exports.cyan("elizaos test")} # Run automated tests
|
|
300
|
-
${base_exports.cyan("elizaos start")} # Test in a live agent environment
|
|
301
|
-
|
|
302
|
-
[3] Publishing
|
|
303
|
-
${base_exports.cyan("elizaos publish --test")} # Check registry requirements
|
|
304
|
-
${base_exports.cyan("elizaos publish")} # Submit to registry
|
|
305
|
-
|
|
306
|
-
[?] Learn more: https://eliza.how/docs/cli/plugins`
|
|
307
|
-
);
|
|
308
|
-
process.stdout.write(`\x1B]1337;CurrentDir=${finalTargetDir}\x07`);
|
|
309
|
-
}
|
|
310
|
-
async function createAgent(projectName) {
|
|
311
|
-
const characterName = projectName || "MyAgent";
|
|
312
|
-
const agentTemplate = { ...character };
|
|
313
|
-
agentTemplate.name = characterName;
|
|
314
|
-
if (agentTemplate.messageExamples) {
|
|
315
|
-
for (const conversation of agentTemplate.messageExamples) {
|
|
316
|
-
for (const message of conversation) {
|
|
317
|
-
if (message.name === "Eliza") {
|
|
318
|
-
message.name = characterName;
|
|
319
|
-
}
|
|
320
|
-
}
|
|
321
|
-
}
|
|
322
|
-
}
|
|
323
|
-
const filename = characterName.endsWith(".json") ? characterName : `${characterName}.json`;
|
|
324
|
-
const fullPath = path.join(process.cwd(), filename);
|
|
325
|
-
await fs.writeFile(fullPath, JSON.stringify(agentTemplate, null, 2), "utf8");
|
|
326
|
-
console.log(`Agent character created successfully: ${filename}`);
|
|
327
|
-
console.info(`
|
|
328
|
-
You can now use this agent with:
|
|
329
|
-
elizaos agent start --path ${filename}`);
|
|
330
|
-
}
|
|
331
|
-
async function createTEEProject(options, projectName, targetDir) {
|
|
332
|
-
console.info("Creating TEE-enabled project with TEE capabilities...");
|
|
333
|
-
await validateTargetDirectory(targetDir, projectName);
|
|
334
|
-
await createProjectDirectories(targetDir);
|
|
335
|
-
const database = await selectDatabase(options.yes);
|
|
336
|
-
const aiModel = await selectAIModel(options.yes);
|
|
337
|
-
await copyTemplate("project-tee-starter", targetDir, projectName);
|
|
338
|
-
await setupProjectEnvironment(targetDir, database, aiModel, options.yes);
|
|
339
|
-
await installDependencies(targetDir);
|
|
340
|
-
if (process.env.ELIZA_NONINTERACTIVE === "1" || process.env.ELIZA_NONINTERACTIVE === "true") {
|
|
341
|
-
console.log("Skipping build in non-interactive mode");
|
|
342
|
-
} else {
|
|
343
|
-
await buildProject(targetDir);
|
|
344
|
-
}
|
|
345
|
-
console.log("TEE project initialized successfully!");
|
|
346
|
-
const cdPath = options.dir === "." ? projectName : path.relative(process.cwd(), targetDir);
|
|
347
|
-
console.info(
|
|
348
|
-
`
|
|
349
|
-
Your TEE project is ready! Here's what you can do next:
|
|
350
|
-
1. \`cd ${cdPath}\` to change into your project directory
|
|
351
|
-
2. Run \`elizaos start\` to start your project
|
|
352
|
-
3. Visit \`http://localhost:3000\` (or your custom port) to view your project in the browser
|
|
353
|
-
4. Use \`elizaos tee phala\` commands for TEE deployment`
|
|
354
|
-
);
|
|
355
|
-
process.stdout.write(`\x1B]1337;CurrentDir=${targetDir}\x07`);
|
|
356
|
-
}
|
|
357
|
-
async function createProject(options, projectName, targetDir) {
|
|
358
|
-
await validateTargetDirectory(targetDir, projectName);
|
|
359
|
-
await createProjectDirectories(targetDir);
|
|
360
|
-
const database = await selectDatabase(options.yes);
|
|
361
|
-
const aiModel = await selectAIModel(options.yes);
|
|
362
|
-
await copyTemplate("project-starter", targetDir, projectName);
|
|
363
|
-
await setupProjectEnvironment(targetDir, database, aiModel, options.yes);
|
|
364
|
-
await installDependencies(targetDir);
|
|
365
|
-
if (process.env.ELIZA_NONINTERACTIVE === "1" || process.env.ELIZA_NONINTERACTIVE === "true") {
|
|
366
|
-
console.log("Skipping build in non-interactive mode");
|
|
367
|
-
} else {
|
|
368
|
-
await buildProject(targetDir);
|
|
369
|
-
}
|
|
370
|
-
console.log("Project initialized successfully!");
|
|
371
|
-
const cdPath = options.dir === "." ? projectName : path.relative(process.cwd(), targetDir);
|
|
372
|
-
console.info(
|
|
373
|
-
`
|
|
374
|
-
Your project is ready! Here's what you can do next:
|
|
375
|
-
1. \`cd ${cdPath}\` to change into your project directory
|
|
376
|
-
2. Run \`elizaos start\` to start your project
|
|
377
|
-
3. Visit \`http://localhost:3000\` (or your custom port) to view your project in the browser`
|
|
378
|
-
);
|
|
379
|
-
process.stdout.write(`\x1B]1337;CurrentDir=${targetDir}\x07`);
|
|
380
|
-
}
|
|
381
|
-
var create = new Command().name("create").description("Initialize a new project, plugin, agent, or TEE project").option("-d, --dir <dir>", "installation directory", ".").option("-y, --yes", "skip confirmation", false).option("-t, --type <type>", "type to create (project, plugin, agent, or tee)", "project").argument("[name]", "name for the project, plugin, agent, or TEE project").action(async (name, opts) => {
|
|
382
|
-
if (process.env.ELIZA_NONINTERACTIVE === "1" || process.env.ELIZA_NONINTERACTIVE === "true" || process.argv.includes("-y") || process.argv.includes("--yes")) {
|
|
383
|
-
opts.yes = true;
|
|
384
|
-
} else {
|
|
385
|
-
opts.yes = false;
|
|
386
|
-
}
|
|
387
|
-
opts.yes = opts.yes === true || opts.yes === "true";
|
|
388
|
-
await displayBanner();
|
|
389
|
-
try {
|
|
390
|
-
const initialOptions = {
|
|
391
|
-
dir: opts.dir || ".",
|
|
392
|
-
yes: opts.yes,
|
|
393
|
-
// Already properly converted to boolean above
|
|
394
|
-
type: opts.type || ""
|
|
395
|
-
};
|
|
396
|
-
let projectType = initialOptions.type;
|
|
397
|
-
if (!projectType) {
|
|
398
|
-
if (initialOptions.yes) {
|
|
399
|
-
projectType = "project";
|
|
400
|
-
} else {
|
|
401
|
-
const { type } = await (0, import_prompts.default)({
|
|
402
|
-
type: "select",
|
|
403
|
-
name: "type",
|
|
404
|
-
message: "What would you like to create?",
|
|
405
|
-
choices: [
|
|
406
|
-
{ title: "Project - Contains agents and plugins", value: "project" },
|
|
407
|
-
{
|
|
408
|
-
title: "Plugin - Can be added to the registry and installed by others",
|
|
409
|
-
value: "plugin"
|
|
410
|
-
},
|
|
411
|
-
{
|
|
412
|
-
title: "Agent - Character definition file for an agent",
|
|
413
|
-
value: "agent"
|
|
414
|
-
},
|
|
415
|
-
{
|
|
416
|
-
title: "TEE - Trusted Execution Environment project",
|
|
417
|
-
value: "tee"
|
|
418
|
-
}
|
|
419
|
-
],
|
|
420
|
-
initial: 0
|
|
421
|
-
});
|
|
422
|
-
if (!type) {
|
|
423
|
-
return;
|
|
424
|
-
}
|
|
425
|
-
projectType = type;
|
|
426
|
-
}
|
|
427
|
-
} else {
|
|
428
|
-
if (!["project", "plugin", "agent", "tee"].includes(projectType)) {
|
|
429
|
-
console.error(
|
|
430
|
-
`Invalid type: ${projectType}. Must be 'project', 'plugin', 'agent', or 'tee'`
|
|
431
|
-
);
|
|
432
|
-
process.exit(1);
|
|
433
|
-
}
|
|
434
|
-
}
|
|
435
|
-
const options = initOptionsSchema.parse({
|
|
436
|
-
...initialOptions,
|
|
437
|
-
type: projectType
|
|
438
|
-
});
|
|
439
|
-
let projectName = name;
|
|
440
|
-
if (!projectName) {
|
|
441
|
-
if (options.yes) {
|
|
442
|
-
projectName = options.type === "plugin" ? "myplugin" : "myproject";
|
|
443
|
-
console.info(`Using default name: ${projectName}`);
|
|
444
|
-
} else {
|
|
445
|
-
const { nameResponse } = await (0, import_prompts.default)({
|
|
446
|
-
type: "text",
|
|
447
|
-
name: "nameResponse",
|
|
448
|
-
message: `What would you like to name your ${options.type}?`,
|
|
449
|
-
validate: (value) => value.length > 0 || `${options.type} name is required`
|
|
450
|
-
});
|
|
451
|
-
if (!nameResponse) {
|
|
452
|
-
return;
|
|
453
|
-
}
|
|
454
|
-
projectName = nameResponse;
|
|
455
|
-
}
|
|
456
|
-
}
|
|
457
|
-
validateProjectName(projectName, options.type);
|
|
458
|
-
const targetDir = path.join(options.dir === "." ? process.cwd() : options.dir, projectName);
|
|
459
|
-
if (options.type === "plugin") {
|
|
460
|
-
await createPlugin(options, projectName, targetDir);
|
|
461
|
-
} else if (options.type === "agent") {
|
|
462
|
-
await createAgent(projectName);
|
|
463
|
-
} else if (options.type === "tee") {
|
|
464
|
-
await createTEEProject(options, projectName, targetDir);
|
|
465
|
-
} else if (options.type === "project") {
|
|
466
|
-
await createProject(options, projectName, targetDir);
|
|
467
|
-
} else {
|
|
468
|
-
console.error(`Unknown type: ${options.type}`);
|
|
469
|
-
process.exit(1);
|
|
470
|
-
}
|
|
471
|
-
} catch (error) {
|
|
472
|
-
handleError(error);
|
|
473
|
-
}
|
|
474
|
-
});
|
|
475
|
-
|
|
476
|
-
export {
|
|
477
|
-
create
|
|
478
|
-
};
|