@axlsdk/axl 0.4.0 → 0.5.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/README.md +26 -0
- package/dist/index.cjs +144 -10
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +173 -98
- package/dist/index.d.ts +173 -98
- package/dist/index.js +144 -10
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -2,6 +2,125 @@ import { z, ZodError } from 'zod';
|
|
|
2
2
|
import { EventEmitter } from 'node:events';
|
|
3
3
|
import { Readable } from 'node:stream';
|
|
4
4
|
|
|
5
|
+
/**
|
|
6
|
+
* Tool definition in OpenAI-compatible format.
|
|
7
|
+
* All providers normalize to this format internally.
|
|
8
|
+
*/
|
|
9
|
+
type ToolDefinition = {
|
|
10
|
+
type: 'function';
|
|
11
|
+
function: {
|
|
12
|
+
name: string;
|
|
13
|
+
description: string;
|
|
14
|
+
parameters: unknown;
|
|
15
|
+
strict?: boolean;
|
|
16
|
+
};
|
|
17
|
+
};
|
|
18
|
+
/**
|
|
19
|
+
* Unified thinking/reasoning level that works across all providers.
|
|
20
|
+
*
|
|
21
|
+
* Simple form (`'low' | 'medium' | 'high' | 'max'`) is portable across all providers:
|
|
22
|
+
* - **OpenAI** (o1/o3/o4-mini): maps to `reasoning_effort` (`'max'` → `'xhigh'`)
|
|
23
|
+
* - **OpenAI Responses**: maps to `reasoning.effort` (`'max'` → `'xhigh'`)
|
|
24
|
+
* - **Anthropic** (4.6): maps to adaptive mode + `output_config.effort`
|
|
25
|
+
* - **Anthropic** (older): maps to `thinking.budget_tokens` (`'max'` → `32000`)
|
|
26
|
+
* - **Gemini** (2.5+): maps to `generationConfig.thinkingConfig.thinkingBudget` (`'max'` → `24576`)
|
|
27
|
+
*
|
|
28
|
+
* Budget form (`{ budgetTokens: number }`) gives explicit control over thinking tokens.
|
|
29
|
+
* For OpenAI, budget is mapped to the nearest effort level.
|
|
30
|
+
*/
|
|
31
|
+
type Thinking = 'low' | 'medium' | 'high' | 'max' | {
|
|
32
|
+
budgetTokens: number;
|
|
33
|
+
};
|
|
34
|
+
/**
|
|
35
|
+
* Reasoning effort level for OpenAI reasoning models.
|
|
36
|
+
*
|
|
37
|
+
* This is a low-level, OpenAI-specific escape hatch. Prefer `thinking` for cross-provider use.
|
|
38
|
+
*
|
|
39
|
+
* Supported values:
|
|
40
|
+
* - **OpenAI** (o1/o3/o4-mini): all values — `'none'`, `'minimal'`, `'low'`, `'medium'`, `'high'`, `'xhigh'`
|
|
41
|
+
* - **OpenAI Responses**: all values (via `reasoning.effort`)
|
|
42
|
+
* - **Anthropic**: not supported
|
|
43
|
+
* - **Gemini**: not supported
|
|
44
|
+
*/
|
|
45
|
+
type ReasoningEffort = 'none' | 'minimal' | 'low' | 'medium' | 'high' | 'xhigh';
|
|
46
|
+
/** Tool choice strategy for LLM calls. */
|
|
47
|
+
type ToolChoice = 'auto' | 'none' | 'required' | {
|
|
48
|
+
type: 'function';
|
|
49
|
+
function: {
|
|
50
|
+
name: string;
|
|
51
|
+
};
|
|
52
|
+
};
|
|
53
|
+
/**
|
|
54
|
+
* Options passed to provider chat/stream calls.
|
|
55
|
+
*/
|
|
56
|
+
type ChatOptions = {
|
|
57
|
+
model: string;
|
|
58
|
+
temperature?: number;
|
|
59
|
+
tools?: ToolDefinition[];
|
|
60
|
+
maxTokens?: number;
|
|
61
|
+
responseFormat?: ResponseFormat;
|
|
62
|
+
stop?: string[];
|
|
63
|
+
signal?: AbortSignal;
|
|
64
|
+
thinking?: Thinking;
|
|
65
|
+
reasoningEffort?: ReasoningEffort;
|
|
66
|
+
toolChoice?: ToolChoice;
|
|
67
|
+
};
|
|
68
|
+
/**
|
|
69
|
+
* Response format for structured output (JSON mode).
|
|
70
|
+
*/
|
|
71
|
+
type ResponseFormat = {
|
|
72
|
+
type: 'text';
|
|
73
|
+
} | {
|
|
74
|
+
type: 'json_object';
|
|
75
|
+
} | {
|
|
76
|
+
type: 'json_schema';
|
|
77
|
+
json_schema: {
|
|
78
|
+
name: string;
|
|
79
|
+
strict?: boolean;
|
|
80
|
+
schema: unknown;
|
|
81
|
+
};
|
|
82
|
+
};
|
|
83
|
+
/**
|
|
84
|
+
* Chunks emitted during streaming.
|
|
85
|
+
*/
|
|
86
|
+
type StreamChunk = {
|
|
87
|
+
type: 'text_delta';
|
|
88
|
+
content: string;
|
|
89
|
+
} | {
|
|
90
|
+
type: 'tool_call_delta';
|
|
91
|
+
id: string;
|
|
92
|
+
name?: string;
|
|
93
|
+
arguments?: string;
|
|
94
|
+
} | {
|
|
95
|
+
type: 'done';
|
|
96
|
+
usage?: {
|
|
97
|
+
prompt_tokens: number;
|
|
98
|
+
completion_tokens: number;
|
|
99
|
+
total_tokens: number;
|
|
100
|
+
reasoning_tokens?: number;
|
|
101
|
+
cached_tokens?: number;
|
|
102
|
+
};
|
|
103
|
+
};
|
|
104
|
+
/**
|
|
105
|
+
* Core provider interface. Every LLM adapter must implement this.
|
|
106
|
+
*/
|
|
107
|
+
interface Provider {
|
|
108
|
+
/** Human-readable name for the provider (e.g. "openai", "anthropic") */
|
|
109
|
+
readonly name?: string;
|
|
110
|
+
/**
|
|
111
|
+
* Send a chat completion request and return the full response.
|
|
112
|
+
*/
|
|
113
|
+
chat(messages: ChatMessage[], options: ChatOptions): Promise<ProviderResponse>;
|
|
114
|
+
/**
|
|
115
|
+
* Stream a chat completion, yielding chunks as they arrive.
|
|
116
|
+
*/
|
|
117
|
+
stream(messages: ChatMessage[], options: ChatOptions): AsyncGenerator<StreamChunk>;
|
|
118
|
+
}
|
|
119
|
+
/**
|
|
120
|
+
* Alias for Provider. Used for backward compatibility with index.ts exports.
|
|
121
|
+
*/
|
|
122
|
+
type ProviderAdapter = Provider;
|
|
123
|
+
|
|
5
124
|
/** Result type for concurrent operations (spawn, map) */
|
|
6
125
|
type Result<T> = {
|
|
7
126
|
ok: true;
|
|
@@ -64,6 +183,18 @@ type AskOptions<T = unknown> = {
|
|
|
64
183
|
retries?: number;
|
|
65
184
|
/** Per-call metadata passed to dynamic model/system selector functions. */
|
|
66
185
|
metadata?: Record<string, unknown>;
|
|
186
|
+
/** Override temperature for this call. */
|
|
187
|
+
temperature?: number;
|
|
188
|
+
/** Override max tokens for this call (default: 4096). */
|
|
189
|
+
maxTokens?: number;
|
|
190
|
+
/** Thinking level — portable across all providers. Prefer this over `reasoningEffort`. */
|
|
191
|
+
thinking?: Thinking;
|
|
192
|
+
/** OpenAI-specific reasoning effort (escape hatch). Overridden by `thinking` if both are set. */
|
|
193
|
+
reasoningEffort?: ReasoningEffort;
|
|
194
|
+
/** Tool choice strategy for this call. */
|
|
195
|
+
toolChoice?: ToolChoice;
|
|
196
|
+
/** Stop sequences for this call. */
|
|
197
|
+
stop?: string[];
|
|
67
198
|
};
|
|
68
199
|
/** Race options */
|
|
69
200
|
type RaceOptions<T = unknown> = {
|
|
@@ -173,6 +304,22 @@ type HandoffRecord = {
|
|
|
173
304
|
timestamp: number;
|
|
174
305
|
duration?: number;
|
|
175
306
|
};
|
|
307
|
+
/** Information about a completed agent call, emitted via onAgentCallComplete. */
|
|
308
|
+
type AgentCallInfo = {
|
|
309
|
+
agent: string;
|
|
310
|
+
prompt: string;
|
|
311
|
+
response: string;
|
|
312
|
+
model: string;
|
|
313
|
+
cost: number;
|
|
314
|
+
duration: number;
|
|
315
|
+
promptVersion?: string;
|
|
316
|
+
temperature?: number;
|
|
317
|
+
maxTokens?: number;
|
|
318
|
+
thinking?: Thinking;
|
|
319
|
+
reasoningEffort?: ReasoningEffort;
|
|
320
|
+
toolChoice?: ToolChoice;
|
|
321
|
+
stop?: string[];
|
|
322
|
+
};
|
|
176
323
|
/** Chat message types for provider communication */
|
|
177
324
|
type ChatRole = 'system' | 'user' | 'assistant' | 'tool';
|
|
178
325
|
type ChatMessage = {
|
|
@@ -225,6 +372,11 @@ type AgentConfig = {
|
|
|
225
372
|
mcp?: string[];
|
|
226
373
|
mcpTools?: string[];
|
|
227
374
|
temperature?: number;
|
|
375
|
+
maxTokens?: number;
|
|
376
|
+
thinking?: Thinking;
|
|
377
|
+
reasoningEffort?: ReasoningEffort;
|
|
378
|
+
toolChoice?: ToolChoice;
|
|
379
|
+
stop?: string[];
|
|
228
380
|
maxTurns?: number;
|
|
229
381
|
timeout?: string;
|
|
230
382
|
maxContext?: number;
|
|
@@ -254,94 +406,6 @@ type Agent = {
|
|
|
254
406
|
*/
|
|
255
407
|
declare function agent(config: AgentConfig): Agent;
|
|
256
408
|
|
|
257
|
-
/**
|
|
258
|
-
* Tool definition in OpenAI-compatible format.
|
|
259
|
-
* All providers normalize to this format internally.
|
|
260
|
-
*/
|
|
261
|
-
type ToolDefinition = {
|
|
262
|
-
type: 'function';
|
|
263
|
-
function: {
|
|
264
|
-
name: string;
|
|
265
|
-
description: string;
|
|
266
|
-
parameters: unknown;
|
|
267
|
-
strict?: boolean;
|
|
268
|
-
};
|
|
269
|
-
};
|
|
270
|
-
/**
|
|
271
|
-
* Options passed to provider chat/stream calls.
|
|
272
|
-
*/
|
|
273
|
-
type ChatOptions = {
|
|
274
|
-
model: string;
|
|
275
|
-
temperature?: number;
|
|
276
|
-
tools?: ToolDefinition[];
|
|
277
|
-
maxTokens?: number;
|
|
278
|
-
responseFormat?: ResponseFormat;
|
|
279
|
-
stop?: string[];
|
|
280
|
-
signal?: AbortSignal;
|
|
281
|
-
reasoningEffort?: 'low' | 'medium' | 'high';
|
|
282
|
-
toolChoice?: 'auto' | 'none' | 'required' | {
|
|
283
|
-
type: 'function';
|
|
284
|
-
function: {
|
|
285
|
-
name: string;
|
|
286
|
-
};
|
|
287
|
-
};
|
|
288
|
-
};
|
|
289
|
-
/**
|
|
290
|
-
* Response format for structured output (JSON mode).
|
|
291
|
-
*/
|
|
292
|
-
type ResponseFormat = {
|
|
293
|
-
type: 'text';
|
|
294
|
-
} | {
|
|
295
|
-
type: 'json_object';
|
|
296
|
-
} | {
|
|
297
|
-
type: 'json_schema';
|
|
298
|
-
json_schema: {
|
|
299
|
-
name: string;
|
|
300
|
-
strict?: boolean;
|
|
301
|
-
schema: unknown;
|
|
302
|
-
};
|
|
303
|
-
};
|
|
304
|
-
/**
|
|
305
|
-
* Chunks emitted during streaming.
|
|
306
|
-
*/
|
|
307
|
-
type StreamChunk = {
|
|
308
|
-
type: 'text_delta';
|
|
309
|
-
content: string;
|
|
310
|
-
} | {
|
|
311
|
-
type: 'tool_call_delta';
|
|
312
|
-
id: string;
|
|
313
|
-
name?: string;
|
|
314
|
-
arguments?: string;
|
|
315
|
-
} | {
|
|
316
|
-
type: 'done';
|
|
317
|
-
usage?: {
|
|
318
|
-
prompt_tokens: number;
|
|
319
|
-
completion_tokens: number;
|
|
320
|
-
total_tokens: number;
|
|
321
|
-
reasoning_tokens?: number;
|
|
322
|
-
cached_tokens?: number;
|
|
323
|
-
};
|
|
324
|
-
};
|
|
325
|
-
/**
|
|
326
|
-
* Core provider interface. Every LLM adapter must implement this.
|
|
327
|
-
*/
|
|
328
|
-
interface Provider {
|
|
329
|
-
/** Human-readable name for the provider (e.g. "openai", "anthropic") */
|
|
330
|
-
readonly name?: string;
|
|
331
|
-
/**
|
|
332
|
-
* Send a chat completion request and return the full response.
|
|
333
|
-
*/
|
|
334
|
-
chat(messages: ChatMessage[], options: ChatOptions): Promise<ProviderResponse>;
|
|
335
|
-
/**
|
|
336
|
-
* Stream a chat completion, yielding chunks as they arrive.
|
|
337
|
-
*/
|
|
338
|
-
stream(messages: ChatMessage[], options: ChatOptions): AsyncGenerator<StreamChunk>;
|
|
339
|
-
}
|
|
340
|
-
/**
|
|
341
|
-
* Alias for Provider. Used for backward compatibility with index.ts exports.
|
|
342
|
-
*/
|
|
343
|
-
type ProviderAdapter = Provider;
|
|
344
|
-
|
|
345
409
|
/** Configuration for OpenTelemetry integration. */
|
|
346
410
|
type TelemetryConfig = {
|
|
347
411
|
/** Whether telemetry is enabled. Defaults to false. */
|
|
@@ -799,15 +863,7 @@ type WorkflowContextInit = {
|
|
|
799
863
|
model: string;
|
|
800
864
|
}) => void;
|
|
801
865
|
/** Callback fired after each ctx.ask() completes (once per ask invocation). */
|
|
802
|
-
onAgentCallComplete?: (call:
|
|
803
|
-
agent: string;
|
|
804
|
-
prompt: string;
|
|
805
|
-
response: string;
|
|
806
|
-
model: string;
|
|
807
|
-
cost: number;
|
|
808
|
-
duration: number;
|
|
809
|
-
promptVersion?: string;
|
|
810
|
-
}) => void;
|
|
866
|
+
onAgentCallComplete?: (call: AgentCallInfo) => void;
|
|
811
867
|
};
|
|
812
868
|
/**
|
|
813
869
|
* The central coordination object for all Axl primitives.
|
|
@@ -1377,6 +1433,16 @@ declare class AnthropicProvider implements Provider {
|
|
|
1377
1433
|
* Map an OpenAI-format ToolDefinition to Anthropic's tool format.
|
|
1378
1434
|
*/
|
|
1379
1435
|
private mapToolDefinition;
|
|
1436
|
+
/**
|
|
1437
|
+
* Map Axl's ToolChoice to Anthropic's tool_choice format.
|
|
1438
|
+
*
|
|
1439
|
+
* Axl (OpenAI format) → Anthropic format
|
|
1440
|
+
* 'auto' → { type: 'auto' }
|
|
1441
|
+
* 'none' → { type: 'none' }
|
|
1442
|
+
* 'required' → { type: 'any' }
|
|
1443
|
+
* { type:'function', function: { name } } → { type: 'tool', name }
|
|
1444
|
+
*/
|
|
1445
|
+
private mapToolChoice;
|
|
1380
1446
|
private parseResponse;
|
|
1381
1447
|
private parseSSEStream;
|
|
1382
1448
|
}
|
|
@@ -1427,6 +1493,15 @@ declare class GeminiProvider implements Provider {
|
|
|
1427
1493
|
* Gemini requires alternating user/model turns.
|
|
1428
1494
|
*/
|
|
1429
1495
|
private mergeConsecutiveRoles;
|
|
1496
|
+
/**
|
|
1497
|
+
* Map Axl's ToolChoice to Gemini's functionCallingConfig format.
|
|
1498
|
+
*
|
|
1499
|
+
* - 'auto' → { mode: 'AUTO' }
|
|
1500
|
+
* - 'none' → { mode: 'NONE' }
|
|
1501
|
+
* - 'required' → { mode: 'ANY' }
|
|
1502
|
+
* - { type: 'function', function: { name } } → { mode: 'ANY', allowedFunctionNames: [name] }
|
|
1503
|
+
*/
|
|
1504
|
+
private mapToolChoice;
|
|
1430
1505
|
private mapToolDefinition;
|
|
1431
1506
|
private parseResponse;
|
|
1432
1507
|
private parseSSEStream;
|
|
@@ -1630,4 +1705,4 @@ declare class NoopSpanManager implements SpanManager {
|
|
|
1630
1705
|
*/
|
|
1631
1706
|
declare function createSpanManager(config?: TelemetryConfig): Promise<SpanManager>;
|
|
1632
1707
|
|
|
1633
|
-
export { type Agent, type AgentConfig, AnthropicProvider, type AskOptions, type AwaitHumanOptions, type AxlConfig, AxlError, AxlRuntime, AxlStream, BudgetExceededError, type BudgetOptions, type BudgetResult, type ChatMessage, type ChatOptions, type Embedder, type ExecutionInfo, type ExecutionState, GeminiProvider, type GuardrailBlockHandler, GuardrailError, type GuardrailResult, type GuardrailsConfig, type HandoffDescriptor, type HandoffRecord, type HumanDecision, InMemoryVectorStore, type InputGuardrail, type MapOptions, MaxTurnsError, McpManager, type McpServer, type McpServerConfig, type McpToolDefinition, type McpToolResult, type MemoryConfig, MemoryManager, MemoryStore, NoConsensus, NoopSpanManager, OpenAIEmbedder, OpenAIProvider, OpenAIResponsesProvider, type OutputGuardrail, type PendingDecision, type Provider, type ProviderAdapter, ProviderRegistry, type ProviderResponse, QuorumNotMet, type RaceOptions, type RecallOptions, RedisStore, type RememberOptions, type Result, type RetryPolicy, SQLiteStore, Session, type SessionOptions, type SpanHandle, type SpanManager, type SpawnOptions, SqliteVectorStore, type StateStore, type StreamChunk, type StreamEvent, type TelemetryConfig, TimeoutError, type Tool, type ToolCallMessage, type ToolConfig, ToolDenied, type ToolHooks, type TraceEvent, type VectorEntry, type VectorResult, type VectorStore, VerifyError, type VerifyOptions, type VoteOptions, type Workflow, type WorkflowConfig, WorkflowContext, type WorkflowContextInit, agent, createSpanManager, defineConfig, tool, workflow, zodToJsonSchema };
|
|
1708
|
+
export { type Agent, type AgentCallInfo, type AgentConfig, AnthropicProvider, type AskOptions, type AwaitHumanOptions, type AxlConfig, AxlError, AxlRuntime, AxlStream, BudgetExceededError, type BudgetOptions, type BudgetResult, type ChatMessage, type ChatOptions, type Embedder, type ExecutionInfo, type ExecutionState, GeminiProvider, type GuardrailBlockHandler, GuardrailError, type GuardrailResult, type GuardrailsConfig, type HandoffDescriptor, type HandoffRecord, type HumanDecision, InMemoryVectorStore, type InputGuardrail, type MapOptions, MaxTurnsError, McpManager, type McpServer, type McpServerConfig, type McpToolDefinition, type McpToolResult, type MemoryConfig, MemoryManager, MemoryStore, NoConsensus, NoopSpanManager, OpenAIEmbedder, OpenAIProvider, OpenAIResponsesProvider, type OutputGuardrail, type PendingDecision, type Provider, type ProviderAdapter, ProviderRegistry, type ProviderResponse, QuorumNotMet, type RaceOptions, type ReasoningEffort, type RecallOptions, RedisStore, type RememberOptions, type Result, type RetryPolicy, SQLiteStore, Session, type SessionOptions, type SpanHandle, type SpanManager, type SpawnOptions, SqliteVectorStore, type StateStore, type StreamChunk, type StreamEvent, type TelemetryConfig, type Thinking, TimeoutError, type Tool, type ToolCallMessage, type ToolChoice, type ToolConfig, ToolDenied, type ToolHooks, type TraceEvent, type VectorEntry, type VectorResult, type VectorStore, VerifyError, type VerifyOptions, type VoteOptions, type Workflow, type WorkflowConfig, WorkflowContext, type WorkflowContextInit, agent, createSpanManager, defineConfig, tool, workflow, zodToJsonSchema };
|
package/dist/index.d.ts
CHANGED
|
@@ -2,6 +2,125 @@ import { z, ZodError } from 'zod';
|
|
|
2
2
|
import { EventEmitter } from 'node:events';
|
|
3
3
|
import { Readable } from 'node:stream';
|
|
4
4
|
|
|
5
|
+
/**
|
|
6
|
+
* Tool definition in OpenAI-compatible format.
|
|
7
|
+
* All providers normalize to this format internally.
|
|
8
|
+
*/
|
|
9
|
+
type ToolDefinition = {
|
|
10
|
+
type: 'function';
|
|
11
|
+
function: {
|
|
12
|
+
name: string;
|
|
13
|
+
description: string;
|
|
14
|
+
parameters: unknown;
|
|
15
|
+
strict?: boolean;
|
|
16
|
+
};
|
|
17
|
+
};
|
|
18
|
+
/**
|
|
19
|
+
* Unified thinking/reasoning level that works across all providers.
|
|
20
|
+
*
|
|
21
|
+
* Simple form (`'low' | 'medium' | 'high' | 'max'`) is portable across all providers:
|
|
22
|
+
* - **OpenAI** (o1/o3/o4-mini): maps to `reasoning_effort` (`'max'` → `'xhigh'`)
|
|
23
|
+
* - **OpenAI Responses**: maps to `reasoning.effort` (`'max'` → `'xhigh'`)
|
|
24
|
+
* - **Anthropic** (4.6): maps to adaptive mode + `output_config.effort`
|
|
25
|
+
* - **Anthropic** (older): maps to `thinking.budget_tokens` (`'max'` → `32000`)
|
|
26
|
+
* - **Gemini** (2.5+): maps to `generationConfig.thinkingConfig.thinkingBudget` (`'max'` → `24576`)
|
|
27
|
+
*
|
|
28
|
+
* Budget form (`{ budgetTokens: number }`) gives explicit control over thinking tokens.
|
|
29
|
+
* For OpenAI, budget is mapped to the nearest effort level.
|
|
30
|
+
*/
|
|
31
|
+
type Thinking = 'low' | 'medium' | 'high' | 'max' | {
|
|
32
|
+
budgetTokens: number;
|
|
33
|
+
};
|
|
34
|
+
/**
|
|
35
|
+
* Reasoning effort level for OpenAI reasoning models.
|
|
36
|
+
*
|
|
37
|
+
* This is a low-level, OpenAI-specific escape hatch. Prefer `thinking` for cross-provider use.
|
|
38
|
+
*
|
|
39
|
+
* Supported values:
|
|
40
|
+
* - **OpenAI** (o1/o3/o4-mini): all values — `'none'`, `'minimal'`, `'low'`, `'medium'`, `'high'`, `'xhigh'`
|
|
41
|
+
* - **OpenAI Responses**: all values (via `reasoning.effort`)
|
|
42
|
+
* - **Anthropic**: not supported
|
|
43
|
+
* - **Gemini**: not supported
|
|
44
|
+
*/
|
|
45
|
+
type ReasoningEffort = 'none' | 'minimal' | 'low' | 'medium' | 'high' | 'xhigh';
|
|
46
|
+
/** Tool choice strategy for LLM calls. */
|
|
47
|
+
type ToolChoice = 'auto' | 'none' | 'required' | {
|
|
48
|
+
type: 'function';
|
|
49
|
+
function: {
|
|
50
|
+
name: string;
|
|
51
|
+
};
|
|
52
|
+
};
|
|
53
|
+
/**
|
|
54
|
+
* Options passed to provider chat/stream calls.
|
|
55
|
+
*/
|
|
56
|
+
type ChatOptions = {
|
|
57
|
+
model: string;
|
|
58
|
+
temperature?: number;
|
|
59
|
+
tools?: ToolDefinition[];
|
|
60
|
+
maxTokens?: number;
|
|
61
|
+
responseFormat?: ResponseFormat;
|
|
62
|
+
stop?: string[];
|
|
63
|
+
signal?: AbortSignal;
|
|
64
|
+
thinking?: Thinking;
|
|
65
|
+
reasoningEffort?: ReasoningEffort;
|
|
66
|
+
toolChoice?: ToolChoice;
|
|
67
|
+
};
|
|
68
|
+
/**
|
|
69
|
+
* Response format for structured output (JSON mode).
|
|
70
|
+
*/
|
|
71
|
+
type ResponseFormat = {
|
|
72
|
+
type: 'text';
|
|
73
|
+
} | {
|
|
74
|
+
type: 'json_object';
|
|
75
|
+
} | {
|
|
76
|
+
type: 'json_schema';
|
|
77
|
+
json_schema: {
|
|
78
|
+
name: string;
|
|
79
|
+
strict?: boolean;
|
|
80
|
+
schema: unknown;
|
|
81
|
+
};
|
|
82
|
+
};
|
|
83
|
+
/**
|
|
84
|
+
* Chunks emitted during streaming.
|
|
85
|
+
*/
|
|
86
|
+
type StreamChunk = {
|
|
87
|
+
type: 'text_delta';
|
|
88
|
+
content: string;
|
|
89
|
+
} | {
|
|
90
|
+
type: 'tool_call_delta';
|
|
91
|
+
id: string;
|
|
92
|
+
name?: string;
|
|
93
|
+
arguments?: string;
|
|
94
|
+
} | {
|
|
95
|
+
type: 'done';
|
|
96
|
+
usage?: {
|
|
97
|
+
prompt_tokens: number;
|
|
98
|
+
completion_tokens: number;
|
|
99
|
+
total_tokens: number;
|
|
100
|
+
reasoning_tokens?: number;
|
|
101
|
+
cached_tokens?: number;
|
|
102
|
+
};
|
|
103
|
+
};
|
|
104
|
+
/**
|
|
105
|
+
* Core provider interface. Every LLM adapter must implement this.
|
|
106
|
+
*/
|
|
107
|
+
interface Provider {
|
|
108
|
+
/** Human-readable name for the provider (e.g. "openai", "anthropic") */
|
|
109
|
+
readonly name?: string;
|
|
110
|
+
/**
|
|
111
|
+
* Send a chat completion request and return the full response.
|
|
112
|
+
*/
|
|
113
|
+
chat(messages: ChatMessage[], options: ChatOptions): Promise<ProviderResponse>;
|
|
114
|
+
/**
|
|
115
|
+
* Stream a chat completion, yielding chunks as they arrive.
|
|
116
|
+
*/
|
|
117
|
+
stream(messages: ChatMessage[], options: ChatOptions): AsyncGenerator<StreamChunk>;
|
|
118
|
+
}
|
|
119
|
+
/**
|
|
120
|
+
* Alias for Provider. Used for backward compatibility with index.ts exports.
|
|
121
|
+
*/
|
|
122
|
+
type ProviderAdapter = Provider;
|
|
123
|
+
|
|
5
124
|
/** Result type for concurrent operations (spawn, map) */
|
|
6
125
|
type Result<T> = {
|
|
7
126
|
ok: true;
|
|
@@ -64,6 +183,18 @@ type AskOptions<T = unknown> = {
|
|
|
64
183
|
retries?: number;
|
|
65
184
|
/** Per-call metadata passed to dynamic model/system selector functions. */
|
|
66
185
|
metadata?: Record<string, unknown>;
|
|
186
|
+
/** Override temperature for this call. */
|
|
187
|
+
temperature?: number;
|
|
188
|
+
/** Override max tokens for this call (default: 4096). */
|
|
189
|
+
maxTokens?: number;
|
|
190
|
+
/** Thinking level — portable across all providers. Prefer this over `reasoningEffort`. */
|
|
191
|
+
thinking?: Thinking;
|
|
192
|
+
/** OpenAI-specific reasoning effort (escape hatch). Overridden by `thinking` if both are set. */
|
|
193
|
+
reasoningEffort?: ReasoningEffort;
|
|
194
|
+
/** Tool choice strategy for this call. */
|
|
195
|
+
toolChoice?: ToolChoice;
|
|
196
|
+
/** Stop sequences for this call. */
|
|
197
|
+
stop?: string[];
|
|
67
198
|
};
|
|
68
199
|
/** Race options */
|
|
69
200
|
type RaceOptions<T = unknown> = {
|
|
@@ -173,6 +304,22 @@ type HandoffRecord = {
|
|
|
173
304
|
timestamp: number;
|
|
174
305
|
duration?: number;
|
|
175
306
|
};
|
|
307
|
+
/** Information about a completed agent call, emitted via onAgentCallComplete. */
|
|
308
|
+
type AgentCallInfo = {
|
|
309
|
+
agent: string;
|
|
310
|
+
prompt: string;
|
|
311
|
+
response: string;
|
|
312
|
+
model: string;
|
|
313
|
+
cost: number;
|
|
314
|
+
duration: number;
|
|
315
|
+
promptVersion?: string;
|
|
316
|
+
temperature?: number;
|
|
317
|
+
maxTokens?: number;
|
|
318
|
+
thinking?: Thinking;
|
|
319
|
+
reasoningEffort?: ReasoningEffort;
|
|
320
|
+
toolChoice?: ToolChoice;
|
|
321
|
+
stop?: string[];
|
|
322
|
+
};
|
|
176
323
|
/** Chat message types for provider communication */
|
|
177
324
|
type ChatRole = 'system' | 'user' | 'assistant' | 'tool';
|
|
178
325
|
type ChatMessage = {
|
|
@@ -225,6 +372,11 @@ type AgentConfig = {
|
|
|
225
372
|
mcp?: string[];
|
|
226
373
|
mcpTools?: string[];
|
|
227
374
|
temperature?: number;
|
|
375
|
+
maxTokens?: number;
|
|
376
|
+
thinking?: Thinking;
|
|
377
|
+
reasoningEffort?: ReasoningEffort;
|
|
378
|
+
toolChoice?: ToolChoice;
|
|
379
|
+
stop?: string[];
|
|
228
380
|
maxTurns?: number;
|
|
229
381
|
timeout?: string;
|
|
230
382
|
maxContext?: number;
|
|
@@ -254,94 +406,6 @@ type Agent = {
|
|
|
254
406
|
*/
|
|
255
407
|
declare function agent(config: AgentConfig): Agent;
|
|
256
408
|
|
|
257
|
-
/**
|
|
258
|
-
* Tool definition in OpenAI-compatible format.
|
|
259
|
-
* All providers normalize to this format internally.
|
|
260
|
-
*/
|
|
261
|
-
type ToolDefinition = {
|
|
262
|
-
type: 'function';
|
|
263
|
-
function: {
|
|
264
|
-
name: string;
|
|
265
|
-
description: string;
|
|
266
|
-
parameters: unknown;
|
|
267
|
-
strict?: boolean;
|
|
268
|
-
};
|
|
269
|
-
};
|
|
270
|
-
/**
|
|
271
|
-
* Options passed to provider chat/stream calls.
|
|
272
|
-
*/
|
|
273
|
-
type ChatOptions = {
|
|
274
|
-
model: string;
|
|
275
|
-
temperature?: number;
|
|
276
|
-
tools?: ToolDefinition[];
|
|
277
|
-
maxTokens?: number;
|
|
278
|
-
responseFormat?: ResponseFormat;
|
|
279
|
-
stop?: string[];
|
|
280
|
-
signal?: AbortSignal;
|
|
281
|
-
reasoningEffort?: 'low' | 'medium' | 'high';
|
|
282
|
-
toolChoice?: 'auto' | 'none' | 'required' | {
|
|
283
|
-
type: 'function';
|
|
284
|
-
function: {
|
|
285
|
-
name: string;
|
|
286
|
-
};
|
|
287
|
-
};
|
|
288
|
-
};
|
|
289
|
-
/**
|
|
290
|
-
* Response format for structured output (JSON mode).
|
|
291
|
-
*/
|
|
292
|
-
type ResponseFormat = {
|
|
293
|
-
type: 'text';
|
|
294
|
-
} | {
|
|
295
|
-
type: 'json_object';
|
|
296
|
-
} | {
|
|
297
|
-
type: 'json_schema';
|
|
298
|
-
json_schema: {
|
|
299
|
-
name: string;
|
|
300
|
-
strict?: boolean;
|
|
301
|
-
schema: unknown;
|
|
302
|
-
};
|
|
303
|
-
};
|
|
304
|
-
/**
|
|
305
|
-
* Chunks emitted during streaming.
|
|
306
|
-
*/
|
|
307
|
-
type StreamChunk = {
|
|
308
|
-
type: 'text_delta';
|
|
309
|
-
content: string;
|
|
310
|
-
} | {
|
|
311
|
-
type: 'tool_call_delta';
|
|
312
|
-
id: string;
|
|
313
|
-
name?: string;
|
|
314
|
-
arguments?: string;
|
|
315
|
-
} | {
|
|
316
|
-
type: 'done';
|
|
317
|
-
usage?: {
|
|
318
|
-
prompt_tokens: number;
|
|
319
|
-
completion_tokens: number;
|
|
320
|
-
total_tokens: number;
|
|
321
|
-
reasoning_tokens?: number;
|
|
322
|
-
cached_tokens?: number;
|
|
323
|
-
};
|
|
324
|
-
};
|
|
325
|
-
/**
|
|
326
|
-
* Core provider interface. Every LLM adapter must implement this.
|
|
327
|
-
*/
|
|
328
|
-
interface Provider {
|
|
329
|
-
/** Human-readable name for the provider (e.g. "openai", "anthropic") */
|
|
330
|
-
readonly name?: string;
|
|
331
|
-
/**
|
|
332
|
-
* Send a chat completion request and return the full response.
|
|
333
|
-
*/
|
|
334
|
-
chat(messages: ChatMessage[], options: ChatOptions): Promise<ProviderResponse>;
|
|
335
|
-
/**
|
|
336
|
-
* Stream a chat completion, yielding chunks as they arrive.
|
|
337
|
-
*/
|
|
338
|
-
stream(messages: ChatMessage[], options: ChatOptions): AsyncGenerator<StreamChunk>;
|
|
339
|
-
}
|
|
340
|
-
/**
|
|
341
|
-
* Alias for Provider. Used for backward compatibility with index.ts exports.
|
|
342
|
-
*/
|
|
343
|
-
type ProviderAdapter = Provider;
|
|
344
|
-
|
|
345
409
|
/** Configuration for OpenTelemetry integration. */
|
|
346
410
|
type TelemetryConfig = {
|
|
347
411
|
/** Whether telemetry is enabled. Defaults to false. */
|
|
@@ -799,15 +863,7 @@ type WorkflowContextInit = {
|
|
|
799
863
|
model: string;
|
|
800
864
|
}) => void;
|
|
801
865
|
/** Callback fired after each ctx.ask() completes (once per ask invocation). */
|
|
802
|
-
onAgentCallComplete?: (call:
|
|
803
|
-
agent: string;
|
|
804
|
-
prompt: string;
|
|
805
|
-
response: string;
|
|
806
|
-
model: string;
|
|
807
|
-
cost: number;
|
|
808
|
-
duration: number;
|
|
809
|
-
promptVersion?: string;
|
|
810
|
-
}) => void;
|
|
866
|
+
onAgentCallComplete?: (call: AgentCallInfo) => void;
|
|
811
867
|
};
|
|
812
868
|
/**
|
|
813
869
|
* The central coordination object for all Axl primitives.
|
|
@@ -1377,6 +1433,16 @@ declare class AnthropicProvider implements Provider {
|
|
|
1377
1433
|
* Map an OpenAI-format ToolDefinition to Anthropic's tool format.
|
|
1378
1434
|
*/
|
|
1379
1435
|
private mapToolDefinition;
|
|
1436
|
+
/**
|
|
1437
|
+
* Map Axl's ToolChoice to Anthropic's tool_choice format.
|
|
1438
|
+
*
|
|
1439
|
+
* Axl (OpenAI format) → Anthropic format
|
|
1440
|
+
* 'auto' → { type: 'auto' }
|
|
1441
|
+
* 'none' → { type: 'none' }
|
|
1442
|
+
* 'required' → { type: 'any' }
|
|
1443
|
+
* { type:'function', function: { name } } → { type: 'tool', name }
|
|
1444
|
+
*/
|
|
1445
|
+
private mapToolChoice;
|
|
1380
1446
|
private parseResponse;
|
|
1381
1447
|
private parseSSEStream;
|
|
1382
1448
|
}
|
|
@@ -1427,6 +1493,15 @@ declare class GeminiProvider implements Provider {
|
|
|
1427
1493
|
* Gemini requires alternating user/model turns.
|
|
1428
1494
|
*/
|
|
1429
1495
|
private mergeConsecutiveRoles;
|
|
1496
|
+
/**
|
|
1497
|
+
* Map Axl's ToolChoice to Gemini's functionCallingConfig format.
|
|
1498
|
+
*
|
|
1499
|
+
* - 'auto' → { mode: 'AUTO' }
|
|
1500
|
+
* - 'none' → { mode: 'NONE' }
|
|
1501
|
+
* - 'required' → { mode: 'ANY' }
|
|
1502
|
+
* - { type: 'function', function: { name } } → { mode: 'ANY', allowedFunctionNames: [name] }
|
|
1503
|
+
*/
|
|
1504
|
+
private mapToolChoice;
|
|
1430
1505
|
private mapToolDefinition;
|
|
1431
1506
|
private parseResponse;
|
|
1432
1507
|
private parseSSEStream;
|
|
@@ -1630,4 +1705,4 @@ declare class NoopSpanManager implements SpanManager {
|
|
|
1630
1705
|
*/
|
|
1631
1706
|
declare function createSpanManager(config?: TelemetryConfig): Promise<SpanManager>;
|
|
1632
1707
|
|
|
1633
|
-
export { type Agent, type AgentConfig, AnthropicProvider, type AskOptions, type AwaitHumanOptions, type AxlConfig, AxlError, AxlRuntime, AxlStream, BudgetExceededError, type BudgetOptions, type BudgetResult, type ChatMessage, type ChatOptions, type Embedder, type ExecutionInfo, type ExecutionState, GeminiProvider, type GuardrailBlockHandler, GuardrailError, type GuardrailResult, type GuardrailsConfig, type HandoffDescriptor, type HandoffRecord, type HumanDecision, InMemoryVectorStore, type InputGuardrail, type MapOptions, MaxTurnsError, McpManager, type McpServer, type McpServerConfig, type McpToolDefinition, type McpToolResult, type MemoryConfig, MemoryManager, MemoryStore, NoConsensus, NoopSpanManager, OpenAIEmbedder, OpenAIProvider, OpenAIResponsesProvider, type OutputGuardrail, type PendingDecision, type Provider, type ProviderAdapter, ProviderRegistry, type ProviderResponse, QuorumNotMet, type RaceOptions, type RecallOptions, RedisStore, type RememberOptions, type Result, type RetryPolicy, SQLiteStore, Session, type SessionOptions, type SpanHandle, type SpanManager, type SpawnOptions, SqliteVectorStore, type StateStore, type StreamChunk, type StreamEvent, type TelemetryConfig, TimeoutError, type Tool, type ToolCallMessage, type ToolConfig, ToolDenied, type ToolHooks, type TraceEvent, type VectorEntry, type VectorResult, type VectorStore, VerifyError, type VerifyOptions, type VoteOptions, type Workflow, type WorkflowConfig, WorkflowContext, type WorkflowContextInit, agent, createSpanManager, defineConfig, tool, workflow, zodToJsonSchema };
|
|
1708
|
+
export { type Agent, type AgentCallInfo, type AgentConfig, AnthropicProvider, type AskOptions, type AwaitHumanOptions, type AxlConfig, AxlError, AxlRuntime, AxlStream, BudgetExceededError, type BudgetOptions, type BudgetResult, type ChatMessage, type ChatOptions, type Embedder, type ExecutionInfo, type ExecutionState, GeminiProvider, type GuardrailBlockHandler, GuardrailError, type GuardrailResult, type GuardrailsConfig, type HandoffDescriptor, type HandoffRecord, type HumanDecision, InMemoryVectorStore, type InputGuardrail, type MapOptions, MaxTurnsError, McpManager, type McpServer, type McpServerConfig, type McpToolDefinition, type McpToolResult, type MemoryConfig, MemoryManager, MemoryStore, NoConsensus, NoopSpanManager, OpenAIEmbedder, OpenAIProvider, OpenAIResponsesProvider, type OutputGuardrail, type PendingDecision, type Provider, type ProviderAdapter, ProviderRegistry, type ProviderResponse, QuorumNotMet, type RaceOptions, type ReasoningEffort, type RecallOptions, RedisStore, type RememberOptions, type Result, type RetryPolicy, SQLiteStore, Session, type SessionOptions, type SpanHandle, type SpanManager, type SpawnOptions, SqliteVectorStore, type StateStore, type StreamChunk, type StreamEvent, type TelemetryConfig, type Thinking, TimeoutError, type Tool, type ToolCallMessage, type ToolChoice, type ToolConfig, ToolDenied, type ToolHooks, type TraceEvent, type VectorEntry, type VectorResult, type VectorStore, VerifyError, type VerifyOptions, type VoteOptions, type Workflow, type WorkflowConfig, WorkflowContext, type WorkflowContextInit, agent, createSpanManager, defineConfig, tool, workflow, zodToJsonSchema };
|