llmist 6.0.0 → 6.1.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/{chunk-F62X5W2G.js → chunk-7BJX376V.js} +97 -2
- package/dist/chunk-7BJX376V.js.map +1 -0
- package/dist/{chunk-EIE5VRSI.js → chunk-VAJLPRJ6.js} +911 -389
- package/dist/chunk-VAJLPRJ6.js.map +1 -0
- package/dist/cli.cjs +4073 -1645
- package/dist/cli.cjs.map +1 -1
- package/dist/cli.js +3008 -1101
- package/dist/cli.js.map +1 -1
- package/dist/index.cjs +1012 -385
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +144 -45
- package/dist/index.d.ts +144 -45
- package/dist/index.js +26 -2
- package/dist/{mock-stream-CAY53Q6u.d.cts → mock-stream-Cq1Sxezz.d.cts} +854 -166
- package/dist/{mock-stream-CAY53Q6u.d.ts → mock-stream-Cq1Sxezz.d.ts} +854 -166
- package/dist/testing/index.cjs +908 -388
- package/dist/testing/index.cjs.map +1 -1
- package/dist/testing/index.d.cts +3 -3
- package/dist/testing/index.d.ts +3 -3
- package/dist/testing/index.js +1 -1
- package/package.json +2 -1
- package/dist/chunk-EIE5VRSI.js.map +0 -1
- package/dist/chunk-F62X5W2G.js.map +0 -1
package/dist/index.d.cts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { ZodType, 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, b as LLMStreamChunk,
|
|
4
|
-
export {
|
|
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 ExecutionContext, Q as GadgetExecuteReturn, U as GadgetExample, A as AbstractGadget, V as ParsedGadgetCall, W as GadgetExecutionResult, X as MediaKind, Y as MediaMetadata, Z as GadgetExecuteResultWithMedia, _ as ProviderAdapter, $ as ModelDescriptor, a0 as ModelSpec, a1 as LLMGenerationOptions, a as LLMStream, a2 as ImageModelSpec, a3 as ImageGenerationOptions, a4 as ImageGenerationResult, a5 as SpeechModelSpec, a6 as SpeechGenerationOptions, a7 as SpeechGenerationResult } from './mock-stream-Cq1Sxezz.cjs';
|
|
4
|
+
export { aK as AddGadgetParams, aL as AddLLMCallParams, ag as AfterGadgetExecutionAction, ah as AfterGadgetExecutionControllerContext, ai as AfterLLMCallAction, aj as AfterLLMCallControllerContext, ak as AfterLLMErrorAction, ab as AgentBuilder, al as AgentOptions, bh as AudioContentPart, bi as AudioMimeType, bj as AudioSource, aT as BaseExecutionEvent, am as BeforeGadgetExecutionAction, an as BeforeLLMCallAction, ao as ChunkInterceptorContext, aM as CompleteGadgetParams, aN as CompleteLLMCallParams, bk as ContentPart, ap as Controllers, bJ as CostEstimate, c3 as CostReportingLLMist, aH as DEFAULT_COMPACTION_CONFIG, bV as DEFAULT_HINTS, bW as DEFAULT_PROMPTS, aI as DEFAULT_SUMMARIZATION_PROMPT, ac as EventHandlers, aV as ExecutionEvent, aW as ExecutionEventType, aO as ExecutionNode, aP as ExecutionNodeType, aX as GadgetCallEvent, c1 as GadgetClass, aY as GadgetCompleteEvent, aZ as GadgetErrorEvent, a_ as GadgetEvent, c4 as GadgetExecuteResult, aq as GadgetExecutionControllerContext, aQ as GadgetNode, c2 as GadgetOrClass, ar as GadgetParameterInterceptorContext, as as GadgetResultInterceptorContext, c5 as GadgetSkippedEvent, b0 as GadgetStartEvent, aR as GadgetState, bR as HintContext, a8 as HistoryMessage, b1 as HumanInputRequiredEvent, bl as ImageBase64Source, bm as ImageContentPart, bn as ImageMimeType, bo as ImageSource, bp as ImageUrlSource, at as Interceptors, b2 as LLMCallCompleteEvent, au as LLMCallControllerContext, b3 as LLMCallErrorEvent, aS as LLMCallNode, b4 as LLMCallStartEvent, b5 as LLMCallStreamEvent, av as LLMErrorControllerContext, b6 as LLMEvent, bH as LLMMessageBuilder, aJ as LLMistOptions, aw as MessageInterceptorContext, bF as MessageRole, ax 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, bK as ModelFeatures, bQ as ModelIdentifierParser, bL as ModelLimits, bM as ModelPricing, ay as ObserveChunkContext, az as ObserveCompactionContext, aA as ObserveGadgetCompleteContext, aB as ObserveGadgetStartContext, aC as ObserveLLMCallContext, aD as ObserveLLMCompleteContext, aE as ObserveLLMErrorContext, aF as Observers, bS as PromptContext, bT as PromptTemplate, bU as PromptTemplateConfig, bP as ProviderIdentifier, c6 as StoredMedia, b7 as StreamCompleteEvent, aG as SubagentContext, c7 as SubagentStreamEvent, bq as TextContentPart, b8 as TextEvent, b_ as TextGenerationOptions, c8 as TextOnlyAction, c9 as TextOnlyContext, ca as TextOnlyCustomHandler, cb as TextOnlyGadgetConfig, cc as TextOnlyHandler, cd as TextOnlyStrategy, a9 as TrailingMessage, aa as TrailingMessageContext, aU as TreeCompactionEvent, a$ as TreeGadgetSkippedEvent, bN as VisionAnalyzeOptions, bO as VisionAnalyzeResult, br as audioFromBase64, bs as audioFromBuffer, ad as collectEvents, ae as collectText, b$ as complete, c as createMockAdapter, e as createMockClient, h as createMockStream, i as createTextMockStream, bt as detectAudioMimeType, bu as detectImageMimeType, bG as extractMessageText, b9 as filterByDepth, ba as filterByParent, bb as filterRootEvents, g as getMockManager, bc as groupByParent, bv as imageFromBase64, bw as imageFromBuffer, bx as imageFromUrl, by as isAudioPart, bz as isDataUrl, bd as isGadgetEvent, bA as isImagePart, be as isLLMEvent, bf as isRootEvent, bg as isSubagentEvent, bB as isTextPart, m as mockLLM, bI as normalizeMessageContent, bC as parseDataUrl, bX as resolveHintTemplate, bY as resolvePromptTemplate, bZ as resolveRulesTemplate, af as runWithHandlers, c0 as stream, bD as text, bE as toBase64 } from './mock-stream-Cq1Sxezz.cjs';
|
|
5
5
|
import { Logger, ILogObj } from 'tslog';
|
|
6
6
|
import { MessageCreateParamsStreaming, MessageStreamEvent } from '@anthropic-ai/sdk/resources/messages';
|
|
7
7
|
import OpenAI from 'openai';
|
|
@@ -888,7 +888,7 @@ declare class ConversationManager implements IConversationManager {
|
|
|
888
888
|
constructor(baseMessages: LLMMessage[], initialMessages: LLMMessage[], options?: ConversationManagerOptions);
|
|
889
889
|
addUserMessage(content: MessageContent): void;
|
|
890
890
|
addAssistantMessage(content: string): void;
|
|
891
|
-
addGadgetCallResult(gadgetName: string, parameters: Record<string, unknown>, result: string, media?: GadgetMediaOutput[], mediaIds?: string[]): void;
|
|
891
|
+
addGadgetCallResult(gadgetName: string, parameters: Record<string, unknown>, result: string, invocationId: string, media?: GadgetMediaOutput[], mediaIds?: string[]): void;
|
|
892
892
|
getMessages(): LLMMessage[];
|
|
893
893
|
getHistoryMessages(): LLMMessage[];
|
|
894
894
|
getBaseMessages(): LLMMessage[];
|
|
@@ -1180,15 +1180,6 @@ interface StreamProcessorOptions {
|
|
|
1180
1180
|
logger?: Logger<ILogObj>;
|
|
1181
1181
|
/** Callback for requesting human input during execution */
|
|
1182
1182
|
requestHumanInput?: (question: string) => Promise<string>;
|
|
1183
|
-
/** Whether to stop on gadget errors */
|
|
1184
|
-
stopOnGadgetError?: boolean;
|
|
1185
|
-
/** Custom error recovery logic */
|
|
1186
|
-
canRecoverFromGadgetError?: (context: {
|
|
1187
|
-
error: string;
|
|
1188
|
-
gadgetName: string;
|
|
1189
|
-
errorType: "parse" | "validation" | "execution";
|
|
1190
|
-
parameters?: Record<string, unknown>;
|
|
1191
|
-
}) => boolean | Promise<boolean>;
|
|
1192
1183
|
/** Default gadget timeout */
|
|
1193
1184
|
defaultGadgetTimeoutMs?: number;
|
|
1194
1185
|
/** LLMist client for ExecutionContext.llmist */
|
|
@@ -1201,6 +1192,12 @@ interface StreamProcessorOptions {
|
|
|
1201
1192
|
subagentConfig?: SubagentConfigMap;
|
|
1202
1193
|
/** Callback for subagent gadgets to report subagent events to parent */
|
|
1203
1194
|
onSubagentEvent?: (event: SubagentEvent) => void;
|
|
1195
|
+
/** Execution tree for tracking LLM calls and gadget executions */
|
|
1196
|
+
tree?: ExecutionTree;
|
|
1197
|
+
/** Parent node ID (for gadget nodes created by this processor) */
|
|
1198
|
+
parentNodeId?: NodeId | null;
|
|
1199
|
+
/** Base depth for nodes created by this processor */
|
|
1200
|
+
baseDepth?: number;
|
|
1204
1201
|
}
|
|
1205
1202
|
/**
|
|
1206
1203
|
* Result of stream processing.
|
|
@@ -1250,10 +1247,10 @@ declare class StreamProcessor {
|
|
|
1250
1247
|
private readonly logger;
|
|
1251
1248
|
private readonly parser;
|
|
1252
1249
|
private readonly executor;
|
|
1253
|
-
private readonly
|
|
1254
|
-
private readonly
|
|
1250
|
+
private readonly tree?;
|
|
1251
|
+
private readonly parentNodeId;
|
|
1252
|
+
private readonly baseDepth;
|
|
1255
1253
|
private responseText;
|
|
1256
|
-
private executionHalted;
|
|
1257
1254
|
private observerFailureCount;
|
|
1258
1255
|
/** Gadgets waiting for their dependencies to complete */
|
|
1259
1256
|
private gadgetsAwaitingDependencies;
|
|
@@ -1263,6 +1260,8 @@ declare class StreamProcessor {
|
|
|
1263
1260
|
private failedInvocations;
|
|
1264
1261
|
/** Promises for independent gadgets currently executing (fire-and-forget) */
|
|
1265
1262
|
private inFlightExecutions;
|
|
1263
|
+
/** Queue of completed gadget results ready to be yielded (for real-time streaming) */
|
|
1264
|
+
private completedResultsQueue;
|
|
1266
1265
|
constructor(options: StreamProcessorOptions);
|
|
1267
1266
|
/**
|
|
1268
1267
|
* Process an LLM stream and yield events in real-time.
|
|
@@ -1275,14 +1274,8 @@ declare class StreamProcessor {
|
|
|
1275
1274
|
* The final event is always a StreamCompletionEvent containing metadata.
|
|
1276
1275
|
*/
|
|
1277
1276
|
process(stream: AsyncIterable<LLMStreamChunk>): AsyncGenerator<StreamEvent>;
|
|
1278
|
-
/**
|
|
1279
|
-
* Process a single parsed event (text or gadget call).
|
|
1280
|
-
* @deprecated Use processEventGenerator for real-time streaming
|
|
1281
|
-
*/
|
|
1282
|
-
private processEvent;
|
|
1283
1277
|
/**
|
|
1284
1278
|
* Process a single parsed event, yielding events in real-time.
|
|
1285
|
-
* Generator version of processEvent for streaming support.
|
|
1286
1279
|
*/
|
|
1287
1280
|
private processEventGenerator;
|
|
1288
1281
|
/**
|
|
@@ -1316,17 +1309,26 @@ declare class StreamProcessor {
|
|
|
1316
1309
|
*/
|
|
1317
1310
|
private executeGadgetGenerator;
|
|
1318
1311
|
/**
|
|
1319
|
-
* Execute a gadget and
|
|
1312
|
+
* Execute a gadget and push events to the completed results queue (non-blocking).
|
|
1320
1313
|
* Used for fire-and-forget parallel execution of independent gadgets.
|
|
1314
|
+
* Results are pushed to completedResultsQueue for real-time streaming to the caller.
|
|
1321
1315
|
*/
|
|
1322
1316
|
private executeGadgetAndCollect;
|
|
1323
1317
|
/**
|
|
1324
|
-
*
|
|
1325
|
-
*
|
|
1326
|
-
*
|
|
1327
|
-
|
|
1318
|
+
* Drain all completed results from the queue.
|
|
1319
|
+
* Used to yield results as they complete during stream processing.
|
|
1320
|
+
* @returns Generator that yields all events currently in the queue
|
|
1321
|
+
*/
|
|
1322
|
+
private drainCompletedResults;
|
|
1323
|
+
/**
|
|
1324
|
+
* Wait for all in-flight gadget executions to complete, yielding events in real-time.
|
|
1325
|
+
* Called at stream end to ensure all parallel executions finish.
|
|
1326
|
+
* Results and subagent events are pushed to completedResultsQueue during execution.
|
|
1327
|
+
* This generator yields queued events while polling, enabling real-time display
|
|
1328
|
+
* of subagent activity (LLM calls, nested gadgets) during long-running gadgets.
|
|
1329
|
+
* Clears the inFlightExecutions map after all gadgets complete.
|
|
1328
1330
|
*/
|
|
1329
|
-
private
|
|
1331
|
+
private waitForInFlightExecutions;
|
|
1330
1332
|
/**
|
|
1331
1333
|
* Handle a gadget that cannot execute because a dependency failed.
|
|
1332
1334
|
* Calls the onDependencySkipped controller to allow customization.
|
|
@@ -1355,22 +1357,6 @@ declare class StreamProcessor {
|
|
|
1355
1357
|
* All observers run concurrently and failures are tracked but don't crash.
|
|
1356
1358
|
*/
|
|
1357
1359
|
private runObserversInParallel;
|
|
1358
|
-
/**
|
|
1359
|
-
* Check if execution can recover from an error.
|
|
1360
|
-
*
|
|
1361
|
-
* Returns true if we should continue processing subsequent gadgets, false if we should stop.
|
|
1362
|
-
*
|
|
1363
|
-
* Logic:
|
|
1364
|
-
* - If custom canRecoverFromGadgetError is provided, use it
|
|
1365
|
-
* - Otherwise, use stopOnGadgetError config:
|
|
1366
|
-
* - stopOnGadgetError=true → return false (stop execution)
|
|
1367
|
-
* - stopOnGadgetError=false → return true (continue execution)
|
|
1368
|
-
*/
|
|
1369
|
-
private checkCanRecoverFromError;
|
|
1370
|
-
/**
|
|
1371
|
-
* Determine the type of error from a gadget execution.
|
|
1372
|
-
*/
|
|
1373
|
-
private determineErrorType;
|
|
1374
1360
|
}
|
|
1375
1361
|
|
|
1376
1362
|
/**
|
|
@@ -1744,13 +1730,17 @@ declare class GadgetExecutor {
|
|
|
1744
1730
|
private readonly agentConfig?;
|
|
1745
1731
|
private readonly subagentConfig?;
|
|
1746
1732
|
private readonly onSubagentEvent?;
|
|
1733
|
+
private readonly tree?;
|
|
1734
|
+
private readonly parentNodeId?;
|
|
1735
|
+
private readonly baseDepth?;
|
|
1747
1736
|
private readonly logger;
|
|
1748
1737
|
private readonly errorFormatter;
|
|
1749
1738
|
private readonly argPrefix;
|
|
1750
|
-
constructor(registry: GadgetRegistry, requestHumanInput?: ((question: string) => Promise<string>) | undefined, logger?: Logger<ILogObj>, defaultGadgetTimeoutMs?: number | undefined, errorFormatterOptions?: ErrorFormatterOptions, client?: LLMist | undefined, mediaStore?: MediaStore | undefined, agentConfig?: AgentContextConfig | undefined, subagentConfig?: SubagentConfigMap | undefined, onSubagentEvent?: ((event: SubagentEvent) => void) | undefined);
|
|
1739
|
+
constructor(registry: GadgetRegistry, requestHumanInput?: ((question: string) => Promise<string>) | undefined, logger?: Logger<ILogObj>, defaultGadgetTimeoutMs?: number | undefined, errorFormatterOptions?: ErrorFormatterOptions, client?: LLMist | undefined, mediaStore?: MediaStore | undefined, agentConfig?: AgentContextConfig | undefined, subagentConfig?: SubagentConfigMap | undefined, onSubagentEvent?: ((event: SubagentEvent) => void) | undefined, tree?: ExecutionTree | undefined, parentNodeId?: (NodeId | null) | undefined, baseDepth?: number | undefined);
|
|
1751
1740
|
/**
|
|
1752
1741
|
* Creates a promise that rejects with a TimeoutException after the specified timeout.
|
|
1753
1742
|
* Aborts the provided AbortController before rejecting, allowing gadgets to clean up.
|
|
1743
|
+
* Returns both the promise and a cancel function to clear the timeout when no longer needed.
|
|
1754
1744
|
*/
|
|
1755
1745
|
private createTimeoutPromise;
|
|
1756
1746
|
/**
|
|
@@ -2334,6 +2324,115 @@ declare function createLogger(options?: LoggerOptions): Logger<ILogObj>;
|
|
|
2334
2324
|
*/
|
|
2335
2325
|
declare const defaultLogger: Logger<ILogObj>;
|
|
2336
2326
|
|
|
2327
|
+
/**
|
|
2328
|
+
* Config resolution utility for subagent gadgets.
|
|
2329
|
+
*
|
|
2330
|
+
* Simplifies the common pattern of resolving configuration from multiple sources:
|
|
2331
|
+
* 1. Runtime params (explicit gadget call parameters)
|
|
2332
|
+
* 2. Subagent config (from CLI [subagents.Name] sections)
|
|
2333
|
+
* 3. Parent agent config (model inheritance)
|
|
2334
|
+
* 4. Package defaults
|
|
2335
|
+
*
|
|
2336
|
+
* @module utils/config-resolver
|
|
2337
|
+
*/
|
|
2338
|
+
|
|
2339
|
+
/**
|
|
2340
|
+
* Options for resolving a single config value.
|
|
2341
|
+
*/
|
|
2342
|
+
interface ResolveValueOptions<T> {
|
|
2343
|
+
/** Runtime parameter value (highest priority) */
|
|
2344
|
+
runtime?: T;
|
|
2345
|
+
/** Subagent config key to check */
|
|
2346
|
+
subagentKey?: string;
|
|
2347
|
+
/** Parent config key to check (for inheritance) - "model" or "temperature" */
|
|
2348
|
+
parentKey?: "model" | "temperature";
|
|
2349
|
+
/** Default value (lowest priority) */
|
|
2350
|
+
defaultValue: T;
|
|
2351
|
+
/** Whether "inherit" string means use parent value */
|
|
2352
|
+
handleInherit?: boolean;
|
|
2353
|
+
}
|
|
2354
|
+
/**
|
|
2355
|
+
* Resolve a single configuration value through the priority chain.
|
|
2356
|
+
*
|
|
2357
|
+
* Priority (highest to lowest):
|
|
2358
|
+
* 1. Runtime parameter (if provided and not undefined)
|
|
2359
|
+
* 2. Subagent config (from ctx.subagentConfig[gadgetName][key])
|
|
2360
|
+
* 3. Parent config (from ctx.agentConfig[key], if parentKey specified)
|
|
2361
|
+
* 4. Default value
|
|
2362
|
+
*
|
|
2363
|
+
* Special handling for "inherit" string:
|
|
2364
|
+
* - If handleInherit is true and value is "inherit", falls through to parent/default
|
|
2365
|
+
*
|
|
2366
|
+
* @param ctx - ExecutionContext from gadget execution
|
|
2367
|
+
* @param gadgetName - Name of the subagent gadget (e.g., "BrowseWeb")
|
|
2368
|
+
* @param options - Resolution options
|
|
2369
|
+
* @returns Resolved value
|
|
2370
|
+
*
|
|
2371
|
+
* @example
|
|
2372
|
+
* ```typescript
|
|
2373
|
+
* const model = resolveValue(ctx, "BrowseWeb", {
|
|
2374
|
+
* runtime: params.model,
|
|
2375
|
+
* subagentKey: "model",
|
|
2376
|
+
* parentKey: "model",
|
|
2377
|
+
* defaultValue: "sonnet",
|
|
2378
|
+
* handleInherit: true,
|
|
2379
|
+
* });
|
|
2380
|
+
* ```
|
|
2381
|
+
*/
|
|
2382
|
+
declare function resolveValue<T>(ctx: ExecutionContext, gadgetName: string, options: ResolveValueOptions<T>): T;
|
|
2383
|
+
/**
|
|
2384
|
+
* Bulk configuration resolution for subagent gadgets.
|
|
2385
|
+
*
|
|
2386
|
+
* Takes a map of config keys to their resolution options and returns
|
|
2387
|
+
* a fully resolved configuration object.
|
|
2388
|
+
*
|
|
2389
|
+
* @param ctx - ExecutionContext from gadget execution
|
|
2390
|
+
* @param gadgetName - Name of the subagent gadget (e.g., "BrowseWeb")
|
|
2391
|
+
* @param config - Map of config keys to resolution options
|
|
2392
|
+
* @returns Fully resolved configuration object
|
|
2393
|
+
*
|
|
2394
|
+
* @example
|
|
2395
|
+
* ```typescript
|
|
2396
|
+
* // Before: 27 lines of manual fallback logic
|
|
2397
|
+
* const subagentConfig = ctx.subagentConfig?.Dhalsim ?? {};
|
|
2398
|
+
* const parentModel = ctx.agentConfig?.model;
|
|
2399
|
+
* const model = params.model ?? subagentConfig.model ?? parentModel ?? "sonnet";
|
|
2400
|
+
* const maxIterations = params.maxIterations ?? subagentConfig.maxIterations ?? 15;
|
|
2401
|
+
* const headless = params.headless ?? subagentConfig.headless ?? true;
|
|
2402
|
+
*
|
|
2403
|
+
* // After: One function call
|
|
2404
|
+
* const { model, maxIterations, headless } = resolveConfig(ctx, "BrowseWeb", {
|
|
2405
|
+
* model: { runtime: params.model, subagentKey: "model", parentKey: "model", defaultValue: "sonnet", handleInherit: true },
|
|
2406
|
+
* maxIterations: { runtime: params.maxIterations, subagentKey: "maxIterations", defaultValue: 15 },
|
|
2407
|
+
* headless: { runtime: params.headless, subagentKey: "headless", defaultValue: true },
|
|
2408
|
+
* });
|
|
2409
|
+
* ```
|
|
2410
|
+
*/
|
|
2411
|
+
declare function resolveConfig<T extends Record<string, unknown>>(ctx: ExecutionContext, gadgetName: string, config: {
|
|
2412
|
+
[K in keyof T]: ResolveValueOptions<T[K]>;
|
|
2413
|
+
}): T;
|
|
2414
|
+
/**
|
|
2415
|
+
* Convenience function for resolving subagent model with "inherit" support.
|
|
2416
|
+
*
|
|
2417
|
+
* This is the most common resolution pattern for subagent gadgets:
|
|
2418
|
+
* - Use runtime model if provided
|
|
2419
|
+
* - Check subagent config for model override
|
|
2420
|
+
* - Inherit parent model if configured
|
|
2421
|
+
* - Fall back to default
|
|
2422
|
+
*
|
|
2423
|
+
* @param ctx - ExecutionContext from gadget execution
|
|
2424
|
+
* @param gadgetName - Name of the subagent gadget
|
|
2425
|
+
* @param runtimeModel - Model from gadget parameters
|
|
2426
|
+
* @param defaultModel - Default model if nothing else specified
|
|
2427
|
+
* @returns Resolved model string
|
|
2428
|
+
*
|
|
2429
|
+
* @example
|
|
2430
|
+
* ```typescript
|
|
2431
|
+
* const model = resolveSubagentModel(ctx, "BrowseWeb", params.model, "sonnet");
|
|
2432
|
+
* ```
|
|
2433
|
+
*/
|
|
2434
|
+
declare function resolveSubagentModel(ctx: ExecutionContext, gadgetName: string, runtimeModel: string | undefined, defaultModel: string): string;
|
|
2435
|
+
|
|
2337
2436
|
/**
|
|
2338
2437
|
* Base Provider Adapter
|
|
2339
2438
|
*
|
|
@@ -2621,4 +2720,4 @@ declare class OpenAIChatProvider extends BaseProviderAdapter {
|
|
|
2621
2720
|
}
|
|
2622
2721
|
declare function createOpenAIProviderFromEnv(): OpenAIChatProvider | null;
|
|
2623
2722
|
|
|
2624
|
-
export { AbortException, AbstractGadget, AgentHooks, AnthropicMessagesProvider, CompactionConfig, CompactionContext, CompactionEvent, CompactionManager, CompactionResult, CompactionStats, CompactionStrategy, ConversationManager, type CreateGadgetConfig, ExecutionContext, Gadget, GadgetCallParser, type GadgetConfig, GadgetExample, GadgetExecuteResultWithMedia, GadgetExecuteReturn, GadgetExecutionResult, GadgetExecutor, GadgetMediaOutput, GadgetOutputStore, GadgetRegistry, GeminiGenerativeProvider, HintTemplate, type HintsConfig, HookPresets, HumanInputRequiredException, HybridStrategy, IConversationManager, type IterationHintOptions, LLMGenerationOptions, LLMMessage, LLMStream, LLMStreamChunk, LLMist, type LoggerOptions, type LoggingOptions, MODEL_ALIASES, MediaKind, MediaMetadata, MediaStore, MessageContent, ModelDescriptor, ModelRegistry, ModelSpec, OpenAIChatProvider, type ParallelGadgetHintOptions, ParsedGadgetCall, ProviderAdapter, ResolvedCompactionConfig, SlidingWindowStrategy, type StoredOutput, StreamEvent, type StreamProcessingResult, StreamProcessor, type StreamProcessorOptions, SubagentEvent, SummarizationStrategy, TaskCompletionSignal, TimeoutException, TokenUsage, type ValidationIssue, type ValidationResult, createAnthropicProviderFromEnv, createGadget, createGadgetOutputViewer, createGeminiProviderFromEnv, createHints, createLogger, createMediaOutput, createOpenAIProviderFromEnv, defaultLogger, discoverProviderAdapters, getModelId, getProvider, hasProviderPrefix, iterationProgressHint, parallelGadgetHint, resolveModel, resultWithAudio, resultWithFile, resultWithImage, resultWithImages, resultWithMedia, validateAndApplyDefaults, validateGadgetParams };
|
|
2723
|
+
export { AbortException, AbstractGadget, AgentHooks, AnthropicMessagesProvider, CompactionConfig, CompactionContext, CompactionEvent, CompactionManager, CompactionResult, CompactionStats, CompactionStrategy, ConversationManager, type CreateGadgetConfig, ExecutionContext, ExecutionTree, Gadget, GadgetCallParser, type GadgetConfig, GadgetExample, GadgetExecuteResultWithMedia, GadgetExecuteReturn, GadgetExecutionResult, GadgetExecutor, GadgetMediaOutput, GadgetOutputStore, GadgetRegistry, GeminiGenerativeProvider, HintTemplate, type HintsConfig, HookPresets, HumanInputRequiredException, HybridStrategy, IConversationManager, type IterationHintOptions, LLMGenerationOptions, LLMMessage, LLMStream, LLMStreamChunk, LLMist, type LoggerOptions, type LoggingOptions, MODEL_ALIASES, MediaKind, MediaMetadata, MediaStore, MessageContent, ModelDescriptor, ModelRegistry, ModelSpec, NodeId, OpenAIChatProvider, type ParallelGadgetHintOptions, ParsedGadgetCall, ProviderAdapter, type ResolveValueOptions, ResolvedCompactionConfig, SlidingWindowStrategy, type StoredOutput, StreamEvent, type StreamProcessingResult, StreamProcessor, type StreamProcessorOptions, SubagentEvent, SummarizationStrategy, TaskCompletionSignal, TimeoutException, TokenUsage, type ValidationIssue, type ValidationResult, createAnthropicProviderFromEnv, createGadget, createGadgetOutputViewer, createGeminiProviderFromEnv, createHints, createLogger, createMediaOutput, createOpenAIProviderFromEnv, defaultLogger, discoverProviderAdapters, getModelId, getProvider, hasProviderPrefix, iterationProgressHint, parallelGadgetHint, resolveConfig, resolveModel, resolveSubagentModel, resolveValue, resultWithAudio, resultWithFile, resultWithImage, resultWithImages, resultWithMedia, validateAndApplyDefaults, validateGadgetParams };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { ZodType, 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, b as LLMStreamChunk,
|
|
4
|
-
export {
|
|
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 ExecutionContext, Q as GadgetExecuteReturn, U as GadgetExample, A as AbstractGadget, V as ParsedGadgetCall, W as GadgetExecutionResult, X as MediaKind, Y as MediaMetadata, Z as GadgetExecuteResultWithMedia, _ as ProviderAdapter, $ as ModelDescriptor, a0 as ModelSpec, a1 as LLMGenerationOptions, a as LLMStream, a2 as ImageModelSpec, a3 as ImageGenerationOptions, a4 as ImageGenerationResult, a5 as SpeechModelSpec, a6 as SpeechGenerationOptions, a7 as SpeechGenerationResult } from './mock-stream-Cq1Sxezz.js';
|
|
4
|
+
export { aK as AddGadgetParams, aL as AddLLMCallParams, ag as AfterGadgetExecutionAction, ah as AfterGadgetExecutionControllerContext, ai as AfterLLMCallAction, aj as AfterLLMCallControllerContext, ak as AfterLLMErrorAction, ab as AgentBuilder, al as AgentOptions, bh as AudioContentPart, bi as AudioMimeType, bj as AudioSource, aT as BaseExecutionEvent, am as BeforeGadgetExecutionAction, an as BeforeLLMCallAction, ao as ChunkInterceptorContext, aM as CompleteGadgetParams, aN as CompleteLLMCallParams, bk as ContentPart, ap as Controllers, bJ as CostEstimate, c3 as CostReportingLLMist, aH as DEFAULT_COMPACTION_CONFIG, bV as DEFAULT_HINTS, bW as DEFAULT_PROMPTS, aI as DEFAULT_SUMMARIZATION_PROMPT, ac as EventHandlers, aV as ExecutionEvent, aW as ExecutionEventType, aO as ExecutionNode, aP as ExecutionNodeType, aX as GadgetCallEvent, c1 as GadgetClass, aY as GadgetCompleteEvent, aZ as GadgetErrorEvent, a_ as GadgetEvent, c4 as GadgetExecuteResult, aq as GadgetExecutionControllerContext, aQ as GadgetNode, c2 as GadgetOrClass, ar as GadgetParameterInterceptorContext, as as GadgetResultInterceptorContext, c5 as GadgetSkippedEvent, b0 as GadgetStartEvent, aR as GadgetState, bR as HintContext, a8 as HistoryMessage, b1 as HumanInputRequiredEvent, bl as ImageBase64Source, bm as ImageContentPart, bn as ImageMimeType, bo as ImageSource, bp as ImageUrlSource, at as Interceptors, b2 as LLMCallCompleteEvent, au as LLMCallControllerContext, b3 as LLMCallErrorEvent, aS as LLMCallNode, b4 as LLMCallStartEvent, b5 as LLMCallStreamEvent, av as LLMErrorControllerContext, b6 as LLMEvent, bH as LLMMessageBuilder, aJ as LLMistOptions, aw as MessageInterceptorContext, bF as MessageRole, ax 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, bK as ModelFeatures, bQ as ModelIdentifierParser, bL as ModelLimits, bM as ModelPricing, ay as ObserveChunkContext, az as ObserveCompactionContext, aA as ObserveGadgetCompleteContext, aB as ObserveGadgetStartContext, aC as ObserveLLMCallContext, aD as ObserveLLMCompleteContext, aE as ObserveLLMErrorContext, aF as Observers, bS as PromptContext, bT as PromptTemplate, bU as PromptTemplateConfig, bP as ProviderIdentifier, c6 as StoredMedia, b7 as StreamCompleteEvent, aG as SubagentContext, c7 as SubagentStreamEvent, bq as TextContentPart, b8 as TextEvent, b_ as TextGenerationOptions, c8 as TextOnlyAction, c9 as TextOnlyContext, ca as TextOnlyCustomHandler, cb as TextOnlyGadgetConfig, cc as TextOnlyHandler, cd as TextOnlyStrategy, a9 as TrailingMessage, aa as TrailingMessageContext, aU as TreeCompactionEvent, a$ as TreeGadgetSkippedEvent, bN as VisionAnalyzeOptions, bO as VisionAnalyzeResult, br as audioFromBase64, bs as audioFromBuffer, ad as collectEvents, ae as collectText, b$ as complete, c as createMockAdapter, e as createMockClient, h as createMockStream, i as createTextMockStream, bt as detectAudioMimeType, bu as detectImageMimeType, bG as extractMessageText, b9 as filterByDepth, ba as filterByParent, bb as filterRootEvents, g as getMockManager, bc as groupByParent, bv as imageFromBase64, bw as imageFromBuffer, bx as imageFromUrl, by as isAudioPart, bz as isDataUrl, bd as isGadgetEvent, bA as isImagePart, be as isLLMEvent, bf as isRootEvent, bg as isSubagentEvent, bB as isTextPart, m as mockLLM, bI as normalizeMessageContent, bC as parseDataUrl, bX as resolveHintTemplate, bY as resolvePromptTemplate, bZ as resolveRulesTemplate, af as runWithHandlers, c0 as stream, bD as text, bE as toBase64 } from './mock-stream-Cq1Sxezz.js';
|
|
5
5
|
import { Logger, ILogObj } from 'tslog';
|
|
6
6
|
import { MessageCreateParamsStreaming, MessageStreamEvent } from '@anthropic-ai/sdk/resources/messages';
|
|
7
7
|
import OpenAI from 'openai';
|
|
@@ -888,7 +888,7 @@ declare class ConversationManager implements IConversationManager {
|
|
|
888
888
|
constructor(baseMessages: LLMMessage[], initialMessages: LLMMessage[], options?: ConversationManagerOptions);
|
|
889
889
|
addUserMessage(content: MessageContent): void;
|
|
890
890
|
addAssistantMessage(content: string): void;
|
|
891
|
-
addGadgetCallResult(gadgetName: string, parameters: Record<string, unknown>, result: string, media?: GadgetMediaOutput[], mediaIds?: string[]): void;
|
|
891
|
+
addGadgetCallResult(gadgetName: string, parameters: Record<string, unknown>, result: string, invocationId: string, media?: GadgetMediaOutput[], mediaIds?: string[]): void;
|
|
892
892
|
getMessages(): LLMMessage[];
|
|
893
893
|
getHistoryMessages(): LLMMessage[];
|
|
894
894
|
getBaseMessages(): LLMMessage[];
|
|
@@ -1180,15 +1180,6 @@ interface StreamProcessorOptions {
|
|
|
1180
1180
|
logger?: Logger<ILogObj>;
|
|
1181
1181
|
/** Callback for requesting human input during execution */
|
|
1182
1182
|
requestHumanInput?: (question: string) => Promise<string>;
|
|
1183
|
-
/** Whether to stop on gadget errors */
|
|
1184
|
-
stopOnGadgetError?: boolean;
|
|
1185
|
-
/** Custom error recovery logic */
|
|
1186
|
-
canRecoverFromGadgetError?: (context: {
|
|
1187
|
-
error: string;
|
|
1188
|
-
gadgetName: string;
|
|
1189
|
-
errorType: "parse" | "validation" | "execution";
|
|
1190
|
-
parameters?: Record<string, unknown>;
|
|
1191
|
-
}) => boolean | Promise<boolean>;
|
|
1192
1183
|
/** Default gadget timeout */
|
|
1193
1184
|
defaultGadgetTimeoutMs?: number;
|
|
1194
1185
|
/** LLMist client for ExecutionContext.llmist */
|
|
@@ -1201,6 +1192,12 @@ interface StreamProcessorOptions {
|
|
|
1201
1192
|
subagentConfig?: SubagentConfigMap;
|
|
1202
1193
|
/** Callback for subagent gadgets to report subagent events to parent */
|
|
1203
1194
|
onSubagentEvent?: (event: SubagentEvent) => void;
|
|
1195
|
+
/** Execution tree for tracking LLM calls and gadget executions */
|
|
1196
|
+
tree?: ExecutionTree;
|
|
1197
|
+
/** Parent node ID (for gadget nodes created by this processor) */
|
|
1198
|
+
parentNodeId?: NodeId | null;
|
|
1199
|
+
/** Base depth for nodes created by this processor */
|
|
1200
|
+
baseDepth?: number;
|
|
1204
1201
|
}
|
|
1205
1202
|
/**
|
|
1206
1203
|
* Result of stream processing.
|
|
@@ -1250,10 +1247,10 @@ declare class StreamProcessor {
|
|
|
1250
1247
|
private readonly logger;
|
|
1251
1248
|
private readonly parser;
|
|
1252
1249
|
private readonly executor;
|
|
1253
|
-
private readonly
|
|
1254
|
-
private readonly
|
|
1250
|
+
private readonly tree?;
|
|
1251
|
+
private readonly parentNodeId;
|
|
1252
|
+
private readonly baseDepth;
|
|
1255
1253
|
private responseText;
|
|
1256
|
-
private executionHalted;
|
|
1257
1254
|
private observerFailureCount;
|
|
1258
1255
|
/** Gadgets waiting for their dependencies to complete */
|
|
1259
1256
|
private gadgetsAwaitingDependencies;
|
|
@@ -1263,6 +1260,8 @@ declare class StreamProcessor {
|
|
|
1263
1260
|
private failedInvocations;
|
|
1264
1261
|
/** Promises for independent gadgets currently executing (fire-and-forget) */
|
|
1265
1262
|
private inFlightExecutions;
|
|
1263
|
+
/** Queue of completed gadget results ready to be yielded (for real-time streaming) */
|
|
1264
|
+
private completedResultsQueue;
|
|
1266
1265
|
constructor(options: StreamProcessorOptions);
|
|
1267
1266
|
/**
|
|
1268
1267
|
* Process an LLM stream and yield events in real-time.
|
|
@@ -1275,14 +1274,8 @@ declare class StreamProcessor {
|
|
|
1275
1274
|
* The final event is always a StreamCompletionEvent containing metadata.
|
|
1276
1275
|
*/
|
|
1277
1276
|
process(stream: AsyncIterable<LLMStreamChunk>): AsyncGenerator<StreamEvent>;
|
|
1278
|
-
/**
|
|
1279
|
-
* Process a single parsed event (text or gadget call).
|
|
1280
|
-
* @deprecated Use processEventGenerator for real-time streaming
|
|
1281
|
-
*/
|
|
1282
|
-
private processEvent;
|
|
1283
1277
|
/**
|
|
1284
1278
|
* Process a single parsed event, yielding events in real-time.
|
|
1285
|
-
* Generator version of processEvent for streaming support.
|
|
1286
1279
|
*/
|
|
1287
1280
|
private processEventGenerator;
|
|
1288
1281
|
/**
|
|
@@ -1316,17 +1309,26 @@ declare class StreamProcessor {
|
|
|
1316
1309
|
*/
|
|
1317
1310
|
private executeGadgetGenerator;
|
|
1318
1311
|
/**
|
|
1319
|
-
* Execute a gadget and
|
|
1312
|
+
* Execute a gadget and push events to the completed results queue (non-blocking).
|
|
1320
1313
|
* Used for fire-and-forget parallel execution of independent gadgets.
|
|
1314
|
+
* Results are pushed to completedResultsQueue for real-time streaming to the caller.
|
|
1321
1315
|
*/
|
|
1322
1316
|
private executeGadgetAndCollect;
|
|
1323
1317
|
/**
|
|
1324
|
-
*
|
|
1325
|
-
*
|
|
1326
|
-
*
|
|
1327
|
-
|
|
1318
|
+
* Drain all completed results from the queue.
|
|
1319
|
+
* Used to yield results as they complete during stream processing.
|
|
1320
|
+
* @returns Generator that yields all events currently in the queue
|
|
1321
|
+
*/
|
|
1322
|
+
private drainCompletedResults;
|
|
1323
|
+
/**
|
|
1324
|
+
* Wait for all in-flight gadget executions to complete, yielding events in real-time.
|
|
1325
|
+
* Called at stream end to ensure all parallel executions finish.
|
|
1326
|
+
* Results and subagent events are pushed to completedResultsQueue during execution.
|
|
1327
|
+
* This generator yields queued events while polling, enabling real-time display
|
|
1328
|
+
* of subagent activity (LLM calls, nested gadgets) during long-running gadgets.
|
|
1329
|
+
* Clears the inFlightExecutions map after all gadgets complete.
|
|
1328
1330
|
*/
|
|
1329
|
-
private
|
|
1331
|
+
private waitForInFlightExecutions;
|
|
1330
1332
|
/**
|
|
1331
1333
|
* Handle a gadget that cannot execute because a dependency failed.
|
|
1332
1334
|
* Calls the onDependencySkipped controller to allow customization.
|
|
@@ -1355,22 +1357,6 @@ declare class StreamProcessor {
|
|
|
1355
1357
|
* All observers run concurrently and failures are tracked but don't crash.
|
|
1356
1358
|
*/
|
|
1357
1359
|
private runObserversInParallel;
|
|
1358
|
-
/**
|
|
1359
|
-
* Check if execution can recover from an error.
|
|
1360
|
-
*
|
|
1361
|
-
* Returns true if we should continue processing subsequent gadgets, false if we should stop.
|
|
1362
|
-
*
|
|
1363
|
-
* Logic:
|
|
1364
|
-
* - If custom canRecoverFromGadgetError is provided, use it
|
|
1365
|
-
* - Otherwise, use stopOnGadgetError config:
|
|
1366
|
-
* - stopOnGadgetError=true → return false (stop execution)
|
|
1367
|
-
* - stopOnGadgetError=false → return true (continue execution)
|
|
1368
|
-
*/
|
|
1369
|
-
private checkCanRecoverFromError;
|
|
1370
|
-
/**
|
|
1371
|
-
* Determine the type of error from a gadget execution.
|
|
1372
|
-
*/
|
|
1373
|
-
private determineErrorType;
|
|
1374
1360
|
}
|
|
1375
1361
|
|
|
1376
1362
|
/**
|
|
@@ -1744,13 +1730,17 @@ declare class GadgetExecutor {
|
|
|
1744
1730
|
private readonly agentConfig?;
|
|
1745
1731
|
private readonly subagentConfig?;
|
|
1746
1732
|
private readonly onSubagentEvent?;
|
|
1733
|
+
private readonly tree?;
|
|
1734
|
+
private readonly parentNodeId?;
|
|
1735
|
+
private readonly baseDepth?;
|
|
1747
1736
|
private readonly logger;
|
|
1748
1737
|
private readonly errorFormatter;
|
|
1749
1738
|
private readonly argPrefix;
|
|
1750
|
-
constructor(registry: GadgetRegistry, requestHumanInput?: ((question: string) => Promise<string>) | undefined, logger?: Logger<ILogObj>, defaultGadgetTimeoutMs?: number | undefined, errorFormatterOptions?: ErrorFormatterOptions, client?: LLMist | undefined, mediaStore?: MediaStore | undefined, agentConfig?: AgentContextConfig | undefined, subagentConfig?: SubagentConfigMap | undefined, onSubagentEvent?: ((event: SubagentEvent) => void) | undefined);
|
|
1739
|
+
constructor(registry: GadgetRegistry, requestHumanInput?: ((question: string) => Promise<string>) | undefined, logger?: Logger<ILogObj>, defaultGadgetTimeoutMs?: number | undefined, errorFormatterOptions?: ErrorFormatterOptions, client?: LLMist | undefined, mediaStore?: MediaStore | undefined, agentConfig?: AgentContextConfig | undefined, subagentConfig?: SubagentConfigMap | undefined, onSubagentEvent?: ((event: SubagentEvent) => void) | undefined, tree?: ExecutionTree | undefined, parentNodeId?: (NodeId | null) | undefined, baseDepth?: number | undefined);
|
|
1751
1740
|
/**
|
|
1752
1741
|
* Creates a promise that rejects with a TimeoutException after the specified timeout.
|
|
1753
1742
|
* Aborts the provided AbortController before rejecting, allowing gadgets to clean up.
|
|
1743
|
+
* Returns both the promise and a cancel function to clear the timeout when no longer needed.
|
|
1754
1744
|
*/
|
|
1755
1745
|
private createTimeoutPromise;
|
|
1756
1746
|
/**
|
|
@@ -2334,6 +2324,115 @@ declare function createLogger(options?: LoggerOptions): Logger<ILogObj>;
|
|
|
2334
2324
|
*/
|
|
2335
2325
|
declare const defaultLogger: Logger<ILogObj>;
|
|
2336
2326
|
|
|
2327
|
+
/**
|
|
2328
|
+
* Config resolution utility for subagent gadgets.
|
|
2329
|
+
*
|
|
2330
|
+
* Simplifies the common pattern of resolving configuration from multiple sources:
|
|
2331
|
+
* 1. Runtime params (explicit gadget call parameters)
|
|
2332
|
+
* 2. Subagent config (from CLI [subagents.Name] sections)
|
|
2333
|
+
* 3. Parent agent config (model inheritance)
|
|
2334
|
+
* 4. Package defaults
|
|
2335
|
+
*
|
|
2336
|
+
* @module utils/config-resolver
|
|
2337
|
+
*/
|
|
2338
|
+
|
|
2339
|
+
/**
|
|
2340
|
+
* Options for resolving a single config value.
|
|
2341
|
+
*/
|
|
2342
|
+
interface ResolveValueOptions<T> {
|
|
2343
|
+
/** Runtime parameter value (highest priority) */
|
|
2344
|
+
runtime?: T;
|
|
2345
|
+
/** Subagent config key to check */
|
|
2346
|
+
subagentKey?: string;
|
|
2347
|
+
/** Parent config key to check (for inheritance) - "model" or "temperature" */
|
|
2348
|
+
parentKey?: "model" | "temperature";
|
|
2349
|
+
/** Default value (lowest priority) */
|
|
2350
|
+
defaultValue: T;
|
|
2351
|
+
/** Whether "inherit" string means use parent value */
|
|
2352
|
+
handleInherit?: boolean;
|
|
2353
|
+
}
|
|
2354
|
+
/**
|
|
2355
|
+
* Resolve a single configuration value through the priority chain.
|
|
2356
|
+
*
|
|
2357
|
+
* Priority (highest to lowest):
|
|
2358
|
+
* 1. Runtime parameter (if provided and not undefined)
|
|
2359
|
+
* 2. Subagent config (from ctx.subagentConfig[gadgetName][key])
|
|
2360
|
+
* 3. Parent config (from ctx.agentConfig[key], if parentKey specified)
|
|
2361
|
+
* 4. Default value
|
|
2362
|
+
*
|
|
2363
|
+
* Special handling for "inherit" string:
|
|
2364
|
+
* - If handleInherit is true and value is "inherit", falls through to parent/default
|
|
2365
|
+
*
|
|
2366
|
+
* @param ctx - ExecutionContext from gadget execution
|
|
2367
|
+
* @param gadgetName - Name of the subagent gadget (e.g., "BrowseWeb")
|
|
2368
|
+
* @param options - Resolution options
|
|
2369
|
+
* @returns Resolved value
|
|
2370
|
+
*
|
|
2371
|
+
* @example
|
|
2372
|
+
* ```typescript
|
|
2373
|
+
* const model = resolveValue(ctx, "BrowseWeb", {
|
|
2374
|
+
* runtime: params.model,
|
|
2375
|
+
* subagentKey: "model",
|
|
2376
|
+
* parentKey: "model",
|
|
2377
|
+
* defaultValue: "sonnet",
|
|
2378
|
+
* handleInherit: true,
|
|
2379
|
+
* });
|
|
2380
|
+
* ```
|
|
2381
|
+
*/
|
|
2382
|
+
declare function resolveValue<T>(ctx: ExecutionContext, gadgetName: string, options: ResolveValueOptions<T>): T;
|
|
2383
|
+
/**
|
|
2384
|
+
* Bulk configuration resolution for subagent gadgets.
|
|
2385
|
+
*
|
|
2386
|
+
* Takes a map of config keys to their resolution options and returns
|
|
2387
|
+
* a fully resolved configuration object.
|
|
2388
|
+
*
|
|
2389
|
+
* @param ctx - ExecutionContext from gadget execution
|
|
2390
|
+
* @param gadgetName - Name of the subagent gadget (e.g., "BrowseWeb")
|
|
2391
|
+
* @param config - Map of config keys to resolution options
|
|
2392
|
+
* @returns Fully resolved configuration object
|
|
2393
|
+
*
|
|
2394
|
+
* @example
|
|
2395
|
+
* ```typescript
|
|
2396
|
+
* // Before: 27 lines of manual fallback logic
|
|
2397
|
+
* const subagentConfig = ctx.subagentConfig?.Dhalsim ?? {};
|
|
2398
|
+
* const parentModel = ctx.agentConfig?.model;
|
|
2399
|
+
* const model = params.model ?? subagentConfig.model ?? parentModel ?? "sonnet";
|
|
2400
|
+
* const maxIterations = params.maxIterations ?? subagentConfig.maxIterations ?? 15;
|
|
2401
|
+
* const headless = params.headless ?? subagentConfig.headless ?? true;
|
|
2402
|
+
*
|
|
2403
|
+
* // After: One function call
|
|
2404
|
+
* const { model, maxIterations, headless } = resolveConfig(ctx, "BrowseWeb", {
|
|
2405
|
+
* model: { runtime: params.model, subagentKey: "model", parentKey: "model", defaultValue: "sonnet", handleInherit: true },
|
|
2406
|
+
* maxIterations: { runtime: params.maxIterations, subagentKey: "maxIterations", defaultValue: 15 },
|
|
2407
|
+
* headless: { runtime: params.headless, subagentKey: "headless", defaultValue: true },
|
|
2408
|
+
* });
|
|
2409
|
+
* ```
|
|
2410
|
+
*/
|
|
2411
|
+
declare function resolveConfig<T extends Record<string, unknown>>(ctx: ExecutionContext, gadgetName: string, config: {
|
|
2412
|
+
[K in keyof T]: ResolveValueOptions<T[K]>;
|
|
2413
|
+
}): T;
|
|
2414
|
+
/**
|
|
2415
|
+
* Convenience function for resolving subagent model with "inherit" support.
|
|
2416
|
+
*
|
|
2417
|
+
* This is the most common resolution pattern for subagent gadgets:
|
|
2418
|
+
* - Use runtime model if provided
|
|
2419
|
+
* - Check subagent config for model override
|
|
2420
|
+
* - Inherit parent model if configured
|
|
2421
|
+
* - Fall back to default
|
|
2422
|
+
*
|
|
2423
|
+
* @param ctx - ExecutionContext from gadget execution
|
|
2424
|
+
* @param gadgetName - Name of the subagent gadget
|
|
2425
|
+
* @param runtimeModel - Model from gadget parameters
|
|
2426
|
+
* @param defaultModel - Default model if nothing else specified
|
|
2427
|
+
* @returns Resolved model string
|
|
2428
|
+
*
|
|
2429
|
+
* @example
|
|
2430
|
+
* ```typescript
|
|
2431
|
+
* const model = resolveSubagentModel(ctx, "BrowseWeb", params.model, "sonnet");
|
|
2432
|
+
* ```
|
|
2433
|
+
*/
|
|
2434
|
+
declare function resolveSubagentModel(ctx: ExecutionContext, gadgetName: string, runtimeModel: string | undefined, defaultModel: string): string;
|
|
2435
|
+
|
|
2337
2436
|
/**
|
|
2338
2437
|
* Base Provider Adapter
|
|
2339
2438
|
*
|
|
@@ -2621,4 +2720,4 @@ declare class OpenAIChatProvider extends BaseProviderAdapter {
|
|
|
2621
2720
|
}
|
|
2622
2721
|
declare function createOpenAIProviderFromEnv(): OpenAIChatProvider | null;
|
|
2623
2722
|
|
|
2624
|
-
export { AbortException, AbstractGadget, AgentHooks, AnthropicMessagesProvider, CompactionConfig, CompactionContext, CompactionEvent, CompactionManager, CompactionResult, CompactionStats, CompactionStrategy, ConversationManager, type CreateGadgetConfig, ExecutionContext, Gadget, GadgetCallParser, type GadgetConfig, GadgetExample, GadgetExecuteResultWithMedia, GadgetExecuteReturn, GadgetExecutionResult, GadgetExecutor, GadgetMediaOutput, GadgetOutputStore, GadgetRegistry, GeminiGenerativeProvider, HintTemplate, type HintsConfig, HookPresets, HumanInputRequiredException, HybridStrategy, IConversationManager, type IterationHintOptions, LLMGenerationOptions, LLMMessage, LLMStream, LLMStreamChunk, LLMist, type LoggerOptions, type LoggingOptions, MODEL_ALIASES, MediaKind, MediaMetadata, MediaStore, MessageContent, ModelDescriptor, ModelRegistry, ModelSpec, OpenAIChatProvider, type ParallelGadgetHintOptions, ParsedGadgetCall, ProviderAdapter, ResolvedCompactionConfig, SlidingWindowStrategy, type StoredOutput, StreamEvent, type StreamProcessingResult, StreamProcessor, type StreamProcessorOptions, SubagentEvent, SummarizationStrategy, TaskCompletionSignal, TimeoutException, TokenUsage, type ValidationIssue, type ValidationResult, createAnthropicProviderFromEnv, createGadget, createGadgetOutputViewer, createGeminiProviderFromEnv, createHints, createLogger, createMediaOutput, createOpenAIProviderFromEnv, defaultLogger, discoverProviderAdapters, getModelId, getProvider, hasProviderPrefix, iterationProgressHint, parallelGadgetHint, resolveModel, resultWithAudio, resultWithFile, resultWithImage, resultWithImages, resultWithMedia, validateAndApplyDefaults, validateGadgetParams };
|
|
2723
|
+
export { AbortException, AbstractGadget, AgentHooks, AnthropicMessagesProvider, CompactionConfig, CompactionContext, CompactionEvent, CompactionManager, CompactionResult, CompactionStats, CompactionStrategy, ConversationManager, type CreateGadgetConfig, ExecutionContext, ExecutionTree, Gadget, GadgetCallParser, type GadgetConfig, GadgetExample, GadgetExecuteResultWithMedia, GadgetExecuteReturn, GadgetExecutionResult, GadgetExecutor, GadgetMediaOutput, GadgetOutputStore, GadgetRegistry, GeminiGenerativeProvider, HintTemplate, type HintsConfig, HookPresets, HumanInputRequiredException, HybridStrategy, IConversationManager, type IterationHintOptions, LLMGenerationOptions, LLMMessage, LLMStream, LLMStreamChunk, LLMist, type LoggerOptions, type LoggingOptions, MODEL_ALIASES, MediaKind, MediaMetadata, MediaStore, MessageContent, ModelDescriptor, ModelRegistry, ModelSpec, NodeId, OpenAIChatProvider, type ParallelGadgetHintOptions, ParsedGadgetCall, ProviderAdapter, type ResolveValueOptions, ResolvedCompactionConfig, SlidingWindowStrategy, type StoredOutput, StreamEvent, type StreamProcessingResult, StreamProcessor, type StreamProcessorOptions, SubagentEvent, SummarizationStrategy, TaskCompletionSignal, TimeoutException, TokenUsage, type ValidationIssue, type ValidationResult, createAnthropicProviderFromEnv, createGadget, createGadgetOutputViewer, createGeminiProviderFromEnv, createHints, createLogger, createMediaOutput, createOpenAIProviderFromEnv, defaultLogger, discoverProviderAdapters, getModelId, getProvider, hasProviderPrefix, iterationProgressHint, parallelGadgetHint, resolveConfig, resolveModel, resolveSubagentModel, resolveValue, resultWithAudio, resultWithFile, resultWithImage, resultWithImages, resultWithMedia, validateAndApplyDefaults, validateGadgetParams };
|