llmist 16.0.1 → 16.0.3
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.cjs +102 -24
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +56 -2
- package/dist/index.d.ts +56 -2
- package/dist/index.js +101 -25
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -6744,6 +6744,56 @@ declare class Agent {
|
|
|
6744
6744
|
* ```
|
|
6745
6745
|
*/
|
|
6746
6746
|
|
|
6747
|
+
/**
|
|
6748
|
+
* State container for file logging session.
|
|
6749
|
+
* Encapsulates all mutable state to enable session isolation and proper
|
|
6750
|
+
* handling of concurrent subagents.
|
|
6751
|
+
*
|
|
6752
|
+
* @remarks
|
|
6753
|
+
* Using a state object instead of module-level globals provides:
|
|
6754
|
+
* - **Session isolation**: Multiple agent sessions don't interfere with each other
|
|
6755
|
+
* - **Testability**: Tests can inject fresh state without needing to reset globals
|
|
6756
|
+
* - **Concurrent subagent support**: Context-based keys prevent race conditions
|
|
6757
|
+
*/
|
|
6758
|
+
interface FileLoggingState {
|
|
6759
|
+
/** Counter per directory path (normalized) */
|
|
6760
|
+
readonly counters: Map<string, number>;
|
|
6761
|
+
/**
|
|
6762
|
+
* Subagent context key -> assigned directory path.
|
|
6763
|
+
* Key format: `${parentDir}:${parentGadgetInvocationId}`
|
|
6764
|
+
*/
|
|
6765
|
+
readonly subagentDirectories: Map<string, string>;
|
|
6766
|
+
/**
|
|
6767
|
+
* Context key -> active directory for that execution context.
|
|
6768
|
+
* Key format: `${parentGadgetInvocationId}:${depth}` (or "root:0" for main agent)
|
|
6769
|
+
*
|
|
6770
|
+
* This replaces the previous depth-only keying which caused race conditions
|
|
6771
|
+
* when multiple subagents at the same depth ran concurrently.
|
|
6772
|
+
*/
|
|
6773
|
+
readonly activeDirectoryByContext: Map<string, string>;
|
|
6774
|
+
}
|
|
6775
|
+
/**
|
|
6776
|
+
* Creates a fresh file logging state container.
|
|
6777
|
+
*
|
|
6778
|
+
* Use this to create isolated state for testing or when running multiple
|
|
6779
|
+
* independent agent sessions that shouldn't share counters.
|
|
6780
|
+
*
|
|
6781
|
+
* @example
|
|
6782
|
+
* ```typescript
|
|
6783
|
+
* // For testing with isolated state:
|
|
6784
|
+
* const state = createFileLoggingState();
|
|
6785
|
+
* const hooks = createFileLoggingHooks({ directory: './logs' }, state);
|
|
6786
|
+
*
|
|
6787
|
+
* // For production (uses default shared state):
|
|
6788
|
+
* const hooks = createFileLoggingHooks({ directory: './logs' });
|
|
6789
|
+
* ```
|
|
6790
|
+
*/
|
|
6791
|
+
declare function createFileLoggingState(): FileLoggingState;
|
|
6792
|
+
/**
|
|
6793
|
+
* Resets the default global state. For testing only.
|
|
6794
|
+
* @internal
|
|
6795
|
+
*/
|
|
6796
|
+
declare function resetFileLoggingState(): void;
|
|
6747
6797
|
/**
|
|
6748
6798
|
* Options for configuring file-based LLM logging.
|
|
6749
6799
|
*/
|
|
@@ -6786,10 +6836,14 @@ interface FileWrittenInfo {
|
|
|
6786
6836
|
filePath: string;
|
|
6787
6837
|
/** Type of log file */
|
|
6788
6838
|
type: "request" | "response";
|
|
6789
|
-
/** LLM call number (1-indexed) */
|
|
6839
|
+
/** LLM call number (1-indexed) within the current directory */
|
|
6790
6840
|
callNumber: number;
|
|
6791
6841
|
/** Length of the written content in characters */
|
|
6792
6842
|
contentLength: number;
|
|
6843
|
+
/** Gadget invocation ID that spawned this subagent (undefined for main agent) */
|
|
6844
|
+
parentGadgetInvocationId?: string;
|
|
6845
|
+
/** Subagent depth (undefined for main agent) */
|
|
6846
|
+
depth?: number;
|
|
6793
6847
|
}
|
|
6794
6848
|
/**
|
|
6795
6849
|
* Formats LLM messages as plain text for debugging.
|
|
@@ -10859,4 +10913,4 @@ declare const timing: {
|
|
|
10859
10913
|
*/
|
|
10860
10914
|
declare function getHostExports(ctx: ExecutionContext): HostExports;
|
|
10861
10915
|
|
|
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 };
|
|
10916
|
+
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
|
@@ -6744,6 +6744,56 @@ declare class Agent {
|
|
|
6744
6744
|
* ```
|
|
6745
6745
|
*/
|
|
6746
6746
|
|
|
6747
|
+
/**
|
|
6748
|
+
* State container for file logging session.
|
|
6749
|
+
* Encapsulates all mutable state to enable session isolation and proper
|
|
6750
|
+
* handling of concurrent subagents.
|
|
6751
|
+
*
|
|
6752
|
+
* @remarks
|
|
6753
|
+
* Using a state object instead of module-level globals provides:
|
|
6754
|
+
* - **Session isolation**: Multiple agent sessions don't interfere with each other
|
|
6755
|
+
* - **Testability**: Tests can inject fresh state without needing to reset globals
|
|
6756
|
+
* - **Concurrent subagent support**: Context-based keys prevent race conditions
|
|
6757
|
+
*/
|
|
6758
|
+
interface FileLoggingState {
|
|
6759
|
+
/** Counter per directory path (normalized) */
|
|
6760
|
+
readonly counters: Map<string, number>;
|
|
6761
|
+
/**
|
|
6762
|
+
* Subagent context key -> assigned directory path.
|
|
6763
|
+
* Key format: `${parentDir}:${parentGadgetInvocationId}`
|
|
6764
|
+
*/
|
|
6765
|
+
readonly subagentDirectories: Map<string, string>;
|
|
6766
|
+
/**
|
|
6767
|
+
* Context key -> active directory for that execution context.
|
|
6768
|
+
* Key format: `${parentGadgetInvocationId}:${depth}` (or "root:0" for main agent)
|
|
6769
|
+
*
|
|
6770
|
+
* This replaces the previous depth-only keying which caused race conditions
|
|
6771
|
+
* when multiple subagents at the same depth ran concurrently.
|
|
6772
|
+
*/
|
|
6773
|
+
readonly activeDirectoryByContext: Map<string, string>;
|
|
6774
|
+
}
|
|
6775
|
+
/**
|
|
6776
|
+
* Creates a fresh file logging state container.
|
|
6777
|
+
*
|
|
6778
|
+
* Use this to create isolated state for testing or when running multiple
|
|
6779
|
+
* independent agent sessions that shouldn't share counters.
|
|
6780
|
+
*
|
|
6781
|
+
* @example
|
|
6782
|
+
* ```typescript
|
|
6783
|
+
* // For testing with isolated state:
|
|
6784
|
+
* const state = createFileLoggingState();
|
|
6785
|
+
* const hooks = createFileLoggingHooks({ directory: './logs' }, state);
|
|
6786
|
+
*
|
|
6787
|
+
* // For production (uses default shared state):
|
|
6788
|
+
* const hooks = createFileLoggingHooks({ directory: './logs' });
|
|
6789
|
+
* ```
|
|
6790
|
+
*/
|
|
6791
|
+
declare function createFileLoggingState(): FileLoggingState;
|
|
6792
|
+
/**
|
|
6793
|
+
* Resets the default global state. For testing only.
|
|
6794
|
+
* @internal
|
|
6795
|
+
*/
|
|
6796
|
+
declare function resetFileLoggingState(): void;
|
|
6747
6797
|
/**
|
|
6748
6798
|
* Options for configuring file-based LLM logging.
|
|
6749
6799
|
*/
|
|
@@ -6786,10 +6836,14 @@ interface FileWrittenInfo {
|
|
|
6786
6836
|
filePath: string;
|
|
6787
6837
|
/** Type of log file */
|
|
6788
6838
|
type: "request" | "response";
|
|
6789
|
-
/** LLM call number (1-indexed) */
|
|
6839
|
+
/** LLM call number (1-indexed) within the current directory */
|
|
6790
6840
|
callNumber: number;
|
|
6791
6841
|
/** Length of the written content in characters */
|
|
6792
6842
|
contentLength: number;
|
|
6843
|
+
/** Gadget invocation ID that spawned this subagent (undefined for main agent) */
|
|
6844
|
+
parentGadgetInvocationId?: string;
|
|
6845
|
+
/** Subagent depth (undefined for main agent) */
|
|
6846
|
+
depth?: number;
|
|
6793
6847
|
}
|
|
6794
6848
|
/**
|
|
6795
6849
|
* Formats LLM messages as plain text for debugging.
|
|
@@ -10859,4 +10913,4 @@ declare const timing: {
|
|
|
10859
10913
|
*/
|
|
10860
10914
|
declare function getHostExports(ctx: ExecutionContext): HostExports;
|
|
10861
10915
|
|
|
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 };
|
|
10916
|
+
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.js
CHANGED
|
@@ -647,11 +647,11 @@ var init_execution_tree = __esm({
|
|
|
647
647
|
yield this.eventQueue.shift();
|
|
648
648
|
}
|
|
649
649
|
if (this.isCompleted) break;
|
|
650
|
-
const event = await new Promise((
|
|
650
|
+
const event = await new Promise((resolve2) => {
|
|
651
651
|
if (this.eventQueue.length > 0) {
|
|
652
|
-
|
|
652
|
+
resolve2(this.eventQueue.shift());
|
|
653
653
|
} else {
|
|
654
|
-
this.eventWaiters.push(
|
|
654
|
+
this.eventWaiters.push(resolve2);
|
|
655
655
|
}
|
|
656
656
|
});
|
|
657
657
|
yield event;
|
|
@@ -4072,7 +4072,63 @@ var init_registry = __esm({
|
|
|
4072
4072
|
|
|
4073
4073
|
// src/agent/file-logging.ts
|
|
4074
4074
|
import { mkdir as mkdir2, writeFile as writeFile2 } from "fs/promises";
|
|
4075
|
-
import { join as join2 } from "path";
|
|
4075
|
+
import { join as join2, resolve } from "path";
|
|
4076
|
+
function createFileLoggingState() {
|
|
4077
|
+
return {
|
|
4078
|
+
counters: /* @__PURE__ */ new Map(),
|
|
4079
|
+
subagentDirectories: /* @__PURE__ */ new Map(),
|
|
4080
|
+
activeDirectoryByContext: /* @__PURE__ */ new Map()
|
|
4081
|
+
};
|
|
4082
|
+
}
|
|
4083
|
+
function getDefaultState() {
|
|
4084
|
+
if (!defaultState) {
|
|
4085
|
+
defaultState = createFileLoggingState();
|
|
4086
|
+
}
|
|
4087
|
+
return defaultState;
|
|
4088
|
+
}
|
|
4089
|
+
function getNextCounter(state, directory) {
|
|
4090
|
+
const current = state.counters.get(directory) ?? 0;
|
|
4091
|
+
const next = current + 1;
|
|
4092
|
+
state.counters.set(directory, next);
|
|
4093
|
+
return next;
|
|
4094
|
+
}
|
|
4095
|
+
function getContextKey(subagentContext) {
|
|
4096
|
+
if (!subagentContext) return "root:0";
|
|
4097
|
+
return `${subagentContext.parentGadgetInvocationId}:${subagentContext.depth}`;
|
|
4098
|
+
}
|
|
4099
|
+
function resetFileLoggingState() {
|
|
4100
|
+
defaultState = void 0;
|
|
4101
|
+
}
|
|
4102
|
+
function findParentContextKey(state, currentDepth) {
|
|
4103
|
+
const parentDepth = currentDepth - 1;
|
|
4104
|
+
if (parentDepth === 0) return "root:0";
|
|
4105
|
+
for (const [key, _path] of state.activeDirectoryByContext) {
|
|
4106
|
+
if (key.endsWith(`:${parentDepth}`)) {
|
|
4107
|
+
return key;
|
|
4108
|
+
}
|
|
4109
|
+
}
|
|
4110
|
+
return "root:0";
|
|
4111
|
+
}
|
|
4112
|
+
function resolveLoggingDirectory(state, baseDirectory, counterPadding, subagentContext) {
|
|
4113
|
+
const contextKey = getContextKey(subagentContext);
|
|
4114
|
+
if (!subagentContext) {
|
|
4115
|
+
state.activeDirectoryByContext.set(contextKey, baseDirectory);
|
|
4116
|
+
return baseDirectory;
|
|
4117
|
+
}
|
|
4118
|
+
const { parentGadgetInvocationId, depth } = subagentContext;
|
|
4119
|
+
const parentContextKey = findParentContextKey(state, depth);
|
|
4120
|
+
const parentDir = state.activeDirectoryByContext.get(parentContextKey) ?? baseDirectory;
|
|
4121
|
+
const subagentKey = `${parentDir}:${parentGadgetInvocationId}`;
|
|
4122
|
+
let fullPath = state.subagentDirectories.get(subagentKey);
|
|
4123
|
+
if (!fullPath) {
|
|
4124
|
+
const chronoNumber = getNextCounter(state, parentDir);
|
|
4125
|
+
const subdirName = `${formatCallNumber(chronoNumber, counterPadding)}-${parentGadgetInvocationId}`;
|
|
4126
|
+
fullPath = join2(parentDir, subdirName);
|
|
4127
|
+
state.subagentDirectories.set(subagentKey, fullPath);
|
|
4128
|
+
}
|
|
4129
|
+
state.activeDirectoryByContext.set(contextKey, fullPath);
|
|
4130
|
+
return fullPath;
|
|
4131
|
+
}
|
|
4076
4132
|
function formatLlmRequest(messages) {
|
|
4077
4133
|
const lines = [];
|
|
4078
4134
|
for (const msg of messages) {
|
|
@@ -4089,16 +4145,20 @@ async function writeLogFile(dir, filename, content) {
|
|
|
4089
4145
|
await mkdir2(dir, { recursive: true });
|
|
4090
4146
|
await writeFile2(join2(dir, filename), content, "utf-8");
|
|
4091
4147
|
}
|
|
4092
|
-
function createFileLoggingHooks(options) {
|
|
4148
|
+
function createFileLoggingHooks(options, state = getDefaultState()) {
|
|
4093
4149
|
const {
|
|
4094
|
-
directory,
|
|
4095
4150
|
startingCounter = 1,
|
|
4096
4151
|
counterPadding = 4,
|
|
4097
4152
|
skipSubagents = true,
|
|
4098
4153
|
formatRequest = formatLlmRequest,
|
|
4099
4154
|
onFileWritten
|
|
4100
4155
|
} = options;
|
|
4101
|
-
|
|
4156
|
+
const baseDirectory = resolve(options.directory);
|
|
4157
|
+
if (!state.counters.has(baseDirectory)) {
|
|
4158
|
+
state.counters.set(baseDirectory, startingCounter - 1);
|
|
4159
|
+
}
|
|
4160
|
+
let currentCallNumber = 0;
|
|
4161
|
+
let currentDirectory = baseDirectory;
|
|
4102
4162
|
return {
|
|
4103
4163
|
observers: {
|
|
4104
4164
|
/**
|
|
@@ -4108,17 +4168,25 @@ function createFileLoggingHooks(options) {
|
|
|
4108
4168
|
if (skipSubagents && context.subagentContext) {
|
|
4109
4169
|
return;
|
|
4110
4170
|
}
|
|
4111
|
-
|
|
4112
|
-
|
|
4171
|
+
currentDirectory = resolveLoggingDirectory(
|
|
4172
|
+
state,
|
|
4173
|
+
baseDirectory,
|
|
4174
|
+
counterPadding,
|
|
4175
|
+
context.subagentContext
|
|
4176
|
+
);
|
|
4177
|
+
currentCallNumber = getNextCounter(state, currentDirectory);
|
|
4178
|
+
const filename = `${formatCallNumber(currentCallNumber, counterPadding)}.request`;
|
|
4113
4179
|
const content = formatRequest(context.options.messages);
|
|
4114
4180
|
try {
|
|
4115
|
-
await writeLogFile(
|
|
4181
|
+
await writeLogFile(currentDirectory, filename, content);
|
|
4116
4182
|
if (onFileWritten) {
|
|
4117
4183
|
onFileWritten({
|
|
4118
|
-
filePath: join2(
|
|
4184
|
+
filePath: join2(currentDirectory, filename),
|
|
4119
4185
|
type: "request",
|
|
4120
|
-
callNumber:
|
|
4121
|
-
contentLength: content.length
|
|
4186
|
+
callNumber: currentCallNumber,
|
|
4187
|
+
contentLength: content.length,
|
|
4188
|
+
parentGadgetInvocationId: context.subagentContext?.parentGadgetInvocationId,
|
|
4189
|
+
depth: context.subagentContext?.depth
|
|
4122
4190
|
});
|
|
4123
4191
|
}
|
|
4124
4192
|
} catch (error) {
|
|
@@ -4132,16 +4200,22 @@ function createFileLoggingHooks(options) {
|
|
|
4132
4200
|
if (skipSubagents && context.subagentContext) {
|
|
4133
4201
|
return;
|
|
4134
4202
|
}
|
|
4135
|
-
|
|
4203
|
+
if (currentCallNumber === 0) {
|
|
4204
|
+
console.warn("[file-logging] Skipping response write: no matching request recorded");
|
|
4205
|
+
return;
|
|
4206
|
+
}
|
|
4207
|
+
const filename = `${formatCallNumber(currentCallNumber, counterPadding)}.response`;
|
|
4136
4208
|
const content = context.rawResponse;
|
|
4137
4209
|
try {
|
|
4138
|
-
await writeLogFile(
|
|
4210
|
+
await writeLogFile(currentDirectory, filename, content);
|
|
4139
4211
|
if (onFileWritten) {
|
|
4140
4212
|
onFileWritten({
|
|
4141
|
-
filePath: join2(
|
|
4213
|
+
filePath: join2(currentDirectory, filename),
|
|
4142
4214
|
type: "response",
|
|
4143
|
-
callNumber:
|
|
4144
|
-
contentLength: content.length
|
|
4215
|
+
callNumber: currentCallNumber,
|
|
4216
|
+
contentLength: content.length,
|
|
4217
|
+
parentGadgetInvocationId: context.subagentContext?.parentGadgetInvocationId,
|
|
4218
|
+
depth: context.subagentContext?.depth
|
|
4145
4219
|
});
|
|
4146
4220
|
}
|
|
4147
4221
|
} catch (error) {
|
|
@@ -4158,7 +4232,7 @@ function getEnvFileLoggingHooks() {
|
|
|
4158
4232
|
}
|
|
4159
4233
|
return createFileLoggingHooks({ directory });
|
|
4160
4234
|
}
|
|
4161
|
-
var ENV_LOG_RAW_DIRECTORY;
|
|
4235
|
+
var defaultState, ENV_LOG_RAW_DIRECTORY;
|
|
4162
4236
|
var init_file_logging = __esm({
|
|
4163
4237
|
"src/agent/file-logging.ts"() {
|
|
4164
4238
|
"use strict";
|
|
@@ -14422,7 +14496,7 @@ var init_stream_processor = __esm({
|
|
|
14422
14496
|
const allDone = this.inFlightExecutions.size > 0 ? Promise.all(this.inFlightExecutions.values()).then(() => "done") : Promise.resolve("done");
|
|
14423
14497
|
const result = await Promise.race([
|
|
14424
14498
|
allDone,
|
|
14425
|
-
new Promise((
|
|
14499
|
+
new Promise((resolve2) => setTimeout(() => resolve2("poll"), POLL_INTERVAL_MS))
|
|
14426
14500
|
]);
|
|
14427
14501
|
yield* this.drainCompletedResults();
|
|
14428
14502
|
if (result === "done" && this.getTotalActiveGadgetCount() === 0 && !this.hasQueuedGadgets()) {
|
|
@@ -15564,7 +15638,7 @@ var init_agent = __esm({
|
|
|
15564
15638
|
* Simple sleep utility for rate limit delays.
|
|
15565
15639
|
*/
|
|
15566
15640
|
sleep(ms) {
|
|
15567
|
-
return new Promise((
|
|
15641
|
+
return new Promise((resolve2) => setTimeout(resolve2, ms));
|
|
15568
15642
|
}
|
|
15569
15643
|
/**
|
|
15570
15644
|
* Handle LLM error through controller.
|
|
@@ -16612,10 +16686,10 @@ function randomDelay(min, max) {
|
|
|
16612
16686
|
}
|
|
16613
16687
|
async function humanDelay(min = 50, max = 150) {
|
|
16614
16688
|
const delay = randomDelay(min, max);
|
|
16615
|
-
return new Promise((
|
|
16689
|
+
return new Promise((resolve2) => setTimeout(resolve2, delay));
|
|
16616
16690
|
}
|
|
16617
16691
|
async function withTimeout(fn, timeoutMs, signal) {
|
|
16618
|
-
return new Promise((
|
|
16692
|
+
return new Promise((resolve2, reject) => {
|
|
16619
16693
|
if (signal?.aborted) {
|
|
16620
16694
|
reject(new Error("Operation aborted"));
|
|
16621
16695
|
return;
|
|
@@ -16641,7 +16715,7 @@ async function withTimeout(fn, timeoutMs, signal) {
|
|
|
16641
16715
|
settled = true;
|
|
16642
16716
|
clearTimeout(timeoutId);
|
|
16643
16717
|
signal?.removeEventListener("abort", abortHandler);
|
|
16644
|
-
|
|
16718
|
+
resolve2(result);
|
|
16645
16719
|
}
|
|
16646
16720
|
}).catch((error) => {
|
|
16647
16721
|
if (!settled) {
|
|
@@ -16674,7 +16748,7 @@ async function withRetry(fn, options = {}) {
|
|
|
16674
16748
|
}
|
|
16675
16749
|
const waitTime = Math.min(currentDelay, maxDelay);
|
|
16676
16750
|
onRetry?.(error, attempt + 1, waitTime);
|
|
16677
|
-
await new Promise((
|
|
16751
|
+
await new Promise((resolve2) => setTimeout(resolve2, waitTime));
|
|
16678
16752
|
if (backoff === "exponential") {
|
|
16679
16753
|
currentDelay *= 2;
|
|
16680
16754
|
} else {
|
|
@@ -16753,6 +16827,7 @@ export {
|
|
|
16753
16827
|
collectText,
|
|
16754
16828
|
complete,
|
|
16755
16829
|
createAnthropicProviderFromEnv,
|
|
16830
|
+
createFileLoggingState,
|
|
16756
16831
|
createGadget,
|
|
16757
16832
|
createGadgetOutputViewer,
|
|
16758
16833
|
createGeminiProviderFromEnv,
|
|
@@ -16815,6 +16890,7 @@ export {
|
|
|
16815
16890
|
parseManifest,
|
|
16816
16891
|
parseRetryAfterHeader,
|
|
16817
16892
|
randomDelay,
|
|
16893
|
+
resetFileLoggingState,
|
|
16818
16894
|
resolveConfig,
|
|
16819
16895
|
resolveHintTemplate,
|
|
16820
16896
|
resolveModel,
|