@elizaos/cli 1.4.3 → 1.4.5
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/BrowserWebSocketTransport-5YQPVDV7.js +7 -0
- package/dist/EnhancedEvaluationEngine-APOQ6INN.js +473 -0
- package/dist/EvaluationEngine-Y7ZQJBRC.js +9 -0
- package/dist/LocalEnvironmentProvider-JWFGG4IN.js +15 -0
- package/dist/NodeWebSocketTransport-PUO724EY.js +8 -0
- package/dist/ScreenRecorder-YK246DNJ.js +10 -0
- package/dist/agent-start-6QJQAMKA.js +13 -0
- package/dist/bidi-2SVNH6F7.js +15309 -0
- package/dist/{bun-exec-ULMPAIQC.js → bun-exec-NH4UCUY4.js} +1 -1
- package/dist/chunk-2ESYSVXG.js +48 -0
- package/dist/chunk-3AEYIKBZ.js +432 -0
- package/dist/chunk-5IWKEMEF.js +239 -0
- package/dist/chunk-5WZO2HMM.js +2644 -0
- package/dist/chunk-ABGBVB74.js +3501 -0
- package/dist/{chunk-NSNXXD3I.js → chunk-BCO32GR6.js} +2 -2
- package/dist/chunk-CGXTFHQP.js +25 -0
- package/dist/chunk-EXUFDTUD.js +3948 -0
- package/dist/chunk-FGGNHEXZ.js +211860 -0
- package/dist/chunk-FWYHSCLF.js +243 -0
- package/dist/chunk-I57T3WPO.js +165 -0
- package/dist/chunk-LBZLMFFF.js +221 -0
- package/dist/chunk-LG7YDBMV.js +401 -0
- package/dist/chunk-NHKLUXNE.js +166 -0
- package/dist/chunk-PUZHCSGF.js +828 -0
- package/dist/chunk-PWDR7CPA.js +7828 -0
- package/dist/{chunk-N5G5XSGP.js → chunk-Q6M2K53X.js} +3 -3
- package/dist/chunk-SVHCNBHM.js +289 -0
- package/dist/{chunk-HOC6B3QV.js → chunk-VFFOOPYS.js} +4 -238
- package/dist/chunk-WX37MM4G.js +292 -0
- package/dist/chunk-XFJIHUT3.js +6 -0
- package/dist/chunk-XPPESCCM.js +787 -0
- package/dist/chunk-YBDC5OZO.js +40 -0
- package/dist/commands/agent/actions/index.js +2 -2
- package/dist/commands/agent/index.js +2 -2
- package/dist/commands/create/actions/index.js +4 -3
- package/dist/commands/create/index.js +5 -4
- package/dist/commands/shared/index.js +1 -1
- package/dist/index.js +66820 -5009
- package/dist/js-yaml-KADNMPWR.js +35 -0
- package/dist/matrix-orchestrator-3WLRK7GG.js +1070 -0
- package/dist/matrix-runner-KDPETCKQ.js +160 -0
- package/dist/matrix-schema-PCO2KGJY.js +102 -0
- package/dist/parameter-override-ALOPPXCE.js +487 -0
- package/dist/{plugin-creator-TCUFII32.js → plugin-creator-J7GNPMPG.js} +1 -1
- package/dist/process-manager-IU2A3BTQ.js +9 -0
- package/dist/{registry-ELONUC44.js → registry-65KMEA7N.js} +2 -2
- package/dist/resource-monitor-EHZSH2P6.js +15 -0
- package/dist/run-isolation-PGLZ37Y7.js +29 -0
- package/dist/runtime-factory-Q4U5YBNV.js +22 -0
- package/dist/schema-C25LVPEK.js +17 -0
- package/dist/src/commands/report/src/assets/report_template.html +1704 -0
- package/dist/src-EJG4ILDC.js +5 -0
- package/dist/templates/plugin-quick-starter/package.json +2 -2
- package/dist/templates/plugin-quick-starter/src/__tests__/test-utils.ts +1 -0
- package/dist/templates/plugin-starter/package.json +2 -2
- package/dist/templates/plugin-starter/src/__tests__/test-utils.ts +1 -0
- package/dist/templates/project-starter/package.json +4 -4
- package/dist/templates/project-tee-starter/package.json +4 -4
- package/dist/templates/project-tee-starter/src/index.ts +1 -2
- package/dist/typescript-ZF3IK2DJ.js +5 -0
- package/dist/{utils-X6UXPLKD.js → utils-QFD2PW4X.js} +2 -2
- package/package.json +14 -8
- package/templates/plugin-quick-starter/package.json +2 -2
- package/templates/plugin-quick-starter/src/__tests__/test-utils.ts +1 -0
- package/templates/plugin-starter/package.json +2 -2
- package/templates/plugin-starter/src/__tests__/test-utils.ts +1 -0
- package/templates/project-starter/package.json +4 -4
- package/templates/project-tee-starter/package.json +4 -4
- package/templates/project-tee-starter/src/index.ts +1 -2
- package/dist/chunk-3RG5ZIWI.js +0 -10
|
@@ -0,0 +1,292 @@
|
|
|
1
|
+
import {
|
|
2
|
+
UserEnvironment,
|
|
3
|
+
createEnvFileService,
|
|
4
|
+
detectPluginContext,
|
|
5
|
+
getCliInstallTag,
|
|
6
|
+
installPlugin,
|
|
7
|
+
loadPluginModule,
|
|
8
|
+
provideLocalPluginGuidance
|
|
9
|
+
} from "./chunk-Q6M2K53X.js";
|
|
10
|
+
|
|
11
|
+
// src/commands/start/actions/agent-start.ts
|
|
12
|
+
import {
|
|
13
|
+
AgentRuntime,
|
|
14
|
+
encryptedCharacter,
|
|
15
|
+
logger as logger3,
|
|
16
|
+
stringToUuid
|
|
17
|
+
} from "@elizaos/core";
|
|
18
|
+
import { plugin as sqlPlugin } from "@elizaos/plugin-sql";
|
|
19
|
+
|
|
20
|
+
// src/commands/start/utils/config-utils.ts
|
|
21
|
+
import dotenv from "dotenv";
|
|
22
|
+
|
|
23
|
+
// src/commands/env/utils/file-operations.ts
|
|
24
|
+
import { existsSync } from "fs";
|
|
25
|
+
import path from "path";
|
|
26
|
+
async function getLocalEnvPath() {
|
|
27
|
+
const localEnvPath = path.join(process.cwd(), ".env");
|
|
28
|
+
return existsSync(localEnvPath) ? localEnvPath : null;
|
|
29
|
+
}
|
|
30
|
+
async function parseEnvFile(filePath) {
|
|
31
|
+
const service = createEnvFileService(filePath);
|
|
32
|
+
return service.read();
|
|
33
|
+
}
|
|
34
|
+
async function writeEnvFile(filePath, envVars) {
|
|
35
|
+
const service = createEnvFileService(filePath);
|
|
36
|
+
await service.write(envVars, {
|
|
37
|
+
preserveComments: true,
|
|
38
|
+
updateProcessEnv: true
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
async function resetEnvFile(filePath) {
|
|
42
|
+
try {
|
|
43
|
+
if (!existsSync(filePath)) {
|
|
44
|
+
return false;
|
|
45
|
+
}
|
|
46
|
+
const service = createEnvFileService(filePath);
|
|
47
|
+
const envVars = await service.read();
|
|
48
|
+
if (Object.keys(envVars).length === 0) {
|
|
49
|
+
return false;
|
|
50
|
+
}
|
|
51
|
+
const resetVars = Object.keys(envVars).reduce((acc, key) => {
|
|
52
|
+
acc[key] = "";
|
|
53
|
+
return acc;
|
|
54
|
+
}, {});
|
|
55
|
+
await service.write(resetVars, {
|
|
56
|
+
preserveComments: true,
|
|
57
|
+
updateProcessEnv: false
|
|
58
|
+
// Don't update process.env with empty values
|
|
59
|
+
});
|
|
60
|
+
return true;
|
|
61
|
+
} catch (error) {
|
|
62
|
+
console.error(
|
|
63
|
+
`Error resetting environment file: ${error instanceof Error ? error.message : String(error)}`
|
|
64
|
+
);
|
|
65
|
+
return false;
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
// src/commands/start/utils/config-utils.ts
|
|
70
|
+
async function loadEnvConfig() {
|
|
71
|
+
const envInfo = await UserEnvironment.getInstanceInfo();
|
|
72
|
+
if (envInfo.paths.envFilePath) {
|
|
73
|
+
dotenv.config({ path: envInfo.paths.envFilePath });
|
|
74
|
+
}
|
|
75
|
+
return process.env;
|
|
76
|
+
}
|
|
77
|
+
function hasCharacterSecrets(character) {
|
|
78
|
+
return character?.settings?.secrets && Object.keys(character.settings.secrets).length > 0;
|
|
79
|
+
}
|
|
80
|
+
function ensureCharacterSettings(character) {
|
|
81
|
+
if (!character.settings) {
|
|
82
|
+
character.settings = {};
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
async function loadLocalEnvSecrets() {
|
|
86
|
+
const envPath = await getLocalEnvPath();
|
|
87
|
+
if (!envPath) {
|
|
88
|
+
return null;
|
|
89
|
+
}
|
|
90
|
+
return await parseEnvFile(envPath);
|
|
91
|
+
}
|
|
92
|
+
async function setDefaultSecretsFromEnv(character) {
|
|
93
|
+
ensureCharacterSettings(character);
|
|
94
|
+
if (hasCharacterSecrets(character)) {
|
|
95
|
+
return false;
|
|
96
|
+
}
|
|
97
|
+
const envSecrets = await loadLocalEnvSecrets();
|
|
98
|
+
if (!envSecrets) {
|
|
99
|
+
return false;
|
|
100
|
+
}
|
|
101
|
+
character.settings.secrets = envSecrets;
|
|
102
|
+
return true;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
// src/commands/start/utils/dependency-resolver.ts
|
|
106
|
+
import { logger } from "@elizaos/core";
|
|
107
|
+
function resolvePluginDependencies(availablePlugins, isTestMode = false) {
|
|
108
|
+
const resolutionOrder = [];
|
|
109
|
+
const visited = /* @__PURE__ */ new Set();
|
|
110
|
+
const visiting = /* @__PURE__ */ new Set();
|
|
111
|
+
function visit(pluginName) {
|
|
112
|
+
if (!availablePlugins.has(pluginName)) {
|
|
113
|
+
logger.warn(`Plugin dependency "${pluginName}" not found and will be skipped.`);
|
|
114
|
+
return;
|
|
115
|
+
}
|
|
116
|
+
if (visited.has(pluginName)) return;
|
|
117
|
+
if (visiting.has(pluginName)) {
|
|
118
|
+
logger.error(`Circular dependency detected involving plugin: ${pluginName}`);
|
|
119
|
+
return;
|
|
120
|
+
}
|
|
121
|
+
visiting.add(pluginName);
|
|
122
|
+
const plugin = availablePlugins.get(pluginName);
|
|
123
|
+
if (plugin) {
|
|
124
|
+
const deps = [...plugin.dependencies || []];
|
|
125
|
+
if (isTestMode) {
|
|
126
|
+
deps.push(...plugin.testDependencies || []);
|
|
127
|
+
}
|
|
128
|
+
for (const dep of deps) {
|
|
129
|
+
visit(dep);
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
visiting.delete(pluginName);
|
|
133
|
+
visited.add(pluginName);
|
|
134
|
+
resolutionOrder.push(pluginName);
|
|
135
|
+
}
|
|
136
|
+
for (const name of availablePlugins.keys()) {
|
|
137
|
+
if (!visited.has(name)) {
|
|
138
|
+
visit(name);
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
const finalPlugins = resolutionOrder.map((name) => availablePlugins.get(name)).filter((p) => p);
|
|
142
|
+
logger.info({ plugins: finalPlugins.map((p) => p.name) }, `Final plugins being loaded:`);
|
|
143
|
+
return finalPlugins;
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
// src/commands/start/utils/plugin-utils.ts
|
|
147
|
+
import { logger as logger2 } from "@elizaos/core";
|
|
148
|
+
function isValidPluginShape(obj) {
|
|
149
|
+
if (!obj || typeof obj !== "object" || !obj.name) {
|
|
150
|
+
return false;
|
|
151
|
+
}
|
|
152
|
+
return !!(obj.init || obj.services || obj.providers || obj.actions || obj.evaluators || obj.description);
|
|
153
|
+
}
|
|
154
|
+
async function loadAndPreparePlugin(pluginName) {
|
|
155
|
+
const version = getCliInstallTag();
|
|
156
|
+
let pluginModule;
|
|
157
|
+
const context = detectPluginContext(pluginName);
|
|
158
|
+
if (context.isLocalDevelopment) {
|
|
159
|
+
try {
|
|
160
|
+
pluginModule = await loadPluginModule(pluginName);
|
|
161
|
+
if (!pluginModule) {
|
|
162
|
+
logger2.error(`Failed to load local plugin ${pluginName}.`);
|
|
163
|
+
provideLocalPluginGuidance(pluginName, context);
|
|
164
|
+
return null;
|
|
165
|
+
}
|
|
166
|
+
} catch (error) {
|
|
167
|
+
logger2.error(`Error loading local plugin ${pluginName}: ${error}`);
|
|
168
|
+
provideLocalPluginGuidance(pluginName, context);
|
|
169
|
+
return null;
|
|
170
|
+
}
|
|
171
|
+
} else {
|
|
172
|
+
try {
|
|
173
|
+
pluginModule = await loadPluginModule(pluginName);
|
|
174
|
+
if (!pluginModule) {
|
|
175
|
+
logger2.info(`Plugin ${pluginName} not available, installing...`);
|
|
176
|
+
await installPlugin(pluginName, process.cwd(), version);
|
|
177
|
+
pluginModule = await loadPluginModule(pluginName);
|
|
178
|
+
}
|
|
179
|
+
} catch (error) {
|
|
180
|
+
logger2.error(`Failed to process plugin ${pluginName}: ${error}`);
|
|
181
|
+
return null;
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
if (!pluginModule) {
|
|
185
|
+
logger2.error(`Failed to load module for plugin ${pluginName}.`);
|
|
186
|
+
return null;
|
|
187
|
+
}
|
|
188
|
+
const expectedFunctionName = `${pluginName.replace(/^@elizaos\/plugin-/, "").replace(/^@elizaos\//, "").replace(/-./g, (match) => match[1].toUpperCase())}Plugin`;
|
|
189
|
+
const exportsToCheck = [
|
|
190
|
+
pluginModule[expectedFunctionName],
|
|
191
|
+
pluginModule.default,
|
|
192
|
+
...Object.values(pluginModule)
|
|
193
|
+
];
|
|
194
|
+
for (const potentialPlugin of exportsToCheck) {
|
|
195
|
+
if (isValidPluginShape(potentialPlugin)) {
|
|
196
|
+
return potentialPlugin;
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
logger2.warn(`Could not find a valid plugin export in ${pluginName}.`);
|
|
200
|
+
return null;
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
// src/commands/start/actions/agent-start.ts
|
|
204
|
+
async function startAgent(character, server, init, plugins = [], options = {}) {
|
|
205
|
+
character.id ??= stringToUuid(character.name);
|
|
206
|
+
if (!hasCharacterSecrets(character)) {
|
|
207
|
+
await setDefaultSecretsFromEnv(character);
|
|
208
|
+
}
|
|
209
|
+
const loadedPlugins = /* @__PURE__ */ new Map();
|
|
210
|
+
const pluginsToLoad = new Set(character.plugins || []);
|
|
211
|
+
for (const p of plugins) {
|
|
212
|
+
if (typeof p === "string") {
|
|
213
|
+
pluginsToLoad.add(p);
|
|
214
|
+
} else if (isValidPluginShape(p) && !loadedPlugins.has(p.name)) {
|
|
215
|
+
loadedPlugins.set(p.name, p);
|
|
216
|
+
(p.dependencies || []).forEach((dep) => pluginsToLoad.add(dep));
|
|
217
|
+
if (options.isTestMode) {
|
|
218
|
+
(p.testDependencies || []).forEach((dep) => pluginsToLoad.add(dep));
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
const allAvailablePlugins = /* @__PURE__ */ new Map();
|
|
223
|
+
for (const p of loadedPlugins.values()) {
|
|
224
|
+
allAvailablePlugins.set(p.name, p);
|
|
225
|
+
}
|
|
226
|
+
for (const name of pluginsToLoad) {
|
|
227
|
+
if (!allAvailablePlugins.has(name)) {
|
|
228
|
+
const loaded = await loadAndPreparePlugin(name);
|
|
229
|
+
if (loaded) {
|
|
230
|
+
allAvailablePlugins.set(loaded.name, loaded);
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
let haveSql = false;
|
|
235
|
+
for (const n of allAvailablePlugins.keys()) {
|
|
236
|
+
if (n === sqlPlugin.name || n === "mysql") {
|
|
237
|
+
haveSql = true;
|
|
238
|
+
break;
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
if (!haveSql) {
|
|
242
|
+
allAvailablePlugins.set(sqlPlugin.name, sqlPlugin);
|
|
243
|
+
}
|
|
244
|
+
const finalPlugins = resolvePluginDependencies(allAvailablePlugins, options.isTestMode);
|
|
245
|
+
const runtime = new AgentRuntime({
|
|
246
|
+
character: encryptedCharacter(character),
|
|
247
|
+
plugins: finalPlugins,
|
|
248
|
+
settings: await loadEnvConfig()
|
|
249
|
+
});
|
|
250
|
+
const initWrapper = async (runtime2) => {
|
|
251
|
+
if (init) {
|
|
252
|
+
await init(runtime2);
|
|
253
|
+
}
|
|
254
|
+
};
|
|
255
|
+
await initWrapper(runtime);
|
|
256
|
+
await runtime.initialize();
|
|
257
|
+
try {
|
|
258
|
+
const migrationService = runtime.getService("database_migration");
|
|
259
|
+
if (migrationService) {
|
|
260
|
+
logger3.info("Discovering plugin schemas for dynamic migration...");
|
|
261
|
+
migrationService.discoverAndRegisterPluginSchemas(finalPlugins);
|
|
262
|
+
logger3.info("Running all plugin migrations...");
|
|
263
|
+
await migrationService.runAllPluginMigrations();
|
|
264
|
+
logger3.info("All plugin migrations completed successfully");
|
|
265
|
+
} else {
|
|
266
|
+
logger3.warn("DatabaseMigrationService not found - plugin schema migrations skipped");
|
|
267
|
+
}
|
|
268
|
+
} catch (error) {
|
|
269
|
+
logger3.error({ error }, "Failed to run plugin migrations:");
|
|
270
|
+
throw error;
|
|
271
|
+
}
|
|
272
|
+
server.registerAgent(runtime);
|
|
273
|
+
logger3.log(`Started ${runtime.character.name} as ${runtime.agentId}`);
|
|
274
|
+
return runtime;
|
|
275
|
+
}
|
|
276
|
+
async function stopAgent(runtime, server) {
|
|
277
|
+
await runtime.close();
|
|
278
|
+
server.unregisterAgent(runtime.agentId);
|
|
279
|
+
logger3.success(`Agent ${runtime.character.name} stopped successfully!`);
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
export {
|
|
283
|
+
getLocalEnvPath,
|
|
284
|
+
parseEnvFile,
|
|
285
|
+
writeEnvFile,
|
|
286
|
+
resetEnvFile,
|
|
287
|
+
loadEnvConfig,
|
|
288
|
+
setDefaultSecretsFromEnv,
|
|
289
|
+
loadAndPreparePlugin,
|
|
290
|
+
startAgent,
|
|
291
|
+
stopAgent
|
|
292
|
+
};
|