@elizaos/server 1.0.15 → 1.0.17
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 +169 -25
- 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.16",
|
|
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
|
|
@@ -4503,11 +4612,6 @@ function createApiRouter(agents, serverInstance) {
|
|
|
4503
4612
|
limit: process.env.EXPRESS_MAX_PAYLOAD || "100kb"
|
|
4504
4613
|
})
|
|
4505
4614
|
);
|
|
4506
|
-
router.use(
|
|
4507
|
-
express29.json({
|
|
4508
|
-
limit: process.env.EXPRESS_MAX_PAYLOAD || "100kb"
|
|
4509
|
-
})
|
|
4510
|
-
);
|
|
4511
4615
|
router.use("/agents", agentsRouter(agents, serverInstance));
|
|
4512
4616
|
router.use("/messaging", messagingRouter(agents, serverInstance));
|
|
4513
4617
|
router.use("/memory", memoryRouter(agents, serverInstance));
|
|
@@ -5437,6 +5541,14 @@ function resolvePgliteDir(dir, fallbackDir) {
|
|
|
5437
5541
|
}
|
|
5438
5542
|
var __dirname2 = dirname(fileURLToPath2(import.meta.url));
|
|
5439
5543
|
var DEFAULT_SERVER_ID5 = "00000000-0000-0000-0000-000000000000";
|
|
5544
|
+
function isWebUIEnabled() {
|
|
5545
|
+
const isProduction = process.env.NODE_ENV === "production";
|
|
5546
|
+
const uiEnabledEnv = process.env.ELIZA_UI_ENABLE;
|
|
5547
|
+
if (uiEnabledEnv !== void 0 && uiEnabledEnv.trim() !== "") {
|
|
5548
|
+
return parseBooleanFromText(uiEnabledEnv);
|
|
5549
|
+
}
|
|
5550
|
+
return !isProduction;
|
|
5551
|
+
}
|
|
5440
5552
|
var AgentServer = class {
|
|
5441
5553
|
app;
|
|
5442
5554
|
agents;
|
|
@@ -5444,6 +5556,8 @@ var AgentServer = class {
|
|
|
5444
5556
|
socketIO;
|
|
5445
5557
|
isInitialized = false;
|
|
5446
5558
|
// Flag to prevent double initialization
|
|
5559
|
+
isWebUIEnabled = true;
|
|
5560
|
+
// Default to enabled until initialized
|
|
5447
5561
|
database;
|
|
5448
5562
|
startAgent;
|
|
5449
5563
|
stopAgent;
|
|
@@ -5585,7 +5699,7 @@ var AgentServer = class {
|
|
|
5585
5699
|
*/
|
|
5586
5700
|
async initializeServer(options) {
|
|
5587
5701
|
try {
|
|
5588
|
-
this.app =
|
|
5702
|
+
this.app = express31();
|
|
5589
5703
|
const isProd = process.env.NODE_ENV === "production";
|
|
5590
5704
|
logger29.debug("Setting up security headers...");
|
|
5591
5705
|
if (!isProd) {
|
|
@@ -5669,8 +5783,8 @@ var AgentServer = class {
|
|
|
5669
5783
|
})
|
|
5670
5784
|
);
|
|
5671
5785
|
this.app.use(
|
|
5672
|
-
|
|
5673
|
-
limit: process.env.EXPRESS_MAX_PAYLOAD || "
|
|
5786
|
+
express31.json({
|
|
5787
|
+
limit: process.env.EXPRESS_MAX_PAYLOAD || "2mb"
|
|
5674
5788
|
})
|
|
5675
5789
|
);
|
|
5676
5790
|
const serverAuthToken = process.env.ELIZA_SERVER_AUTH_TOKEN;
|
|
@@ -5684,6 +5798,17 @@ var AgentServer = class {
|
|
|
5684
5798
|
"Server authentication is disabled. Set ELIZA_SERVER_AUTH_TOKEN environment variable to enable."
|
|
5685
5799
|
);
|
|
5686
5800
|
}
|
|
5801
|
+
this.isWebUIEnabled = isWebUIEnabled();
|
|
5802
|
+
if (this.isWebUIEnabled) {
|
|
5803
|
+
logger29.info("Web UI enabled");
|
|
5804
|
+
} else {
|
|
5805
|
+
const uiEnabledEnv = process.env.ELIZA_UI_ENABLE;
|
|
5806
|
+
if (uiEnabledEnv !== void 0 && uiEnabledEnv.trim() !== "") {
|
|
5807
|
+
logger29.info(`Web UI disabled by environment variable (ELIZA_UI_ENABLE=${uiEnabledEnv})`);
|
|
5808
|
+
} else {
|
|
5809
|
+
logger29.info("Web UI disabled for security (production mode)");
|
|
5810
|
+
}
|
|
5811
|
+
}
|
|
5687
5812
|
const uploadsBasePath = path9.join(process.cwd(), ".eliza", "data", "uploads", "agents");
|
|
5688
5813
|
const generatedBasePath = path9.join(process.cwd(), ".eliza", "data", "generated");
|
|
5689
5814
|
fs9.mkdirSync(uploadsBasePath, { recursive: true });
|
|
@@ -5808,8 +5933,10 @@ var AgentServer = class {
|
|
|
5808
5933
|
}
|
|
5809
5934
|
}
|
|
5810
5935
|
};
|
|
5811
|
-
|
|
5812
|
-
|
|
5936
|
+
if (this.isWebUIEnabled) {
|
|
5937
|
+
const clientPath = path9.resolve(__dirname2, "../../cli/dist");
|
|
5938
|
+
this.app.use(express31.static(clientPath, staticOptions));
|
|
5939
|
+
}
|
|
5813
5940
|
const pluginRouteHandler = createPluginRouteHandler(this.agents);
|
|
5814
5941
|
this.app.use(pluginRouteHandler);
|
|
5815
5942
|
const apiRouter = createApiRouter(this.agents, this);
|
|
@@ -5846,14 +5973,20 @@ var AgentServer = class {
|
|
|
5846
5973
|
next();
|
|
5847
5974
|
}
|
|
5848
5975
|
});
|
|
5849
|
-
this.
|
|
5850
|
-
|
|
5851
|
-
|
|
5852
|
-
|
|
5853
|
-
|
|
5854
|
-
|
|
5855
|
-
|
|
5856
|
-
|
|
5976
|
+
if (this.isWebUIEnabled) {
|
|
5977
|
+
this.app.use((req, res) => {
|
|
5978
|
+
if (req.path.endsWith(".js") || req.path.includes(".js?") || req.path.match(/\/[a-zA-Z0-9_-]+-[A-Za-z0-9]{8}\.js/)) {
|
|
5979
|
+
res.setHeader("Content-Type", "application/javascript");
|
|
5980
|
+
return res.status(404).send(`// JavaScript module not found: ${req.path}`);
|
|
5981
|
+
}
|
|
5982
|
+
const cliDistPath = path9.resolve(__dirname2, "../../cli/dist");
|
|
5983
|
+
res.sendFile(path9.join(cliDistPath, "index.html"));
|
|
5984
|
+
});
|
|
5985
|
+
} else {
|
|
5986
|
+
this.app.use((_req, res) => {
|
|
5987
|
+
res.sendStatus(403);
|
|
5988
|
+
});
|
|
5989
|
+
}
|
|
5857
5990
|
this.server = http.createServer(this.app);
|
|
5858
5991
|
this.socketIO = setupSocketIO(this.server, this.agents, this);
|
|
5859
5992
|
logger29.success("AgentServer HTTP server and Socket.IO initialized");
|
|
@@ -5980,11 +6113,21 @@ var AgentServer = class {
|
|
|
5980
6113
|
logger29.debug(`Environment: ${process.env.NODE_ENV}`);
|
|
5981
6114
|
const host = process.env.SERVER_HOST || "0.0.0.0";
|
|
5982
6115
|
this.server.listen(port, host, () => {
|
|
5983
|
-
if (process.env.NODE_ENV !== "development") {
|
|
6116
|
+
if (this.isWebUIEnabled && process.env.NODE_ENV !== "development") {
|
|
5984
6117
|
console.log(
|
|
5985
6118
|
`\x1B[32mStartup successful!
|
|
5986
6119
|
Go to the dashboard at \x1B[1mhttp://localhost:${port}\x1B[22m\x1B[0m`
|
|
5987
6120
|
);
|
|
6121
|
+
} else if (!this.isWebUIEnabled) {
|
|
6122
|
+
const actualHost = host === "0.0.0.0" ? "localhost" : host;
|
|
6123
|
+
const baseUrl = `http://${actualHost}:${port}`;
|
|
6124
|
+
console.log(
|
|
6125
|
+
`\x1B[32mStartup successful!\x1B[0m
|
|
6126
|
+
\x1B[33mWeb UI disabled.\x1B[0m \x1B[32mAPI endpoints available at:\x1B[0m
|
|
6127
|
+
\x1B[1m${baseUrl}/api/server/ping\x1B[22m\x1B[0m
|
|
6128
|
+
\x1B[1m${baseUrl}/api/agents\x1B[22m\x1B[0m
|
|
6129
|
+
\x1B[1m${baseUrl}/api/messaging\x1B[22m\x1B[0m`
|
|
6130
|
+
);
|
|
5988
6131
|
}
|
|
5989
6132
|
console.log(`AgentServer is listening on port ${port}`);
|
|
5990
6133
|
logger29.success(
|
|
@@ -6190,6 +6333,7 @@ export {
|
|
|
6190
6333
|
AgentServer,
|
|
6191
6334
|
expandTildePath,
|
|
6192
6335
|
hasValidRemoteUrls,
|
|
6336
|
+
isWebUIEnabled,
|
|
6193
6337
|
jsonToCharacter,
|
|
6194
6338
|
loadCharacter,
|
|
6195
6339
|
loadCharacterTryPath,
|