llmist 2.2.0 → 2.4.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.
package/dist/index.d.cts CHANGED
@@ -1,7 +1,7 @@
1
1
  import { ZodType, ZodTypeAny } from 'zod';
2
2
  export { z } from 'zod';
3
- import { A as AgentHooks, q as ModelRegistry, I as IConversationManager, b as LLMMessage, S as StreamEvent, T as TokenUsage, G as GadgetRegistry, r as LLMist, a as LLMStreamChunk, C as CompactionStrategy, R as ResolvedCompactionConfig, s as CompactionContext, t as CompactionResult, u as CompactionConfig, v as CompactionEvent, w as CompactionStats, H as HintTemplate, E as ExecutionContext, x as GadgetExecuteReturn, y as GadgetExample, B as BaseGadget, P as ParsedGadgetCall, z as GadgetExecutionResult, D as ProviderAdapter, F as ModelDescriptor, J as ModelSpec, K as LLMGenerationOptions, L as LLMStream } from './mock-stream-wRfUqXx4.cjs';
4
- export { Z as AfterGadgetExecutionAction, _ as AfterGadgetExecutionControllerContext, $ as AfterLLMCallAction, a0 as AfterLLMCallControllerContext, a1 as AfterLLMErrorAction, U as AgentBuilder, a2 as AgentOptions, a3 as BeforeGadgetExecutionAction, a4 as BeforeLLMCallAction, a5 as ChunkInterceptorContext, a6 as Controllers, as as CostEstimate, aM as CostReportingLLMist, an as DEFAULT_COMPACTION_CONFIG, aC as DEFAULT_HINTS, aD as DEFAULT_PROMPTS, ao as DEFAULT_SUMMARIZATION_PROMPT, V as EventHandlers, aK as GadgetClass, aN as GadgetExecuteResult, a7 as GadgetExecutionControllerContext, aL as GadgetOrClass, a8 as GadgetParameterInterceptorContext, a9 as GadgetResultInterceptorContext, ay as HintContext, N as HistoryMessage, aa as Interceptors, ab as LLMCallControllerContext, ac as LLMErrorControllerContext, ar as LLMMessageBuilder, aq as LLMRole, ap as LLMistOptions, ad as MessageInterceptorContext, al as MessageTurn, d as MockBuilder, f as MockManager, j as MockMatcher, k as MockMatcherContext, l as MockOptions, M as MockProviderAdapter, n as MockRegistration, o as MockResponse, p as MockStats, at as ModelFeatures, ax as ModelIdentifierParser, au as ModelLimits, av as ModelPricing, ae as ObserveChunkContext, am as ObserveCompactionContext, af as ObserveGadgetCompleteContext, ag as ObserveGadgetStartContext, ah as ObserveLLMCallContext, ai as ObserveLLMCompleteContext, aj as ObserveLLMErrorContext, ak as Observers, az as PromptConfig, aA as PromptContext, aB as PromptTemplate, aw as ProviderIdentifier, aH as QuickOptions, aO as TextOnlyAction, aP as TextOnlyContext, aQ as TextOnlyCustomHandler, aR as TextOnlyGadgetConfig, aS as TextOnlyHandler, aT as TextOnlyStrategy, O as TrailingMessage, Q as TrailingMessageContext, W as collectEvents, X as collectText, aI as complete, c as createMockAdapter, e as createMockClient, h as createMockStream, i as createTextMockStream, g as getMockManager, m as mockLLM, aE as resolveHintTemplate, aF as resolvePromptTemplate, aG as resolveRulesTemplate, Y as runWithHandlers, aJ as stream } from './mock-stream-wRfUqXx4.cjs';
3
+ import { A as AgentHooks, q as ModelRegistry, I as IConversationManager, b as LLMMessage, S as StreamEvent, T as TokenUsage, G as GadgetRegistry, r as LLMist, a as LLMStreamChunk, C as CompactionStrategy, R as ResolvedCompactionConfig, s as CompactionContext, t as CompactionResult, u as CompactionConfig, v as CompactionEvent, w as CompactionStats, H as HintTemplate, E as ExecutionContext, x as GadgetExecuteReturn, y as GadgetExample, B as BaseGadget, P as ParsedGadgetCall, z as GadgetExecutionResult, D as ProviderAdapter, F as ModelDescriptor, J as ModelSpec, K as LLMGenerationOptions, L as LLMStream, N as ImageModelSpec, O as ImageGenerationOptions, Q as ImageGenerationResult, U as SpeechModelSpec, V as SpeechGenerationOptions, W as SpeechGenerationResult } from './mock-stream-BQcC2VCP.cjs';
4
+ export { a3 as AfterGadgetExecutionAction, a4 as AfterGadgetExecutionControllerContext, a5 as AfterLLMCallAction, a6 as AfterLLMCallControllerContext, a7 as AfterLLMErrorAction, _ as AgentBuilder, a8 as AgentOptions, a9 as BeforeGadgetExecutionAction, aa as BeforeLLMCallAction, ab as ChunkInterceptorContext, ac as Controllers, ay as CostEstimate, aS as CostReportingLLMist, at as DEFAULT_COMPACTION_CONFIG, aI as DEFAULT_HINTS, aJ as DEFAULT_PROMPTS, au as DEFAULT_SUMMARIZATION_PROMPT, $ as EventHandlers, aQ as GadgetClass, aT as GadgetExecuteResult, ad as GadgetExecutionControllerContext, aR as GadgetOrClass, ae as GadgetParameterInterceptorContext, af as GadgetResultInterceptorContext, aE as HintContext, X as HistoryMessage, ag as Interceptors, ah as LLMCallControllerContext, ai as LLMErrorControllerContext, ax as LLMMessageBuilder, aw as LLMRole, av as LLMistOptions, aj as MessageInterceptorContext, ar as MessageTurn, d as MockBuilder, f as MockManager, j as MockMatcher, k as MockMatcherContext, l as MockOptions, M as MockProviderAdapter, n as MockRegistration, o as MockResponse, p as MockStats, az as ModelFeatures, aD as ModelIdentifierParser, aA as ModelLimits, aB as ModelPricing, ak as ObserveChunkContext, as as ObserveCompactionContext, al as ObserveGadgetCompleteContext, am as ObserveGadgetStartContext, an as ObserveLLMCallContext, ao as ObserveLLMCompleteContext, ap as ObserveLLMErrorContext, aq as Observers, aF as PromptConfig, aG as PromptContext, aH as PromptTemplate, aC as ProviderIdentifier, aN as QuickOptions, aU as TextOnlyAction, aV as TextOnlyContext, aW as TextOnlyCustomHandler, aX as TextOnlyGadgetConfig, aY as TextOnlyHandler, aZ as TextOnlyStrategy, Y as TrailingMessage, Z as TrailingMessageContext, a0 as collectEvents, a1 as collectText, aO as complete, c as createMockAdapter, e as createMockClient, h as createMockStream, i as createTextMockStream, g as getMockManager, m as mockLLM, aK as resolveHintTemplate, aL as resolvePromptTemplate, aM as resolveRulesTemplate, a2 as runWithHandlers, aP as stream } from './mock-stream-BQcC2VCP.cjs';
5
5
  import { Logger, ILogObj } from 'tslog';
