llmist 16.2.2 → 16.2.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +114 -48
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +42 -24
- package/dist/index.d.ts +42 -24
- package/dist/index.js +111 -46
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -1896,7 +1896,7 @@ interface Observers {
|
|
|
1896
1896
|
onRateLimitThrottle?: (context: ObserveRateLimitThrottleContext) => void | Promise<void>;
|
|
1897
1897
|
/** Called when a retry attempt is made after a failed LLM call */
|
|
1898
1898
|
onRetryAttempt?: (context: ObserveRetryAttemptContext) => void | Promise<void>;
|
|
1899
|
-
/** Called when a skill is activated (via
|
|
1899
|
+
/** Called when a skill is activated (via LoadSkill gadget or pre-activation) */
|
|
1900
1900
|
onSkillActivated?: (context: ObserveSkillActivatedContext) => void | Promise<void>;
|
|
1901
1901
|
}
|
|
1902
1902
|
/**
|
|
@@ -2924,6 +2924,18 @@ declare function resolveRetryConfig(config?: RetryConfig): ResolvedRetryConfig;
|
|
|
2924
2924
|
* @returns true if the error is retryable
|
|
2925
2925
|
*/
|
|
2926
2926
|
declare function isRetryableError(error: Error): boolean;
|
|
2927
|
+
/**
|
|
2928
|
+
* Heuristically detects whether an error is likely caused by context overflow
|
|
2929
|
+
* (request too large for the provider/model), as opposed to other 400 errors
|
|
2930
|
+
* like authentication failures or content policy violations.
|
|
2931
|
+
*
|
|
2932
|
+
* Used by the agent's main loop to decide whether forced compaction + retry
|
|
2933
|
+
* is a viable recovery strategy.
|
|
2934
|
+
*
|
|
2935
|
+
* @param error - The error to classify
|
|
2936
|
+
* @returns true if the error is likely a context overflow
|
|
2937
|
+
*/
|
|
2938
|
+
declare function isLikelyContextOverflow(error: Error): boolean;
|
|
2927
2939
|
/**
|
|
2928
2940
|
* Context for enhanced error formatting.
|
|
2929
2941
|
*/
|
|
@@ -6303,6 +6315,12 @@ declare class Agent {
|
|
|
6303
6315
|
* @returns compaction stream event if compaction occurred, null otherwise
|
|
6304
6316
|
*/
|
|
6305
6317
|
private checkAndPerformCompaction;
|
|
6318
|
+
/**
|
|
6319
|
+
* Log compaction, notify observers, and return a StreamEvent.
|
|
6320
|
+
* Shared by proactive compaction (checkAndPerformCompaction) and
|
|
6321
|
+
* reactive overflow recovery (catch block).
|
|
6322
|
+
*/
|
|
6323
|
+
private emitCompactionEvent;
|
|
6306
6324
|
/**
|
|
6307
6325
|
* Run agent with named event handlers (syntactic sugar).
|
|
6308
6326
|
*
|
|
@@ -10029,6 +10047,28 @@ declare function resolveInstructions(instructions: string, options?: {
|
|
|
10029
10047
|
enableShellPreprocessing?: boolean;
|
|
10030
10048
|
}): string;
|
|
10031
10049
|
|
|
10050
|
+
/**
|
|
10051
|
+
* LoadSkill meta-gadget — bridges the skill system into the gadget execution pipeline.
|
|
10052
|
+
*
|
|
10053
|
+
* When skills are registered with an agent, this gadget is auto-created and added
|
|
10054
|
+
* to the gadget registry. The LLM can invoke it like any other gadget, and the
|
|
10055
|
+
* skill's instructions are returned as the gadget result.
|
|
10056
|
+
*
|
|
10057
|
+
* This approach requires zero changes to the stream processor or agent loop.
|
|
10058
|
+
*
|
|
10059
|
+
* @module skills/load-skill-gadget
|
|
10060
|
+
*/
|
|
10061
|
+
|
|
10062
|
+
/** Name for the auto-generated LoadSkill gadget. */
|
|
10063
|
+
declare const LOAD_SKILL_GADGET_NAME = "LoadSkill";
|
|
10064
|
+
/**
|
|
10065
|
+
* Create the LoadSkill meta-gadget from a skill registry.
|
|
10066
|
+
*
|
|
10067
|
+
* The gadget description includes a summary of all available skills,
|
|
10068
|
+
* so the LLM knows what skills exist and when to load them.
|
|
10069
|
+
*/
|
|
10070
|
+
declare function createLoadSkillGadget(registry: SkillRegistry): AbstractGadget;
|
|
10071
|
+
|
|
10032
10072
|
/**
|
|
10033
10073
|
* Filesystem-based skill discovery and loading.
|
|
10034
10074
|
*
|
|
@@ -10115,28 +10155,6 @@ declare function parseSkillContent(content: string, sourcePath: string, source:
|
|
|
10115
10155
|
*/
|
|
10116
10156
|
declare function validateMetadata(metadata: SkillMetadata): string[];
|
|
10117
10157
|
|
|
10118
|
-
/**
|
|
10119
|
-
* UseSkill meta-gadget — bridges the skill system into the gadget execution pipeline.
|
|
10120
|
-
*
|
|
10121
|
-
* When skills are registered with an agent, this gadget is auto-created and added
|
|
10122
|
-
* to the gadget registry. The LLM can invoke it like any other gadget, and the
|
|
10123
|
-
* skill's instructions are returned as the gadget result.
|
|
10124
|
-
*
|
|
10125
|
-
* This approach requires zero changes to the stream processor or agent loop.
|
|
10126
|
-
*
|
|
10127
|
-
* @module skills/use-skill-gadget
|
|
10128
|
-
*/
|
|
10129
|
-
|
|
10130
|
-
/** Name for the auto-generated UseSkill gadget. */
|
|
10131
|
-
declare const USE_SKILL_GADGET_NAME = "UseSkill";
|
|
10132
|
-
/**
|
|
10133
|
-
* Create the UseSkill meta-gadget from a skill registry.
|
|
10134
|
-
*
|
|
10135
|
-
* The gadget description includes a summary of all available skills,
|
|
10136
|
-
* so the LLM knows what skills exist and when to use them.
|
|
10137
|
-
*/
|
|
10138
|
-
declare function createUseSkillGadget(registry: SkillRegistry): AbstractGadget;
|
|
10139
|
-
|
|
10140
10158
|
/**
|
|
10141
10159
|
* Config resolution utility for subagent gadgets.
|
|
10142
10160
|
*
|
|
@@ -10566,4 +10584,4 @@ declare const timing: {
|
|
|
10566
10584
|
*/
|
|
10567
10585
|
declare function getHostExports(ctx: ExecutionContext): HostExports;
|
|
10568
10586
|
|
|
10569
|
-
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, 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 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, 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 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 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,
|
|
10587
|
+
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, 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 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, 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, LOAD_SKILL_GADGET_NAME, 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 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 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, audioFromBase64, audioFromBuffer, collectEvents, collectText, complete, createAnthropicProviderFromEnv, createFileLoggingState, createGadget, createGadgetOutputViewer, createGeminiProviderFromEnv, createHints, createHuggingFaceProviderFromEnv, createLoadSkillGadget, createLogger, createMediaOutput, createOpenAIProviderFromEnv, createOpenRouterProviderFromEnv, createSubagent, defaultLogger, detectAudioMimeType, detectImageMimeType, discoverProviderAdapters, discoverSkills, 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, isLikelyContextOverflow, isRetryableError, isRootEvent, isSubagentEvent, isTextPart, iterationProgressHint, listPresets, listSubagents, loadSkillsFromDirectory, normalizeMessageContent, parallelGadgetHint, parseDataUrl, parseFrontmatter, parseManifest, parseMetadata, parseRetryAfterHeader, parseSkillContent, parseSkillFile, randomDelay, resetFileLoggingState, resolveConfig, resolveHintTemplate, resolveInstructions, resolveModel, resolvePromptTemplate, resolveRateLimitConfig, resolveRetryConfig, resolveRulesTemplate, resolveSubagentModel, resolveSubagentTimeout, resolveValue, resultWithAudio, resultWithFile, resultWithImage, resultWithImages, resultWithMedia, runWithHandlers, scanResources, schemaToJSONSchema, stream, stripProviderPrefix, substituteArguments, substituteVariables, text, timing, toBase64, truncate, validateAndApplyDefaults, validateGadgetParams, validateGadgetSchema, validateMetadata, withErrorHandling, withRetry, withTimeout };
|
package/dist/index.d.ts
CHANGED
|
@@ -1896,7 +1896,7 @@ interface Observers {
|
|
|
1896
1896
|
onRateLimitThrottle?: (context: ObserveRateLimitThrottleContext) => void | Promise<void>;
|
|
1897
1897
|
/** Called when a retry attempt is made after a failed LLM call */
|
|
1898
1898
|
onRetryAttempt?: (context: ObserveRetryAttemptContext) => void | Promise<void>;
|
|
1899
|
-
/** Called when a skill is activated (via
|
|
1899
|
+
/** Called when a skill is activated (via LoadSkill gadget or pre-activation) */
|
|
1900
1900
|
onSkillActivated?: (context: ObserveSkillActivatedContext) => void | Promise<void>;
|
|
1901
1901
|
}
|
|
1902
1902
|
/**
|
|
@@ -2924,6 +2924,18 @@ declare function resolveRetryConfig(config?: RetryConfig): ResolvedRetryConfig;
|
|
|
2924
2924
|
* @returns true if the error is retryable
|
|
2925
2925
|
*/
|
|
2926
2926
|
declare function isRetryableError(error: Error): boolean;
|
|
2927
|
+
/**
|
|
2928
|
+
* Heuristically detects whether an error is likely caused by context overflow
|
|
2929
|
+
* (request too large for the provider/model), as opposed to other 400 errors
|
|
2930
|
+
* like authentication failures or content policy violations.
|
|
2931
|
+
*
|
|
2932
|
+
* Used by the agent's main loop to decide whether forced compaction + retry
|
|
2933
|
+
* is a viable recovery strategy.
|
|
2934
|
+
*
|
|
2935
|
+
* @param error - The error to classify
|
|
2936
|
+
* @returns true if the error is likely a context overflow
|
|
2937
|
+
*/
|
|
2938
|
+
declare function isLikelyContextOverflow(error: Error): boolean;
|
|
2927
2939
|
/**
|
|
2928
2940
|
* Context for enhanced error formatting.
|
|
2929
2941
|
*/
|
|
@@ -6303,6 +6315,12 @@ declare class Agent {
|
|
|
6303
6315
|
* @returns compaction stream event if compaction occurred, null otherwise
|
|
6304
6316
|
*/
|
|
6305
6317
|
private checkAndPerformCompaction;
|
|
6318
|
+
/**
|
|
6319
|
+
* Log compaction, notify observers, and return a StreamEvent.
|
|
6320
|
+
* Shared by proactive compaction (checkAndPerformCompaction) and
|
|
6321
|
+
* reactive overflow recovery (catch block).
|
|
6322
|
+
*/
|
|
6323
|
+
private emitCompactionEvent;
|
|
6306
6324
|
/**
|
|
6307
6325
|
* Run agent with named event handlers (syntactic sugar).
|
|
6308
6326
|
*
|
|
@@ -10029,6 +10047,28 @@ declare function resolveInstructions(instructions: string, options?: {
|
|
|
10029
10047
|
enableShellPreprocessing?: boolean;
|
|
10030
10048
|
}): string;
|
|
10031
10049
|
|
|
10050
|
+
/**
|
|
10051
|
+
* LoadSkill meta-gadget — bridges the skill system into the gadget execution pipeline.
|
|
10052
|
+
*
|
|
10053
|
+
* When skills are registered with an agent, this gadget is auto-created and added
|
|
10054
|
+
* to the gadget registry. The LLM can invoke it like any other gadget, and the
|
|
10055
|
+
* skill's instructions are returned as the gadget result.
|
|
10056
|
+
*
|
|
10057
|
+
* This approach requires zero changes to the stream processor or agent loop.
|
|
10058
|
+
*
|
|
10059
|
+
* @module skills/load-skill-gadget
|
|
10060
|
+
*/
|
|
10061
|
+
|
|
10062
|
+
/** Name for the auto-generated LoadSkill gadget. */
|
|
10063
|
+
declare const LOAD_SKILL_GADGET_NAME = "LoadSkill";
|
|
10064
|
+
/**
|
|
10065
|
+
* Create the LoadSkill meta-gadget from a skill registry.
|
|
10066
|
+
*
|
|
10067
|
+
* The gadget description includes a summary of all available skills,
|
|
10068
|
+
* so the LLM knows what skills exist and when to load them.
|
|
10069
|
+
*/
|
|
10070
|
+
declare function createLoadSkillGadget(registry: SkillRegistry): AbstractGadget;
|
|
10071
|
+
|
|
10032
10072
|
/**
|
|
10033
10073
|
* Filesystem-based skill discovery and loading.
|
|
10034
10074
|
*
|
|
@@ -10115,28 +10155,6 @@ declare function parseSkillContent(content: string, sourcePath: string, source:
|
|
|
10115
10155
|
*/
|
|
10116
10156
|
declare function validateMetadata(metadata: SkillMetadata): string[];
|
|
10117
10157
|
|
|
10118
|
-
/**
|
|
10119
|
-
* UseSkill meta-gadget — bridges the skill system into the gadget execution pipeline.
|
|
10120
|
-
*
|
|
10121
|
-
* When skills are registered with an agent, this gadget is auto-created and added
|
|
10122
|
-
* to the gadget registry. The LLM can invoke it like any other gadget, and the
|
|
10123
|
-
* skill's instructions are returned as the gadget result.
|
|
10124
|
-
*
|
|
10125
|
-
* This approach requires zero changes to the stream processor or agent loop.
|
|
10126
|
-
*
|
|
10127
|
-
* @module skills/use-skill-gadget
|
|
10128
|
-
*/
|
|
10129
|
-
|
|
10130
|
-
/** Name for the auto-generated UseSkill gadget. */
|
|
10131
|
-
declare const USE_SKILL_GADGET_NAME = "UseSkill";
|
|
10132
|
-
/**
|
|
10133
|
-
* Create the UseSkill meta-gadget from a skill registry.
|
|
10134
|
-
*
|
|
10135
|
-
* The gadget description includes a summary of all available skills,
|
|
10136
|
-
* so the LLM knows what skills exist and when to use them.
|
|
10137
|
-
*/
|
|
10138
|
-
declare function createUseSkillGadget(registry: SkillRegistry): AbstractGadget;
|
|
10139
|
-
|
|
10140
10158
|
/**
|
|
10141
10159
|
* Config resolution utility for subagent gadgets.
|
|
10142
10160
|
*
|
|
@@ -10566,4 +10584,4 @@ declare const timing: {
|
|
|
10566
10584
|
*/
|
|
10567
10585
|
declare function getHostExports(ctx: ExecutionContext): HostExports;
|
|
10568
10586
|
|
|
10569
|
-
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, 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 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, 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 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 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,
|
|
10587
|
+
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, 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 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, 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, LOAD_SKILL_GADGET_NAME, 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 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 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, audioFromBase64, audioFromBuffer, collectEvents, collectText, complete, createAnthropicProviderFromEnv, createFileLoggingState, createGadget, createGadgetOutputViewer, createGeminiProviderFromEnv, createHints, createHuggingFaceProviderFromEnv, createLoadSkillGadget, createLogger, createMediaOutput, createOpenAIProviderFromEnv, createOpenRouterProviderFromEnv, createSubagent, defaultLogger, detectAudioMimeType, detectImageMimeType, discoverProviderAdapters, discoverSkills, 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, isLikelyContextOverflow, isRetryableError, isRootEvent, isSubagentEvent, isTextPart, iterationProgressHint, listPresets, listSubagents, loadSkillsFromDirectory, normalizeMessageContent, parallelGadgetHint, parseDataUrl, parseFrontmatter, parseManifest, parseMetadata, parseRetryAfterHeader, parseSkillContent, parseSkillFile, randomDelay, resetFileLoggingState, resolveConfig, resolveHintTemplate, resolveInstructions, resolveModel, resolvePromptTemplate, resolveRateLimitConfig, resolveRetryConfig, resolveRulesTemplate, resolveSubagentModel, resolveSubagentTimeout, resolveValue, resultWithAudio, resultWithFile, resultWithImage, resultWithImages, resultWithMedia, runWithHandlers, scanResources, schemaToJSONSchema, stream, stripProviderPrefix, substituteArguments, substituteVariables, text, timing, toBase64, truncate, validateAndApplyDefaults, validateGadgetParams, validateGadgetSchema, validateMetadata, withErrorHandling, withRetry, withTimeout };
|
package/dist/index.js
CHANGED
|
@@ -1977,6 +1977,21 @@ function isRetryableError(error) {
|
|
|
1977
1977
|
}
|
|
1978
1978
|
return false;
|
|
1979
1979
|
}
|
|
1980
|
+
function isLikelyContextOverflow(error) {
|
|
1981
|
+
const message = error.message.toLowerCase();
|
|
1982
|
+
const statusCode = getErrorStatusCode(error);
|
|
1983
|
+
if (message.includes("context length") || message.includes("token limit") || message.includes("payload too large") || message.includes("request too large") || message.includes("request entity too large") || message.includes("maximum context") || message.includes("content size exceeded") || message.includes("content too large")) {
|
|
1984
|
+
return true;
|
|
1985
|
+
}
|
|
1986
|
+
const is400 = statusCode === 400 || statusCode === void 0 && message.includes("400");
|
|
1987
|
+
if (!is400) {
|
|
1988
|
+
return false;
|
|
1989
|
+
}
|
|
1990
|
+
if (message.includes("authentication") || message.includes("unauthorized") || message.includes("invalid api key") || message.includes("invalid key") || message.includes("invalid model") || message.includes("invalid parameter") || message.includes("content policy") || message.includes("safety") || message.includes("permission") || message.includes("unsupported") || message.includes("not supported") || message.includes("missing required") || message.includes("malformed") || message.includes("not found")) {
|
|
1991
|
+
return false;
|
|
1992
|
+
}
|
|
1993
|
+
return true;
|
|
1994
|
+
}
|
|
1980
1995
|
function formatLLMError(error, context) {
|
|
1981
1996
|
const message = error.message;
|
|
1982
1997
|
const name = error.name;
|
|
@@ -5283,6 +5298,45 @@ var init_activation = __esm({
|
|
|
5283
5298
|
}
|
|
5284
5299
|
});
|
|
5285
5300
|
|
|
5301
|
+
// src/skills/load-skill-gadget.ts
|
|
5302
|
+
import { z as z4 } from "zod";
|
|
5303
|
+
function createLoadSkillGadget(registry) {
|
|
5304
|
+
const summaries = registry.getMetadataSummaries();
|
|
5305
|
+
const skillNames = registry.getModelInvocable().map((s) => s.name);
|
|
5306
|
+
const description = [
|
|
5307
|
+
"Load a skill's specialized instructions into context for a task.",
|
|
5308
|
+
"Available skills:",
|
|
5309
|
+
summaries
|
|
5310
|
+
].join("\n");
|
|
5311
|
+
return createGadget({
|
|
5312
|
+
name: LOAD_SKILL_GADGET_NAME,
|
|
5313
|
+
description,
|
|
5314
|
+
schema: z4.object({
|
|
5315
|
+
skill: z4.enum(skillNames).describe("Name of the skill to load"),
|
|
5316
|
+
arguments: z4.string().optional().describe("Arguments for the skill (e.g., a filename, issue number, or search query)")
|
|
5317
|
+
}),
|
|
5318
|
+
execute: async ({ skill: skillName, arguments: args }) => {
|
|
5319
|
+
const skill = registry.get(skillName);
|
|
5320
|
+
if (!skill) {
|
|
5321
|
+
return `Unknown skill: "${skillName}". Available skills: ${skillNames.join(", ")}`;
|
|
5322
|
+
}
|
|
5323
|
+
const activation = await skill.activate({
|
|
5324
|
+
arguments: args,
|
|
5325
|
+
cwd: process.cwd()
|
|
5326
|
+
});
|
|
5327
|
+
return activation.resolvedInstructions;
|
|
5328
|
+
}
|
|
5329
|
+
});
|
|
5330
|
+
}
|
|
5331
|
+
var LOAD_SKILL_GADGET_NAME;
|
|
5332
|
+
var init_load_skill_gadget = __esm({
|
|
5333
|
+
"src/skills/load-skill-gadget.ts"() {
|
|
5334
|
+
"use strict";
|
|
5335
|
+
init_create_gadget();
|
|
5336
|
+
LOAD_SKILL_GADGET_NAME = "LoadSkill";
|
|
5337
|
+
}
|
|
5338
|
+
});
|
|
5339
|
+
|
|
5286
5340
|
// src/skills/parser.ts
|
|
5287
5341
|
import fs from "fs";
|
|
5288
5342
|
import path from "path";
|
|
@@ -5776,45 +5830,6 @@ var init_loader = __esm({
|
|
|
5776
5830
|
}
|
|
5777
5831
|
});
|
|
5778
5832
|
|
|
5779
|
-
// src/skills/use-skill-gadget.ts
|
|
5780
|
-
import { z as z4 } from "zod";
|
|
5781
|
-
function createUseSkillGadget(registry) {
|
|
5782
|
-
const summaries = registry.getMetadataSummaries();
|
|
5783
|
-
const skillNames = registry.getModelInvocable().map((s) => s.name);
|
|
5784
|
-
const description = [
|
|
5785
|
-
"Activate a skill to get specialized instructions for a task.",
|
|
5786
|
-
"Available skills:",
|
|
5787
|
-
summaries
|
|
5788
|
-
].join("\n");
|
|
5789
|
-
return createGadget({
|
|
5790
|
-
name: USE_SKILL_GADGET_NAME,
|
|
5791
|
-
description,
|
|
5792
|
-
schema: z4.object({
|
|
5793
|
-
skill: z4.enum(skillNames).describe("Name of the skill to activate"),
|
|
5794
|
-
arguments: z4.string().optional().describe("Arguments for the skill (e.g., a filename, issue number, or search query)")
|
|
5795
|
-
}),
|
|
5796
|
-
execute: async ({ skill: skillName, arguments: args }) => {
|
|
5797
|
-
const skill = registry.get(skillName);
|
|
5798
|
-
if (!skill) {
|
|
5799
|
-
return `Unknown skill: "${skillName}". Available skills: ${skillNames.join(", ")}`;
|
|
5800
|
-
}
|
|
5801
|
-
const activation = await skill.activate({
|
|
5802
|
-
arguments: args,
|
|
5803
|
-
cwd: process.cwd()
|
|
5804
|
-
});
|
|
5805
|
-
return activation.resolvedInstructions;
|
|
5806
|
-
}
|
|
5807
|
-
});
|
|
5808
|
-
}
|
|
5809
|
-
var USE_SKILL_GADGET_NAME;
|
|
5810
|
-
var init_use_skill_gadget = __esm({
|
|
5811
|
-
"src/skills/use-skill-gadget.ts"() {
|
|
5812
|
-
"use strict";
|
|
5813
|
-
init_create_gadget();
|
|
5814
|
-
USE_SKILL_GADGET_NAME = "UseSkill";
|
|
5815
|
-
}
|
|
5816
|
-
});
|
|
5817
|
-
|
|
5818
5833
|
// src/agent/builder-utils.ts
|
|
5819
5834
|
function formatGadgetCall(gadgetName, invocationId, parameters, prefixes) {
|
|
5820
5835
|
const startPrefix = prefixes?.start ?? GADGET_START_PREFIX;
|
|
@@ -11835,7 +11850,18 @@ Original error: ${error.message}`
|
|
|
11835
11850
|
Original error: ${error.message}`
|
|
11836
11851
|
);
|
|
11837
11852
|
}
|
|
11838
|
-
if (message.includes("
|
|
11853
|
+
if (message.includes("400") || message.includes("bad request")) {
|
|
11854
|
+
const enhanced = new Error(
|
|
11855
|
+
`OpenRouter: Provider returned error (400). This may indicate the request exceeded the model's limits, or a model-specific rejection.
|
|
11856
|
+
Original error: ${error.message}`
|
|
11857
|
+
);
|
|
11858
|
+
const originalStatus = error.status;
|
|
11859
|
+
Object.assign(enhanced, {
|
|
11860
|
+
status: typeof originalStatus === "number" ? originalStatus : 400
|
|
11861
|
+
});
|
|
11862
|
+
return enhanced;
|
|
11863
|
+
}
|
|
11864
|
+
if (message.includes("401") || message.includes("unauthorized") || message.includes("invalid api key") || message.includes("invalid key") || message.includes("invalid_api_key")) {
|
|
11839
11865
|
return new Error(
|
|
11840
11866
|
`OpenRouter: Authentication failed. Check that OPENROUTER_API_KEY is set correctly.
|
|
11841
11867
|
Original error: ${error.message}`
|
|
@@ -12820,9 +12846,9 @@ var init_builder = __esm({
|
|
|
12820
12846
|
init_model_shortcuts();
|
|
12821
12847
|
init_registry();
|
|
12822
12848
|
init_activation();
|
|
12849
|
+
init_load_skill_gadget();
|
|
12823
12850
|
init_loader();
|
|
12824
12851
|
init_parser();
|
|
12825
|
-
init_use_skill_gadget();
|
|
12826
12852
|
init_agent();
|
|
12827
12853
|
init_agent_internal_key();
|
|
12828
12854
|
init_builder_utils();
|
|
@@ -13157,7 +13183,7 @@ ${resolved}`);
|
|
|
13157
13183
|
const skillRegistry = this.resolveSkillRegistry();
|
|
13158
13184
|
if (skillRegistry && skillRegistry.size > 0) {
|
|
13159
13185
|
if (skillRegistry.getModelInvocable().length > 0) {
|
|
13160
|
-
registry.registerByClass(
|
|
13186
|
+
registry.registerByClass(createLoadSkillGadget(skillRegistry));
|
|
13161
13187
|
}
|
|
13162
13188
|
const preActivatedBlock = this.resolvePreActivatedInstructions(skillRegistry);
|
|
13163
13189
|
if (preActivatedBlock) {
|
|
@@ -16216,7 +16242,7 @@ var init_stream_processor_factory = __esm({
|
|
|
16216
16242
|
});
|
|
16217
16243
|
|
|
16218
16244
|
// src/agent/agent.ts
|
|
16219
|
-
var Agent;
|
|
16245
|
+
var OVERFLOW_RECOVERY_MIN_HISTORY, Agent;
|
|
16220
16246
|
var init_agent = __esm({
|
|
16221
16247
|
"src/agent/agent.ts"() {
|
|
16222
16248
|
"use strict";
|
|
@@ -16239,6 +16265,7 @@ var init_agent = __esm({
|
|
|
16239
16265
|
init_safe_observe();
|
|
16240
16266
|
init_stream_processor_factory();
|
|
16241
16267
|
init_tree_hook_bridge();
|
|
16268
|
+
OVERFLOW_RECOVERY_MIN_HISTORY = 4;
|
|
16242
16269
|
Agent = class {
|
|
16243
16270
|
client;
|
|
16244
16271
|
model;
|
|
@@ -16616,6 +16643,7 @@ var init_agent = __esm({
|
|
|
16616
16643
|
});
|
|
16617
16644
|
let currentLLMNodeId;
|
|
16618
16645
|
let llmOptions;
|
|
16646
|
+
let hasAttemptedOverflowRecovery = false;
|
|
16619
16647
|
try {
|
|
16620
16648
|
while (currentIteration < this.maxIterations) {
|
|
16621
16649
|
if (await this.checkAbortAndNotify(currentIteration)) {
|
|
@@ -16702,6 +16730,34 @@ var init_agent = __esm({
|
|
|
16702
16730
|
}
|
|
16703
16731
|
}
|
|
16704
16732
|
} catch (error) {
|
|
16733
|
+
const historyLength = this.conversation.getHistoryMessages().length;
|
|
16734
|
+
if (this.compactionManager && !hasAttemptedOverflowRecovery && isLikelyContextOverflow(error) && historyLength >= OVERFLOW_RECOVERY_MIN_HISTORY) {
|
|
16735
|
+
hasAttemptedOverflowRecovery = true;
|
|
16736
|
+
this.logger.warn("Possible context overflow detected, attempting compaction recovery", {
|
|
16737
|
+
error: error.message,
|
|
16738
|
+
iteration: currentIteration,
|
|
16739
|
+
historyMessages: historyLength
|
|
16740
|
+
});
|
|
16741
|
+
try {
|
|
16742
|
+
const compactionEvent = await this.compactionManager.compact(
|
|
16743
|
+
this.conversation,
|
|
16744
|
+
currentIteration
|
|
16745
|
+
);
|
|
16746
|
+
if (compactionEvent) {
|
|
16747
|
+
const event = await this.emitCompactionEvent(compactionEvent, currentIteration);
|
|
16748
|
+
yield event;
|
|
16749
|
+
continue;
|
|
16750
|
+
}
|
|
16751
|
+
this.logger.warn("Compaction returned no result, cannot recover from overflow");
|
|
16752
|
+
} catch (compactionError) {
|
|
16753
|
+
this.logger.warn(
|
|
16754
|
+
"Compaction failed during overflow recovery, propagating original error",
|
|
16755
|
+
{
|
|
16756
|
+
compactionError: compactionError.message
|
|
16757
|
+
}
|
|
16758
|
+
);
|
|
16759
|
+
}
|
|
16760
|
+
}
|
|
16705
16761
|
const action = await this.llmCallLifecycle.notifyLLMError(
|
|
16706
16762
|
currentIteration,
|
|
16707
16763
|
currentLLMNodeId,
|
|
@@ -16898,6 +16954,14 @@ var init_agent = __esm({
|
|
|
16898
16954
|
iteration
|
|
16899
16955
|
);
|
|
16900
16956
|
if (!compactionEvent) return null;
|
|
16957
|
+
return this.emitCompactionEvent(compactionEvent, iteration);
|
|
16958
|
+
}
|
|
16959
|
+
/**
|
|
16960
|
+
* Log compaction, notify observers, and return a StreamEvent.
|
|
16961
|
+
* Shared by proactive compaction (checkAndPerformCompaction) and
|
|
16962
|
+
* reactive overflow recovery (catch block).
|
|
16963
|
+
*/
|
|
16964
|
+
async emitCompactionEvent(compactionEvent, iteration) {
|
|
16901
16965
|
this.logger.info("Context compacted", {
|
|
16902
16966
|
strategy: compactionEvent.strategy,
|
|
16903
16967
|
tokensBefore: compactionEvent.tokensBefore,
|
|
@@ -17523,11 +17587,11 @@ var SimpleSessionManager = class extends BaseSessionManager {
|
|
|
17523
17587
|
|
|
17524
17588
|
// src/skills/index.ts
|
|
17525
17589
|
init_activation();
|
|
17590
|
+
init_load_skill_gadget();
|
|
17526
17591
|
init_loader();
|
|
17527
17592
|
init_parser();
|
|
17528
17593
|
init_registry2();
|
|
17529
17594
|
init_skill();
|
|
17530
|
-
init_use_skill_gadget();
|
|
17531
17595
|
|
|
17532
17596
|
// src/utils/format.ts
|
|
17533
17597
|
function truncate(text3, maxLength, suffix = "...") {
|
|
@@ -17715,6 +17779,7 @@ export {
|
|
|
17715
17779
|
HybridStrategy,
|
|
17716
17780
|
LLMMessageBuilder,
|
|
17717
17781
|
LLMist,
|
|
17782
|
+
LOAD_SKILL_GADGET_NAME,
|
|
17718
17783
|
MODEL_ALIASES,
|
|
17719
17784
|
MediaStore,
|
|
17720
17785
|
ModelIdentifierParser,
|
|
@@ -17731,7 +17796,6 @@ export {
|
|
|
17731
17796
|
SummarizationStrategy,
|
|
17732
17797
|
TaskCompletionSignal,
|
|
17733
17798
|
TimeoutException,
|
|
17734
|
-
USE_SKILL_GADGET_NAME,
|
|
17735
17799
|
audioFromBase64,
|
|
17736
17800
|
audioFromBuffer,
|
|
17737
17801
|
collectEvents,
|
|
@@ -17744,12 +17808,12 @@ export {
|
|
|
17744
17808
|
createGeminiProviderFromEnv,
|
|
17745
17809
|
createHints,
|
|
17746
17810
|
createHuggingFaceProviderFromEnv,
|
|
17811
|
+
createLoadSkillGadget,
|
|
17747
17812
|
createLogger,
|
|
17748
17813
|
createMediaOutput,
|
|
17749
17814
|
createOpenAIProviderFromEnv,
|
|
17750
17815
|
createOpenRouterProviderFromEnv,
|
|
17751
17816
|
createSubagent,
|
|
17752
|
-
createUseSkillGadget,
|
|
17753
17817
|
defaultLogger,
|
|
17754
17818
|
detectAudioMimeType,
|
|
17755
17819
|
detectImageMimeType,
|
|
@@ -17790,6 +17854,7 @@ export {
|
|
|
17790
17854
|
isGadgetEvent,
|
|
17791
17855
|
isImagePart,
|
|
17792
17856
|
isLLMEvent,
|
|
17857
|
+
isLikelyContextOverflow,
|
|
17793
17858
|
isRetryableError,
|
|
17794
17859
|
isRootEvent,
|
|
17795
17860
|
isSubagentEvent,
|