@elizaos/core 2.0.0-alpha.7 → 2.0.0-alpha.71

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 (132) hide show
  1. package/README.md +213 -16
  2. package/dist/testing/index.js +22 -0
  3. package/dist/testing/index.js.map +9 -0
  4. package/package.json +46 -27
  5. package/dist/actions.d.ts +0 -22
  6. package/dist/actions.d.ts.map +0 -1
  7. package/dist/browser/index.browser.js +0 -771
  8. package/dist/browser/index.browser.js.map +0 -427
  9. package/dist/browser/index.d.ts +0 -2
  10. package/dist/character.d.ts +0 -39
  11. package/dist/character.d.ts.map +0 -1
  12. package/dist/constants/index.d.ts +0 -7
  13. package/dist/constants/secrets.d.ts +0 -67
  14. package/dist/database.d.ts +0 -494
  15. package/dist/database.d.ts.map +0 -1
  16. package/dist/elizaos.d.ts +0 -194
  17. package/dist/elizaos.d.ts.map +0 -1
  18. package/dist/entities.d.ts +0 -40
  19. package/dist/entities.d.ts.map +0 -1
  20. package/dist/index.browser.d.ts +0 -39
  21. package/dist/index.browser.d.ts.map +0 -1
  22. package/dist/index.d.ts +0 -40
  23. package/dist/index.d.ts.map +0 -1
  24. package/dist/index.js +0 -2
  25. package/dist/index.node.d.ts +0 -37
  26. package/dist/index.node.d.ts.map +0 -1
  27. package/dist/logger.d.ts +0 -72
  28. package/dist/logger.d.ts.map +0 -1
  29. package/dist/memory.d.ts +0 -63
  30. package/dist/memory.d.ts.map +0 -1
  31. package/dist/node/index.d.ts +0 -2
  32. package/dist/node/index.node.js +0 -53403
  33. package/dist/node/index.node.js.map +0 -511
  34. package/dist/onboarding-state.d.ts +0 -209
  35. package/dist/plugin.d.ts +0 -55
  36. package/dist/plugin.d.ts.map +0 -1
  37. package/dist/prompts.d.ts +0 -7
  38. package/dist/prompts.d.ts.map +0 -1
  39. package/dist/request-context.d.ts +0 -142
  40. package/dist/request-context.d.ts.map +0 -1
  41. package/dist/request-context.node.d.ts +0 -36
  42. package/dist/request-context.node.d.ts.map +0 -1
  43. package/dist/roles.d.ts +0 -23
  44. package/dist/roles.d.ts.map +0 -1
  45. package/dist/runtime.d.ts +0 -366
  46. package/dist/runtime.d.ts.map +0 -1
  47. package/dist/schemas/character.d.ts +0 -151
  48. package/dist/schemas/character.d.ts.map +0 -1
  49. package/dist/search.d.ts +0 -316
  50. package/dist/search.d.ts.map +0 -1
  51. package/dist/secrets.d.ts +0 -11
  52. package/dist/secrets.d.ts.map +0 -1
  53. package/dist/services/default-message-service.d.ts +0 -69
  54. package/dist/services/default-message-service.d.ts.map +0 -1
  55. package/dist/services/message-service.d.ts +0 -171
  56. package/dist/services/message-service.d.ts.map +0 -1
  57. package/dist/services.d.ts +0 -56
  58. package/dist/services.d.ts.map +0 -1
  59. package/dist/sessions/index.d.ts +0 -10
  60. package/dist/sessions/paths.d.ts +0 -56
  61. package/dist/sessions/provider.d.ts +0 -73
  62. package/dist/sessions/session-key.d.ts +0 -133
  63. package/dist/sessions/store.d.ts +0 -75
  64. package/dist/sessions/types.d.ts +0 -195
  65. package/dist/settings.d.ts +0 -90
  66. package/dist/settings.d.ts.map +0 -1
  67. package/dist/streaming-context.browser.d.ts +0 -26
  68. package/dist/streaming-context.browser.d.ts.map +0 -1
  69. package/dist/streaming-context.d.ts +0 -95
  70. package/dist/streaming-context.d.ts.map +0 -1
  71. package/dist/streaming-context.node.d.ts +0 -15
  72. package/dist/streaming-context.node.d.ts.map +0 -1
  73. package/dist/types/agent.d.ts +0 -97
  74. package/dist/types/agent.d.ts.map +0 -1
  75. package/dist/types/components.d.ts +0 -155
  76. package/dist/types/components.d.ts.map +0 -1
  77. package/dist/types/database.d.ts +0 -414
  78. package/dist/types/database.d.ts.map +0 -1
  79. package/dist/types/elizaos.d.ts +0 -159
  80. package/dist/types/elizaos.d.ts.map +0 -1
  81. package/dist/types/environment.d.ts +0 -116
  82. package/dist/types/environment.d.ts.map +0 -1
  83. package/dist/types/events.d.ts +0 -203
  84. package/dist/types/events.d.ts.map +0 -1
  85. package/dist/types/index.d.ts +0 -20
  86. package/dist/types/index.d.ts.map +0 -1
  87. package/dist/types/knowledge.d.ts +0 -30
  88. package/dist/types/knowledge.d.ts.map +0 -1
  89. package/dist/types/memory.d.ts +0 -102
  90. package/dist/types/memory.d.ts.map +0 -1
  91. package/dist/types/messaging.d.ts +0 -137
  92. package/dist/types/messaging.d.ts.map +0 -1
  93. package/dist/types/model.d.ts +0 -513
  94. package/dist/types/model.d.ts.map +0 -1
  95. package/dist/types/plugin.d.ts +0 -91
  96. package/dist/types/plugin.d.ts.map +0 -1
  97. package/dist/types/primitives.d.ts +0 -96
  98. package/dist/types/primitives.d.ts.map +0 -1
  99. package/dist/types/runtime.d.ts +0 -140
  100. package/dist/types/runtime.d.ts.map +0 -1
  101. package/dist/types/service.d.ts +0 -150
  102. package/dist/types/service.d.ts.map +0 -1
  103. package/dist/types/settings.d.ts +0 -29
  104. package/dist/types/settings.d.ts.map +0 -1
  105. package/dist/types/state.d.ts +0 -56
  106. package/dist/types/state.d.ts.map +0 -1
  107. package/dist/types/streaming.d.ts +0 -71
  108. package/dist/types/streaming.d.ts.map +0 -1
  109. package/dist/types/task.d.ts +0 -67
  110. package/dist/types/task.d.ts.map +0 -1
  111. package/dist/types/tee.d.ts +0 -96
  112. package/dist/types/tee.d.ts.map +0 -1
  113. package/dist/types/testing.d.ts +0 -28
  114. package/dist/types/testing.d.ts.map +0 -1
  115. package/dist/utils/buffer.d.ts +0 -104
  116. package/dist/utils/buffer.d.ts.map +0 -1
  117. package/dist/utils/crypto-compat.d.ts +0 -183
  118. package/dist/utils/crypto-compat.d.ts.map +0 -1
  119. package/dist/utils/environment.d.ts +0 -50
  120. package/dist/utils/environment.d.ts.map +0 -1
  121. package/dist/utils/node.d.ts +0 -5
  122. package/dist/utils/node.d.ts.map +0 -1
  123. package/dist/utils/paths.d.ts +0 -92
  124. package/dist/utils/paths.d.ts.map +0 -1
  125. package/dist/utils/server-health.d.ts +0 -22
  126. package/dist/utils/server-health.d.ts.map +0 -1
  127. package/dist/utils/streaming.d.ts +0 -179
  128. package/dist/utils/streaming.d.ts.map +0 -1
  129. package/dist/utils/type-guards.d.ts +0 -23
  130. package/dist/utils/type-guards.d.ts.map +0 -1
  131. package/dist/utils.d.ts +0 -182
  132. package/dist/utils.d.ts.map +0 -1
