llm-exe 2.3.11 → 3.0.0-beta.2

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,136 @@ 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: ParserSchemaOptions<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 {
114
+ type BooleanParserMatch = "exact" | "extract";
115
+ interface BooleanParserOptions {
116
+ match?: BooleanParserMatch;
113
117
  }
118
+ /**
119
+ * v3 parser contract:
120
+ * Category: strict
121
+ * Mode: exact
122
+ *
123
+ * Accepts only documented boolean literals after trim/lowercase.
124
+ * Returns true/false only when input is recognized. Pass match: "extract" to
125
+ * extract one documented boolean literal from surrounding text.
126
+ * Throws LlmExeError(parser.parse_failed) for empty or unrecognized input.
127
+ * Invalid input types throw LlmExeError(parser.invalid_input).
128
+ * Error context does not include input content unless LLM_EXE_DEBUG is enabled.
129
+ *
130
+ */
114
131
  declare class BooleanParser extends BaseParser<boolean> {
132
+ private match;
115
133
  constructor(options?: BooleanParserOptions);
116
- parse(text: string): boolean;
134
+ private getInputErrorContext;
135
+ parse(text: string, _attributes?: Record<string, any>): boolean;
117
136
  }
118
137
 
119
- interface NumberParserOptions extends BaseParserOptions {
138
+ type NumberParserMatch = "exact" | "extract";
139
+ interface NumberParserOptions {
140
+ match?: NumberParserMatch;
120
141
  }
142
+ /**
143
+ * v3 parser contract:
144
+ * Category: extractor
145
+ * Mode: numeric token extraction
146
+ *
147
+ * Extracts one documented numeric token from text. Pass match: "exact" to
148
+ * require the input to consist of exactly one numeric token (after trim) with
149
+ * no surrounding prose.
150
+ *
151
+ * Throws LlmExeError(parser.parse_failed) for empty input, no numeric token,
152
+ * multiple numeric tokens, invalid conversion. Invalid input type throws
153
+ * LlmExeError(parser.invalid_input).
154
+ */
121
155
  declare class NumberParser extends BaseParser<number> {
156
+ private match;
122
157
  constructor(options?: NumberParserOptions);
123
- parse(text: string): number;
158
+ parse(text: string, _attributes?: Record<string, any>): number;
124
159
  }
125
160
 
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>>;
161
+ type JsonParserInput = string | Record<string, unknown> | unknown[];
162
+ type JsonParserOutput<S extends JSONSchema | undefined> = S extends JSONSchema ? FromSchema<S> : Record<string, any>;
163
+ declare class JsonParser<S extends JSONSchema | undefined = undefined> extends BaseParserWithJson<S, JsonParserOutput<S>, JsonParserInput> {
164
+ private shouldValidateSchema;
165
+ private match;
166
+ constructor(options?: JsonParserOptions<S>);
167
+ /**
168
+ * v3 parser contract:
169
+ * Category: strict
170
+ * Mode: exact
171
+ *
172
+ * Parses strict JSON object/array output by default. Pass match: "extract"
173
+ * to extract one JSON object or array from surrounding text. Invalid JSON,
174
+ * empty input, JSON primitives, and non-plain runtime objects throw typed parser errors.
175
+ * Schema validation is on by default when a schema is provided unless
176
+ * validateSchema: false is explicitly set.
177
+ *
178
+ */
179
+ parse(text: JsonParserInput, _attributes?: Record<string, any>): JsonParserOutput<S>;
129
180
  }
130
181
 
131
182
  declare class ListToJsonParser<S extends JSONSchema | undefined = undefined> extends BaseParserWithJson<S> {
132
183
  private keyTransform;
184
+ private shouldValidateSchema;
133
185
  constructor(options?: ListToJsonParserOptions<S>);
186
+ /**
187
+ * v3 parser contract:
188
+ * Category: converter
189
+ * Mode: line-oriented format conversion
190
+ *
191
+ * Uses the shared list boundary. Parses normalized lines as key/value pairs
192
+ * split at the first colon. Duplicate keys throw because object output would
193
+ * overwrite data.
194
+ *
195
+ */
134
196
  parse(text: string): ParserOutput<BaseParserWithJson<S>>;
135
197
  }
136
198
 
137
- interface ListToKeyValueParserOptions extends BaseParserOptions {
199
+ interface ListToKeyValueParserOptions {
200
+ keyTransform?: "preserve" | "camelCase";
138
201
  }
139
202
  declare class ListToKeyValueParser extends BaseParser<Array<{
140
203
  key: string;
141
204
  value: string;
142
205
  }>> {
206
+ private keyTransform;
143
207
  constructor(options?: ListToKeyValueParserOptions);
144
- parse(text: string): {
208
+ /**
209
+ * v3 parser contract:
210
+ * Category: converter
211
+ * Mode: line-oriented collector
212
+ *
213
+ * Uses the shared list boundary. Parses normalized lines as key/value pairs
214
+ * split at the first colon. Preserves duplicate keys because output is an
215
+ * ordered array. Keys are returned as written by default; pass
216
+ * keyTransform: "camelCase" to match listToJson's key normalization.
217
+ *
218
+ */
219
+ parse(text: string, _attributes?: Record<string, any>): {
145
220
  key: string;
146
221
  value: string;
147
222
  }[];
@@ -149,180 +224,177 @@ declare class ListToKeyValueParser extends BaseParser<Array<{
149
224
 
150
225
  /**
151
226
  * CustomParser class, extending the BaseParser class.
152
- * @template I The expected type of the input
153
227
  * @template O The type of the parsed value (output)
154
- * @extends {BaseParser<T>}
228
+ * @extends {BaseParser<O>}
229
+ *
230
+ * v3 parser contract:
231
+ * Category: pass-through extension point
232
+ * Mode: user-defined
233
+ *
234
+ * Calls the user parser function with text and the per-call ExecutionContext.
235
+ * Returns the user parser result exactly.
236
+ * Does not wrap user parser errors.
237
+ *
238
+ * When invoked through an executor, `context` includes the resolved trace ID,
239
+ * stable executor metadata, current execution metadata, and the attributes
240
+ * extension bag. When parse() is called directly without a context, callers
241
+ * may pass any shape they want; the type widens to allow that.
155
242
  */
156
243
  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;
244
+ parserFn: (text: string, context: ExecutionContext<any, O>) => O;
245
+ constructor(name: string, parserFn: (text: string, context: ExecutionContext<any, O>) => O);
246
+ parse(text: string, context?: ExecutionContext<any, O>): O;
175
247
  }
176
248
 
249
+ /**
250
+ * v3 parser contract:
251
+ * Category: converter
252
+ * Mode: line-oriented collection conversion
253
+ *
254
+ * Uses the shared list boundary. Returns normalized item text exactly.
255
+ * Throws for empty input, invalid input type, mixed marked/unmarked lines, or
256
+ * a single unmarked prose line.
257
+ *
258
+ */
177
259
  declare class ListToArrayParser extends BaseParser<string[]> {
178
260
  constructor();
179
- parse(text: string): string[];
261
+ parse(text: string, _attributes?: Record<string, any>): string[];
180
262
  }
181
263
 
182
- interface ReplaceStringTemplateParserOptions extends BaseParserOptions {
183
- }
264
+ /**
265
+ * v3 parser contract:
266
+ * Category: pass-through transformation
267
+ * Mode: template replacement
268
+ *
269
+ * Accepts a string template and optional attributes object.
270
+ * Returns the helper replacement result.
271
+ * Throws LlmExeError(parser.parse_failed) for invalid input type,
272
+ * invalid attributes, or template helper failures.
273
+ *
274
+ */
184
275
  declare class ReplaceStringTemplateParser extends BaseParser<string> {
185
- constructor(options?: ReplaceStringTemplateParserOptions);
276
+ constructor();
186
277
  parse(text: string, attributes?: Record<string, any>): string;
187
278
  }
188
279
 
189
- interface MarkdownCodeBlockParserOptions extends BaseParserOptions {
190
- }
280
+ /**
281
+ * v3 parser contract:
282
+ * Category: strict
283
+ * Mode: singular fenced block
284
+ *
285
+ * Accepts input containing exactly one complete fenced markdown code block.
286
+ * Returns that block with exact code content and language string.
287
+ * Throws LlmExeError(parser.parse_failed) for empty input, no block, multiple
288
+ * blocks, malformed fences, or invalid input type.
289
+ *
290
+ */
191
291
  declare class MarkdownCodeBlockParser extends BaseParser<{
192
292
  language: string;
193
293
  code: string;
194
294
  }> {
195
- constructor(options?: MarkdownCodeBlockParserOptions);
196
- parse(input: string): {
295
+ constructor();
296
+ parse(input: string, _attributes?: Record<string, any>): {
197
297
  code: string;
198
298
  language: string;
199
299
  };
200
300
  }
201
301
 
202
- interface MarkdownCodeBlocksParserOptions extends BaseParserOptions {
203
- }
302
+ /**
303
+ * v3 parser contract:
304
+ * Category: collector
305
+ * Mode: markdown fenced block collection
306
+ *
307
+ * Accepts text containing zero or more complete fenced code blocks.
308
+ * Returns all complete blocks in source order.
309
+ * Returns [] when no complete block exists.
310
+ * Throws LlmExeError(parser.parse_failed) for invalid input type or malformed
311
+ * fence structure. Does not unwrap stringified JSON.
312
+ *
313
+ */
204
314
  declare class MarkdownCodeBlocksParser extends BaseParser<{
205
315
  language: string;
206
316
  code: string;
207
317
  }[]> {
208
- constructor(options?: MarkdownCodeBlocksParserOptions);
209
- parse(input: string): {
318
+ constructor();
319
+ parse(input: string, _attributes?: Record<string, any>): {
210
320
  code: string;
211
321
  language: string;
212
322
  }[];
213
323
  }
214
324
 
215
- interface StringExtractParserOptions extends BaseParserOptions {
216
- enum: string[];
325
+ type StringExtractMatch = "exact" | "word" | "substring";
326
+ interface StringExtractParserOptions<E extends readonly string[] = readonly string[]> {
327
+ enum: E;
217
328
  ignoreCase?: boolean;
329
+ match?: StringExtractMatch;
218
330
  }
219
- declare class StringExtractParser extends BaseParser<string> {
331
+ declare class StringExtractParser<E extends readonly string[] = readonly string[]> extends BaseParser<E[number]> {
220
332
  private enum;
221
333
  private ignoreCase;
222
- constructor(options?: StringExtractParserOptions);
223
- parse(text: string): string;
334
+ private match;
335
+ constructor(options?: StringExtractParserOptions<E>);
336
+ /**
337
+ * v3 parser contract:
338
+ * Category: extractor
339
+ * Mode: configured value extraction
340
+ *
341
+ * Returns the single configured enum value found in input. Matching is
342
+ * word-bounded by default; pass match: "exact" to require exact input or
343
+ * match: "substring" for legacy contains() behavior. Case-insensitive by
344
+ * default.
345
+ *
346
+ */
347
+ parse(text: string, _attributes?: Record<string, any>): E[number];
348
+ private findMatches;
349
+ private matchExact;
350
+ private matchSubstring;
351
+ private matchWord;
224
352
  }
225
353
 
226
354
  /**
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.
355
+ * Labeled-tuple union for `createParser` arguments. Each branch enumerates
356
+ * exactly what's valid for one parser type. TypeScript validates the whole
357
+ * argument tuple against this union, which produces useful error messages
358
+ * (e.g. "Source has 1 element(s) but target requires 2" when stringExtract
359
+ * is called without options) instead of overload-resolution mystery.
266
360
  */
267
- declare function createParser<T extends Extract<CreateParserType, "boolean">, S extends JSONSchema | undefined = undefined>(type: T, options?: BaseParserOptions): BooleanParser;
361
+ type CreateParserArgs = [type: "string", options?: never] | [type: "boolean", options?: BooleanParserOptions] | [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>] | [
362
+ type: "listToJson",
363
+ options?: ListToJsonParserOptions<JSONSchema | undefined>
364
+ ] | [
365
+ type: "stringExtract",
366
+ options: StringExtractParserOptions<readonly string[]>
367
+ ];
268
368
  /**
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.
369
+ * Maps a concrete argument tuple back to the parser instance type, preserving
370
+ * schema inference for json/listToJson and enum literal narrowing for
371
+ * stringExtract.
273
372
  */
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.
287
- */
288
- declare function createParser<T extends Extract<CreateParserType, "stringExtract">, S extends JSONSchema | undefined = undefined>(type: T, options?: StringExtractParserOptions): StringExtractParser;
289
- /**
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.
295
- */
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>>;
373
+ 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 [
374
+ "listToJson",
375
+ ListToJsonParserOptions<infer S>
376
+ ] ? ListToJsonParser<S> : A extends readonly [
377
+ "stringExtract",
378
+ StringExtractParserOptions<infer E extends readonly string[]>
379
+ ] ? StringExtractParser<E> : never;
380
+ declare function createParser<const A extends CreateParserArgs>(...args: A): CreateParserReturn<A>;
381
+ declare function createCustomParser<O>(name: string, parserFn: (text: string, context: ExecutionContext<any, any>) => O): CustomParser<ReturnType<typeof parserFn>>;
307
382
 
308
- declare class LlmFunctionParser<T extends BaseParser<any>> extends BaseParser<ParserOutput<T> | OutputResultContent[]> {
309
- parser: T;
310
- constructor(options: LlmNativeFunctionParserOptions<T>);
311
- parse(text: OutputResult, _options?: Record<string, any>): OutputResultContent[] | ParserOutput<T>;
312
- }
313
- interface LlmNativeFunctionParserOptions<T extends BaseParser<any>> extends BaseParserOptions {
383
+ interface LlmNativeFunctionParserOptions<T extends BaseParser<any, any>> {
314
384
  parser: T;
315
385
  }
316
- interface LlmNativeFunctionParserOptions<T extends BaseParser<any>> extends BaseParserOptions {
386
+ declare class LlmFunctionParser<T extends BaseParser<any, any>> extends BaseParser<ParserOutput<T> | OutputResultContent[], OutputResult | string> {
317
387
  parser: T;
388
+ constructor(options: LlmNativeFunctionParserOptions<T>);
389
+ parse(text: OutputResult, _options?: Record<string, any>): ParserOutput<T> | OutputResultContent[];
318
390
  }
319
391
  /**
320
392
  * @deprecated Use `LlmFunctionParser` instead.
321
393
  */
322
- declare class LlmNativeFunctionParser<T extends BaseParser<any>> extends BaseParser<ParserOutput<T> | {
394
+ declare class LlmNativeFunctionParser<T extends BaseParser<any, any>> extends BaseParser<ParserOutput<T> | {
323
395
  name: any;
324
396
  arguments: any;
325
- }> {
397
+ }, OutputResult | string> {
326
398
  parser: T;
327
399
  constructor(options: LlmNativeFunctionParserOptions<T>);
328
400
  parse(text: OutputResult, _options?: Record<string, any>): ParserOutput<T> | {
@@ -347,6 +419,7 @@ declare abstract class BasePrompt<I extends Record<string, any>> {
347
419
  messages: IPromptMessages | IPromptChatMessages;
348
420
  partials: PromptPartial[];
349
421
  helpers: PromptHelper[];
422
+ validateInput: ValidateInputMode;
350
423
  replaceTemplateString: typeof replaceTemplateString;
351
424
  replaceTemplateStringAsync: typeof replaceTemplateStringAsync;
352
425
  filters: {
@@ -383,6 +456,16 @@ declare abstract class BasePrompt<I extends Record<string, any>> {
383
456
  * @return BasePrompt so it can be chained.
384
457
  */
385
458
  registerHelpers(helperOrHelpers: PromptHelper | PromptHelper[]): this;
459
+ /**
460
+ * Returns the Handlebars-bearing strings that should be validated, along
461
+ * with a location label used for error context. Subclasses with structured
462
+ * message content (e.g. ChatPrompt) should override.
463
+ */
464
+ protected getTemplateContents(): {
465
+ content: string;
466
+ location: string;
467
+ }[];
468
+ protected preflightValidate(values: I): void;
386
469
  /**
387
470
  * format description
388
471
  * @param values The message content
@@ -403,10 +486,17 @@ declare abstract class BasePrompt<I extends Record<string, any>> {
403
486
  _input: any;
404
487
  };
405
488
  /**
406
- * Validates the prompt structure.
407
- * @return {boolean} Returns false if the prompt has no messages defined.
489
+ * Validates that `input` provides every variable referenced by this prompt's
490
+ * templates, and that every identifiable helper call is registered.
491
+ *
492
+ * @breaking v3: previously returned `this.messages.length > 0` with no
493
+ * `input` parameter. For the old behavior, read `prompt.messages.length > 0`
494
+ * directly.
495
+ *
496
+ * @throws LlmExeError with code `"prompt.missing_template_variable"` listing
497
+ * all missing variables and helpers.
408
498
  */
409
- validate(): boolean;
499
+ validate(input: I): void;
410
500
  }
411
501
 
412
502
  /**
@@ -535,6 +625,7 @@ type PromptPartial = {
535
625
  name: string;
536
626
  template: string;
537
627
  };
628
+ type ValidateInputMode = false | "strict" | "warn";
538
629
  interface PromptTemplateOptions {
539
630
  partials?: PromptPartial[];
540
631
  helpers?: PromptHelper[];
@@ -543,6 +634,15 @@ interface PromptOptions extends PromptTemplateOptions {
543
634
  preFilters?: ((prompt: string) => string)[];
544
635
  postFilters?: ((prompt: string) => string)[];
545
636
  replaceTemplateString?: (...args: any[]) => string;
637
+ /**
638
+ * Controls whether `format()` preflights input against the variables
639
+ * referenced by the prompt's templates. See `validate(input)`.
640
+ *
641
+ * - `false` (default): no preflight; rendering proceeds.
642
+ * - `"strict"`: throw `LlmExeError("prompt.missing_template_variable")` before rendering.
643
+ * - `"warn"`: emit a Node warning via `process.emitWarning` and continue rendering.
644
+ */
645
+ validateInput?: ValidateInputMode;
546
646
  }
547
647
  interface ChatPromptOptions extends PromptOptions {
548
648
  allowUnsafeUserTemplate?: boolean;
@@ -602,10 +702,27 @@ declare abstract class BaseExecutor<I extends PlainObject, O = any, H extends Ba
602
702
  */
603
703
  readonly maxHooksPerEvent: number;
604
704
  constructor(name: string, type: string, options?: CoreExecutorExecuteOptions<H>);
605
- abstract handler(input: I, _options?: any): Promise<any>;
705
+ abstract handler(input: I, _options?: any, _context?: ExecutionContext<I, O>): Promise<any>;
606
706
  /**
707
+ * Build a per-call execution context snapshot. Captures the current
708
+ * execution metadata so the snapshot reflects state at the time it was
709
+ * taken (e.g. `handlerInput` becomes available after `getHandlerInput`).
710
+ */
711
+ protected snapshotContext(execution: ExecutorExecutionMetadata<I, O>): ExecutionContext<I, O>;
712
+ /**
713
+ *
714
+ * Used to filter the input of the handler.
715
+ *
716
+ * Throws a `TypeError` if `_input` is `null` or `undefined`. The declared
717
+ * input type is `I extends PlainObject`; omitting input or passing an
718
+ * explicit `null` is a contract violation with no valid coercion, so we
719
+ * surface it loudly rather than silently wrapping it.
720
+ *
721
+ * Non-object inputs (strings, numbers, arrays) are intentionally coerced
722
+ * to `{ input: value }` via {@link ensureInputIsObject}. This preserves the
723
+ * convenience pattern used by tool/function callables, which forward raw
724
+ * string arguments into an executor.
607
725
  *
608
- * Used to filter the input of the handler
609
726
  * @param _input
610
727
  * @returns original input formatted for handler
611
728
  */
@@ -616,7 +733,7 @@ declare abstract class BaseExecutor<I extends PlainObject, O = any, H extends Ba
616
733
  * @param _input
617
734
  * @returns output O
618
735
  */
619
- getHandlerOutput(out: any, _metadata: ExecutorExecutionMetadata<any, O>, _options?: any): O;
736
+ getHandlerOutput(out: any, _metadata: ExecutorExecutionMetadata<any, O>, _options?: any, _context?: ExecutionContext<I, O>): O;
620
737
  /**
621
738
  *
622
739
  * execute - Runs the executor
@@ -624,9 +741,10 @@ declare abstract class BaseExecutor<I extends PlainObject, O = any, H extends Ba
624
741
  * @returns handler output
625
742
  */
626
743
  execute(_input: I, _options?: any): Promise<O>;
744
+ private collectHookErrors;
627
745
  metadata(): Record<string, any>;
628
746
  getMetadata(metadata?: Record<string, any>): ExecutorMetadata;
629
- runHook(hook: keyof H, _metadata: ExecutorExecutionMetadata): void;
747
+ runHook(hook: keyof H, _metadata: ExecutorExecutionMetadata): HookErrorRecord[];
630
748
  setHooks(hooks?: CoreExecutorHookInput<H>): this;
631
749
  removeHook(eventName: keyof H, fn: ListenerFunction): this;
632
750
  on(eventName: keyof H, fn: ListenerFunction): this;
@@ -785,16 +903,24 @@ declare function createStateItem<T>(name: string, defaultValue: T): DefaultState
785
903
  /**
786
904
  * Core Executor With LLM
787
905
  */
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> {
906
+ 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
907
  llm: Llm;
790
908
  prompt: Prompt | undefined;
791
909
  promptFn: any;
792
910
  parser: StringParser | Parser;
793
911
  constructor(llmConfiguration: ExecutorWithLlmOptions<Llm, Prompt, Parser, State>, options?: CoreExecutorExecuteOptions<LlmExecutorHooks>);
912
+ /**
913
+ * Runs the executor against the configured LLM and prompt.
914
+ *
915
+ * `null` and `undefined` are rejected with a `TypeError`: the declared
916
+ * input type requires an object, and silently coercing missing input hides a
917
+ * clear contract violation. Use `{}` for prompts that declare no template
918
+ * variables. See issue #410.
919
+ */
794
920
  execute(_input: PromptInput<Prompt>, _options?: LlmExecutorExecuteOptions): Promise<ParserOutput<Parser>>;
795
- handler(_input: PromptInput<Prompt>, ..._args: any[]): Promise<any>;
921
+ handler(_input: PromptInput<Prompt>, _options?: LlmExecutorExecuteOptions, _context?: ExecutionContext<PromptInput<Prompt>, ParserOutput<Parser>>): Promise<any>;
796
922
  getHandlerInput(_input: PromptInput<Prompt>): Promise<any>;
797
- getHandlerOutput(out: BaseLlCall, _metadata: ExecutorExecutionMetadata<PromptInput<Prompt>, ParserOutput<Parser>>): ParserOutput<Parser>;
923
+ getHandlerOutput(out: BaseLlCall, _metadata: ExecutorExecutionMetadata<PromptInput<Prompt>, ParserOutput<Parser>>, _options?: LlmExecutorExecuteOptions, _context?: ExecutionContext<PromptInput<Prompt>, ParserOutput<Parser>>): ParserOutput<Parser>;
798
924
  metadata(): {
799
925
  llm: Record<string, any>;
800
926
  };
@@ -844,7 +970,7 @@ declare const hookOnError = "onError";
844
970
  declare const hookOnSuccess = "onSuccess";
845
971
 
846
972
  type ListenerFunction = (...args: any[]) => void;
847
- type ParserOutput<P> = P extends BaseParser<infer T> ? T : never;
973
+ type ParserOutput<P> = P extends BaseParser<infer T, any> ? T : never;
848
974
  type PromptInput<P> = P extends BasePrompt<infer T> ? T : never;
849
975
  interface ExecutorWithLlmOptions<Llm, Prompt, Parser, State> {
850
976
  name?: string;
@@ -871,6 +997,15 @@ interface ExecutorMetadata {
871
997
  executions: number;
872
998
  metadata?: Record<string, any>;
873
999
  }
1000
+ interface HookErrorRecord {
1001
+ hook: string;
1002
+ error: unknown;
1003
+ errorMessage: string;
1004
+ errorCategory?: string;
1005
+ errorCode?: string;
1006
+ errorContext?: unknown;
1007
+ errorCause?: unknown;
1008
+ }
874
1009
  interface ExecutorExecutionMetadata<I = any, O = any> {
875
1010
  start: null | number;
876
1011
  end: null | number;
@@ -880,12 +1015,29 @@ interface ExecutorExecutionMetadata<I = any, O = any> {
880
1015
  output?: O;
881
1016
  errorMessage?: string;
882
1017
  error?: Error;
1018
+ errorCategory?: string;
1019
+ errorCode?: string;
1020
+ errorContext?: unknown;
1021
+ errorCause?: unknown;
1022
+ hookErrors?: HookErrorRecord[];
883
1023
  metadata?: null | ExecutorMetadata;
884
1024
  }
885
1025
  interface ExecutorContext<I = any, O = any, A = Record<string, any>> extends ExecutorExecutionMetadata<I, O> {
886
1026
  metadata: ExecutorMetadata;
887
1027
  attributes: A;
888
1028
  }
1029
+ /**
1030
+ * Per-call execution context. Built by `BaseExecutor.execute()` and threaded
1031
+ * through `handler()`, `llm.call()`, parsers, and warnings. Provides a single
1032
+ * place to read the resolved trace ID, stable executor identity, and the
1033
+ * mutable execution state for the current run.
1034
+ */
1035
+ interface ExecutionContext<I = any, O = any, A = Record<string, any>> {
1036
+ traceId?: string;
1037
+ executor: ExecutorMetadata;
1038
+ execution: ExecutorExecutionMetadata<I, O>;
1039
+ attributes: A;
1040
+ }
889
1041
  interface BaseExecutorHooks {
890
1042
  [hookOnError]: ListenerFunction[];
891
1043
  [hookOnSuccess]: ListenerFunction[];
@@ -919,14 +1071,15 @@ interface LlmExecutorWithFunctionsOptions<T extends GenericFunctionCall = "auto"
919
1071
  jsonSchema?: Record<string, any>;
920
1072
  }
921
1073
 
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 {
1074
+ interface ParserSchemaOptions<S extends JSONSchema | undefined = undefined> {
926
1075
  schema?: S;
927
1076
  validateSchema?: boolean;
928
1077
  }
929
- interface ListToJsonParserOptions<S extends JSONSchema | undefined = undefined> extends BaseParserOptionsWithSchema<S> {
1078
+ type JsonParserMatch = "exact" | "extract";
1079
+ interface JsonParserOptions<S extends JSONSchema | undefined = undefined> extends ParserSchemaOptions<S> {
1080
+ match?: JsonParserMatch;
1081
+ }
1082
+ interface ListToJsonParserOptions<S extends JSONSchema | undefined = undefined> extends ParserSchemaOptions<S> {
930
1083
  keyTransform?: "camelCase" | "preserve";
931
1084
  }
932
1085
 
@@ -1397,8 +1550,224 @@ interface Config<Pk = LlmProviderKey> {
1397
1550
  * `getEmbeddingOutputParser` instead.
1398
1551
  */
1399
1552
  transformResponse?: (result: any, _config?: Config<any>) => OutputResult;
1553
+ /**
1554
+ * Marks this config as deprecated. When set, useLlm() will emit a one-time
1555
+ * deprecation warning to inform users about upcoming model shutdowns.
1556
+ */
1557
+ deprecated?: {
1558
+ shorthand: string;
1559
+ message: string;
1560
+ };
1400
1561
  }
1401
1562
 
1563
+ type JsonSafe = string | number | boolean | null | JsonSafe[] | {
1564
+ [key: string]: JsonSafe;
1565
+ };
1566
+ type ErrorCategory = "unknown" | "configuration" | "llm" | "embedding" | "prompt" | "parser" | "executor" | "callable" | "state" | "request" | "auth" | "template" | "internal";
1567
+ type BaseErrorContext = {
1568
+ operation?: string;
1569
+ provider?: string;
1570
+ model?: string;
1571
+ key?: string;
1572
+ input?: unknown;
1573
+ output?: unknown;
1574
+ response?: unknown;
1575
+ status?: number;
1576
+ url?: string;
1577
+ parser?: string;
1578
+ promptType?: string;
1579
+ functionName?: string;
1580
+ hook?: string;
1581
+ expected?: unknown;
1582
+ received?: unknown;
1583
+ resolution?: string;
1584
+ docsPath?: string;
1585
+ docsUrl?: string;
1586
+ };
1587
+ type ConfigurationProviderContext = BaseErrorContext & {
1588
+ provider?: string;
1589
+ availableProviders?: string[];
1590
+ };
1591
+ type MissingConfigurationContext = BaseErrorContext & {
1592
+ provider?: string;
1593
+ key?: string;
1594
+ option?: string;
1595
+ envVar?: string;
1596
+ };
1597
+ type InvalidHeadersContext = BaseErrorContext & {
1598
+ provider?: string;
1599
+ key?: string;
1600
+ headerTemplate?: string;
1601
+ replacedHeadersExcerpt?: string;
1602
+ };
1603
+ type ParserInvalidTypeContext = BaseErrorContext & {
1604
+ parser?: unknown;
1605
+ availableParsers?: string[];
1606
+ };
1607
+ type ParserSchemaValidationContext = BaseErrorContext & {
1608
+ parser?: string;
1609
+ schemaErrors?: unknown;
1610
+ outputExcerpt?: string;
1611
+ };
1612
+ type ParserParseFailedContext = BaseErrorContext & {
1613
+ parser?: string;
1614
+ reason?: string;
1615
+ inputExcerpt?: string;
1616
+ inputExcerptTruncated?: boolean;
1617
+ inputLength?: number;
1618
+ matchCount?: number;
1619
+ match?: string;
1620
+ outputExcerpt?: string;
1621
+ };
1622
+ type PromptInputContext = BaseErrorContext & {
1623
+ promptType?: string;
1624
+ };
1625
+ type PromptMessagesContext = BaseErrorContext & {
1626
+ provider?: string;
1627
+ };
1628
+ type PromptMissingTemplateVariableContext = BaseErrorContext & {
1629
+ promptType?: string;
1630
+ missingVariables: string[];
1631
+ missingHelpers: string[];
1632
+ };
1633
+ type NormalizedProviderError = {
1634
+ message?: string;
1635
+ providerType?: string;
1636
+ providerCode?: string;
1637
+ status?: number;
1638
+ statusText?: string;
1639
+ retryable?: boolean;
1640
+ retryAfterMs?: number;
1641
+ };
1642
+ type ProviderErrorContext = BaseErrorContext & {
1643
+ provider?: string;
1644
+ model?: string;
1645
+ status?: number;
1646
+ statusText?: string;
1647
+ url?: string;
1648
+ providerError?: NormalizedProviderError;
1649
+ providerErrorBody?: unknown;
1650
+ providerErrorRaw?: string;
1651
+ responseHeaders?: Record<string, string>;
1652
+ };
1653
+ type ProviderResponseContext = BaseErrorContext & {
1654
+ provider?: string;
1655
+ model?: string;
1656
+ responseExcerpt?: string;
1657
+ lineNumber?: number;
1658
+ lineExcerpt?: string;
1659
+ lineCount?: number;
1660
+ availableProviders?: string[];
1661
+ };
1662
+ type EmbeddingDimensionsContext = BaseErrorContext & {
1663
+ provider?: string;
1664
+ model?: string;
1665
+ dimensions?: number;
1666
+ };
1667
+ type ExecutorErrorContext = BaseErrorContext & {
1668
+ executorName?: string;
1669
+ executorType?: string;
1670
+ traceId?: string;
1671
+ };
1672
+ type ExecutorHookContext = ExecutorErrorContext & {
1673
+ hook?: string;
1674
+ hookCount?: number;
1675
+ maxHooksPerEvent?: number;
1676
+ };
1677
+ type CallableErrorContext = BaseErrorContext & {
1678
+ functionName?: string;
1679
+ availableFunctions?: string[];
1680
+ };
1681
+ type TemplateHelperContext = BaseErrorContext & {
1682
+ helper?: string;
1683
+ };
1684
+ type StateErrorContext = BaseErrorContext & {
1685
+ module?: string;
1686
+ };
1687
+ type AwsAuthContext = BaseErrorContext & {
1688
+ url?: string;
1689
+ regionName?: string;
1690
+ };
1691
+ type RequestErrorContext = BaseErrorContext & {
1692
+ url?: string;
1693
+ status?: number;
1694
+ statusText?: string;
1695
+ providerError?: NormalizedProviderError;
1696
+ providerErrorBody?: unknown;
1697
+ providerErrorRaw?: string;
1698
+ responseHeaders?: Record<string, string>;
1699
+ };
1700
+ type InternalErrorContext = BaseErrorContext & {
1701
+ invariant?: string;
1702
+ };
1703
+ type ErrorContextByCode = {
1704
+ "configuration.missing_provider": ConfigurationProviderContext;
1705
+ "configuration.invalid_provider": ConfigurationProviderContext;
1706
+ "configuration.missing_env": MissingConfigurationContext;
1707
+ "configuration.missing_option": MissingConfigurationContext;
1708
+ "configuration.invalid_headers": InvalidHeadersContext;
1709
+ "parser.invalid_type": ParserInvalidTypeContext;
1710
+ "parser.invalid_input": ParserParseFailedContext;
1711
+ "parser.parse_failed": ParserParseFailedContext;
1712
+ "parser.schema_validation_failed": ParserSchemaValidationContext;
1713
+ "prompt.missing_input": PromptInputContext;
1714
+ "prompt.invalid_messages": PromptMessagesContext;
1715
+ "prompt.missing_template_variable": PromptMissingTemplateVariableContext;
1716
+ "llm.provider_http_error": ProviderErrorContext;
1717
+ "llm.provider_rate_limited": ProviderErrorContext;
1718
+ "llm.provider_auth_failed": ProviderErrorContext;
1719
+ "llm.provider_invalid_request": ProviderErrorContext;
1720
+ "llm.provider_unavailable": ProviderErrorContext;
1721
+ "llm.invalid_response_shape": ProviderResponseContext;
1722
+ "llm.invalid_jsonl_response": ProviderResponseContext;
1723
+ "embedding.provider_http_error": ProviderErrorContext;
1724
+ "embedding.provider_rate_limited": ProviderErrorContext;
1725
+ "embedding.provider_auth_failed": ProviderErrorContext;
1726
+ "embedding.provider_invalid_request": ProviderErrorContext;
1727
+ "embedding.provider_unavailable": ProviderErrorContext;
1728
+ "embedding.missing_provider": ConfigurationProviderContext;
1729
+ "embedding.invalid_provider": ConfigurationProviderContext;
1730
+ "embedding.unsupported_dimensions": EmbeddingDimensionsContext;
1731
+ "embedding.invalid_response_shape": ProviderResponseContext;
1732
+ "executor.missing_prompt": ExecutorErrorContext;
1733
+ "executor.hook_limit_reached": ExecutorHookContext;
1734
+ "executor.hook_failed": ExecutorHookContext;
1735
+ "callable.invalid_handler": CallableErrorContext;
1736
+ "callable.handler_not_found": CallableErrorContext;
1737
+ "callable.validation_failed": CallableErrorContext;
1738
+ "template.invalid_helper_arguments": TemplateHelperContext;
1739
+ "state.invalid_arguments": StateErrorContext;
1740
+ "auth.aws_signing_input_missing": AwsAuthContext;
1741
+ "request.invalid_url": RequestErrorContext;
1742
+ "request.http_error": RequestErrorContext;
1743
+ "internal.invariant_failed": InternalErrorContext;
1744
+ "unknown.unclassified": Record<string, unknown>;
1745
+ };
1746
+ type ErrorCodes = keyof ErrorContextByCode;
1747
+ type CategoryFor<C extends ErrorCodes> = C extends `${infer Category}.${string}` ? Category & ErrorCategory : never;
1748
+ type SerializableCause = {
1749
+ name?: string;
1750
+ message?: string;
1751
+ category?: string;
1752
+ code?: string;
1753
+ context?: unknown;
1754
+ cause?: unknown;
1755
+ } | JsonSafe;
1756
+ type LlmExeErrorOptions<C extends ErrorCodes = ErrorCodes> = {
1757
+ code: C;
1758
+ context?: ErrorContextByCode[C];
1759
+ cause?: unknown;
1760
+ };
1761
+ type LlmExeErrorJson<C extends ErrorCodes = ErrorCodes> = {
1762
+ name: "LlmExeError";
1763
+ message: string;
1764
+ category: CategoryFor<C>;
1765
+ code: C;
1766
+ context?: ErrorContextByCode[C];
1767
+ cause?: SerializableCause;
1768
+ truncated?: boolean;
1769
+ };
1770
+
1402
1771
  declare function enforceResultAttributes<O>(input: any): {
1403
1772
  result: O;
1404
1773
  attributes: Record<string, any>;
@@ -1513,6 +1882,20 @@ declare function assert(condition: any, message?: string | Error | undefined): a
1513
1882
 
1514
1883
  declare function defineSchema<T>(obj: Narrow<T>): Narrow<T>;
1515
1884
 
1885
+ declare const LLM_EXE_ERROR_SYMBOL: unique symbol;
1886
+ declare class LlmExeError<C extends ErrorCodes = "unknown.unclassified"> extends Error {
1887
+ readonly name: "LlmExeError";
1888
+ readonly isLlmExeError: true;
1889
+ readonly [LLM_EXE_ERROR_SYMBOL]: true;
1890
+ readonly category: CategoryFor<C>;
1891
+ readonly code: C;
1892
+ readonly context?: ErrorContextByCode[C];
1893
+ constructor(message: string, options: LlmExeErrorOptions<C>);
1894
+ toJSON(): LlmExeErrorJson<C>;
1895
+ }
1896
+
1897
+ declare function isLlmExeError<C extends ErrorCodes>(error: unknown, code?: C | readonly C[]): error is LlmExeError<C>;
1898
+
1516
1899
  declare function importPartials(_partials: {
1517
1900
  [key in string]: string;
1518
1901
  }): PromptPartial[];
@@ -1536,6 +1919,9 @@ declare function isObjectStringified(maybeObject: string): boolean;
1536
1919
  declare function registerHelpers(helpers: any[]): void;
1537
1920
  declare function registerPartials(partials: any[]): void;
1538
1921
 
1922
+ declare const index_LLM_EXE_ERROR_SYMBOL: typeof LLM_EXE_ERROR_SYMBOL;
1923
+ type index_LlmExeError<C extends ErrorCodes = "unknown.unclassified"> = LlmExeError<C>;
1924
+ declare const index_LlmExeError: typeof LlmExeError;
1539
1925
  declare const index_assert: typeof assert;
1540
1926
  declare const index_asyncCallWithTimeout: typeof asyncCallWithTimeout;
1541
1927
  declare const index_defineSchema: typeof defineSchema;
@@ -1543,6 +1929,7 @@ declare const index_filterObjectOnSchema: typeof filterObjectOnSchema;
1543
1929
  declare const index_guessProviderFromModel: typeof guessProviderFromModel;
1544
1930
  declare const index_importHelpers: typeof importHelpers;
1545
1931
  declare const index_importPartials: typeof importPartials;
1932
+ declare const index_isLlmExeError: typeof isLlmExeError;
1546
1933
  declare const index_isObjectStringified: typeof isObjectStringified;
1547
1934
  declare const index_maybeParseJSON: typeof maybeParseJSON;
1548
1935
  declare const index_maybeStringifyJSON: typeof maybeStringifyJSON;
@@ -1551,7 +1938,7 @@ declare const index_registerPartials: typeof registerPartials;
1551
1938
  declare const index_replaceTemplateString: typeof replaceTemplateString;
1552
1939
  declare const index_replaceTemplateStringAsync: typeof replaceTemplateStringAsync;
1553
1940
  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 };
1941
+ 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
1942
  }
1556
1943
 
1557
1944
  declare function isOutputResult(obj: any): obj is OutputResult;
@@ -1588,15 +1975,15 @@ declare const configs: {
1588
1975
  "deepseek.chat": Config<keyof AllLlm>;
1589
1976
  "deepseek.v4-flash": Config<keyof AllLlm>;
1590
1977
  "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
1978
  "google.gemini-2.0-flash": Config<keyof AllLlm>;
1598
1979
  "google.gemini-2.0-flash-lite": Config<keyof AllLlm>;
1599
1980
  "google.gemini-1.5-pro": Config<keyof AllLlm>;
1981
+ "google.gemini-2.5-pro": Config<any>;
1982
+ "google.gemini-2.5-flash-lite": Config<any>;
1983
+ "google.gemini-2.5-flash": Config<any>;
1984
+ "google.chat.v1": Config<keyof AllLlm>;
1985
+ "google.gemini-3.1-flash-lite": Config<keyof AllLlm>;
1986
+ "google.gemini-3.5-flash": Config<keyof AllLlm>;
1600
1987
  "ollama.chat.v1": Config<keyof AllLlm>;
1601
1988
  "ollama.deepseek-r1": Config<keyof AllLlm>;
1602
1989
  "ollama.llama3.3": Config<keyof AllLlm>;
@@ -1622,20 +2009,21 @@ declare const configs: {
1622
2009
  "xai.grok-4.20-reasoning": Config<keyof AllLlm>;
1623
2010
  "amazon:anthropic.chat.v1": Config<keyof AllLlm>;
1624
2011
  "amazon:meta.chat.v1": Config<keyof AllLlm>;
2012
+ "anthropic.claude-3-opus": Config<any>;
2013
+ "anthropic.claude-3-5-haiku": Config<any>;
2014
+ "anthropic.claude-3-5-sonnet": Config<any>;
2015
+ "anthropic.claude-3-7-sonnet": Config<any>;
2016
+ "anthropic.claude-opus-4": Config<any>;
2017
+ "anthropic.claude-sonnet-4": Config<any>;
2018
+ "anthropic.claude-opus-4-1": Config<any>;
2019
+ "anthropic.claude-opus-4-6": Config<any>;
1625
2020
  "anthropic.chat.v1": Config<keyof AllLlm>;
1626
2021
  "anthropic.claude-opus-4-7": Config<keyof AllLlm>;
1627
2022
  "anthropic.claude-sonnet-4-6": Config<keyof AllLlm>;
1628
2023
  "anthropic.claude-opus-4-5": Config<keyof AllLlm>;
1629
2024
  "anthropic.claude-haiku-4-5": Config<keyof AllLlm>;
1630
2025
  "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>;
2026
+ "openai.o4-mini": Config<any>;
1639
2027
  "openai.chat.v1": Config<keyof AllLlm>;
1640
2028
  "openai.chat-mock.v1": Config<keyof AllLlm>;
1641
2029
  "openai.gpt-5.2": Config<keyof AllLlm>;
@@ -1648,12 +2036,11 @@ declare const configs: {
1648
2036
  "openai.gpt-4": Config<keyof AllLlm>;
1649
2037
  "openai.gpt-4o": Config<keyof AllLlm>;
1650
2038
  "openai.gpt-4o-mini": Config<keyof AllLlm>;
1651
- "openai.o4-mini": Config<keyof AllLlm>;
1652
2039
  };
1653
2040
 
1654
2041
  declare function useLlm<T extends keyof typeof configs>(provider: T, options?: AllUseLlmOptions[T]["input"]): BaseLlm;
1655
2042
  declare function useLlmConfiguration<T extends keyof typeof configs>(config: Config<any>): (options?: AllUseLlmOptions[T]["input"]) => {
1656
- call: (messages: string | IChatMessages, options?: LlmExecutorWithFunctionsOptions) => Promise<{
2043
+ call: (messages: string | IChatMessages, options?: LlmExecutorWithFunctionsOptions, context?: ExecutionContext) => Promise<{
1657
2044
  getResultContent: (index?: number) => OutputResultContent[];
1658
2045
  getResultText: (index?: number) => string;
1659
2046
  getResult: () => OutputResult;
@@ -1682,7 +2069,7 @@ declare function createOpenAiCompatibleConfiguration<K extends Config["key"]>(ov
1682
2069
  }): Config<keyof AllLlm>;
1683
2070
 
1684
2071
  declare function createEmbedding<T extends EmbeddingProviderKey>(provider: T, options: AllEmbedding[T]["input"]): {
1685
- call: (messages: string | string[], options?: LlmExecutorWithFunctionsOptions) => Promise<{
2072
+ call: (messages: string | string[], options?: LlmExecutorWithFunctionsOptions, context?: ExecutionContext) => Promise<{
1686
2073
  getEmbedding: (index?: number) => number[];
1687
2074
  getResult: () => EmbeddingOutputResult;
1688
2075
  }>;
@@ -1700,4 +2087,4 @@ declare function createEmbedding<T extends EmbeddingProviderKey>(provider: T, op
1700
2087
  };
1701
2088
  };
1702
2089
 
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 };
2090
+ export { BaseExecutor, type BaseLlm, BaseParser, BasePrompt, BaseStateItem, type BooleanParserMatch, type BooleanParserOptions, ChatPrompt, CustomParser, DefaultState, DefaultStateItem, type EmbeddingProviderKey, type ErrorCategory, type ErrorCodes, type ErrorContextByCode, type ExecutionContext, type ExecutorContext, type ExecutorExecutionMetadata, type HookErrorRecord, type IChatMessages, type JsonParserMatch, type JsonParserOptions, LLM_EXE_ERROR_SYMBOL, LlmExeError, LlmExecutorOpenAiFunctions, LlmExecutorWithFunctions, LlmNativeFunctionParser, type LlmProvider, type LlmProviderKey, type NormalizedProviderError, type NumberParserMatch, type NumberParserOptions, type OpenAIModelName, OpenAiFunctionParser, type ProviderErrorContext, type StringExtractMatch, type StringExtractParserOptions, 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 };