llmist 6.2.0 → 7.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.cts CHANGED
@@ -1,8 +1,9 @@
1
1
  import { ZodTypeAny } from 'zod';
2
2
  export { z } from 'zod';
3
- import { s as AgentHooks, t as ModelRegistry, u as LLMist, C as CompactionConfig, I as IConversationManager, v as CompactionEvent, L as LLMMessage, w as CompactionStats, x as CompactionStrategy, R as ResolvedCompactionConfig, y as CompactionContext, z as CompactionResult, B as MessageContent, G as GadgetMediaOutput, H as HintTemplate, S as StreamEvent, T as TokenUsage, D as GadgetRegistry, E as MediaStore, F as AgentContextConfig, J as SubagentConfigMap, K as SubagentEvent, N as ExecutionTree, O as NodeId, b as LLMStreamChunk, P as ParsedGadgetCall, Q as GadgetExecutionResult, A as AbstractGadget, U as MediaKind, V as MediaMetadata, W as GadgetExecuteResultWithMedia, X as ExecutionContext, Y as ProviderAdapter, Z as ModelDescriptor, _ as ModelSpec, $ as LLMGenerationOptions, a as LLMStream, a0 as ImageModelSpec, a1 as ImageGenerationOptions, a2 as ImageGenerationResult, a3 as SpeechModelSpec, a4 as SpeechGenerationOptions, a5 as SpeechGenerationResult, a6 as HostExports } from './mock-stream-DG4wF-NH.cjs';
4
- export { aJ as AddGadgetParams, aK as AddLLMCallParams, af as AfterGadgetExecutionAction, ag as AfterGadgetExecutionControllerContext, ah as AfterLLMCallAction, ai as AfterLLMCallControllerContext, aj as AfterLLMErrorAction, aa as AgentBuilder, ak as AgentOptions, bg as AudioContentPart, bh as AudioMimeType, bi as AudioSource, aS as BaseExecutionEvent, al as BeforeGadgetExecutionAction, am as BeforeLLMCallAction, an as ChunkInterceptorContext, aL as CompleteGadgetParams, aM as CompleteLLMCallParams, bj as ContentPart, ao as Controllers, bI as CostEstimate, c6 as CostReportingLLMist, c0 as CreateGadgetConfig, aG as DEFAULT_COMPACTION_CONFIG, bU as DEFAULT_HINTS, bV as DEFAULT_PROMPTS, aH as DEFAULT_SUMMARIZATION_PROMPT, ab as EventHandlers, aU as ExecutionEvent, aV as ExecutionEventType, aN as ExecutionNode, aO as ExecutionNodeType, c5 as Gadget, aW as GadgetCallEvent, c2 as GadgetClass, aX as GadgetCompleteEvent, c4 as GadgetConfig, aY as GadgetErrorEvent, aZ as GadgetEvent, c7 as GadgetExample, c8 as GadgetExecuteResult, c9 as GadgetExecuteReturn, ap as GadgetExecutionControllerContext, aP as GadgetNode, c3 as GadgetOrClass, aq as GadgetParameterInterceptorContext, ar as GadgetResultInterceptorContext, ca as GadgetSkippedEvent, a$ as GadgetStartEvent, aQ as GadgetState, bQ as HintContext, a7 as HistoryMessage, b0 as HumanInputRequiredEvent, bk as ImageBase64Source, bl as ImageContentPart, bm as ImageMimeType, bn as ImageSource, bo as ImageUrlSource, as as Interceptors, b1 as LLMCallCompleteEvent, at as LLMCallControllerContext, b2 as LLMCallErrorEvent, aR as LLMCallNode, b3 as LLMCallStartEvent, b4 as LLMCallStreamEvent, au as LLMErrorControllerContext, b5 as LLMEvent, bG as LLMMessageBuilder, aI as LLMistOptions, av as MessageInterceptorContext, bE as MessageRole, aw as MessageTurn, d as MockBuilder, f as MockManager, l as MockMatcher, n as MockMatcherContext, o as MockOptions, M as MockProviderAdapter, p as MockRegistration, q as MockResponse, r as MockStats, bJ as ModelFeatures, bP as ModelIdentifierParser, bK as ModelLimits, bL as ModelPricing, ax as ObserveChunkContext, ay as ObserveCompactionContext, az as ObserveGadgetCompleteContext, aA as ObserveGadgetStartContext, aB as ObserveLLMCallContext, aC as ObserveLLMCompleteContext, aD as ObserveLLMErrorContext, aE as Observers, bR as PromptContext, bS as PromptTemplate, bT as PromptTemplateConfig, bO as ProviderIdentifier, cb as StoredMedia, b6 as StreamCompleteEvent, aF as SubagentContext, cc as SubagentStreamEvent, bp as TextContentPart, b7 as TextEvent, bZ as TextGenerationOptions, cd as TextOnlyAction, ce as TextOnlyContext, cf as TextOnlyCustomHandler, cg as TextOnlyGadgetConfig, ch as TextOnlyHandler, ci as TextOnlyStrategy, a8 as TrailingMessage, a9 as TrailingMessageContext, aT as TreeCompactionEvent, a_ as TreeGadgetSkippedEvent, bM as VisionAnalyzeOptions, bN as VisionAnalyzeResult, bq as audioFromBase64, br as audioFromBuffer, ac as collectEvents, ad as collectText, b_ as complete, c1 as createGadget, c as createMockAdapter, e as createMockClient, h as createMockStream, i as createTextMockStream, bs as detectAudioMimeType, bt as detectImageMimeType, bF as extractMessageText, b8 as filterByDepth, b9 as filterByParent, ba as filterRootEvents, g as getMockManager, bb as groupByParent, bu as imageFromBase64, bv as imageFromBuffer, bw as imageFromUrl, bx as isAudioPart, by as isDataUrl, bc as isGadgetEvent, bz as isImagePart, bd as isLLMEvent, be as isRootEvent, bf as isSubagentEvent, bA as isTextPart, m as mockLLM, bH as normalizeMessageContent, bB as parseDataUrl, bW as resolveHintTemplate, bX as resolvePromptTemplate, bY as resolveRulesTemplate, ae as runWithHandlers, b$ as stream, bC as text, bD as toBase64 } from './mock-stream-DG4wF-NH.cjs';
3
+ import { s as AgentHooks, t as ModelRegistry, u as LLMist, C as CompactionConfig, I as IConversationManager, v as CompactionEvent, L as LLMMessage, w as CompactionStats, x as CompactionStrategy, R as ResolvedCompactionConfig, y as CompactionContext, z as CompactionResult, B as MessageContent, G as GadgetMediaOutput, H as HintTemplate, S as StreamEvent, T as TokenUsage, D as GadgetRegistry, E as MediaStore, F as AgentContextConfig, J as SubagentConfigMap, K as SubagentEvent, N as ExecutionTree, O as NodeId, b as LLMStreamChunk, P as ParsedGadgetCall, Q as GadgetExecutionResult, A as AbstractGadget, U as MediaKind, V as MediaMetadata, W as GadgetExecuteResultWithMedia, X as ExecutionContext, Y as ProviderAdapter, Z as ModelDescriptor, _ as ModelSpec, $ as LLMGenerationOptions, a as LLMStream, a0 as ImageModelSpec, a1 as ImageGenerationOptions, a2 as ImageGenerationResult, a3 as SpeechModelSpec, a4 as SpeechGenerationOptions, a5 as SpeechGenerationResult, a6 as HostExports } from './mock-stream-r5vjy2Iq.cjs';
4
+ export { aJ as AddGadgetParams, aK as AddLLMCallParams, af as AfterGadgetExecutionAction, ag as AfterGadgetExecutionControllerContext, ah as AfterLLMCallAction, ai as AfterLLMCallControllerContext, aj as AfterLLMErrorAction, aa as AgentBuilder, ak as AgentOptions, bg as AudioContentPart, bh as AudioMimeType, bi as AudioSource, aS as BaseExecutionEvent, al as BeforeGadgetExecutionAction, am as BeforeLLMCallAction, an as ChunkInterceptorContext, aL as CompleteGadgetParams, aM as CompleteLLMCallParams, bj as ContentPart, ao as Controllers, bI as CostEstimate, c6 as CostReportingLLMist, c0 as CreateGadgetConfig, aG as DEFAULT_COMPACTION_CONFIG, bU as DEFAULT_HINTS, bV as DEFAULT_PROMPTS, aH as DEFAULT_SUMMARIZATION_PROMPT, ab as EventHandlers, aU as ExecutionEvent, aV as ExecutionEventType, aN as ExecutionNode, aO as ExecutionNodeType, c5 as Gadget, aW as GadgetCallEvent, c2 as GadgetClass, aX as GadgetCompleteEvent, c4 as GadgetConfig, aY as GadgetErrorEvent, aZ as GadgetEvent, c7 as GadgetExample, c8 as GadgetExecuteResult, c9 as GadgetExecuteReturn, ap as GadgetExecutionControllerContext, aP as GadgetNode, c3 as GadgetOrClass, aq as GadgetParameterInterceptorContext, ar as GadgetResultInterceptorContext, ca as GadgetSkippedEvent, a$ as GadgetStartEvent, aQ as GadgetState, bQ as HintContext, a7 as HistoryMessage, b0 as HumanInputRequiredEvent, bk as ImageBase64Source, bl as ImageContentPart, bm as ImageMimeType, bn as ImageSource, bo as ImageUrlSource, as as Interceptors, b1 as LLMCallCompleteEvent, at as LLMCallControllerContext, b2 as LLMCallErrorEvent, aR as LLMCallNode, b3 as LLMCallStartEvent, b4 as LLMCallStreamEvent, au as LLMErrorControllerContext, b5 as LLMEvent, bG as LLMMessageBuilder, aI as LLMistOptions, av as MessageInterceptorContext, bE as MessageRole, aw as MessageTurn, d as MockBuilder, f as MockManager, l as MockMatcher, n as MockMatcherContext, o as MockOptions, M as MockProviderAdapter, p as MockRegistration, q as MockResponse, r as MockStats, bJ as ModelFeatures, bP as ModelIdentifierParser, bK as ModelLimits, bL as ModelPricing, ax as ObserveChunkContext, ay as ObserveCompactionContext, az as ObserveGadgetCompleteContext, aA as ObserveGadgetStartContext, aB as ObserveLLMCallContext, aC as ObserveLLMCompleteContext, aD as ObserveLLMErrorContext, aE as Observers, bR as PromptContext, bS as PromptTemplate, bT as PromptTemplateConfig, bO as ProviderIdentifier, cb as StoredMedia, b6 as StreamCompleteEvent, aF as SubagentContext, cc as SubagentStreamEvent, bp as TextContentPart, b7 as TextEvent, bZ as TextGenerationOptions, cd as TextOnlyAction, ce as TextOnlyContext, cf as TextOnlyCustomHandler, cg as TextOnlyGadgetConfig, ch as TextOnlyHandler, ci as TextOnlyStrategy, a8 as TrailingMessage, a9 as TrailingMessageContext, aT as TreeCompactionEvent, a_ as TreeGadgetSkippedEvent, bM as VisionAnalyzeOptions, bN as VisionAnalyzeResult, bq as audioFromBase64, br as audioFromBuffer, ac as collectEvents, ad as collectText, b_ as complete, c1 as createGadget, c as createMockAdapter, e as createMockClient, h as createMockStream, i as createTextMockStream, bs as detectAudioMimeType, bt as detectImageMimeType, bF as extractMessageText, b8 as filterByDepth, b9 as filterByParent, ba as filterRootEvents, g as getMockManager, bb as groupByParent, bu as imageFromBase64, bv as imageFromBuffer, bw as imageFromUrl, bx as isAudioPart, by as isDataUrl, bc as isGadgetEvent, bz as isImagePart, bd as isLLMEvent, be as isRootEvent, bf as isSubagentEvent, bA as isTextPart, m as mockLLM, bH as normalizeMessageContent, bB as parseDataUrl, bW as resolveHintTemplate, bX as resolvePromptTemplate, bY as resolveRulesTemplate, ae as runWithHandlers, b$ as stream, bC as text, bD as toBase64 } from './mock-stream-r5vjy2Iq.cjs';
5
5
  import { Logger, ILogObj } from 'tslog';
