@fifthrevision/axle 0.4.2 → 0.6.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.ts CHANGED
@@ -1,3 +1,6 @@
1
+ import * as z from 'zod';
2
+ import z__default, { ZodObject, z as z$1 } from 'zod';
3
+
1
4
  type PlainObject = Record<string, unknown>;
2
5
  type ProgramOptions = {
3
6
  dryRun?: boolean;
@@ -42,6 +45,75 @@ interface RecorderWriter {
42
45
  flush?(): Promise<void>;
43
46
  }
44
47
 
48
+ interface StreamChunk {
49
+ type: "start" | "text" | "tool-call-start" | "tool-call-delta" | "tool-call-complete" | "thinking-start" | "thinking-delta" | "complete" | "error";
50
+ id?: string;
51
+ data?: any;
52
+ }
53
+ interface StreamStartChunk extends StreamChunk {
54
+ type: "start";
55
+ id: string;
56
+ data: {
57
+ model: string;
58
+ timestamp: number;
59
+ };
60
+ }
61
+ interface StreamCompleteChunk extends StreamChunk {
62
+ type: "complete";
63
+ data: {
64
+ finishReason: AxleStopReason;
65
+ usage: Stats;
66
+ };
67
+ }
68
+ interface StreamTextChunk extends StreamChunk {
69
+ type: "text";
70
+ data: {
71
+ text: string;
72
+ index: number;
73
+ };
74
+ }
75
+ interface StreamThinkingStartChunk extends StreamChunk {
76
+ type: "thinking-start";
77
+ data: {
78
+ index: number;
79
+ redacted?: boolean;
80
+ };
81
+ }
82
+ interface StreamThinkingDeltaChunk extends StreamChunk {
83
+ type: "thinking-delta";
84
+ data: {
85
+ index: number;
86
+ text: string;
87
+ };
88
+ }
89
+ interface StreamToolCallStartChunk extends StreamChunk {
90
+ type: "tool-call-start";
91
+ data: {
92
+ index: number;
93
+ id: string;
94
+ name: string;
95
+ };
96
+ }
97
+ interface StreamToolCallCompleteChunk extends StreamChunk {
98
+ type: "tool-call-complete";
99
+ data: {
100
+ index: number;
101
+ id: string;
102
+ name: string;
103
+ arguments: any;
104
+ };
105
+ }
106
+ interface StreamErrorChunk extends StreamChunk {
107
+ type: "error";
108
+ data: {
109
+ type: string;
110
+ message: string;
111
+ usage?: Stats;
112
+ raw?: any;
113
+ };
114
+ }
115
+ type AnyStreamChunk = StreamStartChunk | StreamCompleteChunk | StreamTextChunk | StreamToolCallStartChunk | StreamToolCallCompleteChunk | StreamThinkingStartChunk | StreamThinkingDeltaChunk | StreamErrorChunk;
116
+
45
117
  declare class Recorder {
46
118
  instanceId: `${string}-${string}-${string}-${string}-${string}`;
47
119
  private currentLevel;
@@ -92,41 +164,61 @@ type Base64FileInfo = FileInfo & {
92
164
  type: "image" | "document";
93
165
  };
94
166
 
95
- interface ToolSchema {
167
+ type AxleMessage = AxleUserMessage | AxleAssistantMessage | AxleToolCallMessage;
168
+ interface AxleUserMessage {
169
+ role: "user";
170
+ name?: string;
171
+ content: string | Array<ContentPart>;
172
+ }
173
+ interface AxleAssistantMessage {
174
+ role: "assistant";
175
+ id: string;
176
+ model?: string;
177
+ content: Array<ContentPartText | ContentPartThinking | ContentPartToolCall>;
178
+ finishReason?: AxleStopReason;
179
+ }
180
+ interface AxleToolCallMessage {
181
+ role: "tool";
182
+ content: Array<AxleToolCallResult>;
183
+ }
184
+ interface AxleToolCallResult {
185
+ id: string;
96
186
  name: string;
97
- description: string;
98
- parameters: {
99
- type: "object";
100
- properties: Record<string, object>;
101
- required: string[];
102
- };
187
+ content: string;
103
188
  }
104
- interface ToolExecutable {
189
+ type ContentPart = ContentPartText | ContentPartFile | ContentPartToolCall | ContentPartThinking;
190
+ interface ContentPartText {
191
+ type: "text";
192
+ text: string;
193
+ }
194
+ interface ContentPartFile {
195
+ type: "file";
196
+ file: FileInfo;
197
+ }
198
+ interface ContentPartThinking {
199
+ type: "thinking";
200
+ text: string;
201
+ redacted?: boolean;
202
+ encrypted?: string;
203
+ signature?: string;
204
+ }
205
+ interface ContentPartToolCall {
206
+ type: "tool-call";
207
+ id: string;
105
208
  name: string;
106
- schema: ToolSchema;
209
+ parameters: Record<string, unknown>;
210
+ }
211
+
212
+ type ToolDefinition<Z extends ZodObject = ZodObject> = {
213
+ name: string;
214
+ description?: string;
215
+ schema: Z;
216
+ };
217
+ interface ToolExecutable<Z extends ZodObject = ZodObject> extends ToolDefinition<Z> {
107
218
  setConfig?: (config: {
108
219
  [key: string]: any;
109
220
  }) => void;
110
- execute: (params: {
111
- [key: string]: any;
112
- }) => Promise<string>;
113
- }
114
-
115
- declare class Chat {
116
- system: string;
117
- messages: ChatItem[];
118
- tools: ToolSchema[];
119
- setToolSchemas(schemas: ToolSchema[]): void;
120
- addSystem(message: string): void;
121
- addUser(message: string): void;
122
- addUser(message: string, instruction: string): void;
123
- addUser(message: string, instruction: string, files: FileInfo[]): void;
124
- addUser(message: string, files: FileInfo[]): any;
125
- addAssistant(message: string, toolCalls?: ToolCall[]): void;
126
- addTools(input: Array<ChatItemToolCallResult>): void;
127
- hasFiles(): boolean;
128
- latest(): ChatItem | undefined;
129
- toString(): string;
221
+ execute: (params: z$1.infer<Z>) => Promise<string>;
130
222
  }
131
223
 
132
224
  type OllamaProviderConfig = {
@@ -141,7 +233,7 @@ type OpenAIProviderConfig = {
141
233
  "api-key": string;
142
234
  model?: string;
143
235
  };
144
- type GoogleAIProviderConfig = {
236
+ type GeminiProviderConfig = {
145
237
  "api-key": string;
146
238
  model?: string;
147
239
  };
@@ -149,81 +241,73 @@ interface AIProviderConfig {
149
241
  ollama: OllamaProviderConfig;
150
242
  anthropic: AnthropicProviderConfig;
151
243
  openai: OpenAIProviderConfig;
152
- googleai: GoogleAIProviderConfig;
244
+ gemini: GeminiProviderConfig;
153
245
  }
154
246
  interface AIProvider {
155
- createChatRequest(chat: Chat, context: {
156
- recorder?: Recorder;
157
- }): AIRequest;
158
- }
159
- interface AIRequest {
160
- execute(runtime: {
161
- recorder?: Recorder;
162
- }): Promise<AIResponse>;
163
- }
164
- interface ToolCall {
165
- id: string;
166
- name: string;
167
- arguments: string | Record<string, unknown>;
247
+ get name(): string;
248
+ get model(): string;
249
+ createGenerationRequest(params: {
250
+ messages: Array<AxleMessage>;
251
+ system?: string;
252
+ tools?: Array<ToolDefinition>;
253
+ context: {
254
+ recorder?: Recorder;
255
+ };
256
+ options?: {
257
+ temperature?: number;
258
+ top_p?: number;
259
+ max_tokens?: number;
260
+ frequency_penalty?: number;
261
+ presence_penalty?: number;
262
+ stop?: string | string[];
263
+ [key: string]: any;
264
+ };
265
+ }): Promise<ModelResult>;
266
+ createStreamingRequest?(params: {
267
+ messages: Array<AxleMessage>;
268
+ system?: string;
269
+ tools?: Array<ToolDefinition>;
270
+ context: {
271
+ recorder?: Recorder;
272
+ };
273
+ options?: {
274
+ temperature?: number;
275
+ top_p?: number;
276
+ max_tokens?: number;
277
+ frequency_penalty?: number;
278
+ presence_penalty?: number;
279
+ stop?: string | string[];
280
+ [key: string]: any;
281
+ };
282
+ }): AsyncGenerator<AnyStreamChunk, void, unknown>;
168
283
  }
169
- type AIResponse = AISuccessResponse | AIErrorResponse;
170
- interface AISuccessResponse {
284
+ interface ModelResponse {
171
285
  type: "success";
286
+ role: "assistant";
172
287
  id: string;
173
- reason: StopReason;
174
- message: ChatItemAssistant;
175
288
  model: string;
176
- toolCalls?: ToolCall[];
289
+ text: string;
290
+ content: Array<ContentPartText | ContentPartThinking | ContentPartToolCall>;
291
+ finishReason: AxleStopReason;
177
292
  usage: Stats;
178
293
  raw: any;
179
294
  }
180
- interface AIErrorResponse {
295
+ interface ModelError {
181
296
  type: "error";
182
297
  error: {
183
298
  type: string;
184
299
  message: string;
185
300
  };
186
- usage: Stats;
187
- raw: any;
301
+ usage?: Stats;
302
+ raw?: any;
188
303
  }
189
- declare enum StopReason {
304
+ type ModelResult = ModelResponse | ModelError;
305
+ declare enum AxleStopReason {
190
306
  Stop = 0,
191
307
  Length = 1,
192
308
  FunctionCall = 2,
193
- Error = 3
194
- }
195
- type ChatItem = ChatItemUser | ChatItemAssistant | ChatItemToolCall;
196
- interface ChatItemUser {
197
- role: "user";
198
- name?: string;
199
- content: string | ChatContent[];
200
- }
201
- interface ChatItemAssistant {
202
- role: "assistant";
203
- content?: string;
204
- toolCalls?: ToolCall[];
205
- }
206
- interface ChatItemToolCallResult {
207
- id: string;
208
- name: string;
209
- content: string;
210
- }
211
- interface ChatItemToolCall {
212
- role: "tool";
213
- content: Array<ChatItemToolCallResult>;
214
- }
215
- type ChatContent = ChatContentText | ChatContentFile | ChatContentInstructions;
216
- interface ChatContentText {
217
- type: "text";
218
- text: string;
219
- }
220
- interface ChatContentInstructions {
221
- type: "instructions";
222
- instructions: string;
223
- }
224
- interface ChatContentFile {
225
- type: "file";
226
- file: FileInfo;
309
+ Error = 3,
310
+ Custom = 4
227
311
  }
228
312
 
229
313
  declare class AxleError extends Error {
@@ -284,7 +368,7 @@ interface DAGWorkflowOptions {
284
368
  }
285
369
 
286
370
  declare class Axle {
287
- private provider;
371
+ provider: AIProvider;
288
372
  private stats;
289
373
  private variables;
290
374
  recorder: Recorder;
@@ -316,21 +400,228 @@ declare class Axle {
316
400
  static loadFileContent(filePath: string, encoding: "base64"): Promise<Base64FileInfo>;
317
401
  }
318
402
 
319
- declare enum ResTypes {
403
+ declare const Models$2: {
404
+ readonly CLAUDE_SONNET_4_5_20250929: "claude-sonnet-4-5-20250929";
405
+ readonly CLAUDE_SONNET_4_5_LATEST: "claude-sonnet-4-5";
406
+ readonly CLAUDE_HAIKU_4_5: "claude-haiku-4-5";
407
+ readonly CLAUDE_OPUS_4_1_20250805: "claude-opus-4-1-20250805";
408
+ readonly CLAUDE_OPUS_4_1_LATEST: "claude-opus-4-1";
409
+ readonly CLAUDE_OPUS_4_20250514: "claude-opus-4-20250514";
410
+ readonly CLAUDE_OPUS_4_LATEST: "claude-opus-4-0";
411
+ readonly CLAUDE_SONNET_4_20250514: "claude-sonnet-4-20250514";
412
+ readonly CLAUDE_SONNET_4_LATEST: "claude-sonnet-4-0";
413
+ readonly CLAUDE_3_7_SONNET_20250219: "claude-3-7-sonnet-20250219";
414
+ readonly CLAUDE_3_7_SONNET_LATEST: "claude-3-7-sonnet-latest";
415
+ readonly CLAUDE_3_5_SONNET_20241022: "claude-3-5-sonnet-20241022";
416
+ readonly CLAUDE_3_5_HAIKU_20241022: "claude-3-5-haiku-20241022";
417
+ readonly CLAUDE_3_5_HAIKU_LATEST: "claude-3-5-haiku-latest";
418
+ readonly CLAUDE_3_5_SONNET_20240620: "claude-3-5-sonnet-20240620";
419
+ };
420
+ declare const DEFAULT_MODEL$2: "claude-haiku-4-5";
421
+
422
+ declare const NAME$3: "anthorpic";
423
+
424
+ declare namespace index$3 {
425
+ export {
426
+ DEFAULT_MODEL$2 as DEFAULT_MODEL,
427
+ Models$2 as Models,
428
+ NAME$3 as NAME,
429
+ };
430
+ }
431
+
432
+ declare const Models$1: {
433
+ readonly GEMINI_2_5_PRO: "gemini-2.5-pro";
434
+ readonly GEMINI_2_5_FLASH: "gemini-2.5-flash";
435
+ readonly GEMINI_2_5_FLASH_PREVIEW_05_20: "gemini-2.5-flash-preview-05-20";
436
+ readonly GEMINI_2_5_FLASH_LITE: "gemini-2.5-flash-lite";
437
+ readonly GEMINI_2_5_FLASH_LITE_PREVIEW_06_17: "gemini-2.5-flash-lite-preview-06-17";
438
+ readonly GEMINI_2_5_FLASH_LIVE_PREVIEW: "gemini-live-2.5-flash-preview";
439
+ readonly GEMINI_2_5_FLASH_PREVIEW_NATIVE_AUDIO_DIALOG: "gemini-2.5-flash-preview-native-audio-dialog";
440
+ readonly GEMINI_2_5_FLASH_EXP_NATIVE_AUDIO_THINKING_DIALOG: "gemini-2.5-flash-exp-native-audio-thinking-dialog";
441
+ readonly GEMINI_2_5_FLASH_IMAGE_PREVIEW: "gemini-2.5-flash-image-preview";
442
+ readonly GEMINI_2_5_FLASH_PREVIEW_TTS: "gemini-2.5-flash-preview-tts";
443
+ readonly GEMINI_2_5_PRO_PREVIEW_TTS: "gemini-2.5-pro-preview-tts";
444
+ readonly GEMINI_2_0_FLASH: "gemini-2.0-flash";
445
+ readonly GEMINI_2_0_FLASH_001: "gemini-2.0-flash-001";
446
+ readonly GEMINI_2_0_FLASH_EXP: "gemini-2.0-flash-exp";
447
+ readonly GEMINI_2_0_FLASH_PREVIEW_IMAGE_GENERATION: "gemini-2.0-flash-preview-image-generation";
448
+ readonly GEMINI_2_0_FLASH_LITE: "gemini-2.0-flash-lite";
449
+ readonly GEMINI_2_0_FLASH_LITE_001: "gemini-2.0-flash-lite-001";
450
+ readonly GEMINI_2_0_FLASH_LIVE_001: "gemini-2.0-flash-live-001";
451
+ readonly GEMINI_1_5_PRO: "gemini-1.5-pro";
452
+ readonly GEMINI_1_5_PRO_LATEST: "gemini-1.5-pro-latest";
453
+ readonly GEMINI_1_5_PRO_001: "gemini-1.5-pro-001";
454
+ readonly GEMINI_1_5_PRO_002: "gemini-1.5-pro-002";
455
+ readonly GEMINI_1_5_FLASH: "gemini-1.5-flash";
456
+ readonly GEMINI_1_5_FLASH_LATEST: "gemini-1.5-flash-latest";
457
+ readonly GEMINI_1_5_FLASH_001: "gemini-1.5-flash-001";
458
+ readonly GEMINI_1_5_FLASH_002: "gemini-1.5-flash-002";
459
+ readonly GEMINI_1_5_FLASH_8B: "gemini-1.5-flash-8b";
460
+ readonly GEMINI_1_5_FLASH_8B_LATEST: "gemini-1.5-flash-8b-latest";
461
+ readonly GEMINI_1_5_FLASH_8B_001: "gemini-1.5-flash-8b-001";
462
+ readonly GEMMA_3N_E4B_IT: "gemma-3n-e4b-it";
463
+ readonly GEMMA_3_1B_IT: "gemma-3-1b-it";
464
+ readonly GEMMA_3_4B_IT: "gemma-3-4b-it";
465
+ readonly GEMMA_3_12B_IT: "gemma-3-12b-it";
466
+ readonly GEMMA_3_27B_IT: "gemma-3-27b-it";
467
+ readonly LEARNLM_2_0_FLASH_EXPERIMENTAL: "learnlm-2.0-flash-experimental";
468
+ readonly EMBEDDING_001: "embedding-001";
469
+ readonly TEXT_EMBEDDING_004: "text-embedding-004";
470
+ };
471
+ declare const DEFAULT_MODEL$1: "gemini-2.5-flash";
472
+
473
+ declare const NAME$2: "Gemini";
474
+
475
+ declare namespace index$2 {
476
+ export {
477
+ DEFAULT_MODEL$1 as DEFAULT_MODEL,
478
+ Models$1 as Models,
479
+ NAME$2 as NAME,
480
+ };
481
+ }
482
+
483
+ declare const DEFAULT_OLLAMA_URL = "http://localhost:11434";
484
+ declare const NAME$1: "Ollama";
485
+
486
+ declare const index$1_DEFAULT_OLLAMA_URL: typeof DEFAULT_OLLAMA_URL;
487
+ declare namespace index$1 {
488
+ export {
489
+ index$1_DEFAULT_OLLAMA_URL as DEFAULT_OLLAMA_URL,
490
+ NAME$1 as NAME,
491
+ };
492
+ }
493
+
494
+ declare const Models: {
495
+ readonly GPT_5: "gpt-5";
496
+ readonly GPT_5_MINI: "gpt-5-mini";
497
+ readonly GPT_5_NANO: "gpt-5-nano";
498
+ readonly GPT_5_CHAT_LATEST: "gpt-5-chat-latest";
499
+ readonly GPT_5_PRO: "gpt-5-pro";
500
+ readonly GPT_5_CODEX: "gpt-5-codex";
501
+ readonly GPT_4_5_PREVIEW: "gpt-4.5-preview";
502
+ readonly GPT_4_5_PREVIEW_2025_02_27: "gpt-4.5-preview-2025-02-27";
503
+ readonly GPT_4_1: "gpt-4.1";
504
+ readonly GPT_4_1_2025_04_14: "gpt-4.1-2025-04-14";
505
+ readonly GPT_4_1_MINI: "gpt-4.1-mini";
506
+ readonly GPT_4_1_MINI_2025_04_14: "gpt-4.1-mini-2025-04-14";
507
+ readonly GPT_4_1_NANO: "gpt-4.1-nano";
508
+ readonly GPT_4_1_NANO_2025_04_14: "gpt-4.1-nano-2025-04-14";
509
+ readonly GPT_4O: "gpt-4o";
510
+ readonly GPT_4O_2024_05_13: "gpt-4o-2024-05-13";
511
+ readonly GPT_4O_2024_08_06: "gpt-4o-2024-08-06";
512
+ readonly GPT_4O_2024_11_20: "gpt-4o-2024-11-20";
513
+ readonly GPT_4O_MINI: "gpt-4o-mini";
514
+ readonly GPT_4O_MINI_2024_07_18: "gpt-4o-mini-2024-07-18";
515
+ readonly GPT_4O_AUDIO_PREVIEW: "gpt-4o-audio-preview";
516
+ readonly GPT_4O_AUDIO_PREVIEW_2024_10_01: "gpt-4o-audio-preview-2024-10-01";
517
+ readonly GPT_4O_AUDIO_PREVIEW_2024_12_17: "gpt-4o-audio-preview-2024-12-17";
518
+ readonly GPT_4O_AUDIO_PREVIEW_2025_06_03: "gpt-4o-audio-preview-2025-06-03";
519
+ readonly GPT_4O_MINI_AUDIO_PREVIEW: "gpt-4o-mini-audio-preview";
520
+ readonly GPT_4O_MINI_AUDIO_PREVIEW_2024_12_17: "gpt-4o-mini-audio-preview-2024-12-17";
521
+ readonly GPT_REALTIME: "gpt-realtime";
522
+ readonly GPT_REALTIME_MINI: "gpt-realtime-mini";
523
+ readonly GPT_4O_REALTIME_PREVIEW: "gpt-4o-realtime-preview";
524
+ readonly GPT_4O_REALTIME_PREVIEW_2024_10_01: "gpt-4o-realtime-preview-2024-10-01";
525
+ readonly GPT_4O_REALTIME_PREVIEW_2024_12_17: "gpt-4o-realtime-preview-2024-12-17";
526
+ readonly GPT_4O_REALTIME_PREVIEW_2025_06_03: "gpt-4o-realtime-preview-2025-06-03";
527
+ readonly GPT_4O_MINI_REALTIME_PREVIEW: "gpt-4o-mini-realtime-preview";
528
+ readonly GPT_4O_MINI_REALTIME_PREVIEW_2024_12_17: "gpt-4o-mini-realtime-preview-2024-12-17";
529
+ readonly GPT_4O_SEARCH_PREVIEW: "gpt-4o-search-preview";
530
+ readonly GPT_4O_SEARCH_PREVIEW_2025_03_11: "gpt-4o-search-preview-2025-03-11";
531
+ readonly GPT_4O_MINI_SEARCH_PREVIEW: "gpt-4o-mini-search-preview";
532
+ readonly GPT_4O_MINI_SEARCH_PREVIEW_2025_03_11: "gpt-4o-mini-search-preview-2025-03-11";
533
+ readonly GPT_4O_TRANSCRIBE: "gpt-4o-transcribe";
534
+ readonly GPT_4O_MINI_TRANSCRIBE: "gpt-4o-mini-transcribe";
535
+ readonly GPT_4O_MINI_TTS: "gpt-4o-mini-tts";
536
+ readonly GPT_IMAGE_1: "gpt-image-1";
537
+ readonly GPT_IMAGE_1_MINI: "gpt-image-1-mini";
538
+ readonly O4_MINI: "o4-mini";
539
+ readonly O4_MINI_2025_04_16: "o4-mini-2025-04-16";
540
+ readonly O3: "o3";
541
+ readonly O3_PRO: "o3-pro";
542
+ readonly O3_MINI: "o3-mini";
543
+ readonly O3_MINI_2025_01_31: "o3-mini-2025-01-31";
544
+ readonly O1_PRO: "o1-pro";
545
+ readonly O1_PRO_2025_03_19: "o1-pro-2025-03-19";
546
+ readonly O1: "o1";
547
+ readonly O1_2024_12_17: "o1-2024-12-17";
548
+ readonly O1_MINI: "o1-mini";
549
+ readonly O1_MINI_2024_09_12: "o1-mini-2024-09-12";
550
+ readonly O1_PREVIEW: "o1-preview";
551
+ readonly O1_PREVIEW_2024_09_12: "o1-preview-2024-09-12";
552
+ readonly GPT_OSS_120B: "gpt-oss-120b";
553
+ readonly GPT_OSS_7B: "gpt-oss-7b";
554
+ readonly SORA_2: "sora-2";
555
+ readonly SORA_2025_05_02: "sora-2025-05-02";
556
+ readonly CODEX_MINI: "codex-mini";
557
+ readonly COMPUTER_USE_PREVIEW: "computer-use-preview";
558
+ };
559
+ declare const DEFAULT_MODEL: "gpt-5";
560
+
561
+ declare const NAME: "OpenAI";
562
+
563
+ declare const index_DEFAULT_MODEL: typeof DEFAULT_MODEL;
564
+ declare const index_Models: typeof Models;
565
+ declare const index_NAME: typeof NAME;
566
+ declare namespace index {
567
+ export {
568
+ index_DEFAULT_MODEL as DEFAULT_MODEL,
569
+ index_Models as Models,
570
+ index_NAME as NAME,
571
+ };
572
+ }
573
+
574
+ interface GenerateOptions {
575
+ temperature?: number;
576
+ top_p?: number;
577
+ max_tokens?: number;
578
+ frequency_penalty?: number;
579
+ presence_penalty?: number;
580
+ stop?: string | string[];
581
+ [key: string]: any;
582
+ }
583
+ interface GenerateProps {
584
+ provider: AIProvider;
585
+ messages: Array<AxleMessage>;
586
+ system?: string;
587
+ tools?: Array<ToolDefinition>;
588
+ recorder?: Recorder;
589
+ options?: GenerateOptions;
590
+ }
591
+ declare function generate(props: GenerateProps): Promise<ModelResult>;
592
+
593
+ interface StreamProps {
594
+ provider: AIProvider;
595
+ messages: Array<AxleMessage>;
596
+ system?: string;
597
+ tools?: Array<ToolDefinition>;
598
+ recorder?: Recorder;
599
+ options?: GenerateOptions;
600
+ }
601
+ interface StreamResult {
602
+ get final(): Promise<ModelResult>;
603
+ get current(): AxleAssistantMessage;
604
+ [Symbol.asyncIterator](): AsyncIterator<AnyStreamChunk>;
605
+ }
606
+ declare function stream(props: StreamProps): StreamResult;
607
+
608
+ declare enum ResultType {
320
609
  String = "string",
321
610
  List = "string[]",
322
611
  Number = "number",
323
612
  Boolean = "boolean"
324
613
  }
325
- type ResTypeStrings = `${ResTypes}`;
326
- type StringToType<S extends ResTypeStrings> = S extends ResTypes.String ? string : S extends ResTypes.List ? string[] : S extends ResTypes.Number ? number : S extends ResTypes.Boolean ? boolean : never;
327
- type StructuredOutput<T extends Record<string, ResTypeStrings>> = {
328
- [K in keyof T]: StringToType<T[K]>;
614
+ type ResultTypeUnion = `${ResultType}`;
615
+ type DeclarativeSchema = {
616
+ [key: string]: ResultTypeUnion | DeclarativeSchema | DeclarativeSchema[];
617
+ };
618
+ type OutputSchema = Record<string, z__default.ZodTypeAny>;
619
+ type InferedOutputSchema<T extends OutputSchema> = {
620
+ [K in keyof T]: z__default.output<T[K]>;
329
621
  };
330
622
 
331
- declare abstract class AbstractInstruct<O extends Record<string, ResTypeStrings>> implements Task {
623
+ declare abstract class AbstractInstruct<T extends OutputSchema> implements Task {
332
624
  readonly type = "instruct";
333
- protected _result: StructuredOutput<O> | undefined;
334
625
  prompt: string;
335
626
  system: string | null;
336
627
  inputs: Record<string, string>;
@@ -340,43 +631,29 @@ declare abstract class AbstractInstruct<O extends Record<string, ResTypeStrings>
340
631
  content: string;
341
632
  name?: string;
342
633
  }>;
343
- resFormat: O;
634
+ instructions: string[];
635
+ schema: T;
344
636
  rawResponse: string;
345
- finalPrompt: string;
346
- protected constructor(prompt: string, resFormat: O);
637
+ protected _taggedSections: {
638
+ tags: Record<string, string>;
639
+ remaining: string;
640
+ } | undefined;
641
+ protected _result: InferedOutputSchema<T> | undefined;
642
+ protected constructor(prompt: string, schema: T);
347
643
  setInputs(inputs: Record<string, string>): void;
348
644
  addInput(name: string, value: string): void;
349
645
  addTools(tools: ToolExecutable[]): void;
350
646
  addTool(tool: ToolExecutable): void;
351
- /**
352
- * Add an image file to the task.
353
- * Throws an error if the file type is not "image".
354
- * @param file - the Base64FileInfo representing the image file
355
- */
356
647
  addImage(file: FileInfo): void;
357
- /**
358
- * Add a document file to the task.
359
- * Throws an error if the file type is not "document".
360
- * @param file - the Base64FileInfo representing the document file
361
- */
362
648
  addDocument(file: FileInfo): void;
363
- /**
364
- * Add a file to the task. It can be an image or document file.
365
- * Throws an error if the file type is not supported.
366
- * @param file - the Base64FileInfo representing the document or image file
367
- */
368
649
  addFile(file: FileInfo): void;
369
- /**
370
- * Add a text reference to the task.
371
- * @param textFile - the TextFileInfo or string content of the reference
372
- * @param options - optional name for the reference
373
- */
374
650
  addReference(textFile: FileInfo | TextFileInfo | string, options?: {
375
651
  name?: string;
376
652
  }): void;
653
+ addInstructions(instruction: string): void;
377
654
  hasTools(): boolean;
378
655
  hasFiles(): boolean;
379
- get result(): StructuredOutput<O>;
656
+ get result(): InferedOutputSchema<T> | undefined;
380
657
  compile(variables: Record<string, string>, runtime?: {
381
658
  recorder?: Recorder;
382
659
  options?: {
@@ -386,57 +663,45 @@ declare abstract class AbstractInstruct<O extends Record<string, ResTypeStrings>
386
663
  message: string;
387
664
  instructions: string;
388
665
  };
389
- protected getFinalUserPrompt(variables: Record<string, string>, runtime?: {
666
+ protected createUserMessage(variables: Record<string, string>, runtime?: {
390
667
  recorder?: Recorder;
391
668
  options?: {
392
669
  warnUnused?: boolean;
393
670
  };
394
671
  }): string;
395
- protected getFormatInstructions(): string;
396
- /**
397
- *
398
- * @param rawValue - the raw value from the AI
399
- * @param taggedSections - optional, for overrides to use
400
- * @returns - the parsed result
401
- */
402
- finalize(rawValue: string, taggedSections?: {
403
- tags: Record<string, string>;
404
- remaining: string;
405
- }): StructuredOutput<O>;
672
+ protected createInstructions(instructions?: string): string;
673
+ protected generateFieldInstructions(key: string, schema: z.ZodTypeAny): string;
674
+ finalize(rawValue: string, runtime?: {
675
+ recorder?: Recorder;
676
+ }): InferedOutputSchema<T>;
677
+ private preprocessValue;
406
678
  protected parseTaggedSections(input: string): {
407
679
  tags: Record<string, string>;
408
680
  remaining: string;
409
681
  };
410
- protected typeResponses(typeString: ResTypeStrings, rawValue: string): StringToType<ResTypes>;
411
682
  }
412
683
 
413
- type DefaultResFormatType$1 = {
414
- response: ResTypes.String;
415
- };
416
- declare class Instruct<O extends Record<string, ResTypeStrings>> extends AbstractInstruct<O> {
417
- private constructor();
418
- static with<NewO extends Record<string, ResTypeStrings>>(prompt: string, resFormat: NewO): Instruct<NewO>;
419
- static with(prompt: string): Instruct<DefaultResFormatType$1>;
684
+ declare class Instruct<T extends OutputSchema> extends AbstractInstruct<T> {
685
+ constructor(prompt: string, schema: T);
686
+ static with<T extends OutputSchema>(prompt: string, schema: T): Instruct<T>;
687
+ static with<T extends DeclarativeSchema>(prompt: string, schema: T): Instruct<OutputSchema>;
688
+ static with(prompt: string): Instruct<{
689
+ response: z.ZodString;
690
+ }>;
420
691
  }
421
692
 
422
- type DefaultResFormatType = {
423
- response: ResTypes.String;
424
- };
425
- declare class ChainOfThought<O extends Record<string, ResTypeStrings>> extends AbstractInstruct<O> {
426
- private constructor();
427
- static with<NewO extends Record<string, ResTypeStrings>>(prompt: string, resFormat: NewO): ChainOfThought<NewO>;
428
- static with(prompt: string): ChainOfThought<DefaultResFormatType>;
429
- compile(variables: Record<string, string>, runtime?: {
693
+ declare class ChainOfThought<T extends OutputSchema> extends AbstractInstruct<T> {
694
+ constructor(prompt: string, schema: T);
695
+ static with<T extends OutputSchema>(prompt: string, schema: T): ChainOfThought<T>;
696
+ static with<T extends DeclarativeSchema>(prompt: string, schema: T): ChainOfThought<OutputSchema>;
697
+ static with(prompt: string): ChainOfThought<{
698
+ response: z.ZodString;
699
+ }>;
700
+ createInstructions(instructions?: string): string;
701
+ finalize(rawValue: string, runtime?: {
430
702
  recorder?: Recorder;
431
- options?: {
432
- warnUnused?: boolean;
433
- };
434
- }): {
435
- message: string;
436
- instructions: string;
437
- };
438
- finalize(rawValue: string): StructuredOutput<O> & {
439
- thinking: any;
703
+ }): InferedOutputSchema<T> & {
704
+ thinking: string;
440
705
  };
441
706
  }
442
707
 
@@ -485,7 +750,7 @@ interface ChatStep extends StepBase {
485
750
  uses: "chat";
486
751
  system?: string;
487
752
  message: string;
488
- output?: Record<string, ResTypeStrings>;
753
+ output?: Record<string, ResultTypeUnion>;
489
754
  replace?: Replace[];
490
755
  tools?: string[];
491
756
  images?: ImageReference[];
@@ -495,7 +760,7 @@ interface ChatStep extends StepBase {
495
760
  interface WriteToDiskStep extends StepBase {
496
761
  uses: "write-to-disk";
497
762
  output: string;
498
- keys: string | string[];
763
+ keys?: string | string[];
499
764
  }
500
765
  interface Replace {
501
766
  source: "file";
@@ -529,4 +794,25 @@ interface SerialWorkflow {
529
794
  }
530
795
  declare const serialWorkflow: SerialWorkflow;
531
796
 
532
- export { type AIProvider, Axle, ChainOfThought, type DAGDefinition, type DAGWorkflowOptions, type FileInfo, Instruct, LogLevel, type SerializedExecutionResponse, WriteOutputTask, concurrentWorkflow, dagWorkflow, serialWorkflow };
797
+ declare class ConsoleWriter implements RecorderWriter {
798
+ private tasks;
799
+ private entries;
800
+ private truncate;
801
+ private intervalId;
802
+ private spinnerInterval;
803
+ private lastRender;
804
+ private isRendering;
805
+ private inline;
806
+ constructor(options?: {
807
+ truncate?: number;
808
+ inline?: boolean;
809
+ });
810
+ private startSpinner;
811
+ private stopSpinner;
812
+ private renderTasks;
813
+ handleEvent(event: RecorderEntry): void;
814
+ destroy(): void;
815
+ }
816
+
817
+ export { index$3 as Anthropic, Axle, ChainOfThought, ConsoleWriter, index$2 as Gemini, Instruct, LogLevel, index$1 as Ollama, index as OpenAI, WriteOutputTask, concurrentWorkflow, dagWorkflow, generate, serialWorkflow, stream };
818
+ export type { AIProvider, DAGDefinition, DAGWorkflowOptions, FileInfo, SerializedExecutionResponse };