@elizaos/server 1.4.4 → 1.5.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.
Files changed (124) hide show
  1. package/dist/api/agents/crud.d.ts +8 -0
  2. package/dist/api/agents/crud.d.ts.map +1 -0
  3. package/dist/api/agents/index.d.ts +8 -0
  4. package/dist/api/agents/index.d.ts.map +1 -0
  5. package/dist/api/agents/lifecycle.d.ts +8 -0
  6. package/dist/api/agents/lifecycle.d.ts.map +1 -0
  7. package/dist/api/agents/logs.d.ts +7 -0
  8. package/dist/api/agents/logs.d.ts.map +1 -0
  9. package/dist/api/agents/panels.d.ts +7 -0
  10. package/dist/api/agents/panels.d.ts.map +1 -0
  11. package/dist/api/agents/worlds.d.ts +7 -0
  12. package/dist/api/agents/worlds.d.ts.map +1 -0
  13. package/dist/api/audio/audioBuffer.d.ts +18 -0
  14. package/dist/api/audio/audioBuffer.d.ts.map +1 -0
  15. package/dist/api/audio/conversation.d.ts +7 -0
  16. package/dist/api/audio/conversation.d.ts.map +1 -0
  17. package/dist/api/audio/index.d.ts +7 -0
  18. package/dist/api/audio/index.d.ts.map +1 -0
  19. package/dist/api/audio/processing.d.ts +10 -0
  20. package/dist/api/audio/processing.d.ts.map +1 -0
  21. package/dist/api/audio/synthesis.d.ts +7 -0
  22. package/dist/api/audio/synthesis.d.ts.map +1 -0
  23. package/dist/api/index.d.ts +20 -0
  24. package/dist/api/index.d.ts.map +1 -0
  25. package/dist/api/media/agents.d.ts +6 -0
  26. package/dist/api/media/agents.d.ts.map +1 -0
  27. package/dist/api/media/channels.d.ts +6 -0
  28. package/dist/api/media/channels.d.ts.map +1 -0
  29. package/dist/api/media/index.d.ts +6 -0
  30. package/dist/api/media/index.d.ts.map +1 -0
  31. package/dist/api/memory/agents.d.ts +7 -0
  32. package/dist/api/memory/agents.d.ts.map +1 -0
  33. package/dist/api/memory/groups.d.ts +8 -0
  34. package/dist/api/memory/groups.d.ts.map +1 -0
  35. package/dist/api/memory/index.d.ts +8 -0
  36. package/dist/api/memory/index.d.ts.map +1 -0
  37. package/dist/api/memory/rooms.d.ts +7 -0
  38. package/dist/api/memory/rooms.d.ts.map +1 -0
  39. package/dist/api/messaging/channels.d.ts +8 -0
  40. package/dist/api/messaging/channels.d.ts.map +1 -0
  41. package/dist/api/messaging/core.d.ts +7 -0
  42. package/dist/api/messaging/core.d.ts.map +1 -0
  43. package/dist/api/messaging/errors/SessionErrors.d.ts +149 -0
  44. package/dist/api/messaging/errors/SessionErrors.d.ts.map +1 -0
  45. package/dist/api/messaging/index.d.ts +8 -0
  46. package/dist/api/messaging/index.d.ts.map +1 -0
  47. package/dist/api/messaging/servers.d.ts +7 -0
  48. package/dist/api/messaging/servers.d.ts.map +1 -0
  49. package/dist/api/messaging/sessions.d.ts +23 -0
  50. package/dist/api/messaging/sessions.d.ts.map +1 -0
  51. package/dist/api/runtime/debug.d.ts +7 -0
  52. package/dist/api/runtime/debug.d.ts.map +1 -0
  53. package/dist/api/runtime/health.d.ts +8 -0
  54. package/dist/api/runtime/health.d.ts.map +1 -0
  55. package/dist/api/runtime/index.d.ts +8 -0
  56. package/dist/api/runtime/index.d.ts.map +1 -0
  57. package/dist/api/runtime/logging.d.ts +6 -0
  58. package/dist/api/runtime/logging.d.ts.map +1 -0
  59. package/dist/api/shared/constants.d.ts +22 -0
  60. package/dist/api/shared/constants.d.ts.map +1 -0
  61. package/dist/api/shared/file-utils.d.ts +21 -0
  62. package/dist/api/shared/file-utils.d.ts.map +1 -0
  63. package/dist/api/shared/index.d.ts +7 -0
  64. package/dist/api/shared/index.d.ts.map +1 -0
  65. package/dist/api/shared/middleware.d.ts +40 -0
  66. package/dist/api/shared/middleware.d.ts.map +1 -0
  67. package/dist/api/shared/response-utils.d.ts +10 -0
  68. package/dist/api/shared/response-utils.d.ts.map +1 -0
  69. package/dist/api/shared/uploads/index.d.ts +2 -0
  70. package/dist/api/shared/uploads/index.d.ts.map +1 -0
  71. package/dist/api/shared/validation.d.ts +27 -0
  72. package/dist/api/shared/validation.d.ts.map +1 -0
  73. package/dist/api/system/environment.d.ts +24 -0
  74. package/dist/api/system/environment.d.ts.map +1 -0
  75. package/dist/api/system/index.d.ts +6 -0
  76. package/dist/api/system/index.d.ts.map +1 -0
  77. package/dist/api/system/version.d.ts +6 -0
  78. package/dist/api/system/version.d.ts.map +1 -0
  79. package/dist/api/tee/index.d.ts +6 -0
  80. package/dist/api/tee/index.d.ts.map +1 -0
  81. package/dist/api/tee/tee.d.ts +1 -0
  82. package/dist/api/tee/tee.d.ts.map +1 -0
  83. package/dist/authMiddleware.d.ts +16 -0
  84. package/dist/authMiddleware.d.ts.map +1 -0
  85. package/dist/bus.d.ts +31 -0
  86. package/dist/bus.d.ts.map +1 -0
  87. package/dist/index.d.ts +13 -258
  88. package/dist/index.d.ts.map +1 -0
  89. package/dist/index.js +3506 -3054
  90. package/dist/loader.d.ts +49 -0
  91. package/dist/loader.d.ts.map +1 -0
  92. package/dist/scripts/copy-client-dist.d.ts +2 -0
  93. package/dist/scripts/copy-client-dist.d.ts.map +1 -0
  94. package/dist/services/message.d.ts +49 -0
  95. package/dist/services/message.d.ts.map +1 -0
  96. package/dist/socketio/index.d.ts +23 -0
  97. package/dist/socketio/index.d.ts.map +1 -0
  98. package/dist/types/sessions.d.ts +153 -0
  99. package/dist/types/sessions.d.ts.map +1 -0
  100. package/dist/types.d.ts +52 -0
  101. package/dist/types.d.ts.map +1 -0
  102. package/dist/upload.d.ts +16 -0
  103. package/dist/upload.d.ts.map +1 -0
  104. package/package.json +8 -8
  105. package/dist/client/assets/index-DESjREgK.css +0 -1
  106. package/dist/client/assets/index-DESjREgK.css.br +0 -0
  107. package/dist/client/assets/index-l7vDDpLb.js +0 -160469
  108. package/dist/client/assets/index-l7vDDpLb.js.br +0 -0
  109. package/dist/client/assets/index-l7vDDpLb.js.map +0 -1
  110. package/dist/client/assets/vendor-BWzYG1ky.js +0 -3124
  111. package/dist/client/assets/vendor-BWzYG1ky.js.br +0 -0
  112. package/dist/client/assets/vendor-BWzYG1ky.js.map +0 -1
  113. package/dist/client/elizaos-avatar.png +0 -0
  114. package/dist/client/elizaos-icon.png +0 -0
  115. package/dist/client/elizaos-logo-light.png +0 -0
  116. package/dist/client/elizaos.webp +0 -0
  117. package/dist/client/favicon.ico +0 -0
  118. package/dist/client/images/agents/agent1.png +0 -0
  119. package/dist/client/images/agents/agent2.png +0 -0
  120. package/dist/client/images/agents/agent3.png +0 -0
  121. package/dist/client/images/agents/agent4.png +0 -0
  122. package/dist/client/images/agents/agent5.png +0 -0
  123. package/dist/client/index.html +0 -24
  124. package/dist/index.js.map +0 -1