6
+ export { ILogObj, Logger } from 'tslog';
6
7
  import { MessageCreateParamsStreaming, MessageStreamEvent } from '@anthropic-ai/sdk/resources/messages';
7
8
  import OpenAI from 'openai';
8
9
  import { ChatCompletionChunk } from 'openai/resources/chat/completions';
@@ -1198,6 +1199,16 @@ interface StreamProcessorOptions {
1198
1199
  parentNodeId?: NodeId | null;
1199
1200
  /** Base depth for nodes created by this processor */
1200
1201
  baseDepth?: number;
1202
+ /**
1203
+ * Set of invocation IDs that completed in previous iterations.
1204
+ * Used to resolve dependencies on gadgets from prior LLM responses.
1205
+ */
1206
+ priorCompletedInvocations?: Set<string>;
1207
+ /**
1208
+ * Set of invocation IDs that failed in previous iterations.
1209
+ * Used to skip gadgets that depend on previously-failed gadgets.
1210
+ */
1211
+ priorFailedInvocations?: Set<string>;
1201
1212
  }
1202
1213
  /**
1203
1214
  * Result of stream processing.
@@ -1262,6 +1273,10 @@ declare class StreamProcessor {
1262
1273
  private inFlightExecutions;
1263
1274
  /** Queue of completed gadget results ready to be yielded (for real-time streaming) */
