@fifthrevision/axle 0.23.1 → 0.25.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.
@@ -0,0 +1 @@
1
+ var e=class e{_state;constructor(e){this._state={turns:e?.turns??[],sessionAnnotations:e?.sessionAnnotations}}get state(){return this._state}apply(t){let n=t;switch(t.type){case`session:restore`:return this.replaceState({turns:n.turns??[],sessionAnnotations:n.sessionAnnotations},t);case`turn:user`:return this.replaceTurns([...this._state.turns,n.turn],t);case`turn:start`:{let e={id:n.turnId,owner:`agent`,parts:[],status:`streaming`,...n.timing?{timing:n.timing}:{}};return this.replaceTurns([...this._state.turns,e],t)}case`part:start`:return this.updateTurn(n.turnId,t,e=>({...e,parts:[...e.parts,n.part]}));case`text:delta`:return this.updatePart(n.turnId,n.partId,t,e=>e.type===`text`?{...e,text:e.text+n.delta}:e);case`text:citation`:return this.updatePart(n.turnId,n.partId,t,e=>e.type===`text`?{...e,citations:[...e.citations??[],n.citation]}:e);case`thinking:delta`:return this.updatePart(n.turnId,n.partId,t,e=>e.type===`thinking`?{...e,text:(e.text??``)+n.delta}:e);case`thinking:summary-delta`:return this.updatePart(n.turnId,n.partId,t,e=>e.type===`thinking`?{...e,summary:(e.summary??``)+n.delta}:e);case`thinking:update`:return this.updatePart(n.turnId,n.partId,t,e=>e.type===`thinking`?{...e,...n.redacted===void 0?{}:{redacted:n.redacted},...n.continuity?{continuity:n.continuity}:{},...n.providerMetadata?{providerMetadata:n.providerMetadata}:{}}:e);case`part:end`:return this.updatePart(n.turnId,n.partId,t,e=>({...e,timing:n.timing??e.timing}));case`action:args-delta`:return this.updatePart(n.turnId,n.partId,t,e=>e.type!==`action`||e.kind!==`tool`?e:{...e,detail:{...e.detail,pendingArgs:n.accumulated}});case`action:running`:return this.updatePart(n.turnId,n.partId,t,e=>{if(e.type!==`action`)return e;if(e.kind===`tool`){let{pendingArgs:t,...r}=e.detail;return{...e,status:`running`,detail:n.parameters?{...r,parameters:n.parameters}:r}}return{...e,status:`running`}});case`action:progress`:return this.updatePart(n.turnId,n.partId,t,e=>{if(e.type!==`action`)return e;let t=e.detail.result,r=t?.type===`in-progress`?t.content:``;return{...e,detail:{...e.detail,result:{type:`in-progress`,content:r+n.chunk}}}});case`action:complete`:return this.updatePart(n.turnId,n.partId,t,e=>e.type===`action`?{...e,status:`complete`,detail:{...e.detail,result:n.result},timing:n.timing??e.timing}:e);case`action:error`:return this.updatePart(n.turnId,n.partId,t,e=>e.type===`action`?{...e,status:`error`,detail:{...e.detail,result:{type:`error`,error:n.error}},timing:n.timing??e.timing}:e);case`turn:end`:return this.updateTurn(n.turnId,t,e=>({...e,status:n.status,usage:n.usage,timing:n.timing??e.timing}));case`annotation:start`:return this.addAnnotation(t);case`annotation:update`:return this.replaceAnnotation(t,!1);case`annotation:end`:return this.replaceAnnotation(t,!0);case`error`:return this.handled(t);case`action:child-event`:return this.updatePart(n.turnId,n.partId,t,t=>{if(t.type!==`action`||t.kind!==`agent`)return t;let r=new e({turns:t.detail.children}).apply(n.event);return{...t,detail:{...t.detail,children:r.state.turns}}});default:return{handled:!1,state:this._state,event:t}}}replaceState(e,t){return this._state=e,this.handled(t)}replaceTurns(e,t){return this.replaceState({...this._state,turns:e},t)}updateTurn(e,t,n){let r=!1,i=this._state.turns.map(t=>{if(t.id!==e)return t;let i=n(t);return i===t?t:(r=!0,i)});return r?this.replaceTurns(i,t):this.handled(t)}updatePart(e,t,n,r){return this.updateTurn(e,n,e=>{let n=!1,i=e.parts.map(e=>{if(e.id!==t)return e;let i=r(e);return i===e?e:(n=!0,i)});return n?{...e,parts:i}:e})}addAnnotation(e){let n=e,r=n.target,i=t(n.annotation);return!r||!i?this.handled(e):r.type===`session`?this.replaceState({...this._state,sessionAnnotations:[...this._state.sessionAnnotations??[],i]},e):r.type===`turn`?this.updateTurn(r.turnId,e,e=>({...e,annotations:[...e.annotations??[],i]})):r.type===`part`?this.updatePart(r.turnId,r.partId,e,e=>({...e,annotations:[...e.annotations??[],i]})):this.handled(e)}replaceAnnotation(e,r){let i=e,a=i.target,o=t(i.annotation,r);if(!a||!o)return this.handled(e);if(a.type===`session`){let t=n(this._state.sessionAnnotations,o);return t?this.replaceState({...this._state,sessionAnnotations:t},e):this.handled(e)}return a.type===`turn`?this.updateTurn(a.turnId,e,e=>{let t=n(e.annotations,o);return t?{...e,annotations:t}:e}):a.type===`part`?this.updatePart(a.turnId,a.partId,e,e=>{let t=n(e.annotations,o);return t?{...e,annotations:t}:e}):this.handled(e)}handled(e){return{handled:!0,state:this._state,event:e}}};function t(e,t=!1){if(!e)return;let n=t?e.status??`complete`:e.status,r={...e,placement:e.placement??`after`};return n?{...r,status:n}:r}function n(e,t){if(!e)return;let n=!1,r=e.map(e=>e.id===t.id?(n=!0,t):e);return n?r:void 0}export{e as t};
@@ -83,10 +83,7 @@ interface Span {
83
83
  }
