@elizaos/core 1.5.1 → 1.5.2

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 (88) hide show
  1. package/dist/browser/index.browser.js +120 -120
  2. package/dist/browser/index.browser.js.map +5 -21
  3. package/dist/browser/index.d.ts +3 -1
  4. package/dist/index.d.ts +2 -3
  5. package/dist/index.js +1 -5
  6. package/dist/node/index.d.ts +3 -1
  7. package/package.json +10 -4
  8. package/src/__tests__/action-chaining-simple.test.ts +203 -0
  9. package/src/__tests__/actions.test.ts +218 -0
  10. package/src/__tests__/buffer.test.ts +337 -0
  11. package/src/__tests__/character-validation.test.ts +309 -0
  12. package/src/__tests__/database.test.ts +750 -0
  13. package/src/__tests__/entities.test.ts +727 -0
  14. package/src/__tests__/env.test.ts +23 -0
  15. package/src/__tests__/environment.test.ts +285 -0
  16. package/src/__tests__/logger-browser-node.test.ts +716 -0
  17. package/src/__tests__/logger.test.ts +403 -0
  18. package/src/__tests__/messages.test.ts +196 -0
  19. package/src/__tests__/mockCharacter.ts +544 -0
  20. package/src/__tests__/parsing.test.ts +58 -0
  21. package/src/__tests__/prompts.test.ts +159 -0
  22. package/src/__tests__/roles.test.ts +331 -0
  23. package/src/__tests__/runtime-embedding.test.ts +343 -0
  24. package/src/__tests__/runtime.test.ts +978 -0
  25. package/src/__tests__/search.test.ts +15 -0
  26. package/src/__tests__/services-by-type.test.ts +204 -0
  27. package/src/__tests__/services.test.ts +136 -0
  28. package/src/__tests__/settings.test.ts +810 -0
  29. package/src/__tests__/utils.test.ts +1105 -0
  30. package/src/__tests__/uuid.test.ts +94 -0
  31. package/src/actions.ts +122 -0
  32. package/src/database.ts +579 -0
  33. package/src/entities.ts +406 -0
  34. package/src/index.browser.ts +48 -0
  35. package/src/index.node.ts +39 -0
  36. package/src/index.ts +50 -0
  37. package/src/logger.ts +527 -0
  38. package/src/prompts.ts +243 -0
  39. package/src/roles.ts +85 -0
  40. package/src/runtime.ts +2514 -0
  41. package/src/schemas/character.ts +149 -0
  42. package/src/search.ts +1543 -0
  43. package/src/sentry/instrument.browser.ts +65 -0
  44. package/src/sentry/instrument.node.ts +57 -0
  45. package/src/sentry/instrument.ts +82 -0
  46. package/src/services.ts +105 -0
  47. package/src/settings.ts +409 -0
  48. package/src/test_resources/constants.ts +12 -0
  49. package/src/test_resources/testSetup.ts +21 -0
  50. package/src/test_resources/types.ts +22 -0
  51. package/src/types/agent.ts +112 -0
  52. package/src/types/browser.ts +145 -0
  53. package/src/types/components.ts +184 -0
  54. package/src/types/database.ts +348 -0
  55. package/src/types/email.ts +162 -0
  56. package/src/types/environment.ts +129 -0
  57. package/src/types/events.ts +249 -0
  58. package/src/types/index.ts +29 -0
  59. package/src/types/knowledge.ts +65 -0
  60. package/src/types/lp.ts +124 -0
  61. package/src/types/memory.ts +228 -0
  62. package/src/types/message.ts +233 -0
  63. package/src/types/messaging.ts +57 -0
  64. package/src/types/model.ts +359 -0
  65. package/src/types/pdf.ts +77 -0
  66. package/src/types/plugin.ts +78 -0
  67. package/src/types/post.ts +271 -0
  68. package/src/types/primitives.ts +97 -0
  69. package/src/types/runtime.ts +190 -0
  70. package/src/types/service.ts +198 -0
  71. package/src/types/settings.ts +30 -0
  72. package/src/types/state.ts +60 -0
  73. package/src/types/task.ts +72 -0
  74. package/src/types/tee.ts +107 -0
  75. package/src/types/testing.ts +30 -0
  76. package/src/types/token.ts +96 -0
  77. package/src/types/transcription.ts +133 -0
  78. package/src/types/video.ts +108 -0
  79. package/src/types/wallet.ts +56 -0
  80. package/src/types/web-search.ts +146 -0
  81. package/src/utils/__tests__/buffer.test.ts +80 -0
  82. package/src/utils/__tests__/environment.test.ts +58 -0
  83. package/src/utils/__tests__/stringToUuid.test.ts +88 -0
  84. package/src/utils/buffer.ts +312 -0
  85. package/src/utils/environment.ts +316 -0
  86. package/src/utils/server-health.ts +117 -0
  87. package/src/utils.ts +1076 -0
  88. package/dist/tsconfig.build.tsbuildinfo +0 -1