@@ -1,513 +0,0 @@
1
- import type { IAgentRuntime } from './runtime';
2
- export type ModelTypeName = (typeof ModelType)[keyof typeof ModelType] | string;
3
- /**
4
- * Defines the recognized types of models that the agent runtime can use.
5
- * These include models for text generation (small, large, reasoning, completion),
6
- * text embedding, tokenization (encode/decode), image generation and description,
7
- * audio transcription, text-to-speech, and generic object generation.
8
- * This constant is used throughout the system, particularly in `AgentRuntime.useModel`,
9
- * `AgentRuntime.registerModel`, and in `ModelParamsMap` / `ModelResultMap` to ensure
10
- * type safety and clarity when working with different AI models.
11
- * String values are used for extensibility with custom model types.
12
- */
13
- export declare const ModelType: {
14
- readonly SMALL: "TEXT_SMALL";
15
- readonly MEDIUM: "TEXT_LARGE";
16
- readonly LARGE: "TEXT_LARGE";
17
- readonly TEXT_SMALL: "TEXT_SMALL";
18
- readonly TEXT_LARGE: "TEXT_LARGE";
19
- readonly TEXT_EMBEDDING: "TEXT_EMBEDDING";
20
- readonly TEXT_TOKENIZER_ENCODE: "TEXT_TOKENIZER_ENCODE";
21
- readonly TEXT_TOKENIZER_DECODE: "TEXT_TOKENIZER_DECODE";
22
- readonly TEXT_REASONING_SMALL: "REASONING_SMALL";
23
- readonly TEXT_REASONING_LARGE: "REASONING_LARGE";
24
- readonly TEXT_COMPLETION: "TEXT_COMPLETION";
25
- readonly IMAGE: "IMAGE";
26
- readonly IMAGE_DESCRIPTION: "IMAGE_DESCRIPTION";
27
- readonly TRANSCRIPTION: "TRANSCRIPTION";
28
- readonly TEXT_TO_SPEECH: "TEXT_TO_SPEECH";
29
- readonly AUDIO: "AUDIO";
30
- readonly VIDEO: "VIDEO";
31
- readonly OBJECT_SMALL: "OBJECT_SMALL";
32
- readonly OBJECT_LARGE: "OBJECT_LARGE";
33
- };
34
- /**
35
- * Union type of all text generation model types.
36
- * These models accept GenerateTextParams
37
- */
38
- export type TextGenerationModelType = typeof ModelType.TEXT_SMALL | typeof ModelType.TEXT_LARGE | typeof ModelType.TEXT_REASONING_SMALL | typeof ModelType.TEXT_REASONING_LARGE | typeof ModelType.TEXT_COMPLETION;
39
- /**
40
- * Model configuration setting keys used in character settings.
41
- * These constants define the keys for accessing model parameters
42
- * from character configuration with support for per-model-type settings.
43
- *
44
- * Setting Precedence (highest to lowest):
45
- * 1. Parameters passed directly to useModel()
46
- * 2. Model-specific settings (e.g., TEXT_SMALL_TEMPERATURE)
47
- * 3. Default settings (e.g., DEFAULT_TEMPERATURE)
48
- *
49
- * Example character settings:
50
- * ```
51
- * settings: {
52
- * DEFAULT_TEMPERATURE: 0.7, // Applies to all models
53
- * TEXT_SMALL_TEMPERATURE: 0.5, // Overrides default for TEXT_SMALL
54
- * TEXT_LARGE_MAX_TOKENS: 4096, // Specific to TEXT_LARGE
55
- * OBJECT_SMALL_TEMPERATURE: 0.3, // Specific to OBJECT_SMALL
56
- * }
57
- * ```
58
- */
59
- export declare const MODEL_SETTINGS: {
60
- readonly DEFAULT_MAX_TOKENS: "DEFAULT_MAX_TOKENS";
61
- readonly DEFAULT_TEMPERATURE: "DEFAULT_TEMPERATURE";
62
- readonly DEFAULT_TOP_P: "DEFAULT_TOP_P";
63
- readonly DEFAULT_TOP_K: "DEFAULT_TOP_K";
64
- readonly DEFAULT_MIN_P: "DEFAULT_MIN_P";
65
- readonly DEFAULT_SEED: "DEFAULT_SEED";
66
- readonly DEFAULT_REPETITION_PENALTY: "DEFAULT_REPETITION_PENALTY";
67
- readonly DEFAULT_FREQUENCY_PENALTY: "DEFAULT_FREQUENCY_PENALTY";
68
- readonly DEFAULT_PRESENCE_PENALTY: "DEFAULT_PRESENCE_PENALTY";
69
- readonly TEXT_SMALL_MAX_TOKENS: "TEXT_SMALL_MAX_TOKENS";
70
- readonly TEXT_SMALL_TEMPERATURE: "TEXT_SMALL_TEMPERATURE";
71
- readonly TEXT_SMALL_TOP_P: "TEXT_SMALL_TOP_P";
72
- readonly TEXT_SMALL_TOP_K: "TEXT_SMALL_TOP_K";
73
- readonly TEXT_SMALL_MIN_P: "TEXT_SMALL_MIN_P";
74
- readonly TEXT_SMALL_SEED: "TEXT_SMALL_SEED";
75
- readonly TEXT_SMALL_REPETITION_PENALTY: "TEXT_SMALL_REPETITION_PENALTY";
76
- readonly TEXT_SMALL_FREQUENCY_PENALTY: "TEXT_SMALL_FREQUENCY_PENALTY";
77
- readonly TEXT_SMALL_PRESENCE_PENALTY: "TEXT_SMALL_PRESENCE_PENALTY";
78
- readonly TEXT_LARGE_MAX_TOKENS: "TEXT_LARGE_MAX_TOKENS";
79
- readonly TEXT_LARGE_TEMPERATURE: "TEXT_LARGE_TEMPERATURE";
80
- readonly TEXT_LARGE_TOP_P: "TEXT_LARGE_TOP_P";
81
- readonly TEXT_LARGE_TOP_K: "TEXT_LARGE_TOP_K";
82
- readonly TEXT_LARGE_MIN_P: "TEXT_LARGE_MIN_P";
83
- readonly TEXT_LARGE_SEED: "TEXT_LARGE_SEED";
84
- readonly TEXT_LARGE_REPETITION_PENALTY: "TEXT_LARGE_REPETITION_PENALTY";
85
- readonly TEXT_LARGE_FREQUENCY_PENALTY: "TEXT_LARGE_FREQUENCY_PENALTY";
86
- readonly TEXT_LARGE_PRESENCE_PENALTY: "TEXT_LARGE_PRESENCE_PENALTY";
87
- readonly OBJECT_SMALL_MAX_TOKENS: "OBJECT_SMALL_MAX_TOKENS";
88
- readonly OBJECT_SMALL_TEMPERATURE: "OBJECT_SMALL_TEMPERATURE";
89
- readonly OBJECT_SMALL_TOP_P: "OBJECT_SMALL_TOP_P";
90
- readonly OBJECT_SMALL_TOP_K: "OBJECT_SMALL_TOP_K";
91
- readonly OBJECT_SMALL_MIN_P: "OBJECT_SMALL_MIN_P";
92
- readonly OBJECT_SMALL_SEED: "OBJECT_SMALL_SEED";
93
- readonly OBJECT_SMALL_REPETITION_PENALTY: "OBJECT_SMALL_REPETITION_PENALTY";
94
- readonly OBJECT_SMALL_FREQUENCY_PENALTY: "OBJECT_SMALL_FREQUENCY_PENALTY";
95
- readonly OBJECT_SMALL_PRESENCE_PENALTY: "OBJECT_SMALL_PRESENCE_PENALTY";
96
- readonly OBJECT_LARGE_MAX_TOKENS: "OBJECT_LARGE_MAX_TOKENS";
97
- readonly OBJECT_LARGE_TEMPERATURE: "OBJECT_LARGE_TEMPERATURE";
98
- readonly OBJECT_LARGE_TOP_P: "OBJECT_LARGE_TOP_P";
99
- readonly OBJECT_LARGE_TOP_K: "OBJECT_LARGE_TOP_K";
100
- readonly OBJECT_LARGE_MIN_P: "OBJECT_LARGE_MIN_P";
101
- readonly OBJECT_LARGE_SEED: "OBJECT_LARGE_SEED";
102
- readonly OBJECT_LARGE_REPETITION_PENALTY: "OBJECT_LARGE_REPETITION_PENALTY";
103
- readonly OBJECT_LARGE_FREQUENCY_PENALTY: "OBJECT_LARGE_FREQUENCY_PENALTY";
104
- readonly OBJECT_LARGE_PRESENCE_PENALTY: "OBJECT_LARGE_PRESENCE_PENALTY";
105
- readonly TEXT_REASONING_SMALL_MAX_TOKENS: "TEXT_REASONING_SMALL_MAX_TOKENS";
106
- readonly TEXT_REASONING_SMALL_TEMPERATURE: "TEXT_REASONING_SMALL_TEMPERATURE";
107
- readonly TEXT_REASONING_SMALL_TOP_P: "TEXT_REASONING_SMALL_TOP_P";
108
- readonly TEXT_REASONING_SMALL_TOP_K: "TEXT_REASONING_SMALL_TOP_K";
109
- readonly TEXT_REASONING_SMALL_MIN_P: "TEXT_REASONING_SMALL_MIN_P";
110
- readonly TEXT_REASONING_SMALL_SEED: "TEXT_REASONING_SMALL_SEED";
111
- readonly TEXT_REASONING_SMALL_REPETITION_PENALTY: "TEXT_REASONING_SMALL_REPETITION_PENALTY";
112
- readonly TEXT_REASONING_SMALL_FREQUENCY_PENALTY: "TEXT_REASONING_SMALL_FREQUENCY_PENALTY";
113
- readonly TEXT_REASONING_SMALL_PRESENCE_PENALTY: "TEXT_REASONING_SMALL_PRESENCE_PENALTY";
114
- readonly TEXT_REASONING_LARGE_MAX_TOKENS: "TEXT_REASONING_LARGE_MAX_TOKENS";
115
- readonly TEXT_REASONING_LARGE_TEMPERATURE: "TEXT_REASONING_LARGE_TEMPERATURE";
116
- readonly TEXT_REASONING_LARGE_TOP_P: "TEXT_REASONING_LARGE_TOP_P";
117
- readonly TEXT_REASONING_LARGE_TOP_K: "TEXT_REASONING_LARGE_TOP_K";
118
- readonly TEXT_REASONING_LARGE_MIN_P: "TEXT_REASONING_LARGE_MIN_P";
119
- readonly TEXT_REASONING_LARGE_SEED: "TEXT_REASONING_LARGE_SEED";
120
- readonly TEXT_REASONING_LARGE_REPETITION_PENALTY: "TEXT_REASONING_LARGE_REPETITION_PENALTY";
121
- readonly TEXT_REASONING_LARGE_FREQUENCY_PENALTY: "TEXT_REASONING_LARGE_FREQUENCY_PENALTY";
122
- readonly TEXT_REASONING_LARGE_PRESENCE_PENALTY: "TEXT_REASONING_LARGE_PRESENCE_PENALTY";
123
- readonly TEXT_COMPLETION_MAX_TOKENS: "TEXT_COMPLETION_MAX_TOKENS";
124
- readonly TEXT_COMPLETION_TEMPERATURE: "TEXT_COMPLETION_TEMPERATURE";
125
- readonly TEXT_COMPLETION_TOP_P: "TEXT_COMPLETION_TOP_P";
126
- readonly TEXT_COMPLETION_TOP_K: "TEXT_COMPLETION_TOP_K";
127
- readonly TEXT_COMPLETION_MIN_P: "TEXT_COMPLETION_MIN_P";
128
- readonly TEXT_COMPLETION_SEED: "TEXT_COMPLETION_SEED";
129
- readonly TEXT_COMPLETION_REPETITION_PENALTY: "TEXT_COMPLETION_REPETITION_PENALTY";
130
- readonly TEXT_COMPLETION_FREQUENCY_PENALTY: "TEXT_COMPLETION_FREQUENCY_PENALTY";
131
- readonly TEXT_COMPLETION_PRESENCE_PENALTY: "TEXT_COMPLETION_PRESENCE_PENALTY";
132
- readonly MODEL_MAX_TOKEN: "MODEL_MAX_TOKEN";
133
- readonly MODEL_TEMPERATURE: "MODEL_TEMPERATURE";
134
- readonly MODEL_FREQ_PENALTY: "MODEL_FREQ_PENALTY";
135
- readonly MODEL_PRESENCE_PENALTY: "MODEL_PRESENCE_PENALTY";
136
- };
137
- /**
138
- * Parameters for generating text using a language model.
139
- * This structure is typically passed to `AgentRuntime.useModel` when the `modelType` is one of
140
- * `ModelType.TEXT_SMALL`, `ModelType.TEXT_LARGE`, `ModelType.TEXT_REASONING_SMALL`,
141
- * `ModelType.TEXT_REASONING_LARGE`, or `ModelType.TEXT_COMPLETION`.
142
- * It includes essential information like the prompt and various generation controls.
143
- *
144
- * **Note for Plugin Implementers**: Different LLM providers have varying support for these parameters.
145
- * Some providers may not support both `temperature` and `topP` simultaneously, or may have other restrictions.
146
- * Plugin implementations should filter out unsupported parameters before calling their provider's API.
147
- * Check your provider's documentation to determine which parameters are supported.
148
- */
149
- export type GenerateTextParams = {
150
- /** The input string or prompt that the language model will use to generate text. */
151
- prompt: string;
152
- /** Optional. The maximum number of tokens to generate in the response. */
153
- maxTokens?: number;
154
- /** Optional. The minimum number of tokens to generate in the response. */
155
- minTokens?: number;
156
- /** Optional. Controls randomness (0.0-1.0). Lower values are more deterministic, higher are more creative. */
157
- temperature?: number;
158
- /** Optional. Nucleus sampling parameter (0.0-1.0). Controls diversity via nucleus sampling.
159
- * Note: Some providers may not support both `temperature` and `topP` simultaneously.
160
- * Plugin implementations should filter based on provider capabilities. */
161
- topP?: number;
162
- /** Optional. Limits the number of highest-probability tokens considered at each step.
163
- * Common in Ollama, vLLM, and other local model providers. Alternative/complement to topP. */
164
- topK?: number;
165
- /** Optional. Minimum probability threshold (0.0-1.0). Discards tokens with probability below this threshold.
166
- * Common in node-llama-cpp. Can improve output quality when using higher temperatures by filtering low-probability tokens. */
167
- minP?: number;
168
- /** Optional. Random seed for reproducible outputs. Useful for testing and debugging. */
169
- seed?: number;
170
- /** Optional. Repetition penalty (1.0 = no penalty, >1.0 reduces repetition).
171
- * Common in Ollama, vLLM, and some Hugging Face models. */
172
- repetitionPenalty?: number;
173
- /** Optional. Penalizes new tokens based on their existing frequency in the text so far. */
174
- frequencyPenalty?: number;
175
- /** Optional. Penalizes new tokens based on whether they appear in the text so far. */
176
- presencePenalty?: number;
177
- /** Optional. A list of sequences at which the model will stop generating further tokens. */
178
- stopSequences?: string[];
179
- /** Optional. User identifier for tracking and analytics purposes.
180
- *
181
- * This parameter is used by LLM providers (e.g., OpenAI) to track and monitor API usage per user.
182
- * It helps providers identify abuse patterns, implement rate limiting, and provide usage analytics.
183
- *
184
- * Behavior:
185
- * - If not provided (undefined), will automatically default to the agent's character name
186
- * - If explicitly set to empty string (""), it will be preserved (not overridden)
187
- * - If explicitly set to null, it will be preserved (not overridden)
188
- *
189
- * Examples:
190
- * - `user: "alice"` - Tracks requests from user "alice"
191
- * - `user: ""` - Explicitly sends empty user identifier
192
- * - `user: undefined` - Auto-populates with character name (e.g., "MyAgent")
193
- *
194
- * Note: Plugin implementations should pass this parameter to their provider's API when supported.
195
- */
196
- user?: string | null;
197
- /** Optional. Response format specification. Forces the model to return a specific format (e.g., JSON).
198
- * Common formats: 'json_object' (OpenAI), 'text'. Plugin implementations should map this to provider-specific formats. */
199
- responseFormat?: {
200
- type: 'json_object' | 'text';
201
- } | string;
202
- /**
203
- * Enable or disable streaming mode.
204
- * - `true`: Force streaming (requires onStreamChunk or context)
205
- * - `false`: Force non-streaming even if callback exists
206
- * - `undefined`: Auto (streams if onStreamChunk or context exists)
207
- */
208
- stream?: boolean;
209
- /**
210
- * Optional. Callback function for receiving streaming chunks.
211
- * When provided, streaming is automatically enabled and chunks are sent to this callback.
212
- *
213
- * @example
214
- * ```typescript
215
- * const text = await runtime.useModel(ModelType.TEXT_LARGE, {
216
- * prompt: "Hello",
217
- * onStreamChunk: (chunk) => process.stdout.write(chunk)
218
- * });
219
- * ```
220
- */
221
- onStreamChunk?: (chunk: string, messageId?: string) => void | Promise<void>;
222
- };
223
- /**
224
- * Token usage information from a model response.
225
- * Provides metrics about token consumption for billing and monitoring.
226
- */
227
- export interface TokenUsage {
228
- /** Number of tokens in the input prompt */
229
- promptTokens: number;
230
- /** Number of tokens in the generated response */
231
- completionTokens: number;
232
- /** Total tokens used (promptTokens + completionTokens) */
233
- totalTokens: number;
234
- }
235
- /**
236
- * Represents a single chunk in a text stream.
237
- * Each chunk contains a piece of the generated text.
238
- */
239
- export interface TextStreamChunk {
240
- /** The text content of this chunk */
241
- text: string;
242
- /** Whether this is the final chunk in the stream */
243
- done: boolean;
244
- }
245
- /**
246
- * Result of a streaming text generation request.
247
- * Provides an async iterable for consuming text chunks as they arrive.
248
- *
249
- * @example
250
- * ```typescript
251
- * const result = await runtime.useModel(ModelType.TEXT_LARGE, {
252
- * prompt: "Hello",
253
- * stream: true
254
- * }) as TextStreamResult;
255
- *
256
- * let fullText = '';
257
- * for await (const chunk of result.textStream) {
258
- * fullText += chunk;
259
- * console.log('Received:', chunk);
260
- * }
261
- *
262
- * // After stream completes
263
- * const usage = await result.usage;
264
- * console.log('Total tokens:', usage.totalTokens);
265
- * ```
266
- */
267
- export interface TextStreamResult {
268
- /**
269
- * Async iterable that yields text chunks as they are generated.
270
- * Each iteration provides a string chunk of the response.
271
- */
272
- textStream: AsyncIterable<string>;
273
- /**
274
- * Promise that resolves to the complete text after streaming finishes.
275
- * Useful when you need the full response after streaming.
276
- */
277
- text: Promise<string>;
278
- /**
279
- * Promise that resolves to token usage information after streaming completes.
280
- * May be undefined if the provider doesn't report usage for streaming.
281
- */
282
- usage: Promise<TokenUsage | undefined>;
283
- /**
284
- * Promise that resolves to the finish reason after streaming completes.
285
- * Common values: 'stop', 'length', 'content-filter'
286
- */
287
- finishReason: Promise<string | undefined>;
288
- }
289
- /**
290
- * Options for the simplified generateText API.
291
- * Extends GenerateTextParams with additional configuration for character context.
292
- */
293
- export interface GenerateTextOptions extends Omit<GenerateTextParams, 'prompt'> {
294
- /**
295
- * Whether to include character personality in the prompt.
296
- */
297
- includeCharacter?: boolean;
298
- /**
299
- * The model type to use for text generation.
300
- */
301
- modelType?: TextGenerationModelType;
302
- }
303
- /**
304
- * Structured response from text generation.
305
- */
306
- export interface GenerateTextResult {
307
- /** The generated text response from the model */
308
- text: string;
309
- }
310
- /**
311
- * Parameters for text tokenization models
312
- */
313
- export interface TokenizeTextParams {
314
- /** The text to tokenize */
315
- prompt: string;
316
- /** The model type to use for tokenization */
317
- modelType: ModelTypeName;
318
- }
319
- /**
320
- * Parameters for detokenizing text, i.e., converting a sequence of numerical tokens back into a string.
321
- * This is the reverse operation of tokenization.
322
- * This structure is used with `AgentRuntime.useModel` when the `modelType` is `ModelType.TEXT_TOKENIZER_DECODE`.
323
- */
324
- export interface DetokenizeTextParams {
325
- /** An array of numerical tokens to be converted back into text. */
326
- tokens: number[];
327
- /** The model type used for detokenization, ensuring consistency with the original tokenization. */
328
- modelType: ModelTypeName;
329
- }
330
- /**
331
- * Parameters for text embedding models
332
- */
333
- export interface TextEmbeddingParams {
334
- /** The text to create embeddings for */
335
- text: string;
336
- }
337
- /**
338
- * Parameters for image generation models
339
- */
340
- export interface ImageGenerationParams {
341
- /** The prompt describing the image to generate */
342
- prompt: string;
343
- /** The dimensions of the image to generate */
344
- size?: string;
345
- /** Number of images to generate */
346
- count?: number;
347
- }
348
- /**
349
- * Parameters for image description models
350
- */
351
- export interface ImageDescriptionParams {
352
- /** The URL or path of the image to describe */
353
- imageUrl: string;
354
- /** Optional prompt to guide the description */
355
- prompt?: string;
356
- }
357
- /**
358
- * Parameters for transcription models
359
- */
360
- export interface TranscriptionParams {
361
- /** The URL or path of the audio file to transcribe */
362
- audioUrl: string;
363
- /** Optional prompt to guide transcription */
364
- prompt?: string;
365
- }
366
- /**
367
- * Parameters for text-to-speech models
368
- */
369
- export interface TextToSpeechParams {
370
- /** The text to convert to speech */
371
- text: string;
372
- /** The voice to use */
373
- voice?: string;
374
- /** The speaking speed */
375
- speed?: number;
376
- }
377
- /**
378
- * Parameters for audio processing models
379
- */
380
- export interface AudioProcessingParams {
381
- /** The URL or path of the audio file to process */
382
- audioUrl: string;
383
- /** The type of audio processing to perform */
384
- processingType: string;
385
- }
386
- /**
387
- * Parameters for video processing models
388
- */
389
- export interface VideoProcessingParams {
390
- /** The URL or path of the video file to process */
391
- videoUrl: string;
392
- /** The type of video processing to perform */
393
- processingType: string;
394
- }
395
- /**
396
- * Optional JSON schema for validating generated objects
397
- */
398
- export type JSONSchema = {
399
- type: string;
400
- properties?: Record<string, JSONSchema | {
401
- type: string;
402
- }>;
403
- required?: string[];
404
- items?: JSONSchema;
405
- [key: string]: unknown;
406
- };
407
- /**
408
- * Parameters for object generation models
409
- * @template T - The expected return type, inferred from schema if provided
410
- */
411
- export interface ObjectGenerationParams {
412
- /** The prompt describing the object to generate */
413
- prompt: string;
414
- /** Optional JSON schema for validation */
415
- schema?: JSONSchema;
416
- /** Type of object to generate */
417
- output?: 'object' | 'array' | 'enum';
418
- /** For enum type, the allowed values */
419
- enumValues?: string[];
420
- /** Model type to use */
421
- modelType?: ModelTypeName;
422
- /** Model temperature (0.0 to 1.0) */
423
- temperature?: number;
424
- /** Sequences that should stop generation */
425
- stopSequences?: string[];
426
- }
427
- /**
428
- * Map of model types to their parameter types
429
- */
430
- export interface ModelParamsMap {
431
- [ModelType.TEXT_SMALL]: GenerateTextParams;
432
- [ModelType.TEXT_LARGE]: GenerateTextParams;
433
- [ModelType.TEXT_EMBEDDING]: TextEmbeddingParams | string | null;
434
- [ModelType.TEXT_TOKENIZER_ENCODE]: TokenizeTextParams;
435
- [ModelType.TEXT_TOKENIZER_DECODE]: DetokenizeTextParams;
436
- [ModelType.TEXT_REASONING_SMALL]: GenerateTextParams;
437
- [ModelType.TEXT_REASONING_LARGE]: GenerateTextParams;
438
- [ModelType.IMAGE]: ImageGenerationParams;
439
- [ModelType.IMAGE_DESCRIPTION]: ImageDescriptionParams | string;
440
- [ModelType.TRANSCRIPTION]: TranscriptionParams | Buffer | string;
441
- [ModelType.TEXT_TO_SPEECH]: TextToSpeechParams | string;
442
- [ModelType.AUDIO]: AudioProcessingParams;
443
- [ModelType.VIDEO]: VideoProcessingParams;
444
- [ModelType.OBJECT_SMALL]: ObjectGenerationParams;
445
- [ModelType.OBJECT_LARGE]: ObjectGenerationParams;
446
- [ModelType.TEXT_COMPLETION]: GenerateTextParams;
447
- }
448
- /**
449
- * Map of model types to their DEFAULT return value types.
450
- *
451
- * Note: For text generation models (TEXT_SMALL, TEXT_LARGE, TEXT_REASONING_*),
452
- * the actual return type depends on the parameters and is handled by overloads:
453
- * - `{ prompt }`: Returns `string` (this default)
454
- * - `{ prompt, stream: true }`: Returns `TextStreamResult` (via overload)
455
- *
456
- * The overloads in IAgentRuntime.useModel() provide the correct type inference.
457
- */
458
- export interface ModelResultMap {
459
- [ModelType.TEXT_SMALL]: string;
460
- [ModelType.TEXT_LARGE]: string;
461
- [ModelType.TEXT_EMBEDDING]: number[];
462
- [ModelType.TEXT_TOKENIZER_ENCODE]: number[];
463
- [ModelType.TEXT_TOKENIZER_DECODE]: string;
464
- [ModelType.TEXT_REASONING_SMALL]: string;
465
- [ModelType.TEXT_REASONING_LARGE]: string;
466
- [ModelType.IMAGE]: {
467
- url: string;
468
- }[];
469
- [ModelType.IMAGE_DESCRIPTION]: {
470
- title: string;
471
- description: string;
472
- };
473
- [ModelType.TRANSCRIPTION]: string;
474
- [ModelType.TEXT_TO_SPEECH]: Buffer | ArrayBuffer | Uint8Array;
475
- [ModelType.AUDIO]: Buffer | ArrayBuffer | Uint8Array | Record<string, unknown>;
476
- [ModelType.VIDEO]: Buffer | ArrayBuffer | Uint8Array | Record<string, unknown>;
477
- [ModelType.OBJECT_SMALL]: Record<string, unknown>;
478
- [ModelType.OBJECT_LARGE]: Record<string, unknown>;
479
- [ModelType.TEXT_COMPLETION]: string;
480
- }
481
- /**
482
- * Models that support streaming - their handlers can return either string or TextStreamResult
483
- */
484
- export type StreamableModelType = typeof ModelType.TEXT_SMALL | typeof ModelType.TEXT_LARGE | typeof ModelType.TEXT_REASONING_SMALL | typeof ModelType.TEXT_REASONING_LARGE | typeof ModelType.TEXT_COMPLETION;
485
- /**
486
- * Result type for plugin model handlers - includes TextStreamResult for streamable models
487
- */
488
- export type PluginModelResult<K extends keyof ModelResultMap> = K extends StreamableModelType ? ModelResultMap[K] | TextStreamResult : ModelResultMap[K];
489
- /**
490
- * Type guard to check if a model type supports streaming.
491
- */
492
- export declare function isStreamableModelType(modelType: ModelTypeName): boolean;
493
- /**
494
- * Defines the structure for a model handler registration within the `AgentRuntime`.
495
- * Each model (e.g., for text generation, embedding) is associated with a handler function,
496
- * the name of the provider (plugin or system) that registered it, and an optional priority.
497
- * The `priority` (higher is more preferred) helps in selecting which handler to use if multiple
498
- * handlers are registered for the same model type. The `registrationOrder` (not in type, but used in runtime)
499
- * serves as a tie-breaker. See `AgentRuntime.registerModel` and `AgentRuntime.getModel`.
500
- */
501
- export interface ModelHandler<TParams = Record<string, unknown>, TResult = unknown> {
502
- /** The function that executes the model, taking runtime and parameters, and returning a Promise. */
503
- handler: (runtime: IAgentRuntime, params: TParams) => Promise<TResult>;
504
- /** The name of the provider (e.g., plugin name) that registered this model handler. */
505
- provider: string;
506
- /**
507
- * Optional priority for this model handler. Higher numbers indicate higher priority.
508
- * This is used by `AgentRuntime.getModel` to select the most appropriate handler
509
- * when multiple are available for a given model type. Defaults to 0 if not specified.
510
- */
511
- priority?: number;
512
- registrationOrder?: number;
513
- }
@@ -1 +0,0 @@
1
- {"version":3,"file":"model.d.ts","sourceRoot":"","sources":["../../src/types/model.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAE/C,MAAM,MAAM,aAAa,GAAG,CAAC,OAAO,SAAS,CAAC,CAAC,MAAM,OAAO,SAAS,CAAC,GAAG,MAAM,CAAC;AAEhF;;;;;;;;;GASG;AACH,eAA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AAE,aAAa,EAAE,MAAM,EAAE,OAAO,KAAK,OAAO,CAAC,OAAO,CAAC,CAAC;IACvE,uFAAuF;IACvF,QAAQ,EAAE,MAAM,CAAC;IACjB;;;;OAIG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;IAElB,iBAAiB,CAAC,EAAE,MAAM,CAAC;CAC5B"}
@@ -1,91 +0,0 @@
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 { ModelParamsMap, PluginModelResult } from './model';
6
- import type { IAgentRuntime } from './runtime';
7
- import type { Service } from './service';
8
- import type { TestSuite } from './testing';
9
- /**
10
- * Minimal request interface
11
- * Plugins can use this type for route handlers
12
- */
13
- export interface RouteRequest {
14
- body?: unknown;
15
- params?: Record<string, string>;
16
- query?: Record<string, unknown>;
17
- headers?: Record<string, string | string[] | undefined>;
18
- method?: string;
19
- path?: string;
20
- url?: string;
21
- }
22
- /**
23
- * Minimal response interface
24
- * Plugins can use this type for route handlers
25
- */
26
- export interface RouteResponse {
27
- status: (code: number) => RouteResponse;
28
- json: (data: unknown) => RouteResponse;
29
- send: (data: unknown) => RouteResponse;
30
- end: () => RouteResponse;
31
- setHeader?: (name: string, value: string | string[]) => RouteResponse;
32
- headersSent?: boolean;
33
- }
34
- export type Route = {
35
- type: 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE' | 'STATIC';
36
- path: string;
37
- filePath?: string;
38
- public?: boolean;
39
- name?: string extends {
40
- public: true;
41
- } ? string : string | undefined;
42
- handler?: (req: RouteRequest, res: RouteResponse, runtime: IAgentRuntime) => Promise<void>;
43
- isMultipart?: boolean;
44
- };
45
- /**
46
- * Plugin for extending agent functionality
47
- */
48
- export type PluginEvents = {
49
- [K in keyof EventPayloadMap]?: EventHandler<K>[];
50
- };
51
- /** Internal type for runtime event storage - allows dynamic access for event registration */
52
- export type RuntimeEventStorage = PluginEvents & {
53
- [key: string]: ((params: unknown) => Promise<void>)[] | undefined;
54
- };
55
- export interface Plugin {
56
- name: string;
57
- description: string;
58
- init?: (config: Record<string, string>, runtime: IAgentRuntime) => Promise<void>;
59
- config?: {
60
- [key: string]: string | number | boolean | null | undefined;
61
- };
62
- services?: (typeof Service)[];
63
- componentTypes?: {
64
- name: string;
65
- schema: Record<string, unknown>;
66
- validator?: (data: unknown) => boolean;
67
- }[];
68
- actions?: Action[];
69
- providers?: Provider[];
70
- evaluators?: Evaluator[];
71
- adapter?: IDatabaseAdapter;
72
- models?: {
73
- [K in keyof ModelParamsMap]?: (runtime: IAgentRuntime, params: ModelParamsMap[K]) => Promise<PluginModelResult<K>>;
74
- };
75
- events?: PluginEvents;
76
- routes?: Route[];
77
- tests?: TestSuite[];
78
- dependencies?: string[];
79
- testDependencies?: string[];
80
- priority?: number;
81
- schema?: Record<string, unknown>;
82
- }
83
- export interface ProjectAgent {
84
- character: Character;
85
- init?: (runtime: IAgentRuntime) => Promise<void>;
86
- plugins?: Plugin[];
87
- tests?: TestSuite | TestSuite[];
88
- }
89
- export interface Project {
90
- agents: ProjectAgent[];
91
- }
@@ -1 +0,0 @@
1
- {"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../../src/types/plugin.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AACzC,OAAO,KAAK,EAAE,MAAM,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AAChE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AACnD,OAAO,KAAK,EAAE,YAAY,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AAC9D,OAAO,KAAK,EAAE,cAAc,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAC;AACjE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAC/C,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;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