84
84
  //#endregion
85
85
  //#region src/types.d.ts
86
- /**
87
- * Usage reported by a provider response.
88
- */
89
- interface Stats {
86
+ interface TokenStats {
90
87
  /** Total effective input tokens. Includes `cachedIn` and `cacheWriteIn` when reported. */
91
88
  in: number;
92
89
  /** Total output tokens. Includes `reasoningOut` when reported. */
@@ -98,6 +95,24 @@ interface Stats {
98
95
  /** Output tokens spent on reasoning/thinking. Included in `out`. */
99
96
  reasoningOut?: number;
100
97
  }
98
+ interface UsageEntry extends TokenStats {
99
+ /** Provider identifier. */
100
+ provider: string;
101
+ /** Model identifier. */
102
+ model: string;
103
+ }
104
+ /**
105
+ * Aggregate usage reported by an Axle operation.
106
+ *
107
+ * `breakdown` holds one entry per provider+model pair so cost can be
108
+ * reconstructed when an operation spans models (for example subagent tools).
109
+ * Entries explain the aggregate numeric fields and must not be added to them
110
+ * again.
111
+ */
112
+ interface Stats extends TokenStats {
113
+ /** @experimental The entry shape may gain dimensions in a minor release. */
114
+ breakdown?: UsageEntry[];
115
+ }
101
116
  //#endregion
102
117
  //#region src/messages/stream.d.ts
103
118
  interface StreamChunk {
@@ -303,15 +318,6 @@ type DeferredFileInfo = FileInfo & {
303
318
  ref: unknown;
304
319
  };
305
320
  };
306
- type ConcreteFileInfo = FileInfo & {
307
- source: {
308
- type: "text";
309
- } | {
310
- type: "base64";
311
- } | {
312
- type: "url";
313
- };
314
- };
315
321
  type FileProviderId = "anthropic" | "openai" | "gemini" | "chatcompletions";
316
322
  type FileResolveFormat = "base64" | "url" | "text" | "gemini-file-uri";
317
323
  type ResolvedFileSource = {
@@ -409,11 +415,22 @@ interface AxleModelRequestOptions {
409
415
  }
410
416
  interface AIProvider {
411
417
  get name(): string;
418
+ /**
419
+ * Resolves a portable provider-tool name to the provider-native name.
420
+ * Returning undefined marks the tool unsupported. When omitted, Axle
421
+ * preserves the provider's existing passthrough behavior.
422
+ *
423
+ * @internal
424
+ */
425
+ resolveProviderToolName?(name: string, model: string): string | undefined;
412
426
  /** @internal */
413
427
  createGenerationRequest(model: string, params: ProviderGenerationParams): Promise<ModelResult>;
414
428
  /** @internal */
415
429
  createStreamingRequest(model: string, params: ProviderStreamParams): AsyncGenerator<AnyStreamChunk, void, unknown>;
416
430
  }
431
+ interface ResolvedProviderTool extends ProviderTool {
432
+ nativeName?: string;
433
+ }
417
434
  /**
418
435
  * Parameters passed to provider adapters for one non-streaming generation call.
419
436
  */
@@ -425,7 +442,7 @@ interface ProviderGenerationParams extends AxleModelRequestOptions {
425
442
  /** Executable tools exposed as provider function tools. */
426
443
  tools?: Array<ToolDefinition>;
427
444
  /** Provider-managed tools such as web search or code execution. */
428
- providerTools?: Array<ProviderTool>;
445
+ providerTools?: Array<ResolvedProviderTool>;
429
446
  /** Internal services available during provider request creation. */
430
447
  runtime: ProviderRuntime;
431
448
  }
@@ -510,14 +527,15 @@ type MessageMetadata = Record<string, unknown>;
510
527
  * Content returned by a tool call.
511
528
  *
512
529
  * Tool results may be simple text or structured parts when the result includes
513
- * file data.
530
+ * file data. Deferred file sources remain authored in history and are resolved
531
+ * at each provider conversion boundary so expiring URLs are not persisted.
514
532
  */
515
533
  type ToolResultPart = {
516
534
  type: "text";
517
535
  text: string;
518
536
  } | {
519
537
  type: "file";
520
- file: ConcreteFileInfo;
538
+ file: FileInfo;
521
539
  };
522
540
  /**
523
541
  * Message authored by the user or host application.
@@ -750,56 +768,6 @@ interface ContentPartCitation {
750
768
  providerMetadata?: Record<string, unknown>;
751
769
  }
752
770
  //#endregion
753
- //#region src/tools/registry.d.ts
754
- declare class ToolRegistry {
755
- private tools;
756
- private mcpTools;
757
- private providerTools;
758
- constructor(init?: {
759
- tools?: ExecutableTool[];
760
- providerTools?: ProviderTool[];
761
- });
762
- add(tool: ExecutableTool): void;
763
- add(tools: ExecutableTool[]): void;
764
- addMcp(tool: ExecutableTool): void;
765
- addMcp(tools: ExecutableTool[]): void;
766
- addProvider(tool: ProviderTool): void;
767
- addProvider(tools: ProviderTool[]): void;
768
- remove(name: string): boolean;
769
- has(name: string): boolean;
770
- get(name: string): ExecutableTool | undefined;
771
- getProvider(name: string): ProviderTool | undefined;
772
- executable(): ExecutableTool[];
773
- local(): ExecutableTool[];
774
- mcp(): ExecutableTool[];
775
- provider(): ProviderTool[];
776
- get size(): number;
777
- }
778
- //#endregion
779
- //#region src/tools/types.d.ts
780
- interface ToolContext {
781
- registry: ToolRegistry;
782
- signal: AbortSignal;
783
- emit: (chunk: string) => void;
784
- span?: Span;
785
- }
786
- interface ExecutableTool<TSchema extends ZodObject<any> = ZodObject<any>> {
787
- type?: "function";
788
- name: string;
789
- description: string;
790
- schema: TSchema;
791
- execute(input: z.infer<TSchema>, ctx: ToolContext): Promise<string | ToolResultPart[]>;
792
- configure?(config: Record<string, any>): void;
793
- summarize?(input: z.infer<TSchema>): string;
794
- }
795
- interface ProviderTool {
796
- type: "provider";
797
- name: string;
798
- /** Provider-specific passthrough config. Field names and placement are not portable. */
799
- config?: Record<string, unknown>;
800
- }
801
- type ToolDefinition = Pick<ExecutableTool, "name" | "description" | "schema">;
802
- //#endregion
803
771
  //#region src/turns/types.d.ts
804
772
  /**
805
773
  * Lifecycle state for a renderable turn.
@@ -1163,6 +1131,69 @@ type TurnEvent<TAnnotation extends Annotation = Annotation> = {
1163
1131
  };
1164
1132
  };
1165
1133
  //#endregion
1134
+ //#region src/tools/registry.d.ts
1135
+ declare class ToolRegistry {
1136
+ private tools;
1137
+ private mcpTools;
1138
+ private providerTools;
1139
+ constructor(init?: {
1140
+ tools?: ExecutableTool[];
1141
+ providerTools?: ProviderTool[];
1142
+ });
1143
+ add(tool: ExecutableTool): void;
1144
+ add(tools: ExecutableTool[]): void;
1145
+ addMcp(tool: ExecutableTool): void;
1146
+ addMcp(tools: ExecutableTool[]): void;
1147
+ addProvider(tool: ProviderTool): void;
1148
+ addProvider(tools: ProviderTool[]): void;
1149
+ remove(name: string): boolean;
1150
+ has(name: string): boolean;
1151
+ get(name: string): ExecutableTool | undefined;
1152
+ getProvider(name: string): ProviderTool | undefined;
1153
+ executable(): ExecutableTool[];
1154
+ local(): ExecutableTool[];
1155
+ mcp(): ExecutableTool[];
1156
+ provider(): ProviderTool[];
1157
+ get size(): number;
1158
+ }
1159
+ //#endregion
1160
+ //#region src/tools/types.d.ts
1161
+ type ToolProgressChunk = string | {
1162
+ type: "turn-event";
1163
+ event: TurnEvent;
1164
+ };
1165
+ interface ToolContext {
1166
+ registry: ToolRegistry;
1167
+ signal: AbortSignal;
1168
+ emit: (chunk: ToolProgressChunk) => void;
1169
+ /**
1170
+ * Report model usage incurred while executing this tool (for example a
1171
+ * subagent's tokens) so it is rolled into the parent operation's totals.
1172
+ *
1173
+ * @experimental
1174
+ */
1175
+ reportUsage?: (usage: Stats) => void;
1176
+ span?: Span;
1177
+ }
1178
+ interface ExecutableTool<TSchema extends ZodObject<any> = ZodObject<any>> {
1179
+ type?: "function";
1180
+ /** Presentation metadata. Agent-backed tools set "agent"; execution is identical. */
1181
+ kind?: "tool" | "agent";
1182
+ name: string;
1183
+ description: string;
1184
+ schema: TSchema;
1185
+ execute(input: z.infer<TSchema>, ctx: ToolContext): Promise<string | ToolResultPart[]>;
1186
+ configure?(config: Record<string, any>): void;
1187
+ summarize?(input: z.infer<TSchema>): string;
1188
+ }
1189
+ interface ProviderTool {
1190
+ type: "provider";
1191
+ name: string;
1192
+ /** Provider-specific passthrough config. Field names and placement are not portable. */
1193
+ config?: Record<string, unknown>;
1194
+ }
1195
+ type ToolDefinition = Pick<ExecutableTool, "name" | "description" | "schema">;
1196
+ //#endregion
1166
1197
  //#region src/turns/accumulator.d.ts
1167
1198
  interface TurnAccumulatorState<TAnnotation extends Annotation = Annotation> {
1168
1199
  turns: Turn<TAnnotation>[];
@@ -1195,4 +1226,4 @@ declare class TurnAccumulator<TAnnotation extends Annotation = Annotation, THost
1195
1226
  private handled;
1196
1227
  }
1197
1228
  //#endregion
1198
- export { ContextUsage as $, ToolRegistry as A, ContentPartCitation as B, TurnMetadata as C, SpanResult as Ct, ProviderTool as D, ToolResult as Dt, ExecutableTool as E, TokenUsage as Et, AxleUserMessage as F, ContentPartToolCall as G, ContentPartProviderTool as H, Citation as I, ThinkingContinuity as J, DocumentLocator as K, CitationOutputSpan as L, AxleMessage as M, AxleToolCallMessage as N, ToolContext as O, TraceWriter as Ot, AxleToolCallResult as P, AxleStopReason as Q, CitationSource as R, Turn as S, SpanOptions as St, TurnStatus as T, SpanType as Tt, ContentPartText as U, ContentPartFile as V, ContentPartThinking as W, AIProvider as X, ToolResultPart as Y, AxleModelRequestOptions as Z, SubagentAction as _, LLMResponse as _t, UnknownEvent as a, DeferredFileInfo as at, TimingInfo as b, SpanData as bt, TurnEvent as c, FileProviderId as ct, Annotation as d, FileResolver as dt, ModelError as et, AnnotationPlacement as f, ResolvedFileSource as ft, ProviderToolAction as g, LLMRequest as gt, FilePart as h, EventLevel as ht, TurnAccumulatorState as i, ToolChoice as it, AxleAssistantMessage as j, ToolDefinition as k, ActionPart as l, FileResolveFormat as lt, CitationPart as m, Stats as mt, TurnAccumulator as n, ProviderClientOptions as nt, AnnotationEvent as o, FileInfo as ot, AnnotationStatus as p, loadFileContent as pt, MessageMetadata as q, TurnAccumulatorResult as r, ProviderOptions as rt, AnnotationTarget as s, FileKind as st, AccumulatableEvent as t, ModelResult as tt, ActionResult as u, FileResolveRequest as ut, TextPart as v, LLMResult as vt, TurnPart as w, SpanStatus as wt, ToolAction as x, SpanEvent as xt, ThinkingPart as y, Span as yt, ContentPart as z };
1229
+ export { AxleStopReason as $, TurnPart as A, TokenUsage as At, ContentPart as B, SubagentAction as C, Span as Ct, ToolAction as D, SpanResult as Dt, TimingInfo as E, SpanOptions as Et, AxleToolCallResult as F, ContentPartThinking as G, ContentPartFile as H, AxleUserMessage as I, MessageMetadata as J, ContentPartToolCall as K, Citation as L, AxleAssistantMessage as M, TraceWriter as Mt, AxleMessage as N, Turn as O, SpanStatus as Ot, AxleToolCallMessage as P, AxleModelRequestOptions as Q, CitationOutputSpan as R, ProviderToolAction as S, LLMResult as St, ThinkingPart as T, SpanEvent as Tt, ContentPartProviderTool as U, ContentPartCitation as V, ContentPartText as W, ToolResultPart as X, ThinkingContinuity as Y, AIProvider as Z, Annotation as _, TokenStats as _t, UnknownEvent as a, ResolvedProviderTool as at, CitationPart as b, LLMRequest as bt, ToolContext as c, FileInfo as ct, ToolRegistry as d, FileResolveFormat as dt, ContextUsage as et, AnnotationEvent as f, FileResolveRequest as ft, ActionResult as g, Stats as gt, ActionPart as h, loadFileContent as ht, TurnAccumulatorState as i, ProviderOptions as it, TurnStatus as j, ToolResult as jt, TurnMetadata as k, SpanType as kt, ToolDefinition as l, FileKind as lt, TurnEvent as m, ResolvedFileSource as mt, TurnAccumulator as n, ModelResult as nt, ExecutableTool as o, ToolChoice as ot, AnnotationTarget as p, FileResolver as pt, DocumentLocator as q, TurnAccumulatorResult as r, ProviderClientOptions as rt, ProviderTool as s, DeferredFileInfo as st, AccumulatableEvent as t, ModelError as tt, ToolProgressChunk as u, FileProviderId as ut, AnnotationPlacement as v, UsageEntry as vt, TextPart as w, SpanData as wt, FilePart as x, LLMResponse as xt, AnnotationStatus as y, EventLevel as yt, CitationSource as z };
package/dist/index.d.ts CHANGED
@@ -1,6 +1,50 @@
1
- import { $ as ContextUsage, A as ToolRegistry, B as ContentPartCitation, C as TurnMetadata, Ct as SpanResult, D as ProviderTool, Dt as ToolResult, E as ExecutableTool, Et as TokenUsage, F as AxleUserMessage, G as ContentPartToolCall, H as ContentPartProviderTool, I as Citation, J as ThinkingContinuity, K as DocumentLocator, L as CitationOutputSpan, M as AxleMessage, N as AxleToolCallMessage, O as ToolContext, Ot as TraceWriter, P as AxleToolCallResult, Q as AxleStopReason, R as CitationSource, S as Turn, St as SpanOptions, T as TurnStatus, Tt as SpanType, U as ContentPartText, V as ContentPartFile, W as ContentPartThinking, X as AIProvider, Y as ToolResultPart, Z as AxleModelRequestOptions, _ as SubagentAction, _t as LLMResponse, at as DeferredFileInfo, bt as SpanData, c as TurnEvent, ct as FileProviderId, d as Annotation, dt as FileResolver, et as ModelError, f as AnnotationPlacement, ft as ResolvedFileSource, g as ProviderToolAction, gt as LLMRequest, h as FilePart, ht as EventLevel, i as TurnAccumulatorState, it as ToolChoice, j as AxleAssistantMessage, k as ToolDefinition, l as ActionPart, lt as FileResolveFormat, m as CitationPart, mt as Stats, n as TurnAccumulator, nt as ProviderClientOptions, o as AnnotationEvent, ot as FileInfo, p as AnnotationStatus, pt as loadFileContent, q as MessageMetadata, r as TurnAccumulatorResult, rt as ProviderOptions, s as AnnotationTarget, st as FileKind, t as AccumulatableEvent, tt as ModelResult, u as ActionResult, ut as FileResolveRequest, v as TextPart, vt as LLMResult, w as TurnPart, wt as SpanStatus, x as ToolAction, xt as SpanEvent, y as ThinkingPart, yt as Span, z as ContentPart } from "./accumulator-C4O3UCxY.js";
1
+ import { $ as AxleStopReason, A as TurnPart, At as TokenUsage, B as ContentPart, C as SubagentAction, Ct as Span, D as ToolAction, Dt as SpanResult, Et as SpanOptions, F as AxleToolCallResult, G as ContentPartThinking, H as ContentPartFile, I as AxleUserMessage, J as MessageMetadata, K as ContentPartToolCall, L as Citation, M as AxleAssistantMessage, Mt as TraceWriter, N as AxleMessage, O as Turn, Ot as SpanStatus, P as AxleToolCallMessage, Q as AxleModelRequestOptions, R as CitationOutputSpan, S as ProviderToolAction, St as LLMResult, T as ThinkingPart, Tt as SpanEvent, U as ContentPartProviderTool, V as ContentPartCitation, W as ContentPartText, X as ToolResultPart, Y as ThinkingContinuity, Z as AIProvider, _ as Annotation, _t as TokenStats, at as ResolvedProviderTool, b as CitationPart, bt as LLMRequest, c as ToolContext, ct as FileInfo, d as ToolRegistry, dt as FileResolveFormat, et as ContextUsage, f as AnnotationEvent, ft as FileResolveRequest, g as ActionResult, gt as Stats, h as ActionPart, ht as loadFileContent, i as TurnAccumulatorState, it as ProviderOptions, j as TurnStatus, jt as ToolResult, k as TurnMetadata, kt as SpanType, l as ToolDefinition, lt as FileKind, m as TurnEvent, mt as ResolvedFileSource, n as TurnAccumulator, nt as ModelResult, o as ExecutableTool, ot as ToolChoice, p as AnnotationTarget, pt as FileResolver, q as DocumentLocator, r as TurnAccumulatorResult, rt as ProviderClientOptions, s as ProviderTool, st as DeferredFileInfo, t as AccumulatableEvent, tt as ModelError, u as ToolProgressChunk, ut as FileProviderId, v as AnnotationPlacement, vt as UsageEntry, w as TextPart, wt as SpanData, x as FilePart, xt as LLMResponse, y as AnnotationStatus, yt as EventLevel, z as CitationSource } from "./accumulator-j9h_1Eyk.js";
2
2
  import * as z$2 from "zod";
3
+ import { ZodObject, z } from "zod";
3
4
 
5
+ //#region src/tools/webSearch.d.ts
6
+ interface WebSearchRequest {
7
+ query: string;
8
+ }
9
+ interface WebSearchResult {
10
+ title: string;
11
+ url: string;
12
+ snippets: string[];
13
+ }
14
+ interface WebSearchResponse {
15
+ results: WebSearchResult[];
16
+ }
17
+ interface WebSearchBackendContext {
18
+ signal: AbortSignal;
19
+ span?: Span;
20
+ }
21
+ interface WebSearchBackend {
22
+ readonly name: string;
23
+ search(request: WebSearchRequest, context: WebSearchBackendContext): Promise<WebSearchResponse>;
24
+ }
25
+ interface BraveWebSearchOptions {
26
+ apiKey: string;
27
+ endpoint?: string;
28
+ maxResults?: number;
29
+ candidateCount?: number;
30
+ maxTokens?: number;
31
+ maxSnippets?: number;
32
+ maxTokensPerUrl?: number;
33
+ maxSnippetsPerUrl?: number;
34
+ contextThresholdMode?: string;
35
+ country?: string;
36
+ searchLanguage?: string;
37
+ freshness?: "pd" | "pw" | "pm" | "py" | `${string}to${string}`;
38
+ timeoutMs?: number;
39
+ }
40
+ declare function braveWebSearch(options: BraveWebSearchOptions): WebSearchBackend;
41
+ //#endregion
42
+ //#region src/config.d.ts
43
+ interface AxleConfiguration {
44
+ webSearchFallback?: WebSearchBackend;
45
+ }
46
+ declare function configureAxle(options: AxleConfiguration): void;
47
+ //#endregion
4
48
  //#region src/mcp/MCP.d.ts
5
49
  interface MCPStdioConfig {
6
50
  transport: "stdio";
@@ -55,6 +99,10 @@ declare function parseResponse<T extends OutputSchema>(rawValue: string, schema?
55
99
  //#region src/core/Instruct.d.ts
56
100
  type InstructInputs = Record<string, unknown>;
57
101
  type InstructVarsMode = "required" | "optional";
102
+ interface InstructContextSection {
103
+ content: string;
104
+ title?: string;
105
+ }
58
106
  interface InstructOptions<TSchema extends OutputSchema | undefined = OutputSchema | undefined> {
59
107
  prompt: string;
60
108
  schema?: TSchema;
@@ -69,6 +117,7 @@ declare class Instruct<TSchema extends OutputSchema | undefined = undefined> {
69
117
  content: string;
70
118
  name?: string;
71
119
  }>;
120
+ contextSections: InstructContextSection[];
72
121
  vars: InstructVarsMode;
73
122
  metadata?: MessageMetadata;
74
123
  schema: TSchema;
@@ -81,6 +130,10 @@ declare class Instruct<TSchema extends OutputSchema | undefined = undefined> {
81
130
  addFile(file: FileInfo | string, options?: {
82
131
  name?: string;
83
132
  }): void;
133
+ /** Append host-supplied supporting material without modifying the authored prompt. */
134
+ addContext(content: string, options?: {
135
+ title?: string;
136
+ }): this;
84
137
  hasFiles(): boolean;
85
138
  render(options?: {
86
139
  vars?: InstructVarsMode;
@@ -179,6 +232,80 @@ declare class Tracer {
179
232
  flush(): Promise<void>;
180
233
  }
181
234
  //#endregion
235
+ //#region src/errors/AxleError.d.ts
236
+ declare class AxleError extends Error {
237
+ readonly code: string;
238
+ readonly id?: string;
239
+ readonly details?: Record<string, any>;
240
+ constructor(message: string, options?: {
241
+ code?: string;
242
+ id?: string;
243
+ details?: Record<string, any>;
244
+ cause?: unknown;
245
+ });
246
+ toJSON(): {
247
+ cause?: unknown;
248
+ details?: Record<string, any> | undefined;
249
+ id?: string | undefined;
250
+ name: string;
251
+ message: string;
252
+ code: string;
253
+ };
254
+ }
255
+ //#endregion
256
+ //#region src/errors/AxleAbortError.d.ts
257
+ declare class AxleAbortError extends AxleError {
258
+ readonly reason: unknown;
259
+ readonly messages?: AxleMessage[];
260
+ readonly partial?: AxleAssistantMessage;
261
+ readonly usage?: Stats;
262
+ constructor(message?: string, options?: {
263
+ reason?: unknown;
264
+ messages?: AxleMessage[];
265
+ partial?: AxleAssistantMessage;
266
+ usage?: Stats;
267
+ });
268
+ toJSON(): {
269
+ usage?: Stats | undefined;
270
+ partial?: AxleAssistantMessage | undefined;
271
+ messages?: AxleMessage[] | undefined;
272
+ reason: unknown;
273
+ cause?: unknown;
274
+ details?: Record<string, any> | undefined;
275
+ id?: string | undefined;
276
+ name: string;
277
+ message: string;
278
+ code: string;
279
+ };
280
+ }
281
+ //#endregion
282
+ //#region src/errors/AxleToolFatalError.d.ts
283
+ declare class AxleToolFatalError extends AxleError {
284
+ readonly toolName?: string;
285
+ readonly messages?: AxleMessage[];
286
+ readonly partial?: AxleAssistantMessage;
287
+ readonly usage?: Stats;
288
+ constructor(message?: string, options?: {
289
+ toolName?: string;
290
+ messages?: AxleMessage[];
291
+ partial?: AxleAssistantMessage;
292
+ usage?: Stats;
293
+ cause?: unknown;
294
+ });
295
+ toJSON(): {
296
+ usage?: Stats | undefined;
297
+ partial?: AxleAssistantMessage | undefined;
298
+ messages?: AxleMessage[] | undefined;
299
+ toolName?: string | undefined;
300
+ cause?: unknown;
301
+ details?: Record<string, any> | undefined;
302
+ id?: string | undefined;
303
+ name: string;
304
+ message: string;
305
+ code: string;
306
+ };
307
+ }
308
+ //#endregion
182
309
  //#region src/providers/helpers.d.ts
183
310
  type ToolCallResult = {
184
311
  type: "success";
@@ -455,7 +582,7 @@ declare class Agent {
455
582
  addMcp(mcp: MCP): void;
456
583
  addMcps(mcps: MCP[]): void;
457
584
  hasTools(): boolean;
458
- on(callback: TurnEventCallback): void;
585
+ on(callback: TurnEventCallback): () => void;
459
586
  context(): ContextUsage;
460
587
  /**
461
588
  * Capture the serializable session state for later continuation.
@@ -495,53 +622,6 @@ declare function createAgentConfig(definition: AgentDefinition, resolver: AgentD
495
622
  //#region src/core/userTurn.d.ts
496
623
  type InstructResponse<TSchema extends OutputSchema | undefined> = TSchema extends OutputSchema ? ParsedSchema<TSchema> : string;
497
624
  //#endregion
498
- //#region src/errors/AxleError.d.ts
499
- declare class AxleError extends Error {
500
- readonly code: string;
501
- readonly id?: string;
502
- readonly details?: Record<string, any>;
503
- constructor(message: string, options?: {
504
- code?: string;
505
- id?: string;
506
- details?: Record<string, any>;
507
- cause?: unknown;
508
- });
509
- toJSON(): {
510
- cause?: unknown;
511
- details?: Record<string, any> | undefined;
512
- id?: string | undefined;
513
- name: string;
514
- message: string;
515
- code: string;
516
- };
517
- }
518
- //#endregion
519
- //#region src/errors/AxleAbortError.d.ts
520
- declare class AxleAbortError extends AxleError {
521
- readonly reason: unknown;
522
- readonly messages?: AxleMessage[];
523
- readonly partial?: AxleAssistantMessage;
524
- readonly usage?: Stats;
525
- constructor(message?: string, options?: {
526
- reason?: unknown;
527
- messages?: AxleMessage[];
528
- partial?: AxleAssistantMessage;
529
- usage?: Stats;
530
- });
531
- toJSON(): {
532
- usage?: Stats | undefined;
533
- partial?: AxleAssistantMessage | undefined;
534
- messages?: AxleMessage[] | undefined;
535
- reason: unknown;
536
- cause?: unknown;
537
- details?: Record<string, any> | undefined;
538
- id?: string | undefined;
539
- name: string;
540
- message: string;
541
- code: string;
542
- };
543
- }
544
- //#endregion
545
625
  //#region src/errors/AxleAgentAbortError.d.ts
546
626
  declare class AxleAgentAbortError extends AxleAbortError {
547
627
  readonly turn?: Turn;
@@ -567,33 +647,6 @@ declare class AxleAgentAbortError extends AxleAbortError {
567
647
  };
568
648
  }
569
649
  //#endregion
570
- //#region src/errors/AxleToolFatalError.d.ts
571
- declare class AxleToolFatalError extends AxleError {
572
- readonly toolName?: string;
573
- readonly messages?: AxleMessage[];
574
- readonly partial?: AxleAssistantMessage;
575
- readonly usage?: Stats;
576
- constructor(message?: string, options?: {
577
- toolName?: string;
578
- messages?: AxleMessage[];
579
- partial?: AxleAssistantMessage;
580
- usage?: Stats;
581
- cause?: unknown;
582
- });
583
- toJSON(): {
584
- usage?: Stats | undefined;
585
- partial?: AxleAssistantMessage | undefined;
586
- messages?: AxleMessage[] | undefined;
587
- toolName?: string | undefined;
588
- cause?: unknown;
589
- details?: Record<string, any> | undefined;
590
- id?: string | undefined;
591
- name: string;
592
- message: string;
593
- code: string;
594
- };
595
- }
596
- //#endregion
597
650
  //#region src/errors/InstructVariableError.d.ts
598
651
  declare class InstructVariableError extends AxleError {
599
652
  readonly missingVariables: string[];
@@ -646,9 +699,13 @@ declare const Anthropic: {
646
699
  readonly DefaultModel: "claude-haiku-4-5-20251001";
647
700
  };
648
701
  //#endregion
702
+ //#region src/providers/chatcompletions/utils.d.ts
703
+ type ChatCompletionsProviderDialect = "together";
704
+ //#endregion
649
705
  //#region src/providers/chatcompletions/provider.d.ts
650
706
  interface ChatCompletionsOptions extends ProviderClientOptions {
651
707
  apiKey?: string;
708
+ providerDialect?: ChatCompletionsProviderDialect;
652
709
  providerToolVendor?: "openrouter";
653
710
  }
654
711
  declare function chatCompletions(baseUrl: string, options?: ChatCompletionsOptions): AIProvider;
@@ -725,7 +782,7 @@ interface GenerateTurnParams extends AxleModelRequestOptions {
725
782
  messages: Array<AxleMessage>;
726
783
  system?: string;
727
784
  tools?: Array<ToolDefinition>;
728
- providerTools?: Array<ProviderTool>;
785
+ providerTools?: Array<ResolvedProviderTool>;
729
786
  span?: Span;
730
787
  fileResolver?: FileResolver;
731
788
  }
@@ -799,6 +856,7 @@ type StreamEvent = {
799
856
  index: number;
800
857
  id: string;
801
858
  name: string;
859
+ kind?: "tool" | "agent";
802
860
  } | {
803
861
  type: "tool:args-delta";
804
862
  index: number;
@@ -817,13 +875,24 @@ type StreamEvent = {
817
875
  index: number;
818
876
  id: string;
819
877
  name: string;
820
- chunk: string;
878
+ chunk: ToolProgressChunk;
821
879
  } | {
822
880
  type: "tool:exec-complete";
823
881
  index: number;
824
882
  id: string;
825
883
  name: string;
826
884
  result: ToolCallResult;
885
+ usage?: Stats;
886
+ } | {
887
+ type: "tool:exec-error";
888
+ index: number;
889
+ id: string;
890
+ name: string;
891
+ error: {
892
+ type: "fatal" | "aborted";
893
+ message: string;
894
+ };
895
+ usage?: Stats;
827
896
  } | {
828
897
  type: "provider-tool:start";
829
898
  index: number;
@@ -927,6 +996,70 @@ declare const OpenAI: {
927
996
  readonly DefaultModel: "gpt-5.4-mini";
928
997
  };
929
998
  //#endregion
999
+ //#region src/tools/agentTool.d.ts
1000
+ interface CreateAgentToolOptions<TSchema extends ZodObject<any>> {
1001
+ name: string;
1002
+ description: string;
1003
+ schema: TSchema;
1004
+ /** Create the child agent for this tool call. Fresh agents are recommended. */
1005
+ createAgent: (input: z.infer<TSchema>, ctx: ToolContext) => MaybePromise<Agent>;
1006
+ /**
1007
+ * Convert tool input into the child-agent user prompt. Defaults to a compact
1008
+ * JSON task payload.
1009
+ */
1010
+ prompt?: string | ((input: z.infer<TSchema>) => string);
1011
+ /** Per-send request overrides for the child agent. */
1012
+ request?: AxleModelRequestOptions;
1013
+ }
1014
+ /**
1015
+ * Expose an Agent as a normal executable tool.
1016
+ *
1017
+ * This lets a parent model delegate bounded work to a child agent while only
1018
+ * receiving the child agent's final response. The child's turn events are
1019
+ * forwarded through `ctx.emit` and its token usage through `ctx.reportUsage`,
1020
+ * so parents can render live progress and reconstruct cost.
1021
+ *
1022
+ * @experimental Shapes related to subagent rendering may change in a minor
1023
+ * release.
1024
+ */
1025
+ declare function createAgentTool<TSchema extends ZodObject<any>>(options: CreateAgentToolOptions<TSchema>): ExecutableTool<TSchema>;
1026
+ //#endregion
1027
+ //#region src/tools/parallelize.d.ts
1028
+ interface ParallelizeOptions {
1029
+ /** Name of the generated batch tool. Defaults to `${tool.name}_batch`. */
1030
+ name?: string;
1031
+ /** Description of the generated batch tool. */
1032
+ description?: string;
1033
+ /** Maximum items accepted by the generated tool schema. */
1034
+ maxItems?: number;
1035
+ /** Maximum inner tool calls to run concurrently. */
1036
+ maxConcurrency?: number;
1037
+ }
1038
+ interface ParallelToolResult<TInput = unknown> {
1039
+ index: number;
1040
+ input: TInput;
1041
+ ok: boolean;
1042
+ output?: string | ToolResultPart[];
1043
+ error?: {
1044
+ type: "execution";
1045
+ message: string;
1046
+ };
1047
+ }
1048
+ /**
1049
+ * Create a batch tool that runs a tool over many input items concurrently.
1050
+ *
1051
+ * The generated tool preserves result order and reports per-item failures
1052
+ * instead of failing the whole batch for ordinary execution errors. Fatal
1053
+ * and abort errors are not demoted: they propagate and terminate the run,
1054
+ * matching the unbatched tool contract.
1055
+ *
1056
+ * @experimental The generated tool's result JSON (`ParallelToolResult`) may
1057
+ * change in a minor release.
1058
+ */
1059
+ declare function parallelize<TSchema extends ZodObject<any>>(tool: ExecutableTool<TSchema>, options?: ParallelizeOptions): ExecutableTool<ZodObject<{
1060
+ items: z.ZodArray<TSchema>;
1061
+ }>>;
1062
+ //#endregion
930
1063
  //#region src/turns/eventBuilder.d.ts
931
1064
  declare class TurnEventBuilder {
932
1065
  private currentTurnId;
@@ -1001,5 +1134,6 @@ interface FileStore {
1001
1134
  //#region src/utils/stats.d.ts
1002
1135
  declare function createStats(): Stats;
1003
1136
  declare function addStats(total: Stats, usage?: Stats): void;
1137
+ declare function mergeStats(...usages: Array<Stats | undefined>): Stats;
1004
1138
  //#endregion
1005
- export { type AIProvider, type AccumulatableEvent, type ActionPart, type ActionResult, Agent, type AgentConfig, type AgentDefinition, type AgentDefinitionRequestOptions, type AgentDefinitionResolver, type AgentErrorResult, type AgentHandle, type AgentMemory, type AgentResult, type AgentSession, type Annotation, type AnnotationEvent, type AnnotationPlacement, type AnnotationStatus, type AnnotationTarget, Anthropic, AxleAbortError, AxleAgentAbortError, type AxleAssistantMessage, AxleError, type AxleMessage, type AxleModelRequestOptions, AxleStopReason, type AxleToolCallMessage, type AxleToolCallResult, AxleToolFatalError, type AxleUserMessage, type ChatCompletionsOptions, type Citation, type CitationOutputSpan, type CitationPart, type CitationSource, type ContentPart, type ContentPartCitation, type ContentPartFile, type ContentPartProviderTool, type ContentPartText, type ContentPartThinking, type ContentPartToolCall, type ContextUsage, type DeferredFileInfo, type DocumentLocator, type EventLevel, type ExecutableTool, type FileInfo, type FileKind, type FilePart, type FileProviderId, type FileResolveFormat, type FileResolveRequest, type FileResolver, type FileStore, Gemini, type GenerateInstructParams, type GenerateInstructResult, type GenerateParams, type Handle, History, Instruct, type InstructInputs, type InstructOptions, type InstructResponse, InstructVariableError, type InstructVarsMode, type LLMRequest, type LLMResponse, type LLMResult, type LogEntry, type LogFn, LogWriter, MCP, type MCPConfig, type MCPHttpConfig, type MCPStdioConfig, type MaybePromise, type MemoryContext, type MessageMetadata, type ObservabilityOptions, OpenAI, type OutputSchema, type ParsedSchema, type ProviderClientOptions, type ProviderDefinition, type ProviderOptions, type ProviderTool, type ProviderToolAction, type ProviderToolDefinitionRef, type RecallResult, type ResolvedAgentDefinition, type ResolvedFileSource, type SavedAgent, type SendMessageOptions, SimpleWriter, type SimpleWriterOptions, type Span, type SpanData, type SpanEvent, type SpanOptions, type SpanResult, type SpanStatus, type SpanType, type Stats, type StreamEvent, type StreamEventCallback, type StreamHandle, type StreamInstructHandle, type StreamInstructParams, type StreamInstructResult, type StreamParams, type StreamResult, type SubagentAction, TaskError, type TextPart, type ThinkingContinuity, type ThinkingPart, type TokenUsage, type ToolAction, type ToolChoice, type ToolContext, type ToolDefinition, type ToolDefinitionRef, ToolRegistry, type ToolResult, type ToolResultPart, type TraceWriter, Tracer, type TracerOptions, type Turn, TurnAccumulator, type TurnAccumulatorResult, type TurnAccumulatorState, type TurnEvent, TurnEventBuilder, type TurnEventCallback, type TurnMetadata, type TurnPart, type TurnStatus, addStats, anthropic, chatCompletions, createAgentConfig, createHandle, createStats, estimateContextUsage, gemini, generate, generateTurn, loadFileContent, openai, parseResponse, stream };
1139
+ export { type AIProvider, type AccumulatableEvent, type ActionPart, type ActionResult, Agent, type AgentConfig, type AgentDefinition, type AgentDefinitionRequestOptions, type AgentDefinitionResolver, type AgentErrorResult, type AgentHandle, type AgentMemory, type AgentResult, type AgentSession, type Annotation, type AnnotationEvent, type AnnotationPlacement, type AnnotationStatus, type AnnotationTarget, Anthropic, AxleAbortError, AxleAgentAbortError, type AxleAssistantMessage, type AxleConfiguration, AxleError, type AxleMessage, type AxleModelRequestOptions, AxleStopReason, type AxleToolCallMessage, type AxleToolCallResult, AxleToolFatalError, type AxleUserMessage, type BraveWebSearchOptions, type ChatCompletionsOptions, type Citation, type CitationOutputSpan, type CitationPart, type CitationSource, type ContentPart, type ContentPartCitation, type ContentPartFile, type ContentPartProviderTool, type ContentPartText, type ContentPartThinking, type ContentPartToolCall, type ContextUsage, type CreateAgentToolOptions, type DeferredFileInfo, type DocumentLocator, type EventLevel, type ExecutableTool, type FileInfo, type FileKind, type FilePart, type FileProviderId, type FileResolveFormat, type FileResolveRequest, type FileResolver, type FileStore, Gemini, type GenerateInstructParams, type GenerateInstructResult, type GenerateParams, type Handle, History, Instruct, type InstructContextSection, type InstructInputs, type InstructOptions, type InstructResponse, InstructVariableError, type InstructVarsMode, type LLMRequest, type LLMResponse, type LLMResult, type LogEntry, type LogFn, LogWriter, MCP, type MCPConfig, type MCPHttpConfig, type MCPStdioConfig, type MaybePromise, type MemoryContext, type MessageMetadata, type ObservabilityOptions, OpenAI, type OutputSchema, type ParallelToolResult, type ParallelizeOptions, type ParsedSchema, type ProviderClientOptions, type ProviderDefinition, type ProviderOptions, type ProviderTool, type ProviderToolAction, type ProviderToolDefinitionRef, type RecallResult, type ResolvedAgentDefinition, type ResolvedFileSource, type SavedAgent, type SendMessageOptions, SimpleWriter, type SimpleWriterOptions, type Span, type SpanData, type SpanEvent, type SpanOptions, type SpanResult, type SpanStatus, type SpanType, type Stats, type StreamEvent, type StreamEventCallback, type StreamHandle, type StreamInstructHandle, type StreamInstructParams, type StreamInstructResult, type StreamParams, type StreamResult, type SubagentAction, TaskError, type TextPart, type ThinkingContinuity, type ThinkingPart, type TokenStats, type TokenUsage, type ToolAction, type ToolChoice, type ToolContext, type ToolDefinition, type ToolDefinitionRef, type ToolProgressChunk, ToolRegistry, type ToolResult, type ToolResultPart, type TraceWriter, Tracer, type TracerOptions, type Turn, TurnAccumulator, type TurnAccumulatorResult, type TurnAccumulatorState, type TurnEvent, TurnEventBuilder, type TurnEventCallback, type TurnMetadata, type TurnPart, type TurnStatus, type UsageEntry, type WebSearchBackend, type WebSearchBackendContext, type WebSearchRequest, type WebSearchResponse, type WebSearchResult, addStats, anthropic, braveWebSearch, chatCompletions, configureAxle, createAgentConfig, createAgentTool, createHandle, createStats, estimateContextUsage, gemini, generate, generateTurn, loadFileContent, mergeStats, openai, parallelize, parseResponse, stream };