llmist 16.0.2 → 16.0.4

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
@@ -2058,12 +2058,13 @@ interface Interceptors {
2058
2058
  */
2059
2059
  interceptGadgetParameters?: (parameters: Readonly<Record<string, unknown>>, context: GadgetParameterInterceptorContext) => Record<string, unknown>;
2060
2060
  /**
2061
- * Intercept and transform gadget results after execution.
2061
+ * Intercept and transform gadget results and error messages after execution.
2062
2062
  * This affects what gets sent back to the LLM and stored in history.
2063
+ * Called for both successful results (result.result) and errors (result.error).
2063
2064
  *
2064
- * @param result - The gadget result text
2065
+ * @param result - The gadget result or error text
2065
2066
  * @param context - Context information including parameters and execution time
2066
- * @returns Transformed result text (cannot be suppressed)
2067
+ * @returns Transformed text (cannot be suppressed)
2067
2068
  */
2068
2069
  interceptGadgetResult?: (result: string, context: GadgetResultInterceptorContext) => string;
2069
2070
  }
@@ -5519,7 +5520,9 @@ declare class AgentBuilder {
5519
5520
  */
5520
5521
  /**
5521
5522
  * Build AgentOptions with the given user prompt.
5522
- * Centralizes options construction for ask(), askWithImage(), and askWithContent().
5523
+ * Centralizes options construction for ask(), askWithImage(), askWithContent(), and build().
5524
+ *
5525
+ * @param userPrompt - Optional user prompt (omitted for build() which has no prompt)
5523
5526
  */
5524
5527
  private buildAgentOptions;
5525
5528
  ask(userPrompt: string): Agent;
@@ -6633,10 +6636,6 @@ declare class Agent {
6633
6636
  * Handle text-only response (no gadgets called).
6634
6637
  */
6635
6638
  private handleTextOnlyResponse;
6636
- /**
6637
- * Safely execute an observer, catching and logging any errors.
6638
- */
6639
- private safeObserve;
6640
6639
  /**
6641
6640
  * Resolve max tokens from model catalog.
6642
6641
  */
@@ -6744,6 +6743,56 @@ declare class Agent {
6744
6743
  * ```
6745
6744
  */
6746
6745
 
6746
+ /**
6747
+ * State container for file logging session.
6748
+ * Encapsulates all mutable state to enable session isolation and proper
6749
+ * handling of concurrent subagents.
6750
+ *
6751
+ * @remarks
6752
+ * Using a state object instead of module-level globals provides:
6753
+ * - **Session isolation**: Multiple agent sessions don't interfere with each other
6754
+ * - **Testability**: Tests can inject fresh state without needing to reset globals
6755
+ * - **Concurrent subagent support**: Context-based keys prevent race conditions
6756
+ */
6757
+ interface FileLoggingState {
6758
+ /** Counter per directory path (normalized) */
6759
+ readonly counters: Map<string, number>;
6760
+ /**
6761
+ * Subagent context key -> assigned directory path.
6762
+ * Key format: `${parentDir}:${parentGadgetInvocationId}`
6763
+ */
6764
+ readonly subagentDirectories: Map<string, string>;
6765
+ /**
6766
+ * Context key -> active directory for that execution context.
6767
+ * Key format: `${parentGadgetInvocationId}:${depth}` (or "root:0" for main agent)
6768
+ *
6769
+ * This replaces the previous depth-only keying which caused race conditions
6770
+ * when multiple subagents at the same depth ran concurrently.
6771
+ */
6772
+ readonly activeDirectoryByContext: Map<string, string>;
6773
+ }
6774
+ /**
6775
+ * Creates a fresh file logging state container.
6776
+ *
6777
+ * Use this to create isolated state for testing or when running multiple
6778
+ * independent agent sessions that shouldn't share counters.
6779
+ *
6780
+ * @example
6781
+ * ```typescript
6782
+ * // For testing with isolated state:
6783
+ * const state = createFileLoggingState();
6784
+ * const hooks = createFileLoggingHooks({ directory: './logs' }, state);
6785
+ *
6786
+ * // For production (uses default shared state):
6787
+ * const hooks = createFileLoggingHooks({ directory: './logs' });
6788
+ * ```
6789
+ */
6790
+ declare function createFileLoggingState(): FileLoggingState;
6791
+ /**
6792
+ * Resets the default global state. For testing only.
6793
+ * @internal
6794
+ */
6795
+ declare function resetFileLoggingState(): void;
6747
6796
  /**
6748
6797
  * Options for configuring file-based LLM logging.
6749
6798
  */
@@ -6786,10 +6835,14 @@ interface FileWrittenInfo {
6786
6835
  filePath: string;
6787
6836
  /** Type of log file */
6788
6837
  type: "request" | "response";
6789
- /** LLM call number (1-indexed) */
6838
+ /** LLM call number (1-indexed) within the current directory */
6790
6839
  callNumber: number;
6791
6840
  /** Length of the written content in characters */
6792
6841
  contentLength: number;
6842
+ /** Gadget invocation ID that spawned this subagent (undefined for main agent) */
6843
+ parentGadgetInvocationId?: string;
6844
+ /** Subagent depth (undefined for main agent) */
6845
+ depth?: number;
6793
6846
  }
6794
6847
  /**
6795
6848
  * Formats LLM messages as plain text for debugging.
@@ -7089,6 +7142,8 @@ declare class HookPresets {
7089
7142
  /**
7090
7143
  * Tracks cumulative token usage across all LLM calls.
7091
7144
  *
7145
+ * @public
7146
+ *
7092
7147
  * **Output:**
7093
7148
  * - Per-call token count with 📊 emoji
7094
7149
  * - Cumulative total across all calls
@@ -7266,6 +7321,8 @@ declare class HookPresets {
7266
7321
  /**
7267
7322
  * Logs detailed error information for debugging and troubleshooting.
7268
7323
  *
7324
+ * @public
7325
+ *
7269
7326
  * **Output:**
7270
7327
  * - LLM errors with ❌ emoji, including model and recovery status
7271
7328
  * - Gadget errors with full context (parameters, error message)
@@ -7327,6 +7384,8 @@ declare class HookPresets {
7327
7384
  /**
7328
7385
  * Tracks context compaction events.
7329
7386
  *
7387
+ * @public
7388
+ *
7330
7389
  * **Output:**
7331
7390
  * - Compaction events with 🗜️ emoji
7332
7391
  * - Strategy name, tokens before/after, and savings
@@ -7420,6 +7479,8 @@ declare class HookPresets {
7420
7479
  /**
7421
7480
  * Returns empty hook configuration for clean output without any logging.
7422
7481
  *
7482
+ * @public
7483
+ *
7423
7484
  * **Output:**
7424
7485
  * - None. Returns {} (empty object).
7425
7486
  *
@@ -7546,6 +7607,8 @@ declare class HookPresets {
7546
7607
  /**
7547
7608
  * Composite preset combining logging, timing, tokenTracking, and errorLogging.
7548
7609
  *
7610
+ * @public
7611
+ *
7549
7612
  * This is the recommended preset for development and initial production deployments,
7550
7613
  * providing comprehensive observability with a single method call.
7551
7614
  *
@@ -8159,7 +8222,6 @@ interface StreamProcessingResult {
8159
8222
  */
8160
8223
  declare class StreamProcessor {
8161
8224
  private readonly iteration;
8162
- private readonly registry;
8163
8225
  private readonly hooks;
8164
8226
  private readonly logger;
8165
8227
  private readonly parser;
@@ -8169,29 +8231,10 @@ declare class StreamProcessor {
8169
8231
  private readonly baseDepth;
8170
8232
  private readonly gadgetExecutionMode;
8171
8233
  private responseText;
8172
- private observerFailureCount;
8173
- /** Gadgets waiting for their dependencies to complete */
8174
- private gadgetsAwaitingDependencies;
8175
- /** Completed gadget results, keyed by invocation ID */
8176
- private completedResults;
8177
- /** Invocation IDs of gadgets that have failed (error or skipped due to dependency) */
8178
- private failedInvocations;
8179
- /** Promises for independent gadgets currently executing (fire-and-forget) */
8180
- private inFlightExecutions;
8234
+ private readonly dependencyResolver;
8235
+ private readonly concurrencyManager;
8181
8236
  /** Queue of completed gadget results ready to be yielded (for real-time streaming) */
8182
8237
  private completedResultsQueue;
8183
- /** Subagent configuration map for checking maxConcurrent limits */
8184
- private readonly subagentConfig?;
8185
- /** Track active execution count per gadget name */
8186
- private activeCountByGadget;
8187
- /** Queue of gadgets waiting for a concurrency slot (per gadget name) */
8188
- private concurrencyQueue;
8189
- /** Queue of exclusive gadgets deferred until in-flight gadgets complete */
8190
- private exclusiveQueue;
8191
- /** Invocation IDs completed in previous iterations (read-only reference from Agent) */
8192
- private readonly priorCompletedInvocations;
8193
- /** Invocation IDs that failed in previous iterations (read-only reference from Agent) */
8194
- private readonly priorFailedInvocations;
8195
8238
  private readonly parentObservers?;
8196
8239
  private readonly maxGadgetsPerResponse;
8197
8240
  private gadgetStartedCount;
@@ -8223,26 +8266,11 @@ declare class StreamProcessor {
8223
8266
  * enabling real-time UI feedback.
8224
8267
  */
8225
8268
  private processGadgetCallGenerator;
8226
- /**
8227
- * Get the effective concurrency limit for a gadget.
8228
- * Uses "most restrictive wins" strategy: the lowest non-zero value from
8229
- * external config (SubagentConfig) and gadget's intrinsic maxConcurrent.
8230
- *
8231
- * This ensures gadget authors can set safety floors (e.g., maxConcurrent: 1
8232
- * for file writers) that cannot be weakened by external configuration.
8233
- *
8234
- * @returns 0 if unlimited, otherwise the effective limit
8235
- */
8236
- private getConcurrencyLimit;
8237
8269
  /**
8238
8270
  * Start a gadget execution with concurrency tracking.
8239
- * Increments active count, starts execution, and schedules queue processing on completion.
8271
+ * Delegates tracking to GadgetConcurrencyManager; schedules queue processing on completion.
8240
8272
  */
8241
8273
  private startGadgetWithConcurrencyTracking;
8242
- /**
8243
- * Process the next queued gadget for a given gadget name if a slot is available.
8244
- */
8245
- private processQueuedGadget;
8246
8274
  /**
8247
8275
  * Execute a gadget through the full hook lifecycle and yield events.
8248
8276
  * Handles parameter interception, before/after controllers, observers,
@@ -8270,19 +8298,6 @@ declare class StreamProcessor {
8270
8298
  * Clears the inFlightExecutions map after all gadgets complete.
8271
8299
  */
8272
8300
  private waitForInFlightExecutions;
8273
- /**
8274
- * Check if there are any gadgets waiting in concurrency queues.
8275
- */
8276
- private hasQueuedGadgets;
8277
- /**
8278
- * Get total count of queued gadgets across all queues.
8279
- */
8280
- private getQueuedGadgetCount;
8281
- /**
8282
- * Get total count of actively executing gadgets across all types.
8283
- * Used to know when all work is truly complete (not just when allDone resolves).
8284
- */
8285
- private getTotalActiveGadgetCount;
8286
8301
  /**
8287
8302
  * Handle a gadget that cannot execute because a dependency failed.
8288
8303
  * Calls the onDependencySkipped controller to allow customization.
@@ -8304,11 +8319,6 @@ declare class StreamProcessor {
8304
8319
  * but results are yielded as they become available.
8305
8320
  */
8306
8321
  private processPendingGadgetsGenerator;
8307
- /**
8308
- * Safely execute an observer, catching and logging any errors.
8309
- * Observers are non-critical, so errors are logged but don't crash the system.
8310
- */
8311
- private safeObserve;
8312
8322
  /**
8313
8323
  * Execute multiple observers in parallel.
8314
8324
  * All observers run concurrently and failures are tracked but don't crash.
@@ -10859,4 +10869,4 @@ declare const timing: {
10859
10869
  */
10860
10870
  declare function getHostExports(ctx: ExecutionContext): HostExports;
10861
10871
 
10862
- export { AbortException, AbstractGadget, type AddGadgetParams, type AddLLMCallParams, type AfterGadgetExecutionAction, type AfterGadgetExecutionControllerContext, type AfterLLMCallAction, type AfterLLMCallControllerContext, type AfterLLMErrorAction, Agent, AgentBuilder, type AgentHooks, type AgentOptions, AnthropicMessagesProvider, type AudioContentPart, type AudioMimeType, type AudioSource, type BaseExecutionEvent, BaseSessionManager, type BeforeGadgetExecutionAction, type BeforeLLMCallAction, BudgetPricingUnavailableError, type CachingConfig, type CachingScope, type ChunkInterceptorContext, type CompactionConfig, type CompactionContext, type CompactionEvent, CompactionManager, type CompactionResult, type CompactionStats, type CompactionStrategy, type CompleteGadgetParams, type CompleteLLMCallParams, type ContentPart, type Controllers, ConversationManager, type CostEstimate, type CostReportingLLMist, type CreateGadgetConfig, DEFAULT_COMPACTION_CONFIG, DEFAULT_HINTS, DEFAULT_PROMPTS, DEFAULT_RATE_LIMIT_CONFIG, DEFAULT_RETRY_CONFIG, DEFAULT_SUMMARIZATION_PROMPT, type EventHandlers, type ExecutionContext, type ExecutionEvent, type ExecutionEventType, type ExecutionNode, type ExecutionNodeType, ExecutionTree, FALLBACK_CHARS_PER_TOKEN, type FileLoggingOptions, type FileWrittenInfo, type FormatLLMErrorContext, GADGET_ARG_PREFIX, GADGET_END_PREFIX, GADGET_START_PREFIX, Gadget, type GadgetCallEvent, GadgetCallParser, type GadgetClass, type GadgetCompleteEvent, type GadgetConfig, type GadgetErrorEvent, type GadgetEvent, type GadgetExample, type GadgetExecuteResult, type GadgetExecuteResultWithMedia, type GadgetExecuteReturn, type GadgetExecutionControllerContext, type GadgetExecutionMode, type GadgetExecutionResult, GadgetExecutor, type GadgetFactoryExports, type GadgetMediaOutput, type GadgetNode, type GadgetOrClass, GadgetOutputStore, type GadgetParameterInterceptorContext, GadgetRegistry, type GadgetResultInterceptorContext, type GadgetSkippedEvent, type GadgetStartEvent, type GadgetState, GeminiGenerativeProvider, type HintContext, type HintTemplate, type HintsConfig, type HistoryMessage, HookPresets, type HostExports, HuggingFaceProvider, type HumanInputRequiredEvent, HumanInputRequiredException, HybridStrategy, type IConversationManager, type ISessionManager, type ImageBase64Source, type ImageContentPart, type ImageGenerationOptions, type ImageGenerationResult, type ImageMimeType, type ImageModelSpec, type ImageSource, type ImageUrlSource, type Interceptors, type IterationHintOptions, type LLMCallCompleteEvent, type LLMCallControllerContext, type LLMCallErrorEvent, type LLMCallNode, type LLMCallStartEvent, type LLMCallStreamEvent, type LLMErrorControllerContext, type LLMEvent, type LLMGenerationOptions, type LLMMessage, LLMMessageBuilder, type LLMResponseEndEvent, type LLMStream, type LLMStreamChunk, LLMist, type LLMistOptions, type LLMistPackageManifest, type LoggerOptions, type LoggingOptions, MODEL_ALIASES, type MediaKind, type MediaMetadata, MediaStore, type MessageContent, type MessageInterceptorContext, type MessageRole, type MessageTurn, type ModelDescriptor, type ModelFeatures, ModelIdentifierParser, type ModelLimits, type ModelPricing, ModelRegistry, type ModelSpec, type NodeId, type ObserveChunkContext, type ObserveCompactionContext, type ObserveGadgetCompleteContext, type ObserveGadgetStartContext, type ObserveLLMCallContext, type ObserveLLMCompleteContext, type ObserveLLMErrorContext, type ObserveRateLimitThrottleContext, type ObserveRetryAttemptContext, type Observers, OpenAIChatProvider, type OpenAICompatibleConfig, OpenAICompatibleProvider, type OpenRouterConfig, OpenRouterProvider, type OpenRouterRouting, type ParallelGadgetHintOptions, type ParsedGadgetCall, type PresetDefinition, type PromptContext, type PromptTemplate, type PromptTemplateConfig, type ProviderAdapter, type ProviderIdentifier, type RateLimitConfig, type RateLimitStats, RateLimitTracker, type ReasoningConfig, type ReasoningEffort, type ResolveValueOptions, type ResolvedCompactionConfig, type ResolvedRateLimitConfig, type ResolvedRetryConfig, type RetryConfig, type RetryOptions, type SessionManifestEntry, SimpleSessionManager, SlidingWindowStrategy, type SpeechGenerationOptions, type SpeechGenerationResult, type SpeechModelSpec, type StoredMedia, type StoredOutput, type StreamCompleteEvent, type StreamEvent, type StreamProcessingResult, StreamProcessor, type StreamProcessorOptions, type SubagentConfig, type SubagentConfigMap, type SubagentContext, type SubagentManifestEntry, type SubagentOptions, SummarizationStrategy, TaskCompletionSignal, type TextContentPart, type TextEvent, type TextGenerationOptions, type TextOnlyAction, type TextOnlyContext, type TextOnlyCustomHandler, type TextOnlyGadgetConfig, type TextOnlyHandler, type TextOnlyStrategy, type ThinkingChunk, type ThinkingEvent, TimeoutException, type TokenUsage, type TrailingMessage, type TrailingMessageContext, type CompactionEvent$1 as TreeCompactionEvent, type GadgetSkippedEvent$1 as TreeGadgetSkippedEvent, type TriggeredLimitInfo, type ValidationIssue, type ValidationResult, type VisionAnalyzeOptions, type VisionAnalyzeResult, audioFromBase64, audioFromBuffer, collectEvents, collectText, complete, createAnthropicProviderFromEnv, createGadget, createGadgetOutputViewer, createGeminiProviderFromEnv, createHints, createHuggingFaceProviderFromEnv, createLogger, createMediaOutput, createOpenAIProviderFromEnv, createOpenRouterProviderFromEnv, createSubagent, defaultLogger, detectAudioMimeType, detectImageMimeType, discoverProviderAdapters, extractMessageText, extractRetryAfterMs, filterByDepth, filterByParent, filterRootEvents, format, formatBytes, formatCallNumber, formatDate, formatDuration, formatLLMError, formatLlmRequest, gadgetError, gadgetSuccess, getErrorMessage, getHostExports, getModelId, getPresetGadgets, getProvider, getSubagent, groupByParent, hasHostExports, hasPreset, hasProviderPrefix, hasSubagents, humanDelay, imageFromBase64, imageFromBuffer, imageFromUrl, isAbortError, isAudioPart, isDataUrl, isGadgetEvent, isImagePart, isLLMEvent, isRetryableError, isRootEvent, isSubagentEvent, isTextPart, iterationProgressHint, listPresets, listSubagents, normalizeMessageContent, parallelGadgetHint, parseDataUrl, parseManifest, parseRetryAfterHeader, randomDelay, resolveConfig, resolveHintTemplate, resolveModel, resolvePromptTemplate, resolveRateLimitConfig, resolveRetryConfig, resolveRulesTemplate, resolveSubagentModel, resolveSubagentTimeout, resolveValue, resultWithAudio, resultWithFile, resultWithImage, resultWithImages, resultWithMedia, runWithHandlers, schemaToJSONSchema, stream, text, timing, toBase64, truncate, validateAndApplyDefaults, validateGadgetParams, validateGadgetSchema, withErrorHandling, withRetry, withTimeout };
10872
+ export { AbortException, AbstractGadget, type AddGadgetParams, type AddLLMCallParams, type AfterGadgetExecutionAction, type AfterGadgetExecutionControllerContext, type AfterLLMCallAction, type AfterLLMCallControllerContext, type AfterLLMErrorAction, Agent, AgentBuilder, type AgentHooks, type AgentOptions, AnthropicMessagesProvider, type AudioContentPart, type AudioMimeType, type AudioSource, type BaseExecutionEvent, BaseSessionManager, type BeforeGadgetExecutionAction, type BeforeLLMCallAction, BudgetPricingUnavailableError, type CachingConfig, type CachingScope, type ChunkInterceptorContext, type CompactionConfig, type CompactionContext, type CompactionEvent, CompactionManager, type CompactionResult, type CompactionStats, type CompactionStrategy, type CompleteGadgetParams, type CompleteLLMCallParams, type ContentPart, type Controllers, ConversationManager, type CostEstimate, type CostReportingLLMist, type CreateGadgetConfig, DEFAULT_COMPACTION_CONFIG, DEFAULT_HINTS, DEFAULT_PROMPTS, DEFAULT_RATE_LIMIT_CONFIG, DEFAULT_RETRY_CONFIG, DEFAULT_SUMMARIZATION_PROMPT, type EventHandlers, type ExecutionContext, type ExecutionEvent, type ExecutionEventType, type ExecutionNode, type ExecutionNodeType, ExecutionTree, FALLBACK_CHARS_PER_TOKEN, type FileLoggingOptions, type FileLoggingState, type FileWrittenInfo, type FormatLLMErrorContext, GADGET_ARG_PREFIX, GADGET_END_PREFIX, GADGET_START_PREFIX, Gadget, type GadgetCallEvent, GadgetCallParser, type GadgetClass, type GadgetCompleteEvent, type GadgetConfig, type GadgetErrorEvent, type GadgetEvent, type GadgetExample, type GadgetExecuteResult, type GadgetExecuteResultWithMedia, type GadgetExecuteReturn, type GadgetExecutionControllerContext, type GadgetExecutionMode, type GadgetExecutionResult, GadgetExecutor, type GadgetFactoryExports, type GadgetMediaOutput, type GadgetNode, type GadgetOrClass, GadgetOutputStore, type GadgetParameterInterceptorContext, GadgetRegistry, type GadgetResultInterceptorContext, type GadgetSkippedEvent, type GadgetStartEvent, type GadgetState, GeminiGenerativeProvider, type HintContext, type HintTemplate, type HintsConfig, type HistoryMessage, HookPresets, type HostExports, HuggingFaceProvider, type HumanInputRequiredEvent, HumanInputRequiredException, HybridStrategy, type IConversationManager, type ISessionManager, type ImageBase64Source, type ImageContentPart, type ImageGenerationOptions, type ImageGenerationResult, type ImageMimeType, type ImageModelSpec, type ImageSource, type ImageUrlSource, type Interceptors, type IterationHintOptions, type LLMCallCompleteEvent, type LLMCallControllerContext, type LLMCallErrorEvent, type LLMCallNode, type LLMCallStartEvent, type LLMCallStreamEvent, type LLMErrorControllerContext, type LLMEvent, type LLMGenerationOptions, type LLMMessage, LLMMessageBuilder, type LLMResponseEndEvent, type LLMStream, type LLMStreamChunk, LLMist, type LLMistOptions, type LLMistPackageManifest, type LoggerOptions, type LoggingOptions, MODEL_ALIASES, type MediaKind, type MediaMetadata, MediaStore, type MessageContent, type MessageInterceptorContext, type MessageRole, type MessageTurn, type ModelDescriptor, type ModelFeatures, ModelIdentifierParser, type ModelLimits, type ModelPricing, ModelRegistry, type ModelSpec, type NodeId, type ObserveChunkContext, type ObserveCompactionContext, type ObserveGadgetCompleteContext, type ObserveGadgetStartContext, type ObserveLLMCallContext, type ObserveLLMCompleteContext, type ObserveLLMErrorContext, type ObserveRateLimitThrottleContext, type ObserveRetryAttemptContext, type Observers, OpenAIChatProvider, type OpenAICompatibleConfig, OpenAICompatibleProvider, type OpenRouterConfig, OpenRouterProvider, type OpenRouterRouting, type ParallelGadgetHintOptions, type ParsedGadgetCall, type PresetDefinition, type PromptContext, type PromptTemplate, type PromptTemplateConfig, type ProviderAdapter, type ProviderIdentifier, type RateLimitConfig, type RateLimitStats, RateLimitTracker, type ReasoningConfig, type ReasoningEffort, type ResolveValueOptions, type ResolvedCompactionConfig, type ResolvedRateLimitConfig, type ResolvedRetryConfig, type RetryConfig, type RetryOptions, type SessionManifestEntry, SimpleSessionManager, SlidingWindowStrategy, type SpeechGenerationOptions, type SpeechGenerationResult, type SpeechModelSpec, type StoredMedia, type StoredOutput, type StreamCompleteEvent, type StreamEvent, type StreamProcessingResult, StreamProcessor, type StreamProcessorOptions, type SubagentConfig, type SubagentConfigMap, type SubagentContext, type SubagentManifestEntry, type SubagentOptions, SummarizationStrategy, TaskCompletionSignal, type TextContentPart, type TextEvent, type TextGenerationOptions, type TextOnlyAction, type TextOnlyContext, type TextOnlyCustomHandler, type TextOnlyGadgetConfig, type TextOnlyHandler, type TextOnlyStrategy, type ThinkingChunk, type ThinkingEvent, TimeoutException, type TokenUsage, type TrailingMessage, type TrailingMessageContext, type CompactionEvent$1 as TreeCompactionEvent, type GadgetSkippedEvent$1 as TreeGadgetSkippedEvent, type TriggeredLimitInfo, type ValidationIssue, type ValidationResult, type VisionAnalyzeOptions, type VisionAnalyzeResult, audioFromBase64, audioFromBuffer, collectEvents, collectText, complete, createAnthropicProviderFromEnv, createFileLoggingState, createGadget, createGadgetOutputViewer, createGeminiProviderFromEnv, createHints, createHuggingFaceProviderFromEnv, createLogger, createMediaOutput, createOpenAIProviderFromEnv, createOpenRouterProviderFromEnv, createSubagent, defaultLogger, detectAudioMimeType, detectImageMimeType, discoverProviderAdapters, extractMessageText, extractRetryAfterMs, filterByDepth, filterByParent, filterRootEvents, format, formatBytes, formatCallNumber, formatDate, formatDuration, formatLLMError, formatLlmRequest, gadgetError, gadgetSuccess, getErrorMessage, getHostExports, getModelId, getPresetGadgets, getProvider, getSubagent, groupByParent, hasHostExports, hasPreset, hasProviderPrefix, hasSubagents, humanDelay, imageFromBase64, imageFromBuffer, imageFromUrl, isAbortError, isAudioPart, isDataUrl, isGadgetEvent, isImagePart, isLLMEvent, isRetryableError, isRootEvent, isSubagentEvent, isTextPart, iterationProgressHint, listPresets, listSubagents, normalizeMessageContent, parallelGadgetHint, parseDataUrl, parseManifest, parseRetryAfterHeader, randomDelay, resetFileLoggingState, resolveConfig, resolveHintTemplate, resolveModel, resolvePromptTemplate, resolveRateLimitConfig, resolveRetryConfig, resolveRulesTemplate, resolveSubagentModel, resolveSubagentTimeout, resolveValue, resultWithAudio, resultWithFile, resultWithImage, resultWithImages, resultWithMedia, runWithHandlers, schemaToJSONSchema, stream, text, timing, toBase64, truncate, validateAndApplyDefaults, validateGadgetParams, validateGadgetSchema, withErrorHandling, withRetry, withTimeout };
package/dist/index.d.ts CHANGED
@@ -2058,12 +2058,13 @@ interface Interceptors {
2058
2058
  */
2059
2059
  interceptGadgetParameters?: (parameters: Readonly<Record<string, unknown>>, context: GadgetParameterInterceptorContext) => Record<string, unknown>;
2060
2060
  /**
2061
- * Intercept and transform gadget results after execution.
2061
+ * Intercept and transform gadget results and error messages after execution.
2062
2062
  * This affects what gets sent back to the LLM and stored in history.
2063
+ * Called for both successful results (result.result) and errors (result.error).
2063
2064
  *
2064
- * @param result - The gadget result text
2065
+ * @param result - The gadget result or error text
2065
2066
  * @param context - Context information including parameters and execution time
2066
- * @returns Transformed result text (cannot be suppressed)
2067
+ * @returns Transformed text (cannot be suppressed)
2067
2068
  */
2068
2069
  interceptGadgetResult?: (result: string, context: GadgetResultInterceptorContext) => string;
2069
2070
  }
@@ -5519,7 +5520,9 @@ declare class AgentBuilder {
5519
5520
  */
5520
5521
  /**
5521
5522
  * Build AgentOptions with the given user prompt.
5522
- * Centralizes options construction for ask(), askWithImage(), and askWithContent().
5523
+ * Centralizes options construction for ask(), askWithImage(), askWithContent(), and build().
5524
+ *
5525
+ * @param userPrompt - Optional user prompt (omitted for build() which has no prompt)
5523
5526
  */
5524
5527
  private buildAgentOptions;
5525
5528
  ask(userPrompt: string): Agent;
@@ -6633,10 +6636,6 @@ declare class Agent {
6633
6636
  * Handle text-only response (no gadgets called).
6634
6637
  */
6635
6638
  private handleTextOnlyResponse;
6636
- /**
6637
- * Safely execute an observer, catching and logging any errors.
6638
- */
6639
- private safeObserve;
6640
6639
  /**
6641
6640
  * Resolve max tokens from model catalog.
6642
6641
  */
@@ -6744,6 +6743,56 @@ declare class Agent {
6744
6743
  * ```
6745
6744
  */
6746
6745
 
6746
+ /**
6747
+ * State container for file logging session.
6748
+ * Encapsulates all mutable state to enable session isolation and proper
6749
+ * handling of concurrent subagents.
6750
+ *
6751
+ * @remarks
6752
+ * Using a state object instead of module-level globals provides:
6753
+ * - **Session isolation**: Multiple agent sessions don't interfere with each other
6754
+ * - **Testability**: Tests can inject fresh state without needing to reset globals
6755
+ * - **Concurrent subagent support**: Context-based keys prevent race conditions
6756
+ */
6757
+ interface FileLoggingState {
6758
+ /** Counter per directory path (normalized) */
6759
+ readonly counters: Map<string, number>;
6760
+ /**
6761
+ * Subagent context key -> assigned directory path.
6762
+ * Key format: `${parentDir}:${parentGadgetInvocationId}`
6763
+ */
6764
+ readonly subagentDirectories: Map<string, string>;
6765
+ /**
6766
+ * Context key -> active directory for that execution context.
6767
+ * Key format: `${parentGadgetInvocationId}:${depth}` (or "root:0" for main agent)
6768
+ *
6769
+ * This replaces the previous depth-only keying which caused race conditions
6770
+ * when multiple subagents at the same depth ran concurrently.
6771
+ */
6772
+ readonly activeDirectoryByContext: Map<string, string>;
6773
+ }
6774
+ /**
6775
+ * Creates a fresh file logging state container.
6776
+ *
6777
+ * Use this to create isolated state for testing or when running multiple
6778
+ * independent agent sessions that shouldn't share counters.
6779
+ *
6780
+ * @example
6781
+ * ```typescript
6782
+ * // For testing with isolated state:
6783
+ * const state = createFileLoggingState();
6784
+ * const hooks = createFileLoggingHooks({ directory: './logs' }, state);
6785
+ *
6786
+ * // For production (uses default shared state):
6787
+ * const hooks = createFileLoggingHooks({ directory: './logs' });
6788
+ * ```
6789
+ */
6790
+ declare function createFileLoggingState(): FileLoggingState;
6791
+ /**
6792
+ * Resets the default global state. For testing only.
6793
+ * @internal
6794
+ */
6795
+ declare function resetFileLoggingState(): void;
6747
6796
  /**
6748
6797
  * Options for configuring file-based LLM logging.
6749
6798
  */
@@ -6786,10 +6835,14 @@ interface FileWrittenInfo {
6786
6835
  filePath: string;
6787
6836
  /** Type of log file */
6788
6837
  type: "request" | "response";
6789
- /** LLM call number (1-indexed) */
6838
+ /** LLM call number (1-indexed) within the current directory */
6790
6839
  callNumber: number;
6791
6840
  /** Length of the written content in characters */
6792
6841
  contentLength: number;
6842
+ /** Gadget invocation ID that spawned this subagent (undefined for main agent) */
6843
+ parentGadgetInvocationId?: string;
6844
+ /** Subagent depth (undefined for main agent) */
6845
+ depth?: number;
6793
6846
  }
6794
6847
  /**
6795
6848
  * Formats LLM messages as plain text for debugging.
@@ -7089,6 +7142,8 @@ declare class HookPresets {
7089
7142
  /**
7090
7143
  * Tracks cumulative token usage across all LLM calls.
7091
7144
  *
7145
+ * @public
7146
+ *
7092
7147
  * **Output:**
7093
7148
  * - Per-call token count with 📊 emoji
7094
7149
  * - Cumulative total across all calls
@@ -7266,6 +7321,8 @@ declare class HookPresets {
7266
7321
  /**
7267
7322
  * Logs detailed error information for debugging and troubleshooting.
7268
7323
  *
7324
+ * @public
7325
+ *
7269
7326
  * **Output:**
7270
7327
  * - LLM errors with ❌ emoji, including model and recovery status
7271
7328
  * - Gadget errors with full context (parameters, error message)
@@ -7327,6 +7384,8 @@ declare class HookPresets {
7327
7384
  /**
7328
7385
  * Tracks context compaction events.
7329
7386
  *
7387
+ * @public
7388
+ *
7330
7389
  * **Output:**
7331
7390
  * - Compaction events with 🗜️ emoji
7332
7391
  * - Strategy name, tokens before/after, and savings
@@ -7420,6 +7479,8 @@ declare class HookPresets {
7420
7479
  /**
7421
7480
  * Returns empty hook configuration for clean output without any logging.
7422
7481
  *
7482
+ * @public
7483
+ *
7423
7484
  * **Output:**
7424
7485
  * - None. Returns {} (empty object).
7425
7486
  *
@@ -7546,6 +7607,8 @@ declare class HookPresets {
7546
7607
  /**
7547
7608
  * Composite preset combining logging, timing, tokenTracking, and errorLogging.
7548
7609
  *
7610
+ * @public
7611
+ *
7549
7612
  * This is the recommended preset for development and initial production deployments,
7550
7613
  * providing comprehensive observability with a single method call.
7551
7614
  *
@@ -8159,7 +8222,6 @@ interface StreamProcessingResult {
8159
8222
  */
8160
8223
  declare class StreamProcessor {
8161
8224
  private readonly iteration;
8162
- private readonly registry;
8163
8225
  private readonly hooks;
8164
8226
  private readonly logger;
8165
8227
  private readonly parser;
@@ -8169,29 +8231,10 @@ declare class StreamProcessor {
8169
8231
  private readonly baseDepth;
8170
8232
  private readonly gadgetExecutionMode;
8171
8233
  private responseText;
8172
- private observerFailureCount;
8173
- /** Gadgets waiting for their dependencies to complete */
8174
- private gadgetsAwaitingDependencies;
8175
- /** Completed gadget results, keyed by invocation ID */
8176
- private completedResults;
8177
- /** Invocation IDs of gadgets that have failed (error or skipped due to dependency) */
8178
- private failedInvocations;
8179
- /** Promises for independent gadgets currently executing (fire-and-forget) */
8180
- private inFlightExecutions;
8234
+ private readonly dependencyResolver;
8235
+ private readonly concurrencyManager;
8181
8236
  /** Queue of completed gadget results ready to be yielded (for real-time streaming) */
8182
8237
  private completedResultsQueue;
8183
- /** Subagent configuration map for checking maxConcurrent limits */
8184
- private readonly subagentConfig?;
8185
- /** Track active execution count per gadget name */
8186
- private activeCountByGadget;
8187
- /** Queue of gadgets waiting for a concurrency slot (per gadget name) */
8188
- private concurrencyQueue;
8189
- /** Queue of exclusive gadgets deferred until in-flight gadgets complete */
8190
- private exclusiveQueue;
8191
- /** Invocation IDs completed in previous iterations (read-only reference from Agent) */
8192
- private readonly priorCompletedInvocations;
8193
- /** Invocation IDs that failed in previous iterations (read-only reference from Agent) */
8194
- private readonly priorFailedInvocations;
8195
8238
  private readonly parentObservers?;
8196
8239
  private readonly maxGadgetsPerResponse;
8197
8240
  private gadgetStartedCount;
@@ -8223,26 +8266,11 @@ declare class StreamProcessor {
8223
8266
  * enabling real-time UI feedback.
8224
8267
  */
8225
8268
  private processGadgetCallGenerator;
8226
- /**
8227
- * Get the effective concurrency limit for a gadget.
8228
- * Uses "most restrictive wins" strategy: the lowest non-zero value from
8229
- * external config (SubagentConfig) and gadget's intrinsic maxConcurrent.
8230
- *
8231
- * This ensures gadget authors can set safety floors (e.g., maxConcurrent: 1
8232
- * for file writers) that cannot be weakened by external configuration.
8233
- *
8234
- * @returns 0 if unlimited, otherwise the effective limit
8235
- */
8236
- private getConcurrencyLimit;
8237
8269
  /**
8238
8270
  * Start a gadget execution with concurrency tracking.
8239
- * Increments active count, starts execution, and schedules queue processing on completion.
8271
+ * Delegates tracking to GadgetConcurrencyManager; schedules queue processing on completion.
8240
8272
  */
8241
8273
  private startGadgetWithConcurrencyTracking;
8242
- /**
8243
- * Process the next queued gadget for a given gadget name if a slot is available.
8244
- */
8245
- private processQueuedGadget;
8246
8274
  /**
8247
8275
  * Execute a gadget through the full hook lifecycle and yield events.
8248
8276
  * Handles parameter interception, before/after controllers, observers,
@@ -8270,19 +8298,6 @@ declare class StreamProcessor {
8270
8298
  * Clears the inFlightExecutions map after all gadgets complete.
8271
8299
  */
8272
8300
  private waitForInFlightExecutions;
8273
- /**
8274
- * Check if there are any gadgets waiting in concurrency queues.
8275
- */
8276
- private hasQueuedGadgets;
8277
- /**
8278
- * Get total count of queued gadgets across all queues.
8279
- */
8280
- private getQueuedGadgetCount;
8281
- /**
8282
- * Get total count of actively executing gadgets across all types.
8283
- * Used to know when all work is truly complete (not just when allDone resolves).
8284
- */
8285
- private getTotalActiveGadgetCount;
8286
8301
  /**
8287
8302
  * Handle a gadget that cannot execute because a dependency failed.
8288
8303
  * Calls the onDependencySkipped controller to allow customization.
@@ -8304,11 +8319,6 @@ declare class StreamProcessor {
8304
8319
  * but results are yielded as they become available.
8305
8320
  */
8306
8321
  private processPendingGadgetsGenerator;
8307
- /**
8308
- * Safely execute an observer, catching and logging any errors.
8309
- * Observers are non-critical, so errors are logged but don't crash the system.
8310
- */
8311
- private safeObserve;
8312
8322
  /**
8313
8323
  * Execute multiple observers in parallel.
8314
8324
  * All observers run concurrently and failures are tracked but don't crash.
@@ -10859,4 +10869,4 @@ declare const timing: {
10859
10869
  */
10860
10870
  declare function getHostExports(ctx: ExecutionContext): HostExports;
10861
10871
 
10862
- export { AbortException, AbstractGadget, type AddGadgetParams, type AddLLMCallParams, type AfterGadgetExecutionAction, type AfterGadgetExecutionControllerContext, type AfterLLMCallAction, type AfterLLMCallControllerContext, type AfterLLMErrorAction, Agent, AgentBuilder, type AgentHooks, type AgentOptions, AnthropicMessagesProvider, type AudioContentPart, type AudioMimeType, type AudioSource, type BaseExecutionEvent, BaseSessionManager, type BeforeGadgetExecutionAction, type BeforeLLMCallAction, BudgetPricingUnavailableError, type CachingConfig, type CachingScope, type ChunkInterceptorContext, type CompactionConfig, type CompactionContext, type CompactionEvent, CompactionManager, type CompactionResult, type CompactionStats, type CompactionStrategy, type CompleteGadgetParams, type CompleteLLMCallParams, type ContentPart, type Controllers, ConversationManager, type CostEstimate, type CostReportingLLMist, type CreateGadgetConfig, DEFAULT_COMPACTION_CONFIG, DEFAULT_HINTS, DEFAULT_PROMPTS, DEFAULT_RATE_LIMIT_CONFIG, DEFAULT_RETRY_CONFIG, DEFAULT_SUMMARIZATION_PROMPT, type EventHandlers, type ExecutionContext, type ExecutionEvent, type ExecutionEventType, type ExecutionNode, type ExecutionNodeType, ExecutionTree, FALLBACK_CHARS_PER_TOKEN, type FileLoggingOptions, type FileWrittenInfo, type FormatLLMErrorContext, GADGET_ARG_PREFIX, GADGET_END_PREFIX, GADGET_START_PREFIX, Gadget, type GadgetCallEvent, GadgetCallParser, type GadgetClass, type GadgetCompleteEvent, type GadgetConfig, type GadgetErrorEvent, type GadgetEvent, type GadgetExample, type GadgetExecuteResult, type GadgetExecuteResultWithMedia, type GadgetExecuteReturn, type GadgetExecutionControllerContext, type GadgetExecutionMode, type GadgetExecutionResult, GadgetExecutor, type GadgetFactoryExports, type GadgetMediaOutput, type GadgetNode, type GadgetOrClass, GadgetOutputStore, type GadgetParameterInterceptorContext, GadgetRegistry, type GadgetResultInterceptorContext, type GadgetSkippedEvent, type GadgetStartEvent, type GadgetState, GeminiGenerativeProvider, type HintContext, type HintTemplate, type HintsConfig, type HistoryMessage, HookPresets, type HostExports, HuggingFaceProvider, type HumanInputRequiredEvent, HumanInputRequiredException, HybridStrategy, type IConversationManager, type ISessionManager, type ImageBase64Source, type ImageContentPart, type ImageGenerationOptions, type ImageGenerationResult, type ImageMimeType, type ImageModelSpec, type ImageSource, type ImageUrlSource, type Interceptors, type IterationHintOptions, type LLMCallCompleteEvent, type LLMCallControllerContext, type LLMCallErrorEvent, type LLMCallNode, type LLMCallStartEvent, type LLMCallStreamEvent, type LLMErrorControllerContext, type LLMEvent, type LLMGenerationOptions, type LLMMessage, LLMMessageBuilder, type LLMResponseEndEvent, type LLMStream, type LLMStreamChunk, LLMist, type LLMistOptions, type LLMistPackageManifest, type LoggerOptions, type LoggingOptions, MODEL_ALIASES, type MediaKind, type MediaMetadata, MediaStore, type MessageContent, type MessageInterceptorContext, type MessageRole, type MessageTurn, type ModelDescriptor, type ModelFeatures, ModelIdentifierParser, type ModelLimits, type ModelPricing, ModelRegistry, type ModelSpec, type NodeId, type ObserveChunkContext, type ObserveCompactionContext, type ObserveGadgetCompleteContext, type ObserveGadgetStartContext, type ObserveLLMCallContext, type ObserveLLMCompleteContext, type ObserveLLMErrorContext, type ObserveRateLimitThrottleContext, type ObserveRetryAttemptContext, type Observers, OpenAIChatProvider, type OpenAICompatibleConfig, OpenAICompatibleProvider, type OpenRouterConfig, OpenRouterProvider, type OpenRouterRouting, type ParallelGadgetHintOptions, type ParsedGadgetCall, type PresetDefinition, type PromptContext, type PromptTemplate, type PromptTemplateConfig, type ProviderAdapter, type ProviderIdentifier, type RateLimitConfig, type RateLimitStats, RateLimitTracker, type ReasoningConfig, type ReasoningEffort, type ResolveValueOptions, type ResolvedCompactionConfig, type ResolvedRateLimitConfig, type ResolvedRetryConfig, type RetryConfig, type RetryOptions, type SessionManifestEntry, SimpleSessionManager, SlidingWindowStrategy, type SpeechGenerationOptions, type SpeechGenerationResult, type SpeechModelSpec, type StoredMedia, type StoredOutput, type StreamCompleteEvent, type StreamEvent, type StreamProcessingResult, StreamProcessor, type StreamProcessorOptions, type SubagentConfig, type SubagentConfigMap, type SubagentContext, type SubagentManifestEntry, type SubagentOptions, SummarizationStrategy, TaskCompletionSignal, type TextContentPart, type TextEvent, type TextGenerationOptions, type TextOnlyAction, type TextOnlyContext, type TextOnlyCustomHandler, type TextOnlyGadgetConfig, type TextOnlyHandler, type TextOnlyStrategy, type ThinkingChunk, type ThinkingEvent, TimeoutException, type TokenUsage, type TrailingMessage, type TrailingMessageContext, type CompactionEvent$1 as TreeCompactionEvent, type GadgetSkippedEvent$1 as TreeGadgetSkippedEvent, type TriggeredLimitInfo, type ValidationIssue, type ValidationResult, type VisionAnalyzeOptions, type VisionAnalyzeResult, audioFromBase64, audioFromBuffer, collectEvents, collectText, complete, createAnthropicProviderFromEnv, createGadget, createGadgetOutputViewer, createGeminiProviderFromEnv, createHints, createHuggingFaceProviderFromEnv, createLogger, createMediaOutput, createOpenAIProviderFromEnv, createOpenRouterProviderFromEnv, createSubagent, defaultLogger, detectAudioMimeType, detectImageMimeType, discoverProviderAdapters, extractMessageText, extractRetryAfterMs, filterByDepth, filterByParent, filterRootEvents, format, formatBytes, formatCallNumber, formatDate, formatDuration, formatLLMError, formatLlmRequest, gadgetError, gadgetSuccess, getErrorMessage, getHostExports, getModelId, getPresetGadgets, getProvider, getSubagent, groupByParent, hasHostExports, hasPreset, hasProviderPrefix, hasSubagents, humanDelay, imageFromBase64, imageFromBuffer, imageFromUrl, isAbortError, isAudioPart, isDataUrl, isGadgetEvent, isImagePart, isLLMEvent, isRetryableError, isRootEvent, isSubagentEvent, isTextPart, iterationProgressHint, listPresets, listSubagents, normalizeMessageContent, parallelGadgetHint, parseDataUrl, parseManifest, parseRetryAfterHeader, randomDelay, resolveConfig, resolveHintTemplate, resolveModel, resolvePromptTemplate, resolveRateLimitConfig, resolveRetryConfig, resolveRulesTemplate, resolveSubagentModel, resolveSubagentTimeout, resolveValue, resultWithAudio, resultWithFile, resultWithImage, resultWithImages, resultWithMedia, runWithHandlers, schemaToJSONSchema, stream, text, timing, toBase64, truncate, validateAndApplyDefaults, validateGadgetParams, validateGadgetSchema, withErrorHandling, withRetry, withTimeout };
10872
+ export { AbortException, AbstractGadget, type AddGadgetParams, type AddLLMCallParams, type AfterGadgetExecutionAction, type AfterGadgetExecutionControllerContext, type AfterLLMCallAction, type AfterLLMCallControllerContext, type AfterLLMErrorAction, Agent, AgentBuilder, type AgentHooks, type AgentOptions, AnthropicMessagesProvider, type AudioContentPart, type AudioMimeType, type AudioSource, type BaseExecutionEvent, BaseSessionManager, type BeforeGadgetExecutionAction, type BeforeLLMCallAction, BudgetPricingUnavailableError, type CachingConfig, type CachingScope, type ChunkInterceptorContext, type CompactionConfig, type CompactionContext, type CompactionEvent, CompactionManager, type CompactionResult, type CompactionStats, type CompactionStrategy, type CompleteGadgetParams, type CompleteLLMCallParams, type ContentPart, type Controllers, ConversationManager, type CostEstimate, type CostReportingLLMist, type CreateGadgetConfig, DEFAULT_COMPACTION_CONFIG, DEFAULT_HINTS, DEFAULT_PROMPTS, DEFAULT_RATE_LIMIT_CONFIG, DEFAULT_RETRY_CONFIG, DEFAULT_SUMMARIZATION_PROMPT, type EventHandlers, type ExecutionContext, type ExecutionEvent, type ExecutionEventType, type ExecutionNode, type ExecutionNodeType, ExecutionTree, FALLBACK_CHARS_PER_TOKEN, type FileLoggingOptions, type FileLoggingState, type FileWrittenInfo, type FormatLLMErrorContext, GADGET_ARG_PREFIX, GADGET_END_PREFIX, GADGET_START_PREFIX, Gadget, type GadgetCallEvent, GadgetCallParser, type GadgetClass, type GadgetCompleteEvent, type GadgetConfig, type GadgetErrorEvent, type GadgetEvent, type GadgetExample, type GadgetExecuteResult, type GadgetExecuteResultWithMedia, type GadgetExecuteReturn, type GadgetExecutionControllerContext, type GadgetExecutionMode, type GadgetExecutionResult, GadgetExecutor, type GadgetFactoryExports, type GadgetMediaOutput, type GadgetNode, type GadgetOrClass, GadgetOutputStore, type GadgetParameterInterceptorContext, GadgetRegistry, type GadgetResultInterceptorContext, type GadgetSkippedEvent, type GadgetStartEvent, type GadgetState, GeminiGenerativeProvider, type HintContext, type HintTemplate, type HintsConfig, type HistoryMessage, HookPresets, type HostExports, HuggingFaceProvider, type HumanInputRequiredEvent, HumanInputRequiredException, HybridStrategy, type IConversationManager, type ISessionManager, type ImageBase64Source, type ImageContentPart, type ImageGenerationOptions, type ImageGenerationResult, type ImageMimeType, type ImageModelSpec, type ImageSource, type ImageUrlSource, type Interceptors, type IterationHintOptions, type LLMCallCompleteEvent, type LLMCallControllerContext, type LLMCallErrorEvent, type LLMCallNode, type LLMCallStartEvent, type LLMCallStreamEvent, type LLMErrorControllerContext, type LLMEvent, type LLMGenerationOptions, type LLMMessage, LLMMessageBuilder, type LLMResponseEndEvent, type LLMStream, type LLMStreamChunk, LLMist, type LLMistOptions, type LLMistPackageManifest, type LoggerOptions, type LoggingOptions, MODEL_ALIASES, type MediaKind, type MediaMetadata, MediaStore, type MessageContent, type MessageInterceptorContext, type MessageRole, type MessageTurn, type ModelDescriptor, type ModelFeatures, ModelIdentifierParser, type ModelLimits, type ModelPricing, ModelRegistry, type ModelSpec, type NodeId, type ObserveChunkContext, type ObserveCompactionContext, type ObserveGadgetCompleteContext, type ObserveGadgetStartContext, type ObserveLLMCallContext, type ObserveLLMCompleteContext, type ObserveLLMErrorContext, type ObserveRateLimitThrottleContext, type ObserveRetryAttemptContext, type Observers, OpenAIChatProvider, type OpenAICompatibleConfig, OpenAICompatibleProvider, type OpenRouterConfig, OpenRouterProvider, type OpenRouterRouting, type ParallelGadgetHintOptions, type ParsedGadgetCall, type PresetDefinition, type PromptContext, type PromptTemplate, type PromptTemplateConfig, type ProviderAdapter, type ProviderIdentifier, type RateLimitConfig, type RateLimitStats, RateLimitTracker, type ReasoningConfig, type ReasoningEffort, type ResolveValueOptions, type ResolvedCompactionConfig, type ResolvedRateLimitConfig, type ResolvedRetryConfig, type RetryConfig, type RetryOptions, type SessionManifestEntry, SimpleSessionManager, SlidingWindowStrategy, type SpeechGenerationOptions, type SpeechGenerationResult, type SpeechModelSpec, type StoredMedia, type StoredOutput, type StreamCompleteEvent, type StreamEvent, type StreamProcessingResult, StreamProcessor, type StreamProcessorOptions, type SubagentConfig, type SubagentConfigMap, type SubagentContext, type SubagentManifestEntry, type SubagentOptions, SummarizationStrategy, TaskCompletionSignal, type TextContentPart, type TextEvent, type TextGenerationOptions, type TextOnlyAction, type TextOnlyContext, type TextOnlyCustomHandler, type TextOnlyGadgetConfig, type TextOnlyHandler, type TextOnlyStrategy, type ThinkingChunk, type ThinkingEvent, TimeoutException, type TokenUsage, type TrailingMessage, type TrailingMessageContext, type CompactionEvent$1 as TreeCompactionEvent, type GadgetSkippedEvent$1 as TreeGadgetSkippedEvent, type TriggeredLimitInfo, type ValidationIssue, type ValidationResult, type VisionAnalyzeOptions, type VisionAnalyzeResult, audioFromBase64, audioFromBuffer, collectEvents, collectText, complete, createAnthropicProviderFromEnv, createFileLoggingState, createGadget, createGadgetOutputViewer, createGeminiProviderFromEnv, createHints, createHuggingFaceProviderFromEnv, createLogger, createMediaOutput, createOpenAIProviderFromEnv, createOpenRouterProviderFromEnv, createSubagent, defaultLogger, detectAudioMimeType, detectImageMimeType, discoverProviderAdapters, extractMessageText, extractRetryAfterMs, filterByDepth, filterByParent, filterRootEvents, format, formatBytes, formatCallNumber, formatDate, formatDuration, formatLLMError, formatLlmRequest, gadgetError, gadgetSuccess, getErrorMessage, getHostExports, getModelId, getPresetGadgets, getProvider, getSubagent, groupByParent, hasHostExports, hasPreset, hasProviderPrefix, hasSubagents, humanDelay, imageFromBase64, imageFromBuffer, imageFromUrl, isAbortError, isAudioPart, isDataUrl, isGadgetEvent, isImagePart, isLLMEvent, isRetryableError, isRootEvent, isSubagentEvent, isTextPart, iterationProgressHint, listPresets, listSubagents, normalizeMessageContent, parallelGadgetHint, parseDataUrl, parseManifest, parseRetryAfterHeader, randomDelay, resetFileLoggingState, resolveConfig, resolveHintTemplate, resolveModel, resolvePromptTemplate, resolveRateLimitConfig, resolveRetryConfig, resolveRulesTemplate, resolveSubagentModel, resolveSubagentTimeout, resolveValue, resultWithAudio, resultWithFile, resultWithImage, resultWithImages, resultWithMedia, runWithHandlers, schemaToJSONSchema, stream, text, timing, toBase64, truncate, validateAndApplyDefaults, validateGadgetParams, validateGadgetSchema, withErrorHandling, withRetry, withTimeout };