llm-exe 2.3.11 → 3.0.0-beta.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/dist/index.d.mts CHANGED
@@ -68,20 +68,18 @@ type OpenAIConversationModelName = "davinci" | "text-curie-001" | "text-babbage-
68
68
  type OpenAIEmbeddingModelName = "text-embedding-ada-002";
69
69
  type OpenAIModelName = OpenAIChatModelName | OpenAIConversationModelName | OpenAIEmbeddingModelName;
70
70
 
71
- type ParserInput = string | OutputResult;
72
71
  /**
73
72
  * BaseParser is an abstract class for parsing text and enforcing JSON schema on the parsed data.
74
73
  */
75
- declare abstract class BaseParser<T = any> {
74
+ declare abstract class BaseParser<T = any, TInput = string> {
76
75
  name: string;
77
- options: BaseParserOptions;
78
76
  target: "text" | "function_call";
79
77
  /**
80
78
  * Create a new BaseParser.
81
79
  * @param name - The name of the parser.
82
- * @param options - options
80
+ * @param target - Whether the parser consumes text or function-call output.
83
81
  */
84
- constructor(name: string, options?: BaseParserOptions, target?: "text" | "function_call");
82
+ constructor(name: string, target?: "text" | "function_call");
85
83
  /**
86
84
  * Parse the given text and return the parsed data.
87
85
  * @abstract
@@ -89,59 +87,128 @@ declare abstract class BaseParser<T = any> {
89
87
  * @param [attributes] - Optional attributes to use during parsing.
90
88
  * @returns The parsed data.
91
89
  */
92
- abstract parse(text: ParserInput, attributes?: Record<string, any>): T;
90
+ abstract parse(text: TInput, attributes?: Record<string, any>): T;
93
91
  }
94
- declare abstract class BaseParserWithJson<S extends JSONSchema | undefined = undefined, T = S extends JSONSchema ? FromSchema<S> : Record<string, any>> extends BaseParser<T> {
92
+ declare abstract class BaseParserWithJson<S extends JSONSchema | undefined = undefined, T = S extends JSONSchema ? FromSchema<S> : Record<string, any>, TInput = string> extends BaseParser<T, TInput> {
95
93
  schema: S;
96
94
  validateSchema: boolean;
97
- /**
98
- * Create a new BaseParser.
99
- * @param name - The name of the parser.
100
- * @param options - options
101
- */
102
- constructor(name: string, options: BaseParserOptionsWithSchema<S>);
95
+ constructor(name: string, options: JsonParserOptions<S>);
103
96
  }
104
97
 
105
- interface StringParserOptions extends BaseParserOptions {
106
- }
98
+ /**
99
+ * v3 parser contract:
100
+ * Category: pass-through
101
+ * Mode: string pass-through
102
+ *
103
+ * Accepts any string and returns it exactly.
104
+ * Throws LlmExeError(parser.parse_failed) for non-string input.
105
+ * Executor output normalization owns OutputResult handling before parser
106
+ * invocation.
107
+ *
108
+ */
107
109
  declare class StringParser extends BaseParser<string> {
108
- constructor(options?: StringParserOptions);
109
- parse(text: string | OutputResult, _options?: Record<string, any>): string;
110
+ constructor();
111
+ parse(text: string, _attributes?: Record<string, any>): string;
110
112
  }
111
113
 
112
- interface BooleanParserOptions extends BaseParserOptions {
113
- }
114
+ /**
115
+ * v3 parser contract:
116
+ * Category: strict
117
+ * Mode: whole-output
118
+ *
119
+ * Accepts only documented boolean literals after trim/lowercase.
120
+ * Returns true/false only when input is recognized.
121
+ * Throws LlmExeError(parser.parse_failed) for empty, invalid-type, or
122
+ * unrecognized input. Does not extract booleans from prose.
123
+ * Error context does not include input content unless LLM_EXE_DEBUG is enabled.
124
+ *
125
+ */
114
126
  declare class BooleanParser extends BaseParser<boolean> {
115
- constructor(options?: BooleanParserOptions);
116
- parse(text: string): boolean;
127
+ constructor();
128
+ private getInputErrorContext;
129
+ parse(text: string, _attributes?: Record<string, any>): boolean;
117
130
  }
118
131
 
119
- interface NumberParserOptions extends BaseParserOptions {
132
+ type NumberParserMatch = "extract" | "whole";
133
+ interface NumberParserOptions {
134
+ match?: NumberParserMatch;
120
135
  }
136
+ /**
137
+ * v3 parser contract:
138
+ * Category: extractor
139
+ * Mode: numeric token extraction
140
+ *
141
+ * Extracts one documented numeric token from text. Pass match: "whole" to
142
+ * require the input to consist of exactly one numeric token (after trim) with
143
+ * no surrounding prose.
144
+ *
145
+ * Throws LlmExeError(parser.parse_failed) for empty input, no numeric token,
146
+ * multiple numeric tokens, invalid conversion. Invalid input type throws
147
+ * LlmExeError(parser.invalid_input).
148
+ */
121
149
  declare class NumberParser extends BaseParser<number> {
150
+ private match;
122
151
  constructor(options?: NumberParserOptions);
123
- parse(text: string): number;
152
+ parse(text: string, _attributes?: Record<string, any>): number;
124
153
  }
125
154
 
126
- declare class JsonParser<S extends JSONSchema | undefined = undefined> extends BaseParserWithJson<S> {
127
- constructor(options?: BaseParserOptionsWithSchema<S>);
128
- parse(text: string, _attributes?: Record<string, any>): ParserOutput<BaseParserWithJson<S>>;
155
+ type JsonParserInput = string | Record<string, unknown> | unknown[];
156
+ type JsonParserOutput<S extends JSONSchema | undefined> = S extends JSONSchema ? FromSchema<S> : Record<string, any>;
157
+ declare class JsonParser<S extends JSONSchema | undefined = undefined> extends BaseParserWithJson<S, JsonParserOutput<S>, JsonParserInput> {
158
+ private shouldValidateSchema;
159
+ constructor(options?: JsonParserOptions<S>);
160
+ /**
161
+ * v3 parser contract:
162
+ * Category: strict
163
+ * Mode: whole-output
164
+ *
165
+ * Parses strict JSON object/array output only. Invalid JSON, empty input,
166
+ * JSON primitives, and non-plain runtime objects throw typed parser errors.
167
+ * Schema validation is on by default when a schema is provided unless
168
+ * validateSchema: false is explicitly set.
169
+ *
170
+ */
171
+ parse(text: JsonParserInput, _attributes?: Record<string, any>): JsonParserOutput<S>;
129
172
  }
130
173
 
131
174
  declare class ListToJsonParser<S extends JSONSchema | undefined = undefined> extends BaseParserWithJson<S> {
132
175
  private keyTransform;
176
+ private shouldValidateSchema;
133
177
  constructor(options?: ListToJsonParserOptions<S>);
178
+ /**
179
+ * v3 parser contract:
180
+ * Category: converter
181
+ * Mode: line-oriented format conversion
182
+ *
183
+ * Uses the shared list boundary. Parses normalized lines as key/value pairs
184
+ * split at the first colon. Duplicate keys throw because object output would
185
+ * overwrite data.
186
+ *
187
+ */
134
188
  parse(text: string): ParserOutput<BaseParserWithJson<S>>;
135
189
  }
136
190
 
137
- interface ListToKeyValueParserOptions extends BaseParserOptions {
191
+ interface ListToKeyValueParserOptions {
192
+ keyTransform?: "preserve" | "camelCase";
138
193
  }
139
194
  declare class ListToKeyValueParser extends BaseParser<Array<{
140
195
  key: string;
141
196
  value: string;
142
197
  }>> {
198
+ private keyTransform;
143
199
  constructor(options?: ListToKeyValueParserOptions);
144
- parse(text: string): {
200
+ /**
201
+ * v3 parser contract:
202
+ * Category: converter
203
+ * Mode: line-oriented collector
204
+ *
205
+ * Uses the shared list boundary. Parses normalized lines as key/value pairs
206
+ * split at the first colon. Preserves duplicate keys because output is an
207
+ * ordered array. Keys are returned as written by default; pass
208
+ * keyTransform: "camelCase" to match listToJson's key normalization.
209
+ *
210
+ */
211
+ parse(text: string, _attributes?: Record<string, any>): {
145
212
  key: string;
146
213
  value: string;
147
214
  }[];
@@ -149,180 +216,171 @@ declare class ListToKeyValueParser extends BaseParser<Array<{
149
216
 
150
217
  /**
151
218
  * CustomParser class, extending the BaseParser class.
152
- * @template I The expected type of the input
153
219
  * @template O The type of the parsed value (output)
154
- * @extends {BaseParser<T>}
220
+ * @extends {BaseParser<O>}
221
+ *
222
+ * v3 parser contract:
223
+ * Category: pass-through extension point
224
+ * Mode: user-defined
225
+ *
226
+ * Calls the user parser function with text and the per-call ExecutionContext.
227
+ * Returns the user parser result exactly.
228
+ * Does not wrap user parser errors.
229
+ *
230
+ * When invoked through an executor, `context` includes the resolved trace ID,
231
+ * stable executor metadata, current execution metadata, and the attributes
232
+ * extension bag. When parse() is called directly without a context, callers
233
+ * may pass any shape they want; the type widens to allow that.
155
234
  */
156
235
  declare class CustomParser<O = any> extends BaseParser<O> {
157
- /**
158
- * Custom parsing function.
159
- * @type {any}
160
- */
161
- parserFn: (text: string, inputValues: ExecutorContext<any, any>) => O;
162
- /**
163
- * Creates a new CustomParser instance.
164
- * @param {string} name The name of the parser.
165
- * @param {any} parserFn The custom parsing function.
166
- */
167
- constructor(name: string, parserFn: (text: string, inputValues: ExecutorContext<any, any>) => O);
168
- /**
169
- * Parses the text using the custom parsing function.
170
- * @param {string} text The text to be parsed.
171
- * @param {any} inputValues Additional input values for the parser function.
172
- * @returns {O} The parsed value.
173
- */
174
- parse(text: string, inputValues: ExecutorContext<any, O>): O;
236
+ parserFn: (text: string, context: ExecutionContext<any, O>) => O;
237
+ constructor(name: string, parserFn: (text: string, context: ExecutionContext<any, O>) => O);
238
+ parse(text: string, context?: ExecutionContext<any, O>): O;
175
239
  }
176
240
 
241
+ /**
242
+ * v3 parser contract:
243
+ * Category: converter
244
+ * Mode: line-oriented collection conversion
245
+ *
246
+ * Uses the shared list boundary. Returns normalized item text exactly.
247
+ * Throws for empty input, invalid input type, mixed marked/unmarked lines, or
248
+ * a single unmarked prose line.
249
+ *
250
+ */
177
251
  declare class ListToArrayParser extends BaseParser<string[]> {
178
252
  constructor();
179
- parse(text: string): string[];
253
+ parse(text: string, _attributes?: Record<string, any>): string[];
180
254
  }
181
255
 
182
- interface ReplaceStringTemplateParserOptions extends BaseParserOptions {
183
- }
256
+ /**
257
+ * v3 parser contract:
258
+ * Category: pass-through transformation
259
+ * Mode: template replacement
260
+ *
261
+ * Accepts a string template and optional attributes object.
262
+ * Returns the helper replacement result.
263
+ * Throws LlmExeError(parser.parse_failed) for invalid input type,
264
+ * invalid attributes, or template helper failures.
265
+ *
266
+ */
184
267
  declare class ReplaceStringTemplateParser extends BaseParser<string> {
185
- constructor(options?: ReplaceStringTemplateParserOptions);
268
+ constructor();
186
269
  parse(text: string, attributes?: Record<string, any>): string;
187
270
  }
188
271
 
189
- interface MarkdownCodeBlockParserOptions extends BaseParserOptions {
190
- }
272
+ /**
273
+ * v3 parser contract:
274
+ * Category: strict
275
+ * Mode: singular fenced block
276
+ *
277
+ * Accepts input containing exactly one complete fenced markdown code block.
278
+ * Returns that block with exact code content and language string.
279
+ * Throws LlmExeError(parser.parse_failed) for empty input, no block, multiple
280
+ * blocks, malformed fences, or invalid input type.
281
+ *
282
+ */
191
283
  declare class MarkdownCodeBlockParser extends BaseParser<{
192
284
  language: string;
193
285
  code: string;
194
286
  }> {
195
- constructor(options?: MarkdownCodeBlockParserOptions);
196
- parse(input: string): {
287
+ constructor();
288
+ parse(input: string, _attributes?: Record<string, any>): {
197
289
  code: string;
198
290
  language: string;
199
291
  };
200
292
  }
201
293
 
202
- interface MarkdownCodeBlocksParserOptions extends BaseParserOptions {
203
- }
294
+ /**
295
+ * v3 parser contract:
296
+ * Category: collector
297
+ * Mode: markdown fenced block collection
298
+ *
299
+ * Accepts text containing zero or more complete fenced code blocks.
300
+ * Returns all complete blocks in source order.
301
+ * Returns [] when no complete block exists.
302
+ * Throws LlmExeError(parser.parse_failed) for invalid input type or malformed
303
+ * fence structure. Does not unwrap stringified JSON.
304
+ *
305
+ */
204
306
  declare class MarkdownCodeBlocksParser extends BaseParser<{
205
307
  language: string;
206
308
  code: string;
207
309
  }[]> {
208
- constructor(options?: MarkdownCodeBlocksParserOptions);
209
- parse(input: string): {
310
+ constructor();
311
+ parse(input: string, _attributes?: Record<string, any>): {
210
312
  code: string;
211
313
  language: string;
212
314
  }[];
213
315
  }
214
316
 
215
- interface StringExtractParserOptions extends BaseParserOptions {
216
- enum: string[];
317
+ type StringExtractMatch = "word" | "whole" | "substring";
318
+ interface StringExtractParserOptions<E extends readonly string[] = readonly string[]> {
319
+ enum: E;
217
320
  ignoreCase?: boolean;
321
+ match?: StringExtractMatch;
218
322
  }
219
- declare class StringExtractParser extends BaseParser<string> {
323
+ declare class StringExtractParser<E extends readonly string[] = readonly string[]> extends BaseParser<E[number]> {
220
324
  private enum;
221
325
  private ignoreCase;
222
- constructor(options?: StringExtractParserOptions);
223
- parse(text: string): string;
326
+ private match;
327
+ constructor(options?: StringExtractParserOptions<E>);
328
+ /**
329
+ * v3 parser contract:
330
+ * Category: extractor
331
+ * Mode: configured value extraction
332
+ *
333
+ * Returns the single configured enum value found in input. Matching is
334
+ * word-bounded by default; pass match: "whole" to require exact input or
335
+ * match: "substring" for legacy contains() behavior. Case-insensitive by
336
+ * default.
337
+ *
338
+ */
339
+ parse(text: string, _attributes?: Record<string, any>): E[number];
340
+ private findMatches;
341
+ private matchWhole;
342
+ private matchSubstring;
343
+ private matchWord;
224
344
  }
225
345
 
226
346
  /**
227
- * Creates a parser based on the given type.
228
- * @template S - JSON schema type.
229
- * @param type - The type of parser to create.
230
- * @returns An instance of MarkdownCodeBlocksParser.
231
- */
232
- declare function createParser<T extends Extract<CreateParserType, "markdownCodeBlocks">>(type: T, options?: BaseParserOptions): MarkdownCodeBlocksParser;
233
- /**
234
- * Creates a parser based on the given type.
235
- * @template S - JSON schema type.
236
- * @param type - The type of parser to create.
237
- * @returns An instance of MarkdownCodeBlockParser.
238
- */
239
- declare function createParser<T extends Extract<CreateParserType, "markdownCodeBlock">>(type: T, options?: BaseParserOptions): MarkdownCodeBlockParser;
240
- /**
241
- * Creates a parser based on the given type.
242
- * @template S - JSON schema type.
243
- * @param type - The type of parser to create.
244
- * @returns An instance of ListToKeyValueParser.
245
- */
246
- declare function createParser<T extends Extract<CreateParserType, "listToKeyValue">>(type: T, options?: BaseParserOptions): ListToKeyValueParser;
247
- /**
248
- * Creates a parser based on the given type.
249
- * @template S - JSON schema type.
250
- * @param type - The type of parser to create.
251
- * @returns An instance of ListToArrayParser.
252
- */
253
- declare function createParser<T extends Extract<CreateParserType, "listToArray">, S extends JSONSchema | undefined = undefined>(type: T, options?: BaseParserOptions): ListToArrayParser;
254
- /**
255
- * Creates a parser based on the given type.
256
- * @template S - JSON schema type.
257
- * @param type - The type of parser to create.
258
- * @returns An instance of NumberParser.
259
- */
260
- declare function createParser<T extends Extract<CreateParserType, "number">, S extends JSONSchema | undefined = undefined>(type: T, options?: BaseParserOptions): NumberParser;
261
- /**
262
- * Creates a parser based on the given type.
263
- * @template S - JSON schema type.
264
- * @param type - The type of parser to create.
265
- * @returns An instance of NumberParser.
266
- */
267
- declare function createParser<T extends Extract<CreateParserType, "boolean">, S extends JSONSchema | undefined = undefined>(type: T, options?: BaseParserOptions): BooleanParser;
268
- /**
269
- * Creates a parser based on the given type.
270
- * @template S - JSON schema type.
271
- * @param type - The type of parser to create.
272
- * @returns An instance of ReplaceStringTemplateParser.
273
- */
274
- declare function createParser<T extends Extract<CreateParserType, "replaceStringTemplate">, S extends JSONSchema | undefined = undefined>(type: T, options?: BaseParserOptions): ReplaceStringTemplateParser;
275
- /**
276
- * Creates a parser based on the given type.
277
- * @template S - JSON schema type.
278
- * @param type - The type of parser to create.
279
- * @returns An instance of StringParser.
280
- */
281
- declare function createParser<T extends Extract<CreateParserType, "string">, S extends JSONSchema | undefined = undefined>(type: T, options?: BaseParserOptions): StringParser;
282
- /**
283
- * Creates a parser based on the given type.
284
- * @template S - JSON schema type.
285
- * @param type - The type of parser to create.
286
- * @returns An instance of StringParser.
347
+ * Labeled-tuple union for `createParser` arguments. Each branch enumerates
348
+ * exactly what's valid for one parser type. TypeScript validates the whole
349
+ * argument tuple against this union, which produces useful error messages
350
+ * (e.g. "Source has 1 element(s) but target requires 2" when stringExtract
351
+ * is called without options) instead of overload-resolution mystery.
287
352
  */
288
- declare function createParser<T extends Extract<CreateParserType, "stringExtract">, S extends JSONSchema | undefined = undefined>(type: T, options?: StringExtractParserOptions): StringExtractParser;
353
+ type CreateParserArgs = [type: "string", options?: never] | [type: "boolean", options?: never] | [type: "listToArray", options?: never] | [type: "markdownCodeBlock", options?: never] | [type: "markdownCodeBlocks", options?: never] | [type: "replaceStringTemplate", options?: never] | [type: "number", options?: NumberParserOptions] | [type: "listToKeyValue", options?: ListToKeyValueParserOptions] | [type: "json", options?: JsonParserOptions<JSONSchema | undefined>] | [
354
+ type: "listToJson",
355
+ options?: ListToJsonParserOptions<JSONSchema | undefined>
356
+ ] | [type: "stringExtract", options: StringExtractParserOptions<readonly string[]>];
289
357
  /**
290
- * Creates a parser based on the given type and schema.
291
- * @template S - JSON schema type.
292
- * @param type - The type of parser to create.
293
- * @param options - The JSON schema.
294
- * @returns An instance of ListToJsonParser.
358
+ * Maps a concrete argument tuple back to the parser instance type, preserving
359
+ * schema inference for json/listToJson and enum literal narrowing for
360
+ * stringExtract.
295
361
  */
296
- declare function createParser<T extends Extract<CreateParserType, "listToJson">, S extends JSONSchema | undefined = undefined>(type: T, options?: ListToJsonParserOptions<S>): ListToJsonParser<S>;
297
- /**
298
- * Creates a parser based on the given type and schema.
299
- * @template S - JSON schema type.
300
- * @param type - The type of parser to create.
301
- * @param [options] - The JSON schema.
302
- * @returns An instance of JsonParser.
303
- */
304
- declare function createParser<T extends Extract<CreateParserType, "json">, S extends JSONSchema | undefined = undefined>(type: T, options?: BaseParserOptionsWithSchema<S>): JsonParser<S>;
305
- declare function createParser<T extends CreateParserType, S extends JSONSchema | undefined = undefined>(type: T, options?: BaseParserOptionsWithSchema<S> | BaseParserOptions): JsonParser<S> | ListToJsonParser<S> | StringParser | NumberParser | BooleanParser | ListToArrayParser | ListToKeyValueParser | ReplaceStringTemplateParser | MarkdownCodeBlockParser | MarkdownCodeBlocksParser | StringExtractParser;
306
- declare function createCustomParser<O>(name: string, parserFn: (text: string, inputValues: ExecutorContext<any, any>) => O): CustomParser<ReturnType<typeof parserFn>>;
362
+ type CreateParserReturn<A extends readonly unknown[]> = A extends readonly ["string", ...unknown[]] ? StringParser : A extends readonly ["boolean", ...unknown[]] ? BooleanParser : A extends readonly ["number", ...unknown[]] ? NumberParser : A extends readonly ["listToArray", ...unknown[]] ? ListToArrayParser : A extends readonly ["listToKeyValue", ...unknown[]] ? ListToKeyValueParser : A extends readonly ["markdownCodeBlock", ...unknown[]] ? MarkdownCodeBlockParser : A extends readonly ["markdownCodeBlocks", ...unknown[]] ? MarkdownCodeBlocksParser : A extends readonly ["replaceStringTemplate", ...unknown[]] ? ReplaceStringTemplateParser : A extends readonly ["json"] | readonly ["json", undefined] ? JsonParser<undefined> : A extends readonly ["json", JsonParserOptions<infer S>] ? JsonParser<S> : A extends readonly ["listToJson"] | readonly ["listToJson", undefined] ? ListToJsonParser<undefined> : A extends readonly ["listToJson", ListToJsonParserOptions<infer S>] ? ListToJsonParser<S> : A extends readonly [
363
+ "stringExtract",
364
+ StringExtractParserOptions<infer E extends readonly string[]>
365
+ ] ? StringExtractParser<E> : never;
366
+ declare function createParser<const A extends CreateParserArgs>(...args: A): CreateParserReturn<A>;
367
+ declare function createCustomParser<O>(name: string, parserFn: (text: string, context: ExecutionContext<any, any>) => O): CustomParser<ReturnType<typeof parserFn>>;
307
368
 
308
- declare class LlmFunctionParser<T extends BaseParser<any>> extends BaseParser<ParserOutput<T> | OutputResultContent[]> {
369
+ interface LlmNativeFunctionParserOptions<T extends BaseParser<any, any>> {
309
370
  parser: T;
310
- constructor(options: LlmNativeFunctionParserOptions<T>);
311
- parse(text: OutputResult, _options?: Record<string, any>): OutputResultContent[] | ParserOutput<T>;
312
371
  }
313
- interface LlmNativeFunctionParserOptions<T extends BaseParser<any>> extends BaseParserOptions {
314
- parser: T;
315
- }
316
- interface LlmNativeFunctionParserOptions<T extends BaseParser<any>> extends BaseParserOptions {
372
+ declare class LlmFunctionParser<T extends BaseParser<any, any>> extends BaseParser<ParserOutput<T> | OutputResultContent[], OutputResult | string> {
317
373
  parser: T;
374
+ constructor(options: LlmNativeFunctionParserOptions<T>);
375
+ parse(text: OutputResult, _options?: Record<string, any>): ParserOutput<T> | OutputResultContent[];
318
376
  }
319
377
  /**
320
378
  * @deprecated Use `LlmFunctionParser` instead.
321
379
  */
322
- declare class LlmNativeFunctionParser<T extends BaseParser<any>> extends BaseParser<ParserOutput<T> | {
380
+ declare class LlmNativeFunctionParser<T extends BaseParser<any, any>> extends BaseParser<ParserOutput<T> | {
323
381
  name: any;
324
382
  arguments: any;
325
- }> {
383
+ }, OutputResult | string> {
326
384
  parser: T;
327
385
  constructor(options: LlmNativeFunctionParserOptions<T>);
328
386
  parse(text: OutputResult, _options?: Record<string, any>): ParserOutput<T> | {
@@ -347,6 +405,7 @@ declare abstract class BasePrompt<I extends Record<string, any>> {
347
405
  messages: IPromptMessages | IPromptChatMessages;
348
406
  partials: PromptPartial[];
349
407
  helpers: PromptHelper[];
408
+ validateInput: ValidateInputMode;
350
409
  replaceTemplateString: typeof replaceTemplateString;
351
410
  replaceTemplateStringAsync: typeof replaceTemplateStringAsync;
352
411
  filters: {
@@ -383,6 +442,16 @@ declare abstract class BasePrompt<I extends Record<string, any>> {
383
442
  * @return BasePrompt so it can be chained.
384
443
  */
385
444
  registerHelpers(helperOrHelpers: PromptHelper | PromptHelper[]): this;
445
+ /**
446
+ * Returns the Handlebars-bearing strings that should be validated, along
447
+ * with a location label used for error context. Subclasses with structured
448
+ * message content (e.g. ChatPrompt) should override.
449
+ */
450
+ protected getTemplateContents(): {
451
+ content: string;
452
+ location: string;
453
+ }[];
454
+ protected preflightValidate(values: I): void;
386
455
  /**
387
456
  * format description
388
457
  * @param values The message content
@@ -403,10 +472,17 @@ declare abstract class BasePrompt<I extends Record<string, any>> {
403
472
  _input: any;
404
473
  };
405
474
  /**
406
- * Validates the prompt structure.
407
- * @return {boolean} Returns false if the prompt has no messages defined.
475
+ * Validates that `input` provides every variable referenced by this prompt's
476
+ * templates, and that every identifiable helper call is registered.
477
+ *
478
+ * @breaking v3: previously returned `this.messages.length > 0` with no
479
+ * `input` parameter. For the old behavior, read `prompt.messages.length > 0`
480
+ * directly.
481
+ *
482
+ * @throws LlmExeError with code `"prompt.missing_template_variable"` listing
483
+ * all missing variables and helpers.
408
484
  */
409
- validate(): boolean;
485
+ validate(input: I): void;
410
486
  }
411
487
 
412
488
  /**
@@ -535,6 +611,7 @@ type PromptPartial = {
535
611
  name: string;
536
612
  template: string;
537
613
  };
614
+ type ValidateInputMode = false | "strict" | "warn";
538
615
  interface PromptTemplateOptions {
539
616
  partials?: PromptPartial[];
540
617
  helpers?: PromptHelper[];
@@ -543,6 +620,15 @@ interface PromptOptions extends PromptTemplateOptions {
543
620
  preFilters?: ((prompt: string) => string)[];
544
621
  postFilters?: ((prompt: string) => string)[];
545
622
  replaceTemplateString?: (...args: any[]) => string;
623
+ /**
624
+ * Controls whether `format()` preflights input against the variables
625
+ * referenced by the prompt's templates. See `validate(input)`.
626
+ *
627
+ * - `false` (default): no preflight; rendering proceeds.
628
+ * - `"strict"`: throw `LlmExeError("prompt.missing_template_variable")` before rendering.
629
+ * - `"warn"`: emit a Node warning via `process.emitWarning` and continue rendering.
630
+ */
631
+ validateInput?: ValidateInputMode;
546
632
  }
547
633
  interface ChatPromptOptions extends PromptOptions {
548
634
  allowUnsafeUserTemplate?: boolean;
@@ -602,10 +688,27 @@ declare abstract class BaseExecutor<I extends PlainObject, O = any, H extends Ba
602
688
  */
603
689
  readonly maxHooksPerEvent: number;
604
690
  constructor(name: string, type: string, options?: CoreExecutorExecuteOptions<H>);
605
- abstract handler(input: I, _options?: any): Promise<any>;
691
+ abstract handler(input: I, _options?: any, _context?: ExecutionContext<I, O>): Promise<any>;
692
+ /**
693
+ * Build a per-call execution context snapshot. Captures the current
694
+ * execution metadata so the snapshot reflects state at the time it was
695
+ * taken (e.g. `handlerInput` becomes available after `getHandlerInput`).
696
+ */
697
+ protected snapshotContext(execution: ExecutorExecutionMetadata<I, O>): ExecutionContext<I, O>;
606
698
  /**
607
699
  *
608
- * Used to filter the input of the handler
700
+ * Used to filter the input of the handler.
701
+ *
702
+ * Throws a `TypeError` if `_input` is `null` or `undefined`. The declared
703
+ * input type is `I extends PlainObject`; omitting input or passing an
704
+ * explicit `null` is a contract violation with no valid coercion, so we
705
+ * surface it loudly rather than silently wrapping it.
706
+ *
707
+ * Non-object inputs (strings, numbers, arrays) are intentionally coerced
708
+ * to `{ input: value }` via {@link ensureInputIsObject}. This preserves the
709
+ * convenience pattern used by tool/function callables, which forward raw
710
+ * string arguments into an executor.
711
+ *
609
712
  * @param _input
610
713
  * @returns original input formatted for handler
611
714
  */
@@ -616,7 +719,7 @@ declare abstract class BaseExecutor<I extends PlainObject, O = any, H extends Ba
616
719
  * @param _input
617
720
  * @returns output O
618
721
  */
619
- getHandlerOutput(out: any, _metadata: ExecutorExecutionMetadata<any, O>, _options?: any): O;
722
+ getHandlerOutput(out: any, _metadata: ExecutorExecutionMetadata<any, O>, _options?: any, _context?: ExecutionContext<I, O>): O;
620
723
  /**
621
724
  *
622
725
  * execute - Runs the executor
@@ -624,9 +727,10 @@ declare abstract class BaseExecutor<I extends PlainObject, O = any, H extends Ba
624
727
  * @returns handler output
625
728
  */
626
729
  execute(_input: I, _options?: any): Promise<O>;
730
+ private collectHookErrors;
627
731
  metadata(): Record<string, any>;
628
732
  getMetadata(metadata?: Record<string, any>): ExecutorMetadata;
629
- runHook(hook: keyof H, _metadata: ExecutorExecutionMetadata): void;
733
+ runHook(hook: keyof H, _metadata: ExecutorExecutionMetadata): HookErrorRecord[];
630
734
  setHooks(hooks?: CoreExecutorHookInput<H>): this;
631
735
  removeHook(eventName: keyof H, fn: ListenerFunction): this;
632
736
  on(eventName: keyof H, fn: ListenerFunction): this;
@@ -785,16 +889,24 @@ declare function createStateItem<T>(name: string, defaultValue: T): DefaultState
785
889
  /**
786
890
  * Core Executor With LLM
787
891
  */
788
- declare class LlmExecutor<Llm extends BaseLlm<any>, Prompt extends BasePrompt<Record<string, any>>, Parser extends BaseParser, State extends BaseState> extends BaseExecutor<PromptInput<Prompt>, ParserOutput<Parser>, LlmExecutorHooks> {
892
+ declare class LlmExecutor<Llm extends BaseLlm<any>, Prompt extends BasePrompt<Record<string, any>>, Parser extends BaseParser<any, any>, State extends BaseState> extends BaseExecutor<PromptInput<Prompt>, ParserOutput<Parser>, LlmExecutorHooks> {
789
893
  llm: Llm;
790
894
  prompt: Prompt | undefined;
791
895
  promptFn: any;
792
896
  parser: StringParser | Parser;
793
897
  constructor(llmConfiguration: ExecutorWithLlmOptions<Llm, Prompt, Parser, State>, options?: CoreExecutorExecuteOptions<LlmExecutorHooks>);
898
+ /**
899
+ * Runs the executor against the configured LLM and prompt.
900
+ *
901
+ * `null` and `undefined` are rejected with a `TypeError`: the declared
902
+ * input type requires an object, and silently coercing missing input hides a
903
+ * clear contract violation. Use `{}` for prompts that declare no template
904
+ * variables. See issue #410.
905
+ */
794
906
  execute(_input: PromptInput<Prompt>, _options?: LlmExecutorExecuteOptions): Promise<ParserOutput<Parser>>;
795
- handler(_input: PromptInput<Prompt>, ..._args: any[]): Promise<any>;
907
+ handler(_input: PromptInput<Prompt>, _options?: LlmExecutorExecuteOptions, _context?: ExecutionContext<PromptInput<Prompt>, ParserOutput<Parser>>): Promise<any>;
796
908
  getHandlerInput(_input: PromptInput<Prompt>): Promise<any>;
797
- getHandlerOutput(out: BaseLlCall, _metadata: ExecutorExecutionMetadata<PromptInput<Prompt>, ParserOutput<Parser>>): ParserOutput<Parser>;
909
+ getHandlerOutput(out: BaseLlCall, _metadata: ExecutorExecutionMetadata<PromptInput<Prompt>, ParserOutput<Parser>>, _options?: LlmExecutorExecuteOptions, _context?: ExecutionContext<PromptInput<Prompt>, ParserOutput<Parser>>): ParserOutput<Parser>;
798
910
  metadata(): {
799
911
  llm: Record<string, any>;
800
912
  };
@@ -844,7 +956,7 @@ declare const hookOnError = "onError";
844
956
  declare const hookOnSuccess = "onSuccess";
845
957
 
846
958
  type ListenerFunction = (...args: any[]) => void;
847
- type ParserOutput<P> = P extends BaseParser<infer T> ? T : never;
959
+ type ParserOutput<P> = P extends BaseParser<infer T, any> ? T : never;
848
960
  type PromptInput<P> = P extends BasePrompt<infer T> ? T : never;
849
961
  interface ExecutorWithLlmOptions<Llm, Prompt, Parser, State> {
850
962
  name?: string;
@@ -871,6 +983,15 @@ interface ExecutorMetadata {
871
983
  executions: number;
872
984
  metadata?: Record<string, any>;
873
985
  }
986
+ interface HookErrorRecord {
987
+ hook: string;
988
+ error: unknown;
989
+ errorMessage: string;
990
+ errorCategory?: string;
991
+ errorCode?: string;
992
+ errorContext?: unknown;
993
+ errorCause?: unknown;
994
+ }
874
995
  interface ExecutorExecutionMetadata<I = any, O = any> {
875
996
  start: null | number;
876
997
  end: null | number;
@@ -880,12 +1001,29 @@ interface ExecutorExecutionMetadata<I = any, O = any> {
880
1001
  output?: O;
881
1002
  errorMessage?: string;
882
1003
  error?: Error;
1004
+ errorCategory?: string;
1005
+ errorCode?: string;
1006
+ errorContext?: unknown;
1007
+ errorCause?: unknown;
1008
+ hookErrors?: HookErrorRecord[];
883
1009
  metadata?: null | ExecutorMetadata;
884
1010
  }
885
1011
  interface ExecutorContext<I = any, O = any, A = Record<string, any>> extends ExecutorExecutionMetadata<I, O> {
886
1012
  metadata: ExecutorMetadata;
887
1013
  attributes: A;
888
1014
  }
1015
+ /**
1016
+ * Per-call execution context. Built by `BaseExecutor.execute()` and threaded
1017
+ * through `handler()`, `llm.call()`, parsers, and warnings. Provides a single
1018
+ * place to read the resolved trace ID, stable executor identity, and the
1019
+ * mutable execution state for the current run.
1020
+ */
1021
+ interface ExecutionContext<I = any, O = any, A = Record<string, any>> {
1022
+ traceId?: string;
1023
+ executor: ExecutorMetadata;
1024
+ execution: ExecutorExecutionMetadata<I, O>;
1025
+ attributes: A;
1026
+ }
889
1027
  interface BaseExecutorHooks {
890
1028
  [hookOnError]: ListenerFunction[];
891
1029
  [hookOnSuccess]: ListenerFunction[];
@@ -919,14 +1057,11 @@ interface LlmExecutorWithFunctionsOptions<T extends GenericFunctionCall = "auto"
919
1057
  jsonSchema?: Record<string, any>;
920
1058
  }
921
1059
 
922
- type CreateParserType = "json" | "string" | "boolean" | "number" | "stringExtract" | "listToArray" | "listToJson" | "listToKeyValue" | "replaceStringTemplate" | "markdownCodeBlocks" | "markdownCodeBlock";
923
- interface BaseParserOptions {
924
- }
925
- interface BaseParserOptionsWithSchema<S extends JSONSchema | undefined = undefined> extends BaseParserOptions {
1060
+ interface JsonParserOptions<S extends JSONSchema | undefined = undefined> {
926
1061
  schema?: S;
927
1062
  validateSchema?: boolean;
928
1063
  }
929
- interface ListToJsonParserOptions<S extends JSONSchema | undefined = undefined> extends BaseParserOptionsWithSchema<S> {
1064
+ interface ListToJsonParserOptions<S extends JSONSchema | undefined = undefined> extends JsonParserOptions<S> {
930
1065
  keyTransform?: "camelCase" | "preserve";
931
1066
  }
932
1067
 
@@ -1397,8 +1532,224 @@ interface Config<Pk = LlmProviderKey> {
1397
1532
  * `getEmbeddingOutputParser` instead.
1398
1533
  */
1399
1534
  transformResponse?: (result: any, _config?: Config<any>) => OutputResult;
1535
+ /**
1536
+ * Marks this config as deprecated. When set, useLlm() will emit a one-time
1537
+ * deprecation warning to inform users about upcoming model shutdowns.
1538
+ */
1539
+ deprecated?: {
1540
+ shorthand: string;
1541
+ message: string;
1542
+ };
1400
1543
  }
1401
1544
 
1545
+ type JsonSafe = string | number | boolean | null | JsonSafe[] | {
1546
+ [key: string]: JsonSafe;
1547
+ };
1548
+ type ErrorCategory = "unknown" | "configuration" | "llm" | "embedding" | "prompt" | "parser" | "executor" | "callable" | "state" | "request" | "auth" | "template" | "internal";
1549
+ type BaseErrorContext = {
1550
+ operation?: string;
1551
+ provider?: string;
1552
+ model?: string;
1553
+ key?: string;
1554
+ input?: unknown;
1555
+ output?: unknown;
1556
+ response?: unknown;
1557
+ status?: number;
1558
+ url?: string;
1559
+ parser?: string;
1560
+ promptType?: string;
1561
+ functionName?: string;
1562
+ hook?: string;
1563
+ expected?: unknown;
1564
+ received?: unknown;
1565
+ resolution?: string;
1566
+ docsPath?: string;
1567
+ docsUrl?: string;
1568
+ };
1569
+ type ConfigurationProviderContext = BaseErrorContext & {
1570
+ provider?: string;
1571
+ availableProviders?: string[];
1572
+ };
1573
+ type MissingConfigurationContext = BaseErrorContext & {
1574
+ provider?: string;
1575
+ key?: string;
1576
+ option?: string;
1577
+ envVar?: string;
1578
+ };
1579
+ type InvalidHeadersContext = BaseErrorContext & {
1580
+ provider?: string;
1581
+ key?: string;
1582
+ headerTemplate?: string;
1583
+ replacedHeadersExcerpt?: string;
1584
+ };
1585
+ type ParserInvalidTypeContext = BaseErrorContext & {
1586
+ parser?: unknown;
1587
+ availableParsers?: string[];
1588
+ };
1589
+ type ParserSchemaValidationContext = BaseErrorContext & {
1590
+ parser?: string;
1591
+ schemaErrors?: unknown;
1592
+ outputExcerpt?: string;
1593
+ };
1594
+ type ParserParseFailedContext = BaseErrorContext & {
1595
+ parser?: string;
1596
+ reason?: string;
1597
+ inputExcerpt?: string;
1598
+ inputExcerptTruncated?: boolean;
1599
+ inputLength?: number;
1600
+ matchCount?: number;
1601
+ match?: string;
1602
+ outputExcerpt?: string;
1603
+ };
1604
+ type PromptInputContext = BaseErrorContext & {
1605
+ promptType?: string;
1606
+ };
1607
+ type PromptMessagesContext = BaseErrorContext & {
1608
+ provider?: string;
1609
+ };
1610
+ type PromptMissingTemplateVariableContext = BaseErrorContext & {
1611
+ promptType?: string;
1612
+ missingVariables: string[];
1613
+ missingHelpers: string[];
1614
+ };
1615
+ type NormalizedProviderError = {
1616
+ message?: string;
1617
+ providerType?: string;
1618
+ providerCode?: string;
1619
+ status?: number;
1620
+ statusText?: string;
1621
+ retryable?: boolean;
1622
+ retryAfterMs?: number;
1623
+ };
1624
+ type ProviderErrorContext = BaseErrorContext & {
1625
+ provider?: string;
1626
+ model?: string;
1627
+ status?: number;
1628
+ statusText?: string;
1629
+ url?: string;
1630
+ providerError?: NormalizedProviderError;
1631
+ providerErrorBody?: unknown;
1632
+ providerErrorRaw?: string;
1633
+ responseHeaders?: Record<string, string>;
1634
+ };
1635
+ type ProviderResponseContext = BaseErrorContext & {
1636
+ provider?: string;
1637
+ model?: string;
1638
+ responseExcerpt?: string;
1639
+ lineNumber?: number;
1640
+ lineExcerpt?: string;
1641
+ lineCount?: number;
1642
+ availableProviders?: string[];
1643
+ };
1644
+ type EmbeddingDimensionsContext = BaseErrorContext & {
1645
+ provider?: string;
1646
+ model?: string;
1647
+ dimensions?: number;
1648
+ };
1649
+ type ExecutorErrorContext = BaseErrorContext & {
1650
+ executorName?: string;
1651
+ executorType?: string;
1652
+ traceId?: string;
1653
+ };
1654
+ type ExecutorHookContext = ExecutorErrorContext & {
1655
+ hook?: string;
1656
+ hookCount?: number;
1657
+ maxHooksPerEvent?: number;
1658
+ };
1659
+ type CallableErrorContext = BaseErrorContext & {
1660
+ functionName?: string;
1661
+ availableFunctions?: string[];
1662
+ };
1663
+ type TemplateHelperContext = BaseErrorContext & {
1664
+ helper?: string;
1665
+ };
1666
+ type StateErrorContext = BaseErrorContext & {
1667
+ module?: string;
1668
+ };
1669
+ type AwsAuthContext = BaseErrorContext & {
1670
+ url?: string;
1671
+ regionName?: string;
1672
+ };
1673
+ type RequestErrorContext = BaseErrorContext & {
1674
+ url?: string;
1675
+ status?: number;
1676
+ statusText?: string;
1677
+ providerError?: NormalizedProviderError;
1678
+ providerErrorBody?: unknown;
1679
+ providerErrorRaw?: string;
1680
+ responseHeaders?: Record<string, string>;
1681
+ };
1682
+ type InternalErrorContext = BaseErrorContext & {
1683
+ invariant?: string;
1684
+ };
1685
+ type ErrorContextByCode = {
1686
+ "configuration.missing_provider": ConfigurationProviderContext;
1687
+ "configuration.invalid_provider": ConfigurationProviderContext;
1688
+ "configuration.missing_env": MissingConfigurationContext;
1689
+ "configuration.missing_option": MissingConfigurationContext;
1690
+ "configuration.invalid_headers": InvalidHeadersContext;
1691
+ "parser.invalid_type": ParserInvalidTypeContext;
1692
+ "parser.invalid_input": ParserParseFailedContext;
1693
+ "parser.parse_failed": ParserParseFailedContext;
1694
+ "parser.schema_validation_failed": ParserSchemaValidationContext;
1695
+ "prompt.missing_input": PromptInputContext;
1696
+ "prompt.invalid_messages": PromptMessagesContext;
1697
+ "prompt.missing_template_variable": PromptMissingTemplateVariableContext;
1698
+ "llm.provider_http_error": ProviderErrorContext;
1699
+ "llm.provider_rate_limited": ProviderErrorContext;
1700
+ "llm.provider_auth_failed": ProviderErrorContext;
1701
+ "llm.provider_invalid_request": ProviderErrorContext;
1702
+ "llm.provider_unavailable": ProviderErrorContext;
1703
+ "llm.invalid_response_shape": ProviderResponseContext;
1704
+ "llm.invalid_jsonl_response": ProviderResponseContext;
1705
+ "embedding.provider_http_error": ProviderErrorContext;
1706
+ "embedding.provider_rate_limited": ProviderErrorContext;
1707
+ "embedding.provider_auth_failed": ProviderErrorContext;
1708
+ "embedding.provider_invalid_request": ProviderErrorContext;
1709
+ "embedding.provider_unavailable": ProviderErrorContext;
1710
+ "embedding.missing_provider": ConfigurationProviderContext;
1711
+ "embedding.invalid_provider": ConfigurationProviderContext;
1712
+ "embedding.unsupported_dimensions": EmbeddingDimensionsContext;
1713
+ "embedding.invalid_response_shape": ProviderResponseContext;
1714
+ "executor.missing_prompt": ExecutorErrorContext;
1715
+ "executor.hook_limit_reached": ExecutorHookContext;
1716
+ "executor.hook_failed": ExecutorHookContext;
1717
+ "callable.invalid_handler": CallableErrorContext;
1718
+ "callable.handler_not_found": CallableErrorContext;
1719
+ "callable.validation_failed": CallableErrorContext;
1720
+ "template.invalid_helper_arguments": TemplateHelperContext;
1721
+ "state.invalid_arguments": StateErrorContext;
1722
+ "auth.aws_signing_input_missing": AwsAuthContext;
1723
+ "request.invalid_url": RequestErrorContext;
1724
+ "request.http_error": RequestErrorContext;
1725
+ "internal.invariant_failed": InternalErrorContext;
1726
+ "unknown.unclassified": Record<string, unknown>;
1727
+ };
1728
+ type ErrorCodes = keyof ErrorContextByCode;
1729
+ type CategoryFor<C extends ErrorCodes> = C extends `${infer Category}.${string}` ? Category & ErrorCategory : never;
1730
+ type SerializableCause = {
1731
+ name?: string;
1732
+ message?: string;
1733
+ category?: string;
1734
+ code?: string;
1735
+ context?: unknown;
1736
+ cause?: unknown;
1737
+ } | JsonSafe;
1738
+ type LlmExeErrorOptions<C extends ErrorCodes = ErrorCodes> = {
1739
+ code: C;
1740
+ context?: ErrorContextByCode[C];
1741
+ cause?: unknown;
1742
+ };
1743
+ type LlmExeErrorJson<C extends ErrorCodes = ErrorCodes> = {
1744
+ name: "LlmExeError";
1745
+ message: string;
1746
+ category: CategoryFor<C>;
1747
+ code: C;
1748
+ context?: ErrorContextByCode[C];
1749
+ cause?: SerializableCause;
1750
+ truncated?: boolean;
1751
+ };
1752
+
1402
1753
  declare function enforceResultAttributes<O>(input: any): {
1403
1754
  result: O;
1404
1755
  attributes: Record<string, any>;
@@ -1513,6 +1864,20 @@ declare function assert(condition: any, message?: string | Error | undefined): a
1513
1864
 
1514
1865
  declare function defineSchema<T>(obj: Narrow<T>): Narrow<T>;
1515
1866
 
1867
+ declare const LLM_EXE_ERROR_SYMBOL: unique symbol;
1868
+ declare class LlmExeError<C extends ErrorCodes = "unknown.unclassified"> extends Error {
1869
+ readonly name: "LlmExeError";
1870
+ readonly isLlmExeError: true;
1871
+ readonly [LLM_EXE_ERROR_SYMBOL]: true;
1872
+ readonly category: CategoryFor<C>;
1873
+ readonly code: C;
1874
+ readonly context?: ErrorContextByCode[C];
1875
+ constructor(message: string, options: LlmExeErrorOptions<C>);
1876
+ toJSON(): LlmExeErrorJson<C>;
1877
+ }
1878
+
1879
+ declare function isLlmExeError<C extends ErrorCodes>(error: unknown, code?: C | readonly C[]): error is LlmExeError<C>;
1880
+
1516
1881
  declare function importPartials(_partials: {
1517
1882
  [key in string]: string;
1518
1883
  }): PromptPartial[];
@@ -1536,6 +1901,9 @@ declare function isObjectStringified(maybeObject: string): boolean;
1536
1901
  declare function registerHelpers(helpers: any[]): void;
1537
1902
  declare function registerPartials(partials: any[]): void;
1538
1903
 
1904
+ declare const index_LLM_EXE_ERROR_SYMBOL: typeof LLM_EXE_ERROR_SYMBOL;
1905
+ type index_LlmExeError<C extends ErrorCodes = "unknown.unclassified"> = LlmExeError<C>;
1906
+ declare const index_LlmExeError: typeof LlmExeError;
1539
1907
  declare const index_assert: typeof assert;
1540
1908
  declare const index_asyncCallWithTimeout: typeof asyncCallWithTimeout;
1541
1909
  declare const index_defineSchema: typeof defineSchema;
@@ -1543,6 +1911,7 @@ declare const index_filterObjectOnSchema: typeof filterObjectOnSchema;
1543
1911
  declare const index_guessProviderFromModel: typeof guessProviderFromModel;
1544
1912
  declare const index_importHelpers: typeof importHelpers;
1545
1913
  declare const index_importPartials: typeof importPartials;
1914
+ declare const index_isLlmExeError: typeof isLlmExeError;
1546
1915
  declare const index_isObjectStringified: typeof isObjectStringified;
1547
1916
  declare const index_maybeParseJSON: typeof maybeParseJSON;
1548
1917
  declare const index_maybeStringifyJSON: typeof maybeStringifyJSON;
@@ -1551,7 +1920,7 @@ declare const index_registerPartials: typeof registerPartials;
1551
1920
  declare const index_replaceTemplateString: typeof replaceTemplateString;
1552
1921
  declare const index_replaceTemplateStringAsync: typeof replaceTemplateStringAsync;
1553
1922
  declare namespace index {
1554
- export { index_assert as assert, index_asyncCallWithTimeout as asyncCallWithTimeout, index_defineSchema as defineSchema, index_filterObjectOnSchema as filterObjectOnSchema, index_guessProviderFromModel as guessProviderFromModel, index_importHelpers as importHelpers, index_importPartials as importPartials, index_isObjectStringified as isObjectStringified, index_maybeParseJSON as maybeParseJSON, index_maybeStringifyJSON as maybeStringifyJSON, index_registerHelpers as registerHelpers, index_registerPartials as registerPartials, index_replaceTemplateString as replaceTemplateString, index_replaceTemplateStringAsync as replaceTemplateStringAsync };
1923
+ export { index_LLM_EXE_ERROR_SYMBOL as LLM_EXE_ERROR_SYMBOL, index_LlmExeError as LlmExeError, index_assert as assert, index_asyncCallWithTimeout as asyncCallWithTimeout, index_defineSchema as defineSchema, index_filterObjectOnSchema as filterObjectOnSchema, index_guessProviderFromModel as guessProviderFromModel, index_importHelpers as importHelpers, index_importPartials as importPartials, index_isLlmExeError as isLlmExeError, index_isObjectStringified as isObjectStringified, index_maybeParseJSON as maybeParseJSON, index_maybeStringifyJSON as maybeStringifyJSON, index_registerHelpers as registerHelpers, index_registerPartials as registerPartials, index_replaceTemplateString as replaceTemplateString, index_replaceTemplateStringAsync as replaceTemplateStringAsync };
1555
1924
  }
1556
1925
 
1557
1926
  declare function isOutputResult(obj: any): obj is OutputResult;
@@ -1588,15 +1957,15 @@ declare const configs: {
1588
1957
  "deepseek.chat": Config<keyof AllLlm>;
1589
1958
  "deepseek.v4-flash": Config<keyof AllLlm>;
1590
1959
  "deepseek.v4-pro": Config<keyof AllLlm>;
1591
- "google.chat.v1": Config<keyof AllLlm>;
1592
- "google.gemini-2.5-flash": Config<keyof AllLlm>;
1593
- "google.gemini-2.5-flash-lite": Config<keyof AllLlm>;
1594
- "google.gemini-2.5-pro": Config<keyof AllLlm>;
1595
- "google.gemini-3.1-flash-lite": Config<keyof AllLlm>;
1596
- "google.gemini-3.5-flash": Config<keyof AllLlm>;
1597
1960
  "google.gemini-2.0-flash": Config<keyof AllLlm>;
1598
1961
  "google.gemini-2.0-flash-lite": Config<keyof AllLlm>;
1599
1962
  "google.gemini-1.5-pro": Config<keyof AllLlm>;
1963
+ "google.gemini-2.5-pro": Config<any>;
1964
+ "google.gemini-2.5-flash-lite": Config<any>;
1965
+ "google.gemini-2.5-flash": Config<any>;
1966
+ "google.chat.v1": Config<keyof AllLlm>;
1967
+ "google.gemini-3.1-flash-lite": Config<keyof AllLlm>;
1968
+ "google.gemini-3.5-flash": Config<keyof AllLlm>;
1600
1969
  "ollama.chat.v1": Config<keyof AllLlm>;
1601
1970
  "ollama.deepseek-r1": Config<keyof AllLlm>;
1602
1971
  "ollama.llama3.3": Config<keyof AllLlm>;
@@ -1622,20 +1991,21 @@ declare const configs: {
1622
1991
  "xai.grok-4.20-reasoning": Config<keyof AllLlm>;
1623
1992
  "amazon:anthropic.chat.v1": Config<keyof AllLlm>;
1624
1993
  "amazon:meta.chat.v1": Config<keyof AllLlm>;
1994
+ "anthropic.claude-3-opus": Config<any>;
1995
+ "anthropic.claude-3-5-haiku": Config<any>;
1996
+ "anthropic.claude-3-5-sonnet": Config<any>;
1997
+ "anthropic.claude-3-7-sonnet": Config<any>;
1998
+ "anthropic.claude-opus-4": Config<any>;
1999
+ "anthropic.claude-sonnet-4": Config<any>;
2000
+ "anthropic.claude-opus-4-1": Config<any>;
2001
+ "anthropic.claude-opus-4-6": Config<any>;
1625
2002
  "anthropic.chat.v1": Config<keyof AllLlm>;
1626
2003
  "anthropic.claude-opus-4-7": Config<keyof AllLlm>;
1627
2004
  "anthropic.claude-sonnet-4-6": Config<keyof AllLlm>;
1628
2005
  "anthropic.claude-opus-4-5": Config<keyof AllLlm>;
1629
2006
  "anthropic.claude-haiku-4-5": Config<keyof AllLlm>;
1630
2007
  "anthropic.claude-sonnet-4-5": Config<keyof AllLlm>;
1631
- "anthropic.claude-opus-4-6": Config<keyof AllLlm>;
1632
- "anthropic.claude-opus-4-1": Config<keyof AllLlm>;
1633
- "anthropic.claude-sonnet-4": Config<keyof AllLlm>;
1634
- "anthropic.claude-opus-4": Config<keyof AllLlm>;
1635
- "anthropic.claude-3-7-sonnet": Config<keyof AllLlm>;
1636
- "anthropic.claude-3-5-sonnet": Config<keyof AllLlm>;
1637
- "anthropic.claude-3-5-haiku": Config<keyof AllLlm>;
1638
- "anthropic.claude-3-opus": Config<keyof AllLlm>;
2008
+ "openai.o4-mini": Config<any>;
1639
2009
  "openai.chat.v1": Config<keyof AllLlm>;
1640
2010
  "openai.chat-mock.v1": Config<keyof AllLlm>;
1641
2011
  "openai.gpt-5.2": Config<keyof AllLlm>;
@@ -1648,12 +2018,11 @@ declare const configs: {
1648
2018
  "openai.gpt-4": Config<keyof AllLlm>;
1649
2019
  "openai.gpt-4o": Config<keyof AllLlm>;
1650
2020
  "openai.gpt-4o-mini": Config<keyof AllLlm>;
1651
- "openai.o4-mini": Config<keyof AllLlm>;
1652
2021
  };
1653
2022
 
1654
2023
  declare function useLlm<T extends keyof typeof configs>(provider: T, options?: AllUseLlmOptions[T]["input"]): BaseLlm;
1655
2024
  declare function useLlmConfiguration<T extends keyof typeof configs>(config: Config<any>): (options?: AllUseLlmOptions[T]["input"]) => {
1656
- call: (messages: string | IChatMessages, options?: LlmExecutorWithFunctionsOptions) => Promise<{
2025
+ call: (messages: string | IChatMessages, options?: LlmExecutorWithFunctionsOptions, context?: ExecutionContext) => Promise<{
1657
2026
  getResultContent: (index?: number) => OutputResultContent[];
1658
2027
  getResultText: (index?: number) => string;
1659
2028
  getResult: () => OutputResult;
@@ -1682,7 +2051,7 @@ declare function createOpenAiCompatibleConfiguration<K extends Config["key"]>(ov
1682
2051
  }): Config<keyof AllLlm>;
1683
2052
 
1684
2053
  declare function createEmbedding<T extends EmbeddingProviderKey>(provider: T, options: AllEmbedding[T]["input"]): {
1685
- call: (messages: string | string[], options?: LlmExecutorWithFunctionsOptions) => Promise<{
2054
+ call: (messages: string | string[], options?: LlmExecutorWithFunctionsOptions, context?: ExecutionContext) => Promise<{
1686
2055
  getEmbedding: (index?: number) => number[];
1687
2056
  getResult: () => EmbeddingOutputResult;
1688
2057
  }>;
@@ -1700,4 +2069,4 @@ declare function createEmbedding<T extends EmbeddingProviderKey>(provider: T, op
1700
2069
  };
1701
2070
  };
1702
2071
 
1703
- export { BaseExecutor, type BaseLlm, BaseParser, BasePrompt, BaseStateItem, ChatPrompt, CustomParser, DefaultState, DefaultStateItem, type EmbeddingProviderKey, type ExecutorContext, type IChatMessages, LlmExecutorOpenAiFunctions, LlmExecutorWithFunctions, LlmNativeFunctionParser, type LlmProvider, type LlmProviderKey, type OpenAIModelName, OpenAiFunctionParser, TextPrompt, type UseLlmKey, createCallableExecutor, createChatPrompt, createCoreExecutor, createCustomParser, createDialogue, createEmbedding, createLlmExecutor, createLlmFunctionExecutor, createOpenAiCompatibleConfiguration, createParser, createPrompt, createState, createStateItem, defineSchema, guards, registerHelpers, registerPartials, useExecutors, useLlm, useLlmConfiguration, index as utils };
2072
+ export { BaseExecutor, type BaseLlm, BaseParser, BasePrompt, BaseStateItem, ChatPrompt, CustomParser, DefaultState, DefaultStateItem, type EmbeddingProviderKey, type ErrorCategory, type ErrorCodes, type ErrorContextByCode, type ExecutionContext, type ExecutorContext, type ExecutorExecutionMetadata, type HookErrorRecord, type IChatMessages, LLM_EXE_ERROR_SYMBOL, LlmExeError, LlmExecutorOpenAiFunctions, LlmExecutorWithFunctions, LlmNativeFunctionParser, type LlmProvider, type LlmProviderKey, type NormalizedProviderError, type OpenAIModelName, OpenAiFunctionParser, type ProviderErrorContext, TextPrompt, type UseLlmKey, createCallableExecutor, createChatPrompt, createCoreExecutor, createCustomParser, createDialogue, createEmbedding, createLlmExecutor, createLlmFunctionExecutor, createOpenAiCompatibleConfiguration, createParser, createPrompt, createState, createStateItem, defineSchema, guards, isLlmExeError, registerHelpers, registerPartials, useExecutors, useLlm, useLlmConfiguration, index as utils };