@fifthrevision/axle 0.6.5 → 0.7.0

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,208 +1,13 @@
1
1
  import * as z from 'zod';
2
- import z__default, { ZodObject, z as z$1 } from 'zod';
3
- import Anthropic from '@anthropic-ai/sdk';
4
- import { GoogleGenAI } from '@google/genai';
5
- import OpenAI from 'openai';
2
+ import { ZodObject, z as z$1 } from 'zod';
6
3
 
7
- type PlainObject = Record<string, unknown>;
8
- type ProgramOptions = {
9
- dryRun?: boolean;
10
- config?: string;
11
- warnUnused?: boolean;
12
- job?: string;
13
- log?: boolean;
14
- debug?: boolean;
15
- args?: string[];
16
- };
17
4
  interface Stats {
18
5
  in: number;
19
6
  out: number;
20
7
  }
21
8
 
22
- interface RecorderLevelFunctions {
23
- log: (...message: (string | unknown | Error)[]) => void;
24
- heading: {
25
- log: (...message: (string | unknown | Error)[]) => void;
26
- };
27
- }
28
- type RecorderEntry = {
29
- level: LogLevel;
30
- time: number;
31
- kind: VisualLevel;
32
- payload: PlainObject[];
33
- };
34
- type VisualLevel = "heading" | "body";
35
- declare enum LogLevel {
36
- Trace = 10,
37
- Debug = 20,
38
- Info = 30,
39
- Warn = 40,
40
- Error = 50,
41
- Fatal = 60
42
- }
43
- interface RecorderWriter {
44
- handleEvent(event: RecorderEntry): void | Promise<void>;
45
- flush?(): Promise<void>;
46
- }
47
-
48
- declare class Recorder {
49
- instanceId: `${string}-${string}-${string}-${string}-${string}`;
50
- private currentLevel;
51
- private logs;
52
- private writers;
53
- private _debug;
54
- private _info;
55
- private _warn;
56
- private _error;
57
- constructor();
58
- buildMethods(): void;
59
- set level(level: LogLevel);
60
- get level(): LogLevel;
61
- get info(): RecorderLevelFunctions;
62
- get warn(): RecorderLevelFunctions;
63
- get error(): RecorderLevelFunctions;
64
- get debug(): RecorderLevelFunctions;
65
- subscribe(writer: RecorderWriter): void;
66
- unsubscribe(writer: RecorderWriter): void;
67
- private publish;
68
- private logFunction;
69
- private createLoggingFunction;
70
- getLogs(level?: LogLevel): RecorderEntry[];
71
- /**
72
- * Ensures all writers have completed their pending operations
73
- * Call this before exiting the process to ensure logs are written
74
- */
75
- shutdown(): Promise<void>;
76
- }
77
-
78
- interface Tool<TSchema extends ZodObject<any> = ZodObject<any>> {
79
- name: string;
80
- description: string;
81
- schema: TSchema;
82
- execute(input: z$1.infer<TSchema>): Promise<string>;
83
- configure?(config: Record<string, any>): void;
84
- }
85
- type ToolDefinition = Pick<Tool, "name" | "description" | "schema">;
86
-
87
- interface FileInfo {
88
- path: string;
89
- base64?: string;
90
- content?: string;
91
- mimeType: string;
92
- size: number;
93
- name: string;
94
- type: "image" | "document" | "text";
95
- }
96
- type TextFileInfo = FileInfo & {
97
- content: string;
98
- base64?: never;
99
- type: "text";
100
- };
101
- type Base64FileInfo = FileInfo & {
102
- base64: string;
103
- content?: never;
104
- type: "image" | "document";
105
- };
106
-
107
- declare enum ResultType {
108
- String = "string",
109
- List = "string[]",
110
- Number = "number",
111
- Boolean = "boolean"
112
- }
113
- type ResultTypeUnion = `${ResultType}`;
114
- type DeclarativeSchema = {
115
- [key: string]: ResultTypeUnion | DeclarativeSchema | DeclarativeSchema[];
116
- };
117
- type OutputSchema = Record<string, z__default.ZodTypeAny>;
118
- type InferedOutputSchema<T extends OutputSchema> = {
119
- [K in keyof T]: z__default.output<T[K]>;
120
- };
121
-
122
- declare abstract class AbstractInstruct<T extends OutputSchema> {
123
- readonly name = "instruct";
124
- prompt: string;
125
- system: string | null;
126
- inputs: Record<string, string>;
127
- tools: Record<string, Tool>;
128
- files: Base64FileInfo[];
129
- textReferences: Array<{
130
- content: string;
131
- name?: string;
132
- }>;
133
- instructions: string[];
134
- schema: T;
135
- rawResponse: string;
136
- protected _taggedSections: {
137
- tags: Record<string, string>;
138
- remaining: string;
139
- } | undefined;
140
- protected _result: InferedOutputSchema<T> | undefined;
141
- protected constructor(prompt: string, schema: T);
142
- setInputs(inputs: Record<string, string>): void;
143
- addInput(name: string, value: string): void;
144
- addTools(tools: Tool[]): void;
145
- addTool(tool: Tool): void;
146
- addImage(file: FileInfo): void;
147
- addDocument(file: FileInfo): void;
148
- addFile(file: FileInfo): void;
149
- addReference(textFile: FileInfo | TextFileInfo | string, options?: {
150
- name?: string;
151
- }): void;
152
- addInstructions(instruction: string): void;
153
- hasTools(): boolean;
154
- hasFiles(): boolean;
155
- get result(): InferedOutputSchema<T> | undefined;
156
- compile(variables: Record<string, string>, runtime?: {
157
- recorder?: Recorder;
158
- options?: {
159
- warnUnused?: boolean;
160
- };
161
- }): {
162
- message: string;
163
- instructions: string;
164
- };
165
- protected createUserMessage(variables: Record<string, string>, runtime?: {
166
- recorder?: Recorder;
167
- options?: {
168
- warnUnused?: boolean;
169
- };
170
- }): string;
171
- protected createInstructions(instructions?: string): string;
172
- protected generateFieldInstructions(key: string, schema: z.ZodTypeAny): string;
173
- finalize(rawValue: string, runtime?: {
174
- recorder?: Recorder;
175
- }): InferedOutputSchema<T>;
176
- private preprocessValue;
177
- protected parseTaggedSections(input: string): {
178
- tags: Record<string, string>;
179
- remaining: string;
180
- };
181
- }
182
-
183
- declare class Instruct<T extends OutputSchema> extends AbstractInstruct<T> {
184
- constructor(prompt: string, schema: T);
185
- static with<T extends OutputSchema>(prompt: string, schema: T): Instruct<T>;
186
- static with<T extends DeclarativeSchema>(prompt: string, schema: T): Instruct<OutputSchema>;
187
- static with(prompt: string): Instruct<{
188
- response: z.ZodString;
189
- }>;
190
- }
191
-
192
- interface ActionContext {
193
- input: string;
194
- variables: Record<string, any>;
195
- options?: ProgramOptions;
196
- recorder?: Recorder;
197
- }
198
- interface Action {
199
- name: string;
200
- execute(context: ActionContext): Promise<string | void>;
201
- }
202
- type WorkflowStep = Instruct<any> | Action;
203
-
204
9
  interface StreamChunk {
205
- type: "start" | "text" | "tool-call-start" | "tool-call-delta" | "tool-call-complete" | "thinking-start" | "thinking-delta" | "complete" | "error";
10
+ type: "start" | "text-start" | "text-delta" | "text-complete" | "tool-call-start" | "tool-call-complete" | "thinking-start" | "thinking-delta" | "thinking-summary-delta" | "thinking-complete" | "internal-tool-start" | "internal-tool-complete" | "complete" | "error";
206
11
  id?: string;
207
12
  data?: any;
208
13
  }
@@ -221,10 +26,31 @@ interface StreamCompleteChunk extends StreamChunk {
221
26
  usage: Stats;
222
27
  };
223
28
  }
