@elizaos/server 1.6.2-alpha.8 → 1.6.2-beta.0

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.
@@ -5,7 +5,7 @@
5
5
  <meta name="viewport" content="width=device-width, initial-scale=1.0" />
6
6
  <link rel="icon" type="image/x-icon" href="/favicon.ico" />
7
7
  <title>ElizaOS - Client</title>
8
- <script type="module" crossorigin src="/assets/main-CpHBkAFA.js"></script>
8
+ <script type="module" crossorigin src="/assets/main-BtcZiEuQ.js"></script>
9
9
  </head>
10
10
  <body>
11
11
  <div id="root"></div>
package/dist/index.d.ts CHANGED
@@ -21,17 +21,21 @@ export declare function resolvePgliteDir(dir?: string, fallbackDir?: string): st
21
21
  */
22
22
  export type ServerMiddleware = (req: express.Request, res: express.Response, next: express.NextFunction) => void;
23
23
  /**
24
- * Interface for defining server configuration options.
25
- * @typedef {Object} ServerOptions
26
- * @property {ServerMiddleware[]} [middlewares] - Optional array of server middlewares.
27
- * @property {string} [dataDir] - Optional directory for storing server data.
28
- * @property {string} [postgresUrl] - Optional URL for connecting to a PostgreSQL database.
24
+ * Interface for defining server configuration.
25
+ * Used for unified server initialization and startup.
29
26
  */
30
- export interface ServerOptions {
27
+ export interface ServerConfig {
31
28
  middlewares?: ServerMiddleware[];
32
29
  dataDir?: string;
33
30
  postgresUrl?: string;
34
31
  clientPath?: string;
32
+ port?: number;
33
+ agents?: Array<{
34
+ character: Character;
35
+ plugins?: (Plugin | string)[];
36
+ init?: (runtime: IAgentRuntime) => Promise<void>;
37
+ }>;
38
+ isTestMode?: boolean;
35
39
  }
36
40
  /**
37
41
  * Determines if the web UI should be enabled based on environment variables.
@@ -52,18 +56,22 @@ export declare class AgentServer {
52
56
  private isWebUIEnabled;
53
57
  private clientPath?;
54
58
  elizaOS?: ElizaOS;
55
- private pluginLoader?;
56
- private configManager?;
57
59
  database: DatabaseAdapter;
58
60
  loadCharacterTryPath: (characterPath: string) => Promise<Character>;
59
61
  jsonToCharacter: (character: unknown) => Promise<Character>;
60
62
  /**
61
63
  * Start multiple agents in batch (true parallel)
62
- * @param characters - Array of character configurations
63
- * @param plugins - Optional plugins to load
64
+ * @param agents - Array of agent configurations (character + optional plugins/init)
65
+ * @param options - Optional configuration (e.g., isTestMode for test dependencies)
64
66
  * @returns Array of started agent runtimes
65
67
  */
66
- startAgents(characters: Character[], plugins?: (Plugin | string)[]): Promise<IAgentRuntime[]>;
68
+ startAgents(agents: Array<{
69
+ character: Character;
70
+ plugins?: (Plugin | string)[];
71
+ init?: (runtime: IAgentRuntime) => Promise<void>;
72
+ }>, options?: {
73
+ isTestMode?: boolean;
74
+ }): Promise<IAgentRuntime[]>;
67
75
  /**
68
76
  * Stop multiple agents in batch
69
77
  * @param agentIds - Array of agent IDs to stop
@@ -87,18 +95,20 @@ export declare class AgentServer {
87
95
  */
88
96
  constructor();
89
97
  /**
90
- * Initializes the database and server.
98
+ * Initializes the database and server (internal use only).
91
99
  *
92
- * @param {ServerOptions} [options] - Optional server options.
100
+ * @param {ServerConfig} [config] - Optional server configuration.
93
101
  * @returns {Promise<void>} A promise that resolves when initialization is complete.
102
+ * @private
94
103
  */
95
- initialize(options?: ServerOptions): Promise<void>;
104
+ private initialize;
96
105
  private ensureDefaultServer;
97
106
  /**
98
- * Initializes the server with the provided options.
107
+ * Initializes the server with the provided configuration.
99
108
  *
100
- * @param {ServerOptions} [options] - Optional server options.
109
+ * @param {ServerConfig} [config] - Optional server configuration.
101
110
  * @returns {Promise<void>} - A promise that resolves once the server is initialized.
111
+ * @private
102
112
  */
103
113
  private initializeServer;
104
114
  /**
@@ -124,13 +134,33 @@ export declare class AgentServer {
124
134
  */
125
135
  registerMiddleware(middleware: ServerMiddleware): void;
126
136
  /**
127
- * Starts the server on the specified port.
137
+ * Starts the server with unified configuration.
138
+ * Handles initialization, port resolution, and optional agent startup.
128
139
  *
129
- * @param {number} port - The port number on which the server should listen.
140
+ * @param {ServerConfig} config - Server configuration including port, agents, and infrastructure options.
130
141
  * @returns {Promise<void>} A promise that resolves when the server is listening.
131
- * @throws {Error} If the port is invalid or if there is an error while starting the server.
142
+ * @throws {Error} If there is an error during initialization or startup.
132
143
  */
133
- start(port: number): Promise<void>;
144
+ start(config?: ServerConfig): Promise<void>;
145
+ /**
146
+ * Resolves and finds an available port.
147
+ * - If port is provided (number): validates and returns it (strict - fails if unavailable)
148
+ * - If port is undefined: finds next available port starting from env/default (auto-discovery)
149
+ */
150
+ private resolveAndFindPort;
151
+ /**
152
+ * Finds an available port starting from the requested port.
153
+ * Tries incrementing ports up to maxAttempts.
154
+ */
155
+ private findAvailablePort;
156
+ /**
157
+ * Checks if a port is available by attempting to bind to it.
158
+ */
159
+ private isPortAvailable;
160
+ /**
161
+ * Starts the HTTP server on the specified port.
162
+ */
163
+ private startHttpServer;
134
164
  /**
135
165
  * Stops the server if it is running. Closes the server connection,
136
166
  * stops the database connection, and logs a success message.
@@ -200,5 +230,3 @@ export declare class AgentServer {
200
230
  export { tryLoadFile, loadCharactersFromUrl, jsonToCharacter, loadCharacter, loadCharacterTryPath, hasValidRemoteUrls, loadCharacters, } from './loader';
201
231
  export * from './types';
202
232
  export { ElizaOS } from '@elizaos/core';
203
- export { PluginLoader } from './managers/PluginLoader';
204
- export { ConfigManager } from './managers/ConfigManager';