@elizaos/server 1.0.15 → 1.0.16
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.d.ts +8 -1
- package/dist/index.js +170 -21
- package/dist/index.js.map +1 -1
- package/package.json +4 -4
package/dist/index.d.ts
CHANGED
|
@@ -128,6 +128,12 @@ interface ServerOptions {
|
|
|
128
128
|
dataDir?: string;
|
|
129
129
|
postgresUrl?: string;
|
|
130
130
|
}
|
|
131
|
+
/**
|
|
132
|
+
* Determines if the web UI should be enabled based on environment variables.
|
|
133
|
+
*
|
|
134
|
+
* @returns {boolean} - Returns true if UI should be enabled, false otherwise
|
|
135
|
+
*/
|
|
136
|
+
declare function isWebUIEnabled(): boolean;
|
|
131
137
|
/**
|
|
132
138
|
* Class representing an agent server.
|
|
133
139
|
*/ /**
|
|
@@ -139,6 +145,7 @@ declare class AgentServer {
|
|
|
139
145
|
server: http.Server;
|
|
140
146
|
socketIO: Server;
|
|
141
147
|
isInitialized: boolean;
|
|
148
|
+
private isWebUIEnabled;
|
|
142
149
|
database: DatabaseAdapter;
|
|
143
150
|
startAgent: (character: Character) => Promise<IAgentRuntime>;
|
|
144
151
|
stopAgent: (runtime: IAgentRuntime) => void;
|
|
@@ -246,4 +253,4 @@ declare class AgentServer {
|
|
|
246
253
|
getServersForAgent(agentId: UUID): Promise<UUID[]>;
|
|
247
254
|
}
|
|
248
255
|
|
|
249
|
-
export { AgentServer, type CentralRootMessage, type MessageChannel, type MessageServer, type MessageServiceStructure, type ServerMiddleware, type ServerOptions, expandTildePath, hasValidRemoteUrls, jsonToCharacter, loadCharacter, loadCharacterTryPath, loadCharacters, loadCharactersFromUrl, resolvePgliteDir, tryLoadFile };
|
|
256
|
+
export { AgentServer, type CentralRootMessage, type MessageChannel, type MessageServer, type MessageServiceStructure, type ServerMiddleware, type ServerOptions, expandTildePath, hasValidRemoteUrls, isWebUIEnabled, jsonToCharacter, loadCharacter, loadCharacterTryPath, loadCharacters, loadCharactersFromUrl, resolvePgliteDir, tryLoadFile };
|
package/dist/index.js
CHANGED
|
@@ -379,9 +379,10 @@ var require_lib = __commonJS({
|
|
|
379
379
|
// src/index.ts
|
|
380
380
|
var import_cors2 = __toESM(require_lib(), 1);
|
|
381
381
|
import {
|
|
382
|
-
logger as logger29
|
|
382
|
+
logger as logger29,
|
|
383
|
+
parseBooleanFromText
|
|
383
384
|
} from "@elizaos/core";
|
|
384
|
-
import
|
|
385
|
+
import express31 from "express";
|
|
385
386
|
import helmet2 from "helmet";
|
|
386
387
|
import * as fs9 from "fs";
|
|
387
388
|
import http from "http";
|
|
@@ -392,7 +393,7 @@ import { fileURLToPath as fileURLToPath2 } from "url";
|
|
|
392
393
|
var import_cors = __toESM(require_lib(), 1);
|
|
393
394
|
import { logger as logger25, validateUuid as validateUuid21 } from "@elizaos/core";
|
|
394
395
|
import bodyParser from "body-parser";
|
|
395
|
-
import
|
|
396
|
+
import express30 from "express";
|
|
396
397
|
import helmet from "helmet";
|
|
397
398
|
import { match } from "path-to-regexp";
|
|
398
399
|
import { Server as SocketIOServer } from "socket.io";
|
|
@@ -3695,7 +3696,7 @@ function teeRouter() {
|
|
|
3695
3696
|
}
|
|
3696
3697
|
|
|
3697
3698
|
// src/api/system/index.ts
|
|
3698
|
-
import
|
|
3699
|
+
import express29 from "express";
|
|
3699
3700
|
|
|
3700
3701
|
// src/api/system/environment.ts
|
|
3701
3702
|
import { logger as logger23 } from "@elizaos/core";
|
|
@@ -3804,10 +3805,118 @@ function createEnvironmentRouter() {
|
|
|
3804
3805
|
return router;
|
|
3805
3806
|
}
|
|
3806
3807
|
|
|
3808
|
+
// src/api/system/version.ts
|
|
3809
|
+
import express28 from "express";
|
|
3810
|
+
|
|
3811
|
+
// package.json
|
|
3812
|
+
var package_default = {
|
|
3813
|
+
name: "@elizaos/server",
|
|
3814
|
+
version: "1.0.15",
|
|
3815
|
+
description: "ElizaOS Server - Core server infrastructure for ElizaOS agents",
|
|
3816
|
+
publishConfig: {
|
|
3817
|
+
access: "public",
|
|
3818
|
+
workspaces: {
|
|
3819
|
+
preserveIfPresent: true
|
|
3820
|
+
}
|
|
3821
|
+
},
|
|
3822
|
+
license: "MIT",
|
|
3823
|
+
author: {
|
|
3824
|
+
name: "elizaOS",
|
|
3825
|
+
url: "https://twitter.com/eliza_OS"
|
|
3826
|
+
},
|
|
3827
|
+
repository: {
|
|
3828
|
+
type: "git",
|
|
3829
|
+
url: "https://github.com/elizaOS/eliza.git",
|
|
3830
|
+
directory: "packages/server"
|
|
3831
|
+
},
|
|
3832
|
+
files: [
|
|
3833
|
+
"dist",
|
|
3834
|
+
"templates"
|
|
3835
|
+
],
|
|
3836
|
+
keywords: [],
|
|
3837
|
+
type: "module",
|
|
3838
|
+
exports: {
|
|
3839
|
+
".": "./dist/index.js",
|
|
3840
|
+
"./package.json": "./package.json"
|
|
3841
|
+
},
|
|
3842
|
+
scripts: {
|
|
3843
|
+
build: "tsup",
|
|
3844
|
+
"type-check": "tsc --project tsconfig.build.json --noEmit",
|
|
3845
|
+
lint: "prettier --write ./src",
|
|
3846
|
+
format: "prettier --write ./src",
|
|
3847
|
+
"format:check": "prettier --check ./src",
|
|
3848
|
+
clean: "rm -rf dist .turbo node_modules .turbo-tsconfig.json tsconfig.tsbuildinfo",
|
|
3849
|
+
test: "bun test src/**/*.test.ts",
|
|
3850
|
+
"test:unit": "bun test src/**/*.test.ts --exclude **/integration/**",
|
|
3851
|
+
"test:integration": "bun test src/__tests__/integration/**/*.test.ts",
|
|
3852
|
+
"test:coverage": "bun test --coverage",
|
|
3853
|
+
"test:watch": "bun test --watch",
|
|
3854
|
+
"test:cli": "bun test tests/commands/"
|
|
3855
|
+
},
|
|
3856
|
+
devDependencies: {
|
|
3857
|
+
"@types/node": "^24.0.1",
|
|
3858
|
+
dotenv: "^16.5.0",
|
|
3859
|
+
prettier: "3.5.3",
|
|
3860
|
+
tsup: "8.5.0",
|
|
3861
|
+
tsx: "4.19.4",
|
|
3862
|
+
typescript: "^5.5.4",
|
|
3863
|
+
which: "^4.0.0",
|
|
3864
|
+
ws: "^8.18.0"
|
|
3865
|
+
},
|
|
3866
|
+
gitHead: "d5bd5c43bfebeb7ac02f9e029f924cb6cd5c2ec7",
|
|
3867
|
+
dependencies: {
|
|
3868
|
+
"@elizaos/core": "workspace:*",
|
|
3869
|
+
"@elizaos/plugin-sql": "workspace:*",
|
|
3870
|
+
"@types/express": "^5.0.2",
|
|
3871
|
+
"@types/helmet": "^4.0.0",
|
|
3872
|
+
"@types/multer": "^1.4.13",
|
|
3873
|
+
express: "^5.1.0",
|
|
3874
|
+
"express-rate-limit": "^7.5.0",
|
|
3875
|
+
helmet: "^8.1.0",
|
|
3876
|
+
multer: "^2.0.1",
|
|
3877
|
+
"path-to-regexp": "^8.2.0",
|
|
3878
|
+
"socket.io": "^4.8.1"
|
|
3879
|
+
}
|
|
3880
|
+
};
|
|
3881
|
+
|
|
3882
|
+
// src/api/system/version.ts
|
|
3883
|
+
function getVersionInfo() {
|
|
3884
|
+
const timestamp = (/* @__PURE__ */ new Date()).toISOString();
|
|
3885
|
+
try {
|
|
3886
|
+
return {
|
|
3887
|
+
version: package_default.version,
|
|
3888
|
+
source: "server",
|
|
3889
|
+
timestamp,
|
|
3890
|
+
environment: process.env.NODE_ENV || "development",
|
|
3891
|
+
uptime: process.uptime()
|
|
3892
|
+
};
|
|
3893
|
+
} catch (error) {
|
|
3894
|
+
console.error("Error getting version info:", error);
|
|
3895
|
+
return {
|
|
3896
|
+
version: "unknown",
|
|
3897
|
+
source: "server",
|
|
3898
|
+
timestamp,
|
|
3899
|
+
environment: process.env.NODE_ENV || "development",
|
|
3900
|
+
uptime: process.uptime(),
|
|
3901
|
+
error: "Failed to retrieve version information"
|
|
3902
|
+
};
|
|
3903
|
+
}
|
|
3904
|
+
}
|
|
3905
|
+
function createVersionRouter() {
|
|
3906
|
+
const router = express28.Router();
|
|
3907
|
+
router.get("/", (_, res) => {
|
|
3908
|
+
const versionInfo = getVersionInfo();
|
|
3909
|
+
const statusCode = versionInfo.error ? 500 : 200;
|
|
3910
|
+
res.status(statusCode).json(versionInfo);
|
|
3911
|
+
});
|
|
3912
|
+
return router;
|
|
3913
|
+
}
|
|
3914
|
+
|
|
3807
3915
|
// src/api/system/index.ts
|
|
3808
3916
|
function systemRouter() {
|
|
3809
|
-
const router =
|
|
3917
|
+
const router = express29.Router();
|
|
3810
3918
|
router.use("/env", createEnvironmentRouter());
|
|
3919
|
+
router.use("/version", createVersionRouter());
|
|
3811
3920
|
return router;
|
|
3812
3921
|
}
|
|
3813
3922
|
|
|
@@ -4466,7 +4575,7 @@ function createPluginRouteHandler(agents) {
|
|
|
4466
4575
|
};
|
|
4467
4576
|
}
|
|
4468
4577
|
function createApiRouter(agents, serverInstance) {
|
|
4469
|
-
const router =
|
|
4578
|
+
const router = express30.Router();
|
|
4470
4579
|
router.use(
|
|
4471
4580
|
helmet({
|
|
4472
4581
|
// Disable CSP here - let main app handle it with environment awareness
|
|
@@ -4504,7 +4613,7 @@ function createApiRouter(agents, serverInstance) {
|
|
|
4504
4613
|
})
|
|
4505
4614
|
);
|
|
4506
4615
|
router.use(
|
|
4507
|
-
|
|
4616
|
+
express30.json({
|
|
4508
4617
|
limit: process.env.EXPRESS_MAX_PAYLOAD || "100kb"
|
|
4509
4618
|
})
|
|
4510
4619
|
);
|
|
@@ -5437,6 +5546,14 @@ function resolvePgliteDir(dir, fallbackDir) {
|
|
|
5437
5546
|
}
|
|
5438
5547
|
var __dirname2 = dirname(fileURLToPath2(import.meta.url));
|
|
5439
5548
|
var DEFAULT_SERVER_ID5 = "00000000-0000-0000-0000-000000000000";
|
|
5549
|
+
function isWebUIEnabled() {
|
|
5550
|
+
const isProduction = process.env.NODE_ENV === "production";
|
|
5551
|
+
const uiEnabledEnv = process.env.ELIZA_UI_ENABLE;
|
|
5552
|
+
if (uiEnabledEnv !== void 0 && uiEnabledEnv.trim() !== "") {
|
|
5553
|
+
return parseBooleanFromText(uiEnabledEnv);
|
|
5554
|
+
}
|
|
5555
|
+
return !isProduction;
|
|
5556
|
+
}
|
|
5440
5557
|
var AgentServer = class {
|
|
5441
5558
|
app;
|
|
5442
5559
|
agents;
|
|
@@ -5444,6 +5561,8 @@ var AgentServer = class {
|
|
|
5444
5561
|
socketIO;
|
|
5445
5562
|
isInitialized = false;
|
|
5446
5563
|
// Flag to prevent double initialization
|
|
5564
|
+
isWebUIEnabled = true;
|
|
5565
|
+
// Default to enabled until initialized
|
|
5447
5566
|
database;
|
|
5448
5567
|
startAgent;
|
|
5449
5568
|
stopAgent;
|
|
@@ -5585,7 +5704,7 @@ var AgentServer = class {
|
|
|
5585
5704
|
*/
|
|
5586
5705
|
async initializeServer(options) {
|
|
5587
5706
|
try {
|
|
5588
|
-
this.app =
|
|
5707
|
+
this.app = express31();
|
|
5589
5708
|
const isProd = process.env.NODE_ENV === "production";
|
|
5590
5709
|
logger29.debug("Setting up security headers...");
|
|
5591
5710
|
if (!isProd) {
|
|
@@ -5669,8 +5788,8 @@ var AgentServer = class {
|
|
|
5669
5788
|
})
|
|
5670
5789
|
);
|
|
5671
5790
|
this.app.use(
|
|
5672
|
-
|
|
5673
|
-
limit: process.env.EXPRESS_MAX_PAYLOAD || "
|
|
5791
|
+
express31.json({
|
|
5792
|
+
limit: process.env.EXPRESS_MAX_PAYLOAD || "2mb"
|
|
5674
5793
|
})
|
|
5675
5794
|
);
|
|
5676
5795
|
const serverAuthToken = process.env.ELIZA_SERVER_AUTH_TOKEN;
|
|
@@ -5684,6 +5803,17 @@ var AgentServer = class {
|
|
|
5684
5803
|
"Server authentication is disabled. Set ELIZA_SERVER_AUTH_TOKEN environment variable to enable."
|
|
5685
5804
|
);
|
|
5686
5805
|
}
|
|
5806
|
+
this.isWebUIEnabled = isWebUIEnabled();
|
|
5807
|
+
if (this.isWebUIEnabled) {
|
|
5808
|
+
logger29.info("Web UI enabled");
|
|
5809
|
+
} else {
|
|
5810
|
+
const uiEnabledEnv = process.env.ELIZA_UI_ENABLE;
|
|
5811
|
+
if (uiEnabledEnv !== void 0 && uiEnabledEnv.trim() !== "") {
|
|
5812
|
+
logger29.info(`Web UI disabled by environment variable (ELIZA_UI_ENABLE=${uiEnabledEnv})`);
|
|
5813
|
+
} else {
|
|
5814
|
+
logger29.info("Web UI disabled for security (production mode)");
|
|
5815
|
+
}
|
|
5816
|
+
}
|
|
5687
5817
|
const uploadsBasePath = path9.join(process.cwd(), ".eliza", "data", "uploads", "agents");
|
|
5688
5818
|
const generatedBasePath = path9.join(process.cwd(), ".eliza", "data", "generated");
|
|
5689
5819
|
fs9.mkdirSync(uploadsBasePath, { recursive: true });
|
|
@@ -5808,8 +5938,10 @@ var AgentServer = class {
|
|
|
5808
5938
|
}
|
|
5809
5939
|
}
|
|
5810
5940
|
};
|
|
5811
|
-
|
|
5812
|
-
|
|
5941
|
+
if (this.isWebUIEnabled) {
|
|
5942
|
+
const clientPath = path9.resolve(__dirname2, "../../cli/dist");
|
|
5943
|
+
this.app.use(express31.static(clientPath, staticOptions));
|
|
5944
|
+
}
|
|
5813
5945
|
const pluginRouteHandler = createPluginRouteHandler(this.agents);
|
|
5814
5946
|
this.app.use(pluginRouteHandler);
|
|
5815
5947
|
const apiRouter = createApiRouter(this.agents, this);
|
|
@@ -5846,14 +5978,20 @@ var AgentServer = class {
|
|
|
5846
5978
|
next();
|
|
5847
5979
|
}
|
|
5848
5980
|
});
|
|
5849
|
-
this.
|
|
5850
|
-
|
|
5851
|
-
|
|
5852
|
-
|
|
5853
|
-
|
|
5854
|
-
|
|
5855
|
-
|
|
5856
|
-
|
|
5981
|
+
if (this.isWebUIEnabled) {
|
|
5982
|
+
this.app.use((req, res) => {
|
|
5983
|
+
if (req.path.endsWith(".js") || req.path.includes(".js?") || req.path.match(/\/[a-zA-Z0-9_-]+-[A-Za-z0-9]{8}\.js/)) {
|
|
5984
|
+
res.setHeader("Content-Type", "application/javascript");
|
|
5985
|
+
return res.status(404).send(`// JavaScript module not found: ${req.path}`);
|
|
5986
|
+
}
|
|
5987
|
+
const cliDistPath = path9.resolve(__dirname2, "../../cli/dist");
|
|
5988
|
+
res.sendFile(path9.join(cliDistPath, "index.html"));
|
|
5989
|
+
});
|
|
5990
|
+
} else {
|
|
5991
|
+
this.app.use((_req, res) => {
|
|
5992
|
+
res.sendStatus(403);
|
|
5993
|
+
});
|
|
5994
|
+
}
|
|
5857
5995
|
this.server = http.createServer(this.app);
|
|
5858
5996
|
this.socketIO = setupSocketIO(this.server, this.agents, this);
|
|
5859
5997
|
logger29.success("AgentServer HTTP server and Socket.IO initialized");
|
|
@@ -5980,11 +6118,21 @@ var AgentServer = class {
|
|
|
5980
6118
|
logger29.debug(`Environment: ${process.env.NODE_ENV}`);
|
|
5981
6119
|
const host = process.env.SERVER_HOST || "0.0.0.0";
|
|
5982
6120
|
this.server.listen(port, host, () => {
|
|
5983
|
-
if (process.env.NODE_ENV !== "development") {
|
|
6121
|
+
if (this.isWebUIEnabled && process.env.NODE_ENV !== "development") {
|
|
5984
6122
|
console.log(
|
|
5985
6123
|
`\x1B[32mStartup successful!
|
|
5986
6124
|
Go to the dashboard at \x1B[1mhttp://localhost:${port}\x1B[22m\x1B[0m`
|
|
5987
6125
|
);
|
|
6126
|
+
} else if (!this.isWebUIEnabled) {
|
|
6127
|
+
const actualHost = host === "0.0.0.0" ? "localhost" : host;
|
|
6128
|
+
const baseUrl = `http://${actualHost}:${port}`;
|
|
6129
|
+
console.log(
|
|
6130
|
+
`\x1B[32mStartup successful!\x1B[0m
|
|
6131
|
+
\x1B[33mWeb UI disabled.\x1B[0m \x1B[32mAPI endpoints available at:\x1B[0m
|
|
6132
|
+
\x1B[1m${baseUrl}/api/server/ping\x1B[22m\x1B[0m
|
|
6133
|
+
\x1B[1m${baseUrl}/api/agents\x1B[22m\x1B[0m
|
|
6134
|
+
\x1B[1m${baseUrl}/api/messaging\x1B[22m\x1B[0m`
|
|
6135
|
+
);
|
|
5988
6136
|
}
|
|
5989
6137
|
console.log(`AgentServer is listening on port ${port}`);
|
|
5990
6138
|
logger29.success(
|
|
@@ -6190,6 +6338,7 @@ export {
|
|
|
6190
6338
|
AgentServer,
|
|
6191
6339
|
expandTildePath,
|
|
6192
6340
|
hasValidRemoteUrls,
|
|
6341
|
+
isWebUIEnabled,
|
|
6193
6342
|
jsonToCharacter,
|
|
6194
6343
|
loadCharacter,
|
|
6195
6344
|
loadCharacterTryPath,
|