@elizaos/server 1.1.3 → 1.1.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/index.js +97 -47
- package/dist/index.js.map +1 -1
- package/package.json +4 -4
package/dist/index.js
CHANGED
|
@@ -392,6 +392,7 @@ import express31 from "express";
|
|
|
392
392
|
import helmet2 from "helmet";
|
|
393
393
|
import * as fs9 from "fs";
|
|
394
394
|
import http from "http";
|
|
395
|
+
import os2 from "os";
|
|
395
396
|
import path9, { basename, dirname, extname, join } from "path";
|
|
396
397
|
import { fileURLToPath as fileURLToPath2 } from "url";
|
|
397
398
|
|
|
@@ -3816,7 +3817,7 @@ import express28 from "express";
|
|
|
3816
3817
|
// package.json
|
|
3817
3818
|
var package_default = {
|
|
3818
3819
|
name: "@elizaos/server",
|
|
3819
|
-
version: "1.1.
|
|
3820
|
+
version: "1.1.5",
|
|
3820
3821
|
description: "ElizaOS Server - Core server infrastructure for ElizaOS agents",
|
|
3821
3822
|
publishConfig: {
|
|
3822
3823
|
access: "public",
|
|
@@ -3868,10 +3869,10 @@ var package_default = {
|
|
|
3868
3869
|
which: "^4.0.0",
|
|
3869
3870
|
ws: "^8.18.0"
|
|
3870
3871
|
},
|
|
3871
|
-
gitHead: "
|
|
3872
|
+
gitHead: "4d7e96cd1335e2764cc913b40d31abe18a6c8400",
|
|
3872
3873
|
dependencies: {
|
|
3873
|
-
"@elizaos/core": "1.1.
|
|
3874
|
-
"@elizaos/plugin-sql": "1.1.
|
|
3874
|
+
"@elizaos/core": "1.1.5",
|
|
3875
|
+
"@elizaos/plugin-sql": "1.1.5",
|
|
3875
3876
|
"@types/express": "^5.0.2",
|
|
3876
3877
|
"@types/helmet": "^4.0.0",
|
|
3877
3878
|
"@types/multer": "^1.4.13",
|
|
@@ -4393,6 +4394,11 @@ function createPluginRouteHandler(agents) {
|
|
|
4393
4394
|
if (req.path.startsWith("/api/messages/")) {
|
|
4394
4395
|
return next();
|
|
4395
4396
|
}
|
|
4397
|
+
const clientRoutePattern = /^\/(chat|settings|agents|profile|dashboard|login|register|admin|home|about)\b/i;
|
|
4398
|
+
if (clientRoutePattern.test(req.path)) {
|
|
4399
|
+
logger25.debug(`Skipping client-side route in plugin handler: ${req.path}`);
|
|
4400
|
+
return next();
|
|
4401
|
+
}
|
|
4396
4402
|
if (req.path.endsWith(".js") || req.path.includes(".js?") || req.path.match(/index-[A-Za-z0-9]{8}\.js/)) {
|
|
4397
4403
|
logger25.debug(`JavaScript request in plugin handler: ${req.method} ${req.path}`);
|
|
4398
4404
|
res.setHeader("Content-Type", "application/javascript");
|
|
@@ -4494,25 +4500,33 @@ function createPluginRouteHandler(agents) {
|
|
|
4494
4500
|
logger25.warn(
|
|
4495
4501
|
`Agent ID ${agentIdFromQuery} provided in query, but agent runtime not found. Path: ${reqPath}.`
|
|
4496
4502
|
);
|
|
4497
|
-
|
|
4503
|
+
if (reqPath.startsWith("/api/")) {
|
|
4504
|
+
res.status(404).json({
|
|
4505
|
+
success: false,
|
|
4506
|
+
error: {
|
|
4507
|
+
message: "Agent not found",
|
|
4508
|
+
code: "AGENT_NOT_FOUND"
|
|
4509
|
+
}
|
|
4510
|
+
});
|
|
4511
|
+
return;
|
|
4512
|
+
} else {
|
|
4513
|
+
return next();
|
|
4514
|
+
}
|
|
4515
|
+
}
|
|
4516
|
+
} else if (agentIdFromQuery && !validateUuid21(agentIdFromQuery)) {
|
|
4517
|
+
logger25.warn(`Invalid Agent ID format in query: ${agentIdFromQuery}. Path: ${reqPath}.`);
|
|
4518
|
+
if (reqPath.startsWith("/api/")) {
|
|
4519
|
+
res.status(400).json({
|
|
4498
4520
|
success: false,
|
|
4499
4521
|
error: {
|
|
4500
|
-
message: "
|
|
4501
|
-
code: "
|
|
4522
|
+
message: "Invalid agent ID format",
|
|
4523
|
+
code: "INVALID_AGENT_ID"
|
|
4502
4524
|
}
|
|
4503
4525
|
});
|
|
4504
4526
|
return;
|
|
4527
|
+
} else {
|
|
4528
|
+
return next();
|
|
4505
4529
|
}
|
|
4506
|
-
} else if (agentIdFromQuery && !validateUuid21(agentIdFromQuery)) {
|
|
4507
|
-
logger25.warn(`Invalid Agent ID format in query: ${agentIdFromQuery}. Path: ${reqPath}.`);
|
|
4508
|
-
res.status(400).json({
|
|
4509
|
-
success: false,
|
|
4510
|
-
error: {
|
|
4511
|
-
message: "Invalid agent ID format",
|
|
4512
|
-
code: "INVALID_AGENT_ID"
|
|
4513
|
-
}
|
|
4514
|
-
});
|
|
4515
|
-
return;
|
|
4516
4530
|
} else {
|
|
4517
4531
|
logger25.debug(`No valid agentId in query. Trying global match for path: ${reqPath}`);
|
|
4518
4532
|
for (const [_, runtime] of agents) {
|
|
@@ -5929,11 +5943,12 @@ var AgentServer = class {
|
|
|
5929
5943
|
}
|
|
5930
5944
|
}
|
|
5931
5945
|
};
|
|
5946
|
+
let clientPath = null;
|
|
5932
5947
|
if (this.isWebUIEnabled) {
|
|
5933
5948
|
const possiblePaths = [
|
|
5934
|
-
// Development: relative to server package
|
|
5949
|
+
// Development: relative to server package (monorepo)
|
|
5935
5950
|
path9.resolve(__dirname2, "../../cli/dist"),
|
|
5936
|
-
// Production: using require.resolve to find CLI package
|
|
5951
|
+
// Production: using require.resolve to find CLI package (if installed as dependency)
|
|
5937
5952
|
(() => {
|
|
5938
5953
|
try {
|
|
5939
5954
|
return path9.resolve(
|
|
@@ -5943,19 +5958,76 @@ var AgentServer = class {
|
|
|
5943
5958
|
} catch {
|
|
5944
5959
|
return null;
|
|
5945
5960
|
}
|
|
5946
|
-
})()
|
|
5961
|
+
})(),
|
|
5962
|
+
// Global bun install: check global node_modules locations
|
|
5963
|
+
(() => {
|
|
5964
|
+
try {
|
|
5965
|
+
const { execSync } = __require("child_process");
|
|
5966
|
+
const bunGlobalPath = path9.join(
|
|
5967
|
+
os2.homedir(),
|
|
5968
|
+
".bun/install/global/node_modules/@elizaos/cli/dist"
|
|
5969
|
+
);
|
|
5970
|
+
if (existsSync3(path9.join(bunGlobalPath, "index.html"))) {
|
|
5971
|
+
return bunGlobalPath;
|
|
5972
|
+
}
|
|
5973
|
+
try {
|
|
5974
|
+
const npmRoot = execSync("npm root -g", { encoding: "utf8" }).trim();
|
|
5975
|
+
const globalCliPath = path9.join(npmRoot, "@elizaos/cli/dist");
|
|
5976
|
+
if (existsSync3(path9.join(globalCliPath, "index.html"))) {
|
|
5977
|
+
return globalCliPath;
|
|
5978
|
+
}
|
|
5979
|
+
} catch {
|
|
5980
|
+
}
|
|
5981
|
+
} catch {
|
|
5982
|
+
}
|
|
5983
|
+
return null;
|
|
5984
|
+
})(),
|
|
5985
|
+
// Alternative global locations (common paths)
|
|
5986
|
+
...[
|
|
5987
|
+
"/usr/local/lib/node_modules/@elizaos/cli/dist",
|
|
5988
|
+
"/usr/lib/node_modules/@elizaos/cli/dist",
|
|
5989
|
+
path9.join(os2.homedir(), ".npm-global/lib/node_modules/@elizaos/cli/dist"),
|
|
5990
|
+
// Check nvm installations
|
|
5991
|
+
(() => {
|
|
5992
|
+
try {
|
|
5993
|
+
const nvmPath = path9.join(os2.homedir(), ".nvm/versions/node");
|
|
5994
|
+
if (existsSync3(nvmPath)) {
|
|
5995
|
+
const versions = fs9.readdirSync(nvmPath);
|
|
5996
|
+
for (const version of versions) {
|
|
5997
|
+
const cliPath = path9.join(
|
|
5998
|
+
nvmPath,
|
|
5999
|
+
version,
|
|
6000
|
+
"lib/node_modules/@elizaos/cli/dist"
|
|
6001
|
+
);
|
|
6002
|
+
if (existsSync3(path9.join(cliPath, "index.html"))) {
|
|
6003
|
+
return cliPath;
|
|
6004
|
+
}
|
|
6005
|
+
}
|
|
6006
|
+
}
|
|
6007
|
+
} catch {
|
|
6008
|
+
}
|
|
6009
|
+
return null;
|
|
6010
|
+
})()
|
|
6011
|
+
].filter(Boolean)
|
|
5947
6012
|
].filter(Boolean);
|
|
5948
|
-
let clientPath = null;
|
|
5949
6013
|
for (const possiblePath of possiblePaths) {
|
|
5950
6014
|
if (possiblePath && existsSync3(path9.join(possiblePath, "index.html"))) {
|
|
5951
6015
|
clientPath = possiblePath;
|
|
6016
|
+
logger29.info(`[STATIC] Found client files at: ${clientPath}`);
|
|
5952
6017
|
break;
|
|
5953
6018
|
}
|
|
5954
6019
|
}
|
|
5955
6020
|
if (clientPath) {
|
|
5956
6021
|
this.app.use(express31.static(clientPath, staticOptions));
|
|
5957
6022
|
} else {
|
|
5958
|
-
logger29.warn("[STATIC] Client dist path not found");
|
|
6023
|
+
logger29.warn("[STATIC] Client dist path not found. Searched locations:");
|
|
6024
|
+
possiblePaths.forEach((p) => {
|
|
6025
|
+
if (p) logger29.warn(`[STATIC] - ${p}`);
|
|
6026
|
+
});
|
|
6027
|
+
logger29.warn("[STATIC] The web UI will not be available.");
|
|
6028
|
+
logger29.warn(
|
|
6029
|
+
"[STATIC] To fix this, ensure @elizaos/cli is installed globally: bun install -g @elizaos/cli"
|
|
6030
|
+
);
|
|
5959
6031
|
}
|
|
5960
6032
|
}
|
|
5961
6033
|
const pluginRouteHandler = createPluginRouteHandler(this.agents);
|
|
@@ -6000,31 +6072,8 @@ var AgentServer = class {
|
|
|
6000
6072
|
res.setHeader("Content-Type", "application/javascript");
|
|
6001
6073
|
return res.status(404).send(`// JavaScript module not found: ${req.path}`);
|
|
6002
6074
|
}
|
|
6003
|
-
|
|
6004
|
-
|
|
6005
|
-
path9.resolve(__dirname2, "../../cli/dist"),
|
|
6006
|
-
// Production: using require.resolve to find CLI package
|
|
6007
|
-
(() => {
|
|
6008
|
-
try {
|
|
6009
|
-
return path9.resolve(
|
|
6010
|
-
path9.dirname(__require.resolve("@elizaos/cli/package.json")),
|
|
6011
|
-
"dist"
|
|
6012
|
-
);
|
|
6013
|
-
} catch {
|
|
6014
|
-
return null;
|
|
6015
|
-
}
|
|
6016
|
-
})()
|
|
6017
|
-
].filter((p) => p !== null);
|
|
6018
|
-
let indexPath = null;
|
|
6019
|
-
for (const possiblePath of possiblePaths) {
|
|
6020
|
-
const testPath = path9.join(possiblePath, "index.html");
|
|
6021
|
-
if (possiblePath && existsSync3(testPath)) {
|
|
6022
|
-
indexPath = testPath;
|
|
6023
|
-
break;
|
|
6024
|
-
}
|
|
6025
|
-
}
|
|
6026
|
-
if (indexPath) {
|
|
6027
|
-
const indexFilePath = indexPath;
|
|
6075
|
+
if (clientPath) {
|
|
6076
|
+
const indexFilePath = path9.join(clientPath, "index.html");
|
|
6028
6077
|
res.sendFile(indexFilePath, (err) => {
|
|
6029
6078
|
if (err) {
|
|
6030
6079
|
logger29.warn(`[STATIC] Failed to serve index.html: ${err.message}`);
|
|
@@ -6032,6 +6081,7 @@ var AgentServer = class {
|
|
|
6032
6081
|
}
|
|
6033
6082
|
});
|
|
6034
6083
|
} else {
|
|
6084
|
+
logger29.warn("[STATIC] Client dist path not found in SPA fallback");
|
|
6035
6085
|
res.status(404).send("Client application not found");
|
|
6036
6086
|
}
|
|
6037
6087
|
});
|