llmist 1.6.2 → 1.7.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-T3DIKQWU.js → chunk-E52IO2NO.js} +59 -3
- package/dist/chunk-E52IO2NO.js.map +1 -0
- package/dist/{chunk-TDRPJP2Q.js → chunk-JGORHSHC.js} +2 -2
- package/dist/chunk-JGORHSHC.js.map +1 -0
- package/dist/cli.cjs +59 -3
- package/dist/cli.cjs.map +1 -1
- package/dist/cli.js +3 -3
- package/dist/cli.js.map +1 -1
- package/dist/index.cjs +58 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +2 -2
- package/dist/{mock-stream-Cc47j12U.d.cts → mock-stream-BMuFlQI1.d.cts} +38 -1
- package/dist/{mock-stream-Cc47j12U.d.ts → mock-stream-BMuFlQI1.d.ts} +38 -1
- package/dist/testing/index.cjs +58 -2
- package/dist/testing/index.cjs.map +1 -1
- package/dist/testing/index.d.cts +2 -2
- package/dist/testing/index.d.ts +2 -2
- package/dist/testing/index.js +1 -1
- package/package.json +1 -1
- package/dist/chunk-T3DIKQWU.js.map +0 -1
- package/dist/chunk-TDRPJP2Q.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, 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-
|
|
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-BMuFlQI1.cjs';
|
|
4
|
+
export { X as AfterGadgetExecutionAction, Y as AfterGadgetExecutionControllerContext, Z as AfterLLMCallAction, _ as AfterLLMCallControllerContext, $ as AfterLLMErrorAction, O as AgentBuilder, a0 as AgentOptions, a1 as BeforeGadgetExecutionAction, a2 as BeforeLLMCallAction, a3 as ChunkInterceptorContext, a4 as Controllers, aq as CostEstimate, al as DEFAULT_COMPACTION_CONFIG, aA as DEFAULT_HINTS, aB as DEFAULT_PROMPTS, am as DEFAULT_SUMMARIZATION_PROMPT, Q as EventHandlers, aI as GadgetClass, a5 as GadgetExecutionControllerContext, aJ as GadgetOrClass, a6 as GadgetParameterInterceptorContext, a7 as GadgetResultInterceptorContext, aw as HintContext, J as HistoryMessage, a8 as Interceptors, a9 as LLMCallControllerContext, aa as LLMErrorControllerContext, ap as LLMMessageBuilder, ao as LLMRole, an as LLMistOptions, ab as MessageInterceptorContext, aj 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, ar as ModelFeatures, av as ModelIdentifierParser, as as ModelLimits, at as ModelPricing, ac as ObserveChunkContext, ak as ObserveCompactionContext, ad as ObserveGadgetCompleteContext, ae as ObserveGadgetStartContext, af as ObserveLLMCallContext, ag as ObserveLLMCompleteContext, ah as ObserveLLMErrorContext, ai as Observers, ax as PromptConfig, ay as PromptContext, az as PromptTemplate, au as ProviderIdentifier, aF as QuickOptions, aK as TextOnlyAction, aL as TextOnlyContext, aM as TextOnlyCustomHandler, aN as TextOnlyGadgetConfig, aO as TextOnlyHandler, aP as TextOnlyStrategy, K as TrailingMessage, N as TrailingMessageContext, U as collectEvents, V as collectText, aG as complete, c as createMockAdapter, e as createMockClient, h as createMockStream, i as createTextMockStream, g as getMockManager, m as mockLLM, aC as resolveHintTemplate, aD as resolvePromptTemplate, aE as resolveRulesTemplate, W as runWithHandlers, aH as stream } from './mock-stream-BMuFlQI1.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';
|
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 { 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-
|
|
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-BMuFlQI1.js';
|
|
4
|
+
export { X as AfterGadgetExecutionAction, Y as AfterGadgetExecutionControllerContext, Z as AfterLLMCallAction, _ as AfterLLMCallControllerContext, $ as AfterLLMErrorAction, O as AgentBuilder, a0 as AgentOptions, a1 as BeforeGadgetExecutionAction, a2 as BeforeLLMCallAction, a3 as ChunkInterceptorContext, a4 as Controllers, aq as CostEstimate, al as DEFAULT_COMPACTION_CONFIG, aA as DEFAULT_HINTS, aB as DEFAULT_PROMPTS, am as DEFAULT_SUMMARIZATION_PROMPT, Q as EventHandlers, aI as GadgetClass, a5 as GadgetExecutionControllerContext, aJ as GadgetOrClass, a6 as GadgetParameterInterceptorContext, a7 as GadgetResultInterceptorContext, aw as HintContext, J as HistoryMessage, a8 as Interceptors, a9 as LLMCallControllerContext, aa as LLMErrorControllerContext, ap as LLMMessageBuilder, ao as LLMRole, an as LLMistOptions, ab as MessageInterceptorContext, aj 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, ar as ModelFeatures, av as ModelIdentifierParser, as as ModelLimits, at as ModelPricing, ac as ObserveChunkContext, ak as ObserveCompactionContext, ad as ObserveGadgetCompleteContext, ae as ObserveGadgetStartContext, af as ObserveLLMCallContext, ag as ObserveLLMCompleteContext, ah as ObserveLLMErrorContext, ai as Observers, ax as PromptConfig, ay as PromptContext, az as PromptTemplate, au as ProviderIdentifier, aF as QuickOptions, aK as TextOnlyAction, aL as TextOnlyContext, aM as TextOnlyCustomHandler, aN as TextOnlyGadgetConfig, aO as TextOnlyHandler, aP as TextOnlyStrategy, K as TrailingMessage, N as TrailingMessageContext, U as collectEvents, V as collectText, aG as complete, c as createMockAdapter, e as createMockClient, h as createMockStream, i as createTextMockStream, g as getMockManager, m as mockLLM, aC as resolveHintTemplate, aD as resolvePromptTemplate, aE as resolveRulesTemplate, W as runWithHandlers, aH as stream } from './mock-stream-BMuFlQI1.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';
|
package/dist/index.js
CHANGED
|
@@ -5,7 +5,7 @@ import {
|
|
|
5
5
|
iterationProgressHint,
|
|
6
6
|
parallelGadgetHint,
|
|
7
7
|
z
|
|
8
|
-
} from "./chunk-
|
|
8
|
+
} from "./chunk-JGORHSHC.js";
|
|
9
9
|
import {
|
|
10
10
|
AgentBuilder,
|
|
11
11
|
AnthropicMessagesProvider,
|
|
@@ -64,7 +64,7 @@ import {
|
|
|
64
64
|
stream,
|
|
65
65
|
validateAndApplyDefaults,
|
|
66
66
|
validateGadgetParams
|
|
67
|
-
} from "./chunk-
|
|
67
|
+
} from "./chunk-E52IO2NO.js";
|
|
68
68
|
export {
|
|
69
69
|
AgentBuilder,
|
|
70
70
|
AnthropicMessagesProvider,
|
|
@@ -2071,6 +2071,16 @@ type HistoryMessage = {
|
|
|
2071
2071
|
} | {
|
|
2072
2072
|
system: string;
|
|
2073
2073
|
};
|
|
2074
|
+
/**
|
|
2075
|
+
* Context available to trailing message functions.
|
|
2076
|
+
* Provides iteration information for dynamic message generation.
|
|
2077
|
+
*/
|
|
2078
|
+
type TrailingMessageContext = Pick<LLMCallControllerContext, "iteration" | "maxIterations">;
|
|
2079
|
+
/**
|
|
2080
|
+
* Trailing message can be a static string or a function that generates the message.
|
|
2081
|
+
* The function receives context about the current iteration.
|
|
2082
|
+
*/
|
|
2083
|
+
type TrailingMessage = string | ((ctx: TrailingMessageContext) => string);
|
|
2074
2084
|
/**
|
|
2075
2085
|
* Fluent builder for creating agents.
|
|
2076
2086
|
*
|
|
@@ -2101,6 +2111,7 @@ declare class AgentBuilder {
|
|
|
2101
2111
|
private gadgetOutputLimitPercent?;
|
|
2102
2112
|
private compactionConfig?;
|
|
2103
2113
|
private signal?;
|
|
2114
|
+
private trailingMessage?;
|
|
2104
2115
|
constructor(client?: LLMist);
|
|
2105
2116
|
/**
|
|
2106
2117
|
* Set the model to use.
|
|
@@ -2498,6 +2509,28 @@ declare class AgentBuilder {
|
|
|
2498
2509
|
* ```
|
|
2499
2510
|
*/
|
|
2500
2511
|
withSignal(signal: AbortSignal): this;
|
|
2512
|
+
/**
|
|
2513
|
+
* Add an ephemeral trailing message that appears at the end of each LLM request.
|
|
2514
|
+
*
|
|
2515
|
+
* The message is NOT persisted to conversation history - it only appears in the
|
|
2516
|
+
* current LLM call. This is useful for injecting context-specific instructions
|
|
2517
|
+
* or reminders without polluting the conversation history.
|
|
2518
|
+
*
|
|
2519
|
+
* @param message - Static string or function that generates the message
|
|
2520
|
+
* @returns This builder for chaining
|
|
2521
|
+
*
|
|
2522
|
+
* @example
|
|
2523
|
+
* ```typescript
|
|
2524
|
+
* // Static message
|
|
2525
|
+
* .withTrailingMessage("Always respond in JSON format.")
|
|
2526
|
+
*
|
|
2527
|
+
* // Dynamic message based on iteration
|
|
2528
|
+
* .withTrailingMessage((ctx) =>
|
|
2529
|
+
* `[Iteration ${ctx.iteration}/${ctx.maxIterations}] Stay focused on the task.`
|
|
2530
|
+
* )
|
|
2531
|
+
* ```
|
|
2532
|
+
*/
|
|
2533
|
+
withTrailingMessage(message: TrailingMessage): this;
|
|
2501
2534
|
/**
|
|
2502
2535
|
* Add a synthetic gadget call to the conversation history.
|
|
2503
2536
|
*
|
|
@@ -2524,6 +2557,10 @@ declare class AgentBuilder {
|
|
|
2524
2557
|
* ```
|
|
2525
2558
|
*/
|
|
2526
2559
|
withSyntheticGadgetCall(gadgetName: string, parameters: Record<string, unknown>, result: string): this;
|
|
2560
|
+
/**
|
|
2561
|
+
* Compose the final hooks, including trailing message if configured.
|
|
2562
|
+
*/
|
|
2563
|
+
private composeHooks;
|
|
2527
2564
|
/**
|
|
2528
2565
|
* Format parameters as block format with JSON Pointer paths.
|
|
2529
2566
|
*/
|
|
@@ -3227,4 +3264,4 @@ declare function createTextMockStream(text: string, options?: {
|
|
|
3227
3264
|
usage?: MockResponse["usage"];
|
|
3228
3265
|
}): LLMStream;
|
|
3229
3266
|
|
|
3230
|
-
export { type
|
|
3267
|
+
export { type AfterLLMErrorAction as $, type AgentHooks as A, BaseGadget as B, type CompactionStrategy as C, type ModelDescriptor as D, type ModelSpec as E, type LLMGenerationOptions as F, GadgetRegistry as G, type HintTemplate as H, type IConversationManager as I, type HistoryMessage as J, type TrailingMessage as K, type LLMStream as L, MockProviderAdapter as M, type TrailingMessageContext as N, AgentBuilder as O, type ParsedGadgetCall as P, type EventHandlers as Q, type ResolvedCompactionConfig as R, type StreamEvent as S, type TokenUsage as T, collectEvents as U, collectText as V, runWithHandlers as W, type AfterGadgetExecutionAction as X, type AfterGadgetExecutionControllerContext as Y, type AfterLLMCallAction as Z, type AfterLLMCallControllerContext as _, type LLMStreamChunk as a, type AgentOptions as a0, type BeforeGadgetExecutionAction as a1, type BeforeLLMCallAction as a2, type ChunkInterceptorContext as a3, type Controllers as a4, type GadgetExecutionControllerContext as a5, type GadgetParameterInterceptorContext as a6, type GadgetResultInterceptorContext as a7, type Interceptors as a8, type LLMCallControllerContext as a9, DEFAULT_HINTS as aA, DEFAULT_PROMPTS as aB, resolveHintTemplate as aC, resolvePromptTemplate as aD, resolveRulesTemplate as aE, type QuickOptions as aF, complete as aG, stream as aH, type GadgetClass as aI, type GadgetOrClass as aJ, type TextOnlyAction as aK, type TextOnlyContext as aL, type TextOnlyCustomHandler as aM, type TextOnlyGadgetConfig as aN, type TextOnlyHandler as aO, type TextOnlyStrategy as aP, type LLMErrorControllerContext as aa, type MessageInterceptorContext as ab, type ObserveChunkContext as ac, type ObserveGadgetCompleteContext as ad, type ObserveGadgetStartContext as ae, type ObserveLLMCallContext as af, type ObserveLLMCompleteContext as ag, type ObserveLLMErrorContext as ah, type Observers as ai, type MessageTurn as aj, type ObserveCompactionContext as ak, DEFAULT_COMPACTION_CONFIG as al, DEFAULT_SUMMARIZATION_PROMPT as am, type LLMistOptions as an, type LLMRole as ao, LLMMessageBuilder as ap, type CostEstimate as aq, type ModelFeatures as ar, type ModelLimits as as, type ModelPricing as at, type ProviderIdentifier as au, ModelIdentifierParser as av, type HintContext as aw, type PromptConfig as ax, type PromptContext as ay, type PromptTemplate as az, type LLMMessage as b, createMockAdapter as c, MockBuilder as d, createMockClient as e, MockManager as f, getMockManager as g, createMockStream as h, createTextMockStream as i, type MockMatcher as j, type MockMatcherContext as k, type MockOptions as l, mockLLM as m, type MockRegistration as n, type MockResponse as o, type MockStats as p, ModelRegistry as q, type CompactionContext as r, type CompactionResult as s, LLMist as t, type CompactionConfig as u, type CompactionEvent as v, type CompactionStats as w, type GadgetExample as x, type GadgetExecutionResult as y, type ProviderAdapter as z };
|
|
@@ -2071,6 +2071,16 @@ type HistoryMessage = {
|
|
|
2071
2071
|
} | {
|
|
2072
2072
|
system: string;
|
|
2073
2073
|
};
|
|
2074
|
+
/**
|
|
2075
|
+
* Context available to trailing message functions.
|
|
2076
|
+
* Provides iteration information for dynamic message generation.
|
|
2077
|
+
*/
|
|
2078
|
+
type TrailingMessageContext = Pick<LLMCallControllerContext, "iteration" | "maxIterations">;
|
|
2079
|
+
/**
|
|
2080
|
+
* Trailing message can be a static string or a function that generates the message.
|
|
2081
|
+
* The function receives context about the current iteration.
|
|
2082
|
+
*/
|
|
2083
|
+
type TrailingMessage = string | ((ctx: TrailingMessageContext) => string);
|
|
2074
2084
|
/**
|
|
2075
2085
|
* Fluent builder for creating agents.
|
|
2076
2086
|
*
|
|
@@ -2101,6 +2111,7 @@ declare class AgentBuilder {
|
|
|
2101
2111
|
private gadgetOutputLimitPercent?;
|
|
2102
2112
|
private compactionConfig?;
|
|
2103
2113
|
private signal?;
|
|
2114
|
+
private trailingMessage?;
|
|
2104
2115
|
constructor(client?: LLMist);
|
|
2105
2116
|
/**
|
|
2106
2117
|
* Set the model to use.
|
|
@@ -2498,6 +2509,28 @@ declare class AgentBuilder {
|
|
|
2498
2509
|
* ```
|
|
2499
2510
|
*/
|
|
2500
2511
|
withSignal(signal: AbortSignal): this;
|
|
2512
|
+
/**
|
|
2513
|
+
* Add an ephemeral trailing message that appears at the end of each LLM request.
|
|
2514
|
+
*
|
|
2515
|
+
* The message is NOT persisted to conversation history - it only appears in the
|
|
2516
|
+
* current LLM call. This is useful for injecting context-specific instructions
|
|
2517
|
+
* or reminders without polluting the conversation history.
|
|
2518
|
+
*
|
|
2519
|
+
* @param message - Static string or function that generates the message
|
|
2520
|
+
* @returns This builder for chaining
|
|
2521
|
+
*
|
|
2522
|
+
* @example
|
|
2523
|
+
* ```typescript
|
|
2524
|
+
* // Static message
|
|
2525
|
+
* .withTrailingMessage("Always respond in JSON format.")
|
|
2526
|
+
*
|
|
2527
|
+
* // Dynamic message based on iteration
|
|
2528
|
+
* .withTrailingMessage((ctx) =>
|
|
2529
|
+
* `[Iteration ${ctx.iteration}/${ctx.maxIterations}] Stay focused on the task.`
|
|
2530
|
+
* )
|
|
2531
|
+
* ```
|
|
2532
|
+
*/
|
|
2533
|
+
withTrailingMessage(message: TrailingMessage): this;
|
|
2501
2534
|
/**
|
|
2502
2535
|
* Add a synthetic gadget call to the conversation history.
|
|
2503
2536
|
*
|
|
@@ -2524,6 +2557,10 @@ declare class AgentBuilder {
|
|
|
2524
2557
|
* ```
|
|
2525
2558
|
*/
|
|
2526
2559
|
withSyntheticGadgetCall(gadgetName: string, parameters: Record<string, unknown>, result: string): this;
|
|
2560
|
+
/**
|
|
2561
|
+
* Compose the final hooks, including trailing message if configured.
|
|
2562
|
+
*/
|
|
2563
|
+
private composeHooks;
|
|
2527
2564
|
/**
|
|
2528
2565
|
* Format parameters as block format with JSON Pointer paths.
|
|
2529
2566
|
*/
|
|
@@ -3227,4 +3264,4 @@ declare function createTextMockStream(text: string, options?: {
|
|
|
3227
3264
|
usage?: MockResponse["usage"];
|
|
3228
3265
|
}): LLMStream;
|
|
3229
3266
|
|
|
3230
|
-
export { type
|
|
3267
|
+
export { type AfterLLMErrorAction as $, type AgentHooks as A, BaseGadget as B, type CompactionStrategy as C, type ModelDescriptor as D, type ModelSpec as E, type LLMGenerationOptions as F, GadgetRegistry as G, type HintTemplate as H, type IConversationManager as I, type HistoryMessage as J, type TrailingMessage as K, type LLMStream as L, MockProviderAdapter as M, type TrailingMessageContext as N, AgentBuilder as O, type ParsedGadgetCall as P, type EventHandlers as Q, type ResolvedCompactionConfig as R, type StreamEvent as S, type TokenUsage as T, collectEvents as U, collectText as V, runWithHandlers as W, type AfterGadgetExecutionAction as X, type AfterGadgetExecutionControllerContext as Y, type AfterLLMCallAction as Z, type AfterLLMCallControllerContext as _, type LLMStreamChunk as a, type AgentOptions as a0, type BeforeGadgetExecutionAction as a1, type BeforeLLMCallAction as a2, type ChunkInterceptorContext as a3, type Controllers as a4, type GadgetExecutionControllerContext as a5, type GadgetParameterInterceptorContext as a6, type GadgetResultInterceptorContext as a7, type Interceptors as a8, type LLMCallControllerContext as a9, DEFAULT_HINTS as aA, DEFAULT_PROMPTS as aB, resolveHintTemplate as aC, resolvePromptTemplate as aD, resolveRulesTemplate as aE, type QuickOptions as aF, complete as aG, stream as aH, type GadgetClass as aI, type GadgetOrClass as aJ, type TextOnlyAction as aK, type TextOnlyContext as aL, type TextOnlyCustomHandler as aM, type TextOnlyGadgetConfig as aN, type TextOnlyHandler as aO, type TextOnlyStrategy as aP, type LLMErrorControllerContext as aa, type MessageInterceptorContext as ab, type ObserveChunkContext as ac, type ObserveGadgetCompleteContext as ad, type ObserveGadgetStartContext as ae, type ObserveLLMCallContext as af, type ObserveLLMCompleteContext as ag, type ObserveLLMErrorContext as ah, type Observers as ai, type MessageTurn as aj, type ObserveCompactionContext as ak, DEFAULT_COMPACTION_CONFIG as al, DEFAULT_SUMMARIZATION_PROMPT as am, type LLMistOptions as an, type LLMRole as ao, LLMMessageBuilder as ap, type CostEstimate as aq, type ModelFeatures as ar, type ModelLimits as as, type ModelPricing as at, type ProviderIdentifier as au, ModelIdentifierParser as av, type HintContext as aw, type PromptConfig as ax, type PromptContext as ay, type PromptTemplate as az, type LLMMessage as b, createMockAdapter as c, MockBuilder as d, createMockClient as e, MockManager as f, getMockManager as g, createMockStream as h, createTextMockStream as i, type MockMatcher as j, type MockMatcherContext as k, type MockOptions as l, mockLLM as m, type MockRegistration as n, type MockResponse as o, type MockStats as p, ModelRegistry as q, type CompactionContext as r, type CompactionResult as s, LLMist as t, type CompactionConfig as u, type CompactionEvent as v, type CompactionStats as w, type GadgetExample as x, type GadgetExecutionResult as y, type ProviderAdapter as z };
|
package/dist/testing/index.cjs
CHANGED
|
@@ -3872,6 +3872,7 @@ var init_builder = __esm({
|
|
|
3872
3872
|
gadgetOutputLimitPercent;
|
|
3873
3873
|
compactionConfig;
|
|
3874
3874
|
signal;
|
|
3875
|
+
trailingMessage;
|
|
3875
3876
|
constructor(client) {
|
|
3876
3877
|
this.client = client;
|
|
3877
3878
|
}
|
|
@@ -4347,6 +4348,31 @@ var init_builder = __esm({
|
|
|
4347
4348
|
this.signal = signal;
|
|
4348
4349
|
return this;
|
|
4349
4350
|
}
|
|
4351
|
+
/**
|
|
4352
|
+
* Add an ephemeral trailing message that appears at the end of each LLM request.
|
|
4353
|
+
*
|
|
4354
|
+
* The message is NOT persisted to conversation history - it only appears in the
|
|
4355
|
+
* current LLM call. This is useful for injecting context-specific instructions
|
|
4356
|
+
* or reminders without polluting the conversation history.
|
|
4357
|
+
*
|
|
4358
|
+
* @param message - Static string or function that generates the message
|
|
4359
|
+
* @returns This builder for chaining
|
|
4360
|
+
*
|
|
4361
|
+
* @example
|
|
4362
|
+
* ```typescript
|
|
4363
|
+
* // Static message
|
|
4364
|
+
* .withTrailingMessage("Always respond in JSON format.")
|
|
4365
|
+
*
|
|
4366
|
+
* // Dynamic message based on iteration
|
|
4367
|
+
* .withTrailingMessage((ctx) =>
|
|
4368
|
+
* `[Iteration ${ctx.iteration}/${ctx.maxIterations}] Stay focused on the task.`
|
|
4369
|
+
* )
|
|
4370
|
+
* ```
|
|
4371
|
+
*/
|
|
4372
|
+
withTrailingMessage(message) {
|
|
4373
|
+
this.trailingMessage = message;
|
|
4374
|
+
return this;
|
|
4375
|
+
}
|
|
4350
4376
|
/**
|
|
4351
4377
|
* Add a synthetic gadget call to the conversation history.
|
|
4352
4378
|
*
|
|
@@ -4388,6 +4414,36 @@ ${endPrefix}`
|
|
|
4388
4414
|
});
|
|
4389
4415
|
return this;
|
|
4390
4416
|
}
|
|
4417
|
+
/**
|
|
4418
|
+
* Compose the final hooks, including trailing message if configured.
|
|
4419
|
+
*/
|
|
4420
|
+
composeHooks() {
|
|
4421
|
+
if (!this.trailingMessage) {
|
|
4422
|
+
return this.hooks;
|
|
4423
|
+
}
|
|
4424
|
+
const trailingMsg = this.trailingMessage;
|
|
4425
|
+
const existingBeforeLLMCall = this.hooks?.controllers?.beforeLLMCall;
|
|
4426
|
+
const trailingMessageController = async (ctx) => {
|
|
4427
|
+
const result = existingBeforeLLMCall ? await existingBeforeLLMCall(ctx) : { action: "proceed" };
|
|
4428
|
+
if (result.action === "skip") {
|
|
4429
|
+
return result;
|
|
4430
|
+
}
|
|
4431
|
+
const messages = [...result.modifiedOptions?.messages || ctx.options.messages];
|
|
4432
|
+
const content = typeof trailingMsg === "function" ? trailingMsg({ iteration: ctx.iteration, maxIterations: ctx.maxIterations }) : trailingMsg;
|
|
4433
|
+
messages.push({ role: "user", content });
|
|
4434
|
+
return {
|
|
4435
|
+
action: "proceed",
|
|
4436
|
+
modifiedOptions: { ...result.modifiedOptions, messages }
|
|
4437
|
+
};
|
|
4438
|
+
};
|
|
4439
|
+
return {
|
|
4440
|
+
...this.hooks,
|
|
4441
|
+
controllers: {
|
|
4442
|
+
...this.hooks?.controllers,
|
|
4443
|
+
beforeLLMCall: trailingMessageController
|
|
4444
|
+
}
|
|
4445
|
+
};
|
|
4446
|
+
}
|
|
4391
4447
|
/**
|
|
4392
4448
|
* Format parameters as block format with JSON Pointer paths.
|
|
4393
4449
|
*/
|
|
@@ -4449,7 +4505,7 @@ ${endPrefix}`
|
|
|
4449
4505
|
maxIterations: this.maxIterations,
|
|
4450
4506
|
temperature: this.temperature,
|
|
4451
4507
|
logger: this.logger,
|
|
4452
|
-
hooks: this.
|
|
4508
|
+
hooks: this.composeHooks(),
|
|
4453
4509
|
promptConfig: this.promptConfig,
|
|
4454
4510
|
initialMessages: this.initialMessages,
|
|
4455
4511
|
onHumanInputRequired: this.onHumanInputRequired,
|
|
@@ -4553,7 +4609,7 @@ ${endPrefix}`
|
|
|
4553
4609
|
maxIterations: this.maxIterations,
|
|
4554
4610
|
temperature: this.temperature,
|
|
4555
4611
|
logger: this.logger,
|
|
4556
|
-
hooks: this.
|
|
4612
|
+
hooks: this.composeHooks(),
|
|
4557
4613
|
promptConfig: this.promptConfig,
|
|
4558
4614
|
initialMessages: this.initialMessages,
|
|
4559
4615
|
onHumanInputRequired: this.onHumanInputRequired,
|