1264
1275
  private completedResultsQueue;
1276
+ /** Invocation IDs completed in previous iterations (read-only reference from Agent) */
1277
+ private readonly priorCompletedInvocations;
1278
+ /** Invocation IDs that failed in previous iterations (read-only reference from Agent) */
1279
+ private readonly priorFailedInvocations;
1265
1280
  constructor(options: StreamProcessorOptions);
1266
1281
  /**
1267
1282
  * Process an LLM stream and yield events in real-time.
@@ -1282,30 +1297,17 @@ declare class StreamProcessor {
1282
1297
  * Process a text event through interceptors.
1283
1298
  */
1284
1299
  private processTextEvent;
1285
- /**
1286
- * Process a gadget call through the full lifecycle, handling dependencies.
1287
- *
1288
- * Gadgets without dependencies (or with all dependencies satisfied) execute immediately.
1289
- * Gadgets with unsatisfied dependencies are queued for later execution.
1290
- * After each execution, pending gadgets are checked to see if they can now run.
1291
- */
1292
- private processGadgetCall;
1293
1300
  /**
1294
1301
  * Process a gadget call, yielding events in real-time.
1295
1302
  *
1296
- * Key difference from processGadgetCall: yields gadget_call event IMMEDIATELY
1297
- * when parsed (before execution), enabling real-time UI feedback.
1303
+ * Yields gadget_call event IMMEDIATELY when parsed (before execution),
1304
+ * enabling real-time UI feedback.
1298
1305
  */
1299
1306
  private processGadgetCallGenerator;
1300
1307
  /**
1301
- * Execute a gadget through the full hook lifecycle.
1302
- * This is the core execution logic, extracted from processGadgetCall.
1303
- * @deprecated Use executeGadgetGenerator for real-time streaming
1304
- */
1305
- private executeGadgetWithHooks;
1306
- /**
1307
- * Execute a gadget and yield the result event.
1308
- * Generator version that yields gadget_result immediately when execution completes.
1308
+ * Execute a gadget through the full hook lifecycle and yield events.
1309
+ * Handles parameter interception, before/after controllers, observers,
1310
+ * execution, result interception, and tree tracking.
1309
1311
  */
1310
1312
  private executeGadgetGenerator;
1311
1313
  /**
@@ -1336,14 +1338,9 @@ declare class StreamProcessor {
1336
1338
  private handleFailedDependency;
1337
1339
  /**
1338
1340
  * Process pending gadgets whose dependencies are now satisfied.
1339
- * Executes ready gadgets in parallel and continues until no more can be triggered.
1340
- */
1341
- private processPendingGadgets;
1342
- /**
1343
- * Process pending gadgets, yielding events in real-time.
1344
- * Generator version that yields events as gadgets complete.
1341
+ * Yields events in real-time as gadgets complete.
1345
1342
  *
1346
- * Note: Gadgets are still executed in parallel for efficiency,
1343
+ * Gadgets are executed in parallel for efficiency,
1347
1344
  * but results are yielded as they become available.
1348
1345
  */