224
- interface StreamTextChunk extends StreamChunk {
225
- type: "text";
29
+ interface StreamErrorChunk extends StreamChunk {
30
+ type: "error";
31
+ data: {
32
+ type: string;
33
+ message: string;
34
+ usage?: Stats;
35
+ raw?: any;
36
+ };
37
+ }
38
+ interface StreamTextStartChunk extends StreamChunk {
39
+ type: "text-start";
40
+ data: {
41
+ index: number;
42
+ };
43
+ }
44
+ interface StreamTextDeltaChunk extends StreamChunk {
45
+ type: "text-delta";
226
46
  data: {
47
+ index: number;
227
48
  text: string;
49
+ };
50
+ }
51
+ interface StreamTextCompleteChunk extends StreamChunk {
52
+ type: "text-complete";
53
+ data: {
228
54
  index: number;
229
55
  };
230
56
  }
@@ -232,7 +58,9 @@ interface StreamThinkingStartChunk extends StreamChunk {
232
58
  type: "thinking-start";
233
59
  data: {
234
60
  index: number;
61
+ id?: string;
235
62
  redacted?: boolean;
63
+ signature?: string;
236
64
  };
237
65
  }
238
66
  interface StreamThinkingDeltaChunk extends StreamChunk {
@@ -242,6 +70,19 @@ interface StreamThinkingDeltaChunk extends StreamChunk {
242
70
  text: string;
243
71
  };
244
72
  }
73
+ interface StreamThinkingSummaryDeltaChunk extends StreamChunk {
74
+ type: "thinking-summary-delta";
75
+ data: {
76
+ index: number;
77
+ text: string;
78
+ };
79
+ }
80
+ interface StreamThinkingCompleteChunk extends StreamChunk {
81
+ type: "thinking-complete";
82
+ data: {
83
+ index: number;
84
+ };
85
+ }
245
86
  interface StreamToolCallStartChunk extends StreamChunk {
246
87
  type: "tool-call-start";
247
88
  data: {
@@ -259,93 +100,126 @@ interface StreamToolCallCompleteChunk extends StreamChunk {
259
100
  arguments: any;
260
101
  };
261
102
  }
262
- interface StreamErrorChunk extends StreamChunk {
263
- type: "error";
103
+ interface StreamInternalToolStartChunk extends StreamChunk {
104
+ type: "internal-tool-start";
264
105
  data: {
265
- type: string;
266
- message: string;
267
- usage?: Stats;
268
- raw?: any;
106
+ index: number;
107
+ id: string;
108
+ name: string;
269
109
  };
270
110
  }
271
- type AnyStreamChunk = StreamStartChunk | StreamCompleteChunk | StreamTextChunk | StreamToolCallStartChunk | StreamToolCallCompleteChunk | StreamThinkingStartChunk | StreamThinkingDeltaChunk | StreamErrorChunk;
272
-
273
- type AxleMessage = AxleUserMessage | AxleAssistantMessage | AxleToolCallMessage;
274
- interface AxleUserMessage {
275
- role: "user";
276
- name?: string;
277
- content: string | Array<ContentPart>;
278
- }
279
- interface AxleAssistantMessage {
280
- role: "assistant";
281
- id: string;
282
- model?: string;
283
- content: Array<ContentPartText | ContentPartThinking | ContentPartToolCall>;
284
- finishReason?: AxleStopReason;
111
+ interface StreamInternalToolCompleteChunk extends StreamChunk {
112
+ type: "internal-tool-complete";
113
+ data: {
114
+ index: number;
115
+ id: string;
116
+ name: string;
117
+ output?: unknown;
118
+ };
285
119
  }
286
- interface AxleToolCallMessage {
287
- role: "tool";
288
- content: Array<AxleToolCallResult>;
120
+ type AnyStreamChunk = StreamStartChunk | StreamCompleteChunk | StreamErrorChunk | StreamTextStartChunk | StreamTextDeltaChunk | StreamTextCompleteChunk | StreamThinkingStartChunk | StreamThinkingDeltaChunk | StreamThinkingSummaryDeltaChunk | StreamThinkingCompleteChunk | StreamToolCallStartChunk | StreamToolCallCompleteChunk | StreamInternalToolStartChunk | StreamInternalToolCompleteChunk;
121
+
122
+ interface Tool<TSchema extends ZodObject<any> = ZodObject<any>> {
123
+ name: string;
124
+ description: string;
125
+ schema: TSchema;
126
+ execute(input: z$1.infer<TSchema>): Promise<string>;
127
+ configure?(config: Record<string, any>): void;
128
+ summarize?(input: z$1.infer<TSchema>): string;
289
129
  }
290
- interface AxleToolCallResult {
291
- id: string;
130
+ type ToolDefinition = Pick<Tool, "name" | "description" | "schema">;
131
+
132
+ type SpanStatus = "ok" | "error";
133
+ type EventLevel = "debug" | "info" | "warn" | "error";
134
+ type SpanType = string;
135
+ interface SpanEvent {
292
136
  name: string;
293
- content: string;
137
+ timestamp: number;
138
+ level: EventLevel;
139
+ attributes?: Record<string, unknown>;
140
+ }
141
+ interface SpanData {
142
+ traceId: string;
143
+ spanId: string;
144
+ parentSpanId?: string;
145
+ name: string;
146
+ type?: SpanType;
147
+ startTime: number;
148
+ endTime?: number;
149
+ status: SpanStatus;
150
+ attributes: Record<string, unknown>;
151
+ events: SpanEvent[];
152
+ result?: SpanResult;
153
+ }
154
+ interface SpanOptions {
155
+ type?: SpanType;
156
+ }
157
+ type SpanResult = LLMResult | ToolResult;
158
+ interface LLMResult {
159
+ kind: "llm";
160
+ model: string;
161
+ request: LLMRequest;
162
+ response: LLMResponse;
163
+ usage?: TokenUsage;
164
+ finishReason?: string;
294
165
  }
295
- type ContentPart = ContentPartText | ContentPartFile | ContentPartToolCall | ContentPartThinking;
296
- interface ContentPartText {
297
- type: "text";
298
- text: string;
166
+ interface LLMRequest {
167
+ messages: unknown[];
168
+ system?: string;
169
+ tools?: unknown[];
299
170
  }
300
- interface ContentPartFile {
301
- type: "file";
302
- file: FileInfo;
171
+ interface LLMResponse {
172
+ content: unknown;
303
173
  }
304
- interface ContentPartThinking {
305
- type: "thinking";
306
- text: string;
307
- redacted?: boolean;
308
- encrypted?: string;
309
- signature?: string;
174
+ interface TokenUsage {
175
+ inputTokens?: number;
176
+ outputTokens?: number;
177
+ totalTokens?: number;
310
178
  }
311
- interface ContentPartToolCall {
312
- type: "tool-call";
313
- id: string;
179
+ interface ToolResult {
180
+ kind: "tool";
314
181
  name: string;
315
- parameters: Record<string, unknown>;
182
+ input: unknown;
183
+ output: unknown;
184
+ }
185
+ interface TraceWriter {
186
+ onSpanStart(span: SpanData): void;
187
+ onSpanUpdate?(span: SpanData): void;
188
+ onSpanEnd(span: SpanData): void;
189
+ onEvent?(span: SpanData, event: SpanEvent): void;
190
+ onLLMStreamStart?(span: SpanData): void;
191
+ onLLMStreamChunk?(span: SpanData, chunk: string): void;
192
+ onLLMStreamEnd?(span: SpanData, result: LLMResult): void;
193
+ flush?(): Promise<void>;
316
194
  }
317
-
318
- type OllamaProviderConfig = {
319
- url?: string;
320
- model: string;
321
- };
322
- type AnthropicProviderConfig = {
323
- "api-key": string;
324
- model?: string;
325
- };
326
- type OpenAIProviderConfig = {
327
- "api-key": string;
328
- model?: string;
329
- };
330
- type GeminiProviderConfig = {
331
- "api-key": string;
332
- model?: string;
333
- };
334
- interface AIProviderConfig {
335
- ollama: OllamaProviderConfig;
336
- anthropic: AnthropicProviderConfig;
337
- openai: OpenAIProviderConfig;
338
- gemini: GeminiProviderConfig;
195
+ /**
196
+ * Tracing context for a span. Created by Tracer.startSpan().
197
+ * Can create child spans and log events within the span's scope.
198
+ */
199
+ interface TracingContext {
200
+ startSpan(name: string, options?: SpanOptions): TracingContext;
201
+ end(status?: SpanStatus): void;
202
+ debug(message: string, attributes?: Record<string, unknown>): void;
203
+ info(message: string, attributes?: Record<string, unknown>): void;
204
+ warn(message: string, attributes?: Record<string, unknown>): void;
205
+ error(message: string, attributes?: Record<string, unknown>): void;
206
+ setAttribute(key: string, value: unknown): void;
207
+ setAttributes(attributes: Record<string, unknown>): void;
208
+ setResult(result: SpanResult): void;
209
+ startLLMStream(): void;
210
+ appendLLMStream(chunk: string): void;
211
+ endLLMStream(result: LLMResult): void;
339
212
  }
213
+
340
214
  interface AIProvider {
341
215
  get name(): string;
342
- get model(): string;
343
- createGenerationRequest(params: {
216
+ /** @internal */
217
+ createGenerationRequest(model: string, params: {
344
218
  messages: Array<AxleMessage>;
345
219
  system?: string;
346
220
  tools?: Array<ToolDefinition>;
347
221
  context: {
348
- recorder?: Recorder;
222
+ tracer?: TracingContext;
349
223
  };
350
224
  options?: {
351
225
  temperature?: number;
@@ -357,13 +231,15 @@ interface AIProvider {
357
231
  [key: string]: any;
358
232
  };
359
233
  }): Promise<ModelResult>;
360
- createStreamingRequest?(params: {
234
+ /** @internal */
235
+ createStreamingRequest?(model: string, params: {
361
236
  messages: Array<AxleMessage>;
362
237
  system?: string;
363
238
  tools?: Array<ToolDefinition>;
364
239
  context: {
365
- recorder?: Recorder;
240
+ tracer?: TracingContext;
366
241
  };
242
+ signal?: AbortSignal;
367
243
  options?: {
368
244
  temperature?: number;
369
245
  top_p?: number;
@@ -397,367 +273,114 @@ interface ModelError {
397
273
  }
398
274
  type ModelResult = ModelResponse | ModelError;
399
275
  declare enum AxleStopReason {
400
- Stop = 0,
401
- Length = 1,
402
- FunctionCall = 2,
403
- Error = 3,
404
- Custom = 4
405
- }
406
-
407
- declare class AxleError extends Error {
408
- readonly code: string;
409
- readonly id?: string;
410
- readonly details?: Record<string, any>;
411
- constructor(message: string, options?: {
412
- code?: string;
413
- id?: string;
414
- details?: Record<string, any>;
415
- cause?: Error;
416
- });
276
+ Stop = "stop",
277
+ Length = "length",
278
+ FunctionCall = "function_call",
279
+ Error = "error",
280
+ Custom = "custom",
281
+ Cancelled = "cancelled"
417
282
  }
418
283
 
419
- interface Planner {
420
- plan(steps: WorkflowStep[]): Promise<Run[]>;
284
+ interface FileInfo {
285
+ path: string;
286
+ base64?: string;
287
+ content?: string;
288
+ mimeType: string;
289
+ size: number;
290
+ name: string;
291
+ type: "image" | "document" | "text";
421
292
  }
293
+ type TextFileInfo = FileInfo & {
294
+ content: string;
295
+ base64?: never;
296
+ type: "text";
297
+ };
298
+ type Base64FileInfo = FileInfo & {
299
+ base64: string;
300
+ content?: never;
301
+ type: "image" | "document";
302
+ };
303
+ /**
304
+ * Load a file with the specified encoding or auto-detect based on file extension
305
+ * @param filePath - Path to the file
306
+ * @param encoding - How to load the file: "utf-8" for text, "base64" for binary, or omit for auto-detection
307
+ * @returns FileInfo object with appropriate content based on encoding
308
+ */
309
+ declare function loadFileContent(filePath: string): Promise<FileInfo>;
310
+ declare function loadFileContent(filePath: string, encoding: "utf-8"): Promise<TextFileInfo>;
311
+ declare function loadFileContent(filePath: string, encoding: "base64"): Promise<Base64FileInfo>;
422
312
 
423
- interface Run {
424
- steps: WorkflowStep[];
425
- variables: Record<string, any>;
426
- }
427
- interface SerializedExecutionResponse {
428
- response: string;
429
- stats: Stats;
430
- }
431
- interface WorkflowResult<T = any> {
432
- response: T;
433
- stats?: Stats;
434
- error?: AxleError;
435
- success: boolean;
436
- }
437
- interface WorkflowExecutable {
438
- execute: (context: {
439
- provider: AIProvider;
440
- variables: Record<string, any>;
441
- options?: ProgramOptions;
442
- stats?: Stats;
443
- recorder?: Recorder;
444
- name?: string;
445
- }) => Promise<WorkflowResult>;
446
- }
447
- interface DAGNodeDefinition {
448
- step: WorkflowStep | WorkflowStep[];
449
- dependsOn?: string | string[];
450
- }
451
- interface DAGConcurrentNodeDefinition {
452
- planner: Planner;
453
- steps: WorkflowStep[];
454
- dependsOn?: string | string[];
455
- }
456
- interface DAGDefinition {
457
- [nodeName: string]: WorkflowStep | WorkflowStep[] | DAGNodeDefinition | DAGConcurrentNodeDefinition;
313
+ type AxleMessage = AxleUserMessage | AxleAssistantMessage | AxleToolCallMessage;
314
+ interface AxleUserMessage {
315
+ role: "user";
316
+ name?: string;
317
+ content: string | Array<ContentPart>;
458
318
  }
459
- interface DAGWorkflowOptions {
460
- continueOnError?: boolean;
461
- maxConcurrency?: number;
319
+ interface AxleAssistantMessage {
320
+ role: "assistant";
321
+ id: string;
322
+ model?: string;
323
+ content: Array<ContentPartText | ContentPartThinking | ContentPartToolCall | ContentPartInternalTool>;
324
+ finishReason?: AxleStopReason;
462
325
  }
463
-
464
- declare class Axle {
465
- provider: AIProvider;
466
- private stats;
467
- private variables;
468
- recorder: Recorder;
469
- constructor(config: Partial<AIProviderConfig>);
470
- addWriter(writer: RecorderWriter): void;
471
- /**
472
- * The execute function takes in a list of Tasks
473
- * @param steps
474
- * @returns
475
- */
476
- execute(...steps: WorkflowStep[]): Promise<WorkflowResult>;
477
- /**
478
- * Execute a DAG workflow
479
- * @param dagDefinition - The DAG definition object
480
- * @param variables - Additional variables to pass to the workflow
481
- * @param options - DAG execution options
482
- * @returns Promise<WorkflowResult>
483
- */
484
- executeDAG(dagDefinition: DAGDefinition, variables?: Record<string, any>, options?: DAGWorkflowOptions): Promise<WorkflowResult>;
485
- get logs(): RecorderEntry[];
486
- /**
487
- * Load a file with the specified encoding or auto-detect based on file extension
488
- * @param filePath - Path to the file
489
- * @param encoding - How to load the file: "utf-8" for text, "base64" for binary, or omit for auto-detection
490
- * @returns FileInfo object with appropriate content based on encoding
491
- */
492
- static loadFileContent(filePath: string): Promise<FileInfo>;
493
- static loadFileContent(filePath: string, encoding: "utf-8"): Promise<TextFileInfo>;
494
- static loadFileContent(filePath: string, encoding: "base64"): Promise<Base64FileInfo>;
326
+ interface AxleToolCallMessage {
327
+ role: "tool";
328
+ content: Array<AxleToolCallResult>;
495
329
  }
496
-
497
- declare class ChainOfThought<T extends OutputSchema> extends AbstractInstruct<T> {
498
- constructor(prompt: string, schema: T);
499
- static with<T extends OutputSchema>(prompt: string, schema: T): ChainOfThought<T>;
500
- static with<T extends DeclarativeSchema>(prompt: string, schema: T): ChainOfThought<OutputSchema>;
501
- static with(prompt: string): ChainOfThought<{
502
- response: z.ZodString;
503
- }>;
504
- createInstructions(instructions?: string): string;
505
- finalize(rawValue: string, runtime?: {
506
- recorder?: Recorder;
507
- }): InferedOutputSchema<T> & {
508
- thinking: string;
509
- };
330
+ interface AxleToolCallResult {
331
+ id: string;
332
+ name: string;
333
+ content: string;
510
334
  }
511
-
512
- declare const Models$2: {
513
- readonly CLAUDE_SONNET_4_5_20250929: "claude-sonnet-4-5-20250929";
514
- readonly CLAUDE_SONNET_4_5_LATEST: "claude-sonnet-4-5";
515
- readonly CLAUDE_HAIKU_4_5: "claude-haiku-4-5";
516
- readonly CLAUDE_OPUS_4_1_20250805: "claude-opus-4-1-20250805";
517
- readonly CLAUDE_OPUS_4_1_LATEST: "claude-opus-4-1";
518
- readonly CLAUDE_OPUS_4_20250514: "claude-opus-4-20250514";
519
- readonly CLAUDE_OPUS_4_LATEST: "claude-opus-4-0";
520
- readonly CLAUDE_SONNET_4_20250514: "claude-sonnet-4-20250514";
521
- readonly CLAUDE_SONNET_4_LATEST: "claude-sonnet-4-0";
522
- readonly CLAUDE_3_7_SONNET_20250219: "claude-3-7-sonnet-20250219";
523
- readonly CLAUDE_3_7_SONNET_LATEST: "claude-3-7-sonnet-latest";
524
- readonly CLAUDE_3_5_SONNET_20241022: "claude-3-5-sonnet-20241022";
525
- readonly CLAUDE_3_5_HAIKU_20241022: "claude-3-5-haiku-20241022";
526
- readonly CLAUDE_3_5_HAIKU_LATEST: "claude-3-5-haiku-latest";
527
- readonly CLAUDE_3_5_SONNET_20240620: "claude-3-5-sonnet-20240620";
528
- };
529
- declare const DEFAULT_MODEL$2: "claude-haiku-4-5";
530
-
531
- declare const NAME$3: "anthropic";
532
- declare class AnthropicProvider implements AIProvider {
533
- name: "anthropic";
534
- client: Anthropic;
535
- model: string;
536
- constructor(apiKey: string, model?: string);
537
- createGenerationRequest(params: {
538
- messages: Array<AxleMessage>;
539
- system?: string;
540
- tools?: Array<ToolDefinition>;
541
- context: {
542
- recorder?: Recorder;
543
- };
544
- options?: {
545
- temperature?: number;
546
- top_p?: number;
547
- max_tokens?: number;
548
- frequency_penalty?: number;
549
- presence_penalty?: number;
550
- stop?: string | string[];
551
- [key: string]: any;
552
- };
553
- }): Promise<ModelResult>;
554
- createStreamingRequest(params: {
555
- messages: Array<AxleMessage>;
556
- system?: string;
557
- tools?: Array<ToolDefinition>;
558
- context: {
559
- recorder?: Recorder;
560
- };
561
- options?: {
562
- temperature?: number;
563
- top_p?: number;
564
- max_tokens?: number;
565
- frequency_penalty?: number;
566
- presence_penalty?: number;
567
- stop?: string | string[];
568
- [key: string]: any;
569
- };
570
- }): AsyncGenerator<AnyStreamChunk, void, unknown>;
335
+ type ContentPart = ContentPartText | ContentPartFile | ContentPartToolCall | ContentPartThinking | ContentPartInternalTool;
336
+ interface ContentPartText {
337
+ type: "text";
338
+ text: string;
571
339
  }
572
-
573
- declare namespace index$3 {
574
- export {
575
- DEFAULT_MODEL$2 as DEFAULT_MODEL,
576
- Models$2 as Models,
577
- NAME$3 as NAME,
578
- AnthropicProvider as Provider,
579
- };
340
+ interface ContentPartFile {
341
+ type: "file";
342
+ file: FileInfo;
580
343
  }
581
-
582
- declare const Models$1: {
583
- readonly GEMINI_2_5_PRO: "gemini-2.5-pro";
584
- readonly GEMINI_2_5_FLASH: "gemini-2.5-flash";
585
- readonly GEMINI_2_5_FLASH_PREVIEW_05_20: "gemini-2.5-flash-preview-05-20";
586
- readonly GEMINI_2_5_FLASH_LITE: "gemini-2.5-flash-lite";
587
- readonly GEMINI_2_5_FLASH_LITE_PREVIEW_06_17: "gemini-2.5-flash-lite-preview-06-17";
588
- readonly GEMINI_2_5_FLASH_LIVE_PREVIEW: "gemini-live-2.5-flash-preview";
589
- readonly GEMINI_2_5_FLASH_PREVIEW_NATIVE_AUDIO_DIALOG: "gemini-2.5-flash-preview-native-audio-dialog";
590
- readonly GEMINI_2_5_FLASH_EXP_NATIVE_AUDIO_THINKING_DIALOG: "gemini-2.5-flash-exp-native-audio-thinking-dialog";
591
- readonly GEMINI_2_5_FLASH_IMAGE_PREVIEW: "gemini-2.5-flash-image-preview";
592
- readonly GEMINI_2_5_FLASH_PREVIEW_TTS: "gemini-2.5-flash-preview-tts";
593
- readonly GEMINI_2_5_PRO_PREVIEW_TTS: "gemini-2.5-pro-preview-tts";
594
- readonly GEMINI_2_0_FLASH: "gemini-2.0-flash";
595
- readonly GEMINI_2_0_FLASH_001: "gemini-2.0-flash-001";
596
- readonly GEMINI_2_0_FLASH_EXP: "gemini-2.0-flash-exp";
597
- readonly GEMINI_2_0_FLASH_PREVIEW_IMAGE_GENERATION: "gemini-2.0-flash-preview-image-generation";
598
- readonly GEMINI_2_0_FLASH_LITE: "gemini-2.0-flash-lite";
599
- readonly GEMINI_2_0_FLASH_LITE_001: "gemini-2.0-flash-lite-001";
600
- readonly GEMINI_2_0_FLASH_LIVE_001: "gemini-2.0-flash-live-001";
601
- readonly GEMINI_1_5_PRO: "gemini-1.5-pro";
602
- readonly GEMINI_1_5_PRO_LATEST: "gemini-1.5-pro-latest";
603
- readonly GEMINI_1_5_PRO_001: "gemini-1.5-pro-001";
604
- readonly GEMINI_1_5_PRO_002: "gemini-1.5-pro-002";
605
- readonly GEMINI_1_5_FLASH: "gemini-1.5-flash";
606
- readonly GEMINI_1_5_FLASH_LATEST: "gemini-1.5-flash-latest";
607
- readonly GEMINI_1_5_FLASH_001: "gemini-1.5-flash-001";
608
- readonly GEMINI_1_5_FLASH_002: "gemini-1.5-flash-002";
609
- readonly GEMINI_1_5_FLASH_8B: "gemini-1.5-flash-8b";
610
- readonly GEMINI_1_5_FLASH_8B_LATEST: "gemini-1.5-flash-8b-latest";
611
- readonly GEMINI_1_5_FLASH_8B_001: "gemini-1.5-flash-8b-001";
612
- readonly GEMMA_3N_E4B_IT: "gemma-3n-e4b-it";
613
- readonly GEMMA_3_1B_IT: "gemma-3-1b-it";
614
- readonly GEMMA_3_4B_IT: "gemma-3-4b-it";
615
- readonly GEMMA_3_12B_IT: "gemma-3-12b-it";
616
- readonly GEMMA_3_27B_IT: "gemma-3-27b-it";
617
- readonly LEARNLM_2_0_FLASH_EXPERIMENTAL: "learnlm-2.0-flash-experimental";
618
- readonly EMBEDDING_001: "embedding-001";
619
- readonly TEXT_EMBEDDING_004: "text-embedding-004";
620
- };
621
- declare const DEFAULT_MODEL$1: "gemini-2.5-flash";
622
-
623
- declare const NAME$2: "Gemini";
624
- declare class GeminiProvider implements AIProvider {
625
- name: "Gemini";
626
- client: GoogleGenAI;
627
- model: string;
628
- constructor(apiKey: string, model?: string);
629
- createGenerationRequest(params: {
630
- messages: Array<AxleMessage>;
631
- system?: string;
632
- tools?: Array<ToolDefinition>;
633
- context: {
634
- recorder?: Recorder;
635
- };
636
- options?: {
637
- temperature?: number;
638
- top_p?: number;
639
- max_tokens?: number;
640
- frequency_penalty?: number;
641
- presence_penalty?: number;
642
- stop?: string | string[];
643
- [key: string]: any;
644
- };
645
- }): Promise<ModelResult>;
646
- createStreamingRequest(params: {
647
- messages: Array<AxleMessage>;
648
- system?: string;
649
- tools?: Array<ToolDefinition>;
650
- context: {
651
- recorder?: Recorder;
652
- };
653
- options?: {
654
- temperature?: number;
655
- top_p?: number;
656
- max_tokens?: number;
657
- frequency_penalty?: number;
658
- presence_penalty?: number;
659
- stop?: string | string[];
660
- [key: string]: any;
661
- };
662
- }): AsyncGenerator<AnyStreamChunk, void, unknown>;
344
+ interface ContentPartThinking {
345
+ type: "thinking";
346
+ id?: string;
347
+ text: string;
348
+ summary?: string;
349
+ redacted?: boolean;
350
+ encrypted?: string;
351
+ signature?: string;
663
352
  }
664
-
665
- declare namespace index$2 {
666
- export {
667
- DEFAULT_MODEL$1 as DEFAULT_MODEL,
668
- Models$1 as Models,
669
- NAME$2 as NAME,
670
- GeminiProvider as Provider,
671
- };
353
+ interface ContentPartToolCall {
354
+ type: "tool-call";
355
+ id: string;
356
+ name: string;
357
+ parameters: Record<string, unknown>;
672
358
  }
673
-
674
- declare const DEFAULT_OLLAMA_URL = "http://localhost:11434";
675
- declare const NAME$1: "Ollama";
676
- declare class OllamaProvider implements AIProvider {
359
+ interface ContentPartInternalTool {
360
+ type: "internal-tool";
361
+ id: string;
677
362
  name: string;
678
- url: string;
679
- model: string;
680
- recorder?: Recorder;
681
- constructor(model: string, url?: string);
682
- createGenerationRequest(params: {
683
- messages: Array<AxleMessage>;
684
- system?: string;
685
- tools?: Array<ToolDefinition>;
686
- context: {
687
- recorder?: Recorder;
688
- };
689
- options?: {
690
- temperature?: number;
691
- top_p?: number;
692
- max_tokens?: number;
693
- frequency_penalty?: number;
694
- presence_penalty?: number;
695
- stop?: string | string[];
696
- [key: string]: any;
697
- };
698
- }): Promise<ModelResult>;
699
- createStreamingRequest(params: {
700
- messages: Array<AxleMessage>;
701
- system?: string;
702
- tools?: Array<ToolDefinition>;
703
- context: {
704
- recorder?: Recorder;
705
- };
706
- options?: {
707
- temperature?: number;
708
- top_p?: number;
709
- max_tokens?: number;
710
- frequency_penalty?: number;
711
- presence_penalty?: number;
712
- stop?: string | string[];
713
- [key: string]: any;
714
- };
715
- }): AsyncGenerator<AnyStreamChunk, void, unknown>;
363
+ input?: unknown;
364
+ output?: unknown;
716
365
  }
717
366
 
718
- declare const NAME: "OpenAI";
719
- declare class OpenAIProvider implements AIProvider {
720
- name: "OpenAI";
721
- client: OpenAI;
722
- model: string;
723
- constructor(apiKey: string, model?: string | undefined);
724
- createGenerationRequest(params: {
725
- messages: Array<AxleMessage>;
726
- system?: string;
727
- tools?: Array<ToolDefinition>;
728
- context: {
729
- recorder?: Recorder;
730
- };
731
- options?: {
732
- temperature?: number;
733
- top_p?: number;
734
- max_tokens?: number;
735
- frequency_penalty?: number;
736
- presence_penalty?: number;
737
- stop?: string | string[];
738
- [key: string]: any;
739
- };
740
- }): Promise<ModelResult>;
741
- createStreamingRequest(params: {
742
- messages: Array<AxleMessage>;
743
- system?: string;
744
- tools?: Array<ToolDefinition>;
745
- context: {
746
- recorder?: Recorder;
747
- };
748
- options?: {
749
- temperature?: number;
750
- top_p?: number;
751
- max_tokens?: number;
752
- frequency_penalty?: number;
753
- presence_penalty?: number;
754
- stop?: string | string[];
755
- [key: string]: any;
756
- };
757
- }): AsyncGenerator<AnyStreamChunk, void, unknown>;
367
+ declare class History {
368
+ system: string;
369
+ private _messages;
370
+ constructor(messages?: AxleMessage[]);
371
+ get messages(): AxleMessage[];
372
+ addSystem(message: string): void;
373
+ addUser(message: string): void;
374
+ addUser(parts: AxleUserMessage["content"]): void;
375
+ addAssistant(message: string): void;
376
+ addAssistant(params: Omit<AxleAssistantMessage, "role">): void;
377
+ addToolResults(input: Array<AxleToolCallResult>): void;
378
+ add(messages: AxleMessage | AxleMessage[]): void;
379
+ latest(): AxleMessage | undefined;
380
+ toString(): string;
758
381
  }
759
382
 
760
- interface GenerateOptions {
383
+ interface GenerateTurnOptions {
761
384
  temperature?: number;
762
385
  top_p?: number;
763
386
  max_tokens?: number;
@@ -766,266 +389,310 @@ interface GenerateOptions {
766
389
  stop?: string | string[];
767
390
  [key: string]: any;
768
391
  }
769
- interface GenerateProps {
392
+ interface GenerateTurnProps {
770
393
  provider: AIProvider;
394
+ model: string;
771
395
  messages: Array<AxleMessage>;
772
396
  system?: string;
773
397
  tools?: Array<ToolDefinition>;
774
- recorder?: Recorder;
775
- options?: GenerateOptions;
398
+ tracer?: TracingContext;
399
+ options?: GenerateTurnOptions;
776
400
  }
777
- declare function generate(props: GenerateProps): Promise<ModelResult>;
401
+ declare function generateTurn(props: GenerateTurnProps): Promise<ModelResult>;
778
402
 
779
- interface StreamProps {
403
+ type ToolCallResult = {
404
+ type: "success";
405
+ content: string;
406
+ } | {
407
+ type: "error";
408
+ error: {
409
+ type: string;
410
+ message: string;
411
+ fatal?: boolean;
412
+ retryable?: boolean;
413
+ };
414
+ };
415
+ type ToolCallCallback = (name: string, parameters: Record<string, unknown>) => Promise<ToolCallResult | null | undefined>;
416
+ type GenerateError = {
417
+ type: "model";
418
+ error: ModelError;
419
+ } | {
420
+ type: "tool";
421
+ error: {
422
+ name: string;
423
+ message: string;
424
+ };
425
+ };
426
+ type GenerateResult = {
427
+ result: "success";
428
+ messages: AxleMessage[];
429
+ final?: AxleAssistantMessage;
430
+ usage?: Stats;
431
+ } | {
432
+ result: "error";
433
+ messages: AxleMessage[];
434
+ error: GenerateError;
435
+ usage?: Stats;
436
+ };
437
+ type StreamResult = GenerateResult | {
438
+ result: "cancelled";
439
+ messages: AxleMessage[];
440
+ partial?: AxleAssistantMessage;
441
+ usage: Stats;
442
+ };
443
+
444
+ type StreamPartType = "text" | "thinking";
445
+ type PartStartCallback = (index: number, type: StreamPartType) => void;
446
+ type PartUpdateCallback = (index: number, type: StreamPartType, delta: string, accumulated: string) => void;
447
+ type PartEndCallback = (index: number, type: StreamPartType, final: string) => void;
448
+ type InternalToolEvent = {
449
+ type: "start";
450
+ index: number;
451
+ id: string;
452
+ name: string;
453
+ } | {
454
+ type: "complete";
455
+ index: number;
456
+ id: string;
457
+ name: string;
458
+ output?: unknown;
459
+ };
460
+ type InternalToolCallback = (event: InternalToolEvent) => void;
461
+ type ErrorCallback = (error: GenerateError) => void;
462
+ interface StreamOptions {
780
463
  provider: AIProvider;
464
+ model: string;
781
465
  messages: Array<AxleMessage>;
782
466
  system?: string;
783
467
  tools?: Array<ToolDefinition>;
784
- recorder?: Recorder;
785
- options?: GenerateOptions;
786
- }
787
- interface StreamResult {
788
- get final(): Promise<ModelResult>;
789
- get current(): AxleAssistantMessage;
790
- [Symbol.asyncIterator](): AsyncIterator<AnyStreamChunk>;
468
+ onToolCall?: ToolCallCallback;
469
+ maxIterations?: number;
470
+ tracer?: TracingContext;
471
+ options?: GenerateTurnOptions;
472
+ }
473
+ interface StreamHandle {
474
+ onPartStart(callback: PartStartCallback): void;
475
+ onPartUpdate(callback: PartUpdateCallback): void;
476
+ onPartEnd(callback: PartEndCallback): void;
477
+ onInternalTool(callback: InternalToolCallback): void;
478
+ onError(callback: ErrorCallback): void;
479
+ cancel(): void;
480
+ readonly final: Promise<StreamResult>;
481
+ }
482
+ declare function stream(options: StreamOptions): StreamHandle;
483
+
484
+ type OutputSchema = Record<string, z.ZodTypeAny>;
485
+ type ParsedSchema<T extends OutputSchema> = {
486
+ [K in keyof T]: z.output<T[K]>;
487
+ };
488
+ declare function parseResponse<T extends OutputSchema>(rawValue: string, schema?: T): ParsedSchema<T> | string;
489
+
490
+ declare class Instruct<TSchema extends OutputSchema | undefined = undefined> {
491
+ prompt: string;
492
+ inputs: Record<string, string>;
493
+ files: Base64FileInfo[];
494
+ textReferences: Array<{
495
+ content: string;
496
+ name?: string;
497
+ }>;
498
+ instructions: string[];
499
+ schema: TSchema;
500
+ constructor(prompt: string, schema?: TSchema);
501
+ setInputs(inputs: Record<string, string>): void;
502
+ addInput(name: string, value: string): void;
503
+ addFile(file: FileInfo | string, options?: {
504
+ name?: string;
505
+ }): void;
506
+ addInstructions(instruction: string): void;
507
+ hasFiles(): boolean;
791
508
  }
792
- declare function stream(props: StreamProps): StreamResult;
793
509
 
794
- declare const index$1_DEFAULT_OLLAMA_URL: typeof DEFAULT_OLLAMA_URL;
795
- declare namespace index$1 {
796
- export {
797
- index$1_DEFAULT_OLLAMA_URL as DEFAULT_OLLAMA_URL,
798
- NAME$1 as NAME,
799
- OllamaProvider as Provider,
800
- };
510
+ interface AgentConfig {
511
+ provider: AIProvider;
512
+ model: string;
513
+ system?: string;
514
+ tools?: Tool[];
515
+ tracer?: TracingContext;
516
+ }
517
+ interface AgentResult<T = string> {
518
+ response: T | null;
519
+ messages: AxleMessage[];
520
+ final: AxleAssistantMessage | undefined;
521
+ usage: Stats;
522
+ }
523
+ interface AgentHandle<T = string> {
524
+ cancel(): void;
525
+ readonly final: Promise<AgentResult<T>>;
801
526
  }
527
+ declare class Agent {
528
+ readonly provider: AIProvider;
529
+ readonly model: string;
530
+ readonly history: History;
531
+ readonly tracer?: TracingContext;
532
+ system: string | undefined;
533
+ tools: Record<string, Tool>;
534
+ private partStartCallback?;
535
+ private partUpdateCallback?;
536
+ private partEndCallback?;
537
+ private internalToolCallback?;
538
+ private errorCallback?;
539
+ constructor(config: AgentConfig);
540
+ addTool(tool: Tool): void;
541
+ addTools(tools: Tool[]): void;
542
+ hasTools(): boolean;
543
+ onPartStart(callback: PartStartCallback): void;
544
+ onPartUpdate(callback: PartUpdateCallback): void;
545
+ onPartEnd(callback: PartEndCallback): void;
546
+ onInternalTool(callback: InternalToolCallback): void;
547
+ onError(callback: ErrorCallback): void;
548
+ send(message: string): AgentHandle<string>;
549
+ send(instruct: Instruct<undefined>, variables?: Record<string, string>): AgentHandle<string>;
550
+ send<TSchema extends OutputSchema>(instruct: Instruct<TSchema>, variables?: Record<string, string>): AgentHandle<ParsedSchema<TSchema>>;
551
+ private execute;
552
+ }
553
+
554
+ declare function compileInstruct(instruct: Instruct<any>, variables?: Record<string, string>): string;
555
+
556
+ declare function anthropic(apiKey: string): AIProvider;
557
+
558
+ declare const Anthropic: {
559
+ readonly Models: {
560
+ readonly CLAUDE_OPUS_4_6: "claude-opus-4-6";
561
+ readonly CLAUDE_OPUS_4_5_20251101: "claude-opus-4-5-20251101";
562
+ readonly CLAUDE_OPUS_4_5_LATEST: "claude-opus-4-5-20251101";
563
+ readonly CLAUDE_HAIKU_4_5_20251001: "claude-haiku-4-5-20251001";
564
+ readonly CLAUDE_HAIKU_4_5: "claude-haiku-4-5-20251001";
565
+ readonly CLAUDE_SONNET_4_5_20250929: "claude-sonnet-4-5-20250929";
566
+ readonly CLAUDE_SONNET_4_5_LATEST: "claude-sonnet-4-5-20250929";
567
+ readonly CLAUDE_OPUS_4_1_20250805: "claude-opus-4-1-20250805";
568
+ readonly CLAUDE_OPUS_4_1_LATEST: "claude-opus-4-1-20250805";
569
+ readonly CLAUDE_OPUS_4_20250514: "claude-opus-4-20250514";
570
+ readonly CLAUDE_OPUS_4_LATEST: "claude-opus-4-20250514";
571
+ readonly CLAUDE_SONNET_4_20250514: "claude-sonnet-4-20250514";
572
+ readonly CLAUDE_SONNET_4_LATEST: "claude-sonnet-4-20250514";
573
+ readonly CLAUDE_3_7_SONNET_20250219: "claude-3-7-sonnet-20250219";
574
+ readonly CLAUDE_3_7_SONNET_LATEST: "claude-3-7-sonnet-20250219";
575
+ readonly CLAUDE_3_5_HAIKU_20241022: "claude-3-5-haiku-20241022";
576
+ readonly CLAUDE_3_5_HAIKU_LATEST: "claude-3-5-haiku-20241022";
577
+ readonly CLAUDE_3_HAIKU_20240307: "claude-3-haiku-20240307";
578
+ };
579
+ readonly DefaultModel: "claude-haiku-4-5-20251001";
580
+ };
802
581
 
803
- declare const Models: {
804
- readonly GPT_5: "gpt-5";
805
- readonly GPT_5_MINI: "gpt-5-mini";
806
- readonly GPT_5_NANO: "gpt-5-nano";
807
- readonly GPT_5_CHAT_LATEST: "gpt-5-chat-latest";
808
- readonly GPT_5_PRO: "gpt-5-pro";
809
- readonly GPT_5_CODEX: "gpt-5-codex";
810
- readonly GPT_4_5_PREVIEW: "gpt-4.5-preview";
811
- readonly GPT_4_5_PREVIEW_2025_02_27: "gpt-4.5-preview-2025-02-27";
812
- readonly GPT_4_1: "gpt-4.1";
813
- readonly GPT_4_1_2025_04_14: "gpt-4.1-2025-04-14";
814
- readonly GPT_4_1_MINI: "gpt-4.1-mini";
815
- readonly GPT_4_1_MINI_2025_04_14: "gpt-4.1-mini-2025-04-14";
816
- readonly GPT_4_1_NANO: "gpt-4.1-nano";
817
- readonly GPT_4_1_NANO_2025_04_14: "gpt-4.1-nano-2025-04-14";
818
- readonly GPT_4O: "gpt-4o";
819
- readonly GPT_4O_2024_05_13: "gpt-4o-2024-05-13";
820
- readonly GPT_4O_2024_08_06: "gpt-4o-2024-08-06";
821
- readonly GPT_4O_2024_11_20: "gpt-4o-2024-11-20";
822
- readonly GPT_4O_MINI: "gpt-4o-mini";
823
- readonly GPT_4O_MINI_2024_07_18: "gpt-4o-mini-2024-07-18";
824
- readonly GPT_4O_AUDIO_PREVIEW: "gpt-4o-audio-preview";
825
- readonly GPT_4O_AUDIO_PREVIEW_2024_10_01: "gpt-4o-audio-preview-2024-10-01";
826
- readonly GPT_4O_AUDIO_PREVIEW_2024_12_17: "gpt-4o-audio-preview-2024-12-17";
827
- readonly GPT_4O_AUDIO_PREVIEW_2025_06_03: "gpt-4o-audio-preview-2025-06-03";
828
- readonly GPT_4O_MINI_AUDIO_PREVIEW: "gpt-4o-mini-audio-preview";
829
- readonly GPT_4O_MINI_AUDIO_PREVIEW_2024_12_17: "gpt-4o-mini-audio-preview-2024-12-17";
830
- readonly GPT_REALTIME: "gpt-realtime";
831
- readonly GPT_REALTIME_MINI: "gpt-realtime-mini";
832
- readonly GPT_4O_REALTIME_PREVIEW: "gpt-4o-realtime-preview";
833
- readonly GPT_4O_REALTIME_PREVIEW_2024_10_01: "gpt-4o-realtime-preview-2024-10-01";
834
- readonly GPT_4O_REALTIME_PREVIEW_2024_12_17: "gpt-4o-realtime-preview-2024-12-17";
835
- readonly GPT_4O_REALTIME_PREVIEW_2025_06_03: "gpt-4o-realtime-preview-2025-06-03";
836
- readonly GPT_4O_MINI_REALTIME_PREVIEW: "gpt-4o-mini-realtime-preview";
837
- readonly GPT_4O_MINI_REALTIME_PREVIEW_2024_12_17: "gpt-4o-mini-realtime-preview-2024-12-17";
838
- readonly GPT_4O_SEARCH_PREVIEW: "gpt-4o-search-preview";
839
- readonly GPT_4O_SEARCH_PREVIEW_2025_03_11: "gpt-4o-search-preview-2025-03-11";
840
- readonly GPT_4O_MINI_SEARCH_PREVIEW: "gpt-4o-mini-search-preview";
841
- readonly GPT_4O_MINI_SEARCH_PREVIEW_2025_03_11: "gpt-4o-mini-search-preview-2025-03-11";
842
- readonly GPT_4O_TRANSCRIBE: "gpt-4o-transcribe";
843
- readonly GPT_4O_MINI_TRANSCRIBE: "gpt-4o-mini-transcribe";
844
- readonly GPT_4O_MINI_TTS: "gpt-4o-mini-tts";
845
- readonly GPT_IMAGE_1: "gpt-image-1";
846
- readonly GPT_IMAGE_1_MINI: "gpt-image-1-mini";
847
- readonly O4_MINI: "o4-mini";
848
- readonly O4_MINI_2025_04_16: "o4-mini-2025-04-16";
849
- readonly O3: "o3";
850
- readonly O3_PRO: "o3-pro";
851
- readonly O3_MINI: "o3-mini";
852
- readonly O3_MINI_2025_01_31: "o3-mini-2025-01-31";
853
- readonly O1_PRO: "o1-pro";
854
- readonly O1_PRO_2025_03_19: "o1-pro-2025-03-19";
855
- readonly O1: "o1";
856
- readonly O1_2024_12_17: "o1-2024-12-17";
857
- readonly O1_MINI: "o1-mini";
858
- readonly O1_MINI_2024_09_12: "o1-mini-2024-09-12";
859
- readonly O1_PREVIEW: "o1-preview";
860
- readonly O1_PREVIEW_2024_09_12: "o1-preview-2024-09-12";
861
- readonly GPT_OSS_120B: "gpt-oss-120b";
862
- readonly GPT_OSS_7B: "gpt-oss-7b";
863
- readonly SORA_2: "sora-2";
864
- readonly SORA_2025_05_02: "sora-2025-05-02";
865
- readonly CODEX_MINI: "codex-mini";
866
- readonly COMPUTER_USE_PREVIEW: "computer-use-preview";
582
+ declare function chatCompletions(baseUrl: string, apiKey?: string): AIProvider;
583
+
584
+ declare function gemini(apiKey: string): AIProvider;
585
+
586
+ declare const Gemini: {
587
+ readonly Models: {
588
+ readonly GEMINI_3_PRO_PREVIEW: "gemini-3-pro-preview";
589
+ readonly GEMINI_3_FLASH_PREVIEW: "gemini-3-flash-preview";
590
+ readonly GEMINI_3_PRO_IMAGE_PREVIEW: "gemini-3-pro-image-preview";
591
+ readonly GEMINI_2_5_PRO: "gemini-2.5-pro";
592
+ readonly GEMINI_2_5_PRO_PREVIEW_TTS: "gemini-2.5-pro-preview-tts";
593
+ readonly GEMINI_2_5_FLASH: "gemini-2.5-flash";
594
+ readonly GEMINI_2_5_FLASH_LATEST: "gemini-2.5-flash";
595
+ readonly GEMINI_2_5_FLASH_PREVIEW_09_2025: "gemini-2.5-flash-preview-09-2025";
596
+ readonly GEMINI_2_5_FLASH_PREVIEW_TTS: "gemini-2.5-flash-preview-tts";
597
+ readonly GEMINI_2_5_FLASH_NATIVE_AUDIO_LATEST: "gemini-2.5-flash-native-audio-latest";
598
+ readonly GEMINI_2_5_FLASH_NATIVE_AUDIO_PREVIEW_09_2025: "gemini-2.5-flash-native-audio-preview-09-2025";
599
+ readonly GEMINI_2_5_FLASH_NATIVE_AUDIO_PREVIEW_12_2025: "gemini-2.5-flash-native-audio-preview-12-2025";
600
+ readonly GEMINI_2_5_FLASH_IMAGE: "gemini-2.5-flash-image";
601
+ readonly GEMINI_2_5_FLASH_LITE: "gemini-2.5-flash-lite";
602
+ readonly GEMINI_2_5_FLASH_LITE_LATEST: "gemini-2.5-flash-lite";
603
+ readonly GEMINI_2_5_FLASH_LITE_PREVIEW_09_2025: "gemini-2.5-flash-lite-preview-09-2025";
604
+ readonly GEMINI_2_5_COMPUTER_USE_PREVIEW_10_2025: "gemini-2.5-computer-use-preview-10-2025";
605
+ readonly GEMINI_2_0_FLASH: "gemini-2.0-flash";
606
+ readonly GEMINI_2_0_FLASH_001: "gemini-2.0-flash-001";
607
+ readonly GEMINI_2_0_FLASH_LATEST: "gemini-2.0-flash";
608
+ readonly GEMINI_2_0_FLASH_EXP_IMAGE_GENERATION: "gemini-2.0-flash-exp-image-generation";
609
+ readonly GEMINI_2_0_FLASH_LITE: "gemini-2.0-flash-lite";
610
+ readonly GEMINI_2_0_FLASH_LITE_001: "gemini-2.0-flash-lite-001";
611
+ readonly GEMINI_2_0_FLASH_LITE_LATEST: "gemini-2.0-flash-lite";
612
+ readonly GEMINI_EXP_1206: "gemini-exp-1206";
613
+ readonly GEMINI_FLASH_LATEST: "gemini-flash-latest";
614
+ readonly GEMINI_FLASH_LITE_LATEST: "gemini-flash-lite-latest";
615
+ readonly GEMINI_PRO_LATEST: "gemini-pro-latest";
616
+ readonly GEMMA_3_27B_IT: "gemma-3-27b-it";
617
+ readonly GEMMA_3_12B_IT: "gemma-3-12b-it";
618
+ readonly GEMMA_3_4B_IT: "gemma-3-4b-it";
619
+ readonly GEMMA_3_1B_IT: "gemma-3-1b-it";
620
+ readonly GEMMA_3N_E4B_IT: "gemma-3n-e4b-it";
621
+ readonly GEMMA_3N_E2B_IT: "gemma-3n-e2b-it";
622
+ readonly DEEP_RESEARCH_PRO_PREVIEW_12_2025: "deep-research-pro-preview-12-2025";
623
+ readonly GEMINI_ROBOTICS_ER_1_5_PREVIEW: "gemini-robotics-er-1.5-preview";
624
+ readonly NANO_BANANA_PRO_PREVIEW: "nano-banana-pro-preview";
625
+ readonly AQA: "aqa";
626
+ };
627
+ readonly DefaultModel: "gemini-2.5-flash";
867
628
  };
868
- declare const DEFAULT_MODEL: "gpt-5";
869
629
 
870
- declare const index_DEFAULT_MODEL: typeof DEFAULT_MODEL;
871
- declare const index_Models: typeof Models;
872
- declare const index_NAME: typeof NAME;
873
- declare namespace index {
874
- export {
875
- index_DEFAULT_MODEL as DEFAULT_MODEL,
876
- index_Models as Models,
877
- index_NAME as NAME,
878
- OpenAIProvider as Provider,
879
- };
880
- }
630
+ interface GenerateOptions {
631
+ provider: AIProvider;
632
+ model: string;
633
+ messages: Array<AxleMessage>;
634
+ system?: string;
635
+ tools?: Array<ToolDefinition>;
636
+ onToolCall: ToolCallCallback;
637
+ maxIterations?: number;
638
+ tracer?: TracingContext;
639
+ options?: GenerateTurnOptions;
640
+ }
641
+ declare function generate(options: GenerateOptions): Promise<GenerateResult>;
642
+
643
+ declare function openai(apiKey: string): AIProvider;
644
+
645
+ declare const OpenAI: {
646
+ readonly Models: {
647
+ readonly GPT_5_2: "gpt-5.2";
648
+ readonly GPT_5_2_2025_12_11: "gpt-5.2-2025-12-11";
649
+ readonly GPT_5_2_CHAT_LATEST: "gpt-5.2-chat-latest";
650
+ readonly GPT_5_2_PRO: "gpt-5.2-pro";
651
+ readonly GPT_5_2_PRO_2025_12_11: "gpt-5.2-pro-2025-12-11";
652
+ readonly GPT_5_2_CODEX: "gpt-5.2-codex";
653
+ readonly GPT_5_1: "gpt-5.1";
654
+ readonly GPT_5_1_2025_11_13: "gpt-5.1-2025-11-13";
655
+ readonly GPT_5_1_CHAT_LATEST: "gpt-5.1-chat-latest";
656
+ readonly GPT_5_1_CODEX: "gpt-5.1-codex";
657
+ readonly GPT_5_1_CODEX_MAX: "gpt-5.1-codex-max";
658
+ readonly GPT_5_1_CODEX_MINI: "gpt-5.1-codex-mini";
659
+ readonly GPT_5: "gpt-5";
660
+ readonly GPT_5_2025_08_07: "gpt-5-2025-08-07";
661
+ readonly GPT_5_CHAT_LATEST: "gpt-5-chat-latest";
662
+ readonly GPT_5_CODEX: "gpt-5-codex";
663
+ readonly GPT_5_MINI: "gpt-5-mini";
664
+ readonly GPT_5_MINI_2025_08_07: "gpt-5-mini-2025-08-07";
665
+ readonly GPT_5_NANO: "gpt-5-nano";
666
+ readonly GPT_5_NANO_2025_08_07: "gpt-5-nano-2025-08-07";
667
+ readonly GPT_5_PRO: "gpt-5-pro";
668
+ readonly GPT_5_PRO_2025_10_06: "gpt-5-pro-2025-10-06";
669
+ readonly GPT_4_1: "gpt-4.1";
670
+ readonly GPT_4_1_2025_04_14: "gpt-4.1-2025-04-14";
671
+ readonly GPT_4_1_MINI: "gpt-4.1-mini";
672
+ readonly GPT_4_1_MINI_2025_04_14: "gpt-4.1-mini-2025-04-14";
673
+ readonly GPT_4_1_NANO: "gpt-4.1-nano";
674
+ readonly GPT_4_1_NANO_2025_04_14: "gpt-4.1-nano-2025-04-14";
675
+ readonly O4_MINI: "o4-mini";
676
+ readonly O4_MINI_2025_04_16: "o4-mini-2025-04-16";
677
+ readonly O3: "o3";
678
+ readonly O3_2025_04_16: "o3-2025-04-16";
679
+ readonly O3_PRO: "o3-pro";
680
+ readonly O3_PRO_2025_06_10: "o3-pro-2025-06-10";
681
+ readonly O3_MINI: "o3-mini";
682
+ readonly O3_MINI_2025_01_31: "o3-mini-2025-01-31";
683
+ readonly O1_PRO: "o1-pro";
684
+ readonly O1_PRO_2025_03_19: "o1-pro-2025-03-19";
685
+ readonly O1: "o1";
686
+ readonly O1_2024_12_17: "o1-2024-12-17";
687
+ };
688
+ readonly DefaultModel: "gpt-5-mini";
689
+ };
881
690
 
882
691
  declare const BraveProviderConfigSchema: z$1.ZodObject<{
883
692
  "api-key": z$1.ZodString;
884
693
  rateLimit: z$1.ZodOptional<z$1.ZodNumber>;
885
694
  }, z$1.core.$strip>;
886
695
  type BraveProviderConfig = z$1.infer<typeof BraveProviderConfigSchema>;
887
- declare const JobSchema: z$1.ZodPipe<z$1.ZodTransform<any, any>, z$1.ZodDiscriminatedUnion<[z$1.ZodObject<{
888
- type: z$1.ZodLiteral<"serial">;
889
- tools: z$1.ZodOptional<z$1.ZodArray<z$1.ZodString>>;
890
- steps: z$1.ZodArray<z$1.ZodDiscriminatedUnion<[z$1.ZodObject<{
891
- uses: z$1.ZodLiteral<"chat">;
892
- system: z$1.ZodOptional<z$1.ZodString>;
893
- message: z$1.ZodString;
894
- output: z$1.ZodOptional<z$1.ZodRecord<z$1.ZodString, z$1.ZodAny>>;
895
- replace: z$1.ZodOptional<z$1.ZodArray<z$1.ZodObject<{
896
- source: z$1.ZodLiteral<"file">;
897
- pattern: z$1.ZodString;
898
- files: z$1.ZodUnion<readonly [z$1.ZodString, z$1.ZodArray<z$1.ZodString>]>;
899
- }, z$1.core.$strip>>>;
900
- tools: z$1.ZodOptional<z$1.ZodArray<z$1.ZodString>>;
901
- images: z$1.ZodOptional<z$1.ZodArray<z$1.ZodObject<{
902
- file: z$1.ZodString;
903
- }, z$1.core.$strip>>>;
904
- documents: z$1.ZodOptional<z$1.ZodArray<z$1.ZodObject<{
905
- file: z$1.ZodString;
906
- }, z$1.core.$strip>>>;
907
- references: z$1.ZodOptional<z$1.ZodArray<z$1.ZodObject<{
908
- file: z$1.ZodString;
909
- }, z$1.core.$strip>>>;
910
- }, z$1.core.$strip>, z$1.ZodObject<{
911
- uses: z$1.ZodLiteral<"write-to-disk">;
912
- output: z$1.ZodString;
913
- keys: z$1.ZodOptional<z$1.ZodUnion<readonly [z$1.ZodString, z$1.ZodArray<z$1.ZodString>]>>;
914
- }, z$1.core.$strip>], "uses">>;
915
- }, z$1.core.$strip>, z$1.ZodObject<{
916
- type: z$1.ZodLiteral<"batch">;
917
- tools: z$1.ZodOptional<z$1.ZodArray<z$1.ZodString>>;
918
- batch: z$1.ZodArray<z$1.ZodObject<{
919
- type: z$1.ZodLiteral<"files">;
920
- source: z$1.ZodString;
921
- bind: z$1.ZodString;
922
- "skip-if": z$1.ZodOptional<z$1.ZodArray<z$1.ZodObject<{
923
- type: z$1.ZodLiteral<"file-exist">;
924
- pattern: z$1.ZodString;
925
- }, z$1.core.$strip>>>;
926
- }, z$1.core.$strip>>;
927
- steps: z$1.ZodArray<z$1.ZodDiscriminatedUnion<[z$1.ZodObject<{
928
- uses: z$1.ZodLiteral<"chat">;
929
- system: z$1.ZodOptional<z$1.ZodString>;
930
- message: z$1.ZodString;
931
- output: z$1.ZodOptional<z$1.ZodRecord<z$1.ZodString, z$1.ZodAny>>;
932
- replace: z$1.ZodOptional<z$1.ZodArray<z$1.ZodObject<{
933
- source: z$1.ZodLiteral<"file">;
934
- pattern: z$1.ZodString;
935
- files: z$1.ZodUnion<readonly [z$1.ZodString, z$1.ZodArray<z$1.ZodString>]>;
936
- }, z$1.core.$strip>>>;
937
- tools: z$1.ZodOptional<z$1.ZodArray<z$1.ZodString>>;
938
- images: z$1.ZodOptional<z$1.ZodArray<z$1.ZodObject<{
939
- file: z$1.ZodString;
940
- }, z$1.core.$strip>>>;
941
- documents: z$1.ZodOptional<z$1.ZodArray<z$1.ZodObject<{
942
- file: z$1.ZodString;
943
- }, z$1.core.$strip>>>;
944
- references: z$1.ZodOptional<z$1.ZodArray<z$1.ZodObject<{
945
- file: z$1.ZodString;
946
- }, z$1.core.$strip>>>;
947
- }, z$1.core.$strip>, z$1.ZodObject<{
948
- uses: z$1.ZodLiteral<"write-to-disk">;
949
- output: z$1.ZodString;
950
- keys: z$1.ZodOptional<z$1.ZodUnion<readonly [z$1.ZodString, z$1.ZodArray<z$1.ZodString>]>>;
951
- }, z$1.core.$strip>], "uses">>;
952
- }, z$1.core.$strip>], "type">>;
953
- type Job = z$1.infer<typeof JobSchema>;
954
- type SerialJob = Extract<Job, {
955
- type: "serial";
956
- }>;
957
- type BatchJob = Extract<Job, {
958
- type: "batch";
959
- }>;
960
- declare const DAGJobSchema: z$1.ZodRecord<z$1.ZodString, z$1.ZodPipe<z$1.ZodTransform<any, any>, z$1.ZodDiscriminatedUnion<[z$1.ZodObject<{
961
- type: z$1.ZodLiteral<"serial">;
962
- tools: z$1.ZodOptional<z$1.ZodArray<z$1.ZodString>>;
963
- steps: z$1.ZodArray<z$1.ZodDiscriminatedUnion<[z$1.ZodObject<{
964
- uses: z$1.ZodLiteral<"chat">;
965
- system: z$1.ZodOptional<z$1.ZodString>;
966
- message: z$1.ZodString;
967
- output: z$1.ZodOptional<z$1.ZodRecord<z$1.ZodString, z$1.ZodAny>>;
968
- replace: z$1.ZodOptional<z$1.ZodArray<z$1.ZodObject<{
969
- source: z$1.ZodLiteral<"file">;
970
- pattern: z$1.ZodString;
971
- files: z$1.ZodUnion<readonly [z$1.ZodString, z$1.ZodArray<z$1.ZodString>]>;
972
- }, z$1.core.$strip>>>;
973
- tools: z$1.ZodOptional<z$1.ZodArray<z$1.ZodString>>;
974
- images: z$1.ZodOptional<z$1.ZodArray<z$1.ZodObject<{
975
- file: z$1.ZodString;
976
- }, z$1.core.$strip>>>;
977
- documents: z$1.ZodOptional<z$1.ZodArray<z$1.ZodObject<{
978
- file: z$1.ZodString;
979
- }, z$1.core.$strip>>>;
980
- references: z$1.ZodOptional<z$1.ZodArray<z$1.ZodObject<{
981
- file: z$1.ZodString;
982
- }, z$1.core.$strip>>>;
983
- }, z$1.core.$strip>, z$1.ZodObject<{
984
- uses: z$1.ZodLiteral<"write-to-disk">;
985
- output: z$1.ZodString;
986
- keys: z$1.ZodOptional<z$1.ZodUnion<readonly [z$1.ZodString, z$1.ZodArray<z$1.ZodString>]>>;
987
- }, z$1.core.$strip>], "uses">>;
988
- dependsOn: z$1.ZodOptional<z$1.ZodUnion<readonly [z$1.ZodString, z$1.ZodArray<z$1.ZodString>]>>;
989
- }, z$1.core.$strip>, z$1.ZodObject<{
990
- type: z$1.ZodLiteral<"batch">;
991
- tools: z$1.ZodOptional<z$1.ZodArray<z$1.ZodString>>;
992
- batch: z$1.ZodArray<z$1.ZodObject<{
993
- type: z$1.ZodLiteral<"files">;
994
- source: z$1.ZodString;
995
- bind: z$1.ZodString;
996
- "skip-if": z$1.ZodOptional<z$1.ZodArray<z$1.ZodObject<{
997
- type: z$1.ZodLiteral<"file-exist">;
998
- pattern: z$1.ZodString;
999
- }, z$1.core.$strip>>>;
1000
- }, z$1.core.$strip>>;
1001
- steps: z$1.ZodArray<z$1.ZodDiscriminatedUnion<[z$1.ZodObject<{
1002
- uses: z$1.ZodLiteral<"chat">;
1003
- system: z$1.ZodOptional<z$1.ZodString>;
1004
- message: z$1.ZodString;
1005
- output: z$1.ZodOptional<z$1.ZodRecord<z$1.ZodString, z$1.ZodAny>>;
1006
- replace: z$1.ZodOptional<z$1.ZodArray<z$1.ZodObject<{
1007
- source: z$1.ZodLiteral<"file">;
1008
- pattern: z$1.ZodString;
1009
- files: z$1.ZodUnion<readonly [z$1.ZodString, z$1.ZodArray<z$1.ZodString>]>;
1010
- }, z$1.core.$strip>>>;
1011
- tools: z$1.ZodOptional<z$1.ZodArray<z$1.ZodString>>;
1012
- images: z$1.ZodOptional<z$1.ZodArray<z$1.ZodObject<{
1013
- file: z$1.ZodString;
1014
- }, z$1.core.$strip>>>;
1015
- documents: z$1.ZodOptional<z$1.ZodArray<z$1.ZodObject<{
1016
- file: z$1.ZodString;
1017
- }, z$1.core.$strip>>>;
1018
- references: z$1.ZodOptional<z$1.ZodArray<z$1.ZodObject<{
1019
- file: z$1.ZodString;
1020
- }, z$1.core.$strip>>>;
1021
- }, z$1.core.$strip>, z$1.ZodObject<{
1022
- uses: z$1.ZodLiteral<"write-to-disk">;
1023
- output: z$1.ZodString;
1024
- keys: z$1.ZodOptional<z$1.ZodUnion<readonly [z$1.ZodString, z$1.ZodArray<z$1.ZodString>]>>;
1025
- }, z$1.core.$strip>], "uses">>;
1026
- dependsOn: z$1.ZodOptional<z$1.ZodUnion<readonly [z$1.ZodString, z$1.ZodArray<z$1.ZodString>]>>;
1027
- }, z$1.core.$strip>], "type">>>;
1028
- type DAGJob = z$1.infer<typeof DAGJobSchema>;
1029
696
 
1030
697
  declare const braveSearchSchema: z.ZodObject<{
1031
698
  searchTerm: z.ZodString;
@@ -1058,171 +725,82 @@ declare const calculatorSchema: z$1.ZodObject<{
1058
725
  declare const calculatorTool: Tool<typeof calculatorSchema>;
1059
726
 
1060
727
  /**
1061
- * WriteToDisk Action
1062
- *
1063
- * Writes content to a file on disk. This action is typically used as a workflow
1064
- * step following an LLM call to persist the generated output.
1065
- *
1066
- * ## CLI Job Definition (YAML)
1067
- *
1068
- * In job YAML files, use the `write-to-disk` step type:
1069
- *
1070
- * ```yaml
1071
- * steps:
1072
- * - uses: chat
1073
- * message: Generate a greeting for {{name}}
1074
- * - uses: write-to-disk
1075
- * output: ./output/greeting-{{name}}.txt
1076
- * ```
1077
- *
1078
- * ### Properties
1079
- *
1080
- * | Property | Type | Required | Description |
1081
- * |----------|----------------------|----------|--------------------------------------------------|
1082
- * | `uses` | `"write-to-disk"` | Yes | Identifies this as a WriteToDisk step |
1083
- * | `output` | `string` | Yes | File path template (supports `{{}}` placeholders)|
1084
- * | `keys` | `string \| string[]` | No | Variable keys to include in output content |
1085
- *
1086
- * ### Examples
1087
- *
1088
- * **Basic usage** - writes the LLM response to a file:
1089
- * ```yaml
1090
- * - uses: write-to-disk
1091
- * output: ./output/result.txt
1092
- * ```
1093
- *
1094
- * **With path variables** - uses `{{}}` placeholders in path:
1095
- * ```yaml
1096
- * - uses: write-to-disk
1097
- * output: ./output/greeting-{{name}}.txt
1098
- * ```
1099
- *
1100
- * **With file pattern** (batch processing) - uses `*` to substitute file stem:
1101
- * ```yaml
1102
- * - uses: write-to-disk
1103
- * output: ./output/results-*.txt
1104
- * ```
1105
- *
1106
- * **With specific keys** - outputs only specified variables:
1107
- * ```yaml
1108
- * - uses: write-to-disk
1109
- * output: ./output/summary.txt
1110
- * keys: summary
1111
- * ```
1112
- *
1113
- * **With multiple keys** - outputs multiple variables, each on a new line:
1114
- * ```yaml
1115
- * - uses: write-to-disk
1116
- * output: ./output/report.txt
1117
- * keys:
1118
- * - title
1119
- * - summary
1120
- * - conclusion
1121
- * ```
1122
- *
1123
- * ## Placeholder Styles
1124
- *
1125
- * This action uses `{{variable}}` placeholder style for all variable substitution:
1126
- *
1127
- * - **Path template** (`output`): Uses `{{variable}}` placeholders
1128
- * - Example: `./output/greeting-{{name}}.txt`
1129
- * - Also supports `*` for file stem substitution in batch processing
1130
- *
1131
- * - **Content template** (`keys`): Uses `{{variable}}` placeholders
1132
- * - Default template: `{{response}}`
1133
- * - When `keys` is specified, generates: `{{key1}}\n{{key2}}\n...`
1134
- *
1135
- * ## Variables Available
1136
- *
1137
- * All variables from the workflow context are available for substitution:
1138
- * - `response` - The text response from the previous LLM step
1139
- * - `$previous` - The full output object from the previous step
1140
- * - `file` - File info object when processing batches (contains `stem`, `name`, `ext`, etc.)
1141
- * - Any custom variables defined in the workflow or extracted by previous steps
1142
- *
1143
- * @see WriteToDiskStep in `src/cli/configs/types.ts` for the TypeScript interface
1144
- * @see writeToDiskConverter in `src/cli/converters/writeToDisk.ts` for CLI conversion logic
728
+ * Root tracer that manages writers and creates spans.
729
+ * Use startSpan() to create TracingContext instances for hierarchical tracing.
730
+ * All logging happens within spans - the Tracer itself is just configuration and factory.
1145
731
  */
1146
- declare class WriteToDisk implements Action {
1147
- private pathTemplate;
1148
- private contentTemplate;
1149
- name: string;
732
+ declare class Tracer {
733
+ private writers;
734
+ private _minLevel;
735
+ get minLevel(): EventLevel;
736
+ set minLevel(level: EventLevel);
737
+ addWriter(writer: TraceWriter): void;
738
+ removeWriter(writer: TraceWriter): void;
739
+ startSpan(name: string, options?: SpanOptions): TracingContext;
740
+ flush(): Promise<void>;
741
+ /** @internal */
742
+ _notifySpanEnd(spanData: SpanData): void;
743
+ /** @internal */
744
+ _notifySpanUpdate(spanData: SpanData): void;
745
+ /** @internal */
746
+ _notifyEvent(spanData: SpanData, event: SpanEvent): void;
747
+ /** @internal */
748
+ _notifySpanStart(spanData: SpanData): void;
749
+ /** @internal */
750
+ _notifyLLMStreamStart(spanData: SpanData): void;
751
+ /** @internal */
752
+ _notifyLLMStreamChunk(spanData: SpanData, chunk: string): void;
753
+ /** @internal */
754
+ _notifyLLMStreamEnd(spanData: SpanData, result: LLMResult): void;
755
+ /** @internal */
756
+ _shouldLog(level: EventLevel): boolean;
757
+ }
758
+
759
+ interface SimpleWriterOptions {
760
+ /** Minimum event level to display (default: "info") */
761
+ minLevel?: EventLevel;
762
+ /** Show internal spans - typically enabled via --debug flag (default: false) */
763
+ showInternal?: boolean;
764
+ /** Show timestamps (default: true) */
765
+ showTimestamp?: boolean;
766
+ /** Show duration on span end (default: true) */
767
+ showDuration?: boolean;
768
+ /** Custom output function (default: console.log) */
769
+ output?: (line: string) => void;
770
+ }
771
+ declare class SimpleWriter implements TraceWriter {
772
+ private minLevel;
773
+ private showInternal;
774
+ private showTimestamp;
775
+ private showDuration;
776
+ private output;
777
+ private spans;
778
+ private visibleDepths;
779
+ constructor(options?: SimpleWriterOptions);
780
+ private shouldShowEvent;
781
+ private isSpanVisible;
1150
782
  /**
1151
- * Creates a new WriteToDisk action.
1152
- *
1153
- * @param pathTemplate - The file path template. Supports:
1154
- * - `{{variable}}` placeholders for variable substitution
1155
- * - `*` for file stem substitution (batch processing)
1156
- * @param contentTemplate - The content template using `{{variable}}` placeholders.
1157
- * Defaults to `{{response}}` to output the LLM response.
783
+ * Find the nearest visible ancestor span for a given span.
784
+ * Returns null if no visible ancestor exists (root level).
1158
785
  */
1159
- constructor(pathTemplate: string, contentTemplate?: string);
786
+ private findVisibleAncestor;
1160
787
  /**
1161
- * Executes the write-to-disk action.
1162
- *
1163
- * Resolves the path and content templates using workflow variables,
1164
- * then writes the content to the resolved file path.
1165
- *
1166
- * @param context - The action execution context containing:
1167
- * - `variables`: All workflow variables available for substitution
1168
- * - `options`: Execution options (e.g., `dryRun`)
1169
- * - `recorder`: Optional recorder for logging
1170
- * @returns A promise that resolves when the file has been written
788
+ * Calculate the visible depth for a span.
789
+ * Only counts visible ancestors in the depth.
1171
790
  */
1172
- execute(context: ActionContext): Promise<void>;
1173
- }
1174
-
1175
- interface ConcurrentWorkflow {
1176
- (jobConfig: BatchJob): WorkflowExecutable;
1177
- (planner: Planner, ...steps: WorkflowStep[]): WorkflowExecutable;
1178
- }
1179
- declare const concurrentWorkflow: ConcurrentWorkflow;
1180
-
1181
- interface DAGWorkflow {
1182
- (definition: DAGDefinition | DAGJob, options?: DAGWorkflowOptions): WorkflowExecutable;
1183
- }
1184
- declare const dagWorkflow: DAGWorkflow;
1185
-
1186
- interface SerialWorkflow {
1187
- (jobConfig: SerialJob): WorkflowExecutable;
1188
- (...steps: WorkflowStep[]): WorkflowExecutable;
1189
- }
1190
- declare const serialWorkflow: SerialWorkflow;
1191
-
1192
- declare class Conversation {
1193
- system: string;
1194
- private _messages;
1195
- constructor(messages?: AxleMessage[]);
1196
- get messages(): AxleMessage[];
1197
- addSystem(message: string): void;
1198
- addUser(message: string): void;
1199
- addUser(parts: AxleUserMessage["content"]): void;
1200
- addAssistant(message: string): void;
1201
- addAssistant(params: Omit<AxleAssistantMessage, "role">): void;
1202
- addToolResults(input: Array<AxleToolCallResult>): void;
1203
- latest(): AxleMessage | undefined;
1204
- toString(): string;
1205
- }
1206
-
1207
- declare class ConsoleWriter implements RecorderWriter {
1208
- private tasks;
1209
- private entries;
1210
- private truncate;
1211
- private intervalId;
1212
- private spinnerInterval;
1213
- private lastRender;
1214
- private isRendering;
1215
- private inline;
1216
- constructor(options?: {
1217
- truncate?: number;
1218
- inline?: boolean;
1219
- });
1220
- private startSpinner;
1221
- private stopSpinner;
1222
- private renderTasks;
1223
- handleEvent(event: RecorderEntry): void;
1224
- destroy(): void;
1225
- }
1226
-
1227
- export { index$3 as Anthropic, Axle, AxleStopReason, ChainOfThought, ConsoleWriter, Conversation, index$2 as Gemini, Instruct, LogLevel, index$1 as Ollama, index as OpenAI, WriteToDisk, braveSearchTool, calculatorTool, concurrentWorkflow, dagWorkflow, generate, serialWorkflow, stream };
1228
- export type { AIProvider, Action, ActionContext, AxleAssistantMessage, AxleMessage, AxleToolCallMessage, AxleToolCallResult, AxleUserMessage, ContentPart, ContentPartFile, ContentPartText, ContentPartThinking, ContentPartToolCall, DAGDefinition, DAGWorkflowOptions, FileInfo, SerializedExecutionResponse, Tool, ToolDefinition, WorkflowStep };
791
+ private calculateVisibleDepth;
792
+ private formatTimestamp;
793
+ private formatDuration;
794
+ private formatIndent;
795
+ private formatSpanName;
796
+ onSpanStart(span: SpanData): void;
797
+ onSpanEnd(span: SpanData): void;
798
+ onSpanUpdate(span: SpanData): void;
799
+ onEvent(span: SpanData, event: SpanEvent): void;
800
+ onLLMStreamStart(span: SpanData): void;
801
+ onLLMStreamChunk(_span: SpanData, _chunk: string): void;
802
+ onLLMStreamEnd(span: SpanData, result: LLMResult): void;
803
+ }
804
+
805
+ export { Agent, Anthropic, AxleStopReason, Gemini, History, Instruct, OpenAI, SimpleWriter, Tracer, anthropic, braveSearchTool, calculatorTool, chatCompletions, compileInstruct, gemini, generate, generateTurn, loadFileContent, openai, parseResponse, stream };
806
+ export type { AIProvider, AgentConfig, AgentHandle, AgentResult, AxleAssistantMessage, AxleMessage, AxleToolCallMessage, AxleToolCallResult, AxleUserMessage, ContentPart, ContentPartFile, ContentPartText, ContentPartThinking, ContentPartToolCall, EventLevel, FileInfo, SimpleWriterOptions, SpanData, SpanOptions, SpanType, Tool, ToolDefinition, TraceWriter, TracingContext };