@elizaos/server 1.1.2 → 1.1.4
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 -26
- package/dist/index.js.map +1 -1
- package/package.json +4 -4
package/dist/index.js
CHANGED
|
@@ -4,7 +4,13 @@ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
|
4
4
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
5
|
var __getProtoOf = Object.getPrototypeOf;
|
|
6
6
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
-
var
|
|
7
|
+
var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
|
|
8
|
+
get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
|
|
9
|
+
}) : x)(function(x) {
|
|
10
|
+
if (typeof require !== "undefined") return require.apply(this, arguments);
|
|
11
|
+
throw Error('Dynamic require of "' + x + '" is not supported');
|
|
12
|
+
});
|
|
13
|
+
var __commonJS = (cb, mod) => function __require2() {
|
|
8
14
|
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
9
15
|
};
|
|
10
16
|
var __copyProps = (to, from, except, desc) => {
|
|
@@ -3810,7 +3816,7 @@ import express28 from "express";
|
|
|
3810
3816
|
// package.json
|
|
3811
3817
|
var package_default = {
|
|
3812
3818
|
name: "@elizaos/server",
|
|
3813
|
-
version: "1.1.
|
|
3819
|
+
version: "1.1.4",
|
|
3814
3820
|
description: "ElizaOS Server - Core server infrastructure for ElizaOS agents",
|
|
3815
3821
|
publishConfig: {
|
|
3816
3822
|
access: "public",
|
|
@@ -3862,10 +3868,10 @@ var package_default = {
|
|
|
3862
3868
|
which: "^4.0.0",
|
|
3863
3869
|
ws: "^8.18.0"
|
|
3864
3870
|
},
|
|
3865
|
-
gitHead: "
|
|
3871
|
+
gitHead: "06db8f7642156822f010efef3377af4c6161f2c8",
|
|
3866
3872
|
dependencies: {
|
|
3867
|
-
"@elizaos/core": "1.1.
|
|
3868
|
-
"@elizaos/plugin-sql": "1.1.
|
|
3873
|
+
"@elizaos/core": "1.1.4",
|
|
3874
|
+
"@elizaos/plugin-sql": "1.1.4",
|
|
3869
3875
|
"@types/express": "^5.0.2",
|
|
3870
3876
|
"@types/helmet": "^4.0.0",
|
|
3871
3877
|
"@types/multer": "^1.4.13",
|
|
@@ -4387,6 +4393,11 @@ function createPluginRouteHandler(agents) {
|
|
|
4387
4393
|
if (req.path.startsWith("/api/messages/")) {
|
|
4388
4394
|
return next();
|
|
4389
4395
|
}
|
|
4396
|
+
const clientRoutePattern = /^\/(chat|settings|agents|profile|dashboard|login|register|admin|home|about)\b/i;
|
|
4397
|
+
if (clientRoutePattern.test(req.path)) {
|
|
4398
|
+
logger25.debug(`Skipping client-side route in plugin handler: ${req.path}`);
|
|
4399
|
+
return next();
|
|
4400
|
+
}
|
|
4390
4401
|
if (req.path.endsWith(".js") || req.path.includes(".js?") || req.path.match(/index-[A-Za-z0-9]{8}\.js/)) {
|
|
4391
4402
|
logger25.debug(`JavaScript request in plugin handler: ${req.method} ${req.path}`);
|
|
4392
4403
|
res.setHeader("Content-Type", "application/javascript");
|
|
@@ -4488,25 +4499,33 @@ function createPluginRouteHandler(agents) {
|
|
|
4488
4499
|
logger25.warn(
|
|
4489
4500
|
`Agent ID ${agentIdFromQuery} provided in query, but agent runtime not found. Path: ${reqPath}.`
|
|
4490
4501
|
);
|
|
4491
|
-
|
|
4502
|
+
if (reqPath.startsWith("/api/")) {
|
|
4503
|
+
res.status(404).json({
|
|
4504
|
+
success: false,
|
|
4505
|
+
error: {
|
|
4506
|
+
message: "Agent not found",
|
|
4507
|
+
code: "AGENT_NOT_FOUND"
|
|
4508
|
+
}
|
|
4509
|
+
});
|
|
4510
|
+
return;
|
|
4511
|
+
} else {
|
|
4512
|
+
return next();
|
|
4513
|
+
}
|
|
4514
|
+
}
|
|
4515
|
+
} else if (agentIdFromQuery && !validateUuid21(agentIdFromQuery)) {
|
|
4516
|
+
logger25.warn(`Invalid Agent ID format in query: ${agentIdFromQuery}. Path: ${reqPath}.`);
|
|
4517
|
+
if (reqPath.startsWith("/api/")) {
|
|
4518
|
+
res.status(400).json({
|
|
4492
4519
|
success: false,
|
|
4493
4520
|
error: {
|
|
4494
|
-
message: "
|
|
4495
|
-
code: "
|
|
4521
|
+
message: "Invalid agent ID format",
|
|
4522
|
+
code: "INVALID_AGENT_ID"
|
|
4496
4523
|
}
|
|
4497
4524
|
});
|
|
4498
4525
|
return;
|
|
4526
|
+
} else {
|
|
4527
|
+
return next();
|
|
4499
4528
|
}
|
|
4500
|
-
} else if (agentIdFromQuery && !validateUuid21(agentIdFromQuery)) {
|
|
4501
|
-
logger25.warn(`Invalid Agent ID format in query: ${agentIdFromQuery}. Path: ${reqPath}.`);
|
|
4502
|
-
res.status(400).json({
|
|
4503
|
-
success: false,
|
|
4504
|
-
error: {
|
|
4505
|
-
message: "Invalid agent ID format",
|
|
4506
|
-
code: "INVALID_AGENT_ID"
|
|
4507
|
-
}
|
|
4508
|
-
});
|
|
4509
|
-
return;
|
|
4510
4529
|
} else {
|
|
4511
4530
|
logger25.debug(`No valid agentId in query. Trying global match for path: ${reqPath}`);
|
|
4512
4531
|
for (const [_, runtime] of agents) {
|
|
@@ -5924,8 +5943,33 @@ var AgentServer = class {
|
|
|
5924
5943
|
}
|
|
5925
5944
|
};
|
|
5926
5945
|
if (this.isWebUIEnabled) {
|
|
5927
|
-
const
|
|
5928
|
-
|
|
5946
|
+
const possiblePaths = [
|
|
5947
|
+
// Development: relative to server package
|
|
5948
|
+
path9.resolve(__dirname2, "../../cli/dist"),
|
|
5949
|
+
// Production: using require.resolve to find CLI package
|
|
5950
|
+
(() => {
|
|
5951
|
+
try {
|
|
5952
|
+
return path9.resolve(
|
|
5953
|
+
path9.dirname(__require.resolve("@elizaos/cli/package.json")),
|
|
5954
|
+
"dist"
|
|
5955
|
+
);
|
|
5956
|
+
} catch {
|
|
5957
|
+
return null;
|
|
5958
|
+
}
|
|
5959
|
+
})()
|
|
5960
|
+
].filter(Boolean);
|
|
5961
|
+
let clientPath = null;
|
|
5962
|
+
for (const possiblePath of possiblePaths) {
|
|
5963
|
+
if (possiblePath && existsSync3(path9.join(possiblePath, "index.html"))) {
|
|
5964
|
+
clientPath = possiblePath;
|
|
5965
|
+
break;
|
|
5966
|
+
}
|
|
5967
|
+
}
|
|
5968
|
+
if (clientPath) {
|
|
5969
|
+
this.app.use(express31.static(clientPath, staticOptions));
|
|
5970
|
+
} else {
|
|
5971
|
+
logger29.warn("[STATIC] Client dist path not found");
|
|
5972
|
+
}
|
|
5929
5973
|
}
|
|
5930
5974
|
const pluginRouteHandler = createPluginRouteHandler(this.agents);
|
|
5931
5975
|
this.app.use(pluginRouteHandler);
|
|
@@ -5969,13 +6013,40 @@ var AgentServer = class {
|
|
|
5969
6013
|
res.setHeader("Content-Type", "application/javascript");
|
|
5970
6014
|
return res.status(404).send(`// JavaScript module not found: ${req.path}`);
|
|
5971
6015
|
}
|
|
5972
|
-
const
|
|
5973
|
-
|
|
5974
|
-
|
|
5975
|
-
|
|
5976
|
-
|
|
6016
|
+
const possiblePaths = [
|
|
6017
|
+
// Development: relative to server package
|
|
6018
|
+
path9.resolve(__dirname2, "../../cli/dist"),
|
|
6019
|
+
// Production: using require.resolve to find CLI package
|
|
6020
|
+
(() => {
|
|
6021
|
+
try {
|
|
6022
|
+
return path9.resolve(
|
|
6023
|
+
path9.dirname(__require.resolve("@elizaos/cli/package.json")),
|
|
6024
|
+
"dist"
|
|
6025
|
+
);
|
|
6026
|
+
} catch {
|
|
6027
|
+
return null;
|
|
6028
|
+
}
|
|
6029
|
+
})()
|
|
6030
|
+
].filter((p) => p !== null);
|
|
6031
|
+
let indexPath = null;
|
|
6032
|
+
for (const possiblePath of possiblePaths) {
|
|
6033
|
+
const testPath = path9.join(possiblePath, "index.html");
|
|
6034
|
+
if (possiblePath && existsSync3(testPath)) {
|
|
6035
|
+
indexPath = testPath;
|
|
6036
|
+
break;
|
|
5977
6037
|
}
|
|
5978
|
-
}
|
|
6038
|
+
}
|
|
6039
|
+
if (indexPath) {
|
|
6040
|
+
const indexFilePath = indexPath;
|
|
6041
|
+
res.sendFile(indexFilePath, (err) => {
|
|
6042
|
+
if (err) {
|
|
6043
|
+
logger29.warn(`[STATIC] Failed to serve index.html: ${err.message}`);
|
|
6044
|
+
res.status(404).send("Client application not found");
|
|
6045
|
+
}
|
|
6046
|
+
});
|
|
6047
|
+
} else {
|
|
6048
|
+
res.status(404).send("Client application not found");
|
|
6049
|
+
}
|
|
5979
6050
|
});
|
|
5980
6051
|
} else {
|
|
5981
6052
|
this.app.use((_req, res) => {
|