1349
1346
  private processPendingGadgetsGenerator;
@@ -1357,6 +1354,16 @@ declare class StreamProcessor {
1357
1354
  * All observers run concurrently and failures are tracked but don't crash.
1358
1355
  */
1359
1356
  private runObserversInParallel;
1357
+ /**
1358
+ * Get all invocation IDs that completed successfully in this iteration.
1359
+ * Used by Agent to accumulate completed IDs across iterations.
1360
+ */
1361
+ getCompletedInvocationIds(): Set<string>;
1362
+ /**
1363
+ * Get all invocation IDs that failed in this iteration.
1364
+ * Used by Agent to accumulate failed IDs across iterations.
1365
+ */
1366
+ getFailedInvocationIds(): Set<string>;
1360
1367
  }
1361
1368
 
1362
1369
  /**
@@ -1641,11 +1648,6 @@ declare class GadgetExecutor {
1641
1648
  private unifyExecuteResult;
1642
1649
  execute(call: ParsedGadgetCall): Promise<GadgetExecutionResult>;
1643
1650
  executeAll(calls: ParsedGadgetCall[]): Promise<GadgetExecutionResult[]>;
1644
- /**
1645
- * Deep equality check for objects/arrays.
1646
- * Used to detect if parameters were modified by an interceptor.
1647
- */
1648
- private deepEquals;
1649
1651
  }
1650
1652
 