@@ -0,0 +1,359 @@
1
+ import type { IAgentRuntime } from './runtime';
2
+
3
+ export type ModelTypeName = (typeof ModelType)[keyof typeof ModelType] | string;
4
+
5
+ /**
6
+ * Defines the recognized types of models that the agent runtime can use.
7
+ * These include models for text generation (small, large, reasoning, completion),
8
+ * text embedding, tokenization (encode/decode), image generation and description,
9
+ * audio transcription, text-to-speech, and generic object generation.
10
+ * This constant is used throughout the system, particularly in `AgentRuntime.useModel`,
11
+ * `AgentRuntime.registerModel`, and in `ModelParamsMap` / `ModelResultMap` to ensure
12
+ * type safety and clarity when working with different AI models.
13
+ * String values are used for extensibility with custom model types.
14
+ */
15
+ export const ModelType = {
16
+ SMALL: 'TEXT_SMALL', // kept for backwards compatibility
17
+ MEDIUM: 'TEXT_LARGE', // kept for backwards compatibility
18
+ LARGE: 'TEXT_LARGE', // kept for backwards compatibility
19
+ TEXT_SMALL: 'TEXT_SMALL',
20
+ TEXT_LARGE: 'TEXT_LARGE',
21
+ TEXT_EMBEDDING: 'TEXT_EMBEDDING',
22
+ TEXT_TOKENIZER_ENCODE: 'TEXT_TOKENIZER_ENCODE',
23
+ TEXT_TOKENIZER_DECODE: 'TEXT_TOKENIZER_DECODE',
24
+ TEXT_REASONING_SMALL: 'REASONING_SMALL',
25
+ TEXT_REASONING_LARGE: 'REASONING_LARGE',
26
+ TEXT_COMPLETION: 'TEXT_COMPLETION',
27
+ IMAGE: 'IMAGE',
28
+ IMAGE_DESCRIPTION: 'IMAGE_DESCRIPTION',
29
+ TRANSCRIPTION: 'TRANSCRIPTION',
30
+ TEXT_TO_SPEECH: 'TEXT_TO_SPEECH',
31
+ AUDIO: 'AUDIO',
32
+ VIDEO: 'VIDEO',
33
+ OBJECT_SMALL: 'OBJECT_SMALL',
34
+ OBJECT_LARGE: 'OBJECT_LARGE',
35
+ } as const;
36
+
37
+ /**
38
+ * Model configuration setting keys used in character settings.
39
+ * These constants define the keys for accessing model parameters
40
+ * from character configuration with support for per-model-type settings.
41
+ *
42
+ * Setting Precedence (highest to lowest):
43
+ * 1. Parameters passed directly to useModel()
44
+ * 2. Model-specific settings (e.g., TEXT_SMALL_TEMPERATURE)
45
+ * 3. Default settings (e.g., DEFAULT_TEMPERATURE)
46
+ *
47
+ * Example character settings:
48
+ * ```
49
+ * settings: {
50
+ * DEFAULT_TEMPERATURE: 0.7, // Applies to all models
51
+ * TEXT_SMALL_TEMPERATURE: 0.5, // Overrides default for TEXT_SMALL
52
+ * TEXT_LARGE_MAX_TOKENS: 4096, // Specific to TEXT_LARGE
53
+ * OBJECT_SMALL_TEMPERATURE: 0.3, // Specific to OBJECT_SMALL
54
+ * }
55
+ * ```
56
+ */
57
+ export const MODEL_SETTINGS = {
58
+ // Default settings - apply to all model types unless overridden
59
+ DEFAULT_MAX_TOKENS: 'DEFAULT_MAX_TOKENS',
60
+ DEFAULT_TEMPERATURE: 'DEFAULT_TEMPERATURE',
61
+ DEFAULT_FREQUENCY_PENALTY: 'DEFAULT_FREQUENCY_PENALTY',
62
+ DEFAULT_PRESENCE_PENALTY: 'DEFAULT_PRESENCE_PENALTY',
63
+
64
+ // TEXT_SMALL specific settings
65
+ TEXT_SMALL_MAX_TOKENS: 'TEXT_SMALL_MAX_TOKENS',
66
+ TEXT_SMALL_TEMPERATURE: 'TEXT_SMALL_TEMPERATURE',
67
+ TEXT_SMALL_FREQUENCY_PENALTY: 'TEXT_SMALL_FREQUENCY_PENALTY',
68
+ TEXT_SMALL_PRESENCE_PENALTY: 'TEXT_SMALL_PRESENCE_PENALTY',
69
+
70
+ // TEXT_LARGE specific settings
71
+ TEXT_LARGE_MAX_TOKENS: 'TEXT_LARGE_MAX_TOKENS',
72
+ TEXT_LARGE_TEMPERATURE: 'TEXT_LARGE_TEMPERATURE',
73
+ TEXT_LARGE_FREQUENCY_PENALTY: 'TEXT_LARGE_FREQUENCY_PENALTY',
74
+ TEXT_LARGE_PRESENCE_PENALTY: 'TEXT_LARGE_PRESENCE_PENALTY',
75
+
76
+ // OBJECT_SMALL specific settings
77
+ OBJECT_SMALL_MAX_TOKENS: 'OBJECT_SMALL_MAX_TOKENS',
78
+ OBJECT_SMALL_TEMPERATURE: 'OBJECT_SMALL_TEMPERATURE',
79
+ OBJECT_SMALL_FREQUENCY_PENALTY: 'OBJECT_SMALL_FREQUENCY_PENALTY',
80
+ OBJECT_SMALL_PRESENCE_PENALTY: 'OBJECT_SMALL_PRESENCE_PENALTY',
81
+
82
+ // OBJECT_LARGE specific settings
83
+ OBJECT_LARGE_MAX_TOKENS: 'OBJECT_LARGE_MAX_TOKENS',
84
+ OBJECT_LARGE_TEMPERATURE: 'OBJECT_LARGE_TEMPERATURE',
85
+ OBJECT_LARGE_FREQUENCY_PENALTY: 'OBJECT_LARGE_FREQUENCY_PENALTY',
86
+ OBJECT_LARGE_PRESENCE_PENALTY: 'OBJECT_LARGE_PRESENCE_PENALTY',
87
+
88
+ // Legacy keys for backwards compatibility (will be treated as defaults)
89
+ MODEL_MAX_TOKEN: 'MODEL_MAX_TOKEN',
90
+ MODEL_TEMPERATURE: 'MODEL_TEMPERATURE',
91
+ MODEL_FREQ_PENALTY: 'MODEL_FREQ_PENALTY',
92
+ MODEL_PRESENCE_PENALTY: 'MODEL_PRESENCE_PENALTY',
93
+ } as const;
94
+
95
+ /**
96
+ * Helper to get the model-specific setting key for a given model type and parameter.
97
+ * @param modelType The model type (e.g., TEXT_SMALL, TEXT_LARGE)
98
+ * @param param The parameter name (e.g., MAX_TOKENS, TEMPERATURE)
99
+ * @returns The appropriate setting key or null if not a supported model type
100
+ */
101
+ export function getModelSpecificSettingKey(
102
+ modelType: ModelTypeName,
103
+ param: 'MAX_TOKENS' | 'TEMPERATURE' | 'FREQUENCY_PENALTY' | 'PRESENCE_PENALTY'
104
+ ): string | null {
105
+ const supportedModelTypes = ['TEXT_SMALL', 'TEXT_LARGE', 'OBJECT_SMALL', 'OBJECT_LARGE'];
106
+
107
+ if (!supportedModelTypes.includes(modelType)) {
108
+ return null;
109
+ }
110
+
111
+ return `${modelType}_${param}`;
112
+ }
113
+
114
+ /**
115
+ * Parameters for generating text using a language model.
116
+ * This structure is typically passed to `AgentRuntime.useModel` when the `modelType` is one of
117
+ * `ModelType.TEXT_SMALL`, `ModelType.TEXT_LARGE`, `ModelType.TEXT_REASONING_SMALL`,
118
+ * `ModelType.TEXT_REASONING_LARGE`, or `ModelType.TEXT_COMPLETION`.
119
+ * It includes essential information like the prompt, model type, and various generation controls.
120
+ */
121
+ export type GenerateTextParams = {
122
+ /** The `AgentRuntime` instance, providing access to models and other services. */
123
+ runtime: IAgentRuntime;
124
+ /** The input string or prompt that the language model will use to generate text. */
125
+ prompt: string;
126
+ /** Specifies the type of text generation model to use (e.g., TEXT_LARGE, REASONING_SMALL). */
127
+ modelType: ModelTypeName;
128
+ /** Optional. The maximum number of tokens to generate in the response. */
129
+ maxTokens?: number;
130
+ /** Optional. Controls randomness (0.0-1.0). Lower values are more deterministic, higher are more creative. */
131
+ temperature?: number;
132
+ /** Optional. Penalizes new tokens based on their existing frequency in the text so far. */
133
+ frequencyPenalty?: number;
134
+ /** Optional. Penalizes new tokens based on whether they appear in the text so far. */
135
+ presencePenalty?: number;
136
+ /** Optional. A list of sequences at which the model will stop generating further tokens. */
137
+ stopSequences?: string[];
138
+ };
139
+
140
+ /**
141
+ * Parameters for detokenizing text, i.e., converting a sequence of numerical tokens back into a string.
142
+ * This is the reverse operation of tokenization.
143
+ * This structure is used with `AgentRuntime.useModel` when the `modelType` is `ModelType.TEXT_TOKENIZER_DECODE`.
144
+ */
145
+ export interface DetokenizeTextParams {
146
+ /** An array of numerical tokens to be converted back into text. */
147
+ tokens: number[];
148
+ /** The model type used for detokenization, ensuring consistency with the original tokenization. */
149
+ modelType: ModelTypeName;
150
+ }
151
+
152
+ /**
153
+ * Base parameters common to all model types
154
+ */
155
+ export interface BaseModelParams {
156
+ /** The agent runtime for accessing services and utilities */
157
+ runtime: IAgentRuntime;
158
+ }
159
+
160
+ /**
161
+ * Parameters for text generation models
162
+ */
163
+ export interface TextGenerationParams extends BaseModelParams {
164
+ /** The prompt to generate text from */
165
+ prompt: string;
166
+ /** Model temperature (0.0 to 1.0, lower is more deterministic) */
167
+ temperature?: number;
168
+ /** Maximum number of tokens to generate */
169
+ maxTokens?: number;
170
+ /** Sequences that should stop generation when encountered */
171
+ stopSequences?: string[];
172
+ /** Frequency penalty to apply */
173
+ frequencyPenalty?: number;
174
+ /** Presence penalty to apply */
175
+ presencePenalty?: number;
176
+ }
177
+
178
+ /**
179
+ * Parameters for text embedding models
180
+ */
181
+ export interface TextEmbeddingParams extends BaseModelParams {
182
+ /** The text to create embeddings for */
183
+ text: string;
184
+ }
185
+
186
+ /**
187
+ * Parameters for text tokenization models
188
+ */
189
+ export interface TokenizeTextParams extends BaseModelParams {
190
+ /** The text to tokenize */
191
+ prompt: string;
192
+ /** The model type to use for tokenization */
193
+ modelType: ModelTypeName;
194
+ }
195
+
196
+ /**
197
+ * Parameters for image generation models
198
+ */
199
+ export interface ImageGenerationParams extends BaseModelParams {
200
+ /** The prompt describing the image to generate */
201
+ prompt: string;
202
+ /** The dimensions of the image to generate */
203
+ size?: string;
204
+ /** Number of images to generate */
205
+ count?: number;
206
+ }
207
+
208
+ /**
209
+ * Parameters for image description models
210
+ */
211
+ export interface ImageDescriptionParams extends BaseModelParams {
212
+ /** The URL or path of the image to describe */
213
+ imageUrl: string;
214
+ /** Optional prompt to guide the description */
215
+ prompt?: string;
216
+ }
217
+
218
+ /**
219
+ * Parameters for transcription models
220
+ */
221
+ export interface TranscriptionParams extends BaseModelParams {
222
+ /** The URL or path of the audio file to transcribe */
223
+ audioUrl: string;
224
+ /** Optional prompt to guide transcription */
225
+ prompt?: string;
226
+ }
227
+
228
+ /**
229
+ * Parameters for text-to-speech models
230
+ */
231
+ export interface TextToSpeechParams extends BaseModelParams {
232
+ /** The text to convert to speech */
233
+ text: string;
234
+ /** The voice to use */
235
+ voice?: string;
236
+ /** The speaking speed */
237
+ speed?: number;
238
+ }
239
+
240
+ /**
241
+ * Parameters for audio processing models
242
+ */
243
+ export interface AudioProcessingParams extends BaseModelParams {
244
+ /** The URL or path of the audio file to process */
245
+ audioUrl: string;
246
+ /** The type of audio processing to perform */
247
+ processingType: string;
248
+ }
249
+
250
+ /**
251
+ * Parameters for video processing models
252
+ */
253
+ export interface VideoProcessingParams extends BaseModelParams {
254
+ /** The URL or path of the video file to process */
255
+ videoUrl: string;
256
+ /** The type of video processing to perform */
257
+ processingType: string;
258
+ }
259
+
260
+ /**
261
+ * Optional JSON schema for validating generated objects
262
+ */
263
+ export type JSONSchema = {
264
+ type: string;
265
+ properties?: Record<string, any>;
266
+ required?: string[];
267
+ items?: JSONSchema;
268
+ [key: string]: any;
269
+ };
270
+
271
+ /**
272
+ * Parameters for object generation models
273
+ * @template T - The expected return type, inferred from schema if provided
274
+ */
275
+ export interface ObjectGenerationParams extends BaseModelParams {
276
+ /** The prompt describing the object to generate */
277
+ prompt: string;
278
+ /** Optional JSON schema for validation */
279
+ schema?: JSONSchema;
280
+ /** Type of object to generate */
281
+ output?: 'object' | 'array' | 'enum';
282
+ /** For enum type, the allowed values */
283
+ enumValues?: string[];
284
+ /** Model type to use */
285
+ modelType?: ModelTypeName;
286
+ /** Model temperature (0.0 to 1.0) */
287
+ temperature?: number;
288
+ /** Sequences that should stop generation */
289
+ stopSequences?: string[];
290
+ }
291
+
292
+ /**
293
+ * Map of model types to their parameter types
294
+ */
295
+ export interface ModelParamsMap {
296
+ [ModelType.TEXT_SMALL]: TextGenerationParams;
297
+ [ModelType.TEXT_LARGE]: TextGenerationParams;
298
+ [ModelType.TEXT_EMBEDDING]: TextEmbeddingParams | string | null;
299
+ [ModelType.TEXT_TOKENIZER_ENCODE]: TokenizeTextParams;
300
+ [ModelType.TEXT_TOKENIZER_DECODE]: DetokenizeTextParams;
301
+ [ModelType.TEXT_REASONING_SMALL]: TextGenerationParams;
302
+ [ModelType.TEXT_REASONING_LARGE]: TextGenerationParams;
303
+ [ModelType.IMAGE]: ImageGenerationParams;
304
+ [ModelType.IMAGE_DESCRIPTION]: ImageDescriptionParams | string;
305
+ [ModelType.TRANSCRIPTION]: TranscriptionParams | Buffer | string;
306
+ [ModelType.TEXT_TO_SPEECH]: TextToSpeechParams | string;
307
+ [ModelType.AUDIO]: AudioProcessingParams;
308
+ [ModelType.VIDEO]: VideoProcessingParams;
309
+ [ModelType.OBJECT_SMALL]: ObjectGenerationParams;
310
+ [ModelType.OBJECT_LARGE]: ObjectGenerationParams;
311
+ // Allow string index for custom model types
312
+ [key: string]: BaseModelParams | any;
313
+ }
314
+
315
+ /**
316
+ * Map of model types to their return value types
317
+ */
318
+ export interface ModelResultMap {
319
+ [ModelType.TEXT_SMALL]: string;
320
+ [ModelType.TEXT_LARGE]: string;
321
+ [ModelType.TEXT_EMBEDDING]: number[];
322
+ [ModelType.TEXT_TOKENIZER_ENCODE]: number[];
323
+ [ModelType.TEXT_TOKENIZER_DECODE]: string;
324
+ [ModelType.TEXT_REASONING_SMALL]: string;
325
+ [ModelType.TEXT_REASONING_LARGE]: string;
326
+ [ModelType.IMAGE]: { url: string }[];
327
+ [ModelType.IMAGE_DESCRIPTION]: { title: string; description: string };
328
+ [ModelType.TRANSCRIPTION]: string;
329
+ [ModelType.TEXT_TO_SPEECH]: any | Buffer;
330
+ [ModelType.AUDIO]: any; // Specific return type depends on processing type
331
+ [ModelType.VIDEO]: any; // Specific return type depends on processing type
332
+ [ModelType.OBJECT_SMALL]: any;
333
+ [ModelType.OBJECT_LARGE]: any;
334
+ // Allow string index for custom model types
335
+ [key: string]: any;
336
+ }
337
+
338
+ /**
339
+ * Defines the structure for a model handler registration within the `AgentRuntime`.
340
+ * Each model (e.g., for text generation, embedding) is associated with a handler function,
341
+ * the name of the provider (plugin or system) that registered it, and an optional priority.
342
+ * The `priority` (higher is more preferred) helps in selecting which handler to use if multiple
343
+ * handlers are registered for the same model type. The `registrationOrder` (not in type, but used in runtime)
344
+ * serves as a tie-breaker. See `AgentRuntime.registerModel` and `AgentRuntime.getModel`.
345
+ */
346
+ export interface ModelHandler {
347
+ /** The function that executes the model, taking runtime and parameters, and returning a Promise. */
348
+ handler: (runtime: IAgentRuntime, params: Record<string, unknown>) => Promise<unknown>;
349
+ /** The name of the provider (e.g., plugin name) that registered this model handler. */
350
+ provider: string;
351
+ /**
352
+ * Optional priority for this model handler. Higher numbers indicate higher priority.
353
+ * This is used by `AgentRuntime.getModel` to select the most appropriate handler
354
+ * when multiple are available for a given model type. Defaults to 0 if not specified.
355
+ */
356
+ priority?: number; // Optional priority for selection order
357
+
358
+ registrationOrder?: number;
359
+ }
@@ -0,0 +1,77 @@
1
+ import { Service, ServiceType } from './service';
2
+
3
+ export interface PdfExtractionResult {
4
+ text: string;
5
+ pageCount: number;
6
+ metadata?: {
7
+ title?: string;
8
+ author?: string;
9
+ createdAt?: Date;
10
+ modifiedAt?: Date;
11
+ };
12
+ }
13
+
14
+ export interface PdfGenerationOptions {
15
+ format?: 'A4' | 'A3' | 'Letter';
16
+ orientation?: 'portrait' | 'landscape';
17
+ margins?: {
18
+ top?: number;
19
+ bottom?: number;
20
+ left?: number;
21
+ right?: number;
22
+ };
23
+ header?: string;
24
+ footer?: string;
25
+ }
26
+
27
+ export interface PdfConversionOptions {
28
+ quality?: 'high' | 'medium' | 'low';
29
+ outputFormat?: 'pdf' | 'pdf/a';
30
+ compression?: boolean;
31
+ }
32
+
33
+ /**
34
+ * Interface for PDF processing services
35
+ */
36
+ export abstract class IPdfService extends Service {
37
+ static override readonly serviceType = ServiceType.PDF;
38
+
39
+ public readonly capabilityDescription = 'PDF processing, extraction, and generation capabilities';
40
+
41
+ /**
42
+ * Extract text and metadata from a PDF file
43
+ * @param pdfPath - Path to the PDF file or buffer
44
+ * @returns Promise resolving to extracted text and metadata
45
+ */
46
+ abstract extractText(pdfPath: string | Buffer): Promise<PdfExtractionResult>;
47
+
48
+ /**
49
+ * Generate a PDF from HTML content
50
+ * @param htmlContent - HTML content to convert to PDF
51
+ * @param options - PDF generation options
52
+ * @returns Promise resolving to PDF buffer
53
+ */
54
+ abstract generatePdf(htmlContent: string, options?: PdfGenerationOptions): Promise<Buffer>;
55
+
56
+ /**
57
+ * Convert a document to PDF format
58
+ * @param filePath - Path to the document file
59
+ * @param options - Conversion options
60
+ * @returns Promise resolving to PDF buffer
61
+ */
62
+ abstract convertToPdf(filePath: string, options?: PdfConversionOptions): Promise<Buffer>;
63
+
64
+ /**
65
+ * Merge multiple PDF files into one
66
+ * @param pdfPaths - Array of PDF file paths or buffers
67
+ * @returns Promise resolving to merged PDF buffer
68
+ */
69
+ abstract mergePdfs(pdfPaths: (string | Buffer)[]): Promise<Buffer>;
70
+
71
+ /**
72
+ * Split a PDF into individual pages
73
+ * @param pdfPath - Path to the PDF file or buffer
74
+ * @returns Promise resolving to array of page buffers
75
+ */
76
+ abstract splitPdf(pdfPath: string | Buffer): Promise<Buffer[]>;
77
+ }
@@ -0,0 +1,78 @@
1
+ import type { Character } from './agent';
2
+ import type { Action, Evaluator, Provider } from './components';
3
+ import type { IDatabaseAdapter } from './database';
4
+ import type { EventHandler, EventPayloadMap } from './events';
5
+ import type { IAgentRuntime } from './runtime';
6
+ import type { Service } from './service';
7
+ import type { TestSuite } from './testing';
8
+
9
+ export type Route = {
10
+ type: 'GET' | 'POST' | 'PUT' | 'DELETE' | 'STATIC';
11
+ path: string;
12
+ filePath?: string;
13
+ public?: boolean;
14
+ name?: string extends { public: true } ? string : string | undefined;
15
+ handler?: (req: any, res: any, runtime: IAgentRuntime) => Promise<void>;
16
+ isMultipart?: boolean; // Indicates if the route expects multipart/form-data (file uploads)
17
+ };
18
+
19
+ /**
20
+ * Plugin for extending agent functionality
21
+ */
22
+
23
+ export type PluginEvents = {
24
+ [K in keyof EventPayloadMap]?: EventHandler<K>[];
25
+ } & {
26
+ [key: string]: ((params: any) => Promise<any>)[];
27
+ };
28
+
29
+ export interface Plugin {
30
+ name: string;
31
+ description: string;
32
+
33
+ // Initialize plugin with runtime services
34
+ init?: (config: Record<string, string>, runtime: IAgentRuntime) => Promise<void>;
35
+
36
+ // Configuration
37
+ config?: { [key: string]: any };
38
+
39
+ services?: (typeof Service)[];
40
+
41
+ // Entity component definitions
42
+ componentTypes?: {
43
+ name: string;
44
+ schema: Record<string, unknown>;
45
+ validator?: (data: any) => boolean;
46
+ }[];
47
+
48
+ // Optional plugin features
49
+ actions?: Action[];
50
+ providers?: Provider[];
51
+ evaluators?: Evaluator[];
52
+ adapter?: IDatabaseAdapter;
53
+ models?: {
54
+ [key: string]: (...args: any[]) => Promise<any>;
55
+ };
56
+ events?: PluginEvents;
57
+ routes?: Route[];
58
+ tests?: TestSuite[];
59
+
60
+ dependencies?: string[];
61
+
62
+ testDependencies?: string[];
63
+
64
+ priority?: number;
65
+
66
+ schema?: any;
67
+ }
68
+
69
+ export interface ProjectAgent {
70
+ character: Character;
71
+ init?: (runtime: IAgentRuntime) => Promise<void>;
72
+ plugins?: Plugin[];
73
+ tests?: TestSuite | TestSuite[];
74
+ }
75
+
76
+ export interface Project {
77
+ agents: ProjectAgent[];
78
+ }