@elizaos/plugin-openai 1.6.0 → 2.0.0-alpha.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 (55) hide show
  1. package/LICENSE +1 -1
  2. package/dist/browser/index.browser.js +2 -2
  3. package/dist/browser/index.browser.js.map +18 -17
  4. package/dist/build.d.ts +13 -0
  5. package/dist/build.d.ts.map +1 -0
  6. package/dist/cjs/index.node.cjs +998 -658
  7. package/dist/cjs/index.node.js.map +18 -17
  8. package/dist/generated/specs/specs.d.ts +55 -0
  9. package/dist/generated/specs/specs.d.ts.map +1 -0
  10. package/dist/index.browser.d.ts +1 -0
  11. package/dist/index.browser.d.ts.map +1 -0
  12. package/dist/index.d.ts +1 -5
  13. package/dist/index.d.ts.map +1 -0
  14. package/dist/index.node.d.ts +1 -0
  15. package/dist/index.node.d.ts.map +1 -0
  16. package/dist/init.d.ts +4 -5
  17. package/dist/init.d.ts.map +1 -0
  18. package/dist/models/audio.d.ts +9 -10
  19. package/dist/models/audio.d.ts.map +1 -0
  20. package/dist/models/embedding.d.ts +1 -3
  21. package/dist/models/embedding.d.ts.map +1 -0
  22. package/dist/models/image.d.ts +4 -13
  23. package/dist/models/image.d.ts.map +1 -0
  24. package/dist/models/index.d.ts +7 -5
  25. package/dist/models/index.d.ts.map +1 -0
  26. package/dist/models/object.d.ts +4 -9
  27. package/dist/models/object.d.ts.map +1 -0
  28. package/dist/models/research.d.ts +34 -0
  29. package/dist/models/research.d.ts.map +1 -0
  30. package/dist/models/text.d.ts +22 -3
  31. package/dist/models/text.d.ts.map +1 -0
  32. package/dist/models/tokenizer.d.ts +4 -9
  33. package/dist/models/tokenizer.d.ts.map +1 -0
  34. package/dist/node/index.node.js +987 -644
  35. package/dist/node/index.node.js.map +18 -17
  36. package/dist/providers/index.d.ts +2 -1
  37. package/dist/providers/index.d.ts.map +1 -0
  38. package/dist/providers/openai.d.ts +3 -7
  39. package/dist/providers/openai.d.ts.map +1 -0
  40. package/dist/types/index.d.ts +313 -10
  41. package/dist/types/index.d.ts.map +1 -0
  42. package/dist/utils/audio.d.ts +6 -12
  43. package/dist/utils/audio.d.ts.map +1 -0
  44. package/dist/utils/config.d.ts +16 -59
  45. package/dist/utils/config.d.ts.map +1 -0
  46. package/dist/utils/events.d.ts +14 -9
  47. package/dist/utils/events.d.ts.map +1 -0
  48. package/dist/utils/index.d.ts +2 -1
  49. package/dist/utils/index.d.ts.map +1 -0
  50. package/dist/utils/json.d.ts +9 -6
  51. package/dist/utils/json.d.ts.map +1 -0
  52. package/dist/utils/tokenization.d.ts +5 -16
  53. package/dist/utils/tokenization.d.ts.map +1 -0
  54. package/package.json +24 -28
  55. package/README.md +0 -160
