llmist 2.4.0 → 2.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
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, 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';
3
+ import { A as AgentHooks, s as ModelRegistry, I as IConversationManager, b as LLMMessage, t as MessageContent, S as StreamEvent, T as TokenUsage, G as GadgetRegistry, u as LLMist, a as LLMStreamChunk, C as CompactionStrategy, R as ResolvedCompactionConfig, v as CompactionContext, w as CompactionResult, x as CompactionConfig, y as CompactionEvent, z as CompactionStats, H as HintTemplate, E as ExecutionContext, D as GadgetExecuteReturn, F as GadgetExample, B as BaseGadget, P as ParsedGadgetCall, J as GadgetExecutionResult, K as ProviderAdapter, N as ModelDescriptor, O as ModelSpec, Q as LLMGenerationOptions, L as LLMStream, U as ImageModelSpec, V as ImageGenerationOptions, W as ImageGenerationResult, X as SpeechModelSpec, Y as SpeechGenerationOptions, Z as SpeechGenerationResult } from './mock-stream-ga4KIiwX.cjs';
4
+ export { a6 as AfterGadgetExecutionAction, a7 as AfterGadgetExecutionControllerContext, a8 as AfterLLMCallAction, a9 as AfterLLMCallControllerContext, aa as AfterLLMErrorAction, a1 as AgentBuilder, ab as AgentOptions, az as AudioContentPart, aA as AudioMimeType, aB as AudioSource, ac as BeforeGadgetExecutionAction, ad as BeforeLLMCallAction, ae as ChunkInterceptorContext, aC as ContentPart, af as Controllers, b1 as CostEstimate, bl as CostReportingLLMist, aw as DEFAULT_COMPACTION_CONFIG, bb as DEFAULT_HINTS, bc as DEFAULT_PROMPTS, ax as DEFAULT_SUMMARIZATION_PROMPT, a2 as EventHandlers, bj as GadgetClass, bm as GadgetExecuteResult, ag as GadgetExecutionControllerContext, bk as GadgetOrClass, ah as GadgetParameterInterceptorContext, ai as GadgetResultInterceptorContext, bn as GadgetSkippedEvent, b7 as HintContext, _ as HistoryMessage, aD as ImageBase64Source, aE as ImageContentPart, aF as ImageMimeType, aG as ImageSource, aH as ImageUrlSource, aj as Interceptors, ak as LLMCallControllerContext, al as LLMErrorControllerContext, aZ as LLMMessageBuilder, aX as LLMRole, ay as LLMistOptions, am as MessageInterceptorContext, au as MessageTurn, d as MockBuilder, f as MockManager, l as MockMatcher, n as MockMatcherContext, o as MockOptions, M as MockProviderAdapter, p as MockRegistration, q as MockResponse, r as MockStats, b2 as ModelFeatures, b6 as ModelIdentifierParser, b3 as ModelLimits, b4 as ModelPricing, an as ObserveChunkContext, av as ObserveCompactionContext, ao as ObserveGadgetCompleteContext, ap as ObserveGadgetStartContext, aq as ObserveLLMCallContext, ar as ObserveLLMCompleteContext, as as ObserveLLMErrorContext, at as Observers, b8 as PromptConfig, b9 as PromptContext, ba as PromptTemplate, b5 as ProviderIdentifier, bg as QuickOptions, aI as TextContentPart, bo as TextOnlyAction, bp as TextOnlyContext, bq as TextOnlyCustomHandler, br as TextOnlyGadgetConfig, bs as TextOnlyHandler, bt as TextOnlyStrategy, $ as TrailingMessage, a0 as TrailingMessageContext, a$ as VisionAnalyzeOptions, b0 as VisionAnalyzeResult, aJ as audioFromBase64, aK as audioFromBuffer, a3 as collectEvents, a4 as collectText, bh as complete, c as createMockAdapter, e as createMockClient, h as createMockStream, i as createTextMockStream, aL as detectAudioMimeType, aM as detectImageMimeType, aY as extractText, g as getMockManager, aN as imageFromBase64, aO as imageFromBuffer, aP as imageFromUrl, aQ as isAudioPart, aR as isDataUrl, aS as isImagePart, aT as isTextPart, m as mockLLM, a_ as normalizeContent, aU as parseDataUrl, bd as resolveHintTemplate, be as resolvePromptTemplate, bf as resolveRulesTemplate, a5 as runWithHandlers, bi as stream, aV as text, aW as toBase64 } from './mock-stream-ga4KIiwX.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';
@@ -740,7 +740,7 @@ declare class ConversationManager implements IConversationManager {
740
740
  private readonly endPrefix?;
741
741
  private readonly argPrefix?;
742
742
  constructor(baseMessages: LLMMessage[], initialMessages: LLMMessage[], options?: ConversationManagerOptions);
743
- addUserMessage(content: string): void;
743
+ addUserMessage(content: MessageContent): void;
744
744
  addAssistantMessage(content: string): void;
745
745
  addGadgetCall(gadgetName: string, parameters: Record<string, unknown>, result: string): void;
746
746
  getMessages(): LLMMessage[];
@@ -843,6 +843,12 @@ declare class StreamProcessor {
843
843
  private accumulatedText;
844
844
  private shouldStopExecution;
845
845
  private observerFailureCount;
846
+ /** Gadgets waiting for their dependencies to complete */
847
+ private pendingGadgets;
848
+ /** Completed gadget results, keyed by invocation ID */
849
+ private completedResults;
850
+ /** Invocation IDs of gadgets that have failed (error or skipped due to dependency) */
851
+ private failedInvocations;
846
852
  constructor(options: StreamProcessorOptions);
847
853
  /**
848
854
  * Process an LLM stream and return structured results.
@@ -857,9 +863,28 @@ declare class StreamProcessor {
857
863
  */
858
864
  private processTextEvent;
859
865
  /**
860
- * Process a gadget call through the full lifecycle.
866
+ * Process a gadget call through the full lifecycle, handling dependencies.
867
+ *
868
+ * Gadgets without dependencies (or with all dependencies satisfied) execute immediately.
869
+ * Gadgets with unsatisfied dependencies are queued for later execution.
870
+ * After each execution, pending gadgets are checked to see if they can now run.
861
871
  */
862
872
  private processGadgetCall;
873
+ /**
874
+ * Execute a gadget through the full hook lifecycle.
875
+ * This is the core execution logic, extracted from processGadgetCall.
876
+ */
877
+ private executeGadgetWithHooks;
878
+ /**
879
+ * Handle a gadget that cannot execute because a dependency failed.
880
+ * Calls the onDependencySkipped controller to allow customization.
881
+ */
882
+ private handleFailedDependency;
883
+ /**
884
+ * Process pending gadgets whose dependencies are now satisfied.
885
+ * Executes ready gadgets in parallel and continues until no more can be triggered.
886
+ */
887
+ private processPendingGadgets;
863
888
  /**
864
889
  * Safely execute an observer, catching and logging any errors.
865
890
  * Observers are non-critical, so errors are logged but don't crash the system.
@@ -1682,8 +1707,14 @@ declare class StreamParser {
1682
1707
  constructor(options?: StreamParserOptions);
1683
1708
  private takeTextUntil;
1684
1709
  /**
1685
- * Parse gadget name, handling both old format (name:invocationId) and new format (just name).
1686
- * For new format, generates a unique invocation ID.
1710
+ * Parse gadget name with optional invocation ID and dependencies.
1711
+ *
1712
+ * Supported formats:
1713
+ * - `GadgetName` - Auto-generate ID, no dependencies
1714
+ * - `GadgetName:my_id` - Explicit ID, no dependencies
1715
+ * - `GadgetName:my_id:dep1,dep2` - Explicit ID with dependencies
1716
+ *
1717
+ * Dependencies must be comma-separated invocation IDs.
1687
1718
  */
1688
1719
  private parseGadgetName;
1689
1720
  /**
@@ -2077,6 +2108,15 @@ declare class AnthropicMessagesProvider extends BaseProviderAdapter {
2077
2108
  supportsSpeechGeneration(_modelId: string): boolean;
2078
2109
  generateSpeech(): Promise<never>;
2079
2110
  protected buildRequestPayload(options: LLMGenerationOptions, descriptor: ModelDescriptor, spec: ModelSpec | undefined, messages: LLMMessage[]): MessageCreateParamsStreaming;
2111
+ /**
2112
+ * Convert llmist content to Anthropic's content block format.
2113
+ * Handles text, images (base64 only), and applies cache_control.
2114
+ */
2115
+ private convertToAnthropicContent;
2116
+ /**
2117
+ * Convert an image content part to Anthropic's image block format.
2118
+ */
2119
+ private convertImagePart;
2080
2120
  protected executeStreamRequest(payload: MessageCreateParamsStreaming, signal?: AbortSignal): Promise<AsyncIterable<MessageStreamEvent>>;
2081
2121
  protected wrapStream(iterable: AsyncIterable<unknown>): LLMStream;
2082
2122
  /**
@@ -2108,6 +2148,24 @@ declare function createAnthropicProviderFromEnv(): AnthropicMessagesProvider | n
2108
2148
 
2109
2149
  declare function discoverProviderAdapters(): ProviderAdapter[];
2110
2150
 
2151
+ /**
2152
+ * Gemini content part - can be text or inline data (images/audio).
2153
+ */
2154
+ type GeminiPart = {
2155
+ text: string;
2156
+ } | {
2157
+ inlineData: {
2158
+ mimeType: string;
2159
+ data: string;
2160
+ };
2161
+ };
2162
+ /**
2163
+ * Gemini content with role and multimodal parts.
2164
+ */
2165
+ type GeminiContent = {
2166
+ role: string;
2167
+ parts: GeminiPart[];
2168
+ };
2111
2169
  type GeminiChunk = {
2112
2170
  text?: () => string;
2113
2171
  candidates?: Array<{
@@ -2137,22 +2195,12 @@ declare class GeminiGenerativeProvider extends BaseProviderAdapter {
2137
2195
  generateSpeech(options: SpeechGenerationOptions): Promise<SpeechGenerationResult>;
2138
2196
  protected buildRequestPayload(options: LLMGenerationOptions, descriptor: ModelDescriptor, _spec: ModelSpec | undefined, messages: LLMMessage[]): {
2139
2197
  model: string;
2140
- contents: Array<{
2141
- role: string;
2142
- parts: Array<{
2143
- text: string;
2144
- }>;
2145
- }>;
2198
+ contents: GeminiContent[];
2146
2199
  config: Record<string, unknown>;
2147
2200
  };
2148
2201
  protected executeStreamRequest(payload: {
2149
2202
  model: string;
2150
- contents: Array<{
2151
- role: string;
2152
- parts: Array<{
2153
- text: string;
2154
- }>;
2155
- }>;
2203
+ contents: GeminiContent[];
2156
2204
  config: Record<string, unknown>;
2157
2205
  }, signal?: AbortSignal): Promise<AsyncIterable<GeminiChunk>>;
2158
2206
  /**
@@ -2170,8 +2218,16 @@ declare class GeminiGenerativeProvider extends BaseProviderAdapter {
2170
2218
  * - Model: "Understood."
2171
2219
  */
2172
2220
  private convertMessagesToContents;
2221
+ /**
2222
+ * Merge consecutive messages with the same role (required by Gemini).
2223
+ * Handles multimodal content by converting to Gemini's part format.
2224
+ */
2173
2225
  private mergeConsecutiveMessages;
2174
- private convertContentsForNewSDK;
2226
+ /**
2227
+ * Convert llmist content to Gemini's part format.
2228
+ * Handles text, images, and audio (Gemini supports all three).
2229
+ */
2230
+ private convertToGeminiParts;
2175
2231
  private buildGenerationConfig;
2176
2232
  protected wrapStream(iterable: AsyncIterable<unknown>): LLMStream;
2177
2233
  private extractText;
@@ -2215,6 +2271,23 @@ declare class OpenAIChatProvider extends BaseProviderAdapter {
2215
2271
  supportsSpeechGeneration(modelId: string): boolean;
2216
2272
  generateSpeech(options: SpeechGenerationOptions): Promise<SpeechGenerationResult>;
2217
2273
  protected buildRequestPayload(options: LLMGenerationOptions, descriptor: ModelDescriptor, spec: ModelSpec | undefined, messages: LLMMessage[]): Parameters<OpenAI["chat"]["completions"]["create"]>[0];
2274
+ /**
2275
+ * Convert an LLMMessage to OpenAI's ChatCompletionMessageParam.
2276
+ * Handles role-specific content type requirements:
2277
+ * - system/assistant: string content only
2278
+ * - user: string or multimodal array content
2279
+ */
2280
+ private convertToOpenAIMessage;
2281
+ /**
2282
+ * Convert llmist content to OpenAI's content format.
2283
+ * Optimizes by returning string for text-only content, array for multimodal.
2284
+ */
2285
+ private convertToOpenAIContent;
2286
+ /**
2287
+ * Convert an image content part to OpenAI's image_url format.
2288
+ * Supports both URLs and base64 data URLs.
2289
+ */
2290
+ private convertImagePart;
2218
2291
  protected executeStreamRequest(payload: Parameters<OpenAI["chat"]["completions"]["create"]>[0], signal?: AbortSignal): Promise<AsyncIterable<ChatCompletionChunk>>;
2219
2292
  protected wrapStream(iterable: AsyncIterable<unknown>): LLMStream;
2220
2293
  /**
@@ -2244,4 +2317,4 @@ declare class OpenAIChatProvider extends BaseProviderAdapter {
2244
2317
  }
2245
2318
  declare function createOpenAIProviderFromEnv(): OpenAIChatProvider | null;
2246
2319
 
2247
- export { AbortError, AgentHooks, AnthropicMessagesProvider, BaseGadget, BreakLoopException, CompactionConfig, CompactionContext, CompactionEvent, CompactionManager, CompactionResult, CompactionStats, CompactionStrategy, ConversationManager, type CreateGadgetConfig, ExecutionContext, Gadget, type GadgetConfig, GadgetExample, GadgetExecuteReturn, GadgetExecutionResult, GadgetExecutor, GadgetOutputStore, GadgetRegistry, GeminiGenerativeProvider, HintTemplate, type HintsConfig, HookPresets, HumanInputException, HybridStrategy, IConversationManager, type IterationHintOptions, LLMGenerationOptions, LLMMessage, LLMStream, LLMStreamChunk, LLMist, type LoggerOptions, type LoggingOptions, MODEL_ALIASES, ModelDescriptor, ModelRegistry, ModelSpec, OpenAIChatProvider, type ParallelGadgetHintOptions, ParsedGadgetCall, ProviderAdapter, ResolvedCompactionConfig, SlidingWindowStrategy, type StoredOutput, StreamEvent, StreamParser, type StreamProcessingResult, StreamProcessor, type StreamProcessorOptions, SummarizationStrategy, TokenUsage, type ValidationIssue, type ValidationResult, createAnthropicProviderFromEnv, createGadget, createGadgetOutputViewer, createGeminiProviderFromEnv, createHints, createLogger, createOpenAIProviderFromEnv, defaultLogger, discoverProviderAdapters, getModelId, getProvider, hasProviderPrefix, iterationProgressHint, parallelGadgetHint, resolveModel, validateAndApplyDefaults, validateGadgetParams };
2320
+ export { AbortError, AgentHooks, AnthropicMessagesProvider, BaseGadget, BreakLoopException, CompactionConfig, CompactionContext, CompactionEvent, CompactionManager, CompactionResult, CompactionStats, CompactionStrategy, ConversationManager, type CreateGadgetConfig, ExecutionContext, Gadget, type GadgetConfig, GadgetExample, GadgetExecuteReturn, GadgetExecutionResult, GadgetExecutor, GadgetOutputStore, GadgetRegistry, GeminiGenerativeProvider, HintTemplate, type HintsConfig, HookPresets, HumanInputException, HybridStrategy, IConversationManager, type IterationHintOptions, LLMGenerationOptions, LLMMessage, LLMStream, LLMStreamChunk, LLMist, type LoggerOptions, type LoggingOptions, MODEL_ALIASES, MessageContent, ModelDescriptor, ModelRegistry, ModelSpec, OpenAIChatProvider, type ParallelGadgetHintOptions, ParsedGadgetCall, ProviderAdapter, ResolvedCompactionConfig, SlidingWindowStrategy, type StoredOutput, StreamEvent, StreamParser, type StreamProcessingResult, StreamProcessor, type StreamProcessorOptions, SummarizationStrategy, TokenUsage, type ValidationIssue, type ValidationResult, createAnthropicProviderFromEnv, createGadget, createGadgetOutputViewer, createGeminiProviderFromEnv, createHints, createLogger, createOpenAIProviderFromEnv, defaultLogger, discoverProviderAdapters, getModelId, getProvider, hasProviderPrefix, iterationProgressHint, parallelGadgetHint, resolveModel, validateAndApplyDefaults, validateGadgetParams };
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, 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';
3
+ import { A as AgentHooks, s as ModelRegistry, I as IConversationManager, b as LLMMessage, t as MessageContent, S as StreamEvent, T as TokenUsage, G as GadgetRegistry, u as LLMist, a as LLMStreamChunk, C as CompactionStrategy, R as ResolvedCompactionConfig, v as CompactionContext, w as CompactionResult, x as CompactionConfig, y as CompactionEvent, z as CompactionStats, H as HintTemplate, E as ExecutionContext, D as GadgetExecuteReturn, F as GadgetExample, B as BaseGadget, P as ParsedGadgetCall, J as GadgetExecutionResult, K as ProviderAdapter, N as ModelDescriptor, O as ModelSpec, Q as LLMGenerationOptions, L as LLMStream, U as ImageModelSpec, V as ImageGenerationOptions, W as ImageGenerationResult, X as SpeechModelSpec, Y as SpeechGenerationOptions, Z as SpeechGenerationResult } from './mock-stream-ga4KIiwX.js';
4
+ export { a6 as AfterGadgetExecutionAction, a7 as AfterGadgetExecutionControllerContext, a8 as AfterLLMCallAction, a9 as AfterLLMCallControllerContext, aa as AfterLLMErrorAction, a1 as AgentBuilder, ab as AgentOptions, az as AudioContentPart, aA as AudioMimeType, aB as AudioSource, ac as BeforeGadgetExecutionAction, ad as BeforeLLMCallAction, ae as ChunkInterceptorContext, aC as ContentPart, af as Controllers, b1 as CostEstimate, bl as CostReportingLLMist, aw as DEFAULT_COMPACTION_CONFIG, bb as DEFAULT_HINTS, bc as DEFAULT_PROMPTS, ax as DEFAULT_SUMMARIZATION_PROMPT, a2 as EventHandlers, bj as GadgetClass, bm as GadgetExecuteResult, ag as GadgetExecutionControllerContext, bk as GadgetOrClass, ah as GadgetParameterInterceptorContext, ai as GadgetResultInterceptorContext, bn as GadgetSkippedEvent, b7 as HintContext, _ as HistoryMessage, aD as ImageBase64Source, aE as ImageContentPart, aF as ImageMimeType, aG as ImageSource, aH as ImageUrlSource, aj as Interceptors, ak as LLMCallControllerContext, al as LLMErrorControllerContext, aZ as LLMMessageBuilder, aX as LLMRole, ay as LLMistOptions, am as MessageInterceptorContext, au as MessageTurn, d as MockBuilder, f as MockManager, l as MockMatcher, n as MockMatcherContext, o as MockOptions, M as MockProviderAdapter, p as MockRegistration, q as MockResponse, r as MockStats, b2 as ModelFeatures, b6 as ModelIdentifierParser, b3 as ModelLimits, b4 as ModelPricing, an as ObserveChunkContext, av as ObserveCompactionContext, ao as ObserveGadgetCompleteContext, ap as ObserveGadgetStartContext, aq as ObserveLLMCallContext, ar as ObserveLLMCompleteContext, as as ObserveLLMErrorContext, at as Observers, b8 as PromptConfig, b9 as PromptContext, ba as PromptTemplate, b5 as ProviderIdentifier, bg as QuickOptions, aI as TextContentPart, bo as TextOnlyAction, bp as TextOnlyContext, bq as TextOnlyCustomHandler, br as TextOnlyGadgetConfig, bs as TextOnlyHandler, bt as TextOnlyStrategy, $ as TrailingMessage, a0 as TrailingMessageContext, a$ as VisionAnalyzeOptions, b0 as VisionAnalyzeResult, aJ as audioFromBase64, aK as audioFromBuffer, a3 as collectEvents, a4 as collectText, bh as complete, c as createMockAdapter, e as createMockClient, h as createMockStream, i as createTextMockStream, aL as detectAudioMimeType, aM as detectImageMimeType, aY as extractText, g as getMockManager, aN as imageFromBase64, aO as imageFromBuffer, aP as imageFromUrl, aQ as isAudioPart, aR as isDataUrl, aS as isImagePart, aT as isTextPart, m as mockLLM, a_ as normalizeContent, aU as parseDataUrl, bd as resolveHintTemplate, be as resolvePromptTemplate, bf as resolveRulesTemplate, a5 as runWithHandlers, bi as stream, aV as text, aW as toBase64 } from './mock-stream-ga4KIiwX.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';
@@ -740,7 +740,7 @@ declare class ConversationManager implements IConversationManager {
740
740
  private readonly endPrefix?;
741
741
  private readonly argPrefix?;
742
742
  constructor(baseMessages: LLMMessage[], initialMessages: LLMMessage[], options?: ConversationManagerOptions);
743
- addUserMessage(content: string): void;
743
+ addUserMessage(content: MessageContent): void;
744
744
  addAssistantMessage(content: string): void;
745
745
  addGadgetCall(gadgetName: string, parameters: Record<string, unknown>, result: string): void;
746
746
  getMessages(): LLMMessage[];
@@ -843,6 +843,12 @@ declare class StreamProcessor {
843
843
  private accumulatedText;
844
844
  private shouldStopExecution;
845
845
  private observerFailureCount;
846
+ /** Gadgets waiting for their dependencies to complete */
847
+ private pendingGadgets;
848
+ /** Completed gadget results, keyed by invocation ID */
849
+ private completedResults;
850
+ /** Invocation IDs of gadgets that have failed (error or skipped due to dependency) */
851
+ private failedInvocations;
846
852
  constructor(options: StreamProcessorOptions);
847
853
  /**
848
854
  * Process an LLM stream and return structured results.
@@ -857,9 +863,28 @@ declare class StreamProcessor {
857
863
  */
858
864
  private processTextEvent;
859
865
  /**
860
- * Process a gadget call through the full lifecycle.
866
+ * Process a gadget call through the full lifecycle, handling dependencies.
867
+ *
868
+ * Gadgets without dependencies (or with all dependencies satisfied) execute immediately.
869
+ * Gadgets with unsatisfied dependencies are queued for later execution.
870
+ * After each execution, pending gadgets are checked to see if they can now run.
861
871
  */
862
872
  private processGadgetCall;
873
+ /**
874
+ * Execute a gadget through the full hook lifecycle.
875
+ * This is the core execution logic, extracted from processGadgetCall.
876
+ */
877
+ private executeGadgetWithHooks;
878
+ /**
879
+ * Handle a gadget that cannot execute because a dependency failed.
880
+ * Calls the onDependencySkipped controller to allow customization.
881
+ */
882
+ private handleFailedDependency;
883
+ /**
884
+ * Process pending gadgets whose dependencies are now satisfied.
885
+ * Executes ready gadgets in parallel and continues until no more can be triggered.
886
+ */
887
+ private processPendingGadgets;
863
888
  /**
864
889
  * Safely execute an observer, catching and logging any errors.
865
890
  * Observers are non-critical, so errors are logged but don't crash the system.
@@ -1682,8 +1707,14 @@ declare class StreamParser {
1682
1707
  constructor(options?: StreamParserOptions);
1683
1708
  private takeTextUntil;
1684
1709
  /**
1685
- * Parse gadget name, handling both old format (name:invocationId) and new format (just name).
1686
- * For new format, generates a unique invocation ID.
1710
+ * Parse gadget name with optional invocation ID and dependencies.
1711
+ *
1712
+ * Supported formats:
1713
+ * - `GadgetName` - Auto-generate ID, no dependencies
1714
+ * - `GadgetName:my_id` - Explicit ID, no dependencies
1715
+ * - `GadgetName:my_id:dep1,dep2` - Explicit ID with dependencies
1716
+ *
1717
+ * Dependencies must be comma-separated invocation IDs.
1687
1718
  */
1688
1719
  private parseGadgetName;
1689
1720
  /**
@@ -2077,6 +2108,15 @@ declare class AnthropicMessagesProvider extends BaseProviderAdapter {
2077
2108
  supportsSpeechGeneration(_modelId: string): boolean;
2078
2109
  generateSpeech(): Promise<never>;
2079
2110
  protected buildRequestPayload(options: LLMGenerationOptions, descriptor: ModelDescriptor, spec: ModelSpec | undefined, messages: LLMMessage[]): MessageCreateParamsStreaming;
2111
+ /**
2112
+ * Convert llmist content to Anthropic's content block format.
2113
+ * Handles text, images (base64 only), and applies cache_control.
2114
+ */
2115
+ private convertToAnthropicContent;
2116
+ /**
2117
+ * Convert an image content part to Anthropic's image block format.
2118
+ */
2119
+ private convertImagePart;
2080
2120
  protected executeStreamRequest(payload: MessageCreateParamsStreaming, signal?: AbortSignal): Promise<AsyncIterable<MessageStreamEvent>>;
2081
2121
  protected wrapStream(iterable: AsyncIterable<unknown>): LLMStream;
2082
2122
  /**
@@ -2108,6 +2148,24 @@ declare function createAnthropicProviderFromEnv(): AnthropicMessagesProvider | n
2108
2148
 
2109
2149
  declare function discoverProviderAdapters(): ProviderAdapter[];
2110
2150
 
2151
+ /**
2152
+ * Gemini content part - can be text or inline data (images/audio).
2153
+ */
2154
+ type GeminiPart = {
2155
+ text: string;
2156
+ } | {
2157
+ inlineData: {
2158
+ mimeType: string;
2159
+ data: string;
2160
+ };
2161
+ };
2162
+ /**
2163
+ * Gemini content with role and multimodal parts.
2164
+ */
2165
+ type GeminiContent = {
2166
+ role: string;
2167
+ parts: GeminiPart[];
2168
+ };
2111
2169
  type GeminiChunk = {
2112
2170
  text?: () => string;
2113
2171
  candidates?: Array<{
@@ -2137,22 +2195,12 @@ declare class GeminiGenerativeProvider extends BaseProviderAdapter {
2137
2195
  generateSpeech(options: SpeechGenerationOptions): Promise<SpeechGenerationResult>;
2138
2196
  protected buildRequestPayload(options: LLMGenerationOptions, descriptor: ModelDescriptor, _spec: ModelSpec | undefined, messages: LLMMessage[]): {
2139
2197
  model: string;
2140
- contents: Array<{
2141
- role: string;
2142
- parts: Array<{
2143
- text: string;
2144
- }>;
2145
- }>;
2198
+ contents: GeminiContent[];
2146
2199
  config: Record<string, unknown>;
2147
2200
  };
2148
2201
  protected executeStreamRequest(payload: {
2149
2202
  model: string;
2150
- contents: Array<{
2151
- role: string;
2152
- parts: Array<{
2153
- text: string;
2154
- }>;
2155
- }>;
2203
+ contents: GeminiContent[];
2156
2204
  config: Record<string, unknown>;
2157
2205
  }, signal?: AbortSignal): Promise<AsyncIterable<GeminiChunk>>;
2158
2206
  /**
@@ -2170,8 +2218,16 @@ declare class GeminiGenerativeProvider extends BaseProviderAdapter {
2170
2218
  * - Model: "Understood."
2171
2219
  */
2172
2220
  private convertMessagesToContents;
2221
+ /**
2222
+ * Merge consecutive messages with the same role (required by Gemini).
2223
+ * Handles multimodal content by converting to Gemini's part format.
2224
+ */
2173
2225
  private mergeConsecutiveMessages;
2174
- private convertContentsForNewSDK;
2226
+ /**
2227
+ * Convert llmist content to Gemini's part format.
2228
+ * Handles text, images, and audio (Gemini supports all three).
2229
+ */
2230
+ private convertToGeminiParts;
2175
2231
  private buildGenerationConfig;
2176
2232
  protected wrapStream(iterable: AsyncIterable<unknown>): LLMStream;
2177
2233
  private extractText;
@@ -2215,6 +2271,23 @@ declare class OpenAIChatProvider extends BaseProviderAdapter {
2215
2271
  supportsSpeechGeneration(modelId: string): boolean;
2216
2272
  generateSpeech(options: SpeechGenerationOptions): Promise<SpeechGenerationResult>;
2217
2273
  protected buildRequestPayload(options: LLMGenerationOptions, descriptor: ModelDescriptor, spec: ModelSpec | undefined, messages: LLMMessage[]): Parameters<OpenAI["chat"]["completions"]["create"]>[0];
2274
+ /**
2275
+ * Convert an LLMMessage to OpenAI's ChatCompletionMessageParam.
2276
+ * Handles role-specific content type requirements:
2277
+ * - system/assistant: string content only
2278
+ * - user: string or multimodal array content
2279
+ */
2280
+ private convertToOpenAIMessage;
2281
+ /**
2282
+ * Convert llmist content to OpenAI's content format.
2283
+ * Optimizes by returning string for text-only content, array for multimodal.
2284
+ */
2285
+ private convertToOpenAIContent;
2286
+ /**
2287
+ * Convert an image content part to OpenAI's image_url format.
2288
+ * Supports both URLs and base64 data URLs.
2289
+ */
2290
+ private convertImagePart;
2218
2291
  protected executeStreamRequest(payload: Parameters<OpenAI["chat"]["completions"]["create"]>[0], signal?: AbortSignal): Promise<AsyncIterable<ChatCompletionChunk>>;
2219
2292
  protected wrapStream(iterable: AsyncIterable<unknown>): LLMStream;
2220
2293
  /**
@@ -2244,4 +2317,4 @@ declare class OpenAIChatProvider extends BaseProviderAdapter {
2244
2317
  }
2245
2318
  declare function createOpenAIProviderFromEnv(): OpenAIChatProvider | null;
2246
2319
 
2247
- export { AbortError, AgentHooks, AnthropicMessagesProvider, BaseGadget, BreakLoopException, CompactionConfig, CompactionContext, CompactionEvent, CompactionManager, CompactionResult, CompactionStats, CompactionStrategy, ConversationManager, type CreateGadgetConfig, ExecutionContext, Gadget, type GadgetConfig, GadgetExample, GadgetExecuteReturn, GadgetExecutionResult, GadgetExecutor, GadgetOutputStore, GadgetRegistry, GeminiGenerativeProvider, HintTemplate, type HintsConfig, HookPresets, HumanInputException, HybridStrategy, IConversationManager, type IterationHintOptions, LLMGenerationOptions, LLMMessage, LLMStream, LLMStreamChunk, LLMist, type LoggerOptions, type LoggingOptions, MODEL_ALIASES, ModelDescriptor, ModelRegistry, ModelSpec, OpenAIChatProvider, type ParallelGadgetHintOptions, ParsedGadgetCall, ProviderAdapter, ResolvedCompactionConfig, SlidingWindowStrategy, type StoredOutput, StreamEvent, StreamParser, type StreamProcessingResult, StreamProcessor, type StreamProcessorOptions, SummarizationStrategy, TokenUsage, type ValidationIssue, type ValidationResult, createAnthropicProviderFromEnv, createGadget, createGadgetOutputViewer, createGeminiProviderFromEnv, createHints, createLogger, createOpenAIProviderFromEnv, defaultLogger, discoverProviderAdapters, getModelId, getProvider, hasProviderPrefix, iterationProgressHint, parallelGadgetHint, resolveModel, validateAndApplyDefaults, validateGadgetParams };
2320
+ export { AbortError, AgentHooks, AnthropicMessagesProvider, BaseGadget, BreakLoopException, CompactionConfig, CompactionContext, CompactionEvent, CompactionManager, CompactionResult, CompactionStats, CompactionStrategy, ConversationManager, type CreateGadgetConfig, ExecutionContext, Gadget, type GadgetConfig, GadgetExample, GadgetExecuteReturn, GadgetExecutionResult, GadgetExecutor, GadgetOutputStore, GadgetRegistry, GeminiGenerativeProvider, HintTemplate, type HintsConfig, HookPresets, HumanInputException, HybridStrategy, IConversationManager, type IterationHintOptions, LLMGenerationOptions, LLMMessage, LLMStream, LLMStreamChunk, LLMist, type LoggerOptions, type LoggingOptions, MODEL_ALIASES, MessageContent, ModelDescriptor, ModelRegistry, ModelSpec, OpenAIChatProvider, type ParallelGadgetHintOptions, ParsedGadgetCall, ProviderAdapter, ResolvedCompactionConfig, SlidingWindowStrategy, type StoredOutput, StreamEvent, StreamParser, type StreamProcessingResult, StreamProcessor, type StreamProcessorOptions, SummarizationStrategy, TokenUsage, type ValidationIssue, type ValidationResult, createAnthropicProviderFromEnv, createGadget, createGadgetOutputViewer, createGeminiProviderFromEnv, createHints, createLogger, createOpenAIProviderFromEnv, defaultLogger, discoverProviderAdapters, getModelId, getProvider, hasProviderPrefix, iterationProgressHint, parallelGadgetHint, resolveModel, validateAndApplyDefaults, validateGadgetParams };
package/dist/index.js CHANGED
@@ -5,7 +5,7 @@ import {
5
5
  iterationProgressHint,
6
6
  parallelGadgetHint,
7
7
  z
8
- } from "./chunk-QFRVTS5F.js";
8
+ } from "./chunk-IHSZUAYN.js";
9
9
  import {
10
10
  AbortError,
11
11
  AgentBuilder,
@@ -37,6 +37,8 @@ import {
37
37
  StreamParser,
38
38
  StreamProcessor,
39
39
  SummarizationStrategy,
40
+ audioFromBase64,
41
+ audioFromBuffer,
40
42
  collectEvents,
41
43
  collectText,
42
44
  complete,
@@ -51,21 +53,35 @@ import {
51
53
  createOpenAIProviderFromEnv,
52
54
  createTextMockStream,
53
55
  defaultLogger,
56
+ detectAudioMimeType,
57
+ detectImageMimeType,
54
58
  discoverProviderAdapters,
59
+ extractText,
55
60
  getMockManager,
56
61
  getModelId,
57
62
  getProvider,
58
63
  hasProviderPrefix,
64
+ imageFromBase64,
65
+ imageFromBuffer,
66
+ imageFromUrl,
67
+ isAudioPart,
68
+ isDataUrl,
69
+ isImagePart,
70
+ isTextPart,
59
71
  mockLLM,
72
+ normalizeContent,
73
+ parseDataUrl,
60
74
  resolveHintTemplate,
61
75
  resolveModel,
62
76
  resolvePromptTemplate,
63
77
  resolveRulesTemplate,
64
78
  runWithHandlers,
65
79
  stream,
80
+ text,
81
+ toBase64,
66
82
  validateAndApplyDefaults,
67
83
  validateGadgetParams
68
- } from "./chunk-6ZDUWO6N.js";
84
+ } from "./chunk-YHS2DYXP.js";
69
85
  export {
70
86
  AbortError,
71
87
  AgentBuilder,
@@ -99,6 +115,8 @@ export {
99
115
  StreamParser,
100
116
  StreamProcessor,
101
117
  SummarizationStrategy,
118
+ audioFromBase64,
119
+ audioFromBuffer,
102
120
  collectEvents,
103
121
  collectText,
104
122
  complete,
@@ -114,20 +132,34 @@ export {
114
132
  createOpenAIProviderFromEnv,
115
133
  createTextMockStream,
116
134
  defaultLogger,
135
+ detectAudioMimeType,
136
+ detectImageMimeType,
117
137
  discoverProviderAdapters,
138
+ extractText,
118
139
  getMockManager,
119
140
  getModelId,
120
141
  getProvider,
121
142
  hasProviderPrefix,
143
+ imageFromBase64,
144
+ imageFromBuffer,
145
+ imageFromUrl,
146
+ isAudioPart,
147
+ isDataUrl,
148
+ isImagePart,
149
+ isTextPart,
122
150
  iterationProgressHint,
123
151
  mockLLM,
152
+ normalizeContent,
124
153
  parallelGadgetHint,
154
+ parseDataUrl,
125
155
  resolveHintTemplate,
126
156
  resolveModel,
127
157
  resolvePromptTemplate,
128
158
  resolveRulesTemplate,
129
159
  runWithHandlers,
130
160
  stream,
161
+ text,
162
+ toBase64,
131
163
  validateAndApplyDefaults,
132
164
  validateGadgetParams,
133
165
  z