6
6
  import { MessageCreateParamsStreaming, MessageStreamEvent } from '@anthropic-ai/sdk/resources/messages';
7
7
  import OpenAI from 'openai';
@@ -2072,6 +2072,10 @@ declare class AnthropicMessagesProvider extends BaseProviderAdapter {
2072
2072
  readonly providerId: "anthropic";
2073
2073
  supports(descriptor: ModelDescriptor): boolean;
2074
2074
  getModelSpecs(): ModelSpec[];
2075
+ supportsImageGeneration(_modelId: string): boolean;
2076
+ generateImage(): Promise<never>;
2077
+ supportsSpeechGeneration(_modelId: string): boolean;
2078
+ generateSpeech(): Promise<never>;
2075
2079
  protected buildRequestPayload(options: LLMGenerationOptions, descriptor: ModelDescriptor, spec: ModelSpec | undefined, messages: LLMMessage[]): MessageCreateParamsStreaming;
2076
2080
  protected executeStreamRequest(payload: MessageCreateParamsStreaming, signal?: AbortSignal): Promise<AsyncIterable<MessageStreamEvent>>;
2077
2081
  protected wrapStream(iterable: AsyncIterable<unknown>): LLMStream;
@@ -2125,6 +2129,12 @@ declare class GeminiGenerativeProvider extends BaseProviderAdapter {
2125
2129
  readonly providerId: "gemini";
2126
2130
  supports(descriptor: ModelDescriptor): boolean;
2127
2131
  getModelSpecs(): ModelSpec[];
2132
+ getImageModelSpecs(): ImageModelSpec[];
2133
+ supportsImageGeneration(modelId: string): boolean;
2134
+ generateImage(options: ImageGenerationOptions): Promise<ImageGenerationResult>;
2135
+ getSpeechModelSpecs(): SpeechModelSpec[];
2136
+ supportsSpeechGeneration(modelId: string): boolean;
2137
+ generateSpeech(options: SpeechGenerationOptions): Promise<SpeechGenerationResult>;
2128
2138
  protected buildRequestPayload(options: LLMGenerationOptions, descriptor: ModelDescriptor, _spec: ModelSpec | undefined, messages: LLMMessage[]): {
2129
2139
  model: string;
2130
2140
  contents: Array<{
@@ -2198,6 +2208,12 @@ declare class OpenAIChatProvider extends BaseProviderAdapter {
2198
2208
  readonly providerId: "openai";
2199
2209
  supports(descriptor: ModelDescriptor): boolean;
2200
2210
  getModelSpecs(): ModelSpec[];
2211
+ getImageModelSpecs(): ImageModelSpec[];
2212
+ supportsImageGeneration(modelId: string): boolean;
2213
+ generateImage(options: ImageGenerationOptions): Promise<ImageGenerationResult>;
2214
+ getSpeechModelSpecs(): SpeechModelSpec[];
2215
+ supportsSpeechGeneration(modelId: string): boolean;
2216
+ generateSpeech(options: SpeechGenerationOptions): Promise<SpeechGenerationResult>;
2201
2217
  protected buildRequestPayload(options: LLMGenerationOptions, descriptor: ModelDescriptor, spec: ModelSpec | undefined, messages: LLMMessage[]): Parameters<OpenAI["chat"]["completions"]["create"]>[0];
2202
2218
  protected executeStreamRequest(payload: Parameters<OpenAI["chat"]["completions"]["create"]>[0], signal?: AbortSignal): Promise<AsyncIterable<ChatCompletionChunk>>;
2203
2219
  protected wrapStream(iterable: AsyncIterable<unknown>): LLMStream;
package/dist/index.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import { ZodType, ZodTypeAny } from 'zod';
2
2
  export { z } from 'zod';
3
- import { A as AgentHooks, q as ModelRegistry, I as IConversationManager, b as LLMMessage, S as StreamEvent, T as TokenUsage, G as GadgetRegistry, r as LLMist, a as LLMStreamChunk, C as CompactionStrategy, R as ResolvedCompactionConfig, s as CompactionContext, t as CompactionResult, u as CompactionConfig, v as CompactionEvent, w as CompactionStats, H as HintTemplate, E as ExecutionContext, x as GadgetExecuteReturn, y as GadgetExample, B as BaseGadget, P as ParsedGadgetCall, z as GadgetExecutionResult, D as ProviderAdapter, F as ModelDescriptor, J as ModelSpec, K as LLMGenerationOptions, L as LLMStream } from './mock-stream-wRfUqXx4.js';
4
- export { Z as AfterGadgetExecutionAction, _ as AfterGadgetExecutionControllerContext, $ as AfterLLMCallAction, a0 as AfterLLMCallControllerContext, a1 as AfterLLMErrorAction, U as AgentBuilder, a2 as AgentOptions, a3 as BeforeGadgetExecutionAction, a4 as BeforeLLMCallAction, a5 as ChunkInterceptorContext, a6 as Controllers, as as CostEstimate, aM as CostReportingLLMist, an as DEFAULT_COMPACTION_CONFIG, aC as DEFAULT_HINTS, aD as DEFAULT_PROMPTS, ao as DEFAULT_SUMMARIZATION_PROMPT, V as EventHandlers, aK as GadgetClass, aN as GadgetExecuteResult, a7 as GadgetExecutionControllerContext, aL as GadgetOrClass, a8 as GadgetParameterInterceptorContext, a9 as GadgetResultInterceptorContext, ay as HintContext, N as HistoryMessage, aa as Interceptors, ab as LLMCallControllerContext, ac as LLMErrorControllerContext, ar as LLMMessageBuilder, aq as LLMRole, ap as LLMistOptions, ad as MessageInterceptorContext, al as MessageTurn, d as MockBuilder, f as MockManager, j as MockMatcher, k as MockMatcherContext, l as MockOptions, M as MockProviderAdapter, n as MockRegistration, o as MockResponse, p as MockStats, at as ModelFeatures, ax as ModelIdentifierParser, au as ModelLimits, av as ModelPricing, ae as ObserveChunkContext, am as ObserveCompactionContext, af as ObserveGadgetCompleteContext, ag as ObserveGadgetStartContext, ah as ObserveLLMCallContext, ai as ObserveLLMCompleteContext, aj as ObserveLLMErrorContext, ak as Observers, az as PromptConfig, aA as PromptContext, aB as PromptTemplate, aw as ProviderIdentifier, aH as QuickOptions, aO as TextOnlyAction, aP as TextOnlyContext, aQ as TextOnlyCustomHandler, aR as TextOnlyGadgetConfig, aS as TextOnlyHandler, aT as TextOnlyStrategy, O as TrailingMessage, Q as TrailingMessageContext, W as collectEvents, X as collectText, aI as complete, c as createMockAdapter, e as createMockClient, h as createMockStream, i as createTextMockStream, g as getMockManager, m as mockLLM, aE as resolveHintTemplate, aF as resolvePromptTemplate, aG as resolveRulesTemplate, Y as runWithHandlers, aJ as stream } from './mock-stream-wRfUqXx4.js';
3
+ import { A as AgentHooks, q as ModelRegistry, I as IConversationManager, b as LLMMessage, S as StreamEvent, T as TokenUsage, G as GadgetRegistry, r as LLMist, a as LLMStreamChunk, C as CompactionStrategy, R as ResolvedCompactionConfig, s as CompactionContext, t as CompactionResult, u as CompactionConfig, v as CompactionEvent, w as CompactionStats, H as HintTemplate, E as ExecutionContext, x as GadgetExecuteReturn, y as GadgetExample, B as BaseGadget, P as ParsedGadgetCall, z as GadgetExecutionResult, D as ProviderAdapter, F as ModelDescriptor, J as ModelSpec, K as LLMGenerationOptions, L as LLMStream, N as ImageModelSpec, O as ImageGenerationOptions, Q as ImageGenerationResult, U as SpeechModelSpec, V as SpeechGenerationOptions, W as SpeechGenerationResult } from './mock-stream-BQcC2VCP.js';
4
+ export { a3 as AfterGadgetExecutionAction, a4 as AfterGadgetExecutionControllerContext, a5 as AfterLLMCallAction, a6 as AfterLLMCallControllerContext, a7 as AfterLLMErrorAction, _ as AgentBuilder, a8 as AgentOptions, a9 as BeforeGadgetExecutionAction, aa as BeforeLLMCallAction, ab as ChunkInterceptorContext, ac as Controllers, ay as CostEstimate, aS as CostReportingLLMist, at as DEFAULT_COMPACTION_CONFIG, aI as DEFAULT_HINTS, aJ as DEFAULT_PROMPTS, au as DEFAULT_SUMMARIZATION_PROMPT, $ as EventHandlers, aQ as GadgetClass, aT as GadgetExecuteResult, ad as GadgetExecutionControllerContext, aR as GadgetOrClass, ae as GadgetParameterInterceptorContext, af as GadgetResultInterceptorContext, aE as HintContext, X as HistoryMessage, ag as Interceptors, ah as LLMCallControllerContext, ai as LLMErrorControllerContext, ax as LLMMessageBuilder, aw as LLMRole, av as LLMistOptions, aj as MessageInterceptorContext, ar as MessageTurn, d as MockBuilder, f as MockManager, j as MockMatcher, k as MockMatcherContext, l as MockOptions, M as MockProviderAdapter, n as MockRegistration, o as MockResponse, p as MockStats, az as ModelFeatures, aD as ModelIdentifierParser, aA as ModelLimits, aB as ModelPricing, ak as ObserveChunkContext, as as ObserveCompactionContext, al as ObserveGadgetCompleteContext, am as ObserveGadgetStartContext, an as ObserveLLMCallContext, ao as ObserveLLMCompleteContext, ap as ObserveLLMErrorContext, aq as Observers, aF as PromptConfig, aG as PromptContext, aH as PromptTemplate, aC as ProviderIdentifier, aN as QuickOptions, aU as TextOnlyAction, aV as TextOnlyContext, aW as TextOnlyCustomHandler, aX as TextOnlyGadgetConfig, aY as TextOnlyHandler, aZ as TextOnlyStrategy, Y as TrailingMessage, Z as TrailingMessageContext, a0 as collectEvents, a1 as collectText, aO as complete, c as createMockAdapter, e as createMockClient, h as createMockStream, i as createTextMockStream, g as getMockManager, m as mockLLM, aK as resolveHintTemplate, aL as resolvePromptTemplate, aM as resolveRulesTemplate, a2 as runWithHandlers, aP as stream } from './mock-stream-BQcC2VCP.js';
5
5
  import { Logger, ILogObj } from 'tslog';
6
6
  import { MessageCreateParamsStreaming, MessageStreamEvent } from '@anthropic-ai/sdk/resources/messages';
7
7
  import OpenAI from 'openai';
@@ -2072,6 +2072,10 @@ declare class AnthropicMessagesProvider extends BaseProviderAdapter {
2072
2072
  readonly providerId: "anthropic";
2073
2073
  supports(descriptor: ModelDescriptor): boolean;
2074
2074
  getModelSpecs(): ModelSpec[];
2075
+ supportsImageGeneration(_modelId: string): boolean;
2076
+ generateImage(): Promise<never>;
2077
+ supportsSpeechGeneration(_modelId: string): boolean;
2078
+ generateSpeech(): Promise<never>;
2075
2079
  protected buildRequestPayload(options: LLMGenerationOptions, descriptor: ModelDescriptor, spec: ModelSpec | undefined, messages: LLMMessage[]): MessageCreateParamsStreaming;
2076
2080
  protected executeStreamRequest(payload: MessageCreateParamsStreaming, signal?: AbortSignal): Promise<AsyncIterable<MessageStreamEvent>>;
2077
2081
  protected wrapStream(iterable: AsyncIterable<unknown>): LLMStream;
@@ -2125,6 +2129,12 @@ declare class GeminiGenerativeProvider extends BaseProviderAdapter {
2125
2129
  readonly providerId: "gemini";
2126
2130
  supports(descriptor: ModelDescriptor): boolean;
2127
2131
  getModelSpecs(): ModelSpec[];
2132
+ getImageModelSpecs(): ImageModelSpec[];
2133
+ supportsImageGeneration(modelId: string): boolean;
2134
+ generateImage(options: ImageGenerationOptions): Promise<ImageGenerationResult>;
2135
+ getSpeechModelSpecs(): SpeechModelSpec[];
2136
+ supportsSpeechGeneration(modelId: string): boolean;
2137
+ generateSpeech(options: SpeechGenerationOptions): Promise<SpeechGenerationResult>;
2128
2138
  protected buildRequestPayload(options: LLMGenerationOptions, descriptor: ModelDescriptor, _spec: ModelSpec | undefined, messages: LLMMessage[]): {
2129
2139
  model: string;
2130
2140
  contents: Array<{
@@ -2198,6 +2208,12 @@ declare class OpenAIChatProvider extends BaseProviderAdapter {
2198
2208
  readonly providerId: "openai";
2199
2209
  supports(descriptor: ModelDescriptor): boolean;
2200
2210
  getModelSpecs(): ModelSpec[];
2211
+ getImageModelSpecs(): ImageModelSpec[];
2212
+ supportsImageGeneration(modelId: string): boolean;
2213
+ generateImage(options: ImageGenerationOptions): Promise<ImageGenerationResult>;
2214
+ getSpeechModelSpecs(): SpeechModelSpec[];
2215
+ supportsSpeechGeneration(modelId: string): boolean;
2216
+ generateSpeech(options: SpeechGenerationOptions): Promise<SpeechGenerationResult>;
2201
2217
  protected buildRequestPayload(options: LLMGenerationOptions, descriptor: ModelDescriptor, spec: ModelSpec | undefined, messages: LLMMessage[]): Parameters<OpenAI["chat"]["completions"]["create"]>[0];
2202
2218
  protected executeStreamRequest(payload: Parameters<OpenAI["chat"]["completions"]["create"]>[0], signal?: AbortSignal): Promise<AsyncIterable<ChatCompletionChunk>>;
2203
2219
  protected wrapStream(iterable: AsyncIterable<unknown>): LLMStream;
package/dist/index.js CHANGED
@@ -5,7 +5,7 @@ import {
5
5
  iterationProgressHint,
6
6
  parallelGadgetHint,
7
7
  z
8
- } from "./chunk-ZDNV7DDO.js";
8
+ } from "./chunk-QFRVTS5F.js";
9
9
  import {
10
10
  AbortError,
11
11
  AgentBuilder,
@@ -65,7 +65,7 @@ import {
65
65
  stream,
66
66
  validateAndApplyDefaults,
67
67
  validateGadgetParams
68
- } from "./chunk-GANXNBIZ.js";
68
+ } from "./chunk-6ZDUWO6N.js";
69
69
  export {
70
70
  AbortError,
71
71
  AgentBuilder,
@@ -1,6 +1,218 @@
1
1
  import { ZodTypeAny } from 'zod';
2
2
  import { Logger, ILogObj } from 'tslog';
3
3
 
4
+ /**
5
+ * Types and interfaces for multimodal generation (image, speech).
6
+ *
7
+ * These types support non-token-based billing models where costs are calculated
8
+ * per-image, per-character, or per-second rather than per-token.
9
+ */
10
+ /**
11
+ * Options for image generation requests.
12
+ */
13
+ interface ImageGenerationOptions {
14
+ /** Model to use (e.g., "dall-e-3", "imagen-3.0-generate-002") */
15
+ model: string;
16
+ /** Text prompt describing the desired image */
17
+ prompt: string;
18
+ /**
19
+ * Image size/dimensions.
20
+ * - OpenAI: "1024x1024", "1024x1792", "1792x1024"
21
+ * - Gemini: "1:1", "3:4", "4:3", "9:16", "16:9"
22
+ */
23
+ size?: string;
24
+ /**
25
+ * Image quality level.
26
+ * - OpenAI: "standard", "hd"
27
+ */
28
+ quality?: string;
29
+ /**
30
+ * Number of images to generate.
31
+ * Note: DALL-E 3 only supports n=1
32
+ */
33
+ n?: number;
34
+ /**
35
+ * Response format for the generated image.
36
+ * - "url": Returns a URL to the image (expires after ~1 hour)
37
+ * - "b64_json": Returns base64-encoded image data
38
+ */
39
+ responseFormat?: "url" | "b64_json";
40
+ }
41
+ /**
42
+ * A single generated image.
43
+ */
44
+ interface GeneratedImage {
45
+ /** URL to the generated image (if responseFormat is "url") */
46
+ url?: string;
47
+ /** Base64-encoded image data (if responseFormat is "b64_json") */
48
+ b64Json?: string;
49
+ /** Revised prompt (if the model modified the original prompt) */
50
+ revisedPrompt?: string;
51
+ }
52
+ /**
53
+ * Usage information for image generation.
54
+ */
55
+ interface ImageUsage {
56
+ /** Number of images generated */
57
+ imagesGenerated: number;
58
+ /** Size of generated images */
59
+ size: string;
60
+ /** Quality level used */
61
+ quality: string;
62
+ }
63
+ /**
64
+ * Result of an image generation request.
65
+ */
66
+ interface ImageGenerationResult {
67
+ /** Array of generated images */
68
+ images: GeneratedImage[];
69
+ /** Model used for generation */
70
+ model: string;
71
+ /** Usage information */
72
+ usage: ImageUsage;
73
+ /** Estimated cost in USD */
74
+ cost?: number;
75
+ }
76
+ /**
77
+ * Available audio formats for speech generation.
78
+ */
79
+ type AudioFormat = "mp3" | "opus" | "aac" | "flac" | "wav" | "pcm";
80
+ /**
81
+ * Options for speech (TTS) generation requests.
82
+ */
83
+ interface SpeechGenerationOptions {
84
+ /** Model to use (e.g., "tts-1", "tts-1-hd") */
85
+ model: string;
86
+ /** Text to convert to speech */
87
+ input: string;
88
+ /**
89
+ * Voice to use for generation.
90
+ * - OpenAI: "alloy", "echo", "fable", "onyx", "nova", "shimmer"
91
+ * - Gemini: "Zephyr", "Puck", "Charon", "Kore", etc.
92
+ */
93
+ voice: string;
94
+ /** Output audio format (default: "mp3") */
95
+ responseFormat?: AudioFormat;
96
+ /**
97
+ * Speed of the generated audio.
98
+ * Range: 0.25 to 4.0 (default: 1.0)
99
+ */
100
+ speed?: number;
101
+ }
102
+ /**
103
+ * Usage information for speech generation.
104
+ */
105
+ interface SpeechUsage {
106
+ /** Number of characters processed */
107
+ characterCount: number;
108
+ }
109
+ /**
110
+ * Result of a speech generation request.
111
+ */
112
+ interface SpeechGenerationResult {
113
+ /** Generated audio data */
114
+ audio: ArrayBuffer;
115
+ /** Model used for generation */
116
+ model: string;
117
+ /** Usage information */
118
+ usage: SpeechUsage;
119
+ /** Estimated cost in USD */
120
+ cost?: number;
121
+ /** Audio format of the result */
122
+ format: AudioFormat;
123
+ }
124
+ /**
125
+ * Pricing structure for image models.
126
+ * Maps size -> quality -> price per image.
127
+ */
128
+ interface ImageModelPricing {
129
+ /** Simple per-image price (for models with uniform pricing) */
130
+ perImage?: number;
131
+ /**
132
+ * Size-based pricing.
133
+ * Maps size (e.g., "1024x1024") to quality-based pricing or flat price.
134
+ */
135
+ bySize?: Record<string, Record<string, number> | number>;
136
+ }
137
+ /**
138
+ * Pricing structure for speech models.
139
+ * Supports both character-based pricing (tts-1, tts-1-hd) and
140
+ * token-based pricing (gpt-4o-mini-tts).
141
+ */
142
+ interface SpeechModelPricing {
143
+ /** Price per character (e.g., 0.000015 for $15 per 1M chars) - for tts-1, tts-1-hd */
144
+ perCharacter?: number;
145
+ /** Token-based pricing (for gpt-4o-mini-tts) */
146
+ perInputToken?: number;
147
+ perAudioOutputToken?: number;
148
+ /** Approximate cost per minute of generated audio (for estimation) */
149
+ perMinute?: number;
150
+ }
151
+ /**
152
+ * Specification for an image generation model.
153
+ */
154
+ interface ImageModelSpec {
155
+ /** Provider identifier (e.g., "openai", "gemini") */
156
+ provider: string;
157
+ /** Model identifier */
158
+ modelId: string;
159
+ /** Human-readable display name */
160
+ displayName: string;
161
+ /** Pricing information */
162
+ pricing: ImageModelPricing;
163
+ /** Supported image sizes */
164
+ supportedSizes: string[];
165
+ /** Supported quality levels (optional) */
166
+ supportedQualities?: string[];
167
+ /** Maximum images per request */
168
+ maxImages: number;
169
+ /** Default size if not specified */
170
+ defaultSize?: string;
171
+ /** Default quality if not specified */
172
+ defaultQuality?: string;
173
+ /** Additional feature flags */
174
+ features?: {
175
+ /** Supports conversational/multi-turn image editing */
176
+ conversational?: boolean;
177
+ /** Optimized for text rendering in images */
178
+ textRendering?: boolean;
179
+ /** Supports transparency */
180
+ transparency?: boolean;
181
+ };
182
+ }
183
+ /**
184
+ * Specification for a speech generation model.
185
+ */
186
+ interface SpeechModelSpec {
187
+ /** Provider identifier (e.g., "openai", "gemini") */
188
+ provider: string;
189
+ /** Model identifier */
190
+ modelId: string;
191
+ /** Human-readable display name */
192
+ displayName: string;
193
+ /** Pricing information */
194
+ pricing: SpeechModelPricing;
195
+ /** Available voice options */
196
+ voices: string[];
197
+ /** Supported audio formats */
198
+ formats: AudioFormat[];
199
+ /** Maximum input text length (characters) */
200
+ maxInputLength: number;
201
+ /** Default voice if not specified */
202
+ defaultVoice?: string;
203
+ /** Default format if not specified */
204
+ defaultFormat?: AudioFormat;
205
+ /** Additional feature flags */
206
+ features?: {
207
+ /** Supports multi-speaker output */
208
+ multiSpeaker?: boolean;
209
+ /** Number of supported languages */
210
+ languages?: number;
211
+ /** Supports voice instructions/steering */
212
+ voiceInstructions?: boolean;
213
+ };
214
+ }
215
+
4
216
  /**
5
217
  * Model Catalog Types
6
218
  *
@@ -743,6 +955,26 @@ type TextOnlyAction = {
743
955
  * }
744
956
  * ```
745
957
  */
958
+ /**
959
+ * Image generation namespace with automatic cost reporting.
960
+ */
961
+ interface CostReportingImageNamespace {
962
+ /**
963
+ * Generate images from a text prompt.
964
+ * Costs are automatically reported to the execution context.
965
+ */
966
+ generate(options: ImageGenerationOptions): Promise<ImageGenerationResult>;
967
+ }
968
+ /**
969
+ * Speech generation namespace with automatic cost reporting.
970
+ */
971
+ interface CostReportingSpeechNamespace {
972
+ /**
973
+ * Generate speech audio from text.
974
+ * Costs are automatically reported to the execution context.
975
+ */
976
+ generate(options: SpeechGenerationOptions): Promise<SpeechGenerationResult>;
977
+ }
746
978
  interface CostReportingLLMist {
747
979
  /**
748
980
  * Quick completion - returns final text response.
@@ -763,6 +995,16 @@ interface CostReportingLLMist {
763
995
  * Access to model registry for cost estimation.
764
996
  */
765
997
  readonly modelRegistry: ModelRegistry;
998
+ /**
999
+ * Image generation with automatic cost reporting.
1000
+ * Costs are reported based on model and generation parameters.
1001
+ */
1002
+ readonly image: CostReportingImageNamespace;
1003
+ /**
1004
+ * Speech generation with automatic cost reporting.
1005
+ * Costs are reported based on input length and model pricing.
1006
+ */
1007
+ readonly speech: CostReportingSpeechNamespace;
766
1008
  }
767
1009
  /**
768
1010
  * Execution context provided to gadgets during execution.
@@ -1283,6 +1525,167 @@ interface ProviderAdapter {
1283
1525
  * @returns Promise resolving to the number of input tokens
1284
1526
  */
1285
1527
  countTokens?(messages: LLMMessage[], descriptor: ModelDescriptor, spec?: ModelSpec): Promise<number>;
1528
+ /**
1529
+ * Get image model specifications for this provider.
1530
+ * Returns undefined if the provider doesn't support image generation.
1531
+ */
1532
+ getImageModelSpecs?(): ImageModelSpec[];
1533
+ /**
1534
+ * Check if this provider supports image generation for a given model.
1535
+ * @param modelId - Model identifier (e.g., "dall-e-3")
1536
+ */
1537
+ supportsImageGeneration?(modelId: string): boolean;
1538
+ /**
1539
+ * Generate images from a text prompt.
1540
+ * @param options - Image generation options
1541
+ * @returns Promise resolving to the generation result with images and cost
1542
+ */
1543
+ generateImage?(options: ImageGenerationOptions): Promise<ImageGenerationResult>;
1544
+ /**
1545
+ * Get speech model specifications for this provider.
1546
+ * Returns undefined if the provider doesn't support speech generation.
1547
+ */
1548
+ getSpeechModelSpecs?(): SpeechModelSpec[];
1549
+ /**
1550
+ * Check if this provider supports speech generation for a given model.
1551
+ * @param modelId - Model identifier (e.g., "tts-1", "tts-1-hd")
1552
+ */
1553
+ supportsSpeechGeneration?(modelId: string): boolean;
1554
+ /**
1555
+ * Generate speech audio from text.
1556
+ * @param options - Speech generation options
1557
+ * @returns Promise resolving to the generation result with audio and cost
1558
+ */
1559
+ generateSpeech?(options: SpeechGenerationOptions): Promise<SpeechGenerationResult>;
1560
+ }
1561
+
1562
+ /**
1563
+ * Image Generation Namespace
1564
+ *
1565
+ * Provides image generation methods.
1566
+ *
1567
+ * @example
1568
+ * ```typescript
1569
+ * const llmist = new LLMist();
1570
+ *
1571
+ * const result = await llmist.image.generate({
1572
+ * model: "dall-e-3",
1573
+ * prompt: "A cat in space",
1574
+ * size: "1024x1024",
1575
+ * quality: "hd",
1576
+ * });
1577
+ *
1578
+ * console.log(result.images[0].url);
1579
+ * console.log("Cost:", result.cost);
1580
+ * ```
1581
+ */
1582
+
1583
+ declare class ImageNamespace {
1584
+ private readonly adapters;
1585
+ private readonly defaultProvider;
1586
+ constructor(adapters: ProviderAdapter[], defaultProvider: string);
1587
+ /**
1588
+ * Generate images from a text prompt.
1589
+ *
1590
+ * @param options - Image generation options
1591
+ * @returns Promise resolving to the generation result with images and cost
1592
+ * @throws Error if the provider doesn't support image generation
1593
+ */
1594
+ generate(options: ImageGenerationOptions): Promise<ImageGenerationResult>;
1595
+ /**
1596
+ * List all available image generation models.
1597
+ */
1598
+ listModels(): ImageModelSpec[];
1599
+ /**
1600
+ * Check if a model is supported for image generation.
1601
+ */
1602
+ supportsModel(modelId: string): boolean;
1603
+ private findImageAdapter;
1604
+ }
1605
+
1606
+ /**
1607
+ * Speech Generation Namespace
1608
+ *
1609
+ * Provides text-to-speech generation methods.
1610
+ *
1611
+ * @example
1612
+ * ```typescript
1613
+ * const llmist = new LLMist();
1614
+ *
1615
+ * const result = await llmist.speech.generate({
1616
+ * model: "tts-1-hd",
1617
+ * input: "Hello, world!",
1618
+ * voice: "nova",
1619
+ * });
1620
+ *
1621
+ * // Save the audio
1622
+ * fs.writeFileSync("output.mp3", Buffer.from(result.audio));
1623
+ * console.log("Cost:", result.cost);
1624
+ * ```
1625
+ */
1626
+
1627
+ declare class SpeechNamespace {
1628
+ private readonly adapters;
1629
+ private readonly defaultProvider;
1630
+ constructor(adapters: ProviderAdapter[], defaultProvider: string);
1631
+ /**
1632
+ * Generate speech audio from text.
1633
+ *
1634
+ * @param options - Speech generation options
1635
+ * @returns Promise resolving to the generation result with audio and cost
1636
+ * @throws Error if the provider doesn't support speech generation
1637
+ */
1638
+ generate(options: SpeechGenerationOptions): Promise<SpeechGenerationResult>;
1639
+ /**
1640
+ * List all available speech generation models.
1641
+ */
1642
+ listModels(): SpeechModelSpec[];
1643
+ /**
1644
+ * Check if a model is supported for speech generation.
1645
+ */
1646
+ supportsModel(modelId: string): boolean;
1647
+ private findSpeechAdapter;
1648
+ }
1649
+
1650
+ /**
1651
+ * Text Generation Namespace
1652
+ *
1653
+ * Provides text completion and streaming methods.
1654
+ * Replaces the deprecated llmist.complete() and llmist.stream() methods.
1655
+ *
1656
+ * @example
1657
+ * ```typescript
1658
+ * const llmist = new LLMist();
1659
+ *
1660
+ * // Complete
1661
+ * const answer = await llmist.text.complete("What is 2+2?");
1662
+ *
1663
+ * // Stream
1664
+ * for await (const chunk of llmist.text.stream("Tell me a story")) {
1665
+ * process.stdout.write(chunk);
1666
+ * }
1667
+ * ```
1668
+ */
1669
+
1670
+ declare class TextNamespace {
1671
+ private readonly client;
1672
+ constructor(client: LLMist);
1673
+ /**
1674
+ * Generate a complete text response.
1675
+ *
1676
+ * @param prompt - User prompt
1677
+ * @param options - Optional configuration
1678
+ * @returns Complete text response
1679
+ */
1680
+ complete(prompt: string, options?: QuickOptions): Promise<string>;
1681
+ /**
1682
+ * Stream text chunks.
1683
+ *
1684
+ * @param prompt - User prompt
1685
+ * @param options - Optional configuration
1686
+ * @returns Async generator yielding text chunks
1687
+ */
1688
+ stream(prompt: string, options?: QuickOptions): AsyncGenerator<string>;
1286
1689
  }
1287
1690
 
1288
1691
  interface LLMistOptions {
@@ -1326,8 +1729,12 @@ interface LLMistOptions {
1326
1729
  }
1327
1730
  declare class LLMist {
1328
1731
  private readonly parser;
1732
+ private readonly defaultProvider;
1329
1733
  readonly modelRegistry: ModelRegistry;
1330
1734
  private readonly adapters;
1735
+ readonly text: TextNamespace;
1736
+ readonly image: ImageNamespace;
1737
+ readonly speech: SpeechNamespace;
1331
1738
  constructor();
1332
1739
  constructor(adapters: ProviderAdapter[]);
1333
1740
  constructor(adapters: ProviderAdapter[], defaultProvider: string);
@@ -3609,4 +4016,4 @@ declare function createTextMockStream(text: string, options?: {
3609
4016
  usage?: MockResponse["usage"];
3610
4017
  }): LLMStream;
3611
4018
 
3612
- export { type AfterLLMCallAction as $, type AgentHooks as A, BaseGadget as B, type CompactionStrategy as C, type ProviderAdapter as D, type ExecutionContext as E, type ModelDescriptor as F, GadgetRegistry as G, type HintTemplate as H, type IConversationManager as I, type ModelSpec as J, type LLMGenerationOptions as K, type LLMStream as L, MockProviderAdapter as M, type HistoryMessage as N, type TrailingMessage as O, type ParsedGadgetCall as P, type TrailingMessageContext as Q, type ResolvedCompactionConfig as R, type StreamEvent as S, type TokenUsage as T, AgentBuilder as U, type EventHandlers as V, collectEvents as W, collectText as X, runWithHandlers as Y, type AfterGadgetExecutionAction as Z, type AfterGadgetExecutionControllerContext as _, type LLMStreamChunk as a, type AfterLLMCallControllerContext as a0, type AfterLLMErrorAction as a1, type AgentOptions as a2, type BeforeGadgetExecutionAction as a3, type BeforeLLMCallAction as a4, type ChunkInterceptorContext as a5, type Controllers as a6, type GadgetExecutionControllerContext as a7, type GadgetParameterInterceptorContext as a8, type GadgetResultInterceptorContext as a9, type PromptContext as aA, type PromptTemplate as aB, DEFAULT_HINTS as aC, DEFAULT_PROMPTS as aD, resolveHintTemplate as aE, resolvePromptTemplate as aF, resolveRulesTemplate as aG, type QuickOptions as aH, complete as aI, stream as aJ, type GadgetClass as aK, type GadgetOrClass as aL, type CostReportingLLMist as aM, type GadgetExecuteResult as aN, type TextOnlyAction as aO, type TextOnlyContext as aP, type TextOnlyCustomHandler as aQ, type TextOnlyGadgetConfig as aR, type TextOnlyHandler as aS, type TextOnlyStrategy as aT, type Interceptors as aa, type LLMCallControllerContext as ab, type LLMErrorControllerContext as ac, type MessageInterceptorContext as ad, type ObserveChunkContext as ae, type ObserveGadgetCompleteContext as af, type ObserveGadgetStartContext as ag, type ObserveLLMCallContext as ah, type ObserveLLMCompleteContext as ai, type ObserveLLMErrorContext as aj, type Observers as ak, type MessageTurn as al, type ObserveCompactionContext as am, DEFAULT_COMPACTION_CONFIG as an, DEFAULT_SUMMARIZATION_PROMPT as ao, type LLMistOptions as ap, type LLMRole as aq, LLMMessageBuilder as ar, type CostEstimate as as, type ModelFeatures as at, type ModelLimits as au, type ModelPricing as av, type ProviderIdentifier as aw, ModelIdentifierParser as ax, type HintContext as ay, type PromptConfig as az, type LLMMessage as b, createMockAdapter as c, MockBuilder as d, createMockClient as e, MockManager as f, getMockManager as g, createMockStream as h, createTextMockStream as i, type MockMatcher as j, type MockMatcherContext as k, type MockOptions as l, mockLLM as m, type MockRegistration as n, type MockResponse as o, type MockStats as p, ModelRegistry as q, LLMist as r, type CompactionContext as s, type CompactionResult as t, type CompactionConfig as u, type CompactionEvent as v, type CompactionStats as w, type GadgetExecuteReturn as x, type GadgetExample as y, type GadgetExecutionResult as z };
4019
+ export { type EventHandlers as $, type AgentHooks as A, BaseGadget as B, type CompactionStrategy as C, type ProviderAdapter as D, type ExecutionContext as E, type ModelDescriptor as F, GadgetRegistry as G, type HintTemplate as H, type IConversationManager as I, type ModelSpec as J, type LLMGenerationOptions as K, type LLMStream as L, MockProviderAdapter as M, type ImageModelSpec as N, type ImageGenerationOptions as O, type ParsedGadgetCall as P, type ImageGenerationResult as Q, type ResolvedCompactionConfig as R, type StreamEvent as S, type TokenUsage as T, type SpeechModelSpec as U, type SpeechGenerationOptions as V, type SpeechGenerationResult as W, type HistoryMessage as X, type TrailingMessage as Y, type TrailingMessageContext as Z, AgentBuilder as _, type LLMStreamChunk as a, collectEvents as a0, collectText as a1, runWithHandlers as a2, type AfterGadgetExecutionAction as a3, type AfterGadgetExecutionControllerContext as a4, type AfterLLMCallAction as a5, type AfterLLMCallControllerContext as a6, type AfterLLMErrorAction as a7, type AgentOptions as a8, type BeforeGadgetExecutionAction as a9, type ModelLimits as aA, type ModelPricing as aB, type ProviderIdentifier as aC, ModelIdentifierParser as aD, type HintContext as aE, type PromptConfig as aF, type PromptContext as aG, type PromptTemplate as aH, DEFAULT_HINTS as aI, DEFAULT_PROMPTS as aJ, resolveHintTemplate as aK, resolvePromptTemplate as aL, resolveRulesTemplate as aM, type QuickOptions as aN, complete as aO, stream as aP, type GadgetClass as aQ, type GadgetOrClass as aR, type CostReportingLLMist as aS, type GadgetExecuteResult as aT, type TextOnlyAction as aU, type TextOnlyContext as aV, type TextOnlyCustomHandler as aW, type TextOnlyGadgetConfig as aX, type TextOnlyHandler as aY, type TextOnlyStrategy as aZ, type BeforeLLMCallAction as aa, type ChunkInterceptorContext as ab, type Controllers as ac, type GadgetExecutionControllerContext as ad, type GadgetParameterInterceptorContext as ae, type GadgetResultInterceptorContext as af, type Interceptors as ag, type LLMCallControllerContext as ah, type LLMErrorControllerContext as ai, type MessageInterceptorContext as aj, type ObserveChunkContext as ak, type ObserveGadgetCompleteContext as al, type ObserveGadgetStartContext as am, type ObserveLLMCallContext as an, type ObserveLLMCompleteContext as ao, type ObserveLLMErrorContext as ap, type Observers as aq, type MessageTurn as ar, type ObserveCompactionContext as as, DEFAULT_COMPACTION_CONFIG as at, DEFAULT_SUMMARIZATION_PROMPT as au, type LLMistOptions as av, type LLMRole as aw, LLMMessageBuilder as ax, type CostEstimate as ay, type ModelFeatures as az, type LLMMessage as b, createMockAdapter as c, MockBuilder as d, createMockClient as e, MockManager as f, getMockManager as g, createMockStream as h, createTextMockStream as i, type MockMatcher as j, type MockMatcherContext as k, type MockOptions as l, mockLLM as m, type MockRegistration as n, type MockResponse as o, type MockStats as p, ModelRegistry as q, LLMist as r, type CompactionContext as s, type CompactionResult as t, type CompactionConfig as u, type CompactionEvent as v, type CompactionStats as w, type GadgetExecuteReturn as x, type GadgetExample as y, type GadgetExecutionResult as z };