@fifthrevision/axle 0.8.1 → 0.10.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 DELETED
@@ -1,900 +0,0 @@
1
- import * as z from 'zod';
2
- import { ZodObject, z as z$1 } from 'zod';
3
-
4
- interface Stats {
5
- in: number;
6
- out: number;
7
- }
8
-
9
- interface StreamChunk {
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";
11
- id?: string;
12
- data?: any;
13
- }
14
- interface StreamStartChunk extends StreamChunk {
15
- type: "start";
16
- id: string;
17
- data: {
18
- model: string;
19
- timestamp: number;
20
- };
21
- }
22
- interface StreamCompleteChunk extends StreamChunk {
23
- type: "complete";
24
- data: {
25
- finishReason: AxleStopReason;
26
- usage: Stats;
27
- };
28
- }
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";
46
- data: {
47
- index: number;
48
- text: string;
49
- };
50
- }
51
- interface StreamTextCompleteChunk extends StreamChunk {
52
- type: "text-complete";
53
- data: {
54
- index: number;
55
- };
56
- }
57
- interface StreamThinkingStartChunk extends StreamChunk {
58
- type: "thinking-start";
59
- data: {
60
- index: number;
61
- id?: string;
62
- redacted?: boolean;
63
- signature?: string;
64
- };
65
- }
66
- interface StreamThinkingDeltaChunk extends StreamChunk {
67
- type: "thinking-delta";
68
- data: {
69
- index: number;
70
- text: string;
71
- };
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
- }
86
- interface StreamToolCallStartChunk extends StreamChunk {
87
- type: "tool-call-start";
88
- data: {
89
- index: number;
90
- id: string;
91
- name: string;
92
- };
93
- }
94
- interface StreamToolCallCompleteChunk extends StreamChunk {
95
- type: "tool-call-complete";
96
- data: {
97
- index: number;
98
- id: string;
99
- name: string;
100
- arguments: any;
101
- providerMetadata?: Record<string, unknown>;
102
- };
103
- }
104
- interface StreamInternalToolStartChunk extends StreamChunk {
105
- type: "internal-tool-start";
106
- data: {
107
- index: number;
108
- id: string;
109
- name: string;
110
- };
111
- }
112
- interface StreamInternalToolCompleteChunk extends StreamChunk {
113
- type: "internal-tool-complete";
114
- data: {
115
- index: number;
116
- id: string;
117
- name: string;
118
- output?: unknown;
119
- };
120
- }
121
- type AnyStreamChunk = StreamStartChunk | StreamCompleteChunk | StreamErrorChunk | StreamTextStartChunk | StreamTextDeltaChunk | StreamTextCompleteChunk | StreamThinkingStartChunk | StreamThinkingDeltaChunk | StreamThinkingSummaryDeltaChunk | StreamThinkingCompleteChunk | StreamToolCallStartChunk | StreamToolCallCompleteChunk | StreamInternalToolStartChunk | StreamInternalToolCompleteChunk;
122
-
123
- type SpanStatus = "ok" | "error";
124
- type EventLevel = "debug" | "info" | "warn" | "error";
125
- type SpanType = string;
126
- interface SpanEvent {
127
- name: string;
128
- timestamp: number;
129
- level: EventLevel;
130
- attributes?: Record<string, unknown>;
131
- }
132
- interface SpanData {
133
- traceId: string;
134
- spanId: string;
135
- parentSpanId?: string;
136
- name: string;
137
- type?: SpanType;
138
- startTime: number;
139
- endTime?: number;
140
- status: SpanStatus;
141
- attributes: Record<string, unknown>;
142
- events: SpanEvent[];
143
- result?: SpanResult;
144
- }
145
- interface SpanOptions {
146
- type?: SpanType;
147
- }
148
- type SpanResult = LLMResult | ToolResult;
149
- interface LLMResult {
150
- kind: "llm";
151
- model: string;
152
- request: LLMRequest;
153
- response: LLMResponse;
154
- usage?: TokenUsage;
155
- finishReason?: string;
156
- }
157
- interface LLMRequest {
158
- messages: unknown[];
159
- system?: string;
160
- tools?: unknown[];
161
- }
162
- interface LLMResponse {
163
- content: unknown;
164
- }
165
- interface TokenUsage {
166
- inputTokens?: number;
167
- outputTokens?: number;
168
- totalTokens?: number;
169
- }
170
- interface ToolResult {
171
- kind: "tool";
172
- name: string;
173
- input: unknown;
174
- output: unknown;
175
- }
176
- interface TraceWriter {
177
- onSpanStart(span: SpanData): void;
178
- onSpanUpdate?(span: SpanData): void;
179
- onSpanEnd(span: SpanData): void;
180
- onEvent?(span: SpanData, event: SpanEvent): void;
181
- onLLMStreamStart?(span: SpanData): void;
182
- onLLMStreamChunk?(span: SpanData, chunk: string): void;
183
- onLLMStreamEnd?(span: SpanData, result: LLMResult): void;
184
- flush?(): Promise<void>;
185
- }
186
- /**
187
- * Tracing context for a span. Created by Tracer.startSpan().
188
- * Can create child spans and log events within the span's scope.
189
- */
190
- interface TracingContext {
191
- startSpan(name: string, options?: SpanOptions): TracingContext;
192
- end(status?: SpanStatus): void;
193
- debug(message: string, attributes?: Record<string, unknown>): void;
194
- info(message: string, attributes?: Record<string, unknown>): void;
195
- warn(message: string, attributes?: Record<string, unknown>): void;
196
- error(message: string, attributes?: Record<string, unknown>): void;
197
- setAttribute(key: string, value: unknown): void;
198
- setAttributes(attributes: Record<string, unknown>): void;
199
- setResult(result: SpanResult): void;
200
- startLLMStream(): void;
201
- appendLLMStream(chunk: string): void;
202
- endLLMStream(result: LLMResult): void;
203
- }
204
-
205
- interface AIProvider {
206
- get name(): string;
207
- /** @internal */
208
- createGenerationRequest(model: string, params: {
209
- messages: Array<AxleMessage>;
210
- system?: string;
211
- tools?: Array<ToolDefinition>;
212
- context: {
213
- tracer?: TracingContext;
214
- };
215
- options?: {
216
- temperature?: number;
217
- top_p?: number;
218
- max_tokens?: number;
219
- frequency_penalty?: number;
220
- presence_penalty?: number;
221
- stop?: string | string[];
222
- [key: string]: any;
223
- };
224
- }): Promise<ModelResult>;
225
- /** @internal */
226
- createStreamingRequest?(model: string, params: {
227
- messages: Array<AxleMessage>;
228
- system?: string;
229
- tools?: Array<ToolDefinition>;
230
- context: {
231
- tracer?: TracingContext;
232
- };
233
- signal?: AbortSignal;
234
- options?: {
235
- temperature?: number;
236
- top_p?: number;
237
- max_tokens?: number;
238
- frequency_penalty?: number;
239
- presence_penalty?: number;
240
- stop?: string | string[];
241
- [key: string]: any;
242
- };
243
- }): AsyncGenerator<AnyStreamChunk, void, unknown>;
244
- }
245
- interface ModelResponse {
246
- type: "success";
247
- role: "assistant";
248
- id: string;
249
- model: string;
250
- text: string;
251
- content: Array<ContentPartText | ContentPartThinking | ContentPartToolCall>;
252
- finishReason: AxleStopReason;
253
- usage: Stats;
254
- raw: any;
255
- }
256
- interface ModelError {
257
- type: "error";
258
- error: {
259
- type: string;
260
- message: string;
261
- };
262
- usage?: Stats;
263
- raw?: any;
264
- }
265
- type ModelResult = ModelResponse | ModelError;
266
- declare enum AxleStopReason {
267
- Stop = "stop",
268
- Length = "length",
269
- FunctionCall = "function_call",
270
- Error = "error",
271
- Custom = "custom",
272
- Cancelled = "cancelled"
273
- }
274
-
275
- interface FileInfo {
276
- path: string;
277
- base64?: string;
278
- content?: string;
279
- mimeType: string;
280
- size: number;
281
- name: string;
282
- type: "image" | "document" | "text";
283
- }
284
- type TextFileInfo = FileInfo & {
285
- content: string;
286
- base64?: never;
287
- type: "text";
288
- };
289
- type Base64FileInfo = FileInfo & {
290
- base64: string;
291
- content?: never;
292
- type: "image" | "document";
293
- };
294
- /**
295
- * Load a file with the specified encoding or auto-detect based on file extension
296
- * @param filePath - Path to the file
297
- * @param encoding - How to load the file: "utf-8" for text, "base64" for binary, or omit for auto-detection
298
- * @returns FileInfo object with appropriate content based on encoding
299
- */
300
- declare function loadFileContent(filePath: string): Promise<FileInfo>;
301
- declare function loadFileContent(filePath: string, encoding: "utf-8"): Promise<TextFileInfo>;
302
- declare function loadFileContent(filePath: string, encoding: "base64"): Promise<Base64FileInfo>;
303
-
304
- type AxleMessage = AxleUserMessage | AxleAssistantMessage | AxleToolCallMessage;
305
- interface AxleUserMessage {
306
- role: "user";
307
- name?: string;
308
- content: string | Array<ContentPart>;
309
- }
310
- interface AxleAssistantMessage {
311
- role: "assistant";
312
- id: string;
313
- model?: string;
314
- content: Array<ContentPartText | ContentPartThinking | ContentPartToolCall | ContentPartInternalTool>;
315
- finishReason?: AxleStopReason;
316
- }
317
- interface AxleToolCallMessage {
318
- role: "tool";
319
- content: Array<AxleToolCallResult>;
320
- }
321
- type ToolResultPart = {
322
- type: "text";
323
- text: string;
324
- } | {
325
- type: "image";
326
- data: string;
327
- mimeType: string;
328
- };
329
- interface AxleToolCallResult {
330
- id: string;
331
- name: string;
332
- content: string | ToolResultPart[];
333
- isError?: boolean;
334
- }
335
- type ContentPart = ContentPartText | ContentPartFile | ContentPartToolCall | ContentPartThinking | ContentPartInternalTool;
336
- interface ContentPartText {
337
- type: "text";
338
- text: string;
339
- }
340
- interface ContentPartFile {
341
- type: "file";
342
- file: FileInfo;
343
- }
344
- interface ContentPartThinking {
345
- type: "thinking";
346
- id?: string;
347
- text: string;
348
- summary?: string;
349
- redacted?: boolean;
350
- encrypted?: string;
351
- signature?: string;
352
- }
353
- interface ContentPartToolCall {
354
- type: "tool-call";
355
- id: string;
356
- name: string;
357
- parameters: Record<string, unknown>;
358
- providerMetadata?: Record<string, unknown>;
359
- }
360
- interface ContentPartInternalTool {
361
- type: "internal-tool";
362
- id: string;
363
- name: string;
364
- input?: unknown;
365
- output?: unknown;
366
- }
367
-
368
- interface ExecutableTool<TSchema extends ZodObject<any> = ZodObject<any>> {
369
- type?: "function";
370
- name: string;
371
- description: string;
372
- schema: TSchema;
373
- execute(input: z$1.infer<TSchema>): Promise<string | ToolResultPart[]>;
374
- configure?(config: Record<string, any>): void;
375
- summarize?(input: z$1.infer<TSchema>): string;
376
- }
377
- interface ServerTool {
378
- type: "server";
379
- name: string;
380
- config?: Record<string, unknown>;
381
- }
382
- type AxleTool = ExecutableTool | ServerTool;
383
- type ToolDefinition = Pick<ExecutableTool, "name" | "description" | "schema">;
384
-
385
- interface MCPStdioConfig {
386
- transport: "stdio";
387
- name?: string;
388
- command: string;
389
- args?: string[];
390
- env?: Record<string, string>;
391
- }
392
- interface MCPHttpConfig {
393
- transport: "http";
394
- name?: string;
395
- url: string;
396
- headers?: Record<string, string>;
397
- }
398
- type MCPConfig = MCPStdioConfig | MCPHttpConfig;
399
- declare class MCP {
400
- private config;
401
- private client;
402
- private transport;
403
- private cachedMcpTools;
404
- private _connected;
405
- constructor(config: MCPConfig);
406
- get name(): string | undefined;
407
- get connected(): boolean;
408
- connect(options?: {
409
- tracer?: TracingContext;
410
- }): Promise<void>;
411
- listTools(options?: {
412
- prefix?: string;
413
- tracer?: TracingContext;
414
- }): Promise<ExecutableTool[]>;
415
- listToolDefinitions(options?: {
416
- prefix?: string;
417
- tracer?: TracingContext;
418
- }): Promise<ToolDefinition[]>;
419
- refreshTools(): Promise<ExecutableTool[]>;
420
- close(options?: {
421
- tracer?: TracingContext;
422
- }): Promise<void>;
423
- private fetchTools;
424
- private assertConnected;
425
- }
426
-
427
- declare class History {
428
- system: string;
429
- private _messages;
430
- constructor(messages?: AxleMessage[]);
431
- get messages(): AxleMessage[];
432
- addSystem(message: string): void;
433
- addUser(message: string): void;
434
- addUser(parts: AxleUserMessage["content"]): void;
435
- addAssistant(message: string): void;
436
- addAssistant(params: Omit<AxleAssistantMessage, "role">): void;
437
- addToolResults(input: Array<AxleToolCallResult>): void;
438
- add(messages: AxleMessage | AxleMessage[]): void;
439
- latest(): AxleMessage | undefined;
440
- toString(): string;
441
- }
442
-
443
- interface GenerateTurnOptions {
444
- temperature?: number;
445
- top_p?: number;
446
- max_tokens?: number;
447
- frequency_penalty?: number;
448
- presence_penalty?: number;
449
- stop?: string | string[];
450
- [key: string]: any;
451
- }
452
- interface GenerateTurnProps {
453
- provider: AIProvider;
454
- model: string;
455
- messages: Array<AxleMessage>;
456
- system?: string;
457
- tools?: Array<ToolDefinition>;
458
- tracer?: TracingContext;
459
- options?: GenerateTurnOptions;
460
- }
461
- declare function generateTurn(props: GenerateTurnProps): Promise<ModelResult>;
462
-
463
- type ToolCallResult = {
464
- type: "success";
465
- content: string | ToolResultPart[];
466
- } | {
467
- type: "error";
468
- error: {
469
- type: string;
470
- message: string;
471
- fatal?: boolean;
472
- retryable?: boolean;
473
- };
474
- };
475
- type ToolCallCallback = (name: string, parameters: Record<string, unknown>) => Promise<ToolCallResult | null | undefined>;
476
- type GenerateError = {
477
- type: "model";
478
- error: ModelError;
479
- } | {
480
- type: "tool";
481
- error: {
482
- name: string;
483
- message: string;
484
- };
485
- };
486
- type GenerateResult = {
487
- result: "success";
488
- messages: AxleMessage[];
489
- final?: AxleAssistantMessage;
490
- usage?: Stats;
491
- } | {
492
- result: "error";
493
- messages: AxleMessage[];
494
- error: GenerateError;
495
- usage?: Stats;
496
- };
497
- type StreamResult = GenerateResult | {
498
- result: "cancelled";
499
- messages: AxleMessage[];
500
- partial?: AxleAssistantMessage;
501
- usage: Stats;
502
- };
503
-
504
- type StreamEvent = {
505
- type: "text:start";
506
- index: number;
507
- } | {
508
- type: "text:delta";
509
- index: number;
510
- delta: string;
511
- accumulated: string;
512
- } | {
513
- type: "text:end";
514
- index: number;
515
- final: string;
516
- } | {
517
- type: "thinking:start";
518
- index: number;
519
- } | {
520
- type: "thinking:delta";
521
- index: number;
522
- delta: string;
523
- accumulated: string;
524
- } | {
525
- type: "thinking:end";
526
- index: number;
527
- final: string;
528
- } | {
529
- type: "tool:start";
530
- index: number;
531
- id: string;
532
- name: string;
533
- } | {
534
- type: "tool:execute";
535
- index: number;
536
- id: string;
537
- name: string;
538
- parameters: Record<string, unknown>;
539
- } | {
540
- type: "tool:complete";
541
- index: number;
542
- id: string;
543
- name: string;
544
- result: ToolCallResult | null;
545
- } | {
546
- type: "internal-tool:start";
547
- index: number;
548
- id: string;
549
- name: string;
550
- } | {
551
- type: "internal-tool:complete";
552
- index: number;
553
- id: string;
554
- name: string;
555
- output?: unknown;
556
- } | {
557
- type: "error";
558
- error: GenerateError;
559
- };
560
- type StreamEventCallback = (event: StreamEvent) => void;
561
- interface StreamOptions {
562
- provider: AIProvider;
563
- model: string;
564
- messages: Array<AxleMessage>;
565
- system?: string;
566
- tools?: Array<ToolDefinition>;
567
- serverTools?: Array<ServerTool>;
568
- onToolCall?: ToolCallCallback;
569
- maxIterations?: number;
570
- tracer?: TracingContext;
571
- options?: GenerateTurnOptions;
572
- }
573
- interface StreamHandle {
574
- on(callback: StreamEventCallback): void;
575
- cancel(): void;
576
- readonly final: Promise<StreamResult>;
577
- }
578
- declare function stream(options: StreamOptions): StreamHandle;
579
-
580
- type OutputSchema = Record<string, z.ZodTypeAny>;
581
- type ParsedSchema<T extends OutputSchema> = {
582
- [K in keyof T]: z.output<T[K]>;
583
- };
584
- declare function parseResponse<T extends OutputSchema>(rawValue: string, schema?: T): ParsedSchema<T> | string;
585
-
586
- declare class Instruct<TSchema extends OutputSchema | undefined = undefined> {
587
- prompt: string;
588
- inputs: Record<string, string>;
589
- files: Base64FileInfo[];
590
- textReferences: Array<{
591
- content: string;
592
- name?: string;
593
- }>;
594
- instructions: string[];
595
- schema: TSchema;
596
- constructor(prompt: string, schema?: TSchema);
597
- setInputs(inputs: Record<string, string>): void;
598
- addInput(name: string, value: string): void;
599
- addFile(file: FileInfo | string, options?: {
600
- name?: string;
601
- }): void;
602
- addInstructions(instruction: string): void;
603
- hasFiles(): boolean;
604
- }
605
-
606
- interface AgentConfig {
607
- provider: AIProvider;
608
- model: string;
609
- system?: string;
610
- tools?: AxleTool[];
611
- mcps?: MCP[];
612
- tracer?: TracingContext;
613
- }
614
- interface AgentResult<T = string> {
615
- response: T | null;
616
- messages: AxleMessage[];
617
- final: AxleAssistantMessage | undefined;
618
- usage: Stats;
619
- }
620
- interface AgentHandle<T = string> {
621
- cancel(): void;
622
- readonly final: Promise<AgentResult<T>>;
623
- }
624
- declare class Agent {
625
- readonly provider: AIProvider;
626
- readonly model: string;
627
- readonly history: History;
628
- readonly tracer?: TracingContext;
629
- system: string | undefined;
630
- tools: Record<string, ExecutableTool>;
631
- serverTools: ServerTool[];
632
- private mcps;
633
- private mcpToolsResolved;
634
- private eventCallbacks;
635
- constructor(config: AgentConfig);
636
- addTool(tool: AxleTool): void;
637
- addTools(tools: AxleTool[]): void;
638
- addMcp(mcp: MCP): void;
639
- addMcps(mcps: MCP[]): void;
640
- hasTools(): boolean;
641
- on(callback: StreamEventCallback): void;
642
- send(message: string): AgentHandle<string>;
643
- send(instruct: Instruct<undefined>, variables?: Record<string, string>): AgentHandle<string>;
644
- send<TSchema extends OutputSchema>(instruct: Instruct<TSchema>, variables?: Record<string, string>): AgentHandle<ParsedSchema<TSchema>>;
645
- private resolveMcpTools;
646
- private execute;
647
- }
648
-
649
- declare function compileInstruct(instruct: Instruct<any>, variables?: Record<string, string>): string;
650
-
651
- declare function anthropic(apiKey: string): AIProvider;
652
-
653
- declare const Anthropic: {
654
- readonly Models: {
655
- readonly CLAUDE_SONNET_4_6: "claude-sonnet-4-6";
656
- readonly CLAUDE_OPUS_4_6: "claude-opus-4-6";
657
- readonly CLAUDE_OPUS_4_5_20251101: "claude-opus-4-5-20251101";
658
- readonly CLAUDE_OPUS_4_5: "claude-opus-4-5-20251101";
659
- readonly CLAUDE_HAIKU_4_5_20251001: "claude-haiku-4-5-20251001";
660
- readonly CLAUDE_HAIKU_4_5: "claude-haiku-4-5-20251001";
661
- readonly CLAUDE_SONNET_4_5_20250929: "claude-sonnet-4-5-20250929";
662
- readonly CLAUDE_SONNET_4_5: "claude-sonnet-4-5-20250929";
663
- readonly CLAUDE_OPUS_4_1_20250805: "claude-opus-4-1-20250805";
664
- readonly CLAUDE_OPUS_4_1: "claude-opus-4-1-20250805";
665
- readonly CLAUDE_OPUS_4_20250514: "claude-opus-4-20250514";
666
- readonly CLAUDE_OPUS_4: "claude-opus-4-20250514";
667
- readonly CLAUDE_SONNET_4_20250514: "claude-sonnet-4-20250514";
668
- readonly CLAUDE_SONNET_4: "claude-sonnet-4-20250514";
669
- readonly CLAUDE_3_HAIKU_20240307: "claude-3-haiku-20240307";
670
- readonly CLAUDE_3_HAIKU: "claude-3-haiku-20240307";
671
- };
672
- readonly DefaultModel: "claude-haiku-4-5-20251001";
673
- };
674
-
675
- declare function chatCompletions(baseUrl: string, apiKey?: string): AIProvider;
676
-
677
- declare function gemini(apiKey: string): AIProvider;
678
-
679
- declare const Gemini: {
680
- readonly Models: {
681
- readonly GEMINI_3_1_PRO_PREVIEW: "gemini-3.1-pro-preview";
682
- readonly GEMINI_3_1_PRO_PREVIEW_CUSTOMTOOLS: "gemini-3.1-pro-preview-customtools";
683
- readonly GEMINI_3_PRO_PREVIEW: "gemini-3-pro-preview";
684
- readonly GEMINI_3_FLASH_PREVIEW: "gemini-3-flash-preview";
685
- readonly GEMINI_2_5_PRO: "gemini-2.5-pro";
686
- readonly GEMINI_2_5_FLASH: "gemini-2.5-flash";
687
- readonly GEMINI_2_5_FLASH_LITE: "gemini-2.5-flash-lite";
688
- readonly GEMINI_2_5_FLASH_LITE_PREVIEW_09_2025: "gemini-2.5-flash-lite-preview-09-2025";
689
- readonly GEMINI_2_0_FLASH: "gemini-2.0-flash";
690
- readonly GEMINI_2_0_FLASH_001: "gemini-2.0-flash-001";
691
- readonly GEMINI_2_0_FLASH_LITE: "gemini-2.0-flash-lite";
692
- readonly GEMINI_2_0_FLASH_LITE_001: "gemini-2.0-flash-lite-001";
693
- readonly GEMINI_FLASH_LATEST: "gemini-flash-latest";
694
- readonly GEMINI_FLASH_LITE_LATEST: "gemini-flash-lite-latest";
695
- readonly GEMINI_PRO_LATEST: "gemini-pro-latest";
696
- readonly GEMMA_3_27B_IT: "gemma-3-27b-it";
697
- readonly GEMMA_3_12B_IT: "gemma-3-12b-it";
698
- readonly GEMMA_3_4B_IT: "gemma-3-4b-it";
699
- readonly GEMMA_3_1B_IT: "gemma-3-1b-it";
700
- readonly GEMMA_3N_E4B_IT: "gemma-3n-e4b-it";
701
- readonly GEMMA_3N_E2B_IT: "gemma-3n-e2b-it";
702
- };
703
- readonly DefaultModel: "gemini-3-flash-preview";
704
- };
705
-
706
- interface GenerateOptions {
707
- provider: AIProvider;
708
- model: string;
709
- messages: Array<AxleMessage>;
710
- system?: string;
711
- tools?: Array<ToolDefinition>;
712
- onToolCall: ToolCallCallback;
713
- maxIterations?: number;
714
- tracer?: TracingContext;
715
- options?: GenerateTurnOptions;
716
- }
717
- declare function generate(options: GenerateOptions): Promise<GenerateResult>;
718
-
719
- declare function openai(apiKey: string): AIProvider;
720
-
721
- declare const OpenAI: {
722
- readonly Models: {
723
- readonly GPT_5_2: "gpt-5.2";
724
- readonly GPT_5_2_2025_12_11: "gpt-5.2-2025-12-11";
725
- readonly GPT_5_2_CHAT_LATEST: "gpt-5.2-chat-latest";
726
- readonly GPT_5_2_PRO: "gpt-5.2-pro";
727
- readonly GPT_5_2_PRO_2025_12_11: "gpt-5.2-pro-2025-12-11";
728
- readonly GPT_5_2_CODEX: "gpt-5.2-codex";
729
- readonly GPT_5_1: "gpt-5.1";
730
- readonly GPT_5_1_2025_11_13: "gpt-5.1-2025-11-13";
731
- readonly GPT_5_1_CHAT_LATEST: "gpt-5.1-chat-latest";
732
- readonly GPT_5_1_CODEX: "gpt-5.1-codex";
733
- readonly GPT_5_1_CODEX_MAX: "gpt-5.1-codex-max";
734
- readonly GPT_5_1_CODEX_MINI: "gpt-5.1-codex-mini";
735
- readonly GPT_5: "gpt-5";
736
- readonly GPT_5_2025_08_07: "gpt-5-2025-08-07";
737
- readonly GPT_5_CHAT_LATEST: "gpt-5-chat-latest";
738
- readonly GPT_5_CODEX: "gpt-5-codex";
739
- readonly GPT_5_MINI: "gpt-5-mini";
740
- readonly GPT_5_MINI_2025_08_07: "gpt-5-mini-2025-08-07";
741
- readonly GPT_5_NANO: "gpt-5-nano";
742
- readonly GPT_5_NANO_2025_08_07: "gpt-5-nano-2025-08-07";
743
- readonly GPT_5_PRO: "gpt-5-pro";
744
- readonly GPT_5_PRO_2025_10_06: "gpt-5-pro-2025-10-06";
745
- readonly GPT_5_SEARCH_API: "gpt-5-search-api";
746
- readonly GPT_5_SEARCH_API_2025_10_14: "gpt-5-search-api-2025-10-14";
747
- readonly GPT_4_1: "gpt-4.1";
748
- readonly GPT_4_1_2025_04_14: "gpt-4.1-2025-04-14";
749
- readonly GPT_4_1_MINI: "gpt-4.1-mini";
750
- readonly GPT_4_1_MINI_2025_04_14: "gpt-4.1-mini-2025-04-14";
751
- readonly GPT_4_1_NANO: "gpt-4.1-nano";
752
- readonly GPT_4_1_NANO_2025_04_14: "gpt-4.1-nano-2025-04-14";
753
- readonly GPT_4O: "gpt-4o";
754
- readonly GPT_4O_2024_11_20: "gpt-4o-2024-11-20";
755
- readonly GPT_4O_2024_08_06: "gpt-4o-2024-08-06";
756
- readonly GPT_4O_2024_05_13: "gpt-4o-2024-05-13";
757
- readonly GPT_4O_MINI: "gpt-4o-mini";
758
- readonly GPT_4O_MINI_2024_07_18: "gpt-4o-mini-2024-07-18";
759
- readonly GPT_4O_SEARCH_PREVIEW: "gpt-4o-search-preview";
760
- readonly GPT_4O_SEARCH_PREVIEW_2025_03_11: "gpt-4o-search-preview-2025-03-11";
761
- readonly GPT_4O_MINI_SEARCH_PREVIEW: "gpt-4o-mini-search-preview";
762
- readonly GPT_4O_MINI_SEARCH_PREVIEW_2025_03_11: "gpt-4o-mini-search-preview-2025-03-11";
763
- readonly GPT_4_TURBO: "gpt-4-turbo";
764
- readonly GPT_4_TURBO_2024_04_09: "gpt-4-turbo-2024-04-09";
765
- readonly O4_MINI: "o4-mini";
766
- readonly O4_MINI_2025_04_16: "o4-mini-2025-04-16";
767
- readonly O3: "o3";
768
- readonly O3_2025_04_16: "o3-2025-04-16";
769
- readonly O3_PRO: "o3-pro";
770
- readonly O3_PRO_2025_06_10: "o3-pro-2025-06-10";
771
- readonly O3_MINI: "o3-mini";
772
- readonly O3_MINI_2025_01_31: "o3-mini-2025-01-31";
773
- readonly O1: "o1";
774
- readonly O1_2024_12_17: "o1-2024-12-17";
775
- readonly O1_PRO: "o1-pro";
776
- readonly O1_PRO_2025_03_19: "o1-pro-2025-03-19";
777
- };
778
- readonly DefaultModel: "gpt-5-mini";
779
- };
780
-
781
- declare const BraveProviderConfigSchema: z$1.ZodObject<{
782
- "api-key": z$1.ZodString;
783
- rateLimit: z$1.ZodOptional<z$1.ZodNumber>;
784
- }, z$1.core.$strip>;
785
- type BraveProviderConfig = z$1.infer<typeof BraveProviderConfigSchema>;
786
-
787
- declare const braveSearchSchema: z.ZodObject<{
788
- searchTerm: z.ZodString;
789
- }, z.core.$strip>;
790
- declare class BraveSearchTool implements ExecutableTool<typeof braveSearchSchema> {
791
- name: string;
792
- description: string;
793
- schema: z.ZodObject<{
794
- searchTerm: z.ZodString;
795
- }, z.core.$strip>;
796
- apiKey: string;
797
- throttle: number | undefined;
798
- lastExecTime: number;
799
- constructor(config?: BraveProviderConfig);
800
- configure(config: BraveProviderConfig): void;
801
- execute(params: z.infer<typeof braveSearchSchema>): Promise<string>;
802
- }
803
- declare const braveSearchTool: BraveSearchTool;
804
-
805
- declare const calculatorSchema: z$1.ZodObject<{
806
- operation: z$1.ZodEnum<{
807
- add: "add";
808
- subtract: "subtract";
809
- multiply: "multiply";
810
- divide: "divide";
811
- }>;
812
- a: z$1.ZodNumber;
813
- b: z$1.ZodNumber;
814
- }, z$1.core.$strip>;
815
- declare const calculatorTool: ExecutableTool<typeof calculatorSchema>;
816
-
817
- /**
818
- * Root tracer that manages writers and creates spans.
819
- * Use startSpan() to create TracingContext instances for hierarchical tracing.
820
- * All logging happens within spans - the Tracer itself is just configuration and factory.
821
- */
822
- declare class Tracer {
823
- private writers;
824
- private _minLevel;
825
- get minLevel(): EventLevel;
826
- set minLevel(level: EventLevel);
827
- addWriter(writer: TraceWriter): void;
828
- removeWriter(writer: TraceWriter): void;
829
- startSpan(name: string, options?: SpanOptions): TracingContext;
830
- flush(): Promise<void>;
831
- /** @internal */
832
- _notifySpanEnd(spanData: SpanData): void;
833
- /** @internal */
834
- _notifySpanUpdate(spanData: SpanData): void;
835
- /** @internal */
836
- _notifyEvent(spanData: SpanData, event: SpanEvent): void;
837
- /** @internal */
838
- _notifySpanStart(spanData: SpanData): void;
839
- /** @internal */
840
- _notifyLLMStreamStart(spanData: SpanData): void;
841
- /** @internal */
842
- _notifyLLMStreamChunk(spanData: SpanData, chunk: string): void;
843
- /** @internal */
844
- _notifyLLMStreamEnd(spanData: SpanData, result: LLMResult): void;
845
- /** @internal */
846
- _shouldLog(level: EventLevel): boolean;
847
- }
848
-
849
- interface SimpleWriterOptions {
850
- /** Minimum event level to display (default: "info") */
851
- minLevel?: EventLevel;
852
- /** Show internal spans - typically enabled via --debug flag (default: false) */
853
- showInternal?: boolean;
854
- /** Show timestamps (default: true) */
855
- showTimestamp?: boolean;
856
- /** Show duration on span end (default: true) */
857
- showDuration?: boolean;
858
- /** Render markdown in event messages that have markdown: true attribute (default: false) */
859
- markdown?: boolean;
860
- /** Custom output function (default: console.log) */
861
- output?: (line: string) => void;
862
- }
863
- declare class SimpleWriter implements TraceWriter {
864
- private minLevel;
865
- private showInternal;
866
- private showTimestamp;
867
- private showDuration;
868
- private markdown;
869
- private output;
870
- private spans;
871
- private visibleDepths;
872
- constructor(options?: SimpleWriterOptions);
873
- private shouldShowEvent;
874
- private isSpanVisible;
875
- /**
876
- * Find the nearest visible ancestor span for a given span.
877
- * Returns null if no visible ancestor exists (root level).
878
- */
879
- private findVisibleAncestor;
880
- /**
881
- * Calculate the visible depth for a span.
882
- * Only counts visible ancestors in the depth.
883
- */
884
- private calculateVisibleDepth;
885
- private formatTimestamp;
886
- private formatDuration;
887
- private formatIndent;
888
- private formatSpanName;
889
- private renderMarkdown;
890
- onSpanStart(span: SpanData): void;
891
- onSpanEnd(span: SpanData): void;
892
- onSpanUpdate(span: SpanData): void;
893
- onEvent(span: SpanData, event: SpanEvent): void;
894
- onLLMStreamStart(span: SpanData): void;
895
- onLLMStreamChunk(_span: SpanData, _chunk: string): void;
896
- onLLMStreamEnd(span: SpanData, result: LLMResult): void;
897
- }
898
-
899
- export { Agent, Anthropic, AxleStopReason, Gemini, History, Instruct, MCP, OpenAI, SimpleWriter, Tracer, anthropic, braveSearchTool, calculatorTool, chatCompletions, compileInstruct, gemini, generate, generateTurn, loadFileContent, openai, parseResponse, stream };
900
- export type { AIProvider, AgentConfig, AgentHandle, AgentResult, AxleAssistantMessage, AxleMessage, AxleTool, AxleToolCallMessage, AxleToolCallResult, AxleUserMessage, ContentPart, ContentPartFile, ContentPartText, ContentPartThinking, ContentPartToolCall, EventLevel, ExecutableTool, FileInfo, MCPConfig, MCPHttpConfig, MCPStdioConfig, ServerTool, SimpleWriterOptions, SpanData, SpanOptions, SpanType, StreamEvent, StreamEventCallback, ToolDefinition, ToolResultPart, TraceWriter, TracingContext };