@elizaos/server 1.5.12-alpha.2 → 1.5.13-alpha.1
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/index.js +197 -124
- package/dist/managers/PluginInstaller.d.ts +10 -0
- package/package.json +5 -5
package/dist/index.js
CHANGED
|
@@ -21934,7 +21934,7 @@ var require_src32 = __commonJS((exports) => {
|
|
|
21934
21934
|
|
|
21935
21935
|
// src/index.ts
|
|
21936
21936
|
import {
|
|
21937
|
-
logger as
|
|
21937
|
+
logger as logger32,
|
|
21938
21938
|
parseBooleanFromText,
|
|
21939
21939
|
getDatabaseDir,
|
|
21940
21940
|
getGeneratedDir as getGeneratedDir2,
|
|
@@ -27454,7 +27454,7 @@ import express30 from "express";
|
|
|
27454
27454
|
// package.json
|
|
27455
27455
|
var package_default = {
|
|
27456
27456
|
name: "@elizaos/server",
|
|
27457
|
-
version: "1.5.
|
|
27457
|
+
version: "1.5.13-alpha.1",
|
|
27458
27458
|
description: "ElizaOS Server - Core server infrastructure for ElizaOS agents",
|
|
27459
27459
|
publishConfig: {
|
|
27460
27460
|
access: "public",
|
|
@@ -44051,8 +44051,72 @@ function _init2(options = {}, getDefaultIntegrationsImpl) {
|
|
|
44051
44051
|
import sqlPlugin, { createDatabaseAdapter, DatabaseMigrationService } from "@elizaos/plugin-sql";
|
|
44052
44052
|
|
|
44053
44053
|
// src/managers/PluginLoader.ts
|
|
44054
|
+
import { logger as logger31 } from "@elizaos/core";
|
|
44055
|
+
|
|
44056
|
+
// src/managers/PluginInstaller.ts
|
|
44054
44057
|
import { logger as logger30 } from "@elizaos/core";
|
|
44055
44058
|
|
|
44059
|
+
class PluginInstaller {
|
|
44060
|
+
attempted = new Set;
|
|
44061
|
+
async tryInstall(pluginName) {
|
|
44062
|
+
try {
|
|
44063
|
+
if (!this.isAllowed()) {
|
|
44064
|
+
logger30.debug(`Auto-install disabled or not allowed in this environment. Skipping install for ${pluginName}.`);
|
|
44065
|
+
return false;
|
|
44066
|
+
}
|
|
44067
|
+
if (this.attempted.has(pluginName)) {
|
|
44068
|
+
logger30.debug(`Auto-install already attempted for ${pluginName}. Skipping.`);
|
|
44069
|
+
return false;
|
|
44070
|
+
}
|
|
44071
|
+
this.attempted.add(pluginName);
|
|
44072
|
+
try {
|
|
44073
|
+
const check = Bun.spawn(["bun", "--version"], { stdout: "pipe", stderr: "pipe" });
|
|
44074
|
+
const code = await check.exited;
|
|
44075
|
+
if (code !== 0) {
|
|
44076
|
+
logger30.warn(`Bun not available on PATH. Cannot auto-install ${pluginName}. Please run: bun add ${pluginName}`);
|
|
44077
|
+
return false;
|
|
44078
|
+
}
|
|
44079
|
+
} catch {
|
|
44080
|
+
logger30.warn(`Bun not available on PATH. Cannot auto-install ${pluginName}. Please run: bun add ${pluginName}`);
|
|
44081
|
+
return false;
|
|
44082
|
+
}
|
|
44083
|
+
logger30.info(`Attempting to auto-install missing plugin: ${pluginName}`);
|
|
44084
|
+
const install = Bun.spawn(["bun", "add", pluginName], {
|
|
44085
|
+
cwd: process.cwd(),
|
|
44086
|
+
env: process.env,
|
|
44087
|
+
stdout: "inherit",
|
|
44088
|
+
stderr: "inherit"
|
|
44089
|
+
});
|
|
44090
|
+
const exit = await install.exited;
|
|
44091
|
+
if (exit === 0) {
|
|
44092
|
+
logger30.info(`Successfully installed ${pluginName}. Retrying import...`);
|
|
44093
|
+
return true;
|
|
44094
|
+
}
|
|
44095
|
+
logger30.error(`bun add ${pluginName} failed with exit code ${exit}. Please install manually.`);
|
|
44096
|
+
return false;
|
|
44097
|
+
} catch (e) {
|
|
44098
|
+
const message = e instanceof Error ? e.message : String(e);
|
|
44099
|
+
logger30.error(`Unexpected error during auto-install of ${pluginName}: ${message}`);
|
|
44100
|
+
return false;
|
|
44101
|
+
}
|
|
44102
|
+
}
|
|
44103
|
+
isAllowed() {
|
|
44104
|
+
if (process.env.ELIZA_NO_AUTO_INSTALL === "true")
|
|
44105
|
+
return false;
|
|
44106
|
+
if (process.env.ELIZA_NO_PLUGIN_AUTO_INSTALL === "true")
|
|
44107
|
+
return false;
|
|
44108
|
+
if (process.env.CI === "true")
|
|
44109
|
+
return false;
|
|
44110
|
+
if (process.env.ELIZA_TEST_MODE === "true")
|
|
44111
|
+
return false;
|
|
44112
|
+
if (false)
|
|
44113
|
+
;
|
|
44114
|
+
return true;
|
|
44115
|
+
}
|
|
44116
|
+
}
|
|
44117
|
+
var pluginInstaller = new PluginInstaller;
|
|
44118
|
+
|
|
44119
|
+
// src/managers/PluginLoader.ts
|
|
44056
44120
|
class PluginLoader {
|
|
44057
44121
|
isValidPluginShape(obj) {
|
|
44058
44122
|
if (!obj || typeof obj !== "object" || !obj.name) {
|
|
@@ -44106,11 +44170,20 @@ class PluginLoader {
|
|
|
44106
44170
|
try {
|
|
44107
44171
|
pluginModule = await import(pluginName);
|
|
44108
44172
|
} catch (error2) {
|
|
44109
|
-
|
|
44110
|
-
|
|
44173
|
+
logger31.error(`Failed to load plugin ${pluginName}: ${error2}`);
|
|
44174
|
+
const attempted = await pluginInstaller.tryInstall(pluginName);
|
|
44175
|
+
if (!attempted) {
|
|
44176
|
+
return null;
|
|
44177
|
+
}
|
|
44178
|
+
try {
|
|
44179
|
+
pluginModule = await import(pluginName);
|
|
44180
|
+
} catch (secondError) {
|
|
44181
|
+
logger31.error(`Auto-install attempted for ${pluginName} but import still failed: ${secondError}`);
|
|
44182
|
+
return null;
|
|
44183
|
+
}
|
|
44111
44184
|
}
|
|
44112
44185
|
if (!pluginModule) {
|
|
44113
|
-
|
|
44186
|
+
logger31.error(`Failed to load module for plugin ${pluginName}.`);
|
|
44114
44187
|
return null;
|
|
44115
44188
|
}
|
|
44116
44189
|
const expectedFunctionName = `${pluginName.replace(/^@elizaos\/plugin-/, "").replace(/^@elizaos\//, "").replace(/-./g, (match3) => match3[1].toUpperCase())}Plugin`;
|
|
@@ -44130,14 +44203,14 @@ class PluginLoader {
|
|
|
44130
44203
|
return produced;
|
|
44131
44204
|
}
|
|
44132
44205
|
} catch (err) {
|
|
44133
|
-
|
|
44206
|
+
logger31.debug(`Factory export threw for ${pluginName}: ${err}`);
|
|
44134
44207
|
}
|
|
44135
44208
|
}
|
|
44136
44209
|
}
|
|
44137
|
-
|
|
44210
|
+
logger31.warn(`Could not find a valid plugin export in ${pluginName}.`);
|
|
44138
44211
|
return null;
|
|
44139
44212
|
} catch (error2) {
|
|
44140
|
-
|
|
44213
|
+
logger31.error(`Error loading plugin ${pluginName}: ${error2}`);
|
|
44141
44214
|
return null;
|
|
44142
44215
|
}
|
|
44143
44216
|
}
|
|
@@ -44147,13 +44220,13 @@ class PluginLoader {
|
|
|
44147
44220
|
const visiting = new Set;
|
|
44148
44221
|
function visit2(pluginName) {
|
|
44149
44222
|
if (!availablePlugins.has(pluginName)) {
|
|
44150
|
-
|
|
44223
|
+
logger31.warn(`Plugin dependency "${pluginName}" not found and will be skipped.`);
|
|
44151
44224
|
return;
|
|
44152
44225
|
}
|
|
44153
44226
|
if (visited.has(pluginName))
|
|
44154
44227
|
return;
|
|
44155
44228
|
if (visiting.has(pluginName)) {
|
|
44156
|
-
|
|
44229
|
+
logger31.error(`Circular dependency detected involving plugin: ${pluginName}`);
|
|
44157
44230
|
return;
|
|
44158
44231
|
}
|
|
44159
44232
|
visiting.add(pluginName);
|
|
@@ -44177,7 +44250,7 @@ class PluginLoader {
|
|
|
44177
44250
|
}
|
|
44178
44251
|
}
|
|
44179
44252
|
const finalPlugins = resolutionOrder.map((name) => availablePlugins.get(name)).filter((p) => p);
|
|
44180
|
-
|
|
44253
|
+
logger31.info({ plugins: finalPlugins.map((p) => p.name) }, `Final plugins being loaded:`);
|
|
44181
44254
|
return finalPlugins;
|
|
44182
44255
|
}
|
|
44183
44256
|
}
|
|
@@ -44376,10 +44449,10 @@ class AgentServer {
|
|
|
44376
44449
|
...runtime.character,
|
|
44377
44450
|
id: runtime.agentId
|
|
44378
44451
|
});
|
|
44379
|
-
|
|
44452
|
+
logger32.info(`Persisted agent ${runtime.character.name} (${runtime.agentId}) to database`);
|
|
44380
44453
|
}
|
|
44381
44454
|
} catch (error2) {
|
|
44382
|
-
|
|
44455
|
+
logger32.error({ error: error2 }, `Failed to persist agent ${runtime.agentId} to database`);
|
|
44383
44456
|
}
|
|
44384
44457
|
}
|
|
44385
44458
|
runtimes.push(runtime);
|
|
@@ -44407,28 +44480,28 @@ class AgentServer {
|
|
|
44407
44480
|
}
|
|
44408
44481
|
constructor() {
|
|
44409
44482
|
try {
|
|
44410
|
-
|
|
44483
|
+
logger32.debug("Initializing AgentServer (constructor)...");
|
|
44411
44484
|
this.loadCharacterTryPath = loadCharacterTryPath;
|
|
44412
44485
|
this.jsonToCharacter = jsonToCharacter;
|
|
44413
44486
|
this.registerSignalHandlers();
|
|
44414
44487
|
} catch (error2) {
|
|
44415
|
-
|
|
44488
|
+
logger32.error({ error: error2 }, "Failed to initialize AgentServer (constructor):");
|
|
44416
44489
|
throw error2;
|
|
44417
44490
|
}
|
|
44418
44491
|
}
|
|
44419
44492
|
async initialize(options) {
|
|
44420
44493
|
if (this.isInitialized) {
|
|
44421
|
-
|
|
44494
|
+
logger32.warn("AgentServer is already initialized, skipping initialization");
|
|
44422
44495
|
return;
|
|
44423
44496
|
}
|
|
44424
44497
|
try {
|
|
44425
|
-
|
|
44498
|
+
logger32.debug("Initializing AgentServer (async operations)...");
|
|
44426
44499
|
const agentDataDir = resolvePgliteDir(options?.dataDir);
|
|
44427
|
-
|
|
44500
|
+
logger32.info(`[INIT] Database Dir for SQL plugin: ${agentDataDir}`);
|
|
44428
44501
|
const dbDir = path9.dirname(agentDataDir);
|
|
44429
44502
|
if (!fs7.existsSync(dbDir)) {
|
|
44430
44503
|
fs7.mkdirSync(dbDir, { recursive: true });
|
|
44431
|
-
|
|
44504
|
+
logger32.info(`[INIT] Created database directory: ${dbDir}`);
|
|
44432
44505
|
}
|
|
44433
44506
|
const tempServerAgentId = "00000000-0000-0000-0000-000000000000";
|
|
44434
44507
|
this.database = createDatabaseAdapter({
|
|
@@ -44436,90 +44509,90 @@ class AgentServer {
|
|
|
44436
44509
|
postgresUrl: options?.postgresUrl
|
|
44437
44510
|
}, tempServerAgentId);
|
|
44438
44511
|
await this.database.init();
|
|
44439
|
-
|
|
44440
|
-
|
|
44512
|
+
logger32.success("Database initialized for server operations");
|
|
44513
|
+
logger32.info("[INIT] Running database migrations for messaging tables...");
|
|
44441
44514
|
try {
|
|
44442
44515
|
const migrationService = new DatabaseMigrationService;
|
|
44443
44516
|
const db = this.database.getDatabase();
|
|
44444
44517
|
await migrationService.initializeWithDatabase(db);
|
|
44445
44518
|
migrationService.discoverAndRegisterPluginSchemas([sqlPlugin]);
|
|
44446
44519
|
await migrationService.runAllPluginMigrations();
|
|
44447
|
-
|
|
44520
|
+
logger32.success("[INIT] Database migrations completed successfully");
|
|
44448
44521
|
} catch (migrationError) {
|
|
44449
|
-
|
|
44522
|
+
logger32.error({ error: migrationError }, "[INIT] Failed to run database migrations:");
|
|
44450
44523
|
throw new Error(`Database migration failed: ${migrationError instanceof Error ? migrationError.message : String(migrationError)}`);
|
|
44451
44524
|
}
|
|
44452
44525
|
await new Promise((resolve2) => setTimeout(resolve2, 500));
|
|
44453
|
-
|
|
44526
|
+
logger32.info("[INIT] Ensuring default server exists...");
|
|
44454
44527
|
await this.ensureDefaultServer();
|
|
44455
|
-
|
|
44456
|
-
|
|
44457
|
-
|
|
44458
|
-
|
|
44528
|
+
logger32.success("[INIT] Default server setup complete");
|
|
44529
|
+
logger32.info("[INIT] Server uses temporary adapter for migrations only");
|
|
44530
|
+
logger32.info("[INIT] Initializing ElizaOS...");
|
|
44531
|
+
logger32.debug("[INIT] ElizaOS will use agent-specific database adapters from SQL plugin");
|
|
44459
44532
|
this.elizaOS = new ElizaOS2;
|
|
44460
44533
|
this.elizaOS.enableEditableMode();
|
|
44461
44534
|
this.pluginLoader = new PluginLoader;
|
|
44462
44535
|
this.configManager = new ConfigManager;
|
|
44463
|
-
|
|
44536
|
+
logger32.success("[INIT] ElizaOS initialized");
|
|
44464
44537
|
await this.initializeServer(options);
|
|
44465
44538
|
await new Promise((resolve2) => setTimeout(resolve2, 250));
|
|
44466
44539
|
this.isInitialized = true;
|
|
44467
44540
|
} catch (error2) {
|
|
44468
|
-
|
|
44541
|
+
logger32.error({ error: error2 }, "Failed to initialize AgentServer (async operations):");
|
|
44469
44542
|
console.trace(error2);
|
|
44470
44543
|
throw error2;
|
|
44471
44544
|
}
|
|
44472
44545
|
}
|
|
44473
44546
|
async ensureDefaultServer() {
|
|
44474
44547
|
try {
|
|
44475
|
-
|
|
44548
|
+
logger32.info("[AgentServer] Checking for default server...");
|
|
44476
44549
|
const servers = await this.database.getMessageServers();
|
|
44477
|
-
|
|
44550
|
+
logger32.debug(`[AgentServer] Found ${servers.length} existing servers`);
|
|
44478
44551
|
servers.forEach((s) => {
|
|
44479
|
-
|
|
44552
|
+
logger32.debug(`[AgentServer] Existing server: ID=${s.id}, Name=${s.name}`);
|
|
44480
44553
|
});
|
|
44481
44554
|
const defaultServer = servers.find((s) => s.id === "00000000-0000-0000-0000-000000000000");
|
|
44482
44555
|
if (!defaultServer) {
|
|
44483
|
-
|
|
44556
|
+
logger32.info("[AgentServer] Creating default server with UUID 00000000-0000-0000-0000-000000000000...");
|
|
44484
44557
|
try {
|
|
44485
44558
|
await this.database.db.execute(`
|
|
44486
44559
|
INSERT INTO message_servers (id, name, source_type, created_at, updated_at)
|
|
44487
44560
|
VALUES ('00000000-0000-0000-0000-000000000000', 'Default Server', 'eliza_default', NOW(), NOW())
|
|
44488
44561
|
ON CONFLICT (id) DO NOTHING
|
|
44489
44562
|
`);
|
|
44490
|
-
|
|
44563
|
+
logger32.success("[AgentServer] Default server created via raw SQL");
|
|
44491
44564
|
const checkResult = await this.database.db.execute("SELECT id, name FROM message_servers WHERE id = '00000000-0000-0000-0000-000000000000'");
|
|
44492
|
-
|
|
44565
|
+
logger32.debug("[AgentServer] Raw SQL check result:", checkResult);
|
|
44493
44566
|
} catch (sqlError) {
|
|
44494
|
-
|
|
44567
|
+
logger32.error("[AgentServer] Raw SQL insert failed:", sqlError);
|
|
44495
44568
|
try {
|
|
44496
44569
|
const server = await this.database.createMessageServer({
|
|
44497
44570
|
id: "00000000-0000-0000-0000-000000000000",
|
|
44498
44571
|
name: "Default Server",
|
|
44499
44572
|
sourceType: "eliza_default"
|
|
44500
44573
|
});
|
|
44501
|
-
|
|
44574
|
+
logger32.success("[AgentServer] Default server created via ORM with ID:", server.id);
|
|
44502
44575
|
} catch (ormError) {
|
|
44503
|
-
|
|
44576
|
+
logger32.error("[AgentServer] Both SQL and ORM creation failed:", ormError);
|
|
44504
44577
|
throw new Error(`Failed to create default server: ${ormError.message}`);
|
|
44505
44578
|
}
|
|
44506
44579
|
}
|
|
44507
44580
|
const verifyServers = await this.database.getMessageServers();
|
|
44508
|
-
|
|
44581
|
+
logger32.debug(`[AgentServer] After creation attempt, found ${verifyServers.length} servers`);
|
|
44509
44582
|
verifyServers.forEach((s) => {
|
|
44510
|
-
|
|
44583
|
+
logger32.debug(`[AgentServer] Server after creation: ID=${s.id}, Name=${s.name}`);
|
|
44511
44584
|
});
|
|
44512
44585
|
const verifyDefault = verifyServers.find((s) => s.id === "00000000-0000-0000-0000-000000000000");
|
|
44513
44586
|
if (!verifyDefault) {
|
|
44514
44587
|
throw new Error(`Failed to create or verify default server with ID ${DEFAULT_SERVER_ID6}`);
|
|
44515
44588
|
} else {
|
|
44516
|
-
|
|
44589
|
+
logger32.success("[AgentServer] Default server creation verified successfully");
|
|
44517
44590
|
}
|
|
44518
44591
|
} else {
|
|
44519
|
-
|
|
44592
|
+
logger32.info("[AgentServer] Default server already exists with ID:", defaultServer.id);
|
|
44520
44593
|
}
|
|
44521
44594
|
} catch (error2) {
|
|
44522
|
-
|
|
44595
|
+
logger32.error({ error: error2 }, "[AgentServer] Error ensuring default server:");
|
|
44523
44596
|
throw error2;
|
|
44524
44597
|
}
|
|
44525
44598
|
}
|
|
@@ -44540,16 +44613,16 @@ class AgentServer {
|
|
|
44540
44613
|
integrations: [vercelAIIntegration({ force: sentryEnabled })],
|
|
44541
44614
|
tracesSampleRate: Number(process.env.SENTRY_TRACES_SAMPLE_RATE || 0)
|
|
44542
44615
|
});
|
|
44543
|
-
|
|
44616
|
+
logger32.info("[Sentry] Initialized Sentry for @elizaos/server");
|
|
44544
44617
|
} catch (sentryInitError) {
|
|
44545
|
-
|
|
44618
|
+
logger32.error({ error: sentryInitError }, "[Sentry] Failed to initialize Sentry");
|
|
44546
44619
|
}
|
|
44547
44620
|
}
|
|
44548
44621
|
const isProd = false;
|
|
44549
|
-
|
|
44622
|
+
logger32.debug("Setting up security headers...");
|
|
44550
44623
|
if (!isProd) {
|
|
44551
|
-
|
|
44552
|
-
|
|
44624
|
+
logger32.debug(`NODE_ENV: ${"development"}`);
|
|
44625
|
+
logger32.debug(`CSP will be: ${isProd ? "ENABLED" : "MINIMAL_DEV"}`);
|
|
44553
44626
|
}
|
|
44554
44627
|
this.app.use(helmet({
|
|
44555
44628
|
contentSecurityPolicy: isProd ? {
|
|
@@ -44597,12 +44670,12 @@ class AgentServer {
|
|
|
44597
44670
|
xssFilter: true
|
|
44598
44671
|
}));
|
|
44599
44672
|
if (options?.middlewares) {
|
|
44600
|
-
|
|
44673
|
+
logger32.debug("Applying custom middlewares...");
|
|
44601
44674
|
for (const middleware2 of options.middlewares) {
|
|
44602
44675
|
this.app.use(middleware2);
|
|
44603
44676
|
}
|
|
44604
44677
|
}
|
|
44605
|
-
|
|
44678
|
+
logger32.debug("Setting up standard middlewares...");
|
|
44606
44679
|
this.app.use(cors2({
|
|
44607
44680
|
origin: process.env.CORS_ORIGIN || true,
|
|
44608
44681
|
credentials: true,
|
|
@@ -44614,22 +44687,22 @@ class AgentServer {
|
|
|
44614
44687
|
}));
|
|
44615
44688
|
const serverAuthToken = process.env.ELIZA_SERVER_AUTH_TOKEN;
|
|
44616
44689
|
if (serverAuthToken) {
|
|
44617
|
-
|
|
44690
|
+
logger32.info("Server authentication enabled. Requires X-API-KEY header for /api routes.");
|
|
44618
44691
|
this.app.use("/api", (req, res, next) => {
|
|
44619
44692
|
apiKeyAuthMiddleware(req, res, next);
|
|
44620
44693
|
});
|
|
44621
44694
|
} else {
|
|
44622
|
-
|
|
44695
|
+
logger32.warn("Server authentication is disabled. Set ELIZA_SERVER_AUTH_TOKEN environment variable to enable.");
|
|
44623
44696
|
}
|
|
44624
44697
|
this.isWebUIEnabled = isWebUIEnabled();
|
|
44625
44698
|
if (this.isWebUIEnabled) {
|
|
44626
|
-
|
|
44699
|
+
logger32.info("Web UI enabled");
|
|
44627
44700
|
} else {
|
|
44628
44701
|
const uiEnabledEnv = process.env.ELIZA_UI_ENABLE;
|
|
44629
44702
|
if (uiEnabledEnv !== undefined && uiEnabledEnv.trim() !== "") {
|
|
44630
|
-
|
|
44703
|
+
logger32.info(`Web UI disabled by environment variable (ELIZA_UI_ENABLE=${uiEnabledEnv})`);
|
|
44631
44704
|
} else {
|
|
44632
|
-
|
|
44705
|
+
logger32.info("Web UI disabled for security (production mode)");
|
|
44633
44706
|
}
|
|
44634
44707
|
}
|
|
44635
44708
|
const uploadsBasePath = getUploadsAgentsDir4();
|
|
@@ -44658,13 +44731,13 @@ class AgentServer {
|
|
|
44658
44731
|
res.sendFile(sanitizedFilename, { root: agentUploadsPath }, (err) => {
|
|
44659
44732
|
if (err) {
|
|
44660
44733
|
if (err.message === "Request aborted") {
|
|
44661
|
-
|
|
44734
|
+
logger32.warn(`[MEDIA] Download aborted: ${req.originalUrl}`);
|
|
44662
44735
|
} else if (!res.headersSent) {
|
|
44663
|
-
|
|
44736
|
+
logger32.warn(`[MEDIA] File not found: ${agentUploadsPath}/${sanitizedFilename}`);
|
|
44664
44737
|
res.status(404).json({ error: "File not found" });
|
|
44665
44738
|
}
|
|
44666
44739
|
} else {
|
|
44667
|
-
|
|
44740
|
+
logger32.debug(`[MEDIA] Successfully served: ${sanitizedFilename}`);
|
|
44668
44741
|
}
|
|
44669
44742
|
});
|
|
44670
44743
|
});
|
|
@@ -44719,12 +44792,12 @@ class AgentServer {
|
|
|
44719
44792
|
}
|
|
44720
44793
|
res.sendFile(filePath, (err) => {
|
|
44721
44794
|
if (err) {
|
|
44722
|
-
|
|
44795
|
+
logger32.warn({ err, filePath }, `[STATIC] Channel media file not found: ${filePath}`);
|
|
44723
44796
|
if (!res.headersSent) {
|
|
44724
44797
|
res.status(404).json({ error: "File not found" });
|
|
44725
44798
|
}
|
|
44726
44799
|
} else {
|
|
44727
|
-
|
|
44800
|
+
logger32.debug(`[STATIC] Served channel media file: ${filePath}`);
|
|
44728
44801
|
}
|
|
44729
44802
|
});
|
|
44730
44803
|
});
|
|
@@ -44835,29 +44908,29 @@ class AgentServer {
|
|
|
44835
44908
|
})()
|
|
44836
44909
|
].filter(Boolean)
|
|
44837
44910
|
].filter(Boolean);
|
|
44838
|
-
|
|
44839
|
-
|
|
44840
|
-
|
|
44911
|
+
logger32.debug(`[STATIC] process.argv[0]: ${process.argv[0]}`);
|
|
44912
|
+
logger32.debug(`[STATIC] process.argv[1]: ${process.argv[1]}`);
|
|
44913
|
+
logger32.debug(`[STATIC] __dirname: ${__dirname3}`);
|
|
44841
44914
|
for (const possiblePath of possiblePaths) {
|
|
44842
44915
|
if (possiblePath && existsSync5(path9.join(possiblePath, "index.html"))) {
|
|
44843
44916
|
clientPath = possiblePath;
|
|
44844
|
-
|
|
44917
|
+
logger32.info(`[STATIC] Found client files at: ${clientPath}`);
|
|
44845
44918
|
break;
|
|
44846
44919
|
}
|
|
44847
44920
|
}
|
|
44848
44921
|
if (clientPath) {
|
|
44849
44922
|
this.clientPath = clientPath;
|
|
44850
44923
|
this.app.use(express33.static(clientPath, staticOptions));
|
|
44851
|
-
|
|
44924
|
+
logger32.info(`[STATIC] Serving static files from: ${clientPath}`);
|
|
44852
44925
|
} else {
|
|
44853
|
-
|
|
44926
|
+
logger32.warn("[STATIC] Client dist path not found. Searched locations:");
|
|
44854
44927
|
possiblePaths.forEach((p) => {
|
|
44855
44928
|
if (p)
|
|
44856
|
-
|
|
44929
|
+
logger32.warn(`[STATIC] - ${p}`);
|
|
44857
44930
|
});
|
|
44858
|
-
|
|
44859
|
-
|
|
44860
|
-
|
|
44931
|
+
logger32.warn("[STATIC] The web UI will not be available.");
|
|
44932
|
+
logger32.warn("[STATIC] To fix this, ensure the client is built: cd packages/client && bun run build");
|
|
44933
|
+
logger32.warn("[STATIC] Then rebuild the server: cd packages/server && bun run build");
|
|
44861
44934
|
}
|
|
44862
44935
|
}
|
|
44863
44936
|
const pluginRouteHandler = createPluginRouteHandler(this.elizaOS);
|
|
@@ -44865,7 +44938,7 @@ class AgentServer {
|
|
|
44865
44938
|
const apiRouter = createApiRouter(this.elizaOS, this);
|
|
44866
44939
|
this.app.use("/api", (req, _res, next) => {
|
|
44867
44940
|
if (req.path !== "/ping") {
|
|
44868
|
-
|
|
44941
|
+
logger32.debug(`API request: ${req.method} ${req.path}`);
|
|
44869
44942
|
}
|
|
44870
44943
|
next();
|
|
44871
44944
|
}, apiRouter, (err, req, res, _next) => {
|
|
@@ -44880,7 +44953,7 @@ class AgentServer {
|
|
|
44880
44953
|
return scope;
|
|
44881
44954
|
});
|
|
44882
44955
|
}
|
|
44883
|
-
|
|
44956
|
+
logger32.error({ err }, `API error: ${req.method} ${req.path}`);
|
|
44884
44957
|
res.status(500).json({
|
|
44885
44958
|
success: false,
|
|
44886
44959
|
error: {
|
|
@@ -44930,27 +45003,27 @@ class AgentServer {
|
|
|
44930
45003
|
if (resolvedClientPath) {
|
|
44931
45004
|
const indexFilePath = path9.join(resolvedClientPath, "index.html");
|
|
44932
45005
|
if (!existsSync5(indexFilePath)) {
|
|
44933
|
-
|
|
44934
|
-
|
|
45006
|
+
logger32.error(`[STATIC] index.html not found at expected path: ${indexFilePath}`);
|
|
45007
|
+
logger32.error(`[STATIC] Client path was: ${resolvedClientPath}`);
|
|
44935
45008
|
res.status(404).send("Client application not found");
|
|
44936
45009
|
return;
|
|
44937
45010
|
}
|
|
44938
45011
|
res.sendFile("index.html", { root: resolvedClientPath }, (err) => {
|
|
44939
45012
|
if (err) {
|
|
44940
|
-
|
|
44941
|
-
|
|
44942
|
-
|
|
44943
|
-
|
|
45013
|
+
logger32.warn(`[STATIC] Failed to serve index.html: ${err.message}`);
|
|
45014
|
+
logger32.warn(`[STATIC] Attempted root: ${resolvedClientPath}`);
|
|
45015
|
+
logger32.warn(`[STATIC] Full path was: ${indexFilePath}`);
|
|
45016
|
+
logger32.warn(`[STATIC] Error code: ${err.code || "unknown"}`);
|
|
44944
45017
|
if (!res.headersSent) {
|
|
44945
45018
|
res.status(404).send("Client application not found");
|
|
44946
45019
|
}
|
|
44947
45020
|
} else {
|
|
44948
|
-
|
|
45021
|
+
logger32.debug(`[STATIC] Successfully served index.html for route: ${req.path}`);
|
|
44949
45022
|
}
|
|
44950
45023
|
});
|
|
44951
45024
|
} else {
|
|
44952
|
-
|
|
44953
|
-
|
|
45025
|
+
logger32.warn("[STATIC] Client dist path not found in SPA fallback");
|
|
45026
|
+
logger32.warn("[STATIC] Neither local nor instance clientPath variables are set");
|
|
44954
45027
|
res.status(404).send("Client application not found");
|
|
44955
45028
|
}
|
|
44956
45029
|
});
|
|
@@ -44961,9 +45034,9 @@ class AgentServer {
|
|
|
44961
45034
|
}
|
|
44962
45035
|
this.server = http4.createServer(this.app);
|
|
44963
45036
|
this.socketIO = setupSocketIO(this.server, this.elizaOS, this);
|
|
44964
|
-
|
|
45037
|
+
logger32.success("AgentServer HTTP server and Socket.IO initialized");
|
|
44965
45038
|
} catch (error2) {
|
|
44966
|
-
|
|
45039
|
+
logger32.error({ error: error2 }, "Failed to complete server initialization:");
|
|
44967
45040
|
throw error2;
|
|
44968
45041
|
}
|
|
44969
45042
|
}
|
|
@@ -44978,44 +45051,44 @@ class AgentServer {
|
|
|
44978
45051
|
if (!runtime.character) {
|
|
44979
45052
|
throw new Error("Runtime missing character configuration");
|
|
44980
45053
|
}
|
|
44981
|
-
|
|
45054
|
+
logger32.debug(`Agent ${runtime.character.name} (${runtime.agentId}) registered`);
|
|
44982
45055
|
try {
|
|
44983
45056
|
if (messageBusConnectorPlugin) {
|
|
44984
45057
|
await runtime.registerPlugin(messageBusConnectorPlugin);
|
|
44985
|
-
|
|
45058
|
+
logger32.info(`[AgentServer] Automatically registered MessageBusConnector for agent ${runtime.character.name}`);
|
|
44986
45059
|
} else {
|
|
44987
|
-
|
|
45060
|
+
logger32.error(`[AgentServer] CRITICAL: MessageBusConnector plugin definition not found.`);
|
|
44988
45061
|
}
|
|
44989
45062
|
} catch (e) {
|
|
44990
|
-
|
|
45063
|
+
logger32.error({ error: e }, `[AgentServer] CRITICAL: Failed to register MessageBusConnector for agent ${runtime.character.name}`);
|
|
44991
45064
|
}
|
|
44992
45065
|
const teePlugin = runtime.plugins.find((p) => p.name === "phala-tee-plugin");
|
|
44993
45066
|
if (teePlugin) {
|
|
44994
|
-
|
|
45067
|
+
logger32.debug(`Found TEE plugin for agent ${runtime.agentId}`);
|
|
44995
45068
|
if (teePlugin.providers) {
|
|
44996
45069
|
for (const provider of teePlugin.providers) {
|
|
44997
45070
|
runtime.registerProvider(provider);
|
|
44998
|
-
|
|
45071
|
+
logger32.debug(`Registered TEE provider: ${provider.name}`);
|
|
44999
45072
|
}
|
|
45000
45073
|
}
|
|
45001
45074
|
if (teePlugin.actions) {
|
|
45002
45075
|
for (const action of teePlugin.actions) {
|
|
45003
45076
|
runtime.registerAction(action);
|
|
45004
|
-
|
|
45077
|
+
logger32.debug(`Registered TEE action: ${action.name}`);
|
|
45005
45078
|
}
|
|
45006
45079
|
}
|
|
45007
45080
|
}
|
|
45008
|
-
|
|
45081
|
+
logger32.success(`Successfully registered agent ${runtime.character.name} (${runtime.agentId}) with core services.`);
|
|
45009
45082
|
await this.addAgentToServer(DEFAULT_SERVER_ID6, runtime.agentId);
|
|
45010
|
-
|
|
45083
|
+
logger32.info(`[AgentServer] Auto-associated agent ${runtime.character.name} with server ID: ${DEFAULT_SERVER_ID6}`);
|
|
45011
45084
|
} catch (error2) {
|
|
45012
|
-
|
|
45085
|
+
logger32.error({ error: error2 }, "Failed to register agent:");
|
|
45013
45086
|
throw error2;
|
|
45014
45087
|
}
|
|
45015
45088
|
}
|
|
45016
45089
|
async unregisterAgent(agentId) {
|
|
45017
45090
|
if (!agentId) {
|
|
45018
|
-
|
|
45091
|
+
logger32.warn("[AGENT UNREGISTER] Attempted to unregister undefined or invalid agent runtime");
|
|
45019
45092
|
return;
|
|
45020
45093
|
}
|
|
45021
45094
|
try {
|
|
@@ -45023,19 +45096,19 @@ class AgentServer {
|
|
|
45023
45096
|
if (agent) {
|
|
45024
45097
|
try {
|
|
45025
45098
|
agent.stop().catch((stopError) => {
|
|
45026
|
-
|
|
45099
|
+
logger32.error({ error: stopError, agentId }, `[AGENT UNREGISTER] Error stopping agent services for ${agentId}:`);
|
|
45027
45100
|
});
|
|
45028
|
-
|
|
45101
|
+
logger32.debug(`[AGENT UNREGISTER] Stopping services for agent ${agentId}`);
|
|
45029
45102
|
} catch (stopError) {
|
|
45030
|
-
|
|
45103
|
+
logger32.error({ error: stopError, agentId }, `[AGENT UNREGISTER] Error initiating stop for agent ${agentId}:`);
|
|
45031
45104
|
}
|
|
45032
45105
|
}
|
|
45033
45106
|
if (this.elizaOS) {
|
|
45034
45107
|
await this.elizaOS.deleteAgents([agentId]);
|
|
45035
45108
|
}
|
|
45036
|
-
|
|
45109
|
+
logger32.debug(`Agent ${agentId} unregistered`);
|
|
45037
45110
|
} catch (error2) {
|
|
45038
|
-
|
|
45111
|
+
logger32.error({ error: error2, agentId }, `Error removing agent ${agentId}:`);
|
|
45039
45112
|
}
|
|
45040
45113
|
}
|
|
45041
45114
|
registerMiddleware(middleware2) {
|
|
@@ -45047,9 +45120,9 @@ class AgentServer {
|
|
|
45047
45120
|
if (!port || typeof port !== "number") {
|
|
45048
45121
|
throw new Error(`Invalid port number: ${port}`);
|
|
45049
45122
|
}
|
|
45050
|
-
|
|
45051
|
-
|
|
45052
|
-
|
|
45123
|
+
logger32.debug(`Starting server on port ${port}...`);
|
|
45124
|
+
logger32.debug(`Current agents count: ${this.elizaOS?.getAgents().length || 0}`);
|
|
45125
|
+
logger32.debug(`Environment: ${"development"}`);
|
|
45053
45126
|
const host = process.env.SERVER_HOST || "0.0.0.0";
|
|
45054
45127
|
this.server.listen(port, host, () => {
|
|
45055
45128
|
if (this.isWebUIEnabled && false) {} else if (!this.isWebUIEnabled) {
|
|
@@ -45062,26 +45135,26 @@ class AgentServer {
|
|
|
45062
45135
|
` + ` \x1B[1m${baseUrl}/api/messaging\x1B[22m\x1B[0m`);
|
|
45063
45136
|
}
|
|
45064
45137
|
console.log(`AgentServer is listening on port ${port}`);
|
|
45065
|
-
|
|
45138
|
+
logger32.success(`REST API bound to ${host}:${port}. If running locally, access it at http://localhost:${port}.`);
|
|
45066
45139
|
const agents = this.elizaOS?.getAgents() || [];
|
|
45067
|
-
|
|
45140
|
+
logger32.debug(`Active agents: ${agents.length}`);
|
|
45068
45141
|
agents.forEach((agent) => {
|
|
45069
|
-
|
|
45142
|
+
logger32.debug(`- Agent ${agent.agentId}: ${agent.character.name}`);
|
|
45070
45143
|
});
|
|
45071
45144
|
resolve2();
|
|
45072
45145
|
}).on("error", (error2) => {
|
|
45073
|
-
|
|
45146
|
+
logger32.error({ error: error2, host, port }, `Failed to bind server to ${host}:${port}:`);
|
|
45074
45147
|
if (error2.code === "EADDRINUSE") {
|
|
45075
|
-
|
|
45148
|
+
logger32.error(`Port ${port} is already in use. Please try a different port or stop the process using that port.`);
|
|
45076
45149
|
} else if (error2.code === "EACCES") {
|
|
45077
|
-
|
|
45150
|
+
logger32.error(`Permission denied to bind to port ${port}. Try using a port above 1024 or running with appropriate permissions.`);
|
|
45078
45151
|
} else if (error2.code === "EADDRNOTAVAIL") {
|
|
45079
|
-
|
|
45152
|
+
logger32.error(`Cannot bind to ${host}:${port} - address not available. Check if the host address is correct.`);
|
|
45080
45153
|
}
|
|
45081
45154
|
reject(error2);
|
|
45082
45155
|
});
|
|
45083
45156
|
} catch (error2) {
|
|
45084
|
-
|
|
45157
|
+
logger32.error({ error: error2 }, "Failed to start server:");
|
|
45085
45158
|
reject(error2);
|
|
45086
45159
|
}
|
|
45087
45160
|
});
|
|
@@ -45089,7 +45162,7 @@ class AgentServer {
|
|
|
45089
45162
|
async stop() {
|
|
45090
45163
|
if (this.server) {
|
|
45091
45164
|
this.server.close(() => {
|
|
45092
|
-
|
|
45165
|
+
logger32.success("Server stopped");
|
|
45093
45166
|
});
|
|
45094
45167
|
}
|
|
45095
45168
|
}
|
|
@@ -45136,7 +45209,7 @@ class AgentServer {
|
|
|
45136
45209
|
for (const message of messages) {
|
|
45137
45210
|
await this.database.deleteMessage(message.id);
|
|
45138
45211
|
}
|
|
45139
|
-
|
|
45212
|
+
logger32.info(`[AgentServer] Cleared all messages for central channel: ${channelId}`);
|
|
45140
45213
|
}
|
|
45141
45214
|
async findOrCreateCentralDmChannel(user1Id, user2Id, messageServerId) {
|
|
45142
45215
|
return this.database.findOrCreateDmChannel(user1Id, user2Id, messageServerId);
|
|
@@ -45159,7 +45232,7 @@ class AgentServer {
|
|
|
45159
45232
|
metadata: createdMessage.metadata
|
|
45160
45233
|
};
|
|
45161
45234
|
bus_default.emit("new_message", messageForBus);
|
|
45162
|
-
|
|
45235
|
+
logger32.info(`[AgentServer] Published message ${createdMessage.id} to internal message bus`);
|
|
45163
45236
|
}
|
|
45164
45237
|
return createdMessage;
|
|
45165
45238
|
}
|
|
@@ -45170,7 +45243,7 @@ class AgentServer {
|
|
|
45170
45243
|
return this.database.updateMessage(messageId, patch);
|
|
45171
45244
|
}
|
|
45172
45245
|
async removeParticipantFromChannel() {
|
|
45173
|
-
|
|
45246
|
+
logger32.warn(`[AgentServer] Remove participant operation not directly supported in database adapter`);
|
|
45174
45247
|
}
|
|
45175
45248
|
async addAgentToServer(serverId, agentId) {
|
|
45176
45249
|
const server = await this.getServerById(serverId);
|
|
@@ -45198,32 +45271,32 @@ class AgentServer {
|
|
|
45198
45271
|
}
|
|
45199
45272
|
registerSignalHandlers() {
|
|
45200
45273
|
const gracefulShutdown = async () => {
|
|
45201
|
-
|
|
45202
|
-
|
|
45274
|
+
logger32.info("Received shutdown signal, initiating graceful shutdown...");
|
|
45275
|
+
logger32.debug("Stopping all agents...");
|
|
45203
45276
|
const agents = this.elizaOS?.getAgents() || [];
|
|
45204
45277
|
for (const agent of agents) {
|
|
45205
45278
|
try {
|
|
45206
45279
|
await agent.stop();
|
|
45207
|
-
|
|
45280
|
+
logger32.debug(`Stopped agent ${agent.agentId}`);
|
|
45208
45281
|
} catch (error2) {
|
|
45209
|
-
|
|
45282
|
+
logger32.error({ error: error2, agentId: agent.agentId }, `Error stopping agent ${agent.agentId}:`);
|
|
45210
45283
|
}
|
|
45211
45284
|
}
|
|
45212
45285
|
if (this.database) {
|
|
45213
45286
|
try {
|
|
45214
45287
|
await this.database.close();
|
|
45215
|
-
|
|
45288
|
+
logger32.info("Database closed.");
|
|
45216
45289
|
} catch (error2) {
|
|
45217
|
-
|
|
45290
|
+
logger32.error({ error: error2 }, "Error closing database:");
|
|
45218
45291
|
}
|
|
45219
45292
|
}
|
|
45220
45293
|
if (this.server) {
|
|
45221
45294
|
this.server.close(() => {
|
|
45222
|
-
|
|
45295
|
+
logger32.success("Server closed successfully");
|
|
45223
45296
|
process.exit(0);
|
|
45224
45297
|
});
|
|
45225
45298
|
setTimeout(() => {
|
|
45226
|
-
|
|
45299
|
+
logger32.error("Could not close connections in time, forcing shutdown");
|
|
45227
45300
|
process.exit(1);
|
|
45228
45301
|
}, 5000);
|
|
45229
45302
|
} else {
|
|
@@ -45232,7 +45305,7 @@ class AgentServer {
|
|
|
45232
45305
|
};
|
|
45233
45306
|
process.on("SIGTERM", gracefulShutdown);
|
|
45234
45307
|
process.on("SIGINT", gracefulShutdown);
|
|
45235
|
-
|
|
45308
|
+
logger32.debug("Shutdown handlers registered");
|
|
45236
45309
|
}
|
|
45237
45310
|
}
|
|
45238
45311
|
export {
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Handles on-demand plugin installation using Bun.
|
|
3
|
+
* Provides environment guards and single-attempt tracking per process.
|
|
4
|
+
*/
|
|
5
|
+
export declare class PluginInstaller {
|
|
6
|
+
private attempted;
|
|
7
|
+
tryInstall(pluginName: string): Promise<boolean>;
|
|
8
|
+
private isAllowed;
|
|
9
|
+
}
|
|
10
|
+
export declare const pluginInstaller: PluginInstaller;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@elizaos/server",
|
|
3
|
-
"version": "1.5.
|
|
3
|
+
"version": "1.5.13-alpha.1",
|
|
4
4
|
"description": "ElizaOS Server - Core server infrastructure for ElizaOS agents",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public",
|
|
@@ -44,7 +44,7 @@
|
|
|
44
44
|
"dev": "bun run build.ts --watch"
|
|
45
45
|
},
|
|
46
46
|
"devDependencies": {
|
|
47
|
-
"@elizaos/client": "1.5.
|
|
47
|
+
"@elizaos/client": "1.5.13-alpha.1",
|
|
48
48
|
"@types/node": "^24.0.1",
|
|
49
49
|
"prettier": "3.5.3",
|
|
50
50
|
"tsx": "4.19.4",
|
|
@@ -52,10 +52,10 @@
|
|
|
52
52
|
"which": "^4.0.0",
|
|
53
53
|
"ws": "^8.18.0"
|
|
54
54
|
},
|
|
55
|
-
"gitHead": "
|
|
55
|
+
"gitHead": "680c57c7696fa53f783083c5fd2f2ffdafc6a3d6",
|
|
56
56
|
"dependencies": {
|
|
57
|
-
"@elizaos/core": "1.5.
|
|
58
|
-
"@elizaos/plugin-sql": "1.5.
|
|
57
|
+
"@elizaos/core": "1.5.13-alpha.1",
|
|
58
|
+
"@elizaos/plugin-sql": "1.5.13-alpha.1",
|
|
59
59
|
"@sentry/node": "^10.11.0",
|
|
60
60
|
"@types/express": "^5.0.2",
|
|
61
61
|
"@types/helmet": "^4.0.0",
|