@@ -0,0 +1,7 @@
1
+ export * from './response-utils';
2
+ export * from './validation';
3
+ export * from './file-utils';
4
+ export * from './middleware';
5
+ export * from './uploads';
6
+ export * from './constants';
7
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/api/shared/index.ts"],"names":[],"mappings":"AACA,cAAc,kBAAkB,CAAC;AACjC,cAAc,cAAc,CAAC;AAC7B,cAAc,cAAc,CAAC;AAC7B,cAAc,cAAc,CAAC;AAC7B,cAAc,WAAW,CAAC;AAC1B,cAAc,aAAa,CAAC"}
@@ -0,0 +1,40 @@
1
+ import type { IAgentRuntime, UUID } from '@elizaos/core';
2
+ import express from 'express';
3
+ /**
4
+ * Middleware to validate that an agent exists
5
+ */
6
+ export declare const agentExistsMiddleware: (agents: Map<UUID, IAgentRuntime>) => (req: express.Request, res: express.Response, next: express.NextFunction) => void;
7
+ /**
8
+ * Middleware to validate UUID parameters
9
+ */
10
+ export declare const validateUuidMiddleware: (paramName: string) => (req: express.Request, res: express.Response, next: express.NextFunction) => void;
11
+ /**
12
+ * Enhanced channel ID validation middleware with additional security
13
+ */
14
+ export declare const validateChannelIdMiddleware: () => (req: express.Request, res: express.Response, next: express.NextFunction) => void;
15
+ /**
16
+ * Security middleware to add additional API protection
17
+ */
18
+ export declare const securityMiddleware: () => (req: express.Request, res: express.Response, next: express.NextFunction) => void;
19
+ /**
20
+ * Middleware to validate request content type for POST/PUT/PATCH requests
21
+ */
22
+ export declare const validateContentTypeMiddleware: () => (req: express.Request, res: express.Response, next: express.NextFunction) => void;
23
+ /**
24
+ * General API rate limiting middleware
25
+ */
26
+ export declare const createApiRateLimit: () => import("express-rate-limit").RateLimitRequestHandler;
27
+ /**
28
+ * Strict rate limiting for file system operations
29
+ */
30
+ export declare const createFileSystemRateLimit: () => import("express-rate-limit").RateLimitRequestHandler;
31
+ /**
32
+ * Very strict rate limiting for upload operations
33
+ */
34
+ export declare const createUploadRateLimit: () => import("express-rate-limit").RateLimitRequestHandler;
35
+ /**
36
+ * Rate limiting specifically for channel validation attempts
37
+ * Prevents brute force attacks on channel IDs
38
+ */
39
+ export declare const createChannelValidationRateLimit: () => import("express-rate-limit").RateLimitRequestHandler;
40
+ //# sourceMappingURL=middleware.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"middleware.d.ts","sourceRoot":"","sources":["../../../src/api/shared/middleware.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,IAAI,EAAE,MAAM,eAAe,CAAC;AACzD,OAAO,OAAO,MAAM,SAAS,CAAC;AAM9B;;GAEG;AACH,eAAO,MAAM,qBAAqB,GAAI,QAAQ,GAAG,CAAC,IAAI,EAAE,aAAa,CAAC,MAC5D,KAAK,OAAO,CAAC,OAAO,EAAE,KAAK,OAAO,CAAC,QAAQ,EAAE,MAAM,OAAO,CAAC,YAAY,SAgBhF,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,sBAAsB,GAAI,WAAW,MAAM,MAC9C,KAAK,OAAO,CAAC,OAAO,EAAE,KAAK,OAAO,CAAC,QAAQ,EAAE,MAAM,OAAO,CAAC,YAAY,SAuBhF,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,2BAA2B,SAC9B,KAAK,OAAO,CAAC,OAAO,EAAE,KAAK,OAAO,CAAC,QAAQ,EAAE,MAAM,OAAO,CAAC,YAAY,SAoBhF,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,kBAAkB,SACrB,KAAK,OAAO,CAAC,OAAO,EAAE,KAAK,OAAO,CAAC,QAAQ,EAAE,MAAM,OAAO,CAAC,YAAY,SAqEhF,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,6BAA6B,SAChC,KAAK,OAAO,CAAC,OAAO,EAAE,KAAK,OAAO,CAAC,QAAQ,EAAE,MAAM,OAAO,CAAC,YAAY,SA8BhF,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,kBAAkB,4DAyB9B,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,yBAAyB,4DA2BrC,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,qBAAqB,4DA2BjC,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,gCAAgC,4DAqC5C,CAAC"}
@@ -0,0 +1,10 @@
1
+ import express from 'express';
2
+ /**
3
+ * Sends a standardized error response
4
+ */
5
+ export declare const sendError: (res: express.Response, status: number, code: string, message: string, details?: string) => void;
6
+ /**
7
+ * Sends a standardized success response
8
+ */
9
+ export declare const sendSuccess: (res: express.Response, data: any, status?: number) => void;
10
+ //# sourceMappingURL=response-utils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"response-utils.d.ts","sourceRoot":"","sources":["../../../src/api/shared/response-utils.ts"],"names":[],"mappings":"AAAA,OAAO,OAAO,MAAM,SAAS,CAAC;AAE9B;;GAEG;AACH,eAAO,MAAM,SAAS,GACpB,KAAK,OAAO,CAAC,QAAQ,EACrB,QAAQ,MAAM,EACd,MAAM,MAAM,EACZ,SAAS,MAAM,EACf,UAAU,MAAM,SAUjB,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,WAAW,GAAI,KAAK,OAAO,CAAC,QAAQ,EAAE,MAAM,GAAG,EAAE,eAAY,SAKzE,CAAC"}
@@ -0,0 +1,2 @@
1
+ export { agentAudioUpload, agentMediaUpload, channelUpload, validateAudioFile, validateMediaFile, processUploadedFile, generateSecureFilename, ensureUploadDir, } from '../../../upload';
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/api/shared/uploads/index.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,gBAAgB,EAChB,gBAAgB,EAChB,aAAa,EACb,iBAAiB,EACjB,iBAAiB,EACjB,mBAAmB,EACnB,sBAAsB,EACtB,eAAe,GAChB,MAAM,iBAAiB,CAAC"}
@@ -0,0 +1,27 @@
1
+ import type { IAgentRuntime, UUID } from '@elizaos/core';
2
+ /**
3
+ * Validates and retrieves an agent runtime from the agents map
4
+ */
5
+ export declare const getRuntime: (agents: Map<UUID, IAgentRuntime>, agentId: UUID) => IAgentRuntime;
6
+ /**
7
+ * Validates a UUID parameter and returns it as UUID type or null if invalid
8
+ */
9
+ export declare const validateAgentId: (agentId: string) => UUID | null;
10
+ /**
11
+ * Validates a room ID parameter
12
+ */
13
+ export declare const validateRoomId: (roomId: string) => UUID | null;
14
+ /**
15
+ * Enhanced channel ID validation with security logging
16
+ * Validates a channel ID parameter with additional security checks
17
+ */
18
+ export declare const validateChannelId: (channelId: string, clientIp?: string) => UUID | null;
19
+ /**
20
+ * Validates a memory ID parameter
21
+ */
22
+ export declare const validateMemoryId: (memoryId: string) => UUID | null;
23
+ /**
24
+ * Validates a world ID parameter
25
+ */
26
+ export declare const validateWorldId: (worldId: string) => UUID | null;
27
+ //# sourceMappingURL=validation.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"validation.d.ts","sourceRoot":"","sources":["../../../src/api/shared/validation.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,IAAI,EAAE,MAAM,eAAe,CAAC;AAGzD;;GAEG;AACH,eAAO,MAAM,UAAU,GAAI,QAAQ,GAAG,CAAC,IAAI,EAAE,aAAa,CAAC,EAAE,SAAS,IAAI,kBAMzE,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,eAAe,GAAI,SAAS,MAAM,KAAG,IAAI,GAAG,IAExD,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,cAAc,GAAI,QAAQ,MAAM,KAAG,IAAI,GAAG,IAEtD,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,iBAAiB,GAAI,WAAW,MAAM,EAAE,WAAW,MAAM,KAAG,IAAI,GAAG,IAwB/E,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,gBAAgB,GAAI,UAAU,MAAM,KAAG,IAAI,GAAG,IAE1D,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,eAAe,GAAI,SAAS,MAAM,KAAG,IAAI,GAAG,IAExD,CAAC"}
@@ -0,0 +1,24 @@
1
+ import express from 'express';
2
+ export type EnvVars = Record<string, string>;
3
+ /**
4
+ * Parse an .env file and return the key-value pairs
5
+ * @param filePath Path to the .env file
6
+ * @returns Object containing the key-value pairs
7
+ */
8
+ export declare function parseEnvFile(filePath: string): Promise<EnvVars>;
9
+ /**
10
+ * Resolves the path to the nearest `.env` file.
11
+ *
12
+ * If no `.env` file is found when traversing up from the starting directory,
13
+ * a path to `.env` in the starting directory is returned.
14
+ *
15
+ * @param startDir - The directory to start searching from. Defaults to the
16
+ * current working directory.
17
+ * @returns The resolved path to the `.env` file.
18
+ */
19
+ export declare function resolveEnvFile(startDir?: string): string;
20
+ /**
21
+ * Environment configuration management
22
+ */
23
+ export declare function createEnvironmentRouter(): express.Router;
24
+ //# sourceMappingURL=environment.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"environment.d.ts","sourceRoot":"","sources":["../../../src/api/system/environment.ts"],"names":[],"mappings":"AACA,OAAO,OAAO,MAAM,SAAS,CAAC;AAM9B,MAAM,MAAM,OAAO,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;AAE7C;;;;GAIG;AACH,wBAAsB,YAAY,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAgBrE;AAaD;;;;;;;;;GASG;AACH,wBAAgB,cAAc,CAAC,QAAQ,GAAE,MAAsB,GAAG,MAAM,CAiBvE;AAED;;GAEG;AACH,wBAAgB,uBAAuB,IAAI,OAAO,CAAC,MAAM,CAgFxD"}
@@ -0,0 +1,6 @@
1
+ import express from 'express';
2
+ /**
3
+ * Creates the system router for configuration and environment management
4
+ */
5
+ export declare function systemRouter(): express.Router;
6
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/api/system/index.ts"],"names":[],"mappings":"AAAA,OAAO,OAAO,MAAM,SAAS,CAAC;AAI9B;;GAEG;AACH,wBAAgB,YAAY,IAAI,OAAO,CAAC,MAAM,CAU7C"}
@@ -0,0 +1,6 @@
1
+ import express from 'express';
2
+ /**
3
+ * Creates the version router for system version information
4
+ */
5
+ export declare function createVersionRouter(): express.Router;
6
+ //# sourceMappingURL=version.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"version.d.ts","sourceRoot":"","sources":["../../../src/api/system/version.ts"],"names":[],"mappings":"AAAA,OAAO,OAAO,MAAM,SAAS,CAAC;AAwC9B;;GAEG;AACH,wBAAgB,mBAAmB,IAAI,OAAO,CAAC,MAAM,CAYpD"}
@@ -0,0 +1,6 @@
1
+ import express from 'express';
2
+ /**
3
+ * Creates the security router for TEE and security operations
4
+ */
5
+ export declare function teeRouter(): express.Router;
6
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/api/tee/index.ts"],"names":[],"mappings":"AAAA,OAAO,OAAO,MAAM,SAAS,CAAC;AAG9B;;GAEG;AACH,wBAAgB,SAAS,IAAI,OAAO,CAAC,MAAM,CAO1C"}
@@ -0,0 +1 @@
1
+ //# sourceMappingURL=tee.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tee.d.ts","sourceRoot":"","sources":["../../../src/api/tee/tee.ts"],"names":[],"mappings":""}
@@ -0,0 +1,16 @@
1
+ import { type Request, type Response, type NextFunction } from 'express';
2
+ /**
3
+ * Express middleware for validating API Key authentication based on an environment variable.
4
+ *
5
+ * If the ELIZA_SERVER_AUTH_TOKEN environment variable is set, this middleware
6
+ * checks for a matching 'X-API-KEY' header in incoming requests.
7
+ *
8
+ * If the environment variable is *not* set, the middleware allows all requests
9
+ * to pass through without authentication checks.
10
+ *
11
+ * @param req - Express request object.
12
+ * @param res - Express response object.
13
+ * @param next - Express next function.
14
+ */
15
+ export declare function apiKeyAuthMiddleware(req: Request, res: Response, next: NextFunction): void | Response<any, Record<string, any>>;
16
+ //# sourceMappingURL=authMiddleware.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"authMiddleware.d.ts","sourceRoot":"","sources":["../src/authMiddleware.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,OAAO,EAAE,KAAK,QAAQ,EAAE,KAAK,YAAY,EAAE,MAAM,SAAS,CAAC;AAGzE;;;;;;;;;;;;GAYG;AACH,wBAAgB,oBAAoB,CAAC,GAAG,EAAE,OAAO,EAAE,GAAG,EAAE,QAAQ,EAAE,IAAI,EAAE,YAAY,6CAsBnF"}
package/dist/bus.d.ts ADDED
@@ -0,0 +1,31 @@
1
+ /**
2
+ * A simple in-memory message bus for distributing messages from the server
3
+ * to subscribed MessageBusService instances within the same process.
4
+ *
5
+ * For multi-process or multi-server deployments, this would need to be replaced
6
+ * with a more robust solution like Redis Pub/Sub, Kafka, RabbitMQ, etc.
7
+ *
8
+ * Uses Bun-native EventTarget internally but maintains EventEmitter-like API.
9
+ *
10
+ * NOTE: This implementation uses a class extending EventTarget rather than functional
11
+ * patterns because EventTarget is a native browser/Bun API that requires class inheritance.
12
+ * This is an intentional architectural decision to leverage Bun's native capabilities
13
+ * instead of Node.js EventEmitter for better compatibility.
14
+ *
15
+ * NOTE: Unlike standard EventEmitter, this implementation prevents duplicate handler
16
+ * registration. This is an intentional design choice to prevent memory leaks and
17
+ * unintended multiple executions of the same handler.
18
+ */
19
+ declare class InternalMessageBus extends EventTarget {
20
+ private _maxListeners;
21
+ private handlers;
22
+ emit(event: string, data: unknown): boolean;
23
+ on(event: string, handler: (data: unknown) => void): this;
24
+ off(event: string, handler: (data: unknown) => void): void;
25
+ getMaxListeners(): number;
26
+ setMaxListeners(n: number): void;
27
+ removeAllListeners(event?: string): void;
28
+ }
29
+ declare const internalMessageBus: InternalMessageBus;
30
+ export default internalMessageBus;
31
+ //# sourceMappingURL=bus.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"bus.d.ts","sourceRoot":"","sources":["../src/bus.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AACH,cAAM,kBAAmB,SAAQ,WAAW;IAC1C,OAAO,CAAC,aAAa,CAAc;IACnC,OAAO,CAAC,QAAQ,CAAkE;IAElF,IAAI,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,OAAO,GAAG,OAAO;IAI3C,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,CAAC,IAAI,EAAE,OAAO,KAAK,IAAI,GAAG,IAAI;IA6BzD,GAAG,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,CAAC,IAAI,EAAE,OAAO,KAAK,IAAI;IAenD,eAAe,IAAI,MAAM;IAIzB,eAAe,CAAC,CAAC,EAAE,MAAM;IAMzB,kBAAkB,CAAC,KAAK,CAAC,EAAE,MAAM;CAoBlC;AAED,QAAA,MAAM,kBAAkB,oBAA2B,CAAC;AAKpD,eAAe,kBAAkB,CAAC"}
package/dist/index.d.ts CHANGED
@@ -1,262 +1,16 @@
1
- import { UUID, ChannelType, Character, DatabaseAdapter, IAgentRuntime } from '@elizaos/core';
1
+ import { type Character, DatabaseAdapter, type IAgentRuntime, type UUID } from '@elizaos/core';
2
2
  import express from 'express';