1651
1653
  /**
package/dist/index.d.ts CHANGED
@@ -1,8 +1,9 @@
1
1
  import { ZodTypeAny } from 'zod';
2
2
  export { z } from 'zod';
3
- import { s as AgentHooks, t as ModelRegistry, u as LLMist, C as CompactionConfig, I as IConversationManager, v as CompactionEvent, L as LLMMessage, w as CompactionStats, x as CompactionStrategy, R as ResolvedCompactionConfig, y as CompactionContext, z as CompactionResult, B as MessageContent, G as GadgetMediaOutput, H as HintTemplate, S as StreamEvent, T as TokenUsage, D as GadgetRegistry, E as MediaStore, F as AgentContextConfig, J as SubagentConfigMap, K as SubagentEvent, N as ExecutionTree, O as NodeId, b as LLMStreamChunk, P as ParsedGadgetCall, Q as GadgetExecutionResult, A as AbstractGadget, U as MediaKind, V as MediaMetadata, W as GadgetExecuteResultWithMedia, X as ExecutionContext, Y as ProviderAdapter, Z as ModelDescriptor, _ as ModelSpec, $ as LLMGenerationOptions, a as LLMStream, a0 as ImageModelSpec, a1 as ImageGenerationOptions, a2 as ImageGenerationResult, a3 as SpeechModelSpec, a4 as SpeechGenerationOptions, a5 as SpeechGenerationResult, a6 as HostExports } from './mock-stream-DG4wF-NH.js';
4
- export { aJ as AddGadgetParams, aK as AddLLMCallParams, af as AfterGadgetExecutionAction, ag as AfterGadgetExecutionControllerContext, ah as AfterLLMCallAction, ai as AfterLLMCallControllerContext, aj as AfterLLMErrorAction, aa as AgentBuilder, ak as AgentOptions, bg as AudioContentPart, bh as AudioMimeType, bi as AudioSource, aS as BaseExecutionEvent, al as BeforeGadgetExecutionAction, am as BeforeLLMCallAction, an as ChunkInterceptorContext, aL as CompleteGadgetParams, aM as CompleteLLMCallParams, bj as ContentPart, ao as Controllers, bI as CostEstimate, c6 as CostReportingLLMist, c0 as CreateGadgetConfig, aG as DEFAULT_COMPACTION_CONFIG, bU as DEFAULT_HINTS, bV as DEFAULT_PROMPTS, aH as DEFAULT_SUMMARIZATION_PROMPT, ab as EventHandlers, aU as ExecutionEvent, aV as ExecutionEventType, aN as ExecutionNode, aO as ExecutionNodeType, c5 as Gadget, aW as GadgetCallEvent, c2 as GadgetClass, aX as GadgetCompleteEvent, c4 as GadgetConfig, aY as GadgetErrorEvent, aZ as GadgetEvent, c7 as GadgetExample, c8 as GadgetExecuteResult, c9 as GadgetExecuteReturn, ap as GadgetExecutionControllerContext, aP as GadgetNode, c3 as GadgetOrClass, aq as GadgetParameterInterceptorContext, ar as GadgetResultInterceptorContext, ca as GadgetSkippedEvent, a$ as GadgetStartEvent, aQ as GadgetState, bQ as HintContext, a7 as HistoryMessage, b0 as HumanInputRequiredEvent, bk as ImageBase64Source, bl as ImageContentPart, bm as ImageMimeType, bn as ImageSource, bo as ImageUrlSource, as as Interceptors, b1 as LLMCallCompleteEvent, at as LLMCallControllerContext, b2 as LLMCallErrorEvent, aR as LLMCallNode, b3 as LLMCallStartEvent, b4 as LLMCallStreamEvent, au as LLMErrorControllerContext, b5 as LLMEvent, bG as LLMMessageBuilder, aI as LLMistOptions, av as MessageInterceptorContext, bE as MessageRole, aw as MessageTurn, d as MockBuilder, f as MockManager, l as MockMatcher, n as MockMatcherContext, o as MockOptions, M as MockProviderAdapter, p as MockRegistration, q as MockResponse, r as MockStats, bJ as ModelFeatures, bP as ModelIdentifierParser, bK as ModelLimits, bL as ModelPricing, ax as ObserveChunkContext, ay as ObserveCompactionContext, az as ObserveGadgetCompleteContext, aA as ObserveGadgetStartContext, aB as ObserveLLMCallContext, aC as ObserveLLMCompleteContext, aD as ObserveLLMErrorContext, aE as Observers, bR as PromptContext, bS as PromptTemplate, bT as PromptTemplateConfig, bO as ProviderIdentifier, cb as StoredMedia, b6 as StreamCompleteEvent, aF as SubagentContext, cc as SubagentStreamEvent, bp as TextContentPart, b7 as TextEvent, bZ as TextGenerationOptions, cd as TextOnlyAction, ce as TextOnlyContext, cf as TextOnlyCustomHandler, cg as TextOnlyGadgetConfig, ch as TextOnlyHandler, ci as TextOnlyStrategy, a8 as TrailingMessage, a9 as TrailingMessageContext, aT as TreeCompactionEvent, a_ as TreeGadgetSkippedEvent, bM as VisionAnalyzeOptions, bN as VisionAnalyzeResult, bq as audioFromBase64, br as audioFromBuffer, ac as collectEvents, ad as collectText, b_ as complete, c1 as createGadget, c as createMockAdapter, e as createMockClient, h as createMockStream, i as createTextMockStream, bs as detectAudioMimeType, bt as detectImageMimeType, bF as extractMessageText, b8 as filterByDepth, b9 as filterByParent, ba as filterRootEvents, g as getMockManager, bb as groupByParent, bu as imageFromBase64, bv as imageFromBuffer, bw as imageFromUrl, bx as isAudioPart, by as isDataUrl, bc as isGadgetEvent, bz as isImagePart, bd as isLLMEvent, be as isRootEvent, bf as isSubagentEvent, bA as isTextPart, m as mockLLM, bH as normalizeMessageContent, bB as parseDataUrl, bW as resolveHintTemplate, bX as resolvePromptTemplate, bY as resolveRulesTemplate, ae as runWithHandlers, b$ as stream, bC as text, bD as toBase64 } from './mock-stream-DG4wF-NH.js';
3
+ import { s as AgentHooks, t as ModelRegistry, u as LLMist, C as CompactionConfig, I as IConversationManager, v as CompactionEvent, L as LLMMessage, w as CompactionStats, x as CompactionStrategy, R as ResolvedCompactionConfig, y as CompactionContext, z as CompactionResult, B as MessageContent, G as GadgetMediaOutput, H as HintTemplate, S as StreamEvent, T as TokenUsage, D as GadgetRegistry, E as MediaStore, F as AgentContextConfig, J as SubagentConfigMap, K as SubagentEvent, N as ExecutionTree, O as NodeId, b as LLMStreamChunk, P as ParsedGadgetCall, Q as GadgetExecutionResult, A as AbstractGadget, U as MediaKind, V as MediaMetadata, W as GadgetExecuteResultWithMedia, X as ExecutionContext, Y as ProviderAdapter, Z as ModelDescriptor, _ as ModelSpec, $ as LLMGenerationOptions, a as LLMStream, a0 as ImageModelSpec, a1 as ImageGenerationOptions, a2 as ImageGenerationResult, a3 as SpeechModelSpec, a4 as SpeechGenerationOptions, a5 as SpeechGenerationResult, a6 as HostExports } from './mock-stream-r5vjy2Iq.js';
4
+ export { aJ as AddGadgetParams, aK as AddLLMCallParams, af as AfterGadgetExecutionAction, ag as AfterGadgetExecutionControllerContext, ah as AfterLLMCallAction, ai as AfterLLMCallControllerContext, aj as AfterLLMErrorAction, aa as AgentBuilder, ak as AgentOptions, bg as AudioContentPart, bh as AudioMimeType, bi as AudioSource, aS as BaseExecutionEvent, al as BeforeGadgetExecutionAction, am as BeforeLLMCallAction, an as ChunkInterceptorContext, aL as CompleteGadgetParams, aM as CompleteLLMCallParams, bj as ContentPart, ao as Controllers, bI as CostEstimate, c6 as CostReportingLLMist, c0 as CreateGadgetConfig, aG as DEFAULT_COMPACTION_CONFIG, bU as DEFAULT_HINTS, bV as DEFAULT_PROMPTS, aH as DEFAULT_SUMMARIZATION_PROMPT, ab as EventHandlers, aU as ExecutionEvent, aV as ExecutionEventType, aN as ExecutionNode, aO as ExecutionNodeType, c5 as Gadget, aW as GadgetCallEvent, c2 as GadgetClass, aX as GadgetCompleteEvent, c4 as GadgetConfig, aY as GadgetErrorEvent, aZ as GadgetEvent, c7 as GadgetExample, c8 as GadgetExecuteResult, c9 as GadgetExecuteReturn, ap as GadgetExecutionControllerContext, aP as GadgetNode, c3 as GadgetOrClass, aq as GadgetParameterInterceptorContext, ar as GadgetResultInterceptorContext, ca as GadgetSkippedEvent, a$ as GadgetStartEvent, aQ as GadgetState, bQ as HintContext, a7 as HistoryMessage, b0 as HumanInputRequiredEvent, bk as ImageBase64Source, bl as ImageContentPart, bm as ImageMimeType, bn as ImageSource, bo as ImageUrlSource, as as Interceptors, b1 as LLMCallCompleteEvent, at as LLMCallControllerContext, b2 as LLMCallErrorEvent, aR as LLMCallNode, b3 as LLMCallStartEvent, b4 as LLMCallStreamEvent, au as LLMErrorControllerContext, b5 as LLMEvent, bG as LLMMessageBuilder, aI as LLMistOptions, av as MessageInterceptorContext, bE as MessageRole, aw as MessageTurn, d as MockBuilder, f as MockManager, l as MockMatcher, n as MockMatcherContext, o as MockOptions, M as MockProviderAdapter, p as MockRegistration, q as MockResponse, r as MockStats, bJ as ModelFeatures, bP as ModelIdentifierParser, bK as ModelLimits, bL as ModelPricing, ax as ObserveChunkContext, ay as ObserveCompactionContext, az as ObserveGadgetCompleteContext, aA as ObserveGadgetStartContext, aB as ObserveLLMCallContext, aC as ObserveLLMCompleteContext, aD as ObserveLLMErrorContext, aE as Observers, bR as PromptContext, bS as PromptTemplate, bT as PromptTemplateConfig, bO as ProviderIdentifier, cb as StoredMedia, b6 as StreamCompleteEvent, aF as SubagentContext, cc as SubagentStreamEvent, bp as TextContentPart, b7 as TextEvent, bZ as TextGenerationOptions, cd as TextOnlyAction, ce as TextOnlyContext, cf as TextOnlyCustomHandler, cg as TextOnlyGadgetConfig, ch as TextOnlyHandler, ci as TextOnlyStrategy, a8 as TrailingMessage, a9 as TrailingMessageContext, aT as TreeCompactionEvent, a_ as TreeGadgetSkippedEvent, bM as VisionAnalyzeOptions, bN as VisionAnalyzeResult, bq as audioFromBase64, br as audioFromBuffer, ac as collectEvents, ad as collectText, b_ as complete, c1 as createGadget, c as createMockAdapter, e as createMockClient, h as createMockStream, i as createTextMockStream, bs as detectAudioMimeType, bt as detectImageMimeType, bF as extractMessageText, b8 as filterByDepth, b9 as filterByParent, ba as filterRootEvents, g as getMockManager, bb as groupByParent, bu as imageFromBase64, bv as imageFromBuffer, bw as imageFromUrl, bx as isAudioPart, by as isDataUrl, bc as isGadgetEvent, bz as isImagePart, bd as isLLMEvent, be as isRootEvent, bf as isSubagentEvent, bA as isTextPart, m as mockLLM, bH as normalizeMessageContent, bB as parseDataUrl, bW as resolveHintTemplate, bX as resolvePromptTemplate, bY as resolveRulesTemplate, ae as runWithHandlers, b$ as stream, bC as text, bD as toBase64 } from './mock-stream-r5vjy2Iq.js';
5
5
  import { Logger, ILogObj } from 'tslog';
6
+ export { ILogObj, Logger } from 'tslog';
6
7
  import { MessageCreateParamsStreaming, MessageStreamEvent } from '@anthropic-ai/sdk/resources/messages';
7
8
  import OpenAI from 'openai';
8
9
  import { ChatCompletionChunk } from 'openai/resources/chat/completions';
@@ -1198,6 +1199,16 @@ interface StreamProcessorOptions {
1198
1199
  parentNodeId?: NodeId | null;
1199
1200
  /** Base depth for nodes created by this processor */
