llm-exe 3.0.0 → 3.1.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.
@@ -0,0 +1,1223 @@
1
+ import { JSONSchema, FromSchema } from 'json-schema-to-ts';
2
+
3
+ type PrimitiveValue = bigint | boolean | null | number | string | symbol | undefined;
4
+ type ObjectValue = PrimitiveValue | PlainObject | ObjectArray;
5
+ interface PlainObject {
6
+ [key: string]: ObjectValue;
7
+ }
8
+ interface ObjectArray extends Array<ObjectValue> {
9
+ }
10
+ interface Serializable {
11
+ serialize?(): Record<string, any>;
12
+ deserialize?(): void;
13
+ }
14
+
15
+ type IChatMessageRole = "system" | "model" | "assistant" | "user" | "function" | "function_call";
16
+ interface IChatMessageContentDetailed {
17
+ type: string;
18
+ text?: string;
19
+ image_url?: {
20
+ url: string;
21
+ };
22
+ }
23
+ interface IChatMessageBase {
24
+ role: IChatMessageRole;
25
+ content: string | null | IChatMessageContentDetailed[];
26
+ }
27
+ interface IChatUserMessage extends IChatMessageBase {
28
+ role: Extract<IChatMessageRole, "user">;
29
+ content: string | IChatMessageContentDetailed[];
30
+ name?: string;
31
+ }
32
+ interface IChatFunctionMessage extends IChatMessageBase {
33
+ id?: string;
34
+ role: Extract<IChatMessageRole, "function">;
35
+ content: string;
36
+ name: string;
37
+ }
38
+ interface IChatAssistantMessage extends IChatMessageBase {
39
+ role: Extract<IChatMessageRole, "assistant" | "model">;
40
+ content: string;
41
+ function_call?: undefined;
42
+ }
43
+ interface IChatFunctionCallMessage extends IChatMessageBase {
44
+ role: Extract<IChatMessageRole, "function_call">;
45
+ content: null;
46
+ function_call: {
47
+ name: string;
48
+ arguments: string;
49
+ id?: string;
50
+ };
51
+ }
52
+ interface IChatSystemMessage extends IChatMessageBase {
53
+ role: Extract<IChatMessageRole, "system">;
54
+ content: string;
55
+ }
56
+ interface IChatMessagesPlaceholder {
57
+ role: "placeholder";
58
+ content: string;
59
+ }
60
+ type IPromptMessages = (IChatSystemMessage | IChatMessagesPlaceholder)[];
61
+ type IPromptChatMessages = (IChatUserMessage | IChatAssistantMessage | IChatFunctionCallMessage | IChatSystemMessage | IChatMessagesPlaceholder | IChatFunctionMessage)[];
62
+ type IChatMessage = IChatUserMessage | IChatAssistantMessage | IChatFunctionCallMessage | IChatSystemMessage | IChatFunctionMessage;
63
+ type IChatMessages = IChatMessage[];
64
+
65
+ /**
66
+ * BaseParser is an abstract class for parsing text and enforcing JSON schema on the parsed data.
67
+ */
68
+ declare abstract class BaseParser<T = any, TInput = string> {
69
+ name: string;
70
+ target: "text" | "function_call";
71
+ /**
72
+ * Create a new BaseParser.
73
+ * @param name - The name of the parser.
74
+ * @param target - Whether the parser consumes text or function-call output.
75
+ */
76
+ constructor(name: string, target?: "text" | "function_call");
77
+ /**
78
+ * Parse the given text and return the parsed data.
79
+ * @abstract
80
+ * @param text - The text to parse.
81
+ * @param [attributes] - Optional attributes to use during parsing.
82
+ * @returns The parsed data.
83
+ */
84
+ abstract parse(text: TInput, attributes?: Record<string, any>): T;
85
+ }
86
+ declare abstract class BaseParserWithJson<S extends JSONSchema | undefined = undefined, T = S extends JSONSchema ? FromSchema<S> : Record<string, any>, TInput = string> extends BaseParser<T, TInput> {
87
+ schema: S;
88
+ validateSchema: boolean;
89
+ constructor(name: string, options: ParserSchemaOptions<S>);
90
+ }
91
+
92
+ /**
93
+ * v3 parser contract:
94
+ * Category: pass-through
95
+ * Mode: string pass-through
96
+ *
97
+ * Accepts any string and returns it exactly.
98
+ * Throws LlmExeError(parser.parse_failed) for non-string input.
99
+ * Executor output normalization owns OutputResult handling before parser
100
+ * invocation.
101
+ *
102
+ */
103
+ declare class StringParser extends BaseParser<string> {
104
+ constructor();
105
+ parse(text: string, _attributes?: Record<string, any>): string;
106
+ }
107
+
108
+ declare function replaceTemplateString(templateString?: string, substitutions?: Record<string, any>, configuration?: PromptTemplateOptions): string;
109
+
110
+ declare function replaceTemplateStringAsync(templateString?: string, substitutions?: Record<string, any>, configuration?: PromptTemplateOptions): Promise<string>;
111
+
112
+ /**
113
+ * BasePrompt should be extended.
114
+ */
115
+ declare abstract class BasePrompt<I extends Record<string, any>> {
116
+ readonly type: PromptType;
117
+ messages: IPromptMessages | IPromptChatMessages;
118
+ partials: PromptPartial[];
119
+ helpers: PromptHelper[];
120
+ validateInput: ValidateInputMode;
121
+ replaceTemplateString: typeof replaceTemplateString;
122
+ replaceTemplateStringAsync: typeof replaceTemplateStringAsync;
123
+ filters: {
124
+ pre: ((prompt: string) => string)[];
125
+ post: ((prompt: string) => string)[];
126
+ };
127
+ /**
128
+ * constructor description
129
+ * @param initialPromptMessage An initial message to add to the prompt.
130
+ */
131
+ constructor(initialPromptMessage?: string, options?: PromptOptions);
132
+ /**
133
+ * addToPrompt description
134
+ * @param content The message content
135
+ * @param role The role of the user. Defaults to system for base text prompt.
136
+ * @return instance of BasePrompt.
137
+ */
138
+ addToPrompt(content: string, role?: string): BasePrompt<I>;
139
+ /**
140
+ * addSystemMessage description
141
+ * @param content The message content
142
+ * @return returns BasePrompt so it can be chained.
143
+ */
144
+ addSystemMessage(content: string): this;
145
+ /**
146
+ * registerPartial description
147
+ * @param partialOrPartials Additional partials that can be made available to the template parser.
148
+ * @return BasePrompt so it can be chained.
149
+ */
150
+ registerPartial(partialOrPartials: PromptPartial | PromptPartial[]): this;
151
+ /**
152
+ * registerHelpers description
153
+ * @param helperOrHelpers Additional helper functions that can be made available to the template parser.
154
+ * @return BasePrompt so it can be chained.
155
+ */
156
+ registerHelpers(helperOrHelpers: PromptHelper | PromptHelper[]): this;
157
+ /**
158
+ * Returns the Handlebars-bearing strings that should be validated, along
159
+ * with a location label used for error context. Subclasses with structured
160
+ * message content (e.g. ChatPrompt) should override.
161
+ */
162
+ protected getTemplateContents(): {
163
+ content: string;
164
+ location: string;
165
+ }[];
166
+ protected preflightValidate(values: I): void;
167
+ /**
168
+ * format description
169
+ * @param values The message content
170
+ * @param separator The separator between messages. defaults to "\n\n"
171
+ * @return returns messages formatted with template replacement
172
+ */
173
+ format(values: I, separator?: string): string | IChatMessages;
174
+ /**
175
+ * format description
176
+ * @param values The message content
177
+ * @param separator The separator between messages. defaults to "\n\n"
178
+ * @return returns messages formatted with template replacement
179
+ */
180
+ formatAsync(values: I, separator?: string): Promise<string | IChatMessages>;
181
+ runPromptFilter(prompt: string, filters: ((prompt: string, values: I) => string)[], values: I): string;
182
+ getReplacements(values: I): Omit<I, "input"> & {
183
+ input: any;
184
+ _input: any;
185
+ };
186
+ /**
187
+ * Validates that `input` provides every variable referenced by this prompt's
188
+ * templates, and that every identifiable helper call is registered.
189
+ *
190
+ * @breaking v3: previously returned `this.messages.length > 0` with no
191
+ * `input` parameter. For the old behavior, read `prompt.messages.length > 0`
192
+ * directly.
193
+ *
194
+ * @throws LlmExeError with code `"prompt.missing_template_variable"` listing
195
+ * all missing variables and helpers.
196
+ */
197
+ validate(input: I): void;
198
+ }
199
+
200
+ type TextPromptType = "text";
201
+ type ChatPromptType = "chat";
202
+ type PromptType = TextPromptType | ChatPromptType;
203
+ type PromptHelper = {
204
+ name: string;
205
+ handler: (args: any) => any;
206
+ };
207
+ type PromptPartial = {
208
+ name: string;
209
+ template: string;
210
+ };
211
+ type ValidateInputMode = false | "strict" | "warn";
212
+ interface PromptTemplateOptions {
213
+ partials?: PromptPartial[];
214
+ helpers?: PromptHelper[];
215
+ }
216
+ interface PromptOptions extends PromptTemplateOptions {
217
+ preFilters?: ((prompt: string) => string)[];
218
+ postFilters?: ((prompt: string) => string)[];
219
+ replaceTemplateString?: (...args: any[]) => string;
220
+ /**
221
+ * Controls whether `format()` preflights input against the variables
222
+ * referenced by the prompt's templates. See `validate(input)`.
223
+ *
224
+ * - `false` (default): no preflight; rendering proceeds.
225
+ * - `"strict"`: throw `LlmExeError("prompt.missing_template_variable")` before rendering.
226
+ * - `"warn"`: emit a Node warning via `process.emitWarning` and continue rendering.
227
+ */
228
+ validateInput?: ValidateInputMode;
229
+ }
230
+ interface ChatPromptOptions extends PromptOptions {
231
+ allowUnsafeUserTemplate?: boolean;
232
+ }
233
+
234
+ /**
235
+ * BaseExecutor
236
+ * @template I - Input type.
237
+ * @template O - Output type.
238
+ * @template H - Hooks type.
239
+ */
240
+ declare abstract class BaseExecutor<I extends PlainObject, O = any, H extends BaseExecutorHooks = BaseExecutorHooks, R = any, HI = any> {
241
+ /**
242
+ * @property id - internal id of the executor
243
+ */
244
+ readonly id: string;
245
+ /**
246
+ * @property type - type of executor
247
+ */
248
+ type: string;
249
+ /**
250
+ * @property created - timestamp date created
251
+ */
252
+ readonly created: number;
253
+ /**
254
+ * @property name - name of executor
255
+ */
256
+ name: string;
257
+ /**
258
+ * @property executions -
259
+ */
260
+ executions: number;
261
+ traceId: string | null;
262
+ /**
263
+ * @property hooks - hooks to be ran during execution
264
+ */
265
+ hooks: any;
266
+ readonly allowedHooks: any[];
267
+ /**
268
+ * @property maxHooksPerEvent - Maximum number of hooks allowed per event
269
+ */
270
+ readonly maxHooksPerEvent: number;
271
+ constructor(name: string, type: string, options?: CoreExecutorExecuteOptions<I, O, R, HI, H>);
272
+ abstract handler(input: I, _options?: any, _context?: ExecutionContext<I, O>): Promise<any>;
273
+ /**
274
+ * Build a per-call execution context snapshot. Captures the current
275
+ * execution metadata so the snapshot reflects state at the time it was
276
+ * taken (e.g. `handlerInput` becomes available after `getHandlerInput`).
277
+ */
278
+ protected snapshotContext(execution: ExecutorExecutionMetadata<I, O>): ExecutionContext<I, O>;
279
+ /**
280
+ *
281
+ * Used to filter the input of the handler.
282
+ *
283
+ * Throws a `TypeError` if `_input` is `null` or `undefined`. The declared
284
+ * input type is `I extends PlainObject`; omitting input or passing an
285
+ * explicit `null` is a contract violation with no valid coercion, so we
286
+ * surface it loudly rather than silently wrapping it.
287
+ *
288
+ * Non-object inputs (strings, numbers, arrays) are intentionally coerced
289
+ * to `{ input: value }` via {@link ensureInputIsObject}. This preserves the
290
+ * convenience pattern used by tool/function callables, which forward raw
291
+ * string arguments into an executor.
292
+ *
293
+ * @param _input
294
+ * @returns original input formatted for handler
295
+ */
296
+ getHandlerInput(_input: I, _metadata: ExecutorExecutionMetadata<I, any>, _options?: any): Promise<any>;
297
+ /**
298
+ *
299
+ * Used to filter the output of the handler
300
+ * @param _input
301
+ * @returns output O
302
+ */
303
+ getHandlerOutput(out: any, _metadata: ExecutorExecutionMetadata<any, O>, _options?: any, _context?: ExecutionContext<I, O>): O;
304
+ /**
305
+ *
306
+ * execute - Runs the executor
307
+ * @param _input
308
+ * @returns handler output
309
+ */
310
+ execute(_input: I, _options?: any): Promise<O>;
311
+ private collectHookErrors;
312
+ metadata(): Record<string, any>;
313
+ getMetadata(metadata?: Record<string, any>): ExecutorMetadata;
314
+ runHook(hook: keyof H, _metadata: ExecutorExecutionMetadata): HookErrorRecord[];
315
+ setHooks(hooks?: CoreExecutorHookInput<I, O, R, HI, H>): this;
316
+ removeHook(eventName: keyof H, fn: ListenerFunction): this;
317
+ on(eventName: keyof H, fn: ListenerFunction): this;
318
+ off(eventName: keyof H, fn: ListenerFunction): this;
319
+ once(eventName: keyof H, fn: ListenerFunction): this;
320
+ withTraceId(traceId: string): this;
321
+ getTraceId(): string | null;
322
+ /**
323
+ * Clear all hooks for a specific event or all events
324
+ * Useful for preventing memory leaks in long-running processes
325
+ * @param eventName - The event name to clear hooks for
326
+ */
327
+ clearHooks(eventName?: keyof H): this;
328
+ /**
329
+ * Get the count of hooks for monitoring memory usage
330
+ * @param eventName - Optional event name to get count for
331
+ * @returns Hook count for specific event or all events
332
+ */
333
+ getHookCount(eventName?: keyof H): number | Record<string, number>;
334
+ }
335
+
336
+ declare abstract class BaseStateItem<T> implements Serializable {
337
+ protected key: string;
338
+ protected value: T;
339
+ protected initialValue: T;
340
+ constructor(key: string, initialValue: T);
341
+ setValue(value: T): void;
342
+ getKey(): string;
343
+ getValue(): T;
344
+ resetValue(): void;
345
+ serializeValue(): {
346
+ [x: string]: T;
347
+ };
348
+ serialize(): {
349
+ class: string;
350
+ name: string;
351
+ value: any;
352
+ };
353
+ }
354
+ declare class DefaultStateItem extends BaseStateItem<any> {
355
+ constructor(name: string, defaultValue: any);
356
+ }
357
+
358
+ declare class Dialogue extends BaseStateItem<IChatMessages> {
359
+ name: string;
360
+ constructor(name: string);
361
+ setUserMessage(content: string | IChatMessageContentDetailed[], name?: string): this;
362
+ setAssistantMessage(content: string | OutputResultsText): this;
363
+ setSystemMessage(content: string): this;
364
+ setToolMessage(content: string, name: string, id?: string): this;
365
+ setFunctionMessage(content: string, name: string, id?: string): this;
366
+ /**
367
+ * Set
368
+ */
369
+ setToolCallMessage(input: {
370
+ name: string;
371
+ arguments: string;
372
+ id?: string;
373
+ }): this;
374
+ setFunctionCallMessage(input: {
375
+ name: string;
376
+ arguments: string;
377
+ id?: string;
378
+ } | {
379
+ function_call: {
380
+ name: string;
381
+ arguments: string;
382
+ id?: string;
383
+ };
384
+ }): this;
385
+ setMessageTurn(userMessage: string, assistantMessage: string, systemMessage?: string): this;
386
+ /**
387
+ * Aliases using `add*` naming to match ChatPrompt's API.
388
+ * These delegate to the corresponding `set*` methods.
389
+ */
390
+ addUserMessage(content: string | IChatMessageContentDetailed[], name?: string): this;
391
+ addAssistantMessage(content: string | OutputResultsText): this;
392
+ addSystemMessage(content: string): this;
393
+ addToolMessage(content: string, name: string, id?: string): this;
394
+ addToolCallMessage(input: {
395
+ name: string;
396
+ arguments: string;
397
+ id?: string;
398
+ }): this;
399
+ addFunctionMessage(content: string, name: string, id?: string): this;
400
+ addFunctionCallMessage(input: {
401
+ name: string;
402
+ arguments: string;
403
+ id?: string;
404
+ } | {
405
+ function_call: {
406
+ name: string;
407
+ arguments: string;
408
+ id?: string;
409
+ };
410
+ }): this;
411
+ addMessageTurn(userMessage: string, assistantMessage: string, systemMessage?: string): this;
412
+ addHistory(messages: IChatMessages): this;
413
+ setHistory(messages: IChatMessages): this;
414
+ getHistory(): IChatMessages;
415
+ serialize(): {
416
+ class: string;
417
+ name: string;
418
+ value: IChatMessage[];
419
+ };
420
+ /**
421
+ * Add LLM output to dialogue history in the order it was returned
422
+ *
423
+ * @param output - The LLM output result from llm.call()
424
+ * @returns this for chaining
425
+ */
426
+ addFromOutput(output: OutputResult | BaseLlCall): this;
427
+ }
428
+
429
+ declare abstract class BaseState {
430
+ dialogues: {
431
+ [key in string]: Dialogue;
432
+ };
433
+ attributes: Record<string, any>;
434
+ context: Record<string, BaseStateItem<any>>;
435
+ constructor();
436
+ createDialogue(name?: string): Dialogue;
437
+ useDialogue(name?: string): Dialogue;
438
+ getDialogue(name?: string): Dialogue;
439
+ createContextItem<T extends BaseStateItem<any>>(item: T): T;
440
+ getContext<T>(key: string): BaseStateItem<T>;
441
+ getContextValue<T>(key: string): T;
442
+ setAttribute(key: string, value: any): void;
443
+ deleteAttribute(key: string): void;
444
+ clearAttributes(): void;
445
+ serialize(): {
446
+ dialogues: any;
447
+ context: any;
448
+ attributes: any;
449
+ };
450
+ abstract saveState(): Promise<void>;
451
+ }
452
+ declare class DefaultState extends BaseState {
453
+ constructor();
454
+ saveState(): Promise<void>;
455
+ }
456
+
457
+ /**
458
+ * Core Executor With LLM
459
+ */
460
+ 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, BaseLlCall, ReturnType<Prompt["format"]>> {
461
+ llm: Llm;
462
+ prompt: Prompt | undefined;
463
+ promptFn: any;
464
+ parser: StringParser | Parser;
465
+ constructor(llmConfiguration: ExecutorWithLlmOptions<Llm, Prompt, Parser, State>, options?: CoreExecutorExecuteOptions<PromptInput<Prompt>, ParserOutput<Parser>, BaseLlCall, ReturnType<Prompt["format"]>, LlmExecutorHooks>);
466
+ /**
467
+ * Runs the executor against the configured LLM and prompt.
468
+ *
469
+ * `null` and `undefined` are rejected with a `TypeError`: the declared
470
+ * input type requires an object, and silently coercing missing input hides a
471
+ * clear contract violation. Use `{}` for prompts that declare no template
472
+ * variables. See issue #410.
473
+ */
474
+ execute(_input: PromptInput<Prompt>, _options?: LlmExecutorExecuteOptions): Promise<ParserOutput<Parser>>;
475
+ handler(_input: PromptInput<Prompt>, _options?: LlmExecutorExecuteOptions, _context?: ExecutionContext<PromptInput<Prompt>, ParserOutput<Parser>>): Promise<any>;
476
+ getHandlerInput(_input: PromptInput<Prompt>): Promise<any>;
477
+ getHandlerOutput(out: BaseLlCall, _metadata: ExecutorExecutionMetadata<PromptInput<Prompt>, ParserOutput<Parser>>, _options?: LlmExecutorExecuteOptions, _context?: ExecutionContext<PromptInput<Prompt>, ParserOutput<Parser>>): ParserOutput<Parser>;
478
+ metadata(): {
479
+ llm: Record<string, any>;
480
+ };
481
+ getTraceId(): string | null;
482
+ }
483
+
484
+ declare const hookOnComplete = "onComplete";
485
+ declare const hookOnError = "onError";
486
+ declare const hookOnSuccess = "onSuccess";
487
+
488
+ type ListenerFunction = (...args: any[]) => void;
489
+ type ParserOutput<P> = P extends BaseParser<infer T, any> ? T : never;
490
+ type PromptInput<P> = P extends BasePrompt<infer T> ? T : never;
491
+ interface ExecutorWithLlmOptions<Llm, Prompt, Parser, State> {
492
+ name?: string;
493
+ llm: Llm;
494
+ prompt: Prompt | ((values: PromptInput<Prompt>) => Prompt);
495
+ parser?: Parser;
496
+ state?: State;
497
+ __mock_response_key__?: string;
498
+ }
499
+ interface CoreExecutorInput<I, O> {
500
+ name?: string;
501
+ handler: (input: I, context?: ExecutionContext<I, O>) => Promise<O> | O;
502
+ getHandlerInput?(input: I): Promise<any>;
503
+ getHandlerOutput?(out: any): O;
504
+ }
505
+ type FunctionOrExecutor<I extends PlainObject | {
506
+ input: string;
507
+ }, O> = ((input: I) => Promise<O> | O) | BaseExecutor<I, O>;
508
+ interface ExecutorMetadata {
509
+ id: string;
510
+ type: string;
511
+ name: string;
512
+ created: number;
513
+ executions: number;
514
+ metadata?: Record<string, any>;
515
+ }
516
+ interface HookErrorRecord {
517
+ hook: string;
518
+ error: unknown;
519
+ errorMessage: string;
520
+ errorCategory?: string;
521
+ errorCode?: string;
522
+ errorContext?: unknown;
523
+ errorCause?: unknown;
524
+ }
525
+ interface ExecutorExecutionMetadata<I = any, O = any, R = any, HI = any> {
526
+ start: null | number;
527
+ end: null | number;
528
+ input: I;
529
+ handlerInput?: HI;
530
+ handlerOutput?: R;
531
+ output?: O;
532
+ errorMessage?: string;
533
+ error?: Error;
534
+ errorCategory?: string;
535
+ errorCode?: string;
536
+ errorContext?: unknown;
537
+ errorCause?: unknown;
538
+ hookErrors?: HookErrorRecord[];
539
+ metadata?: null | ExecutorMetadata;
540
+ }
541
+ interface ExecutorContext<I = any, O = any, A = Record<string, any>> extends ExecutorExecutionMetadata<I, O> {
542
+ metadata: ExecutorMetadata;
543
+ attributes: A;
544
+ }
545
+ /**
546
+ * Per-call execution context. Built by `BaseExecutor.execute()` and threaded
547
+ * through `handler()`, `llm.call()`, parsers, and warnings. Provides a single
548
+ * place to read the resolved trace ID, stable executor identity, and the
549
+ * mutable execution state for the current run.
550
+ */
551
+ interface ExecutionContext<I = any, O = any, A = Record<string, any>> {
552
+ traceId?: string;
553
+ executor: ExecutorMetadata;
554
+ execution: ExecutorExecutionMetadata<I, O>;
555
+ attributes: A;
556
+ }
557
+ interface BaseExecutorHooks {
558
+ [hookOnError]: ListenerFunction[];
559
+ [hookOnSuccess]: ListenerFunction[];
560
+ [hookOnComplete]: ListenerFunction[];
561
+ }
562
+ interface LlmExecutorHooks extends BaseExecutorHooks {
563
+ }
564
+ /**
565
+ * A single executor hook callback. Receives the per-run execution metadata
566
+ * (input/output/error fields typed via I/O) followed by the executor's own
567
+ * identity metadata. This is the shape fired for onSuccess / onError /
568
+ * onComplete — the metadata fields that are populated differ per event
569
+ * (`output` on success, `error` on failure), but all are optional on
570
+ * {@link ExecutorExecutionMetadata}, so one signature covers every hook.
571
+ */
572
+ type ExecutorHookFunction<I = any, O = any, R = any, HI = any> = (metadata: ExecutorExecutionMetadata<I, O, R, HI>, executor: ExecutorMetadata) => void;
573
+ type CoreExecutorHookInput<I = any, O = any, R = any, HI = any, H = BaseExecutorHooks> = {
574
+ [key in keyof H]?: ExecutorHookFunction<I, O, R, HI> | ExecutorHookFunction<I, O, R, HI>[];
575
+ };
576
+ interface CoreExecutorExecuteOptions<I = any, O = any, R = any, HI = any, T = BaseExecutorHooks> {
577
+ hooks?: CoreExecutorHookInput<I, O, R, HI, T>;
578
+ }
579
+ interface CallableExecutorCore {
580
+ name: string;
581
+ description: string;
582
+ parameters?: Record<string, any>;
583
+ }
584
+ interface LlmExecutorExecuteOptions {
585
+ functions?: CallableExecutorCore[];
586
+ functionCall?: any;
587
+ jsonSchema?: Record<string, any>;
588
+ }
589
+ type GenericFunctionCall = "auto" | "none" | "any" | {
590
+ name: string;
591
+ };
592
+ interface LlmExecutorWithFunctionsOptions<T extends GenericFunctionCall = "auto"> extends LlmExecutorExecuteOptions {
593
+ functions?: CallableExecutorCore[];
594
+ functionCall?: T;
595
+ functionCallStrictInput?: boolean;
596
+ jsonSchema?: Record<string, any>;
597
+ }
598
+
599
+ type CreateParserType = "json" | "string" | "boolean" | "number" | "stringExtract" | "listToArray" | "listToJson" | "listToKeyValue" | "replaceStringTemplate" | "markdownCodeBlocks" | "markdownCodeBlock";
600
+ interface ParserSchemaOptions<S extends JSONSchema | undefined = undefined> {
601
+ schema?: S;
602
+ validateSchema?: boolean;
603
+ }
604
+ type JsonParserMatch = "exact" | "extract";
605
+ interface JsonParserOptions<S extends JSONSchema | undefined = undefined> extends ParserSchemaOptions<S> {
606
+ match?: JsonParserMatch;
607
+ }
608
+ interface ListToJsonParserOptions<S extends JSONSchema | undefined = undefined> extends ParserSchemaOptions<S> {
609
+ keyTransform?: "camelCase" | "preserve";
610
+ }
611
+
612
+ /**
613
+ * Internal Formats
614
+ */
615
+ interface OutputResultsBase {
616
+ type: "text" | "function_use";
617
+ text?: string;
618
+ }
619
+ interface OutputResultsText extends OutputResultsBase {
620
+ type: "text";
621
+ text: string;
622
+ }
623
+ interface OutputResultsFunction extends OutputResultsBase {
624
+ type: "function_use";
625
+ name: string;
626
+ input: Record<string, any>;
627
+ functionId: string;
628
+ }
629
+ type OutputResultContent = OutputResultsText | OutputResultsFunction;
630
+ interface OutputResult {
631
+ id: string;
632
+ name?: string;
633
+ created: number;
634
+ stopReason: string;
635
+ content: OutputResultContent[];
636
+ options?: OutputResultContent[][];
637
+ usage: {
638
+ input_tokens: number;
639
+ output_tokens: number;
640
+ total_tokens: number;
641
+ };
642
+ }
643
+ interface EmbeddingOutputResult {
644
+ id: string;
645
+ model?: string;
646
+ created: number;
647
+ embedding: number[][];
648
+ usage: {
649
+ input_tokens: number;
650
+ output_tokens: number;
651
+ total_tokens: number;
652
+ };
653
+ }
654
+ interface BaseLlmOptions {
655
+ traceId?: null | string;
656
+ timeout?: number;
657
+ maxDelay?: number;
658
+ numOfAttempts?: number;
659
+ jitter?: "none" | "full";
660
+ promptType?: PromptType;
661
+ endpoint?: string;
662
+ headers?: Record<string, string>;
663
+ }
664
+ interface GenericEmbeddingOptions extends BaseLlmOptions {
665
+ model?: string;
666
+ dimensions?: number;
667
+ }
668
+ interface OpenAiEmbeddingOptions extends GenericEmbeddingOptions {
669
+ model?: string;
670
+ openAiApiKey?: string;
671
+ baseUrl?: string;
672
+ }
673
+ interface AmazonEmbeddingOptions extends GenericEmbeddingOptions {
674
+ model: string;
675
+ awsRegion?: string;
676
+ awsSecretKey?: string;
677
+ awsAccessKey?: string;
678
+ }
679
+ interface CohereBedrockEmbeddingOptions extends AmazonEmbeddingOptions {
680
+ inputType?: "search_document" | "search_query" | "classification" | "clustering";
681
+ truncate?: "NONE" | "START" | "END" | "LEFT" | "RIGHT";
682
+ }
683
+ interface GenericLLm extends BaseLlmOptions {
684
+ model?: string;
685
+ system?: string;
686
+ prompt?: string | {
687
+ role: string;
688
+ content: string;
689
+ }[];
690
+ temperature?: number;
691
+ topP?: number;
692
+ stream?: boolean;
693
+ streamOptions?: Record<string, any>;
694
+ maxTokens?: number;
695
+ stopSequences?: string[];
696
+ effort?: "minimal" | "low" | "medium" | "high";
697
+ }
698
+ interface OpenAiRequest extends GenericLLm {
699
+ model: string;
700
+ frequencyPenalty?: number;
701
+ logitBias?: Record<string, any> | null;
702
+ responseFormat?: Record<string, any>;
703
+ openAiApiKey?: string;
704
+ useJson?: boolean;
705
+ }
706
+ interface XAiRequest extends GenericLLm {
707
+ model: string;
708
+ frequencyPenalty?: number;
709
+ logitBias?: Record<string, any> | null;
710
+ responseFormat?: Record<string, any>;
711
+ xAiApiKey?: string;
712
+ useJson?: boolean;
713
+ }
714
+ interface AmazonBedrockRequest extends GenericLLm {
715
+ model: string;
716
+ awsRegion?: string;
717
+ awsSecretKey?: string;
718
+ awsAccessKey?: string;
719
+ }
720
+ interface AnthropicRequest extends GenericLLm {
721
+ model: string;
722
+ anthropicApiKey?: string;
723
+ topK?: number;
724
+ metadata?: {
725
+ user_id?: string;
726
+ };
727
+ serviceTier?: "auto" | "standard_only";
728
+ }
729
+ interface GeminiRequest extends GenericLLm {
730
+ model: string;
731
+ geminiApiKey?: string;
732
+ }
733
+ interface DeepseekRequest extends GenericLLm {
734
+ model: string;
735
+ responseFormat?: Record<string, any>;
736
+ deepseekApiKey?: string;
737
+ useJson?: boolean;
738
+ }
739
+ type AllEmbedding = {
740
+ "openai.embedding.v1": {
741
+ input: OpenAiEmbeddingOptions;
742
+ };
743
+ "amazon.embedding.v1": {
744
+ input: AmazonEmbeddingOptions;
745
+ };
746
+ "amazon:cohere.embedding.v1": {
747
+ input: CohereBedrockEmbeddingOptions;
748
+ };
749
+ };
750
+ type AllLlm = {
751
+ "openai.chat.v1": {
752
+ input: OpenAiRequest;
753
+ };
754
+ "openai.chat-mock.v1": {
755
+ input: OpenAiRequest;
756
+ };
757
+ "anthropic.chat.v1": {
758
+ input: AnthropicRequest;
759
+ };
760
+ "amazon:anthropic.chat.v1": {
761
+ input: AnthropicRequest & AmazonBedrockRequest;
762
+ };
763
+ "amazon:meta.chat.v1": {
764
+ input: AmazonBedrockRequest;
765
+ };
766
+ "xai.chat.v1": {
767
+ input: XAiRequest;
768
+ };
769
+ "ollama.chat.v1": {
770
+ input: GenericLLm;
771
+ };
772
+ "google.chat.v1": {
773
+ input: GeminiRequest;
774
+ };
775
+ "deepseek.chat.v1": {
776
+ input: DeepseekRequest;
777
+ };
778
+ };
779
+ type AllUseLlmOptions = AllLlm & {
780
+ "openai.gpt-5.2": {
781
+ input: Omit<OpenAiRequest, "model">;
782
+ };
783
+ "openai.gpt-5-mini": {
784
+ input: Omit<OpenAiRequest, "model">;
785
+ };
786
+ "openai.gpt-5-nano": {
787
+ input: Omit<OpenAiRequest, "model">;
788
+ };
789
+ "openai.gpt-4.1": {
790
+ input: Omit<OpenAiRequest, "model">;
791
+ };
792
+ "openai.gpt-4.1-mini": {
793
+ input: Omit<OpenAiRequest, "model">;
794
+ };
795
+ "openai.gpt-4.1-nano": {
796
+ input: Omit<OpenAiRequest, "model">;
797
+ };
798
+ "openai.o3": {
799
+ input: Omit<OpenAiRequest, "model">;
800
+ };
801
+ "openai.gpt-4": {
802
+ input: Omit<OpenAiRequest, "model">;
803
+ };
804
+ "openai.gpt-4o": {
805
+ input: Omit<OpenAiRequest, "model">;
806
+ };
807
+ "openai.gpt-4o-mini": {
808
+ input: Omit<OpenAiRequest, "model">;
809
+ };
810
+ "openai.o4-mini": {
811
+ input: Omit<OpenAiRequest, "model">;
812
+ };
813
+ "anthropic.claude-opus-4-8": {
814
+ input: Omit<AnthropicRequest, "model">;
815
+ };
816
+ "anthropic.claude-opus-4-7": {
817
+ input: Omit<AnthropicRequest, "model">;
818
+ };
819
+ "anthropic.claude-sonnet-4-6": {
820
+ input: Omit<AnthropicRequest, "model">;
821
+ };
822
+ "anthropic.claude-opus-4-5": {
823
+ input: Omit<AnthropicRequest, "model">;
824
+ };
825
+ "anthropic.claude-haiku-4-5": {
826
+ input: Omit<AnthropicRequest, "model">;
827
+ };
828
+ "anthropic.claude-sonnet-4-5": {
829
+ input: Omit<AnthropicRequest, "model">;
830
+ };
831
+ "anthropic.claude-opus-4-6": {
832
+ input: Omit<AnthropicRequest, "model">;
833
+ };
834
+ "anthropic.claude-opus-4-1": {
835
+ input: Omit<AnthropicRequest, "model">;
836
+ };
837
+ "anthropic.claude-sonnet-4-0": {
838
+ input: Omit<AnthropicRequest, "model">;
839
+ };
840
+ "anthropic.claude-opus-4-0": {
841
+ input: Omit<AnthropicRequest, "model">;
842
+ };
843
+ "anthropic.claude-sonnet-4": {
844
+ input: Omit<AnthropicRequest, "model">;
845
+ };
846
+ "anthropic.claude-opus-4": {
847
+ input: Omit<AnthropicRequest, "model">;
848
+ };
849
+ "anthropic.claude-3-7-sonnet": {
850
+ input: Omit<AnthropicRequest, "model">;
851
+ };
852
+ "anthropic.claude-3-5-sonnet": {
853
+ input: Omit<AnthropicRequest, "model">;
854
+ };
855
+ "anthropic.claude-3-5-haiku": {
856
+ input: Omit<AnthropicRequest, "model">;
857
+ };
858
+ "anthropic.claude-3-opus": {
859
+ input: Omit<AnthropicRequest, "model">;
860
+ };
861
+ "google.gemini-2.5-flash": {
862
+ input: Omit<GeminiRequest, "model">;
863
+ };
864
+ "google.gemini-2.5-flash-lite": {
865
+ input: Omit<GeminiRequest, "model">;
866
+ };
867
+ "google.gemini-2.5-pro": {
868
+ input: Omit<GeminiRequest, "model">;
869
+ };
870
+ "google.gemini-3.1-flash-lite": {
871
+ input: Omit<GeminiRequest, "model">;
872
+ };
873
+ "google.gemini-3.5-flash": {
874
+ input: Omit<GeminiRequest, "model">;
875
+ };
876
+ "google.gemini-2.0-flash": {
877
+ input: Omit<GeminiRequest, "model">;
878
+ };
879
+ "google.gemini-2.0-flash-lite": {
880
+ input: Omit<GeminiRequest, "model">;
881
+ };
882
+ "google.gemini-1.5-pro": {
883
+ input: Omit<GeminiRequest, "model">;
884
+ };
885
+ "xai.grok-2": {
886
+ input: Omit<XAiRequest, "model">;
887
+ };
888
+ "xai.grok-3": {
889
+ input: Omit<XAiRequest, "model">;
890
+ };
891
+ "xai.grok-3-mini": {
892
+ input: Omit<XAiRequest, "model">;
893
+ };
894
+ "xai.grok-4": {
895
+ input: Omit<XAiRequest, "model">;
896
+ };
897
+ "xai.grok-4-fast": {
898
+ input: Omit<XAiRequest, "model">;
899
+ };
900
+ "xai.grok-4-1-fast": {
901
+ input: Omit<XAiRequest, "model">;
902
+ };
903
+ "xai.grok-4.3": {
904
+ input: Omit<XAiRequest, "model">;
905
+ };
906
+ "xai.grok-4.20": {
907
+ input: Omit<XAiRequest, "model">;
908
+ };
909
+ "xai.grok-4.20-reasoning": {
910
+ input: Omit<XAiRequest, "model">;
911
+ };
912
+ "ollama.deepseek-r1": {
913
+ input: GenericLLm;
914
+ };
915
+ "ollama.llama3.3": {
916
+ input: GenericLLm;
917
+ };
918
+ "ollama.llama3.2": {
919
+ input: GenericLLm;
920
+ };
921
+ "ollama.llama3.1": {
922
+ input: GenericLLm;
923
+ };
924
+ "ollama.qwq": {
925
+ input: GenericLLm;
926
+ };
927
+ "ollama.gemma3": {
928
+ input: GenericLLm;
929
+ };
930
+ "ollama.mistral": {
931
+ input: GenericLLm;
932
+ };
933
+ "ollama.qwen2.5": {
934
+ input: GenericLLm;
935
+ };
936
+ "ollama.qwen3": {
937
+ input: GenericLLm;
938
+ };
939
+ "ollama.qwen3.5": {
940
+ input: GenericLLm;
941
+ };
942
+ "ollama.gemma4": {
943
+ input: GenericLLm;
944
+ };
945
+ "ollama.gpt-oss": {
946
+ input: GenericLLm;
947
+ };
948
+ "deepseek.chat": {
949
+ input: DeepseekRequest;
950
+ };
951
+ "deepseek.v4-flash": {
952
+ input: Omit<DeepseekRequest, "model">;
953
+ };
954
+ "deepseek.v4-pro": {
955
+ input: Omit<DeepseekRequest, "model">;
956
+ };
957
+ };
958
+ type LlmProviderKey = keyof AllLlm;
959
+ type EmbeddingProviderKey = keyof AllEmbedding;
960
+ type UseLlmKey = keyof AllUseLlmOptions;
961
+ interface BaseLlCall {
962
+ getResultContent: () => OutputResultContent[];
963
+ getResultText: () => string;
964
+ getResult: () => OutputResult;
965
+ }
966
+ interface BaseRequest<_T extends Record<string, any>> {
967
+ call: (...args: any[]) => Promise<_T>;
968
+ getTraceId: () => string | null;
969
+ withTraceId: (traceId: string) => void;
970
+ getMetadata: () => Record<string, any>;
971
+ }
972
+ interface BaseLlm<_T extends BaseLlCall = BaseLlCall> extends BaseRequest<_T> {
973
+ }
974
+
975
+ type LlmProvider = "openai.chat" | "openai.embedding" | "google.embedding" | "openai.chat-mock" | "anthropic.chat" | "amazon:anthropic.chat" | "amazon:meta.chat" | "amazon:nova.chat" | "amazon.embedding" | "amazon:cohere.embedding" | "xai.chat" | "google.chat" | "ollama.chat" | "deepseek.chat";
976
+ interface Config<Pk = LlmProviderKey> {
977
+ /**
978
+ * Unique identifier for this configuration (e.g., "openai.chat.v1", "anthropic.claude-3-opus")
979
+ * Used to reference this config when calling useLlm()
980
+ */
981
+ key: Pk;
982
+ /**
983
+ * The provider type this config is for (e.g., "openai.chat", "anthropic.chat")
984
+ * Used internally for provider-specific logic
985
+ */
986
+ provider: LlmProvider;
987
+ /**
988
+ * HTTP method for the API request (typically "POST" for LLM providers)
989
+ */
990
+ method: "POST" | "PUT" | "GET";
991
+ /**
992
+ * API endpoint URL template. Supports template variables using {{variable}} syntax
993
+ * Variables are replaced with values from the state object
994
+ * @example "https://api.openai.com/v1/chat/completions"
995
+ * @example "https://bedrock-runtime.{{awsRegion}}.amazonaws.com/model/{{model}}/invoke"
996
+ */
997
+ endpoint: string;
998
+ /**
999
+ * HTTP headers template as a JSON string. Supports template variables using {{variable}} syntax
1000
+ * @example '{"Authorization":"Bearer {{openAiApiKey}}", "Content-Type": "application/json"}'
1001
+ * // TODO: make this also accept object and function
1002
+ */
1003
+ headers: string;
1004
+ options: {
1005
+ [key in string]: {
1006
+ /**
1007
+ * Default value for this parameter if not provided by the user
1008
+ * Can be a static value or a function that returns the value
1009
+ * @example 4096
1010
+ * @example () => process.env.OPENAI_API_KEY
1011
+ */
1012
+ default?: any;
1013
+ /**
1014
+ * Whether this parameter is required
1015
+ * [true, "error message"] - Required with custom error
1016
+ * [true] - Required with default error message
1017
+ * @example [true, "maxTokens is required for Anthropic"]
1018
+ */
1019
+ required?: [boolean, string] | [boolean];
1020
+ };
1021
+ };
1022
+ mapBody: {
1023
+ [key in string]: {
1024
+ /**
1025
+ * The target field name in the provider's request body.
1026
+ * Supports dot notation for nested fields (e.g., "response_format.type")
1027
+ */
1028
+ key: string;
1029
+ /**
1030
+ * Default value to use if the source field is not provided
1031
+ */
1032
+ default?: any;
1033
+ /**
1034
+ * Transform function to convert the value before mapping to the request body
1035
+ * @param value - The input value from the user's state
1036
+ * @param state - The complete user state object containing all parameters
1037
+ * @param config - The current Config object (for access to options, etc.)
1038
+ * @returns The transformed value to be included in the request body
1039
+ */
1040
+ transform?: (value: any, state: Record<string, any>, config: Record<string, any>) => any;
1041
+ };
1042
+ };
1043
+ /**
1044
+ * Maps executor-level options (jsonSchema, functions, functionCall) to provider-specific request formats
1045
+ * @optional - Only needed if provider supports these features
1046
+ */
1047
+ mapOptions?: {
1048
+ /**
1049
+ * Transform JSON schema into provider-specific format
1050
+ * @param schema - The JSON schema object
1051
+ * @param options - Executor options (e.g., functionCallStrictInput)
1052
+ * @param currentInput - Current accumulated input state (for merging)
1053
+ * @param config - The full config object
1054
+ * @returns Provider-specific request body additions
1055
+ */
1056
+ jsonSchema?: (schema: any, options: any, currentInput?: Record<string, any>, config?: Config) => Record<string, any>;
1057
+ /**
1058
+ * Transform function call mode into provider-specific format
1059
+ * @param call - Function call mode ("auto", "any", "none", or specific function)
1060
+ * @param options - Executor options
1061
+ * @param currentInput - Current accumulated input state (for merging)
1062
+ * @param config - The full config object
1063
+ * @returns Provider-specific request body additions
1064
+ */
1065
+ functionCall?: (call: any, options?: any, currentInput?: Record<string, any>, config?: Config) => Record<string, any>;
1066
+ /**
1067
+ * Transform function definitions into provider-specific format
1068
+ * @param functions - Array of function definitions
1069
+ * @param options - Executor options (e.g., functionCallStrictInput)
1070
+ * @param currentInput - Current accumulated input state (for merging)
1071
+ * @param config - The full config object
1072
+ * @returns Provider-specific request body additions
1073
+ */
1074
+ functions?: (functions: any[], options?: any, currentInput?: Record<string, any>, config?: Config) => Record<string, any>;
1075
+ };
1076
+ /**
1077
+ * Optional response transformer for chat/LLM configs. The LLM call path
1078
+ * (`llm.call.ts`) defaults to `OutputDefault` when this is omitted.
1079
+ * Embedding configs do not use this — their flow dispatches via
1080
+ * `getEmbeddingOutputParser` instead.
1081
+ */
1082
+ transformResponse?: (result: any, _config?: Config<any>, headers?: Record<string, string>) => OutputResult;
1083
+ /**
1084
+ * Marks this config as deprecated. When set, useLlm() will emit a one-time
1085
+ * deprecation warning to inform users about upcoming model shutdowns.
1086
+ */
1087
+ deprecated?: {
1088
+ shorthand: string;
1089
+ message: string;
1090
+ };
1091
+ }
1092
+
1093
+ declare const configs: {
1094
+ "deepseek.chat.v1": Config<keyof AllLlm>;
1095
+ "deepseek.chat": Config<keyof AllLlm>;
1096
+ "deepseek.v4-flash": Config<keyof AllLlm>;
1097
+ "deepseek.v4-pro": Config<keyof AllLlm>;
1098
+ "google.gemini-2.0-flash": Config<keyof AllLlm>;
1099
+ "google.gemini-2.0-flash-lite": Config<keyof AllLlm>;
1100
+ "google.gemini-1.5-pro": Config<keyof AllLlm>;
1101
+ "google.gemini-2.5-pro": Config<any>;
1102
+ "google.gemini-2.5-flash-lite": Config<any>;
1103
+ "google.gemini-2.5-flash": Config<any>;
1104
+ "google.chat.v1": Config<keyof AllLlm>;
1105
+ "google.gemini-3.1-flash-lite": Config<keyof AllLlm>;
1106
+ "google.gemini-3.5-flash": Config<keyof AllLlm>;
1107
+ "ollama.chat.v1": Config<keyof AllLlm>;
1108
+ "ollama.deepseek-r1": Config<keyof AllLlm>;
1109
+ "ollama.llama3.3": Config<keyof AllLlm>;
1110
+ "ollama.llama3.2": Config<keyof AllLlm>;
1111
+ "ollama.llama3.1": Config<keyof AllLlm>;
1112
+ "ollama.qwq": Config<keyof AllLlm>;
1113
+ "ollama.gemma3": Config<keyof AllLlm>;
1114
+ "ollama.mistral": Config<keyof AllLlm>;
1115
+ "ollama.qwen2.5": Config<keyof AllLlm>;
1116
+ "ollama.qwen3": Config<keyof AllLlm>;
1117
+ "ollama.qwen3.5": Config<keyof AllLlm>;
1118
+ "ollama.gemma4": Config<keyof AllLlm>;
1119
+ "ollama.gpt-oss": Config<keyof AllLlm>;
1120
+ "xai.chat.v1": Config<keyof AllLlm>;
1121
+ "xai.grok-2": Config<keyof AllLlm>;
1122
+ "xai.grok-3": Config<keyof AllLlm>;
1123
+ "xai.grok-3-mini": Config<keyof AllLlm>;
1124
+ "xai.grok-4": Config<keyof AllLlm>;
1125
+ "xai.grok-4-fast": Config<keyof AllLlm>;
1126
+ "xai.grok-4-1-fast": Config<keyof AllLlm>;
1127
+ "xai.grok-4.3": Config<keyof AllLlm>;
1128
+ "xai.grok-4.20": Config<keyof AllLlm>;
1129
+ "xai.grok-4.20-reasoning": Config<keyof AllLlm>;
1130
+ "amazon:anthropic.chat.v1": Config<keyof AllLlm>;
1131
+ "amazon:meta.chat.v1": Config<keyof AllLlm>;
1132
+ "anthropic.claude-3-opus": Config<any>;
1133
+ "anthropic.claude-3-5-haiku": Config<any>;
1134
+ "anthropic.claude-3-5-sonnet": Config<any>;
1135
+ "anthropic.claude-3-7-sonnet": Config<any>;
1136
+ "anthropic.claude-opus-4": Config<any>;
1137
+ "anthropic.claude-sonnet-4": Config<any>;
1138
+ "anthropic.claude-opus-4-1": Config<any>;
1139
+ "anthropic.claude-opus-4-6": Config<any>;
1140
+ "anthropic.chat.v1": Config<keyof AllLlm>;
1141
+ "anthropic.claude-opus-4-8": Config<keyof AllLlm>;
1142
+ "anthropic.claude-opus-4-7": Config<keyof AllLlm>;
1143
+ "anthropic.claude-sonnet-4-6": Config<keyof AllLlm>;
1144
+ "anthropic.claude-opus-4-5": Config<keyof AllLlm>;
1145
+ "anthropic.claude-haiku-4-5": Config<keyof AllLlm>;
1146
+ "anthropic.claude-sonnet-4-5": Config<keyof AllLlm>;
1147
+ "openai.o4-mini": Config<any>;
1148
+ "openai.chat.v1": Config<keyof AllLlm>;
1149
+ "openai.chat-mock.v1": Config<keyof AllLlm>;
1150
+ "openai.gpt-5.2": Config<keyof AllLlm>;
1151
+ "openai.gpt-5-mini": Config<keyof AllLlm>;
1152
+ "openai.gpt-5-nano": Config<keyof AllLlm>;
1153
+ "openai.gpt-4.1": Config<keyof AllLlm>;
1154
+ "openai.gpt-4.1-mini": Config<keyof AllLlm>;
1155
+ "openai.gpt-4.1-nano": Config<keyof AllLlm>;
1156
+ "openai.o3": Config<keyof AllLlm>;
1157
+ "openai.gpt-4": Config<keyof AllLlm>;
1158
+ "openai.gpt-4o": Config<keyof AllLlm>;
1159
+ "openai.gpt-4o-mini": Config<keyof AllLlm>;
1160
+ };
1161
+
1162
+ /**
1163
+ * Serialization formats a config can arrive in. `auto` is best-effort
1164
+ * detection (JSON → YAML → markdown) for sources whose extension is unknown.
1165
+ */
1166
+ type Format = "json" | "yaml" | "markdown" | "auto";
1167
+ /**
1168
+ * A `useLlm` provider key — e.g. "openai.chat.v1", "openai.gpt-4.1",
1169
+ * "openai.chat-mock.v1". NOT a friendly vendor name like "openai".
1170
+ */
1171
+ type ProviderKey = keyof typeof configs;
1172
+ /**
1173
+ * Construction-time options for the executor (hooks, etc.). This is the
1174
+ * SECOND arg to `createLlm*Executor`, kept distinct from `executorOptions`
1175
+ * (which is execute-time state, the second arg to `.execute()`).
1176
+ *
1177
+ * `CoreExecutorExecuteOptions` now leads with the executor's I/O/R/HI type
1178
+ * params; the hook key set is the LAST param. A config-driven executor can't
1179
+ * know those concrete types, so they stay `any` and only the hook set is
1180
+ * pinned to `LlmExecutorHooks`.
1181
+ */
1182
+ type ExecutorCreateOptions = CoreExecutorExecuteOptions<any, any, any, any, LlmExecutorHooks>;
1183
+ /**
1184
+ * Canonical normalized config. The JSON Schema in `schema.ts` validates this
1185
+ * shape; every loader funnels into it via `normalizeConfig`.
1186
+ */
1187
+ interface ExecutorConfig {
1188
+ provider: ProviderKey;
1189
+ model?: string;
1190
+ system?: string;
1191
+ message: string;
1192
+ parser: CreateParserType;
1193
+ parserOptions?: Record<string, unknown>;
1194
+ llmOptions?: Record<string, unknown>;
1195
+ executorOptions?: Record<string, unknown>;
1196
+ data?: Record<string, unknown>;
1197
+ }
1198
+ /**
1199
+ * Runtime overrides applied over a parsed config. Precedence: caller (patch)
1200
+ * > file > defaults. `data` is deep-merged; every other field is replace-on-set.
1201
+ */
1202
+ interface ExecutorConfigPatch {
1203
+ data?: Record<string, unknown>;
1204
+ model?: string;
1205
+ provider?: ProviderKey;
1206
+ parser?: CreateParserType;
1207
+ parserOptions?: Record<string, unknown>;
1208
+ llmOptions?: Record<string, unknown>;
1209
+ executorOptions?: Record<string, unknown>;
1210
+ system?: string;
1211
+ message?: string;
1212
+ }
1213
+ /**
1214
+ * Per-run overrides for the terminal "run once" helpers (`runConfig`,
1215
+ * `runFile`). `data` deep-merges over `config.data`; `executorOptions`
1216
+ * shallow-merges over `config.executorOptions`.
1217
+ */
1218
+ interface RunOverrides {
1219
+ data?: Record<string, unknown>;
1220
+ executorOptions?: Record<string, unknown>;
1221
+ }
1222
+
1223
+ export { type AllLlm as $, type CallableExecutorCore as A, BaseParser as B, type ChatPromptType as C, DefaultState as D, type ExecutorConfigPatch as E, type FunctionOrExecutor as F, type GenericFunctionCall as G, type PromptPartial as H, type IPromptChatMessages as I, type JsonParserOptions as J, type PromptHelper as K, LlmExecutor as L, replaceTemplateString as M, replaceTemplateStringAsync as N, type OutputResultContent as O, type ParserOutput as P, type OutputResultsText as Q, type RunOverrides as R, StringParser as S, type OutputResultsFunction as T, type IChatMessage as U, type IChatUserMessage as V, type IChatAssistantMessage as W, type IChatSystemMessage as X, configs as Y, type AllUseLlmOptions as Z, type Config as _, type ExecutorConfig as a, type EmbeddingProviderKey as a0, type AllEmbedding as a1, type EmbeddingOutputResult as a2, type Format as a3, BaseStateItem as a4, type CreateParserType as a5, type LlmProvider as a6, type ExecutorContext as a7, type ExecutorExecutionMetadata as a8, type HookErrorRecord as a9, type LlmProviderKey as aa, type UseLlmKey as ab, type JsonParserMatch as ac, type ExecutorCreateOptions as b, BaseParserWithJson as c, type ListToJsonParserOptions as d, type ExecutionContext as e, type OutputResult as f, BasePrompt as g, type PromptOptions as h, type ChatPromptOptions as i, type IChatMessageRole as j, type IChatMessageContentDetailed as k, type IChatMessages as l, type PromptType as m, type PlainObject as n, BaseExecutor as o, type CoreExecutorInput as p, type CoreExecutorExecuteOptions as q, DefaultStateItem as r, Dialogue as s, type BaseLlm as t, BaseState as u, type ExecutorWithLlmOptions as v, type PromptInput as w, type BaseLlCall as x, type LlmExecutorHooks as y, type LlmExecutorWithFunctionsOptions as z };