@elizaos/server 1.1.4 → 1.1.6
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 +2 -0
- package/dist/index.js +100 -34
- package/dist/index.js.map +1 -1
- package/package.json +4 -4
package/dist/index.d.ts
CHANGED
|
@@ -127,6 +127,7 @@ interface ServerOptions {
|
|
|
127
127
|
middlewares?: ServerMiddleware[];
|
|
128
128
|
dataDir?: string;
|
|
129
129
|
postgresUrl?: string;
|
|
130
|
+
clientPath?: string;
|
|
130
131
|
}
|
|
131
132
|
/**
|
|
132
133
|
* Determines if the web UI should be enabled based on environment variables.
|
|
@@ -146,6 +147,7 @@ declare class AgentServer {
|
|
|
146
147
|
socketIO: Server;
|
|
147
148
|
isInitialized: boolean;
|
|
148
149
|
private isWebUIEnabled;
|
|
150
|
+
private clientPath?;
|
|
149
151
|
database: DatabaseAdapter;
|
|
150
152
|
startAgent: (character: Character) => Promise<IAgentRuntime>;
|
|
151
153
|
stopAgent: (runtime: IAgentRuntime) => void;
|
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.6",
|
|
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: "0e840205db9f212b2b5568b26b669a9860256099",
|
|
3872
3873
|
dependencies: {
|
|
3873
|
-
"@elizaos/core": "1.1.
|
|
3874
|
-
"@elizaos/plugin-sql": "1.1.
|
|
3874
|
+
"@elizaos/core": "1.1.6",
|
|
3875
|
+
"@elizaos/plugin-sql": "1.1.6",
|
|
3875
3876
|
"@types/express": "^5.0.2",
|
|
3876
3877
|
"@types/helmet": "^4.0.0",
|
|
3877
3878
|
"@types/multer": "^1.4.13",
|
|
@@ -5566,6 +5567,8 @@ var AgentServer = class {
|
|
|
5566
5567
|
// Flag to prevent double initialization
|
|
5567
5568
|
isWebUIEnabled = true;
|
|
5568
5569
|
// Default to enabled until initialized
|
|
5570
|
+
clientPath;
|
|
5571
|
+
// Optional path to client dist files
|
|
5569
5572
|
database;
|
|
5570
5573
|
startAgent;
|
|
5571
5574
|
stopAgent;
|
|
@@ -5708,6 +5711,9 @@ var AgentServer = class {
|
|
|
5708
5711
|
*/
|
|
5709
5712
|
async initializeServer(options) {
|
|
5710
5713
|
try {
|
|
5714
|
+
if (options?.clientPath) {
|
|
5715
|
+
this.clientPath = options.clientPath;
|
|
5716
|
+
}
|
|
5711
5717
|
this.app = express31();
|
|
5712
5718
|
const isProd = process.env.NODE_ENV === "production";
|
|
5713
5719
|
logger29.debug("Setting up security headers...");
|
|
@@ -5942,11 +5948,14 @@ var AgentServer = class {
|
|
|
5942
5948
|
}
|
|
5943
5949
|
}
|
|
5944
5950
|
};
|
|
5951
|
+
let clientPath = null;
|
|
5945
5952
|
if (this.isWebUIEnabled) {
|
|
5946
5953
|
const possiblePaths = [
|
|
5947
|
-
//
|
|
5954
|
+
// First priority: explicitly provided client path
|
|
5955
|
+
this.clientPath,
|
|
5956
|
+
// Development: relative to server package (monorepo)
|
|
5948
5957
|
path9.resolve(__dirname2, "../../cli/dist"),
|
|
5949
|
-
// Production: using require.resolve to find CLI package
|
|
5958
|
+
// Production: using require.resolve to find CLI package (if installed as dependency)
|
|
5950
5959
|
(() => {
|
|
5951
5960
|
try {
|
|
5952
5961
|
return path9.resolve(
|
|
@@ -5956,19 +5965,98 @@ var AgentServer = class {
|
|
|
5956
5965
|
} catch {
|
|
5957
5966
|
return null;
|
|
5958
5967
|
}
|
|
5959
|
-
})()
|
|
5968
|
+
})(),
|
|
5969
|
+
// Check if running from global CLI - look for client files in the same directory as the running process
|
|
5970
|
+
(() => {
|
|
5971
|
+
try {
|
|
5972
|
+
if (process.argv[1]) {
|
|
5973
|
+
const cliPath = path9.dirname(process.argv[1]);
|
|
5974
|
+
const possibleDistPath = path9.join(cliPath, "index.html");
|
|
5975
|
+
if (existsSync3(possibleDistPath)) {
|
|
5976
|
+
return cliPath;
|
|
5977
|
+
}
|
|
5978
|
+
const parentPath = path9.dirname(cliPath);
|
|
5979
|
+
const possibleParentDistPath = path9.join(parentPath, "index.html");
|
|
5980
|
+
if (existsSync3(possibleParentDistPath)) {
|
|
5981
|
+
return parentPath;
|
|
5982
|
+
}
|
|
5983
|
+
}
|
|
5984
|
+
} catch {
|
|
5985
|
+
}
|
|
5986
|
+
return null;
|
|
5987
|
+
})(),
|
|
5988
|
+
// Global bun install: check global node_modules locations
|
|
5989
|
+
(() => {
|
|
5990
|
+
try {
|
|
5991
|
+
const { execSync } = __require("child_process");
|
|
5992
|
+
const bunGlobalPath = path9.join(
|
|
5993
|
+
os2.homedir(),
|
|
5994
|
+
".bun/install/global/node_modules/@elizaos/cli/dist"
|
|
5995
|
+
);
|
|
5996
|
+
if (existsSync3(path9.join(bunGlobalPath, "index.html"))) {
|
|
5997
|
+
return bunGlobalPath;
|
|
5998
|
+
}
|
|
5999
|
+
try {
|
|
6000
|
+
const npmRoot = execSync("npm root -g", { encoding: "utf8" }).trim();
|
|
6001
|
+
const globalCliPath = path9.join(npmRoot, "@elizaos/cli/dist");
|
|
6002
|
+
if (existsSync3(path9.join(globalCliPath, "index.html"))) {
|
|
6003
|
+
return globalCliPath;
|
|
6004
|
+
}
|
|
6005
|
+
} catch {
|
|
6006
|
+
}
|
|
6007
|
+
} catch {
|
|
6008
|
+
}
|
|
6009
|
+
return null;
|
|
6010
|
+
})(),
|
|
6011
|
+
// Alternative global locations (common paths)
|
|
6012
|
+
...[
|
|
6013
|
+
"/usr/local/lib/node_modules/@elizaos/cli/dist",
|
|
6014
|
+
"/usr/lib/node_modules/@elizaos/cli/dist",
|
|
6015
|
+
path9.join(os2.homedir(), ".npm-global/lib/node_modules/@elizaos/cli/dist"),
|
|
6016
|
+
// Check nvm installations
|
|
6017
|
+
(() => {
|
|
6018
|
+
try {
|
|
6019
|
+
const nvmPath = path9.join(os2.homedir(), ".nvm/versions/node");
|
|
6020
|
+
if (existsSync3(nvmPath)) {
|
|
6021
|
+
const versions = fs9.readdirSync(nvmPath);
|
|
6022
|
+
for (const version of versions) {
|
|
6023
|
+
const cliPath = path9.join(
|
|
6024
|
+
nvmPath,
|
|
6025
|
+
version,
|
|
6026
|
+
"lib/node_modules/@elizaos/cli/dist"
|
|
6027
|
+
);
|
|
6028
|
+
if (existsSync3(path9.join(cliPath, "index.html"))) {
|
|
6029
|
+
return cliPath;
|
|
6030
|
+
}
|
|
6031
|
+
}
|
|
6032
|
+
}
|
|
6033
|
+
} catch {
|
|
6034
|
+
}
|
|
6035
|
+
return null;
|
|
6036
|
+
})()
|
|
6037
|
+
].filter(Boolean)
|
|
5960
6038
|
].filter(Boolean);
|
|
5961
|
-
|
|
6039
|
+
logger29.debug(`[STATIC] process.argv[0]: ${process.argv[0]}`);
|
|
6040
|
+
logger29.debug(`[STATIC] process.argv[1]: ${process.argv[1]}`);
|
|
6041
|
+
logger29.debug(`[STATIC] __dirname: ${__dirname2}`);
|
|
5962
6042
|
for (const possiblePath of possiblePaths) {
|
|
5963
6043
|
if (possiblePath && existsSync3(path9.join(possiblePath, "index.html"))) {
|
|
5964
6044
|
clientPath = possiblePath;
|
|
6045
|
+
logger29.info(`[STATIC] Found client files at: ${clientPath}`);
|
|
5965
6046
|
break;
|
|
5966
6047
|
}
|
|
5967
6048
|
}
|
|
5968
6049
|
if (clientPath) {
|
|
5969
6050
|
this.app.use(express31.static(clientPath, staticOptions));
|
|
5970
6051
|
} else {
|
|
5971
|
-
logger29.warn("[STATIC] Client dist path not found");
|
|
6052
|
+
logger29.warn("[STATIC] Client dist path not found. Searched locations:");
|
|
6053
|
+
possiblePaths.forEach((p) => {
|
|
6054
|
+
if (p) logger29.warn(`[STATIC] - ${p}`);
|
|
6055
|
+
});
|
|
6056
|
+
logger29.warn("[STATIC] The web UI will not be available.");
|
|
6057
|
+
logger29.warn(
|
|
6058
|
+
"[STATIC] To fix this, ensure @elizaos/cli is installed globally: bun install -g @elizaos/cli"
|
|
6059
|
+
);
|
|
5972
6060
|
}
|
|
5973
6061
|
}
|
|
5974
6062
|
const pluginRouteHandler = createPluginRouteHandler(this.agents);
|
|
@@ -6013,31 +6101,8 @@ var AgentServer = class {
|
|
|
6013
6101
|
res.setHeader("Content-Type", "application/javascript");
|
|
6014
6102
|
return res.status(404).send(`// JavaScript module not found: ${req.path}`);
|
|
6015
6103
|
}
|
|
6016
|
-
|
|
6017
|
-
|
|
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;
|
|
6037
|
-
}
|
|
6038
|
-
}
|
|
6039
|
-
if (indexPath) {
|
|
6040
|
-
const indexFilePath = indexPath;
|
|
6104
|
+
if (clientPath) {
|
|
6105
|
+
const indexFilePath = path9.join(clientPath, "index.html");
|
|
6041
6106
|
res.sendFile(indexFilePath, (err) => {
|
|
6042
6107
|
if (err) {
|
|
6043
6108
|
logger29.warn(`[STATIC] Failed to serve index.html: ${err.message}`);
|
|
@@ -6045,6 +6110,7 @@ var AgentServer = class {
|
|
|
6045
6110
|
}
|
|
6046
6111
|
});
|
|
6047
6112
|
} else {
|
|
6113
|
+
logger29.warn("[STATIC] Client dist path not found in SPA fallback");
|
|
6048
6114
|
res.status(404).send("Client application not found");
|
|
6049
6115
|
}
|
|
6050
6116
|
});
|