3
3
  import http from 'node:http';
4
- import { Server } from 'socket.io';
5
-
6
- /**
7
- * Session timeout configuration
8
- */
9
- interface SessionTimeoutConfig {
10
- /** Timeout in minutes. If not specified, uses agent or global default */
11
- timeoutMinutes?: number;
12
- /** Whether to auto-renew the session on activity */
13
- autoRenew?: boolean;
14
- /** Maximum session duration in minutes (even with renewals) */
15
- maxDurationMinutes?: number;
16
- /** Warning threshold in minutes before timeout */
17
- warningThresholdMinutes?: number;
18
- }
19
- /**
20
- * Metadata associated with a session
21
- */
22
- interface SessionMetadata {
23
- platform?: string;
24
- username?: string;
25
- discriminator?: string;
26
- avatar?: string;
27
- [key: string]: string | number | boolean | undefined;
28
- }
29
- /**
30
- * Represents a messaging session between a user and an agent
31
- */
32
- interface Session {
33
- id: string;
34
- agentId: UUID;
35
- channelId: UUID;
36
- userId: UUID;
37
- metadata: SessionMetadata;
38
- createdAt: Date;
39
- lastActivity: Date;
40
- /** Session expiration time */
41
- expiresAt: Date;
42
- /** Session timeout configuration */
43
- timeoutConfig: SessionTimeoutConfig;
44
- /** Number of times the session has been renewed */
45
- renewalCount: number;
46
- /** Whether a warning has been sent about upcoming expiration */
47
- warningState?: {
48
- sent: boolean;
49
- sentAt?: Date;
50
- };
51
- }
52
- /**
53
- * Request body for creating a session
54
- */
55
- interface CreateSessionRequest {
56
- agentId: string;
57
- userId: string;
58
- metadata?: SessionMetadata;
59
- /** Optional timeout configuration for this session */
60
- timeoutConfig?: SessionTimeoutConfig;
61
- }
62
- /**
63
- * Response for session creation
64
- */
65
- interface CreateSessionResponse {
66
- sessionId: string;
67
- agentId: UUID;
68
- userId: UUID;
69
- createdAt: Date;
70
- metadata: SessionMetadata;
71
- /** When the session will expire */
72
- expiresAt: Date;
73
- /** Session timeout configuration */
74
- timeoutConfig: SessionTimeoutConfig;
75
- }
76
- /**
77
- * Request body for sending a message
78
- */
79
- interface SendMessageRequest {
80
- content: string;
81
- attachments?: Array<{
82
- type: string;
83
- url: string;
84
- name?: string;
85
- }>;
86
- metadata?: Record<string, any>;
87
- }
88
- /**
89
- * Query parameters for retrieving messages
90
- */
91
- interface GetMessagesQuery {
92
- limit?: string;
93
- before?: string;
94
- after?: string;
95
- }
96
- /**
97
- * Simplified message format for API responses
98
- */
99
- interface SimplifiedMessage {
100
- id: string;
101
- content: string;
102
- authorId: string;
103
- isAgent: boolean;
104
- createdAt: Date;
105
- metadata: {
106
- thought?: string;
107
- actions?: string[];
108
- [key: string]: any;
109
- };
110
- }
111
- /**
112
- * Response for message retrieval
113
- */
114
- interface GetMessagesResponse {
115
- messages: SimplifiedMessage[];
116
- hasMore: boolean;
117
- /** Pagination cursors for navigating through messages */
118
- cursors?: {
119
- /** Timestamp to use for getting older messages (pagination backward) */
120
- before?: number;
121
- /** Timestamp to use for getting newer messages (pagination forward) */
122
- after?: number;
123
- };
124
- }
125
- /**
126
- * Session info response
127
- */
128
- interface SessionInfoResponse {
129
- sessionId: string;
130
- agentId: UUID;
131
- userId: UUID;
132
- createdAt: Date;
133
- lastActivity: Date;
134
- metadata: SessionMetadata;
135
- /** When the session will expire */
136
- expiresAt: Date;
137
- /** Session timeout configuration */
138
- timeoutConfig: SessionTimeoutConfig;
139
- /** Number of times the session has been renewed */
140
- renewalCount: number;
141
- /** Time remaining in milliseconds */
142
- timeRemaining: number;
143
- /** Whether the session is near expiration */
144
- isNearExpiration: boolean;
145
- }
146
- /**
147
- * Health check response
148
- */
149
- interface HealthCheckResponse {
150
- status: 'healthy' | 'unhealthy';
151
- activeSessions: number;
152
- timestamp: string;
153
- }
154
-
155
- interface MessageServer {
156
- id: UUID;
157
- name: string;
158
- sourceType: string;
159
- sourceId?: string;
160
- metadata?: Record<string, any>;
161
- createdAt: Date;
162
- updatedAt: Date;
163
- }
164
- interface MessageChannel {
165
- id: UUID;
166
- messageServerId: UUID;
167
- name: string;
168
- type: ChannelType;
169
- sourceType?: string;
170
- sourceId?: string;
171
- topic?: string;
172
- metadata?: Record<string, any>;
173
- createdAt: Date;
174
- updatedAt: Date;
175
- }
176
- interface CentralRootMessage {
177
- id: UUID;
178
- channelId: UUID;
179
- authorId: UUID;
180
- content: string;
181
- rawMessage?: any;
182
- inReplyToRootMessageId?: UUID;
183
- sourceType?: string;
184
- sourceId?: string;
185
- createdAt: Date;
186
- updatedAt: Date;
187
- metadata?: Record<string, any>;
188
- }
189
- interface MessageServiceStructure {
190
- id: UUID;
191
- channel_id: UUID;
192
- server_id: UUID;
193
- author_id: UUID;
194
- author_display_name?: string;
195
- content: string;
196
- raw_message?: any;
197
- source_id?: string;
198
- source_type?: string;
199
- in_reply_to_message_id?: UUID;
200
- created_at: number;
201
- metadata?: any;
202
- }
203
-
204
- /**
205
- * Attempts to load a file from the given file path.
206
- *
207
- * @param {string} filePath - The path to the file to load.
208
- * @returns {string | null} The contents of the file as a string, or null if an error occurred.
209
- * @throws {Error} If an error occurs while loading the file.
210
- */
211
- declare function tryLoadFile(filePath: string): string | null;
212
- /**
213
- * Load characters from a specified URL and return them as an array of Character objects.
214
- * @param {string} url - The URL from which to load character data.
215
- * @returns {Promise<Character[]>} - A promise that resolves with an array of Character objects.
216
- */
217
- declare function loadCharactersFromUrl(url: string): Promise<Character[]>;
218
- /**
219
- * Converts a JSON object representing a character into a validated Character object with additional settings and secrets.
220
- *
221
- * @param {unknown} character - The input data representing a character.
222
- * @returns {Promise<Character>} - A Promise that resolves to a validated Character object.
223
- * @throws {Error} If character validation fails.
224
- */
225
- declare function jsonToCharacter(character: unknown): Promise<Character>;
226
- /**
227
- * Loads a character from the specified file path with safe JSON parsing and validation.
228
- *
229
- * @param {string} filePath - The path to the character file.
230
- * @returns {Promise<Character>} A Promise that resolves to the validated Character object.
231
- * @throws {Error} If the character file is not found, has invalid JSON, or fails validation.
232
- */
233
- declare function loadCharacter(filePath: string): Promise<Character>;
234
- /**
235
- * Asynchronously loads a character from the specified path.
236
- * If the path is a URL, it loads the character from the URL.
237
- * If the path is a local file path, it tries multiple possible locations and
238
- * loads the character from the first valid location found.
239
- *
240
- * @param {string} characterPath - The path to load the character from.
241
- * @returns {Promise<Character>} A Promise that resolves to the loaded character.
242
- */
243
- declare function loadCharacterTryPath(characterPath: string): Promise<Character>;
244
- declare const hasValidRemoteUrls: () => boolean | "" | undefined;
245
- /**
246
- * Load characters from local paths or remote URLs based on configuration.
247
- * @param charactersArg - A comma-separated list of local file paths or remote URLs to load characters from.
248
- * @returns A promise that resolves to an array of loaded characters.
249
- */
250
- declare function loadCharacters(charactersArg: string): Promise<Character[]>;
251
-
4
+ import { Server as SocketIOServer } from 'socket.io';
5
+ import type { CentralRootMessage, MessageChannel, MessageServer } from './types.js';
252
6
  /**
253
7
  * Expands a file path starting with `~` to the project directory.
254
8
  *
255
9
  * @param filepath - The path to expand.
256
10
  * @returns The expanded path.
257
11
  */