1200
1201
  baseDepth?: number;
1202
+ /**
1203
+ * Set of invocation IDs that completed in previous iterations.
1204
+ * Used to resolve dependencies on gadgets from prior LLM responses.
1205
+ */
1206
+ priorCompletedInvocations?: Set<string>;
1207
+ /**
1208
+ * Set of invocation IDs that failed in previous iterations.
1209
+ * Used to skip gadgets that depend on previously-failed gadgets.
1210
+ */
1211
+ priorFailedInvocations?: Set<string>;
1201
1212
  }
1202
1213
  /**
1203
1214
  * Result of stream processing.
@@ -1262,6 +1273,10 @@ declare class StreamProcessor {
1262
1273
  private inFlightExecutions;
1263
1274
  /** Queue of completed gadget results ready to be yielded (for real-time streaming) */
1264
1275
  private completedResultsQueue;
1276
+ /** Invocation IDs completed in previous iterations (read-only reference from Agent) */
1277
+ private readonly priorCompletedInvocations;
1278
+ /** Invocation IDs that failed in previous iterations (read-only reference from Agent) */
1279
+ private readonly priorFailedInvocations;
1265
1280
  constructor(options: StreamProcessorOptions);
1266
1281
  /**
1267
1282
  * Process an LLM stream and yield events in real-time.
@@ -1282,30 +1297,17 @@ declare class StreamProcessor {
1282
1297
  * Process a text event through interceptors.
1283
1298
  */
1284
1299
  private processTextEvent;
1285
- /**
1286
- * Process a gadget call through the full lifecycle, handling dependencies.
1287
- *
1288
- * Gadgets without dependencies (or with all dependencies satisfied) execute immediately.
1289
- * Gadgets with unsatisfied dependencies are queued for later execution.
1290
- * After each execution, pending gadgets are checked to see if they can now run.
1291
- */
1292
- private processGadgetCall;
1293
1300
  /**
1294
1301
  * Process a gadget call, yielding events in real-time.
1295
1302
  *
1296
- * Key difference from processGadgetCall: yields gadget_call event IMMEDIATELY
1297
- * when parsed (before execution), enabling real-time UI feedback.
1303
+ * Yields gadget_call event IMMEDIATELY when parsed (before execution),
1304
+ * enabling real-time UI feedback.
1298
1305
  */
1299
1306
  private processGadgetCallGenerator;
