@agentloop/core 0.1.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 +287 -0
- package/dist/index.cjs +1168 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +825 -0
- package/dist/index.d.mts +825 -0
- package/dist/index.mjs +1152 -0
- package/dist/index.mjs.map +1 -0
- package/dist/test.cjs +7 -0
- package/dist/test.cjs.map +1 -0
- package/dist/test.d.cts +5 -0
- package/dist/test.d.mts +5 -0
- package/dist/test.mjs +6 -0
- package/dist/test.mjs.map +1 -0
- package/package.json +58 -0
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,825 @@
|
|
|
1
|
+
//#region src/content.d.ts
|
|
2
|
+
/** Plain text content. */
|
|
3
|
+
interface TextPart {
|
|
4
|
+
/** Part discriminator. */
|
|
5
|
+
type: "text";
|
|
6
|
+
/** The text content. */
|
|
7
|
+
text: string;
|
|
8
|
+
/** Provider-specific signature for reasoning verification. */
|
|
9
|
+
signature?: string;
|
|
10
|
+
/** Arbitrary key-value pairs for provider or application use. */
|
|
11
|
+
metadata?: Record<string, unknown>;
|
|
12
|
+
}
|
|
13
|
+
/** Structured JSON content. */
|
|
14
|
+
interface JsonPart {
|
|
15
|
+
/** Part discriminator. */
|
|
16
|
+
type: "json";
|
|
17
|
+
/** The JSON payload. */
|
|
18
|
+
json: Record<string, unknown>;
|
|
19
|
+
/** Arbitrary key-value pairs for provider or application use. */
|
|
20
|
+
metadata?: Record<string, unknown>;
|
|
21
|
+
}
|
|
22
|
+
/** Inline binary data (images, audio, video, documents, etc.). */
|
|
23
|
+
interface BlobPart {
|
|
24
|
+
/** Part discriminator. */
|
|
25
|
+
type: "blob";
|
|
26
|
+
/** Raw binary content or a base64-encoded string. */
|
|
27
|
+
data: string | Uint8Array;
|
|
28
|
+
/** MIME type of the binary data (e.g. `"image/png"`, `"audio/wav"`). */
|
|
29
|
+
mediaType: string;
|
|
30
|
+
/** Arbitrary key-value pairs for provider or application use. */
|
|
31
|
+
metadata?: Record<string, unknown>;
|
|
32
|
+
}
|
|
33
|
+
/** Reference to an external resource. */
|
|
34
|
+
interface URLPart {
|
|
35
|
+
/** Part discriminator. */
|
|
36
|
+
type: "url";
|
|
37
|
+
/** The resource URL. */
|
|
38
|
+
url: string;
|
|
39
|
+
/** Optional MIME type hint for the referenced resource. */
|
|
40
|
+
mediaType?: string;
|
|
41
|
+
/** Arbitrary key-value pairs for provider or application use. */
|
|
42
|
+
metadata?: Record<string, unknown>;
|
|
43
|
+
}
|
|
44
|
+
/** Model reasoning trace. */
|
|
45
|
+
interface ThinkingPart {
|
|
46
|
+
/** Part discriminator. */
|
|
47
|
+
type: "thinking";
|
|
48
|
+
/** The model's internal reasoning text. */
|
|
49
|
+
thinking: string;
|
|
50
|
+
/** Provider-specific signature for thinking verification. */
|
|
51
|
+
signature?: string;
|
|
52
|
+
/** Whether the thinking content was redacted by the provider. */
|
|
53
|
+
redacted: boolean;
|
|
54
|
+
}
|
|
55
|
+
/** A request from the model to invoke a tool. */
|
|
56
|
+
interface ToolCallPart {
|
|
57
|
+
/** Part discriminator. */
|
|
58
|
+
type: "tool_call";
|
|
59
|
+
/** Unique identifier for this tool call, used to match results. */
|
|
60
|
+
id: string;
|
|
61
|
+
/** The name of the tool to invoke. */
|
|
62
|
+
name: string;
|
|
63
|
+
/** The arguments to pass to the tool. */
|
|
64
|
+
arguments: Record<string, unknown>;
|
|
65
|
+
/** Provider-specific signature for tool call verification. */
|
|
66
|
+
signature?: string;
|
|
67
|
+
}
|
|
68
|
+
/** The result of a tool invocation. */
|
|
69
|
+
interface ToolResultPart {
|
|
70
|
+
/** Part discriminator. */
|
|
71
|
+
type: "tool_result";
|
|
72
|
+
/** Identifier matching the originating {@link ToolCallPart.id}. */
|
|
73
|
+
id: string;
|
|
74
|
+
/** The name of the tool that was invoked. */
|
|
75
|
+
name: string;
|
|
76
|
+
/** The content returned by the tool. */
|
|
77
|
+
output: Content[];
|
|
78
|
+
/** Whether the tool invocation failed. */
|
|
79
|
+
isError?: boolean;
|
|
80
|
+
}
|
|
81
|
+
/** Renderable content: text, structured data, or binary/external media. */
|
|
82
|
+
type Content = TextPart | JsonPart | BlobPart | URLPart;
|
|
83
|
+
/** Content that can appear in a system message. */
|
|
84
|
+
type SystemContent = TextPart;
|
|
85
|
+
/** Content that can appear in a user message. */
|
|
86
|
+
type UserContent = TextPart | JsonPart | BlobPart | URLPart;
|
|
87
|
+
/** Content that can appear in an assistant message. */
|
|
88
|
+
type AssistantContent = TextPart | ThinkingPart | ToolCallPart;
|
|
89
|
+
/** Content that can appear in a tool message. */
|
|
90
|
+
type ToolContent = ToolResultPart;
|
|
91
|
+
/** Create a {@link TextPart}. */
|
|
92
|
+
declare function text(value: string): TextPart;
|
|
93
|
+
/** Create a {@link JsonPart}. */
|
|
94
|
+
declare function json(value: Record<string, unknown>): JsonPart;
|
|
95
|
+
/** Create a {@link BlobPart}. */
|
|
96
|
+
declare function blob(data: string | Uint8Array, mediaType: string): BlobPart;
|
|
97
|
+
/** Create a {@link URLPart}. */
|
|
98
|
+
declare function url(value: string, mediaType?: string): URLPart;
|
|
99
|
+
//#endregion
|
|
100
|
+
//#region src/message.d.ts
|
|
101
|
+
/** A system instruction that guides model behavior. */
|
|
102
|
+
interface SystemMessage {
|
|
103
|
+
/** Message discriminator. */
|
|
104
|
+
role: "system";
|
|
105
|
+
/** The system instruction content. */
|
|
106
|
+
content: SystemContent[];
|
|
107
|
+
/** Arbitrary key-value pairs for provider or application use. */
|
|
108
|
+
metadata?: Record<string, unknown>;
|
|
109
|
+
}
|
|
110
|
+
/** A message from the user. */
|
|
111
|
+
interface UserMessage {
|
|
112
|
+
/** Message discriminator. */
|
|
113
|
+
role: "user";
|
|
114
|
+
/** User-provided content (text, media, structured data, etc.). */
|
|
115
|
+
content: UserContent[];
|
|
116
|
+
/** Arbitrary key-value pairs for provider or application use. */
|
|
117
|
+
metadata?: Record<string, unknown>;
|
|
118
|
+
}
|
|
119
|
+
/** A response from the model. */
|
|
120
|
+
interface AssistantMessage {
|
|
121
|
+
/** Message discriminator. */
|
|
122
|
+
role: "assistant";
|
|
123
|
+
/** Model-generated content (text, thinking, tool calls). */
|
|
124
|
+
content: AssistantContent[];
|
|
125
|
+
/** Arbitrary key-value pairs for provider or application use. */
|
|
126
|
+
metadata?: Record<string, unknown>;
|
|
127
|
+
}
|
|
128
|
+
/** The result of one or more tool invocations. */
|
|
129
|
+
interface ToolMessage {
|
|
130
|
+
/** Message discriminator. */
|
|
131
|
+
role: "tool";
|
|
132
|
+
/** Tool results to return to the model. */
|
|
133
|
+
content: ToolContent[];
|
|
134
|
+
/** Arbitrary key-value pairs for provider or application use. */
|
|
135
|
+
metadata?: Record<string, unknown>;
|
|
136
|
+
}
|
|
137
|
+
/** A message in a conversation. */
|
|
138
|
+
type Message = SystemMessage | UserMessage | AssistantMessage | ToolMessage;
|
|
139
|
+
/** Create a {@link SystemMessage}. Accepts a string or content array. */
|
|
140
|
+
declare function system(content: string | SystemContent[]): SystemMessage;
|
|
141
|
+
/** Create a {@link UserMessage}. Accepts a string or content array. */
|
|
142
|
+
declare function user(content: string | UserContent[]): UserMessage;
|
|
143
|
+
/** Create an {@link AssistantMessage}. Accepts a string or content array. */
|
|
144
|
+
declare function assistant(content: string | AssistantContent[]): AssistantMessage;
|
|
145
|
+
/** Flexible input type for agent invocations. A plain string is treated as a user message. */
|
|
146
|
+
type Prompt = string | Message | Message[];
|
|
147
|
+
/** Normalize a {@link Prompt} into a {@link Message} array. */
|
|
148
|
+
declare function normalizePrompt(prompt: Prompt): Message[];
|
|
149
|
+
//#endregion
|
|
150
|
+
//#region src/schema.d.ts
|
|
151
|
+
/**
|
|
152
|
+
* Minimal schema interface for argument validation and type inference.
|
|
153
|
+
*
|
|
154
|
+
* Any validator with a compatible `safeParse` method works — Zod, Valibot,
|
|
155
|
+
* ArkType, or a hand-rolled validator. No adapter needed.
|
|
156
|
+
*
|
|
157
|
+
* **Provider requirement:** When used in tool definitions, providers need to
|
|
158
|
+
* extract a JSON Schema representation to send to the model API. Providers
|
|
159
|
+
* use the [Standard Schema](https://github.com/standard-schema/standard-schema)
|
|
160
|
+
* interface (`~standard.jsonSchema.input()`) for this conversion.
|
|
161
|
+
*
|
|
162
|
+
* Schemas from Standard Schema-compliant libraries (Zod v4+, Valibot v1+,
|
|
163
|
+
* ArkType) work automatically with all providers. Hand-rolled schemas with
|
|
164
|
+
* only `safeParse` will validate arguments correctly but will throw at
|
|
165
|
+
* runtime when used with a provider that requires JSON Schema extraction.
|
|
166
|
+
*/
|
|
167
|
+
interface Schema<T = unknown> {
|
|
168
|
+
safeParse(value: unknown): {
|
|
169
|
+
success: true;
|
|
170
|
+
data: T;
|
|
171
|
+
} | {
|
|
172
|
+
success: false;
|
|
173
|
+
error: unknown;
|
|
174
|
+
};
|
|
175
|
+
}
|
|
176
|
+
/** Extract the output type from a {@link Schema}. */
|
|
177
|
+
type Infer<S extends Schema> = S extends Schema<infer T> ? T : never;
|
|
178
|
+
/**
|
|
179
|
+
* Extract a JSON Schema object from a
|
|
180
|
+
* [Standard Schema v1](https://github.com/standard-schema/standard-schema)
|
|
181
|
+
* compatible validator.
|
|
182
|
+
*
|
|
183
|
+
* Throws if the schema does not expose `~standard.jsonSchema.input()`.
|
|
184
|
+
*/
|
|
185
|
+
declare function schemaToJsonSchema(schema: unknown): Record<string, unknown>;
|
|
186
|
+
//#endregion
|
|
187
|
+
//#region src/context.d.ts
|
|
188
|
+
/** Shared context for the current agent run, passed to policies and hooks. */
|
|
189
|
+
interface RunContext {
|
|
190
|
+
/** Unique identifier for the current run. */
|
|
191
|
+
readonly runId: string;
|
|
192
|
+
/** The current step number (zero-indexed). */
|
|
193
|
+
readonly step: number;
|
|
194
|
+
/** The name of the active agent, if applicable. */
|
|
195
|
+
readonly agent?: string;
|
|
196
|
+
/** Run-scoped key-value store shared across policies and tools. */
|
|
197
|
+
readonly state: Record<string, unknown>;
|
|
198
|
+
/** How many times the current step has been retried. Resets to zero on each new step. */
|
|
199
|
+
readonly retries: number;
|
|
200
|
+
/** Signal for cooperative cancellation. */
|
|
201
|
+
readonly signal: AbortSignal;
|
|
202
|
+
}
|
|
203
|
+
/** Extended context passed to tool executions. */
|
|
204
|
+
interface ToolContext extends RunContext {
|
|
205
|
+
/** Identifier of the tool call being executed, matching {@link ToolCallPart.id}. */
|
|
206
|
+
readonly id: string;
|
|
207
|
+
/** Emit a progress update to observers during tool execution. */
|
|
208
|
+
update(data: Record<string, unknown>): void;
|
|
209
|
+
}
|
|
210
|
+
//#endregion
|
|
211
|
+
//#region src/policy.d.ts
|
|
212
|
+
/** Action returned from {@link Policy.beforeStep}. */
|
|
213
|
+
type BeforeStepAction = {
|
|
214
|
+
action: "stop";
|
|
215
|
+
reason?: string;
|
|
216
|
+
};
|
|
217
|
+
/** Action returned from {@link Policy.afterResponse}. */
|
|
218
|
+
type AfterResponseAction = {
|
|
219
|
+
action: "stop";
|
|
220
|
+
reason?: string;
|
|
221
|
+
} | {
|
|
222
|
+
action: "replace";
|
|
223
|
+
message: AssistantMessage;
|
|
224
|
+
reason?: string;
|
|
225
|
+
} | {
|
|
226
|
+
action: "retry";
|
|
227
|
+
messages?: Message[];
|
|
228
|
+
reason?: string;
|
|
229
|
+
};
|
|
230
|
+
/** Action returned from {@link Policy.beforeToolRun} and {@link Tool.before}. */
|
|
231
|
+
type BeforeToolRunAction = {
|
|
232
|
+
action: "skip";
|
|
233
|
+
output?: Content[];
|
|
234
|
+
reason?: string;
|
|
235
|
+
} | {
|
|
236
|
+
action: "stop";
|
|
237
|
+
output?: Content[];
|
|
238
|
+
reason?: string;
|
|
239
|
+
};
|
|
240
|
+
/** Action returned from {@link Policy.afterToolRun} and {@link Tool.after}. */
|
|
241
|
+
type AfterToolRunAction = {
|
|
242
|
+
action: "rewrite";
|
|
243
|
+
output: Content[];
|
|
244
|
+
reason?: string;
|
|
245
|
+
} | {
|
|
246
|
+
action: "retry";
|
|
247
|
+
arguments?: Record<string, unknown>;
|
|
248
|
+
reason?: string;
|
|
249
|
+
} | {
|
|
250
|
+
action: "stop";
|
|
251
|
+
reason?: string;
|
|
252
|
+
};
|
|
253
|
+
/** Action returned from {@link Policy.afterStep}. */
|
|
254
|
+
type AfterStepAction = {
|
|
255
|
+
action: "stop";
|
|
256
|
+
reason?: string;
|
|
257
|
+
} | {
|
|
258
|
+
action: "retry";
|
|
259
|
+
messages?: Message[];
|
|
260
|
+
reason?: string;
|
|
261
|
+
} | {
|
|
262
|
+
action: "inject";
|
|
263
|
+
messages: Message[];
|
|
264
|
+
};
|
|
265
|
+
/**
|
|
266
|
+
* A mutable plan for the upcoming model call.
|
|
267
|
+
*
|
|
268
|
+
* The loop creates a shallow copy of the transcript for {@link StepPlan.messages},
|
|
269
|
+
* so policies can safely add, remove, or reorder messages without affecting the
|
|
270
|
+
* canonical transcript.
|
|
271
|
+
*/
|
|
272
|
+
interface StepPlan extends Partial<ModelConfig> {
|
|
273
|
+
/** The model to use for this step. Policies can swap this to route different steps to different models. */
|
|
274
|
+
model: Model;
|
|
275
|
+
/** System instructions for the model. Converted to a system message before calling the model. */
|
|
276
|
+
instructions?: string;
|
|
277
|
+
/** A draft copy of the transcript. Safe to mutate without affecting the canonical transcript. */
|
|
278
|
+
messages: Message[];
|
|
279
|
+
/** Tools available for this step. Policies can add or remove tools. */
|
|
280
|
+
tools: Tool[];
|
|
281
|
+
}
|
|
282
|
+
/** Information about the model's response, before tool execution. */
|
|
283
|
+
interface ResponseInfo {
|
|
284
|
+
/** The assistant message. */
|
|
285
|
+
readonly message: AssistantMessage;
|
|
286
|
+
/** The full transcript including the new message. */
|
|
287
|
+
readonly messages: readonly Message[];
|
|
288
|
+
/** Token usage for this response. */
|
|
289
|
+
readonly usage: Usage;
|
|
290
|
+
/** Aggregated token usage across all steps so far. */
|
|
291
|
+
readonly totalUsage: Usage;
|
|
292
|
+
/** Why the model stopped generating. */
|
|
293
|
+
readonly finishReason: FinishReason;
|
|
294
|
+
/** Parsed structured output, if an output schema was provided. */
|
|
295
|
+
readonly object?: unknown;
|
|
296
|
+
}
|
|
297
|
+
/** Information about a tool call before execution. */
|
|
298
|
+
interface ToolCallInfo {
|
|
299
|
+
/** The tool call ID. */
|
|
300
|
+
readonly id: string;
|
|
301
|
+
/** The tool name. */
|
|
302
|
+
readonly name: string;
|
|
303
|
+
/** Parsed arguments. Mutable for sanitization by policies. */
|
|
304
|
+
arguments: Record<string, unknown>;
|
|
305
|
+
}
|
|
306
|
+
/** Information about a tool call after execution. */
|
|
307
|
+
interface ToolResultInfo {
|
|
308
|
+
/** The tool call ID. */
|
|
309
|
+
readonly id: string;
|
|
310
|
+
/** The tool name. */
|
|
311
|
+
readonly name: string;
|
|
312
|
+
/** The arguments that were passed to the tool. */
|
|
313
|
+
readonly arguments: Record<string, unknown>;
|
|
314
|
+
/** The output content produced by the tool. */
|
|
315
|
+
readonly output: readonly Content[];
|
|
316
|
+
/** Whether the tool produced an error. */
|
|
317
|
+
readonly isError: boolean;
|
|
318
|
+
}
|
|
319
|
+
/** Information about a completed step. */
|
|
320
|
+
interface StepInfo {
|
|
321
|
+
/** Messages produced during this step. */
|
|
322
|
+
readonly messages: readonly Message[];
|
|
323
|
+
/** The full transcript. */
|
|
324
|
+
readonly transcript: readonly Message[];
|
|
325
|
+
/** Token usage for this step. */
|
|
326
|
+
readonly usage: Usage;
|
|
327
|
+
/** Aggregated token usage across all steps so far. */
|
|
328
|
+
readonly totalUsage: Usage;
|
|
329
|
+
/** Why the model stopped in this step. */
|
|
330
|
+
readonly finishReason: FinishReason;
|
|
331
|
+
/** Parsed structured output, if an output schema was provided. */
|
|
332
|
+
readonly object?: unknown;
|
|
333
|
+
}
|
|
334
|
+
/**
|
|
335
|
+
* Controls agent loop behavior at key decision points.
|
|
336
|
+
*
|
|
337
|
+
* Implement any combination of hooks — unimplemented hooks default to
|
|
338
|
+
* continue with no side effects.
|
|
339
|
+
*
|
|
340
|
+
* Policies are evaluated in pipeline order: the first policy to return
|
|
341
|
+
* a non-continue result short-circuits, and later policies are skipped.
|
|
342
|
+
* If a hook returns an error, it is treated as a stop directive.
|
|
343
|
+
*/
|
|
344
|
+
interface Policy {
|
|
345
|
+
/** A human-readable name for this policy, used in error attribution and events. */
|
|
346
|
+
name: string;
|
|
347
|
+
/** Called before each model call. Can mutate the step plan or stop the run. */
|
|
348
|
+
beforeStep?(ctx: RunContext, plan: StepPlan): void | BeforeStepAction | Promise<void | BeforeStepAction>;
|
|
349
|
+
/** Called after the model responds, before tool execution. */
|
|
350
|
+
afterResponse?(ctx: RunContext, info: ResponseInfo): void | AfterResponseAction | Promise<void | AfterResponseAction>;
|
|
351
|
+
/** Called before each individual tool execution. */
|
|
352
|
+
beforeToolRun?(ctx: RunContext, call: ToolCallInfo): void | BeforeToolRunAction | Promise<void | BeforeToolRunAction>;
|
|
353
|
+
/** Called after each individual tool execution. */
|
|
354
|
+
afterToolRun?(ctx: RunContext, result: ToolResultInfo): void | AfterToolRunAction | Promise<void | AfterToolRunAction>;
|
|
355
|
+
/** Called after the complete step (model response + tool execution). */
|
|
356
|
+
afterStep?(ctx: RunContext, info: StepInfo): void | AfterStepAction | Promise<void | AfterStepAction>;
|
|
357
|
+
}
|
|
358
|
+
/** Create a {@link Policy}. */
|
|
359
|
+
declare function definePolicy(config: Policy): Policy;
|
|
360
|
+
//#endregion
|
|
361
|
+
//#region src/tool.d.ts
|
|
362
|
+
/** Flexible return type for tool execution. Strings and objects are auto-wrapped. */
|
|
363
|
+
type ToolReturn = string | Record<string, unknown> | Content[];
|
|
364
|
+
/** Declarative tool metadata shared between {@link Tool} and the model API. */
|
|
365
|
+
interface ToolDefinition<T = unknown> {
|
|
366
|
+
/** The tool name exposed to the model. */
|
|
367
|
+
name: string;
|
|
368
|
+
/** Description of what the tool does, sent to the model. */
|
|
369
|
+
description: string;
|
|
370
|
+
/** Schema for argument validation and JSON Schema extraction. */
|
|
371
|
+
schema: Schema<T>;
|
|
372
|
+
/** Maximum execution time in milliseconds before the tool is aborted. */
|
|
373
|
+
timeout?: number;
|
|
374
|
+
}
|
|
375
|
+
/** A tool the model can invoke. */
|
|
376
|
+
interface Tool<T = unknown> extends ToolDefinition<T> {
|
|
377
|
+
/** Called before execution. Can skip, stop, or modify arguments. */
|
|
378
|
+
before?(args: T, ctx: RunContext): void | BeforeToolRunAction | Promise<void | BeforeToolRunAction>;
|
|
379
|
+
/** Execute the tool with validated arguments. */
|
|
380
|
+
execute(args: T, ctx: ToolContext): ToolReturn | Promise<ToolReturn>;
|
|
381
|
+
/** Called after execution. Can rewrite output, retry, or stop the run. */
|
|
382
|
+
after?(args: T, output: Content[], ctx: RunContext): void | AfterToolRunAction | Promise<void | AfterToolRunAction>;
|
|
383
|
+
}
|
|
384
|
+
/** Create a type-safe {@link Tool}. Schema infers the argument type. */
|
|
385
|
+
declare function defineTool<T>(config: Tool<T>): Tool<T>;
|
|
386
|
+
/** Normalize a {@link ToolReturn} into a {@link Content} array. */
|
|
387
|
+
declare function normalizeToolReturn(value: ToolReturn): Content[];
|
|
388
|
+
//#endregion
|
|
389
|
+
//#region src/model.d.ts
|
|
390
|
+
/** Normalized reason the model stopped generating. */
|
|
391
|
+
type FinishReason = "stop" | "tool_call" | "length" | "stop_sequence" | "cancelled" | "refused" | "error" | "unknown";
|
|
392
|
+
/** Token usage statistics for a model call. */
|
|
393
|
+
interface Usage {
|
|
394
|
+
/** Number of tokens in the input/prompt. */
|
|
395
|
+
inputTokens: number;
|
|
396
|
+
/** Number of tokens in the generated output. */
|
|
397
|
+
outputTokens: number;
|
|
398
|
+
/** Total tokens (input + output). */
|
|
399
|
+
totalTokens: number;
|
|
400
|
+
/** Tokens read from cache (e.g. Anthropic prompt caching, Google cached content). */
|
|
401
|
+
cacheReadTokens?: number;
|
|
402
|
+
/** Tokens written to cache (e.g. Anthropic cache creation). */
|
|
403
|
+
cacheWriteTokens?: number;
|
|
404
|
+
}
|
|
405
|
+
/** Individual chunks yielded by a model during streaming. */
|
|
406
|
+
type StreamPart = {
|
|
407
|
+
type: "text_start";
|
|
408
|
+
} | {
|
|
409
|
+
type: "text_delta";
|
|
410
|
+
text: string;
|
|
411
|
+
} | {
|
|
412
|
+
type: "text_end";
|
|
413
|
+
} | {
|
|
414
|
+
type: "thinking_start";
|
|
415
|
+
redacted?: boolean;
|
|
416
|
+
} | {
|
|
417
|
+
type: "thinking_delta";
|
|
418
|
+
thinking: string;
|
|
419
|
+
} | {
|
|
420
|
+
type: "thinking_end";
|
|
421
|
+
signature?: string;
|
|
422
|
+
} | {
|
|
423
|
+
type: "tool_call_start";
|
|
424
|
+
id: string;
|
|
425
|
+
name: string;
|
|
426
|
+
signature?: string;
|
|
427
|
+
} | {
|
|
428
|
+
type: "tool_call_delta";
|
|
429
|
+
id: string;
|
|
430
|
+
args: string;
|
|
431
|
+
} | {
|
|
432
|
+
type: "tool_call_end";
|
|
433
|
+
id: string;
|
|
434
|
+
} | {
|
|
435
|
+
type: "finish";
|
|
436
|
+
finishReason: FinishReason;
|
|
437
|
+
usage: Usage;
|
|
438
|
+
} | {
|
|
439
|
+
type: "error";
|
|
440
|
+
error: Error;
|
|
441
|
+
};
|
|
442
|
+
/** Configuration knobs for a model call. */
|
|
443
|
+
interface ModelConfig {
|
|
444
|
+
/** Maximum tokens to generate. */
|
|
445
|
+
maxTokens?: number;
|
|
446
|
+
/** Sampling temperature. */
|
|
447
|
+
temperature?: number;
|
|
448
|
+
/** Top-p (nucleus) sampling. */
|
|
449
|
+
topP?: number;
|
|
450
|
+
/** Top-k sampling. */
|
|
451
|
+
topK?: number;
|
|
452
|
+
/** Stop sequences. */
|
|
453
|
+
stopSequences?: string[];
|
|
454
|
+
}
|
|
455
|
+
/** A configured model instance returned by a {@link Provider}. */
|
|
456
|
+
interface Model {
|
|
457
|
+
/** The model identifier (e.g. "claude-sonnet-4-20250514"). */
|
|
458
|
+
name: string;
|
|
459
|
+
/** Stream a response as incremental parts. */
|
|
460
|
+
stream(options: {
|
|
461
|
+
/** The conversation messages. */messages: Message[]; /** Tool definitions available to the model. */
|
|
462
|
+
tools?: ToolDefinition[]; /** Per-call config overrides. */
|
|
463
|
+
config?: ModelConfig; /** Schema for structured output. */
|
|
464
|
+
output?: Schema; /** Signal for cooperative cancellation. */
|
|
465
|
+
signal?: AbortSignal;
|
|
466
|
+
}): AsyncIterable<StreamPart>;
|
|
467
|
+
}
|
|
468
|
+
/** Configuration for a provider connection. */
|
|
469
|
+
interface ProviderConfig {
|
|
470
|
+
/** API key for authentication. */
|
|
471
|
+
apiKey?: string;
|
|
472
|
+
/** Base URL for the API. */
|
|
473
|
+
baseUrl?: string;
|
|
474
|
+
/** Request timeout in milliseconds. */
|
|
475
|
+
timeout?: number;
|
|
476
|
+
/** Maximum number of retries on transient failures. */
|
|
477
|
+
maxRetries?: number;
|
|
478
|
+
/** Additional headers to include in requests. */
|
|
479
|
+
headers?: Record<string, string>;
|
|
480
|
+
}
|
|
481
|
+
/** Factory for creating {@link Model} instances. */
|
|
482
|
+
interface Provider {
|
|
483
|
+
/** Create a model instance with optional default config. */
|
|
484
|
+
model(name: string, config?: ModelConfig): Model;
|
|
485
|
+
}
|
|
486
|
+
/** Create an empty {@link Usage}. */
|
|
487
|
+
declare function emptyUsage(): Usage;
|
|
488
|
+
/** Add two {@link Usage} objects together. */
|
|
489
|
+
declare function addUsage(a: Usage, b: Usage): Usage;
|
|
490
|
+
//#endregion
|
|
491
|
+
//#region src/observer.d.ts
|
|
492
|
+
/** Common fields present on every observer event. */
|
|
493
|
+
interface BaseEvent {
|
|
494
|
+
/** Event discriminator. */
|
|
495
|
+
readonly type: string;
|
|
496
|
+
/** Unique identifier for the current run. */
|
|
497
|
+
readonly runId: string;
|
|
498
|
+
/** The current step number (zero-indexed). */
|
|
499
|
+
readonly step: number;
|
|
500
|
+
/** The name of the active agent, if applicable. */
|
|
501
|
+
readonly agent?: string;
|
|
502
|
+
/** Unix timestamp (ms) when the event was created. */
|
|
503
|
+
readonly timestamp: number;
|
|
504
|
+
}
|
|
505
|
+
/** Fired when a run begins. */
|
|
506
|
+
interface RunStartEvent extends BaseEvent {
|
|
507
|
+
readonly type: "runStart";
|
|
508
|
+
/** The model being used for the run. */
|
|
509
|
+
readonly model: string;
|
|
510
|
+
/** System instructions, if provided. */
|
|
511
|
+
readonly instructions?: string;
|
|
512
|
+
/** The input prompt. */
|
|
513
|
+
readonly prompt?: Prompt;
|
|
514
|
+
/** Names of the tools available to the model. */
|
|
515
|
+
readonly tools: string[];
|
|
516
|
+
}
|
|
517
|
+
/** Fired when a run completes (successfully or with an error). */
|
|
518
|
+
interface RunFinishEvent extends BaseEvent {
|
|
519
|
+
readonly type: "runFinish";
|
|
520
|
+
/** Convenience extraction of the final text output. */
|
|
521
|
+
readonly text: string;
|
|
522
|
+
/** The final assistant message. */
|
|
523
|
+
readonly response: AssistantMessage;
|
|
524
|
+
/** The full conversation transcript. */
|
|
525
|
+
readonly transcript: readonly Message[];
|
|
526
|
+
/** Parsed structured output, if an output schema was provided. */
|
|
527
|
+
readonly object?: unknown;
|
|
528
|
+
/** Total number of steps executed. */
|
|
529
|
+
readonly steps: number;
|
|
530
|
+
/** Aggregated token usage for the entire run. */
|
|
531
|
+
readonly usage: Usage;
|
|
532
|
+
/** Why the run ended. */
|
|
533
|
+
readonly finishReason: FinishReason;
|
|
534
|
+
/** The name of the policy that stopped the run, if applicable. */
|
|
535
|
+
readonly stoppedBy?: string;
|
|
536
|
+
/** The error, if the run ended due to a failure. */
|
|
537
|
+
readonly error?: Error;
|
|
538
|
+
/** Wall-clock duration of the run in milliseconds. */
|
|
539
|
+
readonly duration: number;
|
|
540
|
+
}
|
|
541
|
+
/** Fired when a step begins (one model call + tool execution cycle). */
|
|
542
|
+
interface StepStartEvent extends BaseEvent {
|
|
543
|
+
readonly type: "stepStart";
|
|
544
|
+
/** The model being used for this step (may differ from run start if swapped by a policy). */
|
|
545
|
+
readonly model: string;
|
|
546
|
+
}
|
|
547
|
+
/** Fired when a step is retried. */
|
|
548
|
+
interface StepRetryEvent extends BaseEvent {
|
|
549
|
+
readonly type: "stepRetry";
|
|
550
|
+
/** Why the step is being retried. */
|
|
551
|
+
readonly reason?: string;
|
|
552
|
+
/** How many times this step has been retried so far. */
|
|
553
|
+
readonly retries: number;
|
|
554
|
+
}
|
|
555
|
+
/** Fired when a step completes (model response + all tool executions). */
|
|
556
|
+
interface StepFinishEvent extends BaseEvent {
|
|
557
|
+
readonly type: "stepFinish";
|
|
558
|
+
/** Messages produced during this step. */
|
|
559
|
+
readonly messages: readonly Message[];
|
|
560
|
+
/** Parsed structured output, if an output schema was provided. */
|
|
561
|
+
readonly object?: unknown;
|
|
562
|
+
/** Token usage for this step. */
|
|
563
|
+
readonly usage: Usage;
|
|
564
|
+
/** Aggregated token usage across all steps so far. */
|
|
565
|
+
readonly totalUsage: Usage;
|
|
566
|
+
/** Why the model stopped generating in this step. */
|
|
567
|
+
readonly finishReason: FinishReason;
|
|
568
|
+
/** Wall-clock duration of the step in milliseconds. */
|
|
569
|
+
readonly duration: number;
|
|
570
|
+
}
|
|
571
|
+
/** Fired after the model responds, before tool execution. */
|
|
572
|
+
interface ResponseFinishEvent extends BaseEvent {
|
|
573
|
+
readonly type: "responseFinish";
|
|
574
|
+
/** The assistant message. */
|
|
575
|
+
readonly message: AssistantMessage;
|
|
576
|
+
/** Token usage for this response. */
|
|
577
|
+
readonly usage: Usage;
|
|
578
|
+
/** Aggregated token usage across all steps so far. */
|
|
579
|
+
readonly totalUsage: Usage;
|
|
580
|
+
/** Why the model stopped generating. */
|
|
581
|
+
readonly finishReason: FinishReason;
|
|
582
|
+
/** The error, if the response failed. */
|
|
583
|
+
readonly error?: Error;
|
|
584
|
+
/** Wall-clock duration of the model call in milliseconds. */
|
|
585
|
+
readonly duration: number;
|
|
586
|
+
}
|
|
587
|
+
/** Fired when the model begins producing text output. */
|
|
588
|
+
interface TextStartEvent extends BaseEvent {
|
|
589
|
+
readonly type: "textStart";
|
|
590
|
+
}
|
|
591
|
+
/** Fired for each chunk of text output. */
|
|
592
|
+
interface TextDeltaEvent extends BaseEvent {
|
|
593
|
+
readonly type: "textDelta";
|
|
594
|
+
/** The text chunk. */
|
|
595
|
+
readonly text: string;
|
|
596
|
+
}
|
|
597
|
+
/** Fired when the model finishes producing text output. */
|
|
598
|
+
interface TextStopEvent extends BaseEvent {
|
|
599
|
+
readonly type: "textStop";
|
|
600
|
+
}
|
|
601
|
+
/** Fired when the model begins a reasoning trace. */
|
|
602
|
+
interface ThinkingStartEvent extends BaseEvent {
|
|
603
|
+
readonly type: "thinkingStart";
|
|
604
|
+
/** Whether the thinking content is redacted by the provider. */
|
|
605
|
+
readonly redacted?: boolean;
|
|
606
|
+
}
|
|
607
|
+
/** Fired for each chunk of reasoning output. */
|
|
608
|
+
interface ThinkingDeltaEvent extends BaseEvent {
|
|
609
|
+
readonly type: "thinkingDelta";
|
|
610
|
+
/** The reasoning text chunk. */
|
|
611
|
+
readonly text: string;
|
|
612
|
+
}
|
|
613
|
+
/** Fired when the model finishes a reasoning trace. */
|
|
614
|
+
interface ThinkingStopEvent extends BaseEvent {
|
|
615
|
+
readonly type: "thinkingStop";
|
|
616
|
+
}
|
|
617
|
+
/** Fired when the model begins producing a tool call. */
|
|
618
|
+
interface ToolCallStartEvent extends BaseEvent {
|
|
619
|
+
readonly type: "toolCallStart";
|
|
620
|
+
/** The tool call ID, matching {@link ToolCallPart.id}. */
|
|
621
|
+
readonly id: string;
|
|
622
|
+
/** The tool name. */
|
|
623
|
+
readonly name: string;
|
|
624
|
+
}
|
|
625
|
+
/** Fired for each chunk of tool call arguments. */
|
|
626
|
+
interface ToolCallDeltaEvent extends BaseEvent {
|
|
627
|
+
readonly type: "toolCallDelta";
|
|
628
|
+
/** The tool call ID, matching {@link ToolCallPart.id}. */
|
|
629
|
+
readonly id: string;
|
|
630
|
+
/** The tool name. */
|
|
631
|
+
readonly name: string;
|
|
632
|
+
/** Partial JSON arguments received so far. */
|
|
633
|
+
readonly partialArguments: string;
|
|
634
|
+
}
|
|
635
|
+
/** Fired when the model finishes producing a tool call. */
|
|
636
|
+
interface ToolCallStopEvent extends BaseEvent {
|
|
637
|
+
readonly type: "toolCallStop";
|
|
638
|
+
/** The tool call ID, matching {@link ToolCallPart.id}. */
|
|
639
|
+
readonly id: string;
|
|
640
|
+
/** The tool name. */
|
|
641
|
+
readonly name: string;
|
|
642
|
+
/** The fully parsed tool call arguments, matching {@link ToolCallPart.arguments}. */
|
|
643
|
+
readonly arguments: Record<string, unknown>;
|
|
644
|
+
}
|
|
645
|
+
/** Fired when a tool begins executing. */
|
|
646
|
+
interface ToolRunStartEvent extends BaseEvent {
|
|
647
|
+
readonly type: "toolRunStart";
|
|
648
|
+
/** The tool call ID, matching {@link ToolCallPart.id}. */
|
|
649
|
+
readonly id: string;
|
|
650
|
+
/** The tool name. */
|
|
651
|
+
readonly name: string;
|
|
652
|
+
/** The arguments passed to the tool. */
|
|
653
|
+
readonly arguments: Record<string, unknown>;
|
|
654
|
+
}
|
|
655
|
+
/** Fired when a tool emits a progress update via {@link ToolContext.update}. */
|
|
656
|
+
interface ToolRunUpdateEvent extends BaseEvent {
|
|
657
|
+
readonly type: "toolRunUpdate";
|
|
658
|
+
/** The tool call ID, matching {@link ToolCallPart.id}. */
|
|
659
|
+
readonly id: string;
|
|
660
|
+
/** The tool name. */
|
|
661
|
+
readonly name: string;
|
|
662
|
+
/** The progress data emitted by the tool. */
|
|
663
|
+
readonly data: Record<string, unknown>;
|
|
664
|
+
}
|
|
665
|
+
/** Fired when a tool finishes executing. */
|
|
666
|
+
interface ToolRunEndEvent extends BaseEvent {
|
|
667
|
+
readonly type: "toolRunEnd";
|
|
668
|
+
/** The tool call ID, matching {@link ToolCallPart.id}. */
|
|
669
|
+
readonly id: string;
|
|
670
|
+
/** The tool name. */
|
|
671
|
+
readonly name: string;
|
|
672
|
+
/** The content returned by the tool. */
|
|
673
|
+
readonly output: readonly Content[];
|
|
674
|
+
/** The error, if the tool failed. */
|
|
675
|
+
readonly error?: Error;
|
|
676
|
+
/** Wall-clock duration of the tool execution in milliseconds. */
|
|
677
|
+
readonly duration: number;
|
|
678
|
+
}
|
|
679
|
+
/** Fired when a tool call is skipped by a policy or the tool's own before hook. */
|
|
680
|
+
interface ToolSkipEvent extends BaseEvent {
|
|
681
|
+
readonly type: "toolSkip";
|
|
682
|
+
/** The tool call ID, matching {@link ToolCallPart.id}. */
|
|
683
|
+
readonly id: string;
|
|
684
|
+
/** The tool name. */
|
|
685
|
+
readonly name: string;
|
|
686
|
+
/** The arguments the model passed to the tool. */
|
|
687
|
+
readonly arguments: Record<string, unknown>;
|
|
688
|
+
/** Whether the tool was skipped or the entire run was stopped. */
|
|
689
|
+
readonly action: "skip" | "stop";
|
|
690
|
+
/** What triggered the skip. */
|
|
691
|
+
readonly source: "policy" | "tool";
|
|
692
|
+
/** Human-readable reason for the skip. */
|
|
693
|
+
readonly reason?: string;
|
|
694
|
+
}
|
|
695
|
+
/** Fired when the run is aborted via the abort signal. */
|
|
696
|
+
interface AbortEvent extends BaseEvent {
|
|
697
|
+
readonly type: "abort";
|
|
698
|
+
/** Human-readable reason for the abort. */
|
|
699
|
+
readonly reason?: string;
|
|
700
|
+
}
|
|
701
|
+
/** Fired when an error occurs during the run. */
|
|
702
|
+
interface ErrorEvent extends BaseEvent {
|
|
703
|
+
readonly type: "error";
|
|
704
|
+
/** The error that occurred. */
|
|
705
|
+
readonly error: Error;
|
|
706
|
+
/** Where the error originated. */
|
|
707
|
+
readonly source: "provider" | "tool" | "policy" | "validation" | "observer";
|
|
708
|
+
/** The tool call that caused the error, if applicable. */
|
|
709
|
+
readonly toolCall?: ToolCallPart;
|
|
710
|
+
/** The name of the policy that caused the error, if applicable. */
|
|
711
|
+
readonly policy?: string;
|
|
712
|
+
/** The name of the observer that caused the error, if applicable. */
|
|
713
|
+
readonly observer?: string;
|
|
714
|
+
}
|
|
715
|
+
/** Discriminated union of all observer events. */
|
|
716
|
+
type ObserverEvent = RunStartEvent | RunFinishEvent | StepStartEvent | StepRetryEvent | StepFinishEvent | ResponseFinishEvent | TextStartEvent | TextDeltaEvent | TextStopEvent | ThinkingStartEvent | ThinkingDeltaEvent | ThinkingStopEvent | ToolCallStartEvent | ToolCallDeltaEvent | ToolCallStopEvent | ToolRunStartEvent | ToolRunUpdateEvent | ToolRunEndEvent | ToolSkipEvent | AbortEvent | ErrorEvent;
|
|
717
|
+
/** Auto-generated typed handler for each event (e.g. `onTextDelta`, `onRunFinish`). */
|
|
718
|
+
type EventHandlers = { [E in ObserverEvent as `on${Capitalize<E["type"]>}`]?: (event: E) => void | Promise<void> };
|
|
719
|
+
/**
|
|
720
|
+
* Watches the agent loop and reacts to events.
|
|
721
|
+
*
|
|
722
|
+
* Implement individual `on*` handlers for specific events,
|
|
723
|
+
* or a catch-all {@link Observer.handler} for everything.
|
|
724
|
+
*/
|
|
725
|
+
interface Observer extends EventHandlers {
|
|
726
|
+
/** A human-readable name for this observer. */
|
|
727
|
+
name: string;
|
|
728
|
+
/** Catch-all handler invoked for every event. */
|
|
729
|
+
handler?(event: ObserverEvent): void | Promise<void>;
|
|
730
|
+
}
|
|
731
|
+
/** Create an {@link Observer}. */
|
|
732
|
+
declare function defineObserver(config: Observer): Observer;
|
|
733
|
+
//#endregion
|
|
734
|
+
//#region src/agent.d.ts
|
|
735
|
+
/** Configuration for creating an agent. */
|
|
736
|
+
interface AgentConfig {
|
|
737
|
+
/** Human-readable name for this agent, used in events and error attribution. */
|
|
738
|
+
name?: string;
|
|
739
|
+
/** The model instance to use. */
|
|
740
|
+
model: Model;
|
|
741
|
+
/** System instructions that guide model behavior. */
|
|
742
|
+
instructions?: string;
|
|
743
|
+
/** Tools available to the agent. */
|
|
744
|
+
tools?: Tool[];
|
|
745
|
+
/** Observers that watch the agent loop. */
|
|
746
|
+
observers?: Observer[];
|
|
747
|
+
/** Policies that govern the agent loop. */
|
|
748
|
+
policies?: Policy[];
|
|
749
|
+
}
|
|
750
|
+
/** Per-run overrides passed to {@link Agent.run} or {@link Agent.stream}. */
|
|
751
|
+
interface RunOptions extends Partial<ModelConfig> {
|
|
752
|
+
/** Existing transcript to continue from. */
|
|
753
|
+
transcript?: Message[];
|
|
754
|
+
/** Additional observers merged with the agent's observers. */
|
|
755
|
+
observers?: Observer[];
|
|
756
|
+
/** Additional policies merged with the agent's policies. */
|
|
757
|
+
policies?: Policy[];
|
|
758
|
+
/** Schema for structured output. */
|
|
759
|
+
output?: Schema;
|
|
760
|
+
/** Initial state for the run context. */
|
|
761
|
+
state?: Record<string, unknown>;
|
|
762
|
+
/** Signal for cooperative cancellation. */
|
|
763
|
+
signal?: AbortSignal;
|
|
764
|
+
}
|
|
765
|
+
/** The result of an agent run. */
|
|
766
|
+
interface AgentResult<TOutput = unknown> {
|
|
767
|
+
/** Convenience extraction of the final text output. */
|
|
768
|
+
readonly text: string;
|
|
769
|
+
/** The final assistant message. */
|
|
770
|
+
readonly response: AssistantMessage;
|
|
771
|
+
/** The full conversation transcript. */
|
|
772
|
+
readonly transcript: readonly Message[];
|
|
773
|
+
/** Total number of steps executed. */
|
|
774
|
+
readonly steps: number;
|
|
775
|
+
/** Aggregated token usage for the entire run. */
|
|
776
|
+
readonly usage: Usage;
|
|
777
|
+
/** Why the run ended. */
|
|
778
|
+
readonly finishReason: FinishReason;
|
|
779
|
+
/** The name of the policy that stopped the run, if applicable. */
|
|
780
|
+
readonly stoppedBy?: string;
|
|
781
|
+
/** The error, if the run ended due to a failure. */
|
|
782
|
+
readonly error?: Error;
|
|
783
|
+
/** Wall-clock duration of the run in milliseconds. */
|
|
784
|
+
readonly duration: number;
|
|
785
|
+
/** Parsed structured output, if an output schema was provided. */
|
|
786
|
+
readonly object?: TOutput | null;
|
|
787
|
+
}
|
|
788
|
+
/** An async iterable of observer events with access to the final result. */
|
|
789
|
+
interface AgentStream<TOutput = unknown> extends AsyncIterable<ObserverEvent> {
|
|
790
|
+
/** Resolves to the final result when the run completes. */
|
|
791
|
+
readonly result: Promise<AgentResult<TOutput>>;
|
|
792
|
+
}
|
|
793
|
+
/** Configuration for converting an agent into a {@link Tool} via {@link Agent.asTool}. */
|
|
794
|
+
interface AsToolConfig<TArgs> {
|
|
795
|
+
/** The tool name exposed to the parent agent. */
|
|
796
|
+
name: string;
|
|
797
|
+
/** Description of what this sub-agent does. */
|
|
798
|
+
description: string;
|
|
799
|
+
/** Schema for the tool's arguments. */
|
|
800
|
+
schema: Schema<TArgs>;
|
|
801
|
+
/** Build the prompt from the parsed arguments. */
|
|
802
|
+
prompt(args: TArgs): Prompt;
|
|
803
|
+
/** Transform the agent result into tool output. Defaults to returning the text. */
|
|
804
|
+
output?(result: AgentResult): ToolReturn;
|
|
805
|
+
}
|
|
806
|
+
/** An agent that runs a model loop with tools, policies, and observers. */
|
|
807
|
+
interface Agent {
|
|
808
|
+
/** Run the agent to completion and return the result. */
|
|
809
|
+
run<T>(prompt: Prompt | undefined, options: RunOptions & {
|
|
810
|
+
output: Schema<T>;
|
|
811
|
+
}): Promise<AgentResult<T>>;
|
|
812
|
+
run(prompt?: Prompt, options?: RunOptions): Promise<AgentResult>;
|
|
813
|
+
/** Run the agent and stream observer events as they occur. */
|
|
814
|
+
stream<T>(prompt: Prompt | undefined, options: RunOptions & {
|
|
815
|
+
output: Schema<T>;
|
|
816
|
+
}): AgentStream<T>;
|
|
817
|
+
stream(prompt?: Prompt, options?: RunOptions): AgentStream;
|
|
818
|
+
/** Convert this agent into a tool for use by another agent. */
|
|
819
|
+
asTool<TArgs>(config: AsToolConfig<TArgs>): Tool;
|
|
820
|
+
}
|
|
821
|
+
/** Create an {@link Agent} from the given configuration. */
|
|
822
|
+
declare function defineAgent(config: AgentConfig): Agent;
|
|
823
|
+
//#endregion
|
|
824
|
+
export { type AbortEvent, type AfterResponseAction, type AfterStepAction, type AfterToolRunAction, type Agent, type AgentConfig, type AgentResult, type AgentStream, type AsToolConfig, type AssistantContent, type AssistantMessage, type BaseEvent, type BeforeStepAction, type BeforeToolRunAction, type BlobPart, type Content, type ErrorEvent, type FinishReason, type Infer, type JsonPart, type Message, type Model, type ModelConfig, type Observer, type ObserverEvent, type Policy, type Prompt, type Provider, type ProviderConfig, type ResponseFinishEvent, type ResponseInfo, type RunContext, type RunFinishEvent, type RunOptions, type RunStartEvent, type Schema, type StepFinishEvent, type StepInfo, type StepPlan, type StepRetryEvent, type StepStartEvent, type StreamPart, type SystemContent, type SystemMessage, type TextDeltaEvent, type TextPart, type TextStartEvent, type TextStopEvent, type ThinkingDeltaEvent, type ThinkingPart, type ThinkingStartEvent, type ThinkingStopEvent, type Tool, type ToolCallDeltaEvent, type ToolCallInfo, type ToolCallPart, type ToolCallStartEvent, type ToolCallStopEvent, type ToolContent, type ToolContext, type ToolDefinition, type ToolMessage, type ToolResultInfo, type ToolResultPart, type ToolReturn, type ToolRunEndEvent, type ToolRunStartEvent, type ToolRunUpdateEvent, type ToolSkipEvent, type URLPart, type Usage, type UserContent, type UserMessage, addUsage, assistant, blob, defineAgent, defineObserver, definePolicy, defineTool, emptyUsage, json, normalizePrompt, normalizeToolReturn, schemaToJsonSchema, system, text, url, user };
|
|
825
|
+
//# sourceMappingURL=index.d.mts.map
|