258
- declare function expandTildePath(filepath: string): string;
259
- declare function resolvePgliteDir(dir?: string, fallbackDir?: string): string;
12
+ export declare function expandTildePath(filepath: string): string;
13
+ export declare function resolvePgliteDir(dir?: string, fallbackDir?: string): string;
260
14
  /**
261
15
  * Represents a function that acts as a server middleware.
262
16
  * @param {express.Request} req - The request object.
@@ -264,7 +18,7 @@ declare function resolvePgliteDir(dir?: string, fallbackDir?: string): string;
264
18
  * @param {express.NextFunction} next - The next function to be called in the middleware chain.
265
19
  * @returns {void}
266
20
  */
267
- type ServerMiddleware = (req: express.Request, res: express.Response, next: express.NextFunction) => void;
21
+ export type ServerMiddleware = (req: express.Request, res: express.Response, next: express.NextFunction) => void;
268
22
  /**
269
23
  * Interface for defining server configuration options.
270
24
  * @typedef {Object} ServerOptions
@@ -272,7 +26,7 @@ type ServerMiddleware = (req: express.Request, res: express.Response, next: expr
272
26
  * @property {string} [dataDir] - Optional directory for storing server data.
273
27
  * @property {string} [postgresUrl] - Optional URL for connecting to a PostgreSQL database.
274
28
  */
