@axlsdk/axl 0.4.0 → 0.6.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 +84 -10
- package/dist/index.cjs +589 -79
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +266 -102
- package/dist/index.d.ts +266 -102
- package/dist/index.js +588 -79
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -2,6 +2,153 @@ 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 effort level controlling how thoroughly the model responds.
|
|
20
|
+
*
|
|
21
|
+
* - `'none'` — Disable thinking/reasoning. On Gemini 3.x, maps to the model's
|
|
22
|
+
* minimum thinking level (3.1 Pro: 'low', others: 'minimal'). On other providers,
|
|
23
|
+
* fully disables reasoning.
|
|
24
|
+
* - `'low'` through `'max'` — Increasing levels of reasoning depth and token spend.
|
|
25
|
+
*
|
|
26
|
+
* Provider mapping:
|
|
27
|
+
* - Anthropic 4.6: adaptive thinking + output_config.effort
|
|
28
|
+
* - Anthropic Opus 4.5: output_config.effort (no adaptive)
|
|
29
|
+
* - Anthropic older: thinking.budget_tokens fallback
|
|
30
|
+
* - OpenAI o-series: reasoning_effort
|
|
31
|
+
* - OpenAI GPT-5.x: reasoning.effort / reasoning_effort
|
|
32
|
+
* - Gemini 3.x: thinkingLevel (`'none'` → model min: `'minimal'` or `'low'` for 3.1 Pro)
|
|
33
|
+
* - Gemini 2.x: thinkingBudget (`'none'` → 0; some models have minimums)
|
|
34
|
+
*/
|
|
35
|
+
type Effort = 'none' | 'low' | 'medium' | 'high' | 'max';
|
|
36
|
+
/** Tool choice strategy for LLM calls. */
|
|
37
|
+
type ToolChoice = 'auto' | 'none' | 'required' | {
|
|
38
|
+
type: 'function';
|
|
39
|
+
function: {
|
|
40
|
+
name: string;
|
|
41
|
+
};
|
|
42
|
+
};
|
|
43
|
+
/**
|
|
44
|
+
* Options passed to provider chat/stream calls.
|
|
45
|
+
*/
|
|
46
|
+
type ChatOptions = {
|
|
47
|
+
model: string;
|
|
48
|
+
temperature?: number;
|
|
49
|
+
tools?: ToolDefinition[];
|
|
50
|
+
maxTokens?: number;
|
|
51
|
+
responseFormat?: ResponseFormat;
|
|
52
|
+
stop?: string[];
|
|
53
|
+
signal?: AbortSignal;
|
|
54
|
+
/** How hard should the model try? Primary param for cost/quality tradeoff.
|
|
55
|
+
* 'none' disables thinking/reasoning (Gemini 3.x: maps to minimal).
|
|
56
|
+
* Omit to use provider defaults. */
|
|
57
|
+
effort?: Effort;
|
|
58
|
+
/** Precise thinking token budget (advanced). When set alongside `effort`, overrides the
|
|
59
|
+
* thinking/reasoning allocation. On Anthropic 4.6, `effort` still controls output quality
|
|
60
|
+
* independently. On all other providers, `thinkingBudget` fully overrides `effort` for
|
|
61
|
+
* reasoning behavior. Set to 0 to disable thinking while keeping effort for output control
|
|
62
|
+
* (Anthropic-specific optimization; on other providers, simply disables reasoning). */
|
|
63
|
+
thinkingBudget?: number;
|
|
64
|
+
/** Show reasoning summaries in responses (thinking_content / thinking_delta).
|
|
65
|
+
* Supported on OpenAI Responses API and Gemini. No-op on Anthropic. */
|
|
66
|
+
includeThoughts?: boolean;
|
|
67
|
+
toolChoice?: ToolChoice;
|
|
68
|
+
/** Provider-specific options merged LAST into the raw API request body.
|
|
69
|
+
* Can override any computed field including model and messages — use with care.
|
|
70
|
+
* NOT portable across providers — use effort/thinkingBudget/includeThoughts for cross-provider behavior. */
|
|
71
|
+
providerOptions?: Record<string, unknown>;
|
|
72
|
+
};
|
|
73
|
+
/**
|
|
74
|
+
* Response format for structured output (JSON mode).
|
|
75
|
+
*/
|
|
76
|
+
type ResponseFormat = {
|
|
77
|
+
type: 'text';
|
|
78
|
+
} | {
|
|
79
|
+
type: 'json_object';
|
|
80
|
+
} | {
|
|
81
|
+
type: 'json_schema';
|
|
82
|
+
json_schema: {
|
|
83
|
+
name: string;
|
|
84
|
+
strict?: boolean;
|
|
85
|
+
schema: unknown;
|
|
86
|
+
};
|
|
87
|
+
};
|
|
88
|
+
/**
|
|
89
|
+
* Chunks emitted during streaming.
|
|
90
|
+
*/
|
|
91
|
+
type StreamChunk = {
|
|
92
|
+
type: 'text_delta';
|
|
93
|
+
content: string;
|
|
94
|
+
} | {
|
|
95
|
+
type: 'thinking_delta';
|
|
96
|
+
content: string;
|
|
97
|
+
} | {
|
|
98
|
+
type: 'tool_call_delta';
|
|
99
|
+
id: string;
|
|
100
|
+
name?: string;
|
|
101
|
+
arguments?: string;
|
|
102
|
+
} | {
|
|
103
|
+
type: 'done';
|
|
104
|
+
usage?: {
|
|
105
|
+
prompt_tokens: number;
|
|
106
|
+
completion_tokens: number;
|
|
107
|
+
total_tokens: number;
|
|
108
|
+
reasoning_tokens?: number;
|
|
109
|
+
cached_tokens?: number;
|
|
110
|
+
};
|
|
111
|
+
/** Provider-specific opaque metadata (e.g. raw Gemini parts with thought signatures). */
|
|
112
|
+
providerMetadata?: Record<string, unknown>;
|
|
113
|
+
};
|
|
114
|
+
/**
|
|
115
|
+
* Core provider interface. Every LLM adapter must implement this.
|
|
116
|
+
*/
|
|
117
|
+
interface Provider {
|
|
118
|
+
/** Human-readable name for the provider (e.g. "openai", "anthropic") */
|
|
119
|
+
readonly name?: string;
|
|
120
|
+
/**
|
|
121
|
+
* Send a chat completion request and return the full response.
|
|
122
|
+
*/
|
|
123
|
+
chat(messages: ChatMessage[], options: ChatOptions): Promise<ProviderResponse>;
|
|
124
|
+
/**
|
|
125
|
+
* Stream a chat completion, yielding chunks as they arrive.
|
|
126
|
+
*/
|
|
127
|
+
stream(messages: ChatMessage[], options: ChatOptions): AsyncGenerator<StreamChunk>;
|
|
128
|
+
}
|
|
129
|
+
/**
|
|
130
|
+
* Alias for Provider. Used for backward compatibility with index.ts exports.
|
|
131
|
+
*/
|
|
132
|
+
type ProviderAdapter = Provider;
|
|
133
|
+
/** Normalized thinking options computed once, used by all providers. */
|
|
134
|
+
type ResolvedThinkingOptions = {
|
|
135
|
+
/** Raw effort value from user. */
|
|
136
|
+
effort: Effort | undefined;
|
|
137
|
+
/** Raw thinking budget from user. */
|
|
138
|
+
thinkingBudget: number | undefined;
|
|
139
|
+
/** Whether to include thought summaries in responses. */
|
|
140
|
+
includeThoughts: boolean;
|
|
141
|
+
/** True when thinking/reasoning should be disabled (effort: 'none' or thinkingBudget: 0). */
|
|
142
|
+
thinkingDisabled: boolean;
|
|
143
|
+
/** Effort level with 'none' stripped (undefined when effort is 'none' or unset). */
|
|
144
|
+
activeEffort: Exclude<Effort, 'none'> | undefined;
|
|
145
|
+
/** True when an explicit positive budget overrides effort-based allocation. */
|
|
146
|
+
hasBudgetOverride: boolean;
|
|
147
|
+
};
|
|
148
|
+
/** Resolve effort/thinkingBudget/includeThoughts into normalized form.
|
|
149
|
+
* Validates inputs and computes derived flags used by all provider adapters. */
|
|
150
|
+
declare function resolveThinkingOptions(options: Pick<ChatOptions, 'effort' | 'thinkingBudget' | 'includeThoughts'>): ResolvedThinkingOptions;
|
|
151
|
+
|
|
5
152
|
/** Result type for concurrent operations (spawn, map) */
|
|
6
153
|
type Result<T> = {
|
|
7
154
|
ok: true;
|
|
@@ -64,6 +211,33 @@ type AskOptions<T = unknown> = {
|
|
|
64
211
|
retries?: number;
|
|
65
212
|
/** Per-call metadata passed to dynamic model/system selector functions. */
|
|
66
213
|
metadata?: Record<string, unknown>;
|
|
214
|
+
/** Override temperature for this call. */
|
|
215
|
+
temperature?: number;
|
|
216
|
+
/** Override max tokens for this call (default: 4096). */
|
|
217
|
+
maxTokens?: number;
|
|
218
|
+
/** How hard should the model try? Primary param for cost/quality tradeoff. */
|
|
219
|
+
effort?: Effort;
|
|
220
|
+
/** Precise thinking token budget (advanced). Overrides effort-based thinking allocation. */
|
|
221
|
+
thinkingBudget?: number;
|
|
222
|
+
/** Show reasoning summaries in responses. */
|
|
223
|
+
includeThoughts?: boolean;
|
|
224
|
+
/** Tool choice strategy for this call. */
|
|
225
|
+
toolChoice?: ToolChoice;
|
|
226
|
+
/** Stop sequences for this call. */
|
|
227
|
+
stop?: string[];
|
|
228
|
+
/** Provider-specific options merged into API requests. Not portable across providers. */
|
|
229
|
+
providerOptions?: Record<string, unknown>;
|
|
230
|
+
};
|
|
231
|
+
/** Delegate options */
|
|
232
|
+
type DelegateOptions<T = unknown> = {
|
|
233
|
+
/** Zod schema for structured output from the selected agent. */
|
|
234
|
+
schema?: z.ZodType<T>;
|
|
235
|
+
/** Model URI for the internal router agent (default: first candidate's model). */
|
|
236
|
+
routerModel?: string;
|
|
237
|
+
/** Additional metadata passed to the router and selected agent. */
|
|
238
|
+
metadata?: Record<string, unknown>;
|
|
239
|
+
/** Number of retries for structured output validation (passed to the final ask). */
|
|
240
|
+
retries?: number;
|
|
67
241
|
};
|
|
68
242
|
/** Race options */
|
|
69
243
|
type RaceOptions<T = unknown> = {
|
|
@@ -76,7 +250,7 @@ type ExecutionStatus = 'running' | 'completed' | 'failed' | 'waiting';
|
|
|
76
250
|
type TraceEvent = {
|
|
77
251
|
executionId: string;
|
|
78
252
|
step: number;
|
|
79
|
-
type: 'agent_call' | 'tool_call' | 'verify' | 'handoff' | 'tool_denied' | 'log' | 'workflow_start' | 'workflow_end' | 'guardrail';
|
|
253
|
+
type: 'agent_call' | 'tool_call' | 'verify' | 'handoff' | 'delegate' | 'tool_denied' | 'log' | 'workflow_start' | 'workflow_end' | 'guardrail';
|
|
80
254
|
workflow?: string;
|
|
81
255
|
agent?: string;
|
|
82
256
|
tool?: string;
|
|
@@ -173,6 +347,25 @@ type HandoffRecord = {
|
|
|
173
347
|
timestamp: number;
|
|
174
348
|
duration?: number;
|
|
175
349
|
};
|
|
350
|
+
/** Information about a completed agent call, emitted via onAgentCallComplete. */
|
|
351
|
+
type AgentCallInfo = {
|
|
352
|
+
agent: string;
|
|
353
|
+
prompt: string;
|
|
354
|
+
response: string;
|
|
355
|
+
model: string;
|
|
356
|
+
cost: number;
|
|
357
|
+
duration: number;
|
|
358
|
+
promptVersion?: string;
|
|
359
|
+
temperature?: number;
|
|
360
|
+
maxTokens?: number;
|
|
361
|
+
effort?: Effort;
|
|
362
|
+
thinkingBudget?: number;
|
|
363
|
+
includeThoughts?: boolean;
|
|
364
|
+
toolChoice?: ToolChoice;
|
|
365
|
+
stop?: string[];
|
|
366
|
+
/** Provider-specific options merged into API requests. Not portable across providers. */
|
|
367
|
+
providerOptions?: Record<string, unknown>;
|
|
368
|
+
};
|
|
176
369
|
/** Chat message types for provider communication */
|
|
177
370
|
type ChatRole = 'system' | 'user' | 'assistant' | 'tool';
|
|
178
371
|
type ChatMessage = {
|
|
@@ -181,6 +374,8 @@ type ChatMessage = {
|
|
|
181
374
|
name?: string;
|
|
182
375
|
tool_calls?: ToolCallMessage[];
|
|
183
376
|
tool_call_id?: string;
|
|
377
|
+
/** Provider-specific opaque metadata that must round-trip through conversation history. */
|
|
378
|
+
providerMetadata?: Record<string, unknown>;
|
|
184
379
|
};
|
|
185
380
|
type ToolCallMessage = {
|
|
186
381
|
id: string;
|
|
@@ -193,6 +388,7 @@ type ToolCallMessage = {
|
|
|
193
388
|
/** Provider response */
|
|
194
389
|
type ProviderResponse = {
|
|
195
390
|
content: string;
|
|
391
|
+
thinking_content?: string;
|
|
196
392
|
tool_calls?: ToolCallMessage[];
|
|
197
393
|
usage?: {
|
|
198
394
|
prompt_tokens: number;
|
|
@@ -202,6 +398,8 @@ type ProviderResponse = {
|
|
|
202
398
|
cached_tokens?: number;
|
|
203
399
|
};
|
|
204
400
|
cost?: number;
|
|
401
|
+
/** Provider-specific opaque metadata that needs to round-trip through conversation history. */
|
|
402
|
+
providerMetadata?: Record<string, unknown>;
|
|
205
403
|
};
|
|
206
404
|
|
|
207
405
|
/** Descriptor for a handoff target agent with optional description. */
|
|
@@ -221,10 +419,20 @@ type AgentConfig = {
|
|
|
221
419
|
metadata?: Record<string, unknown>;
|
|
222
420
|
}) => string);
|
|
223
421
|
tools?: Tool<any, any>[];
|
|
224
|
-
handoffs?: HandoffDescriptor[]
|
|
422
|
+
handoffs?: HandoffDescriptor[] | ((ctx: {
|
|
423
|
+
metadata?: Record<string, unknown>;
|
|
424
|
+
}) => HandoffDescriptor[]);
|
|
225
425
|
mcp?: string[];
|
|
226
426
|
mcpTools?: string[];
|
|
227
427
|
temperature?: number;
|
|
428
|
+
maxTokens?: number;
|
|
429
|
+
effort?: Effort;
|
|
430
|
+
thinkingBudget?: number;
|
|
431
|
+
includeThoughts?: boolean;
|
|
432
|
+
toolChoice?: ToolChoice;
|
|
433
|
+
stop?: string[];
|
|
434
|
+
/** Provider-specific options merged into API requests. Not portable across providers. */
|
|
435
|
+
providerOptions?: Record<string, unknown>;
|
|
228
436
|
maxTurns?: number;
|
|
229
437
|
timeout?: string;
|
|
230
438
|
maxContext?: number;
|
|
@@ -254,94 +462,6 @@ type Agent = {
|
|
|
254
462
|
*/
|
|
255
463
|
declare function agent(config: AgentConfig): Agent;
|
|
256
464
|
|
|
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
465
|
/** Configuration for OpenTelemetry integration. */
|
|
346
466
|
type TelemetryConfig = {
|
|
347
467
|
/** Whether telemetry is enabled. Defaults to false. */
|
|
@@ -799,15 +919,7 @@ type WorkflowContextInit = {
|
|
|
799
919
|
model: string;
|
|
800
920
|
}) => void;
|
|
801
921
|
/** 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;
|
|
922
|
+
onAgentCallComplete?: (call: AgentCallInfo) => void;
|
|
811
923
|
};
|
|
812
924
|
/**
|
|
813
925
|
* The central coordination object for all Axl primitives.
|
|
@@ -840,6 +952,14 @@ declare class WorkflowContext<TInput = unknown> {
|
|
|
840
952
|
private onAgentStart?;
|
|
841
953
|
private onAgentCallComplete?;
|
|
842
954
|
constructor(init: WorkflowContextInit);
|
|
955
|
+
/**
|
|
956
|
+
* Create a child context for nested agent invocations (e.g., agent-as-tool).
|
|
957
|
+
* Shares: budget tracking, abort signals, trace emission, provider registry,
|
|
958
|
+
* state store, span manager, memory manager, MCP manager, config,
|
|
959
|
+
* awaitHuman handler, pending decisions, tool overrides.
|
|
960
|
+
* Isolates: session history, step counter, streaming callbacks (onToken, onAgentStart, onToolCall).
|
|
961
|
+
*/
|
|
962
|
+
createChildContext(): WorkflowContext;
|
|
843
963
|
/**
|
|
844
964
|
* Resolve the current abort signal.
|
|
845
965
|
* Branch-scoped signals (from race/spawn/map/budget) in AsyncLocalStorage
|
|
@@ -848,6 +968,11 @@ declare class WorkflowContext<TInput = unknown> {
|
|
|
848
968
|
private get currentSignal();
|
|
849
969
|
ask<T = string>(agent: Agent, prompt: string, options?: AskOptions<T>): Promise<T>;
|
|
850
970
|
private executeAgentCall;
|
|
971
|
+
/**
|
|
972
|
+
* Push the final assistant message into session history, preserving providerMetadata
|
|
973
|
+
* (e.g., Gemini thought signatures needed for multi-turn reasoning context).
|
|
974
|
+
*/
|
|
975
|
+
private pushAssistantToSessionHistory;
|
|
851
976
|
private buildToolDefs;
|
|
852
977
|
/**
|
|
853
978
|
* Summarize old messages to fit within context window.
|
|
@@ -908,6 +1033,18 @@ declare class WorkflowContext<TInput = unknown> {
|
|
|
908
1033
|
forget(key: string, options?: {
|
|
909
1034
|
scope?: 'session' | 'global';
|
|
910
1035
|
}): Promise<void>;
|
|
1036
|
+
/**
|
|
1037
|
+
* Select the best agent from a list of candidates and invoke it.
|
|
1038
|
+
* Creates a temporary router agent that uses handoffs to pick the right specialist.
|
|
1039
|
+
*
|
|
1040
|
+
* This is convenience sugar over creating a router agent with dynamic handoffs.
|
|
1041
|
+
* For full control over the router's behavior, create the router agent explicitly.
|
|
1042
|
+
*
|
|
1043
|
+
* @param agents - Candidate agents to choose from (at least 1)
|
|
1044
|
+
* @param prompt - The prompt to send to the selected agent
|
|
1045
|
+
* @param options - Optional: schema, routerModel, metadata, retries
|
|
1046
|
+
*/
|
|
1047
|
+
delegate<T = string>(agents: Agent[], prompt: string, options?: DelegateOptions<T>): Promise<T>;
|
|
911
1048
|
private emitTrace;
|
|
912
1049
|
}
|
|
913
1050
|
|
|
@@ -931,7 +1068,7 @@ type ToolConfig<TInput extends z.ZodTypeAny, TOutput = unknown> = {
|
|
|
931
1068
|
name: string;
|
|
932
1069
|
description: string;
|
|
933
1070
|
input: TInput;
|
|
934
|
-
handler: (input: z.infer<TInput
|
|
1071
|
+
handler: (input: z.infer<TInput>, ctx: WorkflowContext) => TOutput | Promise<TOutput>;
|
|
935
1072
|
retry?: RetryPolicy;
|
|
936
1073
|
sensitive?: boolean;
|
|
937
1074
|
/** Maximum string length for any string argument. Default: 10000. Set to 0 to disable. */
|
|
@@ -953,7 +1090,7 @@ type Tool<TInput extends z.ZodTypeAny = z.ZodTypeAny, TOutput = unknown> = {
|
|
|
953
1090
|
/** Run the tool directly from workflow code */
|
|
954
1091
|
run(ctx: WorkflowContext, input: z.infer<TInput>): Promise<TOutput>;
|
|
955
1092
|
/** Execute the handler (internal use — includes retry logic) */
|
|
956
|
-
_execute(input: z.infer<TInput
|
|
1093
|
+
_execute(input: z.infer<TInput>, ctx?: WorkflowContext): Promise<TOutput>;
|
|
957
1094
|
};
|
|
958
1095
|
/**
|
|
959
1096
|
* Define a tool with Zod-validated input, a handler function, and optional retry policy.
|
|
@@ -1142,6 +1279,14 @@ declare class AxlRuntime extends EventEmitter {
|
|
|
1142
1279
|
runRegisteredEval(name: string): Promise<unknown>;
|
|
1143
1280
|
/** Get all execution info (running + completed). */
|
|
1144
1281
|
getExecutions(): ExecutionInfo[];
|
|
1282
|
+
/**
|
|
1283
|
+
* Create a lightweight WorkflowContext for ad-hoc use (tool testing, prototyping).
|
|
1284
|
+
* The context has access to the runtime's providers, state store, and MCP manager
|
|
1285
|
+
* but no session history, streaming callbacks, or budget tracking.
|
|
1286
|
+
*/
|
|
1287
|
+
createContext(options?: {
|
|
1288
|
+
metadata?: Record<string, unknown>;
|
|
1289
|
+
}): WorkflowContext;
|
|
1145
1290
|
/** Register a custom provider instance. */
|
|
1146
1291
|
registerProvider(name: string, provider: Provider): void;
|
|
1147
1292
|
/** Execute a workflow and return the result. */
|
|
@@ -1377,6 +1522,16 @@ declare class AnthropicProvider implements Provider {
|
|
|
1377
1522
|
* Map an OpenAI-format ToolDefinition to Anthropic's tool format.
|
|
1378
1523
|
*/
|
|
1379
1524
|
private mapToolDefinition;
|
|
1525
|
+
/**
|
|
1526
|
+
* Map Axl's ToolChoice to Anthropic's tool_choice format.
|
|
1527
|
+
*
|
|
1528
|
+
* Axl (OpenAI format) → Anthropic format
|
|
1529
|
+
* 'auto' → { type: 'auto' }
|
|
1530
|
+
* 'none' → { type: 'none' }
|
|
1531
|
+
* 'required' → { type: 'any' }
|
|
1532
|
+
* { type:'function', function: { name } } → { type: 'tool', name }
|
|
1533
|
+
*/
|
|
1534
|
+
private mapToolChoice;
|
|
1380
1535
|
private parseResponse;
|
|
1381
1536
|
private parseSSEStream;
|
|
1382
1537
|
}
|
|
@@ -1427,6 +1582,15 @@ declare class GeminiProvider implements Provider {
|
|
|
1427
1582
|
* Gemini requires alternating user/model turns.
|
|
1428
1583
|
*/
|
|
1429
1584
|
private mergeConsecutiveRoles;
|
|
1585
|
+
/**
|
|
1586
|
+
* Map Axl's ToolChoice to Gemini's functionCallingConfig format.
|
|
1587
|
+
*
|
|
1588
|
+
* - 'auto' → { mode: 'AUTO' }
|
|
1589
|
+
* - 'none' → { mode: 'NONE' }
|
|
1590
|
+
* - 'required' → { mode: 'ANY' }
|
|
1591
|
+
* - { type: 'function', function: { name } } → { mode: 'ANY', allowedFunctionNames: [name] }
|
|
1592
|
+
*/
|
|
1593
|
+
private mapToolChoice;
|
|
1430
1594
|
private mapToolDefinition;
|
|
1431
1595
|
private parseResponse;
|
|
1432
1596
|
private parseSSEStream;
|
|
@@ -1630,4 +1794,4 @@ declare class NoopSpanManager implements SpanManager {
|
|
|
1630
1794
|
*/
|
|
1631
1795
|
declare function createSpanManager(config?: TelemetryConfig): Promise<SpanManager>;
|
|
1632
1796
|
|
|
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 };
|
|
1797
|
+
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 DelegateOptions, type Effort, 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 ResolvedThinkingOptions, 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 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, resolveThinkingOptions, tool, workflow, zodToJsonSchema };
|