@@ -1,26 +1,329 @@
1
- export interface OpenAITranscriptionParams {
1
+ /**
2
+ * Supported audio formats for transcription
3
+ */
4
+ export type AudioFormat = "mp3" | "wav" | "webm" | "ogg" | "flac" | "mp4";
5
+ /**
6
+ * Supported response formats for transcription
7
+ */
8
+ export type TranscriptionResponseFormat = "json" | "text" | "srt" | "verbose_json" | "vtt";
9
+ /**
10
+ * Timestamp granularity options for transcription
11
+ */
12
+ export type TimestampGranularity = "word" | "segment";
13
+ /**
14
+ * Supported TTS output formats
15
+ */
16
+ export type TTSOutputFormat = "mp3" | "wav" | "flac" | "opus" | "aac" | "pcm";
17
+ /**
18
+ * Supported TTS voices
19
+ */
20
+ export type TTSVoice = "alloy" | "echo" | "fable" | "onyx" | "nova" | "shimmer";
21
+ /**
22
+ * Image sizes for DALL-E
23
+ */
24
+ export type ImageSize = "256x256" | "512x512" | "1024x1024" | "1792x1024" | "1024x1792";
25
+ /**
26
+ * Image quality options
27
+ */
28
+ export type ImageQuality = "standard" | "hd";
29
+ /**
30
+ * Image style options
31
+ */
32
+ export type ImageStyle = "vivid" | "natural";
33
+ /**
34
+ * Parameters for audio transcription
35
+ */
36
+ export interface TranscriptionParams {
37
+ /** The audio data to transcribe */
2
38
  audio: Blob | File | Buffer;
39
+ /** The model to use for transcription */
3
40
  model?: string;
41
+ /** The language of the audio (ISO-639-1 code) */
4
42
  language?: string;
5
- response_format?: string;
43
+ /** The format of the response */
44
+ responseFormat?: TranscriptionResponseFormat;
45
+ /** An optional prompt to guide the model's style */
6
46
  prompt?: string;
47
+ /** Sampling temperature between 0 and 1 */
7
48
  temperature?: number;
8
- timestampGranularities?: string[];
49
+ /** Timestamp granularity for verbose output */
50
+ timestampGranularities?: TimestampGranularity[];
51
+ /** MIME type hint for buffer audio data */
9
52
  mimeType?: string;
10
53
  }
11
- export interface OpenAITextToSpeechParams {
54
+ /**
55
+ * Parameters for text-to-speech generation
56
+ */
57
+ export interface TextToSpeechParams {
58
+ /** The text to convert to speech (max 4096 characters) */
12
59
  text: string;
60
+ /** The model to use */
13
61
  model?: string;
14
- voice?: string;
15
- format?: "mp3" | "wav" | "flac" | string;
62
+ /** The voice to use */
63
+ voice?: TTSVoice;
64
+ /** The output format */
65
+ format?: TTSOutputFormat;
66
+ /** Additional instructions for the TTS model */
16
67
  instructions?: string;
17
68
  }
18
- export interface OpenAIImageDescriptionResult {
69
+ /**
70
+ * Parameters for embedding generation
71
+ */
72
+ export interface EmbeddingParams {
73
+ /** The text to embed */
74
+ text: string;
75
+ /** The model to use */
76
+ model?: string;
77
+ /** The number of dimensions for the embedding */
78
+ dimensions?: number;
79
+ }
80
+ /**
81
+ * Parameters for image generation
82
+ */
83
+ export interface ImageGenerationParams {
84
+ /** The prompt describing the image to generate */
85
+ prompt: string;
86
+ /** Number of images to generate (1-10) */
87
+ count?: number;
88
+ /** The size of the generated images */
89
+ size?: ImageSize;
90
+ /** The quality of the generated images */
91
+ quality?: ImageQuality;
92
+ /** The style of the generated images */
93
+ style?: ImageStyle;
94
+ }
95
+ /**
96
+ * Parameters for image description/analysis
97
+ */
98
+ export interface ImageDescriptionParams {
99
+ /** URL of the image to analyze */
100
+ imageUrl: string;
101
+ /** Custom prompt for analysis */
102
+ prompt?: string;
103
+ /** Maximum tokens for the response */
104
+ maxTokens?: number;
105
+ }
106
+ /**
107
+ * Parameters for text generation
108
+ */
109
+ export interface TextGenerationParams {
110
+ /** The prompt for generation */
111
+ prompt: string;
112
+ /** System message for the model */
113
+ system?: string;
114
+ /** Temperature for sampling (0-2) */
115
+ temperature?: number;
116
+ /** Maximum output tokens */
117
+ maxTokens?: number;
118
+ /** Frequency penalty (-2 to 2) */
119
+ frequencyPenalty?: number;
120
+ /** Presence penalty (-2 to 2) */
121
+ presencePenalty?: number;
122
+ /** Stop sequences */
123
+ stopSequences?: string[];
124
+ /** Whether to stream the response */
125
+ stream?: boolean;
126
+ /** Callback for streaming chunks */
127
+ onStreamChunk?: (chunk: string) => void;
128
+ }
129
+ /**
130
+ * Parameters for tokenization
131
+ */
132
+ export interface TokenizeParams {
133
+ /** The text to tokenize */
134
+ prompt: string;
135
+ /** The model whose tokenizer to use */
136
+ modelType?: string;
137
+ }
138
+ /**
139
+ * Parameters for detokenization
140
+ */
141
+ export interface DetokenizeParams {
142
+ /** The tokens to decode */
143
+ tokens: number[];
144
+ /** The model whose tokenizer to use */
145
+ modelType?: string;
146
+ }
147
+ /**
148
+ * Result of image description/analysis
149
+ */
150
+ export interface ImageDescriptionResult {
151
+ /** A title for the image */
19
152
  title: string;
153
+ /** A detailed description of the image */
20
154
  description: string;
21
155
  }
22
- export interface OpenAIImageGenerationResult {
23
- data: {
156
+ /**
157
+ * Result of image generation
158
+ */
159
+ export interface ImageGenerationResult {
160
+ /** URL of the generated image */
161
+ url: string;
162
+ /** Revised prompt (if applicable) */
163
+ revisedPrompt?: string;
164
+ }
165
+ /**
166
+ * Token usage statistics
167
+ */
168
+ export interface TokenUsage {
169
+ /** Number of prompt tokens */
170
+ promptTokens: number;
171
+ /** Number of completion tokens */
172
+ completionTokens: number;
173
+ /** Total tokens used */
174
+ totalTokens: number;
175
+ }
176
+ /**
177
+ * Streaming text result
178
+ */
179
+ export interface TextStreamResult {
180
+ /** Async iterable stream of text chunks */
181
+ textStream: AsyncIterable<string>;
182
+ /** Promise resolving to final complete text */
183
+ text: Promise<string>;
184
+ /** Promise resolving to token usage */
185
+ usage: Promise<TokenUsage | undefined>;
186
+ /** Promise resolving to finish reason */
187
+ finishReason: Promise<string | undefined>;
188
+ }
189
+ /**
190
+ * OpenAI embedding response structure
191
+ */
192
+ export interface OpenAIEmbeddingResponse {
193
+ object: "list";
194
+ data: Array<{
195
+ object: "embedding";
196
+ embedding: number[];
197
+ index: number;
198
+ }>;
199
+ model: string;
200
+ usage: {
201
+ prompt_tokens: number;
202
+ total_tokens: number;
203
+ };
204
+ }
205
+ /**
206
+ * OpenAI chat completion response structure
207
+ */
208
+ export interface OpenAIChatCompletionResponse {
209
+ id: string;
210
+ object: "chat.completion";
211
+ created: number;
212
+ model: string;
213
+ choices: Array<{
214
+ index: number;
215
+ message: {
216
+ role: "assistant";
217
+ content: string | null;
218
+ };
219
+ finish_reason: "stop" | "length" | "content_filter" | "tool_calls";
220
+ }>;
221
+ usage: {
222
+ prompt_tokens: number;
223
+ completion_tokens: number;
224
+ total_tokens: number;
225
+ };
226
+ }
227
+ /**
228
+ * OpenAI image generation response structure
229
+ */
230
+ export interface OpenAIImageGenerationResponse {
231
+ created: number;
232
+ data: Array<{
24
233
  url: string;
25
- }[];
234
+ revised_prompt?: string;
235
+ }>;
236
+ }
237
+ /**
238
+ * OpenAI transcription response structure
239
+ */
240
+ export interface OpenAITranscriptionResponse {
241
+ text: string;
242
+ language?: string;
243
+ duration?: number;
244
+ words?: Array<{
245
+ word: string;
246
+ start: number;
247
+ end: number;
248
+ }>;
249
+ segments?: Array<{
250
+ id: number;
251
+ start: number;
252
+ end: number;
253
+ text: string;
254
+ }>;
255
+ }
256
+ /**
257
+ * OpenAI models list response
258
+ */
259
+ export interface OpenAIModelsResponse {
260
+ object: "list";
261
+ data: Array<{
262
+ id: string;
263
+ object: "model";
264
+ created: number;
265
+ owned_by: string;
266
+ }>;
267
+ }
268
+ /**
269
+ * OpenAI plugin configuration settings
270
+ */
271
+ export interface OpenAIPluginConfig {
272
+ /** OpenAI API key */
273
+ OPENAI_API_KEY?: string;
274
+ /** Base URL for API requests */
275
+ OPENAI_BASE_URL?: string;
276
+ /** Small model identifier */
277
+ OPENAI_SMALL_MODEL?: string;
278
+ /** Large model identifier */
279
+ OPENAI_LARGE_MODEL?: string;
280
+ /** Embedding model identifier */
281
+ OPENAI_EMBEDDING_MODEL?: string;
282
+ /** Separate API key for embeddings */
283
+ OPENAI_EMBEDDING_API_KEY?: string;
284
+ /** Separate base URL for embeddings */
285
+ OPENAI_EMBEDDING_URL?: string;
286
+ /** Embedding dimensions */
287
+ OPENAI_EMBEDDING_DIMENSIONS?: string;
288
+ /** Image description model */
289
+ OPENAI_IMAGE_DESCRIPTION_MODEL?: string;
290
+ /** Max tokens for image description */
291
+ OPENAI_IMAGE_DESCRIPTION_MAX_TOKENS?: string;
292
+ /** TTS model */
293
+ OPENAI_TTS_MODEL?: string;
294
+ /** TTS voice */
295
+ OPENAI_TTS_VOICE?: string;
296
+ /** TTS instructions */
297
+ OPENAI_TTS_INSTRUCTIONS?: string;
298
+ /** Enable experimental telemetry */
299
+ OPENAI_EXPERIMENTAL_TELEMETRY?: string;
300
+ /** Browser-only proxy base URL */
301
+ OPENAI_BROWSER_BASE_URL?: string;
302
+ /** Browser-only embedding proxy URL */
303
+ OPENAI_BROWSER_EMBEDDING_URL?: string;
304
+ /** Transcription model */
305
+ OPENAI_TRANSCRIPTION_MODEL?: string;
306
+ /** Image generation model */
307
+ OPENAI_IMAGE_MODEL?: string;
308
+ /** Deep research model (o3-deep-research or o4-mini-deep-research) */
309
+ OPENAI_RESEARCH_MODEL?: string;
310
+ /** Timeout for deep research requests in milliseconds (default: 3600000 = 1 hour) */
311
+ OPENAI_RESEARCH_TIMEOUT?: string;
26
312
  }
313
+ /**
314
+ * Validates that a string is non-empty
315
+ */
316
+ export declare function requireNonEmptyString(value: string, fieldName: string): string;
317
+ /**
318
+ * Validates that a number is within a range
319
+ */
320
+ export declare function requireNumberInRange(value: number, min: number, max: number, fieldName: string): number;
321
+ /**
322
+ * Validates that an array is non-empty
323
+ */
324
+ export declare function requireNonEmptyArray<T>(arr: T[], fieldName: string): T[];
325
+ /**
326
+ * Validates embedding dimensions
327
+ */
328
+ export declare function validateEmbeddingDimension(dimension: number, validDimensions: readonly number[]): number;
329
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../types/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,MAAM,WAAW,GAAG,KAAK,GAAG,KAAK,GAAG,MAAM,GAAG,KAAK,GAAG,MAAM,GAAG,KAAK,CAAC;AAE1E;;GAEG;AACH,MAAM,MAAM,2BAA2B,GAAG,MAAM,GAAG,MAAM,GAAG,KAAK,GAAG,cAAc,GAAG,KAAK,CAAC;AAE3F;;GAEG;AACH,MAAM,MAAM,oBAAoB,GAAG,MAAM,GAAG,SAAS,CAAC;AAEtD;;GAEG;AACH,MAAM,MAAM,eAAe,GAAG,KAAK,GAAG,KAAK,GAAG,MAAM,GAAG,MAAM,GAAG,KAAK,GAAG,KAAK,CAAC;AAE9E;;GAEG;AACH,MAAM,MAAM,QAAQ,GAAG,OAAO,GAAG,MAAM,GAAG,OAAO,GAAG,MAAM,GAAG,MAAM,GAAG,SAAS,CAAC;AAEhF;;GAEG;AACH,MAAM,MAAM,SAAS,GAAG,SAAS,GAAG,SAAS,GAAG,WAAW,GAAG,WAAW,GAAG,WAAW,CAAC;AAExF;;GAEG;AACH,MAAM,MAAM,YAAY,GAAG,UAAU,GAAG,IAAI,CAAC;AAE7C;;GAEG;AACH,MAAM,MAAM,UAAU,GAAG,OAAO,GAAG,SAAS,CAAC;AAE7C;;GAEG;AACH,MAAM,WAAW,mBAAmB;IAClC,mCAAmC;IACnC,KAAK,EAAE,IAAI,GAAG,IAAI,GAAG,MAAM,CAAC;IAE5B,yCAAyC;IACzC,KAAK,CAAC,EAAE,MAAM,C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G;AACH,wBAAgB,0BAA0B,CACxC,SAAS,EAAE,MAAM,EACjB,eAAe,EAAE,SAAS,MAAM,EAAE,GACjC,MAAM,CAOR"}
@@ -1,12 +1,6 @@
1
- /**
2
- * Detects audio MIME type from buffer by checking magic bytes (file signature)
3
- * @param buffer The audio buffer to analyze
4
- * @returns The detected MIME type or 'application/octet-stream' if unknown
5
- */
6
- export declare function detectAudioMimeType(buffer: Buffer): string;
7
- /**
8
- * Converts a Web ReadableStream to a Node.js Readable stream
9
- * Handles both browser and Node.js environments
10
- * Uses dynamic import to avoid bundling node:stream in browser builds
11
- */
12
- export declare function webStreamToNodeStream(webStream: ReadableStream<Uint8Array>): Promise<import("stream").Readable>;
1
+ export type AudioMimeType = "audio/wav" | "audio/mpeg" | "audio/ogg" | "audio/flac" | "audio/mp4" | "audio/webm" | "application/octet-stream";
2
+ export declare function detectAudioMimeType(buffer: Buffer): AudioMimeType;
3
+ export declare function getExtensionForMimeType(mimeType: AudioMimeType): string;
4
+ export declare function getFilenameForMimeType(mimeType: AudioMimeType): string;
5
+ export declare function validateAudioFormat(buffer: Buffer): AudioMimeType;
6
+ //# sourceMappingURL=audio.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"audio.d.ts","sourceRoot":"","sources":["../../utils/audio.ts"],"names":[],"mappings":"AAgBA,MAAM,MAAM,aAAa,GACrB,WAAW,GACX,YAAY,GACZ,WAAW,GACX,YAAY,GACZ,WAAW,GACX,YAAY,GACZ,0BAA0B,CAAC;AAY/B,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,MAAM,GAAG,aAAa,CA6CjE;AAED,wBAAgB,uBAAuB,CAAC,QAAQ,EAAE,aAAa,GAAG,MAAM,CAiBvE;AAED,wBAAgB,sBAAsB,CAAC,QAAQ,EAAE,aAAa,GAAG,MAAM,CAGtE;AAED,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,MAAM,GAAG,aAAa,CAQjE"}
@@ -1,70 +1,27 @@
1
1
  import type { IAgentRuntime } from "@elizaos/core";
2
- /**
3
- * Retrieves a configuration setting from the runtime, falling back to environment variables or a default value if not found.
4
- *
5
- * @param key - The name of the setting to retrieve.
6
- * @param defaultValue - The value to return if the setting is not found in the runtime or environment.
7
- * @returns The resolved setting value, or {@link defaultValue} if not found.
8
- */
9
2
  export declare function getSetting(runtime: IAgentRuntime, key: string, defaultValue?: string): string | undefined;
3
+ export declare function getRequiredSetting(runtime: IAgentRuntime, key: string, errorMessage?: string): string;
4
+ export declare function getNumericSetting(runtime: IAgentRuntime, key: string, defaultValue: number): number;
5
+ export declare function getBooleanSetting(runtime: IAgentRuntime, key: string, defaultValue: boolean): boolean;
10
6
  export declare function isBrowser(): boolean;
11
- /**
12
- * Determines whether we're running in a browser with a server-hosted proxy configured.
13
- * In this mode, we do not require a real API key on the client and rely on the proxy to inject it.
14
- */
15
7
  export declare function isProxyMode(runtime: IAgentRuntime): boolean;
8
+ export declare function getApiKey(runtime: IAgentRuntime): string | undefined;
9
+ export declare function getEmbeddingApiKey(runtime: IAgentRuntime): string | undefined;
16
10
  export declare function getAuthHeader(runtime: IAgentRuntime, forEmbedding?: boolean): Record<string, string>;
17
- /**
18
- * Retrieves the OpenAI API base URL from runtime settings, environment variables, or defaults, using provider-aware resolution.
19
- *
20
- * @returns The resolved base URL for OpenAI API requests.
21
- */
22
11
  export declare function getBaseURL(runtime: IAgentRuntime): string;
23
- /**
24
- * Retrieves the OpenAI API base URL for embeddings, falling back to the general base URL.
25
- *
26
- * @returns The resolved base URL for OpenAI embedding requests.
27
- */
28
12
  export declare function getEmbeddingBaseURL(runtime: IAgentRuntime): string;
29
- /**
30
- * Helper function to get the API key for OpenAI
31
- *
32
- * @param runtime The runtime context
33
- * @returns The configured API key
34
- */
35
- export declare function getApiKey(runtime: IAgentRuntime): string | undefined;
36
- /**
37
- * Helper function to get the embedding API key for OpenAI, falling back to the general API key if not set.
38
- *
39
- * @param runtime The runtime context
40
- * @returns The configured API key
41
- */
42
- export declare function getEmbeddingApiKey(runtime: IAgentRuntime): string | undefined;
43
- /**
44
- * Helper function to get the small model name with fallbacks
45
- *
46
- * @param runtime The runtime context
47
- * @returns The configured small model name
48
- */
49
13
  export declare function getSmallModel(runtime: IAgentRuntime): string;
50
- /**
51
- * Helper function to get the large model name with fallbacks
52
- *
53
- * @param runtime The runtime context
54
- * @returns The configured large model name
55
- */
56
14
  export declare function getLargeModel(runtime: IAgentRuntime): string;
57
- /**
58
- * Helper function to get the image description model name with fallbacks
59
- *
60
- * @param runtime The runtime context
61
- * @returns The configured image description model name
62
- */
15
+ export declare function getEmbeddingModel(runtime: IAgentRuntime): string;
63
16
  export declare function getImageDescriptionModel(runtime: IAgentRuntime): string;
64
- /**
65
- * Helper function to get experimental telemetry setting
66
- *
67
- * @param runtime The runtime context
68
- * @returns Whether experimental telemetry is enabled
69
- */
17
+ export declare function getTranscriptionModel(runtime: IAgentRuntime): string;
18
+ export declare function getTTSModel(runtime: IAgentRuntime): string;
19
+ export declare function getTTSVoice(runtime: IAgentRuntime): string;
20
+ export declare function getTTSInstructions(runtime: IAgentRuntime): string;
21
+ export declare function getImageModel(runtime: IAgentRuntime): string;
70
22
  export declare function getExperimentalTelemetry(runtime: IAgentRuntime): boolean;
23
+ export declare function getEmbeddingDimensions(runtime: IAgentRuntime): number;
24
+ export declare function getImageDescriptionMaxTokens(runtime: IAgentRuntime): number;
25
+ export declare function getResearchModel(runtime: IAgentRuntime): string;
26
+ export declare function getResearchTimeout(runtime: IAgentRuntime): number;
27
+ //# sourceMappingURL=config.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../utils/config.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAWnD,wBAAgB,UAAU,CACxB,OAAO,EAAE,aAAa,EACtB,GAAG,EAAE,MAAM,EACX,YAAY,CAAC,EAAE,MAAM,GACpB,MAAM,GAAG,SAAS,CAMpB;AACD,wBAAg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AO,EAAE,aAAa,GAAG,MAAM,CAE1D;AAED,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,aAAa,GAAG,MAAM,CAEjE;AAED,wBAAgB,aAAa,CAAC,OAAO,EAAE,aAAa,GAAG,MAAM,CAE5D;AAED,wBAAgB,wBAAwB,CAAC,OAAO,EAAE,aAAa,GAAG,OAAO,CAExE;AAED,wBAAgB,sBAAsB,CAAC,OAAO,EAAE,aAAa,GAAG,MAAM,CAErE;AAED,wBAAgB,4BAA4B,CAAC,OAAO,EAAE,aAAa,GAAG,MAAM,CAE3E;AAED,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,aAAa,GAAG,MAAM,CAE/D;AAED,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,aAAa,GAAG,MAAM,CAEjE"}
@@ -1,10 +1,15 @@
1
1
  import type { IAgentRuntime, ModelTypeName } from "@elizaos/core";
2
- import type { LanguageModelUsage } from "ai";
3
- /**
4
- * Emits a model usage event
5
- * @param runtime The runtime context
6
- * @param type The model type
7
- * @param prompt The prompt used
8
- * @param usage The LLM usage data
9
- */
10
- export declare function emitModelUsageEvent(runtime: IAgentRuntime, type: ModelTypeName, prompt: string, usage: LanguageModelUsage): void;
2
+ import type { TokenUsage } from "../types";
3
+ interface AISDKUsage {
4
+ inputTokens?: number;
5
+ outputTokens?: number;
6
+ }
7
+ interface OpenAIAPIUsage {
8
+ promptTokens?: number;
9
+ completionTokens?: number;
10
+ totalTokens?: number;
11
+ }
12
+ type ModelUsage = TokenUsage | AISDKUsage | OpenAIAPIUsage;
13
+ export declare function emitModelUsageEvent(runtime: IAgentRuntime, type: ModelTypeName, prompt: string, usage: ModelUsage): void;
14
+ export {};
15
+ //# sourceMappingURL=events.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"events.d.ts","sourceRoot":"","sources":["../../utils/events.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAElE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AAiB3C,UAAU,UAAU;IAClB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB;AAED,UAAU,cAAc;IACtB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED,KAAK,UAAU,GAAG,UAAU,GAAG,UAAU,GAAG,cAAc,CAAC;AAiC3D,wBAAgB,mBAAmB,CACjC,OAAO,EAAE,aAAa,EACtB,IAAI,EAAE,aAAa,EACnB,MAAM,EAAE,MAAM,EACd,KAAK,EAAE,UAAU,GAChB,IAAI,CAiBN"}
@@ -1,5 +1,6 @@
1
+ export * from "./audio";
1
2
  export * from "./config";
2
3
  export * from "./events";
3
- export * from "./audio";
4
4
  export * from "./json";
5
5
  export * from "./tokenization";
6
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../utils/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAC;AACxB,cAAc,UAAU,CAAC;AACzB,cAAc,UAAU,CAAC;AACzB,cAAc,QAAQ,CAAC;AACvB,cAAc,gBAAgB,CAAC"}
@@ -1,7 +1,10 @@
1
- /**
2
- * Returns a function to repair JSON text
3
- */
4
- export declare function getJsonRepairFunction(): (params: {
1
+ interface JsonRepairParams {
5
2
  text: string;
6
- error: unknown;
7
- }) => Promise<string | null>;
3
+ error: Error;
4
+ }
5
+ type JsonRepairFunction = (params: JsonRepairParams) => Promise<string | null>;
6
+ export declare function getJsonRepairFunction(): JsonRepairFunction;
7
+ export declare function parseJsonWithRepair<T>(text: string): T;
8
+ export declare function safeStringify(value: unknown, indent?: number): string;
9
+ export {};
10
+ //# sourceMappingURL=json.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"json.d.ts","sourceRoot":"","sources":["../../utils/json.ts"],"names":[],"mappings":"AAGA,UAAU,gBAAgB;IACxB,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,KAAK,CAAC;CACd;AAED,KAAK,kBAAkB,GAAG,CAAC,MAAM,EAAE,gBAAgB,KAAK,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAAC;AAO/E,wBAAgB,qBAAqB,IAAI,kBAAkB,CAe1D;AAED,wBAAgB,mBAAmB,CAAC,CAAC,EAAE,IAAI,EAAE,MAAM,GAAG,CAAC,CAYtD;AAED,wBAAgB,aAAa,CAAC,KAAK,EAAE,OAAO,EAAE,MAAM,SAAI,GAAG,MAAM,CAwChE"}
@@ -1,17 +1,6 @@
1
1
  import type { IAgentRuntime, ModelTypeName } from "@elizaos/core";
2
- /**
3
- * Asynchronously tokenizes the given text based on the specified model and prompt.
4
- *
5
- * @param {ModelTypeName} model - The type of model to use for tokenization.
6
- * @param {string} prompt - The text prompt to tokenize.
7
- * @returns {number[]} - An array of tokens representing the encoded prompt.
8
- */
9
- export declare function tokenizeText(runtime: IAgentRuntime, model: ModelTypeName, prompt: string): Promise<number[]>;
10
- /**
11
- * Detokenize a sequence of tokens back into text using the specified model.
12
- *
13
- * @param {ModelTypeName} model - The type of model to use for detokenization.
14
- * @param {number[]} tokens - The sequence of tokens to detokenize.
15
- * @returns {string} The detokenized text.
16
- */
17
- export declare function detokenizeText(runtime: IAgentRuntime, model: ModelTypeName, tokens: number[]): Promise<string>;
2
+ export declare function tokenizeText(runtime: IAgentRuntime, modelType: ModelTypeName, text: string): number[];
3
+ export declare function detokenizeText(runtime: IAgentRuntime, modelType: ModelTypeName, tokens: number[]): string;
4
+ export declare function countTokens(runtime: IAgentRuntime, modelType: ModelTypeName, text: string): number;
5
+ export declare function truncateToTokenLimit(runtime: IAgentRuntime, modelType: ModelTypeName, text: string, maxTokens: number): string;
6
+ //# sourceMappingURL=tokenization.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tokenization.d.ts","sourceRoot":"","sources":["../../utils/tokenization.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAgClE,wBAAgB,YAAY,CAC1B,OAAO,EAAE,aAAa,EACtB,SAAS,EAAE,aAAa,EACxB,IAAI,EAAE,MAAM,GACX,MAAM,EAAE,CAIV;AAED,wBAAgB,cAAc,CAC5B,OAAO,EAAE,aAAa,EACtB,SAAS,EAAE,aAAa,EACxB,MAAM,EAAE,MAAM,EAAE,GACf,MAAM,CAIR;AAED,wBAAgB,WAAW,CACzB,OAAO,EAAE,aAAa,EACtB,SAAS,EAAE,aAAa,EACxB,IAAI,EAAE,MAAM,GACX,MAAM,CAGR;AAED,wBAAgB,oBAAoB,CAClC,OAAO,EAAE,aAAa,EACtB,SAAS,EAAE,aAAa,EACxB,IAAI,EAAE,MAAM,EACZ,SAAS,EAAE,MAAM,GAChB,MAAM,CAOR"}