1300
1307
  /**
1301
- * Execute a gadget through the full hook lifecycle.
1302
- * This is the core execution logic, extracted from processGadgetCall.
1303
- * @deprecated Use executeGadgetGenerator for real-time streaming
1304
- */
1305
- private executeGadgetWithHooks;
1306
- /**
1307
- * Execute a gadget and yield the result event.
1308
- * Generator version that yields gadget_result immediately when execution completes.
1308
+ * Execute a gadget through the full hook lifecycle and yield events.
1309
+ * Handles parameter interception, before/after controllers, observers,
1310
+ * execution, result interception, and tree tracking.
1309
1311
  */
1310
1312
  private executeGadgetGenerator;
1311
1313
  /**
@@ -1336,14 +1338,9 @@ declare class StreamProcessor {
1336
1338
  private handleFailedDependency;
1337
1339
  /**
1338
1340
  * Process pending gadgets whose dependencies are now satisfied.
1339
- * Executes ready gadgets in parallel and continues until no more can be triggered.
1340
- */
1341
- private processPendingGadgets;
1342
- /**
1343
- * Process pending gadgets, yielding events in real-time.
1344
- * Generator version that yields events as gadgets complete.
1341
+ * Yields events in real-time as gadgets complete.
1345
1342
  *
1346
- * Note: Gadgets are still executed in parallel for efficiency,
1343
+ * Gadgets are executed in parallel for efficiency,
1347
1344
  * but results are yielded as they become available.
1348
1345
  */
1349
1346
  private processPendingGadgetsGenerator;
@@ -1357,6 +1354,16 @@ declare class StreamProcessor {
1357
1354
  * All observers run concurrently and failures are tracked but don't crash.
1358
1355
  */
1359
1356
  private runObserversInParallel;
1357
+ /**
1358
+ * Get all invocation IDs that completed successfully in this iteration.
1359
+ * Used by Agent to accumulate completed IDs across iterations.
1360
+ */
1361
+ getCompletedInvocationIds(): Set<string>;
1362
+ /**
1363
+ * Get all invocation IDs that failed in this iteration.
1364
+ * Used by Agent to accumulate failed IDs across iterations.
1365
+ */
1366
+ getFailedInvocationIds(): Set<string>;
1360
1367
  }
1361
1368
 
1362
1369
  /**
@@ -1641,11 +1648,6 @@ declare class GadgetExecutor {
1641
1648
  private unifyExecuteResult;
1642
1649
  execute(call: ParsedGadgetCall): Promise<GadgetExecutionResult>;
1643
1650
  executeAll(calls: ParsedGadgetCall[]): Promise<GadgetExecutionResult[]>;
1644
- /**
1645
- * Deep equality check for objects/arrays.
1646
- * Used to detect if parameters were modified by an interceptor.
1647
- */
1648
- private deepEquals;
1649
1651
  }
1650
1652
 
1651
1653
  /**
package/dist/index.js CHANGED
@@ -22,7 +22,7 @@ import {
22
22
  resultWithImages,
23
23
  resultWithMedia,
24
24
  z
25
- } from "./chunk-EJEP5MHQ.js";
25
+ } from "./chunk-5KEZ7SQX.js";
26
26
  import {
27
27
  AbortException,
28
28
  AbstractGadget,
@@ -102,7 +102,7 @@ import {
102
102
  toBase64,
103
103
  validateAndApplyDefaults,
104
104
  validateGadgetParams
105
- } from "./chunk-36YSBSGB.js";
105
+ } from "./chunk-SFZIL2VR.js";
106
106
  export {
107
107
  AbortException,
108
108
  AbstractGadget,
@@ -1524,7 +1524,8 @@ declare class ModelRegistry {
1524
1524
  registerModels(specs: ModelSpec[]): void;
1525
1525
  /**
1526
1526
  * Get model specification by model ID
1527
- * @param modelId - Full model identifier (e.g., 'gpt-5', 'claude-sonnet-4-5-20250929')
1527
+ * @param modelId - Full model identifier, optionally with provider prefix
1528
+ * (e.g., 'gpt-5', 'claude-sonnet-4-5-20250929', 'anthropic:claude-sonnet-4-5')
1528
1529
  * @returns ModelSpec if found, undefined otherwise
1529
1530
  */
1530
1531
  getModelSpec(modelId: string): ModelSpec | undefined;
