@jaypie/llm 1.3.1 → 1.3.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.
@@ -0,0 +1,661 @@
1
+ import * as _jaypie_types from '@jaypie/types';
2
+ import { JsonObject, AnyValue, NaturalMap, NaturalSchema, JsonReturn } from '@jaypie/types';
3
+ import { z } from 'zod/v4';
4
+
5
+ declare const MODEL: {
6
+ OPUS: string;
7
+ SONNET: string;
8
+ HAIKU: string;
9
+ FABLE: string;
10
+ MYTHOS: string;
11
+ GEMINI_FLASH: string;
12
+ GEMINI_FLASH_LITE: string;
13
+ GEMINI_PRO: string;
14
+ GPT: string;
15
+ GPT_MINI: string;
16
+ GPT_NANO: string;
17
+ GROK: string;
18
+ };
19
+ declare const PROVIDER: {
20
+ readonly BEDROCK: {
21
+ readonly MODEL: {
22
+ readonly DEFAULT: "amazon.nova-lite-v1:0";
23
+ readonly LARGE: "amazon.nova-pro-v1:0";
24
+ readonly SMALL: "amazon.nova-lite-v1:0";
25
+ readonly TINY: "amazon.nova-micro-v1:0";
26
+ };
27
+ readonly MODEL_MATCH_WORDS: readonly ["amazon.nova", "amazon.titan", "anthropic.claude", "cohere.command", "meta.llama", "mistral.mistral", "ai21."];
28
+ readonly NAME: "bedrock";
29
+ readonly REGION: "AWS_REGION";
30
+ };
31
+ readonly ANTHROPIC: {
32
+ readonly MAX_TOKENS: {
33
+ readonly DEFAULT: 4096;
34
+ };
35
+ readonly MODEL: {
36
+ readonly DEFAULT: "claude-sonnet-4-6";
37
+ readonly LARGE: "claude-opus-4-8";
38
+ readonly SMALL: "claude-sonnet-4-6";
39
+ readonly TINY: "claude-haiku-4-5";
40
+ };
41
+ readonly MODEL_MATCH_WORDS: readonly ["anthropic", "claude", "haiku", "opus", "sonnet"];
42
+ readonly NAME: "anthropic";
43
+ readonly PROMPT: {
44
+ readonly AI: "\n\nAssistant:";
45
+ readonly HUMAN: "\n\nHuman:";
46
+ };
47
+ readonly ROLE: {
48
+ readonly ASSISTANT: "assistant";
49
+ readonly SYSTEM: "system";
50
+ readonly USER: "user";
51
+ };
52
+ readonly TOOLS: {
53
+ readonly SCHEMA_VERSION: "v2";
54
+ };
55
+ };
56
+ /** @deprecated Use PROVIDER.GOOGLE — "Google" is the provider; Gemini is the model family */
57
+ readonly GEMINI: {
58
+ readonly MODEL: {
59
+ readonly DEFAULT: "gemini-3.1-pro-preview";
60
+ readonly LARGE: "gemini-3.1-pro-preview";
61
+ readonly SMALL: "gemini-3.5-flash";
62
+ readonly TINY: "gemini-3.1-flash-lite";
63
+ };
64
+ readonly MODEL_MATCH_WORDS: readonly ["gemini", "google"];
65
+ readonly NAME: "google";
66
+ readonly ROLE: {
67
+ readonly MODEL: "model";
68
+ readonly USER: "user";
69
+ };
70
+ };
71
+ readonly GOOGLE: {
72
+ readonly MODEL: {
73
+ readonly DEFAULT: "gemini-3.1-pro-preview";
74
+ readonly LARGE: "gemini-3.1-pro-preview";
75
+ readonly SMALL: "gemini-3.5-flash";
76
+ readonly TINY: "gemini-3.1-flash-lite";
77
+ };
78
+ readonly MODEL_MATCH_WORDS: readonly ["gemini", "google"];
79
+ readonly NAME: "google";
80
+ readonly ROLE: {
81
+ readonly MODEL: "model";
82
+ readonly USER: "user";
83
+ };
84
+ };
85
+ readonly OPENAI: {
86
+ readonly MODEL: {
87
+ readonly DEFAULT: "gpt-5.4";
88
+ readonly LARGE: "gpt-5.5";
89
+ readonly SMALL: "gpt-5.4-mini";
90
+ readonly TINY: "gpt-5.4-nano";
91
+ };
92
+ readonly MODEL_MATCH_WORDS: readonly ["openai", "gpt", RegExp];
93
+ readonly NAME: "openai";
94
+ };
95
+ readonly OPENROUTER: {
96
+ readonly MODEL: {
97
+ readonly DEFAULT: "anthropic/claude-sonnet-4-6";
98
+ readonly LARGE: "anthropic/claude-opus-4-8";
99
+ readonly SMALL: "anthropic/claude-sonnet-4-6";
100
+ readonly TINY: "anthropic/claude-haiku-4-5";
101
+ };
102
+ readonly MODEL_MATCH_WORDS: readonly ["openrouter"];
103
+ readonly NAME: "openrouter";
104
+ readonly ROLE: {
105
+ readonly ASSISTANT: "assistant";
106
+ readonly SYSTEM: "system";
107
+ readonly TOOL: "tool";
108
+ readonly USER: "user";
109
+ };
110
+ };
111
+ readonly XAI: {
112
+ readonly API_KEY: "XAI_API_KEY";
113
+ readonly BASE_URL: "https://api.x.ai/v1";
114
+ readonly MODEL: {
115
+ readonly DEFAULT: "grok-latest";
116
+ readonly LARGE: "grok-4.3-latest";
117
+ readonly SMALL: "grok-4-1-fast-reasoning";
118
+ readonly TINY: "grok-4-1-fast-non-reasoning";
119
+ };
120
+ readonly MODEL_MATCH_WORDS: readonly ["grok", "xai"];
121
+ readonly NAME: "xai";
122
+ };
123
+ };
124
+ type LlmProviderName = typeof PROVIDER.ANTHROPIC.NAME | typeof PROVIDER.BEDROCK.NAME | typeof PROVIDER.GOOGLE.NAME | typeof PROVIDER.OPENAI.NAME | typeof PROVIDER.OPENROUTER.NAME | typeof PROVIDER.XAI.NAME;
125
+ declare const DEFAULT: {
126
+ readonly MODEL: {
127
+ readonly BASE: "gpt-5.4";
128
+ readonly LARGE: "gpt-5.5";
129
+ readonly SMALL: "gpt-5.4-mini";
130
+ readonly TINY: "gpt-5.4-nano";
131
+ };
132
+ readonly PROVIDER: {
133
+ readonly MODEL: {
134
+ readonly DEFAULT: "gpt-5.4";
135
+ readonly LARGE: "gpt-5.5";
136
+ readonly SMALL: "gpt-5.4-mini";
137
+ readonly TINY: "gpt-5.4-nano";
138
+ };
139
+ readonly MODEL_MATCH_WORDS: readonly ["openai", "gpt", RegExp];
140
+ readonly NAME: "openai";
141
+ };
142
+ };
143
+ declare const ALL: {
144
+ readonly BASE: readonly ["claude-sonnet-4-6", "gemini-3.1-pro-preview", "gpt-5.4", "grok-latest"];
145
+ readonly COMBINED: readonly ("claude-opus-4-8" | "claude-sonnet-4-6" | "claude-haiku-4-5" | "gemini-3.5-flash" | "gemini-3.1-flash-lite" | "gemini-3.1-pro-preview" | "gpt-5.5" | "gpt-5.4-mini" | "gpt-5.4-nano" | "grok-latest" | "gpt-5.4" | "grok-4.3-latest" | "grok-4-1-fast-reasoning" | "grok-4-1-fast-non-reasoning")[];
146
+ readonly LARGE: readonly ["claude-opus-4-8", "gemini-3.1-pro-preview", "gpt-5.5", "grok-4.3-latest"];
147
+ readonly SMALL: readonly ["claude-sonnet-4-6", "gemini-3.5-flash", "gpt-5.4-mini", "grok-4-1-fast-reasoning"];
148
+ readonly TINY: readonly ["claude-haiku-4-5", "gemini-3.1-flash-lite", "gpt-5.4-nano", "grok-4-1-fast-non-reasoning"];
149
+ };
150
+
151
+ declare const constants_ALL: typeof ALL;
152
+ declare const constants_DEFAULT: typeof DEFAULT;
153
+ type constants_LlmProviderName = LlmProviderName;
154
+ declare const constants_MODEL: typeof MODEL;
155
+ declare const constants_PROVIDER: typeof PROVIDER;
156
+ declare namespace constants {
157
+ export { constants_ALL as ALL, constants_DEFAULT as DEFAULT, constants_MODEL as MODEL, constants_PROVIDER as PROVIDER };
158
+ export type { constants_LlmProviderName as LlmProviderName };
159
+ }
160
+
161
+ interface LlmTool {
162
+ description: string;
163
+ name: string;
164
+ parameters: JsonObject | z.ZodType;
165
+ type: "function" | string;
166
+ call: (args?: JsonObject) => Promise<AnyValue> | AnyValue;
167
+ message?: string | ((args?: JsonObject, context?: {
168
+ name: string;
169
+ }) => Promise<string> | string);
170
+ }
171
+
172
+ declare enum LlmStreamChunkType {
173
+ Done = "done",
174
+ Error = "error",
175
+ Text = "text",
176
+ ToolCall = "tool_call",
177
+ ToolResult = "tool_result"
178
+ }
179
+ interface LlmStreamChunkText {
180
+ type: LlmStreamChunkType.Text;
181
+ content: string;
182
+ }
183
+ interface LlmStreamChunkToolCall {
184
+ type: LlmStreamChunkType.ToolCall;
185
+ toolCall: {
186
+ id: string;
187
+ name: string;
188
+ arguments: string;
189
+ /** Provider-specific metadata preserved through tool-call roundtrip */
190
+ metadata?: Record<string, unknown>;
191
+ };
192
+ }
193
+ interface LlmStreamChunkToolResult {
194
+ type: LlmStreamChunkType.ToolResult;
195
+ toolResult: {
196
+ id: string;
197
+ name: string;
198
+ result: unknown;
199
+ };
200
+ }
201
+ interface LlmStreamChunkDone {
202
+ type: LlmStreamChunkType.Done;
203
+ usage: LlmUsage;
204
+ }
205
+ interface LlmStreamChunkError {
206
+ type: LlmStreamChunkType.Error;
207
+ error: {
208
+ detail?: string;
209
+ status: number | string;
210
+ title: string;
211
+ };
212
+ }
213
+ type LlmStreamChunk = LlmStreamChunkDone | LlmStreamChunkError | LlmStreamChunkText | LlmStreamChunkToolCall | LlmStreamChunkToolResult;
214
+
215
+ type LogFunction = (message: string, context: {
216
+ name: string;
217
+ args: any;
218
+ }) => void | Promise<void>;
219
+ interface ToolkitOptions {
220
+ explain?: boolean;
221
+ log?: boolean | LogFunction;
222
+ }
223
+ declare class Toolkit {
224
+ private readonly _tools;
225
+ private readonly _options;
226
+ private readonly explain;
227
+ private readonly log;
228
+ constructor(tools: LlmTool[], options?: ToolkitOptions);
229
+ get tools(): Omit<LlmTool, "call">[];
230
+ call({ name, arguments: args }: {
231
+ name: string;
232
+ arguments: string;
233
+ }): Promise<_jaypie_types.AnyValue>;
234
+ extend(tools: LlmTool[], options?: {
235
+ warn?: boolean;
236
+ replace?: boolean;
237
+ log?: boolean | LogFunction;
238
+ explain?: boolean;
239
+ }): this;
240
+ }
241
+
242
+ declare enum LlmMessageRole {
243
+ Assistant = "assistant",
244
+ Developer = "developer",
245
+ System = "system",
246
+ User = "user"
247
+ }
248
+ declare enum LlmMessageType {
249
+ FunctionCall = "function_call",
250
+ FunctionCallOutput = "function_call_output",
251
+ InputFile = "input_file",
252
+ InputImage = "input_image",
253
+ InputText = "input_text",
254
+ ItemReference = "item_reference",
255
+ Message = "message",
256
+ OutputText = "output_text",
257
+ Refusal = "refusal"
258
+ }
259
+ declare enum LlmResponseStatus {
260
+ Completed = "completed",
261
+ Incomplete = "incomplete",
262
+ InProgress = "in_progress"
263
+ }
264
+ interface LlmError {
265
+ detail?: string;
266
+ status: number | string;
267
+ title: string;
268
+ }
269
+ interface LlmInputContentFile {
270
+ type: LlmMessageType.InputFile;
271
+ file_data: File | string;
272
+ file_id?: string;
273
+ filename?: string;
274
+ }
275
+ interface LlmInputContentImage {
276
+ type: LlmMessageType.InputImage;
277
+ detail?: File;
278
+ file_id?: string;
279
+ image_url?: string;
280
+ }
281
+ interface LlmInputContentText {
282
+ type: LlmMessageType.InputText;
283
+ text: string;
284
+ }
285
+ type LlmInputContent = LlmInputContentFile | LlmInputContentImage | LlmInputContentText;
286
+ /**
287
+ * Represents the "Input message object" in the "input item list"
288
+ * from [OpenAI Responses API](https://platform.openai.com/docs/api-reference/responses/create)
289
+ */
290
+ interface LlmInputMessage {
291
+ content: string | Array<LlmInputContent>;
292
+ role: LlmMessageRole;
293
+ type?: LlmMessageType.Message;
294
+ }
295
+ /**
296
+ * File input that can be loaded from local filesystem, S3, or provided as base64 data.
297
+ * For PDFs, specific pages can be extracted via the `pages` property.
298
+ * If the file extension is an image type, it will be treated as an image internally.
299
+ */
300
+ interface LlmOperateInputFile {
301
+ /** Path or filename (extension determines type via /\.(\w+)$/) */
302
+ file: string;
303
+ /** S3 bucket name (if present, load from S3) */
304
+ bucket?: string;
305
+ /** Specific pages to extract from PDF (omit = all pages) */
306
+ pages?: number[];
307
+ /** Base64 data (if present, use directly instead of loading from file) */
308
+ data?: string;
309
+ }
310
+ /**
311
+ * Image input that can be loaded from local filesystem, S3, or provided as base64 data.
312
+ */
313
+ interface LlmOperateInputImage {
314
+ /** Path or filename */
315
+ image: string;
316
+ /** S3 bucket name (if present, load from S3) */
317
+ bucket?: string;
318
+ /** Base64 data (if present, use directly instead of loading from file) */
319
+ data?: string;
320
+ }
321
+ /**
322
+ * Content item in LlmOperateInput array.
323
+ * Can be a string (text), file object, or image object.
324
+ */
325
+ type LlmOperateInputContent = string | LlmOperateInputFile | LlmOperateInputImage;
326
+ /**
327
+ * Simplified input format for operate() that supports automatic file resolution.
328
+ * Files/images are loaded from local filesystem, S3, or provided data.
329
+ *
330
+ * @example
331
+ * ```typescript
332
+ * const input: LlmOperateInput = [
333
+ * "Extract text from these documents",
334
+ * { file: "document.pdf", bucket: "my-bucket", pages: [1, 2, 3] },
335
+ * { image: "photo.png" }, // loads from local filesystem
336
+ * ];
337
+ * ```
338
+ */
339
+ type LlmOperateInput = LlmOperateInputContent[];
340
+ interface LlmOutputContentText {
341
+ annotations?: AnyValue[];
342
+ text: string;
343
+ type: LlmMessageType.OutputText;
344
+ }
345
+ interface LlmOutputRefusal {
346
+ refusal: string;
347
+ type: LlmMessageType.Refusal;
348
+ }
349
+ type LlmOutputContent = LlmOutputContentText | LlmOutputRefusal;
350
+ /**
351
+ * Represents the "Output message object" in the "input item list"
352
+ * from [OpenAI Responses API](https://platform.openai.com/docs/api-reference/responses/create)
353
+ */
354
+ interface LlmOutputMessage {
355
+ content: string | Array<LlmOutputContent>;
356
+ id?: string;
357
+ role: LlmMessageRole.Assistant;
358
+ status?: LlmResponseStatus;
359
+ type?: LlmMessageType.Message;
360
+ }
361
+ type LlmOutputItem = LlmToolCall | LlmToolResult | LlmOutputMessage;
362
+ type LlmOutput = LlmOutputItem[];
363
+ interface LlmToolCall {
364
+ arguments: string;
365
+ call_id: string;
366
+ id: string;
367
+ name: string;
368
+ type: LlmMessageType.FunctionCall;
369
+ status: LlmResponseStatus;
370
+ }
371
+ interface LlmToolResult {
372
+ call_id: string;
373
+ output: string;
374
+ status?: LlmResponseStatus;
375
+ type: LlmMessageType.FunctionCallOutput;
376
+ }
377
+ interface LlmItemReference {
378
+ type: LlmMessageType.ItemReference;
379
+ id: string;
380
+ }
381
+ type LlmHistoryItem = LlmInputMessage | LlmItemReference | LlmOutputItem | LlmToolResult;
382
+ type LlmHistory = LlmHistoryItem[];
383
+ /**
384
+ * Configuration for a fallback provider.
385
+ * Used when the primary provider fails with an unrecoverable error.
386
+ */
387
+ interface LlmFallbackConfig {
388
+ /** Provider name (e.g., "openai", "anthropic", "google") */
389
+ provider: string;
390
+ /** Model to use with this provider (optional, uses provider default if not specified) */
391
+ model?: string;
392
+ /** API key for this provider (optional, uses environment variable if not specified) */
393
+ apiKey?: string;
394
+ }
395
+ interface LlmMessageOptions {
396
+ data?: NaturalMap;
397
+ model?: string;
398
+ placeholders?: {
399
+ message?: boolean;
400
+ system?: boolean;
401
+ };
402
+ response?: NaturalSchema | z.ZodType;
403
+ system?: string;
404
+ }
405
+ interface LlmOperateOptions {
406
+ data?: NaturalMap;
407
+ explain?: boolean;
408
+ /** Chain of fallback providers to try if primary fails. Set to false to disable instance-level fallback. */
409
+ fallback?: LlmFallbackConfig[] | false;
410
+ format?: JsonObject | NaturalSchema | z.ZodType;
411
+ history?: LlmHistory;
412
+ hooks?: {
413
+ afterEachModelResponse?: ({ input, options, providerRequest, providerResponse, content, usage, }: {
414
+ input: string | LlmHistory | LlmInputMessage;
415
+ options?: LlmOperateOptions;
416
+ providerRequest: any;
417
+ providerResponse: any;
418
+ content: string | JsonObject;
419
+ usage: LlmUsage;
420
+ }) => unknown | Promise<unknown>;
421
+ afterEachTool?: ({ result, toolName, args, }: {
422
+ result: unknown;
423
+ toolName: string;
424
+ args: string;
425
+ }) => unknown | Promise<unknown>;
426
+ beforeEachModelRequest?: ({ input, options, providerRequest, }: {
427
+ input: string | LlmHistory | LlmInputMessage;
428
+ options?: LlmOperateOptions;
429
+ providerRequest: any;
430
+ }) => unknown | Promise<unknown>;
431
+ beforeEachTool?: ({ toolName, args, }: {
432
+ toolName: string;
433
+ args: string;
434
+ }) => unknown | Promise<unknown>;
435
+ onRetryableModelError?: ({ input, options, providerRequest, error, }: {
436
+ input: string | LlmHistory | LlmInputMessage;
437
+ options?: LlmOperateOptions;
438
+ providerRequest: any;
439
+ error: any;
440
+ }) => unknown | Promise<unknown>;
441
+ onToolError?: ({ error, toolName, args, }: {
442
+ error: Error;
443
+ toolName: string;
444
+ args: string;
445
+ }) => unknown | Promise<unknown>;
446
+ onUnrecoverableModelError?: ({ input, options, providerRequest, error, }: {
447
+ input: string | LlmHistory | LlmInputMessage;
448
+ options?: LlmOperateOptions;
449
+ providerRequest: any;
450
+ error: any;
451
+ }) => unknown | Promise<unknown>;
452
+ };
453
+ instructions?: string;
454
+ model?: string;
455
+ placeholders?: {
456
+ input?: boolean;
457
+ instructions?: boolean;
458
+ system?: boolean;
459
+ };
460
+ providerOptions?: JsonObject;
461
+ system?: string;
462
+ temperature?: number;
463
+ tools?: LlmTool[] | Toolkit;
464
+ turns?: boolean | number;
465
+ user?: string;
466
+ }
467
+ interface LlmOptions {
468
+ apiKey?: string;
469
+ /** Chain of fallback providers to try if primary fails */
470
+ fallback?: LlmFallbackConfig[];
471
+ model?: string;
472
+ }
473
+ interface LlmUsageItem {
474
+ input: number;
475
+ output: number;
476
+ reasoning: number;
477
+ total: number;
478
+ provider?: string;
479
+ model?: string;
480
+ }
481
+ type LlmUsage = LlmUsageItem[];
482
+ interface LlmOperateResponse {
483
+ content?: string | JsonObject;
484
+ error?: LlmError;
485
+ /** Number of providers attempted (1 = primary only, >1 = fallback(s) used) */
486
+ fallbackAttempts?: number;
487
+ /** Whether a fallback provider was used instead of the primary */
488
+ fallbackUsed?: boolean;
489
+ history: LlmHistory;
490
+ model?: string;
491
+ output: LlmOutput;
492
+ /** Which provider actually handled the request */
493
+ provider?: string;
494
+ reasoning: string[];
495
+ responses: JsonReturn[];
496
+ status: LlmResponseStatus;
497
+ usage: LlmUsage;
498
+ }
499
+ interface LlmProvider {
500
+ operate?(input: string | LlmHistory | LlmInputMessage | LlmOperateInput, options?: LlmOperateOptions): Promise<LlmOperateResponse>;
501
+ send(message: string, options?: LlmMessageOptions): Promise<string | JsonObject>;
502
+ stream?(input: string | LlmHistory | LlmInputMessage | LlmOperateInput, options?: LlmOperateOptions): AsyncIterable<LlmStreamChunk>;
503
+ }
504
+
505
+ declare class Llm implements LlmProvider {
506
+ private _fallbackConfig?;
507
+ private _llm;
508
+ private _options;
509
+ private _provider;
510
+ constructor(providerName?: LlmProviderName | string, options?: LlmOptions);
511
+ private createProvider;
512
+ send(message: string, options?: LlmMessageOptions): Promise<string | JsonObject>;
513
+ /**
514
+ * Resolves the fallback chain from instance config and per-call options.
515
+ * Per-call options take precedence over instance config.
516
+ * Returns empty array if fallback is disabled.
517
+ */
518
+ private resolveFallbackChain;
519
+ /**
520
+ * Creates a fallback Llm instance lazily when needed.
521
+ */
522
+ private createFallbackInstance;
523
+ operate(input: string | LlmHistory | LlmInputMessage | LlmOperateInput, options?: LlmOperateOptions): Promise<LlmOperateResponse>;
524
+ stream(input: string | LlmHistory | LlmInputMessage | LlmOperateInput, options?: LlmOperateOptions): AsyncIterable<LlmStreamChunk>;
525
+ static send(message: string, options?: LlmMessageOptions & {
526
+ llm?: LlmProviderName;
527
+ apiKey?: string;
528
+ model?: string;
529
+ }): Promise<string | JsonObject>;
530
+ static operate(input: string | LlmHistory | LlmInputMessage | LlmOperateInput, options?: LlmOperateOptions & {
531
+ apiKey?: string;
532
+ fallback?: LlmFallbackConfig[] | false;
533
+ llm?: LlmProviderName;
534
+ model?: string;
535
+ }): Promise<LlmOperateResponse>;
536
+ static stream(input: string | LlmHistory | LlmInputMessage | LlmOperateInput, options?: LlmOperateOptions & {
537
+ llm?: LlmProviderName;
538
+ apiKey?: string;
539
+ model?: string;
540
+ }): AsyncIterable<LlmStreamChunk>;
541
+ }
542
+
543
+ /**
544
+ * Type guard to check if an item is an LlmOperateInputFile
545
+ */
546
+ declare function isLlmOperateInputFile(item: unknown): item is LlmOperateInputFile;
547
+ /**
548
+ * Type guard to check if an item is an LlmOperateInputImage
549
+ */
550
+ declare function isLlmOperateInputImage(item: unknown): item is LlmOperateInputImage;
551
+ /**
552
+ * Type guard to check if an item is an LlmOperateInputContent
553
+ */
554
+ declare function isLlmOperateInputContent(item: unknown): item is LlmOperateInputContent;
555
+ /**
556
+ * Type guard to check if input is an LlmOperateInput array
557
+ */
558
+ declare function isLlmOperateInput(input: unknown): input is LlmOperateInput;
559
+
560
+ declare const tools: LlmTool[];
561
+ declare class JaypieToolkit extends Toolkit {
562
+ readonly random: LlmTool;
563
+ readonly roll: LlmTool;
564
+ readonly time: LlmTool;
565
+ readonly weather: LlmTool;
566
+ constructor(tools: LlmTool[], options?: any);
567
+ }
568
+ declare const toolkit: JaypieToolkit;
569
+
570
+ /**
571
+ * Extracts reasoning text from LLM history items.
572
+ *
573
+ * Reasoning items may have text in different locations depending on the provider:
574
+ * - OpenAI: `summary` array with objects containing `text` property (type: "reasoning")
575
+ * - OpenAI: `content` property on reasoning items (type: "reasoning")
576
+ * - Anthropic: `thinking` property on thinking items (type: "thinking")
577
+ * - OpenRouter/z-ai: `reasoning` property on message items
578
+ *
579
+ * @param history - The LLM history array to extract reasoning from
580
+ * @returns Array of reasoning text strings
581
+ */
582
+ declare function extractReasoning(history: LlmHistory): string[];
583
+
584
+ declare class BedrockProvider implements LlmProvider {
585
+ private model;
586
+ private region?;
587
+ private _client?;
588
+ private _operateLoop?;
589
+ private _streamLoop?;
590
+ private log;
591
+ private conversationHistory;
592
+ constructor(model?: string, { region }?: {
593
+ region?: string;
594
+ });
595
+ private getClient;
596
+ private getOperateLoop;
597
+ private getStreamLoop;
598
+ send(message: string, options?: LlmMessageOptions): Promise<string | JsonObject>;
599
+ operate(input: string | LlmHistory | LlmInputMessage, options?: LlmOperateOptions): Promise<LlmOperateResponse>;
600
+ stream(input: string | LlmHistory | LlmInputMessage, options?: LlmOperateOptions): AsyncIterable<LlmStreamChunk>;
601
+ }
602
+
603
+ declare class GoogleProvider implements LlmProvider {
604
+ private model;
605
+ private _client?;
606
+ private _operateLoop?;
607
+ private _streamLoop?;
608
+ private apiKey?;
609
+ private log;
610
+ private conversationHistory;
611
+ constructor(model?: string, { apiKey }?: {
612
+ apiKey?: string;
613
+ });
614
+ private getClient;
615
+ private getOperateLoop;
616
+ private getStreamLoop;
617
+ send(message: string, options?: LlmMessageOptions): Promise<string | JsonObject>;
618
+ operate(input: string | LlmHistory | LlmInputMessage, options?: LlmOperateOptions): Promise<LlmOperateResponse>;
619
+ stream(input: string | LlmHistory | LlmInputMessage, options?: LlmOperateOptions): AsyncIterable<LlmStreamChunk>;
620
+ }
621
+
622
+ declare class OpenRouterProvider implements LlmProvider {
623
+ private model;
624
+ private _client?;
625
+ private _operateLoop?;
626
+ private _streamLoop?;
627
+ private apiKey?;
628
+ private log;
629
+ private conversationHistory;
630
+ constructor(model?: string, { apiKey }?: {
631
+ apiKey?: string;
632
+ });
633
+ private getClient;
634
+ private getOperateLoop;
635
+ private getStreamLoop;
636
+ send(message: string, options?: LlmMessageOptions): Promise<string | JsonObject>;
637
+ operate(input: string | LlmHistory | LlmInputMessage, options?: LlmOperateOptions): Promise<LlmOperateResponse>;
638
+ stream(input: string | LlmHistory | LlmInputMessage, options?: LlmOperateOptions): AsyncIterable<LlmStreamChunk>;
639
+ }
640
+
641
+ declare class XaiProvider implements LlmProvider {
642
+ private model;
643
+ private _client?;
644
+ private _operateLoop?;
645
+ private _streamLoop?;
646
+ private apiKey?;
647
+ private log;
648
+ private conversationHistory;
649
+ constructor(model?: string, { apiKey }?: {
650
+ apiKey?: string;
651
+ });
652
+ private getClient;
653
+ private getOperateLoop;
654
+ private getStreamLoop;
655
+ send(message: string, options?: LlmMessageOptions): Promise<string | JsonObject>;
656
+ operate(input: string | LlmHistory | LlmInputMessage, options?: LlmOperateOptions): Promise<LlmOperateResponse>;
657
+ stream(input: string | LlmHistory | LlmInputMessage, options?: LlmOperateOptions): AsyncIterable<LlmStreamChunk>;
658
+ }
659
+
660
+ export { BedrockProvider, GoogleProvider as GeminiProvider, GoogleProvider, JaypieToolkit, constants as LLM, Llm, LlmMessageRole, LlmMessageType, LlmStreamChunkType, OpenRouterProvider, Toolkit, XaiProvider, extractReasoning, isLlmOperateInput, isLlmOperateInputContent, isLlmOperateInputFile, isLlmOperateInputImage, toolkit, tools };
661
+ export type { LlmFallbackConfig, LlmHistory, LlmInputContent, LlmInputContentFile, LlmInputContentImage, LlmInputContentText, LlmInputMessage, LlmMessageOptions, LlmOperateInput, LlmOperateInputContent, LlmOperateInputFile, LlmOperateInputImage, LlmOperateOptions, LlmOperateResponse, LlmOptions, LlmProvider, LlmStreamChunk, LlmStreamChunkDone, LlmStreamChunkError, LlmStreamChunkText, LlmStreamChunkToolCall, LlmStreamChunkToolResult, LlmTool };
@@ -1,9 +1,10 @@
1
+ import { createLogger } from "@jaypie/logger";
1
2
  import type Anthropic from "@anthropic-ai/sdk";
