@fifthrevision/axle 0.19.0 → 0.21.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts CHANGED
@@ -1,366 +1,6 @@
1
- import { A as FileResolveRequest, B as TracingContext, C as TurnStatus, D as FileKind, E as FileInfo, F as SpanData, I as SpanEvent, L as SpanOptions, M as ResolvedFileSource, N as loadFileContent, O as FileProviderId, P as EventLevel, R as SpanType, S as TurnPart, T as DeferredFileInfo, V as Stats, _ as TextPart, b as ToolAction, c as TurnEvent, d as Annotation, f as AnnotationPlacement, g as SubagentAction, h as ProviderToolAction, i as TurnAccumulatorState, j as FileResolver, k as FileResolveFormat, l as ActionPart, m as FilePart, n as TurnAccumulator, o as AnnotationEvent, p as AnnotationStatus, r as TurnAccumulatorResult, s as AnnotationTarget, t as AccumulatableEvent, u as ActionResult, v as ThinkingPart, w as ConcreteFileInfo, x as Turn, z as TraceWriter } from "./accumulator-D2NgIGxp.js";
1
+ import { $ as ModelResult, A as AxleAssistantMessage, B as ContentPartProviderTool, C as TurnPart, D as ToolContext, E as ProviderTool, F as Citation, G as MessageMetadata, H as ContentPartThinking, I as CitationOutputSpan, J as AIProvider, K as ThinkingContinuity, L as CitationSource, M as AxleToolCallMessage, N as AxleToolCallResult, O as ToolDefinition, P as AxleUserMessage, Q as ModelError, R as ContentPart, S as TurnMetadata, T as ExecutableTool, U as ContentPartToolCall, V as ContentPartText, W as DocumentLocator, X as AxleStopReason, Y as AxleModelRequestOptions, Z as ContextUsage, _ as TextPart, _t as TraceWriter, at as FileKind, b as ToolAction, c as TurnEvent, ct as FileResolveRequest, d as Annotation, dt as loadFileContent, et as ProviderClientOptions, f as AnnotationPlacement, ft as EventLevel, g as SubagentAction, gt as SpanType, h as ProviderToolAction, ht as SpanOptions, i as TurnAccumulatorState, it as FileInfo, j as AxleMessage, k as ToolRegistry, l as ActionPart, lt as FileResolver, m as FilePart, mt as SpanEvent, n as TurnAccumulator, nt as ToolChoice, o as AnnotationEvent, ot as FileProviderId, p as AnnotationStatus, pt as SpanData, q as ToolResultPart, r as TurnAccumulatorResult, rt as DeferredFileInfo, s as AnnotationTarget, st as FileResolveFormat, t as AccumulatableEvent, tt as ProviderOptions, u as ActionResult, ut as ResolvedFileSource, v as ThinkingPart, vt as TracingContext, w as TurnStatus, x as Turn, yt as Stats, z as ContentPartFile } from "./accumulator-svhGVEwB.js";
2
2
  import * as z$2 from "zod";
3
- import { ZodObject, z } from "zod";
4
3
 