@@ -2401,6 +2402,27 @@ interface ExecutionContext {
2401
2402
  * ```
2402
2403
  */
2403
2404
  hostExports?: HostExports;
2405
+ /**
2406
+ * Logger instance for structured logging.
2407
+ *
2408
+ * External gadgets should use this for logging instead of importing
2409
+ * defaultLogger directly. This ensures logs respect the CLI's configured
2410
+ * log level, format, and destination (file/console).
2411
+ *
2412
+ * The logger is optional to support standalone gadget execution and testing.
2413
+ * Use optional chaining when logging: `ctx.logger?.debug(...)`.
2414
+ *
2415
+ * @example
2416
+ * ```typescript
2417
+ * execute: async (params, ctx) => {
2418
+ * ctx.logger?.debug("[MyGadget] Starting operation", { itemId: params.id });
2419
+ * // ... do work ...
2420
+ * ctx.logger?.info("[MyGadget] Completed successfully");
2421
+ * return "done";
2422
+ * }
2423
+ * ```
2424
+ */
2425
+ logger?: Logger<ILogObj>;
2404
2426
  }
2405
2427
  /**
2406
2428
  * Host llmist exports provided to external gadgets via ExecutionContext.
@@ -4689,6 +4711,8 @@ declare class Agent {
4689
4711
  private readonly pendingSubagentEvents;
4690
4712
  private readonly onSubagentEvent;
4691
4713
  private syntheticInvocationCounter;
4714
+ private readonly completedInvocationIds;
4715
+ private readonly failedInvocationIds;
4692
4716
  private readonly tree;
4693
4717
  private readonly parentNodeId;
4694
4718
  private readonly baseDepth;
@@ -4857,6 +4881,34 @@ declare class Agent {
4857
4881
  * The limiter runs first, then chains to any user interceptor.
4858
4882
  */
4859
4883
  private chainOutputLimiterWithUserHooks;
4884
+ /**
4885
+ * Check abort signal and notify observers if aborted.
4886
+ * @returns true if agent should terminate
4887
+ */
4888
+ private checkAbortAndNotify;
4889
+ /**
4890
+ * Check and perform context compaction if needed.
4891
+ * @returns compaction stream event if compaction occurred, null otherwise
4892
+ */
4893
+ private checkAndPerformCompaction;
4894
+ /**
4895
+ * Prepare LLM call options and process beforeLLMCall controller.
4896
+ * @returns options and optional skipWithSynthetic response if controller wants to skip
4897
+ */
4898
+ private prepareLLMCall;
4899
+ /**
4900
+ * Calculate cost and complete LLM call in execution tree.
4901
+ */
4902
+ private completeLLMCallInTree;
4903
+ /**
4904
+ * Process afterLLMCall controller and return modified final message.
4905
+ */
4906
+ private processAfterLLMCallController;
4907
+ /**
4908
+ * Update conversation history with gadget results or text-only response.
4909
+ * @returns true if loop should break (text-only handler requested termination)
4910
+ */
4911
+ private updateConversationWithResults;
4860
4912
  /**
4861
4913
  * Run agent with named event handlers (syntactic sugar).
4862
4914
  *
@@ -1524,7 +1524,8 @@ declare class ModelRegistry {
1524
1524
  registerModels(specs: ModelSpec[]): void;
1525
1525
  /**
1526
1526
  * Get model specification by model ID
1527
- * @param modelId - Full model identifier (e.g., 'gpt-5', 'claude-sonnet-4-5-20250929')
1527
+ * @param modelId - Full model identifier, optionally with provider prefix
1528
+ * (e.g., 'gpt-5', 'claude-sonnet-4-5-20250929', 'anthropic:claude-sonnet-4-5')
1528
1529
  * @returns ModelSpec if found, undefined otherwise
1529
1530
  */
1530
1531
  getModelSpec(modelId: string): ModelSpec | undefined;
@@ -2401,6 +2402,27 @@ interface ExecutionContext {
2401
2402
  * ```
2402
2403
  */
2403
2404
  hostExports?: HostExports;
2405
+ /**
2406
+ * Logger instance for structured logging.
2407
+ *
2408
+ * External gadgets should use this for logging instead of importing
2409
+ * defaultLogger directly. This ensures logs respect the CLI's configured
2410
+ * log level, format, and destination (file/console).
2411
+ *
2412
+ * The logger is optional to support standalone gadget execution and testing.
2413
+ * Use optional chaining when logging: `ctx.logger?.debug(...)`.
2414
+ *
2415
+ * @example
2416
+ * ```typescript
2417
+ * execute: async (params, ctx) => {
2418
+ * ctx.logger?.debug("[MyGadget] Starting operation", { itemId: params.id });
2419
+ * // ... do work ...
2420
+ * ctx.logger?.info("[MyGadget] Completed successfully");
2421
+ * return "done";
2422
+ * }
2423
+ * ```
2424
+ */
2425
+ logger?: Logger<ILogObj>;
2404
2426
  }
2405
2427
  /**
2406
2428
  * Host llmist exports provided to external gadgets via ExecutionContext.
@@ -4689,6 +4711,8 @@ declare class Agent {
4689
4711
  private readonly pendingSubagentEvents;
4690
4712
  private readonly onSubagentEvent;
4691
4713
  private syntheticInvocationCounter;
4714
+ private readonly completedInvocationIds;
4715
+ private readonly failedInvocationIds;
4692
4716
  private readonly tree;
4693
4717
  private readonly parentNodeId;
4694
4718
  private readonly baseDepth;
@@ -4857,6 +4881,34 @@ declare class Agent {
4857
4881
  * The limiter runs first, then chains to any user interceptor.
4858
4882
  */
4859
4883
  private chainOutputLimiterWithUserHooks;
4884
+ /**
4885
+ * Check abort signal and notify observers if aborted.
4886
+ * @returns true if agent should terminate
4887
+ */
4888
+ private checkAbortAndNotify;
4889
+ /**
4890
+ * Check and perform context compaction if needed.
4891
+ * @returns compaction stream event if compaction occurred, null otherwise
4892
+ */
4893
+ private checkAndPerformCompaction;
4894
+ /**
4895
+ * Prepare LLM call options and process beforeLLMCall controller.
4896
+ * @returns options and optional skipWithSynthetic response if controller wants to skip
4897
+ */
4898
+ private prepareLLMCall;
4899
+ /**
4900
+ * Calculate cost and complete LLM call in execution tree.
4901
+ */
4902
+ private completeLLMCallInTree;
4903
+ /**
4904
+ * Process afterLLMCall controller and return modified final message.
4905
+ */
4906
+ private processAfterLLMCallController;
4907
+ /**
4908
+ * Update conversation history with gadget results or text-only response.
4909
+ * @returns true if loop should break (text-only handler requested termination)
4910
+ */
4911
+ private updateConversationWithResults;
4860
4912
  /**
4861
4913
  * Run agent with named event handlers (syntactic sugar).
4862
4914
  *