2
3
  import { LlmMessageOptions } from "../../types/LlmProvider.interface.js";
3
4
  import { z } from "zod/v4";
4
5
  import { JsonObject, NaturalSchema } from "@jaypie/types";
5
6
  export declare function loadSdk(): Promise<typeof import("@anthropic-ai/sdk")>;
6
- export declare const getLogger: () => import("@jaypie/logger/dist/esm/JaypieLogger.js").default;
7
+ export declare const getLogger: () => ReturnType<typeof createLogger>;
7
8
  export declare function initializeClient({ apiKey, }?: {
8
9
  apiKey?: string;
9
10
  }): Promise<Anthropic>;
@@ -1,6 +1,7 @@
1
+ import { createLogger } from "@jaypie/logger";
1
2
  import type { BedrockRuntimeClient } from "@aws-sdk/client-bedrock-runtime";
2
3
  export declare function loadSdk(): Promise<typeof import("@aws-sdk/client-bedrock-runtime")>;
3
- export declare const getLogger: () => import("@jaypie/logger/dist/esm/JaypieLogger").default;
4
+ export declare const getLogger: () => ReturnType<typeof createLogger>;
4
5
  export declare function initializeClient({ region, }?: {
5
6
  region?: string;
6
7
  }): Promise<BedrockRuntimeClient>;
@@ -1,7 +1,8 @@
1
+ import { createLogger } from "@jaypie/logger";
1
2
  import type { GoogleGenAI } from "@google/genai";
2
3
  import { LlmMessageOptions } from "../../types/LlmProvider.interface.js";
3
4
  export declare function loadSdk(): Promise<typeof import("@google/genai")>;
4
- export declare const getLogger: () => import("@jaypie/logger/dist/esm/JaypieLogger.js").default;
5
+ export declare const getLogger: () => ReturnType<typeof createLogger>;
5
6
  export declare function initializeClient({ apiKey, }?: {
6
7
  apiKey?: string;
7
8
  }): Promise<GoogleGenAI>;