llmist 1.2.0 → 1.3.1
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/README.md +12 -75
- package/dist/{chunk-KORMY3CD.js → chunk-RZTAKIDE.js} +605 -4
- package/dist/chunk-RZTAKIDE.js.map +1 -0
- package/dist/{chunk-LELPPETT.js → chunk-TFIKR2RK.js} +459 -3
- package/dist/chunk-TFIKR2RK.js.map +1 -0
- package/dist/cli.cjs +628 -23
- package/dist/cli.cjs.map +1 -1
- package/dist/cli.js +49 -22
- package/dist/cli.js.map +1 -1
- package/dist/index.cjs +769 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +354 -32
- package/dist/index.d.ts +354 -32
- package/dist/index.js +177 -2
- package/dist/index.js.map +1 -1
- package/dist/{mock-stream-DKF5yatf.d.cts → mock-stream-DNt-HBTn.d.cts} +525 -79
- package/dist/{mock-stream-DKF5yatf.d.ts → mock-stream-DNt-HBTn.d.ts} +525 -79
- package/dist/testing/index.cjs +1063 -4
- package/dist/testing/index.cjs.map +1 -1
- package/dist/testing/index.d.cts +437 -3
- package/dist/testing/index.d.ts +437 -3
- package/dist/testing/index.js +54 -4
- package/package.json +1 -1
- package/dist/chunk-KORMY3CD.js.map +0 -1
- package/dist/chunk-LELPPETT.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 { A as AgentHooks,
|
|
4
|
-
export {
|
|
3
|
+
import { A as AgentHooks, q as ModelRegistry, I as IConversationManager, b as LLMMessage, S as StreamEvent, T as TokenUsage, G as GadgetRegistry, a as LLMStreamChunk, C as CompactionStrategy, R as ResolvedCompactionConfig, r as CompactionContext, s as CompactionResult, t as LLMist, u as CompactionConfig, v as CompactionEvent, w as CompactionStats, H as HintTemplate, x as GadgetExample, B as BaseGadget, P as ParsedGadgetCall, y as GadgetExecutionResult, z as ProviderAdapter, D as ModelDescriptor, E as ModelSpec, F as LLMGenerationOptions, L as LLMStream } from './mock-stream-DNt-HBTn.cjs';
|
|
4
|
+
export { V as AfterGadgetExecutionAction, W as AfterGadgetExecutionControllerContext, X as AfterLLMCallAction, Y as AfterLLMCallControllerContext, Z as AfterLLMErrorAction, K as AgentBuilder, _ as AgentOptions, $ as BeforeGadgetExecutionAction, a0 as BeforeLLMCallAction, a1 as ChunkInterceptorContext, a2 as Controllers, ao as CostEstimate, aj as DEFAULT_COMPACTION_CONFIG, ay as DEFAULT_HINTS, az as DEFAULT_PROMPTS, ak as DEFAULT_SUMMARIZATION_PROMPT, N as EventHandlers, aG as GadgetClass, a3 as GadgetExecutionControllerContext, aH as GadgetOrClass, a4 as GadgetParameterInterceptorContext, a5 as GadgetResultInterceptorContext, au as HintContext, J as HistoryMessage, a6 as Interceptors, a7 as LLMCallControllerContext, a8 as LLMErrorControllerContext, an as LLMMessageBuilder, am as LLMRole, al as LLMistOptions, a9 as MessageInterceptorContext, ah as MessageTurn, d as MockBuilder, f as MockManager, j as MockMatcher, k as MockMatcherContext, l as MockOptions, M as MockProviderAdapter, n as MockRegistration, o as MockResponse, p as MockStats, ap as ModelFeatures, at as ModelIdentifierParser, aq as ModelLimits, ar as ModelPricing, aa as ObserveChunkContext, ai as ObserveCompactionContext, ab as ObserveGadgetCompleteContext, ac as ObserveGadgetStartContext, ad as ObserveLLMCallContext, ae as ObserveLLMCompleteContext, af as ObserveLLMErrorContext, ag as Observers, av as PromptConfig, aw as PromptContext, ax as PromptTemplate, as as ProviderIdentifier, aD as QuickOptions, aI as TextOnlyAction, aJ as TextOnlyContext, aK as TextOnlyCustomHandler, aL as TextOnlyGadgetConfig, aM as TextOnlyHandler, aN as TextOnlyStrategy, O as collectEvents, Q as collectText, aE as complete, c as createMockAdapter, e as createMockClient, h as createMockStream, i as createTextMockStream, g as getMockManager, m as mockLLM, aA as resolveHintTemplate, aB as resolvePromptTemplate, aC as resolveRulesTemplate, U as runWithHandlers, aF as stream } from './mock-stream-DNt-HBTn.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';
|
|
@@ -500,6 +500,31 @@ declare class HookPresets {
|
|
|
500
500
|
* @see {@link https://github.com/zbigniewsobiecki/llmist/blob/main/docs/HOOKS.md#hookpresetserrorlogging | Full documentation}
|
|
501
501
|
*/
|
|
502
502
|
static errorLogging(): AgentHooks;
|
|
503
|
+
/**
|
|
504
|
+
* Tracks context compaction events.
|
|
505
|
+
*
|
|
506
|
+
* **Output:**
|
|
507
|
+
* - Compaction events with 🗜️ emoji
|
|
508
|
+
* - Strategy name, tokens before/after, and savings
|
|
509
|
+
* - Cumulative statistics
|
|
510
|
+
*
|
|
511
|
+
* **Use cases:**
|
|
512
|
+
* - Monitoring long-running conversations
|
|
513
|
+
* - Understanding when and how compaction occurs
|
|
514
|
+
* - Debugging context management issues
|
|
515
|
+
*
|
|
516
|
+
* **Performance:** Minimal overhead. Simple console output.
|
|
517
|
+
*
|
|
518
|
+
* @returns Hook configuration that can be passed to .withHooks()
|
|
519
|
+
*
|
|
520
|
+
* @example
|
|
521
|
+
* ```typescript
|
|
522
|
+
* await LLMist.createAgent()
|
|
523
|
+
* .withHooks(HookPresets.compactionTracking())
|
|
524
|
+
* .ask("Your prompt");
|
|
525
|
+
* ```
|
|
526
|
+
*/
|
|
527
|
+
static compactionTracking(): AgentHooks;
|
|
503
528
|
/**
|
|
504
529
|
* Returns empty hook configuration for clean output without any logging.
|
|
505
530
|
*
|
|
@@ -687,34 +712,6 @@ declare class HookPresets {
|
|
|
687
712
|
static monitoring(options?: LoggingOptions): AgentHooks;
|
|
688
713
|
}
|
|
689
714
|
|
|
690
|
-
/**
|
|
691
|
-
* Core interfaces for the Agent architecture.
|
|
692
|
-
* These interfaces define the contracts for the composable services that make up the agent system.
|
|
693
|
-
*/
|
|
694
|
-
|
|
695
|
-
/**
|
|
696
|
-
* Manages the conversation history and message building.
|
|
697
|
-
* This interface abstracts conversation state management from the orchestration logic.
|
|
698
|
-
*/
|
|
699
|
-
interface IConversationManager {
|
|
700
|
-
/**
|
|
701
|
-
* Adds a user message to the conversation.
|
|
702
|
-
*/
|
|
703
|
-
addUserMessage(content: string): void;
|
|
704
|
-
/**
|
|
705
|
-
* Adds an assistant message to the conversation.
|
|
706
|
-
*/
|
|
707
|
-
addAssistantMessage(content: string): void;
|
|
708
|
-
/**
|
|
709
|
-
* Adds a gadget call and its result to the conversation.
|
|
710
|
-
*/
|
|
711
|
-
addGadgetCall(gadgetName: string, parameters: Record<string, unknown>, result: string): void;
|
|
712
|
-
/**
|
|
713
|
-
* Gets the complete conversation history including base messages (system prompts, gadget instructions).
|
|
714
|
-
*/
|
|
715
|
-
getMessages(): LLMMessage[];
|
|
716
|
-
}
|
|
717
|
-
|
|
718
715
|
/**
|
|
719
716
|
* ConversationManager handles conversation state and message building.
|
|
720
717
|
* Extracted from AgentLoop to follow Single Responsibility Principle.
|
|
@@ -738,12 +735,18 @@ interface ConversationManagerOptions {
|
|
|
738
735
|
declare class ConversationManager implements IConversationManager {
|
|
739
736
|
private readonly baseMessages;
|
|
740
737
|
private readonly initialMessages;
|
|
741
|
-
private
|
|
738
|
+
private historyBuilder;
|
|
739
|
+
private readonly startPrefix?;
|
|
740
|
+
private readonly endPrefix?;
|
|
741
|
+
private readonly argPrefix?;
|
|
742
742
|
constructor(baseMessages: LLMMessage[], initialMessages: LLMMessage[], options?: ConversationManagerOptions);
|
|
743
743
|
addUserMessage(content: string): void;
|
|
744
744
|
addAssistantMessage(content: string): void;
|
|
745
745
|
addGadgetCall(gadgetName: string, parameters: Record<string, unknown>, result: string): void;
|
|
746
746
|
getMessages(): LLMMessage[];
|
|
747
|
+
getHistoryMessages(): LLMMessage[];
|
|
748
|
+
getBaseMessages(): LLMMessage[];
|
|
749
|
+
replaceHistory(newHistory: LLMMessage[]): void;
|
|
747
750
|
}
|
|
748
751
|
|
|
749
752
|
/**
|
|
@@ -968,6 +971,325 @@ declare class GadgetOutputStore {
|
|
|
968
971
|
private generateId;
|
|
969
972
|
}
|
|
970
973
|
|
|
974
|
+
/**
|
|
975
|
+
* Sliding Window Compaction Strategy
|
|
976
|
+
*
|
|
977
|
+
* A fast, no-LLM-call strategy that simply keeps the most recent N turns
|
|
978
|
+
* and drops older ones. Best for:
|
|
979
|
+
* - Long-running conversations where older context becomes irrelevant
|
|
980
|
+
* - Scenarios requiring minimal latency
|
|
981
|
+
* - As a fallback when summarization is too slow
|
|
982
|
+
*/
|
|
983
|
+
|
|
984
|
+
/**
|
|
985
|
+
* Sliding window strategy - keeps recent turns, drops older ones.
|
|
986
|
+
*
|
|
987
|
+
* This strategy:
|
|
988
|
+
* 1. Groups messages into logical turns (user + assistant pairs)
|
|
989
|
+
* 2. Keeps the `preserveRecentTurns` most recent turns
|
|
990
|
+
* 3. Inserts a truncation marker at the beginning
|
|
991
|
+
* 4. Requires no LLM call - very fast
|
|
992
|
+
*/
|
|
993
|
+
declare class SlidingWindowStrategy implements CompactionStrategy {
|
|
994
|
+
readonly name = "sliding-window";
|
|
995
|
+
compact(messages: LLMMessage[], config: ResolvedCompactionConfig, context: CompactionContext): Promise<CompactionResult>;
|
|
996
|
+
}
|
|
997
|
+
|
|
998
|
+
/**
|
|
999
|
+
* Summarization Compaction Strategy
|
|
1000
|
+
*
|
|
1001
|
+
* Uses an LLM to summarize older conversation messages into a concise summary.
|
|
1002
|
+
* Best for:
|
|
1003
|
+
* - Tasks where historical context matters
|
|
1004
|
+
* - Complex multi-step reasoning
|
|
1005
|
+
* - When accuracy is more important than speed
|
|
1006
|
+
*/
|
|
1007
|
+
|
|
1008
|
+
/**
|
|
1009
|
+
* Summarization strategy - uses LLM to compress conversation history.
|
|
1010
|
+
*
|
|
1011
|
+
* This strategy:
|
|
1012
|
+
* 1. Groups messages into logical turns
|
|
1013
|
+
* 2. Keeps recent turns intact
|
|
1014
|
+
* 3. Summarizes older turns using LLM
|
|
1015
|
+
* 4. Returns summary + recent turns
|
|
1016
|
+
*/
|
|
1017
|
+
declare class SummarizationStrategy implements CompactionStrategy {
|
|
1018
|
+
readonly name = "summarization";
|
|
1019
|
+
compact(messages: LLMMessage[], config: ResolvedCompactionConfig, context: CompactionContext): Promise<CompactionResult>;
|
|
1020
|
+
/**
|
|
1021
|
+
* Formats messages into a readable conversation format for summarization.
|
|
1022
|
+
*/
|
|
1023
|
+
private formatTurnsForSummary;
|
|
1024
|
+
/**
|
|
1025
|
+
* Generates a summary using the configured LLM.
|
|
1026
|
+
*/
|
|
1027
|
+
private generateSummary;
|
|
1028
|
+
}
|
|
1029
|
+
|
|
1030
|
+
/**
|
|
1031
|
+
* Hybrid Compaction Strategy
|
|
1032
|
+
*
|
|
1033
|
+
* Combines sliding window and summarization for the best of both worlds:
|
|
1034
|
+
* 1. Identifies which turns to compact vs keep (like sliding window)
|
|
1035
|
+
* 2. Summarizes the older turns (like summarization)
|
|
1036
|
+
* 3. Returns summary + recent turns intact
|
|
1037
|
+
*
|
|
1038
|
+
* Falls back to sliding window if there are too few turns to summarize.
|
|
1039
|
+
*/
|
|
1040
|
+
|
|
1041
|
+
/**
|
|
1042
|
+
* Hybrid strategy - summarizes old turns + keeps recent turns.
|
|
1043
|
+
*
|
|
1044
|
+
* This is the recommended default strategy as it:
|
|
1045
|
+
* - Preserves important historical context via summarization
|
|
1046
|
+
* - Keeps recent conversation turns verbatim for continuity
|
|
1047
|
+
* - Falls back gracefully to sliding window when appropriate
|
|
1048
|
+
*/
|
|
1049
|
+
declare class HybridStrategy implements CompactionStrategy {
|
|
1050
|
+
readonly name = "hybrid";
|
|
1051
|
+
private readonly slidingWindow;
|
|
1052
|
+
private readonly summarization;
|
|
1053
|
+
compact(messages: LLMMessage[], config: ResolvedCompactionConfig, context: CompactionContext): Promise<CompactionResult>;
|
|
1054
|
+
}
|
|
1055
|
+
|
|
1056
|
+
/**
|
|
1057
|
+
* CompactionManager - Central orchestrator for context compaction.
|
|
1058
|
+
*
|
|
1059
|
+
* Monitors token usage and coordinates compaction strategies to keep
|
|
1060
|
+
* conversation context within model limits.
|
|
1061
|
+
*/
|
|
1062
|
+
|
|
1063
|
+
/**
|
|
1064
|
+
* Pre-computed token counts to avoid redundant counting.
|
|
1065
|
+
* Passed from checkAndCompact to compact for efficiency.
|
|
1066
|
+
*/
|
|
1067
|
+
interface PrecomputedTokens {
|
|
1068
|
+
historyMessages: LLMMessage[];
|
|
1069
|
+
baseMessages: LLMMessage[];
|
|
1070
|
+
historyTokens: number;
|
|
1071
|
+
baseTokens: number;
|
|
1072
|
+
currentTokens: number;
|
|
1073
|
+
}
|
|
1074
|
+
/**
|
|
1075
|
+
* CompactionManager orchestrates context compaction for an agent.
|
|
1076
|
+
*
|
|
1077
|
+
* It:
|
|
1078
|
+
* - Monitors token usage before each LLM call
|
|
1079
|
+
* - Triggers compaction when threshold is exceeded
|
|
1080
|
+
* - Coordinates with ConversationManager to update history
|
|
1081
|
+
* - Tracks statistics for observability
|
|
1082
|
+
*/
|
|
1083
|
+
declare class CompactionManager {
|
|
1084
|
+
private readonly client;
|
|
1085
|
+
private readonly model;
|
|
1086
|
+
private readonly config;
|
|
1087
|
+
private readonly strategy;
|
|
1088
|
+
private modelLimits?;
|
|
1089
|
+
private totalCompactions;
|
|
1090
|
+
private totalTokensSaved;
|
|
1091
|
+
private lastTokenCount;
|
|
1092
|
+
constructor(client: LLMist, model: string, config?: CompactionConfig);
|
|
1093
|
+
/**
|
|
1094
|
+
* Check if compaction is needed and perform it if so.
|
|
1095
|
+
*
|
|
1096
|
+
* @param conversation - The conversation manager to compact
|
|
1097
|
+
* @param iteration - Current agent iteration (for event metadata)
|
|
1098
|
+
* @returns CompactionEvent if compaction was performed, null otherwise
|
|
1099
|
+
*/
|
|
1100
|
+
checkAndCompact(conversation: IConversationManager, iteration: number): Promise<CompactionEvent | null>;
|
|
1101
|
+
/**
|
|
1102
|
+
* Force compaction regardless of threshold.
|
|
1103
|
+
*
|
|
1104
|
+
* @param conversation - The conversation manager to compact
|
|
1105
|
+
* @param iteration - Current agent iteration (for event metadata). Use -1 for manual compaction.
|
|
1106
|
+
* @param precomputed - Optional pre-computed token counts (passed from checkAndCompact for efficiency)
|
|
1107
|
+
* @returns CompactionEvent with compaction details
|
|
1108
|
+
*/
|
|
1109
|
+
compact(conversation: IConversationManager, iteration: number, precomputed?: PrecomputedTokens): Promise<CompactionEvent | null>;
|
|
1110
|
+
/**
|
|
1111
|
+
* Get compaction statistics.
|
|
1112
|
+
*/
|
|
1113
|
+
getStats(): CompactionStats;
|
|
1114
|
+
/**
|
|
1115
|
+
* Check if compaction is enabled.
|
|
1116
|
+
*/
|
|
1117
|
+
isEnabled(): boolean;
|
|
1118
|
+
}
|
|
1119
|
+
|
|
1120
|
+
/**
|
|
1121
|
+
* LLM Assistance Hints System
|
|
1122
|
+
*
|
|
1123
|
+
* Provides reusable hook factories that inject helpful context and coaching
|
|
1124
|
+
* messages to guide LLM behavior during agentic execution.
|
|
1125
|
+
*
|
|
1126
|
+
* ## Two Types of Hints
|
|
1127
|
+
*
|
|
1128
|
+
* 1. **Proactive (beforeLLMCall)**: Inject context before LLM generates response
|
|
1129
|
+
* - Example: Iteration progress ("You're on iteration 3/10")
|
|
1130
|
+
*
|
|
1131
|
+
* 2. **Reactive (afterLLMCall)**: Coach based on what LLM did
|
|
1132
|
+
* - Example: "Tip: You can call multiple gadgets in parallel"
|
|
1133
|
+
*
|
|
1134
|
+
* ## Usage
|
|
1135
|
+
*
|
|
1136
|
+
* ```typescript
|
|
1137
|
+
* import { createHints, iterationProgressHint, parallelGadgetHint } from "llmist";
|
|
1138
|
+
*
|
|
1139
|
+
* // Option 1: Use individual hints
|
|
1140
|
+
* const agent = new AgentBuilder()
|
|
1141
|
+
* .withHooks(HookPresets.merge(
|
|
1142
|
+
* iterationProgressHint({ timing: "late" }),
|
|
1143
|
+
* parallelGadgetHint(),
|
|
1144
|
+
* ))
|
|
1145
|
+
* .build();
|
|
1146
|
+
*
|
|
1147
|
+
* // Option 2: Use convenience factory
|
|
1148
|
+
* const agent = new AgentBuilder()
|
|
1149
|
+
* .withHooks(createHints({
|
|
1150
|
+
* iterationProgress: { timing: "late" },
|
|
1151
|
+
* parallelGadgets: true,
|
|
1152
|
+
* }))
|
|
1153
|
+
* .build();
|
|
1154
|
+
* ```
|
|
1155
|
+
*
|
|
1156
|
+
* @module agent/hints
|
|
1157
|
+
*/
|
|
1158
|
+
|
|
1159
|
+
/**
|
|
1160
|
+
* Options for iteration progress hint.
|
|
1161
|
+
*/
|
|
1162
|
+
interface IterationHintOptions {
|
|
1163
|
+
/**
|
|
1164
|
+
* When to show the hint.
|
|
1165
|
+
* - "always": Show on every iteration
|
|
1166
|
+
* - "late": Show only when >= 50% through iterations
|
|
1167
|
+
* - "urgent": Show only when >= 80% through iterations
|
|
1168
|
+
* @default "always"
|
|
1169
|
+
*/
|
|
1170
|
+
timing?: "always" | "late" | "urgent";
|
|
1171
|
+
/**
|
|
1172
|
+
* Whether to include urgency indicators for late iterations.
|
|
1173
|
+
* Adds extra text when running low on iterations.
|
|
1174
|
+
* @default true
|
|
1175
|
+
*/
|
|
1176
|
+
showUrgency?: boolean;
|
|
1177
|
+
/**
|
|
1178
|
+
* Custom template. Supports placeholders: {iteration}, {maxIterations}, {remaining}
|
|
1179
|
+
* Or a function receiving HintContext.
|
|
1180
|
+
* @default DEFAULT_HINTS.iterationProgressHint
|
|
1181
|
+
*/
|
|
1182
|
+
template?: HintTemplate;
|
|
1183
|
+
}
|
|
1184
|
+
/**
|
|
1185
|
+
* Options for parallel gadget usage hint.
|
|
1186
|
+
*/
|
|
1187
|
+
interface ParallelGadgetHintOptions {
|
|
1188
|
+
/**
|
|
1189
|
+
* Minimum number of gadget calls to consider "efficient".
|
|
1190
|
+
* If response has fewer calls, hint will suggest parallelization.
|
|
1191
|
+
* @default 2
|
|
1192
|
+
*/
|
|
1193
|
+
minGadgetsForEfficiency?: number;
|
|
1194
|
+
/**
|
|
1195
|
+
* Custom message when single gadget detected.
|
|
1196
|
+
* @default DEFAULT_HINTS.parallelGadgetsHint
|
|
1197
|
+
*/
|
|
1198
|
+
message?: string;
|
|
1199
|
+
/**
|
|
1200
|
+
* Whether to enable this hint.
|
|
1201
|
+
* @default true
|
|
1202
|
+
*/
|
|
1203
|
+
enabled?: boolean;
|
|
1204
|
+
}
|
|
1205
|
+
/**
|
|
1206
|
+
* Combined hints configuration for createHints().
|
|
1207
|
+
*/
|
|
1208
|
+
interface HintsConfig {
|
|
1209
|
+
/**
|
|
1210
|
+
* Enable iteration progress hints.
|
|
1211
|
+
* Pass `true` for defaults, or options object for customization.
|
|
1212
|
+
*/
|
|
1213
|
+
iterationProgress?: boolean | IterationHintOptions;
|
|
1214
|
+
/**
|
|
1215
|
+
* Enable parallel gadget hints.
|
|
1216
|
+
* Pass `true` for defaults, or options object for customization.
|
|
1217
|
+
*/
|
|
1218
|
+
parallelGadgets?: boolean | ParallelGadgetHintOptions;
|
|
1219
|
+
/**
|
|
1220
|
+
* Additional custom hooks to merge.
|
|
1221
|
+
*/
|
|
1222
|
+
custom?: AgentHooks[];
|
|
1223
|
+
}
|
|
1224
|
+
/**
|
|
1225
|
+
* Creates a proactive hint that informs the LLM about iteration progress.
|
|
1226
|
+
*
|
|
1227
|
+
* This hint is injected before each LLM call (via beforeLLMCall controller),
|
|
1228
|
+
* helping the LLM understand how much "budget" remains for completing the task.
|
|
1229
|
+
*
|
|
1230
|
+
* @param options - Configuration options
|
|
1231
|
+
* @returns AgentHooks that can be merged with other hooks
|
|
1232
|
+
*
|
|
1233
|
+
* @example
|
|
1234
|
+
* ```typescript
|
|
1235
|
+
* // Basic usage - show on every iteration
|
|
1236
|
+
* const hooks = iterationProgressHint();
|
|
1237
|
+
*
|
|
1238
|
+
* // Show only when running low on iterations
|
|
1239
|
+
* const hooks = iterationProgressHint({ timing: "late" });
|
|
1240
|
+
*
|
|
1241
|
+
* // Custom template
|
|
1242
|
+
* const hooks = iterationProgressHint({
|
|
1243
|
+
* template: "Turn {iteration} of {maxIterations}. {remaining} turns left.",
|
|
1244
|
+
* });
|
|
1245
|
+
* ```
|
|
1246
|
+
*/
|
|
1247
|
+
declare function iterationProgressHint(options?: IterationHintOptions): AgentHooks;
|
|
1248
|
+
/**
|
|
1249
|
+
* Creates a reactive hint that encourages parallel gadget usage.
|
|
1250
|
+
*
|
|
1251
|
+
* This hint analyzes the LLM's response and, if only a single gadget was called,
|
|
1252
|
+
* appends a reminder that multiple gadgets can be used in parallel for efficiency.
|
|
1253
|
+
*
|
|
1254
|
+
* @param options - Configuration options
|
|
1255
|
+
* @returns AgentHooks that can be merged with other hooks
|
|
1256
|
+
*
|
|
1257
|
+
* @example
|
|
1258
|
+
* ```typescript
|
|
1259
|
+
* // Basic usage
|
|
1260
|
+
* const hooks = parallelGadgetHint();
|
|
1261
|
+
*
|
|
1262
|
+
* // Custom threshold and message
|
|
1263
|
+
* const hooks = parallelGadgetHint({
|
|
1264
|
+
* minGadgetsForEfficiency: 3,
|
|
1265
|
+
* message: "Consider calling multiple gadgets at once!",
|
|
1266
|
+
* });
|
|
1267
|
+
* ```
|
|
1268
|
+
*/
|
|
1269
|
+
declare function parallelGadgetHint(options?: ParallelGadgetHintOptions): AgentHooks;
|
|
1270
|
+
/**
|
|
1271
|
+
* Creates combined hints from a configuration object.
|
|
1272
|
+
*
|
|
1273
|
+
* This is a convenience function that creates and merges multiple hints
|
|
1274
|
+
* based on a simple configuration object.
|
|
1275
|
+
*
|
|
1276
|
+
* @param config - Configuration for which hints to enable
|
|
1277
|
+
* @returns Merged AgentHooks
|
|
1278
|
+
*
|
|
1279
|
+
* @example
|
|
1280
|
+
* ```typescript
|
|
1281
|
+
* const hooks = createHints({
|
|
1282
|
+
* iterationProgress: { timing: "late" },
|
|
1283
|
+
* parallelGadgets: true,
|
|
1284
|
+
* });
|
|
1285
|
+
*
|
|
1286
|
+
* const agent = new AgentBuilder()
|
|
1287
|
+
* .withHooks(HookPresets.merge(existingHooks, hooks))
|
|
1288
|
+
* .build();
|
|
1289
|
+
* ```
|
|
1290
|
+
*/
|
|
1291
|
+
declare function createHints(config: HintsConfig): AgentHooks;
|
|
1292
|
+
|
|
971
1293
|
/**
|
|
972
1294
|
* Model shortcuts and aliases for more expressive DX.
|
|
973
1295
|
*
|
|
@@ -1841,4 +2163,4 @@ declare class OpenAIChatProvider extends BaseProviderAdapter {
|
|
|
1841
2163
|
}
|
|
1842
2164
|
declare function createOpenAIProviderFromEnv(): OpenAIChatProvider | null;
|
|
1843
2165
|
|
|
1844
|
-
export { AgentHooks, AnthropicMessagesProvider, BaseGadget, BreakLoopException, ConversationManager, type CreateGadgetConfig, Gadget, type GadgetConfig, GadgetExample, GadgetExecutionResult, GadgetExecutor, GadgetOutputStore, GadgetRegistry, GeminiGenerativeProvider, HookPresets, HumanInputException,
|
|
2166
|
+
export { AgentHooks, AnthropicMessagesProvider, BaseGadget, BreakLoopException, CompactionConfig, CompactionContext, CompactionEvent, CompactionManager, CompactionResult, CompactionStats, CompactionStrategy, ConversationManager, type CreateGadgetConfig, Gadget, type GadgetConfig, GadgetExample, GadgetExecutionResult, GadgetExecutor, GadgetOutputStore, GadgetRegistry, GeminiGenerativeProvider, HintTemplate, type HintsConfig, HookPresets, HumanInputException, HybridStrategy, IConversationManager, type IterationHintOptions, LLMGenerationOptions, LLMMessage, LLMStream, LLMStreamChunk, LLMist, type LoggerOptions, type LoggingOptions, MODEL_ALIASES, ModelDescriptor, ModelRegistry, ModelSpec, OpenAIChatProvider, type ParallelGadgetHintOptions, ParsedGadgetCall, ProviderAdapter, ResolvedCompactionConfig, SlidingWindowStrategy, type StoredOutput, StreamEvent, StreamParser, type StreamProcessingResult, StreamProcessor, type StreamProcessorOptions, SummarizationStrategy, TokenUsage, type ValidationIssue, type ValidationResult, createAnthropicProviderFromEnv, createGadget, createGadgetOutputViewer, createGeminiProviderFromEnv, createHints, createLogger, createOpenAIProviderFromEnv, defaultLogger, discoverProviderAdapters, getModelId, getProvider, hasProviderPrefix, iterationProgressHint, parallelGadgetHint, resolveModel, validateAndApplyDefaults, validateGadgetParams };
|