5
- //#region src/messages/stream.d.ts
6
- interface StreamChunk {
7
- type: "start" | "text-start" | "text-delta" | "text-complete" | "tool-call-start" | "tool-call-args-delta" | "tool-call-complete" | "thinking-start" | "thinking-delta" | "thinking-summary-delta" | "thinking-complete" | "provider-tool-start" | "provider-tool-complete" | "complete" | "error";
8
- id?: string;
9
- data?: any;
10
- }
11
- interface StreamStartChunk extends StreamChunk {
12
- type: "start";
13
- id: string;
14
- data: {
15
- model: string;
16
- timestamp: number;
17
- };
18
- }
19
- interface StreamCompleteChunk extends StreamChunk {
20
- type: "complete";
21
- data: {
22
- finishReason: AxleStopReason;
23
- usage: Stats;
24
- };
25
- }
26
- interface StreamErrorChunk extends StreamChunk {
27
- type: "error";
28
- data: {
29
- type: string;
30
- message: string;
31
- usage?: Stats;
32
- raw?: any;
33
- };
34
- }
35
- interface StreamTextStartChunk extends StreamChunk {
36
- type: "text-start";
37
- data: {
38
- index: number;
39
- };
40
- }
41
- interface StreamTextDeltaChunk extends StreamChunk {
42
- type: "text-delta";
43
- data: {
44
- index: number;
45
- text: string;
46
- };
47
- }
48
- interface StreamTextCompleteChunk extends StreamChunk {
49
- type: "text-complete";
50
- data: {
51
- index: number;
52
- };
53
- }
54
- interface StreamThinkingStartChunk extends StreamChunk {
55
- type: "thinking-start";
56
- data: {
57
- index: number;
58
- id?: string;
59
- redacted?: boolean;
60
- signature?: string;
61
- };
62
- }
63
- interface StreamThinkingDeltaChunk extends StreamChunk {
64
- type: "thinking-delta";
65
- data: {
66
- index: number;
67
- text: string;
68
- };
69
- }
70
- interface StreamThinkingSummaryDeltaChunk extends StreamChunk {
71
- type: "thinking-summary-delta";
72
- data: {
73
- index: number;
74
- text: string;
75
- };
76
- }
77
- interface StreamThinkingCompleteChunk extends StreamChunk {
78
- type: "thinking-complete";
79
- data: {
80
- index: number;
81
- };
82
- }
83
- interface StreamToolCallStartChunk extends StreamChunk {
84
- type: "tool-call-start";
85
- data: {
86
- index: number;
87
- id: string;
88
- name: string;
89
- };
90
- }
91
- interface StreamToolCallArgsDeltaChunk extends StreamChunk {
92
- type: "tool-call-args-delta";
93
- data: {
94
- index: number;
95
- id: string;
96
- name: string;
97
- delta: string;
98
- accumulated: string;
99
- };
100
- }
101
- interface StreamToolCallCompleteChunk extends StreamChunk {
102
- type: "tool-call-complete";
103
- data: {
104
- index: number;
105
- id: string;
106
- name: string;
107
- arguments: any;
108
- providerMetadata?: Record<string, unknown>;
109
- };
110
- }
111
- interface StreamProviderToolStartChunk extends StreamChunk {
112
- type: "provider-tool-start";
113
- data: {
114
- index: number;
115
- id: string;
116
- name: string;
117
- };
118
- }
119
- interface StreamProviderToolCompleteChunk extends StreamChunk {
120
- type: "provider-tool-complete";
121
- data: {
122
- index: number;
123
- id: string;
124
- name: string;
125
- output?: unknown;
126
- };
127
- }
128
- type AnyStreamChunk = StreamStartChunk | StreamCompleteChunk | StreamErrorChunk | StreamTextStartChunk | StreamTextDeltaChunk | StreamTextCompleteChunk | StreamThinkingStartChunk | StreamThinkingDeltaChunk | StreamThinkingSummaryDeltaChunk | StreamThinkingCompleteChunk | StreamToolCallStartChunk | StreamToolCallArgsDeltaChunk | StreamToolCallCompleteChunk | StreamProviderToolStartChunk | StreamProviderToolCompleteChunk;
129
- //#endregion
130
- //#region src/providers/types.d.ts
131
- /**
132
- * Internal services available to provider adapters while executing a model request.
133
- */
134
- interface ProviderRuntime {
135
- /** Request-scoped tracing span used by provider adapters. */
136
- tracer?: TracingContext;
137
- /** Resolves file references before provider-specific request conversion. */
138
- fileResolver?: FileResolver;
139
- }
140
- /**
141
- * Raw provider-specific request fields.
142
- *
143
- * Provider adapters apply this after Axle-normalized options, so these values
144
- * can intentionally override Axle's provider mappings.
145
- */
146
- interface ProviderOptions {
147
- [key: string]: any;
148
- }
149
- /**
150
- * Controls how the model may use tools during a single model request.
151
- */
152
- type ToolChoice = "auto" | "none" | "required" | {
153
- type: "tool";
154
- name: string;
155
- };
156
- /**
157
- * Provider-portable options for a single model request.
158
- *
159
- * These fields are normalized by Axle and mapped to each provider's request
160
- * shape. Use `providerOptions` for provider-specific controls that are not
161
- * represented here.
162
- */
163
- interface AxleModelRequestOptions {
164
- /** Enables or disables provider reasoning/thinking controls where supported. */
165
- reasoning?: boolean;
166
- /** Maximum output tokens to request from the model. */
167
- maxOutputTokens?: number;
168
- /** Sampling temperature, when supported by the provider/model. */
169
- temperature?: number;
170
- /** Nucleus sampling value, mapped to provider-specific casing. */
171
- topP?: number;
172
- /** Stop sequence or sequences for text generation. */
173
- stop?: string | string[];
174
- /** Constrains tool use for this model request. */
175
- toolChoice?: ToolChoice;
176
- /** Requests that the provider avoid parallel tool calls when supported. */
177
- parallelToolCalls?: boolean;
178
- /** Raw provider-specific request fields applied after normalized mappings. */
179
- providerOptions?: ProviderOptions;
180
- /** Abort signal for the in-flight model request. */
181
- signal?: AbortSignal;
182
- }
183
- /**
184
- * Parameters passed to provider adapters for one non-streaming generation call.
185
- */
186
- interface ProviderGenerationParams extends AxleModelRequestOptions {
187
- /** Conversation messages to send to the provider. */
188
- messages: Array<AxleMessage>;
189
- /** Optional system/developer instruction for the request. */
190
- system?: string;
191
- /** Executable tools exposed as provider function tools. */
192
- tools?: Array<ToolDefinition>;
193
- /** Provider-managed tools such as web search or code execution. */
194
- providerTools?: Array<ProviderTool>;
195
- /** Internal services available during provider request creation. */
196
- runtime: ProviderRuntime;
197
- }
198
- /**
199
- * Parameters passed to provider adapters for one streaming generation call.
200
- */
201
- interface ProviderStreamParams extends ProviderGenerationParams {}
202
- interface ContextUsage {
203
- total: number;
204
- system: number;
205
- tools: number;
206
- mcpTools: number;
207
- providerTools: number;
208
- messages: number;
209
- limit?: number;
210
- free?: number;
211
- }
212
- interface AIProvider {
213
- get name(): string;
214
- /** @internal */
215
- createGenerationRequest(model: string, params: ProviderGenerationParams): Promise<ModelResult>;
216
- /** @internal */
217
- createStreamingRequest(model: string, params: ProviderStreamParams): AsyncGenerator<AnyStreamChunk, void, unknown>;
218
- }
219
- interface ModelResponse {
220
- type: "success";
221
- role: "assistant";
222
- id: string;
223
- model: string;
224
- text: string;
225
- content: Array<ContentPartText | ContentPartThinking | ContentPartToolCall>;
226
- finishReason: AxleStopReason;
227
- usage: Stats;
228
- raw: any;
229
- }
230
- interface ModelError {
231
- type: "error";
232
- error: {
233
- type: string;
234
- message: string;
235
- };
236
- usage?: Stats;
237
- raw?: any;
238
- }
239
- type ModelResult = ModelResponse | ModelError;
240
- declare enum AxleStopReason {
241
- Stop = "stop",
242
- Length = "length",
243
- FunctionCall = "function_call",
244
- Error = "error",
245
- Custom = "custom",
246
- Cancelled = "cancelled"
247
- }
248
- //#endregion
249
- //#region src/messages/message.d.ts
250
- type AxleMessage = AxleUserMessage | AxleAssistantMessage | AxleToolCallMessage;
251
- type ToolResultPart = {
252
- type: "text";
253
- text: string;
254
- } | {
255
- type: "file";
256
- file: ConcreteFileInfo;
257
- };
258
- interface AxleUserMessage {
259
- role: "user";
260
- id?: string;
261
- name?: string;
262
- content: string | Array<ContentPart>;
263
- }
264
- interface AxleAssistantMessage {
265
- role: "assistant";
266
- id: string;
267
- model?: string;
268
- content: Array<ContentPartText | ContentPartThinking | ContentPartToolCall | ContentPartProviderTool>;
269
- finishReason?: AxleStopReason;
270
- }
271
- interface AxleToolCallMessage {
272
- role: "tool";
273
- id: string;
274
- content: Array<AxleToolCallResult>;
275
- }
276
- interface AxleToolCallResult {
277
- id: string;
278
- name: string;
279
- content: string | ToolResultPart[];
280
- isError?: boolean;
281
- }
282
- type ContentPart = ContentPartText | ContentPartFile | ContentPartToolCall | ContentPartThinking | ContentPartProviderTool;
283
- interface ContentPartText {
284
- type: "text";
285
- text: string;
286
- }
287
- interface ContentPartFile {
288
- type: "file";
289
- file: FileInfo;
290
- }
291
- interface ContentPartThinking {
292
- type: "thinking";
293
- id?: string;
294
- text: string;
295
- summary?: string;
296
- redacted?: boolean;
297
- encrypted?: string;
298
- signature?: string;
299
- }
300
- interface ContentPartToolCall {
301
- type: "tool-call";
302
- id: string;
303
- name: string;
304
- parameters: Record<string, unknown>;
305
- providerMetadata?: Record<string, unknown>;
306
- }
307
- interface ContentPartProviderTool {
308
- type: "provider-tool";
309
- id: string;
310
- name: string;
311
- input?: unknown;
312
- output?: unknown;
313
- }
314
- //#endregion
315
- //#region src/tools/registry.d.ts
316
- declare class ToolRegistry {
317
- private tools;
318
- private mcpTools;
319
- private providerTools;
320
- constructor(init?: {
321
- tools?: ExecutableTool[];
322
- providerTools?: ProviderTool[];
323
- });
324
- add(tool: ExecutableTool): void;
325
- add(tools: ExecutableTool[]): void;
326
- addMcp(tool: ExecutableTool): void;
327
- addMcp(tools: ExecutableTool[]): void;
328
- addProvider(tool: ProviderTool): void;
329
- addProvider(tools: ProviderTool[]): void;
330
- remove(name: string): boolean;
331
- has(name: string): boolean;
332
- get(name: string): ExecutableTool | undefined;
333
- getProvider(name: string): ProviderTool | undefined;
334
- executable(): ExecutableTool[];
335
- local(): ExecutableTool[];
336
- mcp(): ExecutableTool[];
337
- provider(): ProviderTool[];
338
- get size(): number;
339
- }
340
- //#endregion
341
- //#region src/tools/types.d.ts
342
- interface ToolContext {
343
- registry: ToolRegistry;
344
- signal: AbortSignal;
345
- emit: (chunk: string) => void;
346
- tracer?: TracingContext;
347
- }
348
- interface ExecutableTool<TSchema extends ZodObject<any> = ZodObject<any>> {
349
- type?: "function";
350
- name: string;
351
- description: string;
352
- schema: TSchema;
353
- execute(input: z.infer<TSchema>, ctx: ToolContext): Promise<string | ToolResultPart[]>;
354
- configure?(config: Record<string, any>): void;
355
- summarize?(input: z.infer<TSchema>): string;
356
- }
357
- interface ProviderTool {
358
- type: "provider";
359
- name: string;
360
- config?: Record<string, unknown>;
361
- }
362
- type ToolDefinition = Pick<ExecutableTool, "name" | "description" | "schema">;
363
- //#endregion
364
4
  //#region src/mcp/MCP.d.ts