275
- interface ServerOptions {
29
+ export interface ServerOptions {
276
30
  middlewares?: ServerMiddleware[];
277
31
  dataDir?: string;
278
32
  postgresUrl?: string;
@@ -283,17 +37,17 @@ interface ServerOptions {
283
37
  *
284
38
  * @returns {boolean} - Returns true if UI should be enabled, false otherwise
285
39
  */
286
- declare function isWebUIEnabled(): boolean;
40
+ export declare function isWebUIEnabled(): boolean;
287
41
  /**
288
42
  * Class representing an agent server.
289
43
  */ /**
290
44
  * Represents an agent server which handles agents, database, and server functionalities.
291
45
  */
292
- declare class AgentServer {
46
+ export declare class AgentServer {
293
47
  app: express.Application;
294
48
  private agents;
295
49
  server: http.Server;
296
- socketIO: Server;
50
+ socketIO: SocketIOServer;
297
51
  isInitialized: boolean;
298
52
  private isWebUIEnabled;
299
53
  private clientPath?;
@@ -409,5 +163,6 @@ declare class AgentServer {
409
163
  */
410
164
  private registerSignalHandlers;
411
165
  }
412
-
413
- export { AgentServer, type CentralRootMessage, type CreateSessionRequest, type CreateSessionResponse, type GetMessagesQuery, type GetMessagesResponse, type HealthCheckResponse, type MessageChannel, type MessageServer, type MessageServiceStructure, type SendMessageRequest, type ServerMiddleware, type ServerOptions, type Session, type SessionInfoResponse, type SessionMetadata, type SessionTimeoutConfig, type SimplifiedMessage, expandTildePath, hasValidRemoteUrls, isWebUIEnabled, jsonToCharacter, loadCharacter, loadCharacterTryPath, loadCharacters, loadCharactersFromUrl, resolvePgliteDir, tryLoadFile };
166
+ export { tryLoadFile, loadCharactersFromUrl, jsonToCharacter, loadCharacter, loadCharacterTryPath, hasValidRemoteUrls, loadCharacters, } from './loader';
167
+ export * from './types';
168
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,SAAS,EACd,eAAe,EACf,KAAK,aAAa,EAElB,KAAK,IAAI,EAEV,MAAM,eAAe,CAAC;AAEvB,OAAO,OAA8B,MAAM,SAAS,CAAC;AAGrD,OAAO,IAAI,MAAM,WAAW,CAAC;AAI7B,OAAO,EAAE,MAAM,IAAI,cAAc,EAAE,MAAM,WAAW,CAA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