llmist 18.0.0 → 18.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +155 -57
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +28 -1
- package/dist/index.d.ts +28 -1
- package/dist/index.js +149 -52
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -2999,6 +2999,15 @@ interface RetryConfig {
|
|
|
2999
2999
|
* @default 120000 (2 minutes)
|
|
3000
3000
|
*/
|
|
3001
3001
|
maxRetryAfterMs?: number;
|
|
3002
|
+
/**
|
|
3003
|
+
* Whether to treat an empty completion (a 200-OK response with no text,
|
|
3004
|
+
* no tool calls, and no reasoning) as a transient failure and retry it.
|
|
3005
|
+
* When all attempts come back empty, an `EmptyCompletionError` is thrown
|
|
3006
|
+
* rather than committing a silent blank turn. Only takes effect when
|
|
3007
|
+
* `enabled` is true.
|
|
3008
|
+
* @default true
|
|
3009
|
+
*/
|
|
3010
|
+
retryOnEmpty?: boolean;
|
|
3002
3011
|
}
|
|
3003
3012
|
/**
|
|
3004
3013
|
* Resolved retry configuration with all defaults applied.
|
|
@@ -3015,6 +3024,7 @@ interface ResolvedRetryConfig {
|
|
|
3015
3024
|
shouldRetry?: (error: Error) => boolean;
|
|
3016
3025
|
respectRetryAfter: boolean;
|
|
3017
3026
|
maxRetryAfterMs: number;
|
|
3027
|
+
retryOnEmpty: boolean;
|
|
3018
3028
|
}
|
|
3019
3029
|
/**
|
|
3020
3030
|
* Default retry configuration values.
|
|
@@ -8086,6 +8096,23 @@ declare const GADGET_ARG_PREFIX = "!!!ARG:";
|
|
|
8086
8096
|
/**
|
|
8087
8097
|
* Error utilities for llmist.
|
|
8088
8098
|
*/
|
|
8099
|
+
/**
|
|
8100
|
+
* Thrown when an LLM provider returns a completion with no usable output —
|
|
8101
|
+
* no text, no tool calls, and no reasoning — typically a transient provider
|
|
8102
|
+
* glitch (e.g. a 200-OK response with an empty body). The retry orchestrator
|
|
8103
|
+
* treats this as a retryable failure; if every attempt comes back empty it
|
|
8104
|
+
* surfaces this error rather than committing a silent blank turn.
|
|
8105
|
+
*/
|
|
8106
|
+
declare class EmptyCompletionError extends Error {
|
|
8107
|
+
/** Agent iteration on which the empty completion was observed. */
|
|
8108
|
+
readonly iteration: number;
|
|
8109
|
+
/** Finish reason reported alongside the empty body (often null). */
|
|
8110
|
+
readonly finishReason: string | null;
|
|
8111
|
+
constructor(params: {
|
|
8112
|
+
iteration: number;
|
|
8113
|
+
finishReason: string | null;
|
|
8114
|
+
});
|
|
8115
|
+
}
|
|
8089
8116
|
/**
|
|
8090
8117
|
* Detects if an error is an abort/cancellation error from any provider.
|
|
8091
8118
|
*
|
|
@@ -11120,4 +11147,4 @@ declare const timing: {
|
|
|
11120
11147
|
*/
|
|
11121
11148
|
declare function getHostExports(ctx: ExecutionContext): HostExports;
|
|
11122
11149
|
|
|
11123
|
-
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, type BeforeSkillActivationAction, 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, type CreateMcpServerOptions, DEFAULT_COMPACTION_CONFIG, DEFAULT_HINTS, DEFAULT_MCP_COMMAND_ALLOWLIST, 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 GadgetExecutorOptions, 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, type HttpMcpServerSpec, 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 JSONSchemaLike, JsonSchemaConversionError, 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, LOAD_SKILL_GADGET_NAME, type LoggerOptions, type LoggingOptions, MODEL_ALIASES, McpClient, type McpClientOptions, McpConnectError, type McpContentBlock, McpError, McpLifecycle, type McpServerCapabilities, type McpServerHandle, type McpServerSpec, type McpToolAdapterOptions, McpToolCallError, type McpToolDescriptor, type McpToolResult, McpUntrustedCommandError, 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 ObserveSkillActivatedContext, type Observers, OpenAIChatProvider, type OpenAICompatibleConfig, OpenAICompatibleProvider, type OpenRouterConfig, OpenRouterProvider, type OpenRouterRouting, type OutputLimitConfig, type ParallelGadgetHintOptions, type ParsedGadgetCall, type ParsedSkill, type PrefixConfig, 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, Skill, type SkillActivation, type SkillActivationControllerContext, type SkillActivationOptions, type SkillInstructionInterceptorContext, type SkillMetadata, SkillRegistry, type SkillResource, type SkillSource, SlidingWindowStrategy, type SpeechGenerationOptions, type SpeechGenerationResult, type SpeechModelSpec, type StdioMcpServerSpec, 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 TreeConfig, type GadgetSkippedEvent$1 as TreeGadgetSkippedEvent, type TriggeredLimitInfo, type ValidationIssue, type ValidationResult, type VisionAnalyzeOptions, type VisionAnalyzeResult, assertCommandAllowed, audioFromBase64, audioFromBuffer, collectEvents, collectText, complete, createAnthropicProviderFromEnv, createFileLoggingState, createGadget, createGadgetOutputViewer, createGeminiProviderFromEnv, createHints, createHuggingFaceProviderFromEnv, createLoadSkillGadget, createLogger, createMcpServer, createMediaOutput, createOpenAIProviderFromEnv, createOpenRouterProviderFromEnv, createSubagent, defaultLogger, detectAudioMimeType, detectImageMimeType, discoverProviderAdapters, discoverSkills, extractMessageText, extractRetryAfterMs, filterByDepth, filterByParent, filterRootEvents, format, formatBytes, formatCallNumber, formatDate, formatDuration, formatLLMError, formatLlmRequest, gadgetError, gadgetResultToMcpContent, gadgetSuccess, gadgetToMcpTool, getErrorMessage, getHostExports, getModelId, getPresetGadgets, getProvider, getSubagent, groupByParent, hasHostExports, hasPreset, hasProviderPrefix, hasSubagents, humanDelay, imageFromBase64, imageFromBuffer, imageFromUrl, isAbortError, isAudioPart, isDataUrl, isGadgetEvent, isImagePart, isLLMEvent, isLikelyContextOverflow, isRetryableError, isRootEvent, isSubagentEvent, isTextPart, iterationProgressHint, jsonSchemaToZod, listPresets, listSubagents, loadSkillsFromDirectory, mcpToolToGadget, normalizeMessageContent, parallelGadgetHint, parseDataUrl, parseFrontmatter, parseManifest, parseMetadata, parseRetryAfterHeader, parseSkillContent, parseSkillFile, randomDelay, renderSkillForMcpPrompt, resetFileLoggingState, resolveConfig, resolveHintTemplate, resolveInstructions, resolveModel, resolvePromptTemplate, resolveRateLimitConfig, resolveRetryConfig, resolveRulesTemplate, resolveSubagentModel, resolveSubagentTimeout, resolveValue, resultWithAudio, resultWithFile, resultWithImage, resultWithImages, resultWithMedia, runGadgetForMcp, runWithHandlers, scanResources, schemaToJSONSchema, skillToMcpPrompt, stream, stripProviderPrefix, substituteArguments, substituteVariables, text, timing, toBase64, truncate, validateAndApplyDefaults, validateGadgetParams, validateGadgetSchema, validateMetadata, withErrorHandling, withRetry, withTimeout };
|
|
11150
|
+
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, type BeforeSkillActivationAction, 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, type CreateMcpServerOptions, DEFAULT_COMPACTION_CONFIG, DEFAULT_HINTS, DEFAULT_MCP_COMMAND_ALLOWLIST, DEFAULT_PROMPTS, DEFAULT_RATE_LIMIT_CONFIG, DEFAULT_RETRY_CONFIG, DEFAULT_SUMMARIZATION_PROMPT, EmptyCompletionError, 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 GadgetExecutorOptions, 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, type HttpMcpServerSpec, 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 JSONSchemaLike, JsonSchemaConversionError, 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, LOAD_SKILL_GADGET_NAME, type LoggerOptions, type LoggingOptions, MODEL_ALIASES, McpClient, type McpClientOptions, McpConnectError, type McpContentBlock, McpError, McpLifecycle, type McpServerCapabilities, type McpServerHandle, type McpServerSpec, type McpToolAdapterOptions, McpToolCallError, type McpToolDescriptor, type McpToolResult, McpUntrustedCommandError, 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 ObserveSkillActivatedContext, type Observers, OpenAIChatProvider, type OpenAICompatibleConfig, OpenAICompatibleProvider, type OpenRouterConfig, OpenRouterProvider, type OpenRouterRouting, type OutputLimitConfig, type ParallelGadgetHintOptions, type ParsedGadgetCall, type ParsedSkill, type PrefixConfig, 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, Skill, type SkillActivation, type SkillActivationControllerContext, type SkillActivationOptions, type SkillInstructionInterceptorContext, type SkillMetadata, SkillRegistry, type SkillResource, type SkillSource, SlidingWindowStrategy, type SpeechGenerationOptions, type SpeechGenerationResult, type SpeechModelSpec, type StdioMcpServerSpec, 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 TreeConfig, type GadgetSkippedEvent$1 as TreeGadgetSkippedEvent, type TriggeredLimitInfo, type ValidationIssue, type ValidationResult, type VisionAnalyzeOptions, type VisionAnalyzeResult, assertCommandAllowed, audioFromBase64, audioFromBuffer, collectEvents, collectText, complete, createAnthropicProviderFromEnv, createFileLoggingState, createGadget, createGadgetOutputViewer, createGeminiProviderFromEnv, createHints, createHuggingFaceProviderFromEnv, createLoadSkillGadget, createLogger, createMcpServer, createMediaOutput, createOpenAIProviderFromEnv, createOpenRouterProviderFromEnv, createSubagent, defaultLogger, detectAudioMimeType, detectImageMimeType, discoverProviderAdapters, discoverSkills, extractMessageText, extractRetryAfterMs, filterByDepth, filterByParent, filterRootEvents, format, formatBytes, formatCallNumber, formatDate, formatDuration, formatLLMError, formatLlmRequest, gadgetError, gadgetResultToMcpContent, gadgetSuccess, gadgetToMcpTool, getErrorMessage, getHostExports, getModelId, getPresetGadgets, getProvider, getSubagent, groupByParent, hasHostExports, hasPreset, hasProviderPrefix, hasSubagents, humanDelay, imageFromBase64, imageFromBuffer, imageFromUrl, isAbortError, isAudioPart, isDataUrl, isGadgetEvent, isImagePart, isLLMEvent, isLikelyContextOverflow, isRetryableError, isRootEvent, isSubagentEvent, isTextPart, iterationProgressHint, jsonSchemaToZod, listPresets, listSubagents, loadSkillsFromDirectory, mcpToolToGadget, normalizeMessageContent, parallelGadgetHint, parseDataUrl, parseFrontmatter, parseManifest, parseMetadata, parseRetryAfterHeader, parseSkillContent, parseSkillFile, randomDelay, renderSkillForMcpPrompt, resetFileLoggingState, resolveConfig, resolveHintTemplate, resolveInstructions, resolveModel, resolvePromptTemplate, resolveRateLimitConfig, resolveRetryConfig, resolveRulesTemplate, resolveSubagentModel, resolveSubagentTimeout, resolveValue, resultWithAudio, resultWithFile, resultWithImage, resultWithImages, resultWithMedia, runGadgetForMcp, runWithHandlers, scanResources, schemaToJSONSchema, skillToMcpPrompt, stream, stripProviderPrefix, substituteArguments, substituteVariables, text, timing, toBase64, truncate, validateAndApplyDefaults, validateGadgetParams, validateGadgetSchema, validateMetadata, withErrorHandling, withRetry, withTimeout };
|
package/dist/index.d.ts
CHANGED
|
@@ -2999,6 +2999,15 @@ interface RetryConfig {
|
|
|
2999
2999
|
* @default 120000 (2 minutes)
|
|
3000
3000
|
*/
|
|
3001
3001
|
maxRetryAfterMs?: number;
|
|
3002
|
+
/**
|
|
3003
|
+
* Whether to treat an empty completion (a 200-OK response with no text,
|
|
3004
|
+
* no tool calls, and no reasoning) as a transient failure and retry it.
|
|
3005
|
+
* When all attempts come back empty, an `EmptyCompletionError` is thrown
|
|
3006
|
+
* rather than committing a silent blank turn. Only takes effect when
|
|
3007
|
+
* `enabled` is true.
|
|
3008
|
+
* @default true
|
|
3009
|
+
*/
|
|
3010
|
+
retryOnEmpty?: boolean;
|
|
3002
3011
|
}
|
|
3003
3012
|
/**
|
|
3004
3013
|
* Resolved retry configuration with all defaults applied.
|
|
@@ -3015,6 +3024,7 @@ interface ResolvedRetryConfig {
|
|
|
3015
3024
|
shouldRetry?: (error: Error) => boolean;
|
|
3016
3025
|
respectRetryAfter: boolean;
|
|
3017
3026
|
maxRetryAfterMs: number;
|
|
3027
|
+
retryOnEmpty: boolean;
|
|
3018
3028
|
}
|
|
3019
3029
|
/**
|
|
3020
3030
|
* Default retry configuration values.
|
|
@@ -8086,6 +8096,23 @@ declare const GADGET_ARG_PREFIX = "!!!ARG:";
|
|
|
8086
8096
|
/**
|
|
8087
8097
|
* Error utilities for llmist.
|
|
8088
8098
|
*/
|
|
8099
|
+
/**
|
|
8100
|
+
* Thrown when an LLM provider returns a completion with no usable output —
|
|
8101
|
+
* no text, no tool calls, and no reasoning — typically a transient provider
|
|
8102
|
+
* glitch (e.g. a 200-OK response with an empty body). The retry orchestrator
|
|
8103
|
+
* treats this as a retryable failure; if every attempt comes back empty it
|
|
8104
|
+
* surfaces this error rather than committing a silent blank turn.
|
|
8105
|
+
*/
|
|
8106
|
+
declare class EmptyCompletionError extends Error {
|
|
8107
|
+
/** Agent iteration on which the empty completion was observed. */
|
|
8108
|
+
readonly iteration: number;
|
|
8109
|
+
/** Finish reason reported alongside the empty body (often null). */
|
|
8110
|
+
readonly finishReason: string | null;
|
|
8111
|
+
constructor(params: {
|
|
8112
|
+
iteration: number;
|
|
8113
|
+
finishReason: string | null;
|
|
8114
|
+
});
|
|
8115
|
+
}
|
|
8089
8116
|
/**
|
|
8090
8117
|
* Detects if an error is an abort/cancellation error from any provider.
|
|
8091
8118
|
*
|
|
@@ -11120,4 +11147,4 @@ declare const timing: {
|
|
|
11120
11147
|
*/
|
|
11121
11148
|
declare function getHostExports(ctx: ExecutionContext): HostExports;
|
|
11122
11149
|
|
|
11123
|
-
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, type BeforeSkillActivationAction, 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, type CreateMcpServerOptions, DEFAULT_COMPACTION_CONFIG, DEFAULT_HINTS, DEFAULT_MCP_COMMAND_ALLOWLIST, 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 GadgetExecutorOptions, 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, type HttpMcpServerSpec, 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 JSONSchemaLike, JsonSchemaConversionError, 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, LOAD_SKILL_GADGET_NAME, type LoggerOptions, type LoggingOptions, MODEL_ALIASES, McpClient, type McpClientOptions, McpConnectError, type McpContentBlock, McpError, McpLifecycle, type McpServerCapabilities, type McpServerHandle, type McpServerSpec, type McpToolAdapterOptions, McpToolCallError, type McpToolDescriptor, type McpToolResult, McpUntrustedCommandError, 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 ObserveSkillActivatedContext, type Observers, OpenAIChatProvider, type OpenAICompatibleConfig, OpenAICompatibleProvider, type OpenRouterConfig, OpenRouterProvider, type OpenRouterRouting, type OutputLimitConfig, type ParallelGadgetHintOptions, type ParsedGadgetCall, type ParsedSkill, type PrefixConfig, 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, Skill, type SkillActivation, type SkillActivationControllerContext, type SkillActivationOptions, type SkillInstructionInterceptorContext, type SkillMetadata, SkillRegistry, type SkillResource, type SkillSource, SlidingWindowStrategy, type SpeechGenerationOptions, type SpeechGenerationResult, type SpeechModelSpec, type StdioMcpServerSpec, 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 TreeConfig, type GadgetSkippedEvent$1 as TreeGadgetSkippedEvent, type TriggeredLimitInfo, type ValidationIssue, type ValidationResult, type VisionAnalyzeOptions, type VisionAnalyzeResult, assertCommandAllowed, audioFromBase64, audioFromBuffer, collectEvents, collectText, complete, createAnthropicProviderFromEnv, createFileLoggingState, createGadget, createGadgetOutputViewer, createGeminiProviderFromEnv, createHints, createHuggingFaceProviderFromEnv, createLoadSkillGadget, createLogger, createMcpServer, createMediaOutput, createOpenAIProviderFromEnv, createOpenRouterProviderFromEnv, createSubagent, defaultLogger, detectAudioMimeType, detectImageMimeType, discoverProviderAdapters, discoverSkills, extractMessageText, extractRetryAfterMs, filterByDepth, filterByParent, filterRootEvents, format, formatBytes, formatCallNumber, formatDate, formatDuration, formatLLMError, formatLlmRequest, gadgetError, gadgetResultToMcpContent, gadgetSuccess, gadgetToMcpTool, getErrorMessage, getHostExports, getModelId, getPresetGadgets, getProvider, getSubagent, groupByParent, hasHostExports, hasPreset, hasProviderPrefix, hasSubagents, humanDelay, imageFromBase64, imageFromBuffer, imageFromUrl, isAbortError, isAudioPart, isDataUrl, isGadgetEvent, isImagePart, isLLMEvent, isLikelyContextOverflow, isRetryableError, isRootEvent, isSubagentEvent, isTextPart, iterationProgressHint, jsonSchemaToZod, listPresets, listSubagents, loadSkillsFromDirectory, mcpToolToGadget, normalizeMessageContent, parallelGadgetHint, parseDataUrl, parseFrontmatter, parseManifest, parseMetadata, parseRetryAfterHeader, parseSkillContent, parseSkillFile, randomDelay, renderSkillForMcpPrompt, resetFileLoggingState, resolveConfig, resolveHintTemplate, resolveInstructions, resolveModel, resolvePromptTemplate, resolveRateLimitConfig, resolveRetryConfig, resolveRulesTemplate, resolveSubagentModel, resolveSubagentTimeout, resolveValue, resultWithAudio, resultWithFile, resultWithImage, resultWithImages, resultWithMedia, runGadgetForMcp, runWithHandlers, scanResources, schemaToJSONSchema, skillToMcpPrompt, stream, stripProviderPrefix, substituteArguments, substituteVariables, text, timing, toBase64, truncate, validateAndApplyDefaults, validateGadgetParams, validateGadgetSchema, validateMetadata, withErrorHandling, withRetry, withTimeout };
|
|
11150
|
+
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, type BeforeSkillActivationAction, 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, type CreateMcpServerOptions, DEFAULT_COMPACTION_CONFIG, DEFAULT_HINTS, DEFAULT_MCP_COMMAND_ALLOWLIST, DEFAULT_PROMPTS, DEFAULT_RATE_LIMIT_CONFIG, DEFAULT_RETRY_CONFIG, DEFAULT_SUMMARIZATION_PROMPT, EmptyCompletionError, 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 GadgetExecutorOptions, 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, type HttpMcpServerSpec, 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 JSONSchemaLike, JsonSchemaConversionError, 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, LOAD_SKILL_GADGET_NAME, type LoggerOptions, type LoggingOptions, MODEL_ALIASES, McpClient, type McpClientOptions, McpConnectError, type McpContentBlock, McpError, McpLifecycle, type McpServerCapabilities, type McpServerHandle, type McpServerSpec, type McpToolAdapterOptions, McpToolCallError, type McpToolDescriptor, type McpToolResult, McpUntrustedCommandError, 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 ObserveSkillActivatedContext, type Observers, OpenAIChatProvider, type OpenAICompatibleConfig, OpenAICompatibleProvider, type OpenRouterConfig, OpenRouterProvider, type OpenRouterRouting, type OutputLimitConfig, type ParallelGadgetHintOptions, type ParsedGadgetCall, type ParsedSkill, type PrefixConfig, 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, Skill, type SkillActivation, type SkillActivationControllerContext, type SkillActivationOptions, type SkillInstructionInterceptorContext, type SkillMetadata, SkillRegistry, type SkillResource, type SkillSource, SlidingWindowStrategy, type SpeechGenerationOptions, type SpeechGenerationResult, type SpeechModelSpec, type StdioMcpServerSpec, 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 TreeConfig, type GadgetSkippedEvent$1 as TreeGadgetSkippedEvent, type TriggeredLimitInfo, type ValidationIssue, type ValidationResult, type VisionAnalyzeOptions, type VisionAnalyzeResult, assertCommandAllowed, audioFromBase64, audioFromBuffer, collectEvents, collectText, complete, createAnthropicProviderFromEnv, createFileLoggingState, createGadget, createGadgetOutputViewer, createGeminiProviderFromEnv, createHints, createHuggingFaceProviderFromEnv, createLoadSkillGadget, createLogger, createMcpServer, createMediaOutput, createOpenAIProviderFromEnv, createOpenRouterProviderFromEnv, createSubagent, defaultLogger, detectAudioMimeType, detectImageMimeType, discoverProviderAdapters, discoverSkills, extractMessageText, extractRetryAfterMs, filterByDepth, filterByParent, filterRootEvents, format, formatBytes, formatCallNumber, formatDate, formatDuration, formatLLMError, formatLlmRequest, gadgetError, gadgetResultToMcpContent, gadgetSuccess, gadgetToMcpTool, getErrorMessage, getHostExports, getModelId, getPresetGadgets, getProvider, getSubagent, groupByParent, hasHostExports, hasPreset, hasProviderPrefix, hasSubagents, humanDelay, imageFromBase64, imageFromBuffer, imageFromUrl, isAbortError, isAudioPart, isDataUrl, isGadgetEvent, isImagePart, isLLMEvent, isLikelyContextOverflow, isRetryableError, isRootEvent, isSubagentEvent, isTextPart, iterationProgressHint, jsonSchemaToZod, listPresets, listSubagents, loadSkillsFromDirectory, mcpToolToGadget, normalizeMessageContent, parallelGadgetHint, parseDataUrl, parseFrontmatter, parseManifest, parseMetadata, parseRetryAfterHeader, parseSkillContent, parseSkillFile, randomDelay, renderSkillForMcpPrompt, resetFileLoggingState, resolveConfig, resolveHintTemplate, resolveInstructions, resolveModel, resolvePromptTemplate, resolveRateLimitConfig, resolveRetryConfig, resolveRulesTemplate, resolveSubagentModel, resolveSubagentTimeout, resolveValue, resultWithAudio, resultWithFile, resultWithImage, resultWithImages, resultWithMedia, runGadgetForMcp, runWithHandlers, scanResources, schemaToJSONSchema, skillToMcpPrompt, stream, stripProviderPrefix, substituteArguments, substituteVariables, text, timing, toBase64, truncate, validateAndApplyDefaults, validateGadgetParams, validateGadgetSchema, validateMetadata, withErrorHandling, withRetry, withTimeout };
|
package/dist/index.js
CHANGED
|
@@ -1305,7 +1305,8 @@ function resolveRetryConfig(config) {
|
|
|
1305
1305
|
onRetriesExhausted: config.onRetriesExhausted,
|
|
1306
1306
|
shouldRetry: config.shouldRetry,
|
|
1307
1307
|
respectRetryAfter: config.respectRetryAfter ?? DEFAULT_RETRY_CONFIG.respectRetryAfter,
|
|
1308
|
-
maxRetryAfterMs: config.maxRetryAfterMs ?? DEFAULT_RETRY_CONFIG.maxRetryAfterMs
|
|
1308
|
+
maxRetryAfterMs: config.maxRetryAfterMs ?? DEFAULT_RETRY_CONFIG.maxRetryAfterMs,
|
|
1309
|
+
retryOnEmpty: config.retryOnEmpty ?? DEFAULT_RETRY_CONFIG.retryOnEmpty
|
|
1309
1310
|
};
|
|
1310
1311
|
}
|
|
1311
1312
|
function getErrorStatusCode(error) {
|
|
@@ -1557,8 +1558,9 @@ var init_retry = __esm({
|
|
|
1557
1558
|
factor: 2,
|
|
1558
1559
|
randomize: true,
|
|
1559
1560
|
respectRetryAfter: true,
|
|
1560
|
-
maxRetryAfterMs: 12e4
|
|
1561
|
+
maxRetryAfterMs: 12e4,
|
|
1561
1562
|
// 2 minutes cap
|
|
1563
|
+
retryOnEmpty: true
|
|
1562
1564
|
};
|
|
1563
1565
|
}
|
|
1564
1566
|
});
|
|
@@ -3773,11 +3775,51 @@ var init_output_limit_manager = __esm({
|
|
|
3773
3775
|
}
|
|
3774
3776
|
});
|
|
3775
3777
|
|
|
3778
|
+
// src/core/errors.ts
|
|
3779
|
+
function isAbortError(error) {
|
|
3780
|
+
if (!(error instanceof Error)) return false;
|
|
3781
|
+
if (error.name === "AbortError") return true;
|
|
3782
|
+
if (error.name === "APIConnectionAbortedError") return true;
|
|
3783
|
+
if (error.name === "APIUserAbortError") return true;
|
|
3784
|
+
const message = error.message.toLowerCase();
|
|
3785
|
+
if (message.includes("abort")) return true;
|
|
3786
|
+
if (message.includes("cancelled")) return true;
|
|
3787
|
+
if (message.includes("canceled")) return true;
|
|
3788
|
+
return false;
|
|
3789
|
+
}
|
|
3790
|
+
var EmptyCompletionError;
|
|
3791
|
+
var init_errors2 = __esm({
|
|
3792
|
+
"src/core/errors.ts"() {
|
|
3793
|
+
"use strict";
|
|
3794
|
+
EmptyCompletionError = class extends Error {
|
|
3795
|
+
/** Agent iteration on which the empty completion was observed. */
|
|
3796
|
+
iteration;
|
|
3797
|
+
/** Finish reason reported alongside the empty body (often null). */
|
|
3798
|
+
finishReason;
|
|
3799
|
+
constructor(params) {
|
|
3800
|
+
super(
|
|
3801
|
+
`LLM returned an empty completion (no text, tool calls, or reasoning) on iteration ${params.iteration}`
|
|
3802
|
+
);
|
|
3803
|
+
this.name = "EmptyCompletionError";
|
|
3804
|
+
this.iteration = params.iteration;
|
|
3805
|
+
this.finishReason = params.finishReason;
|
|
3806
|
+
}
|
|
3807
|
+
};
|
|
3808
|
+
}
|
|
3809
|
+
});
|
|
3810
|
+
|
|
3776
3811
|
// src/agent/retry-orchestrator.ts
|
|
3812
|
+
function isEmptyCompletion(meta) {
|
|
3813
|
+
if (meta.didExecuteGadgets) return false;
|
|
3814
|
+
if (meta.rawResponse?.trim() || meta.finalMessage?.trim()) return false;
|
|
3815
|
+
if (meta.thinkingContent?.trim()) return false;
|
|
3816
|
+
return true;
|
|
3817
|
+
}
|
|
3777
3818
|
var RetryOrchestrator;
|
|
3778
3819
|
var init_retry_orchestrator = __esm({
|
|
3779
3820
|
"src/agent/retry-orchestrator.ts"() {
|
|
3780
3821
|
"use strict";
|
|
3822
|
+
init_errors2();
|
|
3781
3823
|
init_retry();
|
|
3782
3824
|
init_safe_observe();
|
|
3783
3825
|
init_tree_hook_bridge();
|
|
@@ -3843,6 +3885,7 @@ var init_retry_orchestrator = __esm({
|
|
|
3843
3885
|
let gadgetCallCount = 0;
|
|
3844
3886
|
const textOutputs = [];
|
|
3845
3887
|
const gadgetResults = [];
|
|
3888
|
+
let emptyFailure = null;
|
|
3846
3889
|
while (streamAttempt < maxStreamAttempts) {
|
|
3847
3890
|
streamAttempt++;
|
|
3848
3891
|
try {
|
|
@@ -3851,6 +3894,7 @@ var init_retry_orchestrator = __esm({
|
|
|
3851
3894
|
for await (const event of processor.process(stream2)) {
|
|
3852
3895
|
if (event.type === "stream_complete") {
|
|
3853
3896
|
streamMetadata = event;
|
|
3897
|
+
continue;
|
|
3854
3898
|
}
|
|
3855
3899
|
if (event.type === "llm_response_end") {
|
|
3856
3900
|
this.tree.endLLMResponse(llmNodeId, {
|
|
@@ -3872,43 +3916,44 @@ var init_retry_orchestrator = __esm({
|
|
|
3872
3916
|
for (const id of processor.getFailedInvocationIds()) {
|
|
3873
3917
|
this.failedInvocationIds.add(id);
|
|
3874
3918
|
}
|
|
3919
|
+
if (this.retryConfig.enabled && this.retryConfig.retryOnEmpty && streamMetadata !== null && !streamMetadata.finishReason && isEmptyCompletion(streamMetadata)) {
|
|
3920
|
+
const emptyError = new EmptyCompletionError({
|
|
3921
|
+
iteration,
|
|
3922
|
+
finishReason: streamMetadata.finishReason
|
|
3923
|
+
});
|
|
3924
|
+
if (streamAttempt < maxStreamAttempts) {
|
|
3925
|
+
await this.backoffBeforeRetry(
|
|
3926
|
+
emptyError,
|
|
3927
|
+
streamAttempt,
|
|
3928
|
+
maxStreamAttempts,
|
|
3929
|
+
iteration,
|
|
3930
|
+
llmNodeId
|
|
3931
|
+
);
|
|
3932
|
+
streamMetadata = null;
|
|
3933
|
+
gadgetCallCount = 0;
|
|
3934
|
+
textOutputs.length = 0;
|
|
3935
|
+
gadgetResults.length = 0;
|
|
3936
|
+
continue;
|
|
3937
|
+
}
|
|
3938
|
+
emptyFailure = emptyError;
|
|
3939
|
+
break;
|
|
3940
|
+
}
|
|
3941
|
+
if (streamMetadata !== null) {
|
|
3942
|
+
yield streamMetadata;
|
|
3943
|
+
}
|
|
3875
3944
|
break;
|
|
3876
3945
|
} catch (streamError) {
|
|
3877
3946
|
const error = streamError;
|
|
3878
3947
|
const canRetry = this.retryConfig.enabled && streamAttempt < maxStreamAttempts;
|
|
3879
3948
|
const shouldRetryError = this.retryConfig.shouldRetry ? this.retryConfig.shouldRetry(error) : isRetryableError(error);
|
|
3880
3949
|
if (canRetry && shouldRetryError) {
|
|
3881
|
-
|
|
3882
|
-
|
|
3883
|
-
|
|
3884
|
-
|
|
3885
|
-
|
|
3886
|
-
|
|
3887
|
-
`Stream iteration failed (attempt ${streamAttempt}/${maxStreamAttempts}), retrying...`,
|
|
3888
|
-
{
|
|
3889
|
-
error: error.message,
|
|
3890
|
-
retriesLeft: maxStreamAttempts - streamAttempt,
|
|
3891
|
-
delayMs: Math.round(finalDelay),
|
|
3892
|
-
retryAfterMs
|
|
3893
|
-
}
|
|
3950
|
+
await this.backoffBeforeRetry(
|
|
3951
|
+
error,
|
|
3952
|
+
streamAttempt,
|
|
3953
|
+
maxStreamAttempts,
|
|
3954
|
+
iteration,
|
|
3955
|
+
llmNodeId
|
|
3894
3956
|
);
|
|
3895
|
-
this.retryConfig.onRetry?.(error, streamAttempt);
|
|
3896
|
-
await safeObserve(async () => {
|
|
3897
|
-
if (this.hooks.observers?.onRetryAttempt) {
|
|
3898
|
-
const subagentContext = getSubagentContextForNode(this.tree, llmNodeId);
|
|
3899
|
-
const hookContext = {
|
|
3900
|
-
iteration,
|
|
3901
|
-
attemptNumber: streamAttempt,
|
|
3902
|
-
retriesLeft: maxStreamAttempts - streamAttempt,
|
|
3903
|
-
error,
|
|
3904
|
-
retryAfterMs: retryAfterMs ?? void 0,
|
|
3905
|
-
logger: this.logger,
|
|
3906
|
-
subagentContext
|
|
3907
|
-
};
|
|
3908
|
-
await this.hooks.observers.onRetryAttempt(hookContext);
|
|
3909
|
-
}
|
|
3910
|
-
}, this.logger);
|
|
3911
|
-
await this.sleep(finalDelay);
|
|
3912
3957
|
streamMetadata = null;
|
|
3913
3958
|
gadgetCallCount = 0;
|
|
3914
3959
|
textOutputs.length = 0;
|
|
@@ -3925,8 +3970,55 @@ var init_retry_orchestrator = __esm({
|
|
|
3925
3970
|
throw error;
|
|
3926
3971
|
}
|
|
3927
3972
|
}
|
|
3973
|
+
if (emptyFailure !== null) {
|
|
3974
|
+
this.logger.error(`LLM returned empty completions on all ${streamAttempt} attempts`, {
|
|
3975
|
+
iteration
|
|
3976
|
+
});
|
|
3977
|
+
this.retryConfig.onRetriesExhausted?.(emptyFailure, streamAttempt);
|
|
3978
|
+
throw emptyFailure;
|
|
3979
|
+
}
|
|
3928
3980
|
return streamMetadata !== null ? { streamMetadata, textOutputs, gadgetResults, gadgetCallCount } : null;
|
|
3929
3981
|
}
|
|
3982
|
+
/**
|
|
3983
|
+
* Apply the configured backoff before a retry attempt: compute the delay
|
|
3984
|
+
* (Retry-After hint or exponential backoff, with optional jitter), emit the
|
|
3985
|
+
* retry log, fire the `onRetry` callback and `onRetryAttempt` observer, then
|
|
3986
|
+
* sleep. Shared by the error-retry and empty-completion-retry paths so both
|
|
3987
|
+
* honour identical backoff and observer semantics.
|
|
3988
|
+
*/
|
|
3989
|
+
async backoffBeforeRetry(error, streamAttempt, maxStreamAttempts, iteration, llmNodeId) {
|
|
3990
|
+
const retryAfterMs = this.retryConfig.respectRetryAfter ? extractRetryAfterMs(error) : null;
|
|
3991
|
+
const baseDelay = this.retryConfig.minTimeout * this.retryConfig.factor ** (streamAttempt - 1);
|
|
3992
|
+
const cappedBaseDelay = Math.min(baseDelay, this.retryConfig.maxTimeout);
|
|
3993
|
+
const delay = retryAfterMs !== null ? Math.min(retryAfterMs, this.retryConfig.maxRetryAfterMs) : cappedBaseDelay;
|
|
3994
|
+
const finalDelay = this.retryConfig.randomize ? delay * (0.5 + Math.random()) : delay;
|
|
3995
|
+
this.logger.warn(
|
|
3996
|
+
`Stream iteration failed (attempt ${streamAttempt}/${maxStreamAttempts}), retrying...`,
|
|
3997
|
+
{
|
|
3998
|
+
error: error.message,
|
|
3999
|
+
retriesLeft: maxStreamAttempts - streamAttempt,
|
|
4000
|
+
delayMs: Math.round(finalDelay),
|
|
4001
|
+
retryAfterMs
|
|
4002
|
+
}
|
|
4003
|
+
);
|
|
4004
|
+
this.retryConfig.onRetry?.(error, streamAttempt);
|
|
4005
|
+
await safeObserve(async () => {
|
|
4006
|
+
if (this.hooks.observers?.onRetryAttempt) {
|
|
4007
|
+
const subagentContext = getSubagentContextForNode(this.tree, llmNodeId);
|
|
4008
|
+
const hookContext = {
|
|
4009
|
+
iteration,
|
|
4010
|
+
attemptNumber: streamAttempt,
|
|
4011
|
+
retriesLeft: maxStreamAttempts - streamAttempt,
|
|
4012
|
+
error,
|
|
4013
|
+
retryAfterMs: retryAfterMs ?? void 0,
|
|
4014
|
+
logger: this.logger,
|
|
4015
|
+
subagentContext
|
|
4016
|
+
};
|
|
4017
|
+
await this.hooks.observers.onRetryAttempt(hookContext);
|
|
4018
|
+
}
|
|
4019
|
+
}, this.logger);
|
|
4020
|
+
await this.sleep(finalDelay);
|
|
4021
|
+
}
|
|
3930
4022
|
};
|
|
3931
4023
|
}
|
|
3932
4024
|
});
|
|
@@ -4133,15 +4225,30 @@ function createLoadSkillGadget(registry) {
|
|
|
4133
4225
|
const summaries = registry.getMetadataSummaries();
|
|
4134
4226
|
const skillNames = registry.getModelInvocable().map((s) => s.name);
|
|
4135
4227
|
const description = [
|
|
4136
|
-
"Load one or more skill bodies into context. Pass
|
|
4137
|
-
|
|
4138
|
-
"
|
|
4139
|
-
"
|
|
4140
|
-
"
|
|
4228
|
+
"Load one or more skill bodies into context. Pass `skills` as a JSON",
|
|
4229
|
+
"array of skill-name strings \u2014 NOT a string of a JSON-encoded array.",
|
|
4230
|
+
'Right: `{"skills": ["alpha"]}` or `{"skills": ["alpha", "beta"]}`.',
|
|
4231
|
+
'Wrong: `{"skills": "[\\"alpha\\"]"}` (the value is a string, not an array).',
|
|
4232
|
+
"**This gadget is an iteration barrier \u2014 no other gadgets in the same",
|
|
4233
|
+
"tool batch will execute, so load every skill you know you'll need in",
|
|
4234
|
+
"one shot.** The loaded bodies are sticky and survive context compaction.",
|
|
4141
4235
|
"",
|
|
4142
4236
|
"Available skills:",
|
|
4143
4237
|
summaries
|
|
4144
4238
|
].join("\n");
|
|
4239
|
+
const examples = [];
|
|
4240
|
+
if (skillNames.length >= 1) {
|
|
4241
|
+
examples.push({
|
|
4242
|
+
params: { skills: [skillNames[0]] },
|
|
4243
|
+
comment: "Single-skill call \u2014 `skills` is still an array of length 1."
|
|
4244
|
+
});
|
|
4245
|
+
}
|
|
4246
|
+
if (skillNames.length >= 2) {
|
|
4247
|
+
examples.push({
|
|
4248
|
+
params: { skills: [skillNames[0], skillNames[1]] },
|
|
4249
|
+
comment: "Multi-skill call \u2014 load several skills in one shot to avoid round-trips."
|
|
4250
|
+
});
|
|
4251
|
+
}
|
|
4145
4252
|
return createGadget({
|
|
4146
4253
|
name: LOAD_SKILL_GADGET_NAME,
|
|
4147
4254
|
description,
|
|
@@ -4155,6 +4262,7 @@ function createLoadSkillGadget(registry) {
|
|
|
4155
4262
|
}),
|
|
4156
4263
|
stickyResult: true,
|
|
4157
4264
|
iterationBarrier: true,
|
|
4265
|
+
examples,
|
|
4158
4266
|
execute: async ({ skills: skillNamesArg, arguments: args }) => {
|
|
4159
4267
|
const sections = [];
|
|
4160
4268
|
for (const skillName of skillNamesArg) {
|
|
@@ -11051,7 +11159,7 @@ var init_model_registry = __esm({
|
|
|
11051
11159
|
* Register a provider and collect its model specifications
|
|
11052
11160
|
*/
|
|
11053
11161
|
registerProvider(provider) {
|
|
11054
|
-
const specs = provider.getModelSpecs?.() ?? [];
|
|
11162
|
+
const specs = [...provider.getModelSpecs?.() ?? []];
|
|
11055
11163
|
if (specs.length > 0) {
|
|
11056
11164
|
this.modelSpecs.push(...specs);
|
|
11057
11165
|
this.providerMap.set(provider.providerId, specs);
|
|
@@ -11145,7 +11253,7 @@ var init_model_registry = __esm({
|
|
|
11145
11253
|
if (!providerId) {
|
|
11146
11254
|
return [...this.modelSpecs];
|
|
11147
11255
|
}
|
|
11148
|
-
return this.providerMap.get(providerId) ?? [];
|
|
11256
|
+
return [...this.providerMap.get(providerId) ?? []];
|
|
11149
11257
|
}
|
|
11150
11258
|
/**
|
|
11151
11259
|
* Get context window and output limits for a model
|
|
@@ -16263,19 +16371,7 @@ init_stream_processor();
|
|
|
16263
16371
|
// src/index.ts
|
|
16264
16372
|
init_client2();
|
|
16265
16373
|
init_constants();
|
|
16266
|
-
|
|
16267
|
-
// src/core/errors.ts
|
|
16268
|
-
function isAbortError(error) {
|
|
16269
|
-
if (!(error instanceof Error)) return false;
|
|
16270
|
-
if (error.name === "AbortError") return true;
|
|
16271
|
-
if (error.name === "APIConnectionAbortedError") return true;
|
|
16272
|
-
if (error.name === "APIUserAbortError") return true;
|
|
16273
|
-
const message = error.message.toLowerCase();
|
|
16274
|
-
if (message.includes("abort")) return true;
|
|
16275
|
-
if (message.includes("cancelled")) return true;
|
|
16276
|
-
if (message.includes("canceled")) return true;
|
|
16277
|
-
return false;
|
|
16278
|
-
}
|
|
16374
|
+
init_errors2();
|
|
16279
16375
|
|
|
16280
16376
|
// src/core/execution-events.ts
|
|
16281
16377
|
function isLLMEvent(event) {
|
|
@@ -16984,6 +17080,7 @@ export {
|
|
|
16984
17080
|
DEFAULT_RATE_LIMIT_CONFIG,
|
|
16985
17081
|
DEFAULT_RETRY_CONFIG,
|
|
16986
17082
|
DEFAULT_SUMMARIZATION_PROMPT,
|
|
17083
|
+
EmptyCompletionError,
|
|
16987
17084
|
ExecutionTree,
|
|
16988
17085
|
FALLBACK_CHARS_PER_TOKEN,
|
|
16989
17086
|
GADGET_ARG_PREFIX,
|