365
5
  interface MCPStdioConfig {
366
6
  transport: "stdio";
@@ -407,20 +47,89 @@ declare class MCP {
407
47
  private assertConnected;
408
48
  }
409
49
  //#endregion
410
- //#region src/store/types.d.ts
411
- interface FileStore {
412
- read(path: string): Promise<string | null>;
413
- write(path: string, content: string): Promise<void>;
50
+ //#region src/core/parse.d.ts
51
+ type OutputSchema = z$2.ZodTypeAny;
52
+ type ParsedSchema<T extends OutputSchema> = z$2.output<T>;
53
+ declare function parseResponse<T extends OutputSchema>(rawValue: string, schema?: T): ParsedSchema<T> | string;
54
+ //#endregion
55
+ //#region src/core/Instruct.d.ts
56
+ type InstructInputs = Record<string, unknown>;
57
+ type InstructVarsMode = "required" | "optional";
58
+ interface InstructOptions<TSchema extends OutputSchema | undefined = OutputSchema | undefined> {
59
+ prompt: string;
60
+ schema?: TSchema;
61
+ vars?: InstructVarsMode;
62
+ metadata?: MessageMetadata;
63
+ }
64
+ declare class Instruct<TSchema extends OutputSchema | undefined = undefined> {
65
+ prompt: string;
66
+ inputs: InstructInputs;
67
+ files: FileInfo[];
68
+ textReferences: Array<{
69
+ content: string;
70
+ name?: string;
71
+ }>;
72
+ vars: InstructVarsMode;
73
+ metadata?: MessageMetadata;
74
+ schema: TSchema;
75
+ constructor(options: InstructOptions<TSchema>);
76
+ clone(): Instruct<TSchema>;
77
+ withInputs(inputs: InstructInputs): Instruct<TSchema>;
78
+ withInput(name: string, value: unknown): Instruct<TSchema>;
79
+ setInputs(inputs: InstructInputs): void;
80
+ addInput(name: string, value: unknown): void;
81
+ addFile(file: FileInfo | string, options?: {
82
+ name?: string;
83
+ }): void;
84
+ hasFiles(): boolean;
85
+ render(options?: {
86
+ vars?: InstructVarsMode;
87
+ }): string;
88
+ }
89
+ //#endregion
90
+ //#region src/core/agent/history.d.ts
91
+ /**
92
+ * In-memory conversation and presentation history for an agent.
93
+ *
94
+ * `log` is the canonical model-facing message history. `turns` and
95
+ * `sessionAnnotations` are renderable presentation state for consumers.
96
+ *
97
+ * @typeParam TAnnotation - Annotation union supported by the host renderer.
98
+ */
99
+ declare class History<TAnnotation extends Annotation = Annotation> {
100
+ private _turns;
101
+ private _log;
102
+ private _sessionAnnotations;
103
+ constructor(init?: {
104
+ turns?: Turn<TAnnotation>[];
105
+ log?: AxleMessage[];
106
+ sessionAnnotations?: TAnnotation[];
107
+ });
108
+ get turns(): Turn<TAnnotation>[];
109
+ get log(): AxleMessage[];
110
+ get sessionAnnotations(): TAnnotation[];
111
+ addTurn(turn: Turn<TAnnotation>): void;
112
+ replaceTurns(turns: Turn<TAnnotation>[]): void;
113
+ replaceLog(messages: AxleMessage[]): void;
114
+ replaceSessionAnnotations(annotations?: TAnnotation[]): void;
115
+ appendToLog(messages: AxleMessage | AxleMessage[]): void;
116
+ latestTurn(): Turn<TAnnotation> | undefined;
117
+ toString(): string;
414
118
  }
415
119
  //#endregion
416
120
  //#region src/memory/types.d.ts
417
121
  interface MemoryContext {
418
- name?: string;
419
- scope?: Record<string, string>;
122
+ /** Optional agent name provided by the host. */
123
+ agentName?: string;
124
+ /** Stable conversation/session id from the agent. */
125
+ sessionId: string;
126
+ /** Current system prompt, before memory augmentation. */
420
127
  system?: string;
128
+ /** Full message context available for recall or extraction. */
421
129
  messages: AxleMessage[];
130
+ /** Newly produced messages to record after a turn completes. */
422
131
  newMessages?: AxleMessage[];
423
- store: FileStore;
132
+ /** Optional tracing context. */
424
133
  tracer?: TracingContext;
425
134
  }
426
135
  interface RecallResult {
@@ -492,75 +201,153 @@ declare function createHandle<T>(queue: Promise<void>, work: (signal: AbortSigna
492
201
  settled: Promise<void>;
493
202
  };
494
203
  //#endregion
495
- //#region src/core/history.d.ts
496
- declare class History {
497
- private _turns;
498
- private _log;
499
- constructor(init?: {
500
- turns?: Turn[];
501
- log?: AxleMessage[];
502
- });
503
- get turns(): Turn[];
504
- get log(): AxleMessage[];
505
- addTurn(turn: Turn): void;
506
- replaceTurns(turns: Turn[]): void;
507
- appendToLog(messages: AxleMessage | AxleMessage[]): void;
508
- latestTurn(): Turn | undefined;
509
- toString(): string;
510
- }
511
- //#endregion
512
- //#region src/core/parse.d.ts
513
- type OutputSchema = z$2.ZodTypeAny;
514
- type ParsedSchema<T extends OutputSchema> = z$2.output<T>;
515
- declare function parseResponse<T extends OutputSchema>(rawValue: string, schema?: T): ParsedSchema<T> | string;
516
- //#endregion
517
- //#region src/core/Instruct.d.ts
518
- type InstructInputs = Record<string, unknown>;
519
- type InstructVarsMode = "required" | "optional";
520
- interface InstructOptions<TSchema extends OutputSchema | undefined = OutputSchema | undefined> {
521
- prompt: string;
522
- schema?: TSchema;
523
- vars?: InstructVarsMode;
524
- }
525
- declare class Instruct<TSchema extends OutputSchema | undefined = undefined> {
526
- prompt: string;
527
- inputs: InstructInputs;
528
- files: FileInfo[];
529
- textReferences: Array<{
530
- content: string;
531
- name?: string;
532
- }>;
533
- vars: InstructVarsMode;
534
- schema: TSchema;
535
- constructor(options: InstructOptions<TSchema>);
536
- clone(): Instruct<TSchema>;
537
- withInputs(inputs: InstructInputs): Instruct<TSchema>;
538
- withInput(name: string, value: unknown): Instruct<TSchema>;
539
- setInputs(inputs: InstructInputs): void;
540
- addInput(name: string, value: unknown): void;
541
- addFile(file: FileInfo | string, options?: {
542
- name?: string;
543
- }): void;
544
- hasFiles(): boolean;
545
- render(options?: {
546
- vars?: InstructVarsMode;
547
- }): string;
548
- }
549
- //#endregion
550
- //#region src/core/Agent.d.ts
204
+ //#region src/core/agent/types.d.ts
205
+ /**
206
+ * Runtime configuration for an `Agent`.
207
+ *
208
+ * This contains executable objects and process-local services. It is not meant
209
+ * to be serialized directly. Use `AgentDefinition` for a serializable recipe
210
+ * and `createAgentConfig()` to produce an `AgentConfig`.
211
+ */
551
212
  interface AgentConfig extends Omit<AxleModelRequestOptions, "signal"> {
213
+ /** Provider adapter used to execute model requests. */
552
214
  provider: AIProvider;
215
+ /** Model identifier passed to the provider. */
553
216
  model: string;
217
+ /** Stable conversation/session id. Generated when omitted. */
218
+ sessionId?: string;
219
+ /** Optional system/developer instruction. */
554
220
  system?: string;
221
+ /** Optional agent name passed to host services such as memory. */
555
222
  name?: string;
556
- scope?: Record<string, string>;
223
+ /** Executable tools available to the agent. */
557
224
  tools?: ExecutableTool[];
225
+ /** Provider-managed tools such as hosted search or code execution. */
558
226
  providerTools?: ProviderTool[];
227
+ /** MCP clients whose tools should be lazily resolved. */
559
228
  mcps?: MCP[];
229
+ /** Optional memory implementation. */
560
230
  memory?: AgentMemory;
231
+ /** Optional tracing context. */
561
232
  tracer?: TracingContext;
233
+ /** Optional file resolver for request file references. */
562
234
  fileResolver?: FileResolver;
563
235
  }
236
+ /**
237
+ * Serializable provider reference for an agent definition.
238
+ *
239
+ * `type` is host-defined. Common values are provider names such as `"openai"`,
240
+ * `"anthropic"`, `"gemini"`, or `"chatcompletions"`, but core does not
241
+ * interpret the value. `config` is passed through to the host resolver.
242
+ */
243
+ interface ProviderDefinition {
244
+ /** Host-defined provider discriminator. */
245
+ type: string;
246
+ /** Serializable provider configuration or references, such as `apiKeyEnv`. */
247
+ config?: Record<string, unknown>;
248
+ }
249
+ /**
250
+ * Serializable reference to an executable tool.
251
+ */
252
+ interface ToolDefinitionRef {
253
+ /** Host-defined tool name or id. */
254
+ name: string;
255
+ /** Optional serializable tool configuration passed to the resolver. */
256
+ config?: Record<string, unknown>;
257
+ }
258
+ /**
259
+ * Serializable reference to a provider-managed tool.
260
+ */
261
+ interface ProviderToolDefinitionRef {
262
+ /** Provider tool name. */
263
+ name: string;
264
+ /** Optional provider tool configuration. */
265
+ config?: Record<string, unknown>;
266
+ }
267
+ /**
268
+ * Serializable request options for an agent definition.
269
+ */
270
+ interface AgentDefinitionRequestOptions extends Omit<AxleModelRequestOptions, "signal"> {}
271
+ /**
272
+ * Serializable recipe for reconstructing an agent.
273
+ *
274
+ * This is deliberately not executable by itself. Hosts resolve provider and
275
+ * tool references into runtime objects using an `AgentDefinitionResolver`.
276
+ * Harness concerns such as memory implementations, file resolvers, tracing,
277
+ * transport, and stores should be modeled outside this core definition.
278
+ */
279
+ interface AgentDefinition {
280
+ /** Agent definition schema version. */
281
+ version: 1;
282
+ /** Optional agent name passed to host services such as memory. */
283
+ name?: string;
284
+ /** Provider reference resolved by the host. */
285
+ provider: ProviderDefinition;
286
+ /** Optional model identifier passed to the resolved provider. */
287
+ model?: string;
288
+ /** Optional system/developer instruction. */
289
+ system?: string;
290
+ /** Provider-portable request defaults. */
291
+ request?: AgentDefinitionRequestOptions;
292
+ /** Serializable executable tool references. */
293
+ tools?: ToolDefinitionRef[];
294
+ /** Serializable provider-managed tool references. */
295
+ providerTools?: ProviderToolDefinitionRef[];
296
+ /** Serializable MCP client configuration. */
297
+ mcps?: MCPConfig[];
298
+ }
299
+ type MaybePromise<T> = T | Promise<T>;
300
+ /**
301
+ * Executable dependencies resolved from an `AgentDefinition`.
302
+ */
303
+ interface ResolvedAgentDefinition {
304
+ /** Provider adapter used to execute model requests. */
305
+ provider: AIProvider;
306
+ /** Model identifier used when `AgentDefinition.model` is omitted. */
307
+ model?: string;
308
+ /** Executable tools resolved from `AgentDefinition.tools`. */
309
+ tools?: ExecutableTool[];
310
+ /** Provider-managed tools resolved from `AgentDefinition.providerTools`. */
311
+ providerTools?: ProviderTool[];
312
+ /** MCP clients resolved from `AgentDefinition.mcps`. */
313
+ mcps?: MCP[];
314
+ }
315
+ /**
316
+ * Host function used to turn an `AgentDefinition` into executable dependencies.
317
+ */
318
+ type AgentDefinitionResolver = (definition: AgentDefinition) => MaybePromise<ResolvedAgentDefinition>;
319
+ /**
320
+ * Serializable continuation and presentation state for an `Agent`.
321
+ *
322
+ * This is the data needed to continue a model conversation and restore the
323
+ * renderable turn state. It intentionally does not include executable runtime
324
+ * objects such as providers, tools, MCP clients, memory implementations, file
325
+ * resolvers, or tracers. Recreate those from host-owned configuration, then
326
+ * call `agent.restore(session)`.
327
+ *
328
+ * @typeParam TAnnotation - Annotation union supported by the host renderer.
329
+ */
330
+ interface AgentSession<TAnnotation extends Annotation = Annotation> {
331
+ /** Agent session schema version. */
332
+ version: 1;
333
+ /** Stable conversation/session id. */
334
+ sessionId: string;
335
+ /** Canonical model-facing message history used for continuation. */
336
+ messages: AxleMessage[];
337
+ /** Renderable turn state for exact UI restoration. */
338
+ turns?: Turn<TAnnotation>[];
339
+ /** Session-level annotations for generic renderer state. */
340
+ sessionAnnotations?: TAnnotation[];
341
+ }
342
+ /**
343
+ * Serializable saved agent payload: definition plus continuation state.
344
+ */
345
+ interface SavedAgent<TAnnotation extends Annotation = Annotation> {
346
+ /** Serializable recipe used to reconstruct runtime config. */
347
+ definition: AgentDefinition;
348
+ /** Serializable continuation and presentation state. */
349
+ session: AgentSession<TAnnotation>;
350
+ }
564
351
  interface AgentResult<T = string> {
565
352
  ok: true;
566
353
  response: T;
@@ -578,30 +365,58 @@ type AgentHandle<T = string> = Handle<AgentResult<T> | AgentErrorResult>;
578
365
  type TurnEventCallback = (event: TurnEvent) => void;
579
366
  interface SendMessageOptions extends AxleModelRequestOptions {
580
367
  fileResolver?: FileResolver;
368
+ /**
369
+ * Stable host-owned metadata attached to the user message and copied to the
370
+ * renderable user turn. Providers ignore this data.
371
+ */
372
+ metadata?: MessageMetadata;
581
373
  }
374
+ //#endregion
375
+ //#region src/core/agent/Agent.d.ts
582
376
  declare class Agent {
583
377
  readonly provider: AIProvider;
584
378
  readonly model: string;
585
379
  readonly history: History;
586
380
  readonly tracer?: TracingContext;
587
381
  readonly name?: string;
588
- readonly scope?: Record<string, string>;
589
- readonly store: FileStore;
590
382
  readonly fileResolver?: FileResolver;
591
383
  readonly requestOptions: Omit<AxleModelRequestOptions, "signal">;
592
384
  readonly registry: ToolRegistry;
385
+ sessionId: string;
593
386
  system: string | undefined;
594
387
  private mcps;
595
388
  private resolvedMcps;
596
389
  private memory?;
597
390
  private eventCallbacks;
598
391
  private sendQueue;
599
- constructor(config: AgentConfig);
392
+ /**
393
+ * Create an agent from runtime config and, optionally, restore saved session state.
394
+ *
395
+ * When both `config.sessionId` and `session.sessionId` are supplied, the
396
+ * restored session id wins.
397
+ */
398
+ constructor(config: AgentConfig, session?: AgentSession);
600
399
  addMcp(mcp: MCP): void;
601
400
  addMcps(mcps: MCP[]): void;
602
401
  hasTools(): boolean;
603
402
  on(callback: TurnEventCallback): void;
604
403
  context(): ContextUsage;
404
+ /**
405
+ * Capture the serializable session state for later continuation.
406
+ *
407
+ * The returned object contains message history and renderable turn state, but
408
+ * not executable configuration such as providers, tools, MCP clients, memory,
409
+ * or tracers.
410
+ */
411
+ snapshot(): AgentSession;
412
+ /**
413
+ * Replace the agent's continuation and render state from a saved session.
414
+ *
415
+ * Restore does not change runtime configuration. The current provider, model,
416
+ * tools, MCP clients, memory, and other constructor-supplied objects remain in
417
+ * effect.
418
+ */
419
+ restore(session: AgentSession): void;
605
420
  send(message: string | Instruct<undefined>, options?: SendMessageOptions): AgentHandle<string>;
606
421
  send<TSchema extends OutputSchema>(instruct: Instruct<TSchema>, options?: SendMessageOptions): AgentHandle<ParsedSchema<TSchema>>;
607
422
  private resolveMcpTools;
@@ -610,6 +425,17 @@ declare class Agent {
610
425
  private run;
611
426
  }
612
427
  //#endregion
428
+ //#region src/core/agent/createAgentConfig.d.ts
429
+ /**
430
+ * Create executable `Agent` config from a serializable agent definition.
431
+ *
432
+ * Core resolves only what it can safely construct from serializable data. The
433
+ * host remains responsible for executable dependencies such as providers,
434
+ * tools, and MCP clients. Harness runtime services such as memory and file
435
+ * resolvers should be layered onto the returned config by the host.
436
+ */
437
+ declare function createAgentConfig(definition: AgentDefinition, resolver: AgentDefinitionResolver): Promise<AgentConfig>;
438
+ //#endregion
613
439
  //#region src/core/userTurn.d.ts
614
440
  type InstructResponse<TSchema extends OutputSchema | undefined> = TSchema extends OutputSchema ? ParsedSchema<TSchema> : string;
615
441
  //#endregion
@@ -739,11 +565,12 @@ declare class TaskError extends AxleError {
739
565
  }
740
566
  //#endregion
741
567
  //#region src/providers/anthropic/provider.d.ts
742
- declare function anthropic(apiKey: string): AIProvider;
568
+ declare function anthropic(apiKey: string, options?: ProviderClientOptions): AIProvider;
743
569
  //#endregion
744
570
  //#region src/providers/anthropic/index.d.ts
745
571
  declare const Anthropic: {
746
572
  readonly Models: {
573
+ readonly CLAUDE_OPUS_4_8: "claude-opus-4-8";
747
574
  readonly CLAUDE_OPUS_4_7: "claude-opus-4-7";
748
575
  readonly CLAUDE_SONNET_4_6: "claude-sonnet-4-6";
749
576
  readonly CLAUDE_OPUS_4_6: "claude-opus-4-6";
@@ -764,6 +591,10 @@ declare const Anthropic: {
764
591
  };
765
592
  //#endregion
766
593
  //#region src/providers/chatcompletions/provider.d.ts
594
+ interface ChatCompletionsOptions extends ProviderClientOptions {
595
+ apiKey?: string;
596
+ }
597
+ declare function chatCompletions(baseUrl: string, options?: ChatCompletionsOptions): AIProvider;
767
598
  declare function chatCompletions(baseUrl: string, apiKey?: string): AIProvider;
768
599
  //#endregion
769
600
  //#region src/providers/context.d.ts
@@ -778,7 +609,7 @@ interface ContextEstimateInput {
778
609
  declare function estimateContextUsage(input: ContextEstimateInput): ContextUsage;
779
610
  //#endregion
780
611
  //#region src/providers/gemini/provider.d.ts
781
- declare function gemini(apiKey: string): AIProvider;
612
+ declare function gemini(apiKey: string, options?: ProviderClientOptions): AIProvider;
782
613
  //#endregion
783
614
  //#region src/providers/gemini/index.d.ts
784
615
  declare const Gemini: {
@@ -804,7 +635,7 @@ declare const Gemini: {
804
635
  readonly GEMINI_FLASH_LITE_LATEST: "gemini-flash-lite-latest";
805
636
  readonly GEMINI_PRO_LATEST: "gemini-pro-latest";
806
637
  };
807
- readonly DefaultModel: "gemini-3.1-flash-lite-preview";
638
+ readonly DefaultModel: "gemini-3.5-flash";
808
639
  };
809
640
  //#endregion
810
641
  //#region src/providers/generate.d.ts
@@ -865,6 +696,11 @@ type StreamEvent = {
865
696
  index: number;
866
697
  delta: string;
867
698
  accumulated: string;
699
+ } | {
700
+ type: "text:citation";
701
+ index: number;
702
+ citation: Citation;
703
+ citations: Citation[];
868
704
  } | {
869
705
  type: "text:end";
870
706
  index: number;
@@ -872,11 +708,25 @@ type StreamEvent = {
872
708
  } | {
873
709
  type: "thinking:start";
874
710
  index: number;
711
+ redacted?: boolean;
712
+ continuity?: ThinkingContinuity;
713
+ providerMetadata?: Record<string, unknown>;
875
714
  } | {
876
715
  type: "thinking:delta";
877
716
  index: number;
878
717
  delta: string;
879
718
  accumulated: string;
719
+ } | {
720
+ type: "thinking:summary-delta";
721
+ index: number;
722
+ delta: string;
723
+ accumulated: string;
724
+ } | {
725
+ type: "thinking:update";
726
+ index: number;
727
+ redacted?: boolean;
728
+ continuity?: ThinkingContinuity;
729
+ providerMetadata?: Record<string, unknown>;
880
730
  } | {
881
731
  type: "thinking:end";
882
732
  index: number;
@@ -957,7 +807,7 @@ declare function stream<TSchema extends OutputSchema | undefined>(options: Strea
957
807
  declare function stream(options: StreamParams): StreamHandle;
958
808
  //#endregion
959
809
  //#region src/providers/openai/provider.d.ts
960
- declare function openai(apiKey: string): AIProvider;
810
+ declare function openai(apiKey: string, options?: ProviderClientOptions): AIProvider;
961
811
  //#endregion
962
812
  //#region src/providers/openai/index.d.ts
963
813
  declare const OpenAI: {
@@ -1014,94 +864,6 @@ declare const OpenAI: {
1014
864
  readonly DefaultModel: "gpt-5.4-mini";
1015
865
  };
1016
866
  //#endregion
1017
- //#region src/cli/configs/schemas.d.ts
1018
- declare const BraveProviderConfigSchema: z.ZodObject<{
1019
- "api-key": z.ZodString;
1020
- rateLimit: z.ZodOptional<z.ZodNumber>;
1021
- }, z.core.$strip>;
1022
- type BraveProviderConfig = z.infer<typeof BraveProviderConfigSchema>;
1023
- declare const ExecProviderConfigSchema: z.ZodObject<{
1024
- timeout: z.ZodOptional<z.ZodNumber>;
1025
- maxBuffer: z.ZodOptional<z.ZodNumber>;
1026
- cwd: z.ZodOptional<z.ZodString>;
1027
- }, z.core.$strip>;
1028
- type ExecProviderConfig = z.infer<typeof ExecProviderConfigSchema>;
1029
- //#endregion
1030
- //#region src/tools/brave.d.ts
1031
- declare const braveSearchSchema: z$2.ZodObject<{
1032
- searchTerm: z$2.ZodString;
1033
- }, z$2.core.$strip>;
1034
- declare class BraveSearchTool implements ExecutableTool<typeof braveSearchSchema> {
1035
- name: string;
1036
- description: string;
1037
- schema: z$2.ZodObject<{
1038
- searchTerm: z$2.ZodString;
1039
- }, z$2.core.$strip>;
1040
- apiKey: string | undefined;
1041
- throttle: number | undefined;
1042
- lastExecTime: number;
1043
- constructor(config?: BraveProviderConfig);
1044
- configure(config: BraveProviderConfig): void;
1045
- execute(params: z$2.infer<typeof braveSearchSchema>, ctx: ToolContext): Promise<string>;
1046
- }
1047
- declare const braveSearchTool: BraveSearchTool;
1048
- //#endregion
1049
- //#region src/tools/calculator.d.ts
1050
- declare const calculatorSchema: z.ZodObject<{
1051
- operation: z.ZodEnum<{
1052
- add: "add";
1053
- subtract: "subtract";
1054
- multiply: "multiply";
1055
- divide: "divide";
1056
- }>;
1057
- a: z.ZodNumber;
1058
- b: z.ZodNumber;
1059
- }, z.core.$strip>;
1060
- declare const calculatorTool: ExecutableTool<typeof calculatorSchema>;
1061
- //#endregion
1062
- //#region src/tools/exec/index.d.ts
1063
- declare const execSchema: z$2.ZodObject<{
1064
- command: z$2.ZodString;
1065
- }, z$2.core.$strip>;
1066
- declare class ExecTool implements ExecutableTool<typeof execSchema> {
1067
- name: string;
1068
- description: string;
1069
- schema: z$2.ZodObject<{
1070
- command: z$2.ZodString;
1071
- }, z$2.core.$strip>;
1072
- private timeout;
1073
- private maxBuffer;
1074
- private cwd?;
1075
- constructor(config?: ExecProviderConfig);
1076
- configure(config: ExecProviderConfig): void;
1077
- summarize(params: z$2.infer<typeof execSchema>): string;
1078
- execute(params: z$2.infer<typeof execSchema>, ctx: ToolContext): Promise<string>;
1079
- }
1080
- declare const execTool: ExecTool;
1081
- //#endregion
1082
- //#region src/tools/patch-file.d.ts
1083
- declare const patchFileSchema: z.ZodObject<{
1084
- path: z.ZodString;
1085
- old_string: z.ZodString;
1086
- new_string: z.ZodString;
1087
- start_line: z.ZodNumber;
1088
- end_line: z.ZodNumber;
1089
- }, z.core.$strip>;
1090
- declare const patchFileTool: ExecutableTool<typeof patchFileSchema>;
1091
- //#endregion
1092
- //#region src/tools/read-file.d.ts
1093
- declare const readFileSchema: z.ZodObject<{
1094
- path: z.ZodString;
1095
- }, z.core.$strip>;
1096
- declare const readFileTool: ExecutableTool<typeof readFileSchema>;
1097
- //#endregion
1098
- //#region src/tools/write-file.d.ts
1099
- declare const writeFileSchema: z.ZodObject<{
1100
- path: z.ZodString;
1101
- content: z.ZodString;
1102
- }, z.core.$strip>;
1103
- declare const writeFileTool: ExecutableTool<typeof writeFileSchema>;
1104
- //#endregion
1105
867
  //#region src/turns/eventBuilder.d.ts
1106
868
  declare class TurnEventBuilder {
1107
869
  private currentTurnId;
@@ -1194,36 +956,14 @@ declare class SimpleWriter implements TraceWriter {
1194
956
  onEvent(span: SpanData, event: SpanEvent): void;
1195
957
  }
1196
958
  //#endregion
1197
- //#region src/memory/ProceduralMemory.d.ts
1198
- interface ProceduralMemoryConfig {
1199
- provider: AIProvider;
1200
- model: string;
1201
- enableTools?: boolean;
1202
- }
1203
- declare class ProceduralMemory implements AgentMemory {
1204
- private provider;
1205
- private model;
1206
- private enableTools;
1207
- private lastStore?;
1208
- private lastName?;
1209
- private lastScope?;
1210
- constructor(config: ProceduralMemoryConfig);
1211
- recall(context: MemoryContext): Promise<RecallResult>;
1212
- record(context: MemoryContext): Promise<void>;
1213
- tools(): ExecutableTool[];
1214
- private formatMessages;
1215
- private parseInstructions;
1216
- private getStorePath;
1217
- private loadStore;
1218
- private saveStore;
1219
- }
1220
- //#endregion
1221
- //#region src/store/LocalFileStore.d.ts
1222
- declare class LocalFileStore implements FileStore {
1223
- readonly rootPath: string;
1224
- constructor(rootPath: string);
959
+ //#region src/store/types.d.ts
960
+ interface FileStore {
1225
961
  read(path: string): Promise<string | null>;
1226
962
  write(path: string, content: string): Promise<void>;
1227
963
  }
1228
964
  //#endregion
1229
- export { type AIProvider, type AccumulatableEvent, type ActionPart, type ActionResult, Agent, type AgentConfig, type AgentHandle, type AgentMemory, type AgentResult, 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 ContentPart, type ContentPartFile, type ContentPartProviderTool, type ContentPartText, type ContentPartThinking, type ContentPartToolCall, type ContextUsage, type DeferredFileInfo, 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, LocalFileStore, MCP, type MCPConfig, type MCPHttpConfig, type MCPStdioConfig, type MemoryContext, OpenAI, ProceduralMemory, type ProceduralMemoryConfig, type ProviderOptions, type ProviderTool, type ProviderToolAction, type RecallResult, type ResolvedFileSource, type SendMessageOptions, SimpleWriter, type SimpleWriterOptions, type SpanData, type SpanOptions, type SpanType, type StreamEvent, type StreamEventCallback, type StreamHandle, type StreamInstructHandle, type StreamInstructParams, type StreamInstructResult, type StreamParams, type StreamResult, type SubagentAction, TaskError, type TextPart, type ThinkingPart, type ToolAction, type ToolChoice, type ToolContext, type ToolDefinition, ToolRegistry, type ToolResultPart, type TraceWriter, Tracer, type TracingContext, type Turn, TurnAccumulator, type TurnAccumulatorResult, type TurnAccumulatorState, type TurnEvent, TurnEventBuilder, type TurnEventCallback, type TurnPart, type TurnStatus, anthropic, braveSearchTool, calculatorTool, chatCompletions, createHandle, estimateContextUsage, execTool, gemini, generate, generateTurn, loadFileContent, openai, parseResponse, patchFileTool, readFileTool, stream, writeFileTool };
965
+ //#region src/utils/stats.d.ts
966
+ declare function createStats(): Stats;
967
+ declare function addStats(total: Stats, usage?: Stats): void;
968
+ //#endregion
969
+ 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 CitationSource, type ContentPart, 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, MCP, type MCPConfig, type MCPHttpConfig, type MCPStdioConfig, type MaybePromise, type MemoryContext, type MessageMetadata, 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 SpanData, type SpanOptions, 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 ToolAction, type ToolChoice, type ToolContext, type ToolDefinition, type ToolDefinitionRef, ToolRegistry, type ToolResultPart, type TraceWriter, Tracer, type TracingContext, 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 };