@nuvin/agent-core 0.0.0-rc.2 → 0.0.0-rc.3

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.
@@ -1,17 +1,712 @@
1
- import { D as AutoReasoningEffort, u as ReasoningConfig, F as AnthropicThinkingConfig, G as OpenAiReasoningConfig } from '../types-QPBW5jHO.js';
2
- export { aJ as AgentAssistantChunkEvent, aI as AgentAssistantMessageEvent, bd as AgentDefinition, bc as AgentDefinitionFactoryContext, aU as AgentEvent, ay as AgentEventContext, aY as AgentEventHandler, aR as AgentFinalMessageEvent, a as AgentInput, aT as AgentLifecycleEvent, aG as AgentModelRequestEvent, aH as AgentModelResponseEvent, A as AgentOptions, aN as AgentReasoningChunkEvent, aM as AgentReasoningMessageEvent, b as AgentSendOptions, aO as AgentToolCallEvent, aP as AgentToolResultEvent, aQ as AgentToolResultMessageEvent, aL as AgentToolUseChunkEvent, aK as AgentToolUseMessageEvent, aS as AgentTurnCompleteEvent, aF as AgentUserMessageEvent, ab as AnthropicAdaptiveThinkingConfig, a5 as AnthropicAssistantContentBlock, ac as AnthropicDisabledThinkingConfig, aa as AnthropicEnabledThinkingConfig, a0 as AnthropicRedactedThinkingBlock, a4 as AnthropicRedactedThinkingWireBlock, ao as AnthropicSignatureDeltaChunk, $ as AnthropicThinkingBlock, an as AnthropicThinkingDeltaChunk, a8 as AnthropicThinkingDisplay, a9 as AnthropicThinkingEffort, a3 as AnthropicThinkingWireBlock, bb as AnyExtensionRegistration, b2 as AnyToolDefinition, ag as AssistantContentBlock, a7 as AutoReasoningConfig, B as BaseChatModelOptions, ax as ChatModel, j as ChatRequest, l as ChatResponse, v as ChatResponseChunk, h as CompileRequestInput, f as ContentBlock, al as ContentDeltaChunk, C as ContentInput, bl as CreateManagedRunInput, t as EngineChatModel, b5 as ExtensionContext, ba as ExtensionRegistration, E as ExtensionRegistry, ai as IdentifiedMessage, Y as ImageBlock, X as ImageMediaType, a_ as InferJsonSchema, H as JsonObject, J as JsonPrimitive, W as JsonSchema, U as JsonSchemaArray, Q as JsonSchemaBoolean, N as JsonSchemaNumber, V as JsonSchemaObject, L as JsonSchemaString, K as JsonSchemaType, I as JsonValue, bg as ManagedAgentRun, bh as ManagedAgentRunHandle, bf as ManagedRunError, bi as ManagedRunEvent, bj as ManagedRunEventHandler, be as ManagedRunStatus, M as Message, g as MessageInput, af as MessageProviderState, ah as MessageRole, w as ModelExecutionOptions, x as ModelInfo, ar as ModelLimits, i as ModelRequest, k as ModelResponse, b7 as Observer, b9 as ObserverExtensionRegistration, bp as OpenAiFunctionCall, bq as OpenAiFunctionCallOutput, bx as OpenAiFunctionTool, bn as OpenAiInputImage, bo as OpenAiInputMessage, bm as OpenAiInputText, bt as OpenAiOutputMessage, br as OpenAiOutputTextPart, a2 as OpenAiReasoningBlock, ap as OpenAiReasoningDeltaChunk, ad as OpenAiReasoningEffort, bu as OpenAiReasoningOutputItem, ae as OpenAiReasoningSummary, aq as OpenAiReasoningSummaryDeltaChunk, a1 as OpenAiReasoningSummaryText, bs as OpenAiRefusalPart, bv as OpenAiResponsesOutputItem, bw as OpenAiResponsesReasoningParam, O as OpenAiResponsesRequest, b4 as PayloadByStage, aw as PrepareRequestInput, r as PreparedRequest, s as ProviderCredential, y as ProviderCredentialKind, z as ProviderEndpoints, q as ProviderRequestMutator, P as ProviderSessionResolver, a6 as ReasoningVisibility, p as ResolvedProviderSession, R as RunTurnDeps, bk as RuntimeManagerOptions, b3 as Stage, S as SystemInput, e as TextBlock, b1 as ToolDefinition, az as ToolExecutionContext, b0 as ToolGenerator, au as ToolOutputEnvelope, a$ as ToolOutputValue, o as ToolResult, n as ToolResultBlock, at as ToolResultChunk, _ as ToolResultContent, Z as ToolResultContentBlock, as as ToolResultMeta, aZ as ToolRuntime, aC as ToolRuntimeCompletedEvent, aV as ToolRuntimeDispatchDecision, aE as ToolRuntimeEvent, aX as ToolRuntimeEventHandler, aB as ToolRuntimeOutputChunkEvent, aD as ToolRuntimeRejectedEvent, aA as ToolRuntimeStartedEvent, aW as ToolRuntimeToolCallHandler, aj as ToolSchema, m as ToolUseBlock, am as ToolUseDeltaChunk, b6 as Transformer, b8 as TransformerExtensionRegistration, c as TurnInput, T as TurnResult, av as TurnResultStatus, d as TurnState, ak as Usage } from '../types-QPBW5jHO.js';
1
+ // Generated by dts-bundle-generator v9.5.1
3
2
 
4
- declare class OperationAbortedError extends Error {
5
- readonly code = "ABORT_ERR";
6
- constructor(message?: string);
7
- }
8
- declare function toAbortError(reason: unknown): Error;
9
- declare function isAbortError(error: unknown): boolean;
10
- declare function throwIfAborted(signal?: AbortSignal): void;
11
- declare function addAbortListener(signal: AbortSignal | undefined, onAbort: () => void): () => void;
3
+ export declare class OperationAbortedError extends Error {
4
+ readonly code = "ABORT_ERR";
5
+ constructor(message?: string);
6
+ }
7
+ export declare function toAbortError(reason: unknown): Error;
8
+ export declare function isAbortError(error: unknown): boolean;
9
+ export declare function throwIfAborted(signal?: AbortSignal): void;
10
+ export declare function addAbortListener(signal: AbortSignal | undefined, onAbort: () => void): () => void;
11
+ export type JsonPrimitive = boolean | number | string | null;
12
+ export interface JsonObject {
13
+ [key: string]: JsonValue;
14
+ }
15
+ export type JsonValue = JsonObject | JsonPrimitive | JsonValue[];
16
+ export type JsonSchemaType = "array" | "boolean" | "number" | "object" | "string";
17
+ export interface JsonSchemaString {
18
+ type: "string";
19
+ }
20
+ export interface JsonSchemaNumber {
21
+ type: "number";
22
+ }
23
+ export interface JsonSchemaBoolean {
24
+ type: "boolean";
25
+ }
26
+ export interface JsonSchemaArray<TItem extends JsonSchema = JsonSchema> {
27
+ type: "array";
28
+ items: TItem;
29
+ }
30
+ export interface JsonSchemaObject<TProperties extends Record<string, JsonSchema> = Record<string, JsonSchema>, TRequired extends readonly string[] | undefined = readonly string[] | undefined> {
31
+ type: "object";
32
+ properties: TProperties;
33
+ required?: TRequired;
34
+ }
35
+ export type JsonSchema = JsonSchemaArray | JsonSchemaBoolean | JsonSchemaNumber | JsonSchemaObject | JsonSchemaString;
36
+ export interface TextBlock {
37
+ type: "text";
38
+ text: string;
39
+ }
40
+ export type ImageMediaType = "image/gif" | "image/jpeg" | "image/png" | "image/webp";
41
+ export interface ImageBlock {
42
+ type: "image";
43
+ source: {
44
+ type: "base64";
45
+ media_type: ImageMediaType;
46
+ data: string;
47
+ };
48
+ }
49
+ export type ToolResultContentBlock = ImageBlock | TextBlock;
50
+ export type ToolResultContent = string | ToolResultContentBlock[];
51
+ export interface AnthropicThinkingBlock {
52
+ type: "anthropic_thinking";
53
+ thinking: string;
54
+ signature: string;
55
+ }
56
+ export interface AnthropicRedactedThinkingBlock {
57
+ type: "anthropic_redacted_thinking";
58
+ data: string;
59
+ }
60
+ export interface OpenAiReasoningSummaryText {
61
+ type: "summary_text";
62
+ text: string;
63
+ }
64
+ export interface OpenAiReasoningBlock {
65
+ type: "openai_reasoning";
66
+ encryptedContent?: string;
67
+ id?: string;
68
+ summary: OpenAiReasoningSummaryText[];
69
+ text?: string;
70
+ }
71
+ export interface ToolUseBlock {
72
+ type: "tool_use";
73
+ id: string;
74
+ name: string;
75
+ input: JsonValue;
76
+ }
77
+ export interface ToolResultBlock {
78
+ type: "tool_result";
79
+ tool_use_id: string;
80
+ content: ToolResultContent;
81
+ is_error: boolean;
82
+ }
83
+ export interface AnthropicThinkingWireBlock {
84
+ type: "thinking";
85
+ thinking: string;
86
+ signature: string;
87
+ }
88
+ export interface AnthropicRedactedThinkingWireBlock {
89
+ type: "redacted_thinking";
90
+ data: string;
91
+ }
92
+ export type AnthropicAssistantContentBlock = AnthropicRedactedThinkingWireBlock | AnthropicThinkingWireBlock | TextBlock | ToolUseBlock;
93
+ export type ReasoningVisibility = "continuity-only" | "user-visible";
94
+ export type AutoReasoningEffort = "low" | "medium" | "high";
95
+ export interface AutoReasoningConfig {
96
+ effort: AutoReasoningEffort;
97
+ }
98
+ export type AnthropicThinkingDisplay = "omitted" | "summarized";
99
+ export type AnthropicThinkingEffort = "low" | "medium" | "high";
100
+ export interface AnthropicEnabledThinkingConfig {
101
+ type: "enabled";
102
+ budgetTokens: number;
103
+ display?: AnthropicThinkingDisplay;
104
+ interleaved?: boolean;
105
+ }
106
+ export interface AnthropicAdaptiveThinkingConfig {
107
+ type: "adaptive";
108
+ display?: AnthropicThinkingDisplay;
109
+ effort?: AnthropicThinkingEffort;
110
+ interleaved?: boolean;
111
+ }
112
+ export interface AnthropicDisabledThinkingConfig {
113
+ type: "disabled";
114
+ }
115
+ export type AnthropicThinkingConfig = AnthropicAdaptiveThinkingConfig | AnthropicDisabledThinkingConfig | AnthropicEnabledThinkingConfig;
116
+ export type OpenAiReasoningEffort = "high" | "low" | "medium" | "minimal" | "none" | "xhigh";
117
+ export type OpenAiReasoningSummary = "auto" | "concise" | "detailed";
118
+ export interface OpenAiReasoningConfig {
119
+ effort?: OpenAiReasoningEffort;
120
+ includeEncryptedContent?: boolean;
121
+ summary?: OpenAiReasoningSummary;
122
+ }
123
+ export interface ReasoningConfig {
124
+ auto?: AutoReasoningConfig;
125
+ anthropic?: AnthropicThinkingConfig;
126
+ openai?: OpenAiReasoningConfig;
127
+ visibility?: ReasoningVisibility;
128
+ }
129
+ export interface MessageProviderState {
130
+ anthropicAssistantContent?: AnthropicAssistantContentBlock[];
131
+ openaiResponsesOutput?: OpenAiResponsesOutputItem[];
132
+ openaiResponsesResponseId?: string;
133
+ }
134
+ export type AssistantContentBlock = AnthropicRedactedThinkingBlock | AnthropicThinkingBlock | OpenAiReasoningBlock | TextBlock | ToolUseBlock;
135
+ export type ContentBlock = AssistantContentBlock | ToolResultBlock;
136
+ export type ContentInput = ContentBlock[] | string | null | undefined;
137
+ export type MessageRole = "assistant" | "user";
138
+ export type SystemInput = TextBlock[] | string | null | undefined;
139
+ export interface Message {
140
+ id?: string;
141
+ role: MessageRole;
142
+ content: ContentBlock[];
143
+ providerState?: MessageProviderState;
144
+ }
145
+ export interface IdentifiedMessage extends Message {
146
+ id: string;
147
+ }
148
+ export interface MessageInput {
149
+ id?: string;
150
+ role: MessageRole;
151
+ content?: ContentInput;
152
+ providerState?: MessageProviderState;
153
+ }
154
+ export interface ToolSchema {
155
+ name: string;
156
+ description: string;
157
+ input_schema: JsonSchemaObject;
158
+ }
159
+ export interface Usage {
160
+ input_tokens: number;
161
+ output_tokens: number;
162
+ reasoning_tokens?: number;
163
+ }
164
+ export interface ModelRequest {
165
+ model: string;
166
+ max_tokens: number;
167
+ reasoning?: ReasoningConfig;
168
+ system: TextBlock[];
169
+ messages: Message[];
170
+ tools: ToolSchema[];
171
+ metadata: {
172
+ session_id: string;
173
+ turn_id: string;
174
+ };
175
+ }
176
+ export interface ModelResponse {
177
+ id: string;
178
+ type: "message";
179
+ role: "assistant";
180
+ content: AssistantContentBlock[];
181
+ stop_reason: "end_turn" | "tool_use";
182
+ stop_sequence: null | string;
183
+ usage: Usage;
184
+ providerState?: MessageProviderState;
185
+ }
186
+ export interface ChatRequest {
187
+ model: string;
188
+ maxTokens: number;
189
+ reasoning?: ReasoningConfig;
190
+ system: TextBlock[];
191
+ messages: Message[];
192
+ tools: ToolSchema[];
193
+ metadata: {
194
+ sessionId: string;
195
+ turnId: string;
196
+ };
197
+ }
198
+ export interface ChatResponse {
199
+ id: string;
200
+ content: AssistantContentBlock[];
201
+ stopReason: "end_turn" | "tool_use";
202
+ usage: {
203
+ inputTokens: number;
204
+ outputTokens: number;
205
+ reasoningTokens?: number;
206
+ };
207
+ providerState?: MessageProviderState;
208
+ }
209
+ export interface ContentDeltaChunk {
210
+ type: "content_delta";
211
+ index?: number;
212
+ text?: string;
213
+ }
214
+ export interface ToolUseDeltaChunk {
215
+ type: "tool_use_delta";
216
+ id: string;
217
+ index: number;
218
+ inputDelta?: string;
219
+ name?: string;
220
+ }
221
+ export interface AnthropicThinkingDeltaChunk {
222
+ type: "anthropic_thinking_delta";
223
+ index: number;
224
+ thinking: string;
225
+ }
226
+ export interface AnthropicSignatureDeltaChunk {
227
+ type: "anthropic_signature_delta";
228
+ index: number;
229
+ signature: string;
230
+ }
231
+ export interface OpenAiReasoningDeltaChunk {
232
+ type: "openai_reasoning_delta";
233
+ contentIndex: number;
234
+ delta: string;
235
+ itemId: string;
236
+ outputIndex: number;
237
+ }
238
+ export interface OpenAiReasoningSummaryDeltaChunk {
239
+ type: "openai_reasoning_summary_delta";
240
+ delta: string;
241
+ itemId: string;
242
+ outputIndex: number;
243
+ summaryIndex: number;
244
+ }
245
+ export interface ChatResponseChunk {
246
+ type: "anthropic_signature_delta" | "anthropic_thinking_delta" | "content_delta" | "done" | "openai_reasoning_delta" | "openai_reasoning_summary_delta" | "tool_use_delta";
247
+ contentIndex?: number;
248
+ delta?: string;
249
+ index?: number;
250
+ itemId?: string;
251
+ outputIndex?: number;
252
+ signature?: string;
253
+ summaryIndex?: number;
254
+ text?: string;
255
+ thinking?: string;
256
+ inputDelta?: string;
257
+ name?: string;
258
+ id?: string;
259
+ response?: ChatResponse;
260
+ }
261
+ export interface ModelLimits {
262
+ contextWindow?: number;
263
+ maxOutput?: number;
264
+ }
265
+ export interface ModelInfo {
266
+ id: string;
267
+ name: string;
268
+ limits?: ModelLimits;
269
+ supportedEndpoints?: string[];
270
+ }
271
+ export interface ToolResultMeta {
272
+ truncated?: boolean;
273
+ originalBytes?: number;
274
+ transforms: string[];
275
+ }
276
+ export interface ToolResultChunk {
277
+ output: string;
278
+ structured: JsonObject;
279
+ content?: ToolResultContent;
280
+ }
281
+ export interface ToolOutputEnvelope {
282
+ output: string;
283
+ structured?: JsonObject;
284
+ content?: ToolResultContent;
285
+ }
286
+ export interface ToolResult {
287
+ callId: string;
288
+ toolName: string;
289
+ status: "error" | "ok";
290
+ output: string;
291
+ structured: JsonObject;
292
+ content?: ToolResultContent;
293
+ chunks: ToolResultChunk[];
294
+ meta: ToolResultMeta;
295
+ }
296
+ export interface TurnInput {
297
+ sessionId: string;
298
+ turnId: string;
299
+ streaming?: boolean;
300
+ signal?: AbortSignal;
301
+ system?: SystemInput;
302
+ messages?: MessageInput[];
303
+ message: MessageInput;
304
+ }
305
+ export interface TurnState {
306
+ sessionId: string;
307
+ turnId: string;
308
+ system: TextBlock[];
309
+ messages: Message[];
310
+ lastResponse?: ChatResponse;
311
+ toolResults: ToolResult[];
312
+ finalMessage?: IdentifiedMessage;
313
+ }
314
+ export type TurnResultStatus = "completed" | "aborted";
315
+ export interface TurnResult {
316
+ status: TurnResultStatus;
317
+ finalMessage?: IdentifiedMessage;
318
+ state: TurnState;
319
+ }
320
+ export type ProviderCredentialKind = "api-key" | "oauth-token" | "session-token";
321
+ export interface ProviderCredential {
322
+ kind: ProviderCredentialKind;
323
+ value: string;
324
+ }
325
+ export interface ProviderEndpoints {
326
+ api?: string;
327
+ originTracker?: string;
328
+ proxy?: string;
329
+ telemetry?: string;
330
+ }
331
+ export interface ResolvedProviderSession {
332
+ credential: ProviderCredential;
333
+ endpoints?: ProviderEndpoints;
334
+ metadata?: Record<string, string>;
335
+ }
336
+ export interface ProviderSessionResolver {
337
+ resolve(signal?: AbortSignal): Promise<ResolvedProviderSession>;
338
+ }
339
+ export interface PrepareRequestInput {
340
+ sessionId: string;
341
+ turnId: string;
342
+ reasoning?: ReasoningConfig;
343
+ system: TextBlock[];
344
+ messages: Message[];
345
+ tools: ToolSchema[];
346
+ maxTokens?: number;
347
+ }
348
+ export interface PreparedRequest {
349
+ request: ModelRequest;
350
+ session?: ResolvedProviderSession;
351
+ }
352
+ export type ProviderRequestMutator = (preparedRequest: PreparedRequest) => PreparedRequest | Promise<PreparedRequest>;
353
+ export interface ChatModel {
354
+ prepareRequest(request: PrepareRequestInput): ModelRequest;
355
+ complete(request: ModelRequest): Promise<ModelResponse>;
356
+ }
357
+ export interface ModelExecutionOptions {
358
+ signal?: AbortSignal;
359
+ }
360
+ export interface EngineChatModel {
361
+ model: string;
362
+ maxTokens?: number;
363
+ complete(request: ChatRequest, options?: ModelExecutionOptions): Promise<ChatResponse>;
364
+ stream?(request: ChatRequest, options?: ModelExecutionOptions): AsyncIterable<ChatResponseChunk>;
365
+ getModels?(signal?: AbortSignal): Promise<ModelInfo[]>;
366
+ }
367
+ export interface BaseChatModelOptions {
368
+ model: string;
369
+ maxTokens?: number;
370
+ reasoning?: ReasoningConfig;
371
+ providerSessionResolver?: ProviderSessionResolver;
372
+ requestMutators?: ProviderRequestMutator[];
373
+ }
374
+ export interface AgentEventContext {
375
+ sessionId: string;
376
+ turnId: string;
377
+ state: TurnState;
378
+ }
379
+ export interface ToolExecutionContext extends AgentEventContext {
380
+ signal: AbortSignal;
381
+ toolCallId?: string;
382
+ }
383
+ export interface ToolRuntimeStartedEvent {
384
+ type: "tool_started";
385
+ toolCall: ToolUseBlock;
386
+ }
387
+ export interface ToolRuntimeOutputChunkEvent {
388
+ type: "tool_output_chunk";
389
+ toolCall: ToolUseBlock;
390
+ chunk: ToolResultChunk;
391
+ }
392
+ export interface ToolRuntimeCompletedEvent {
393
+ type: "tool_completed";
394
+ toolCall: ToolUseBlock;
395
+ result: ToolResult;
396
+ }
397
+ export interface ToolRuntimeRejectedEvent {
398
+ type: "tool_rejected";
399
+ toolCall: ToolUseBlock;
400
+ result: ToolResult;
401
+ }
402
+ export type ToolRuntimeEvent = ToolRuntimeOutputChunkEvent | ToolRuntimeCompletedEvent | ToolRuntimeRejectedEvent | ToolRuntimeStartedEvent;
403
+ export interface AgentUserMessageEvent {
404
+ type: "user_message";
405
+ message: Message;
406
+ }
407
+ export interface AgentModelRequestEvent {
408
+ type: "model_request";
409
+ request: ChatRequest;
410
+ }
411
+ export interface AgentModelResponseEvent {
412
+ type: "model_response";
413
+ response: ChatResponse;
414
+ }
415
+ export interface AgentAssistantMessageEvent {
416
+ type: "assistant_message";
417
+ message: IdentifiedMessage;
418
+ }
419
+ export interface AgentAssistantChunkEvent {
420
+ type: "assistant_chunk";
421
+ index: number;
422
+ messageId: string;
423
+ chunk: ContentDeltaChunk;
424
+ }
425
+ export interface AgentToolUseMessageEvent {
426
+ type: "tool_use_message";
427
+ message: IdentifiedMessage;
428
+ }
429
+ export interface AgentToolUseChunkEvent {
430
+ type: "tool_use_chunk";
431
+ index: number;
432
+ messageId: string;
433
+ chunk: ToolUseDeltaChunk;
434
+ }
435
+ export interface AgentReasoningMessageEvent {
436
+ type: "reasoning_message";
437
+ message: IdentifiedMessage;
438
+ }
439
+ export interface AgentReasoningChunkEvent {
440
+ type: "reasoning_chunk";
441
+ index: number;
442
+ messageId: string;
443
+ chunk: AnthropicThinkingDeltaChunk | OpenAiReasoningDeltaChunk | OpenAiReasoningSummaryDeltaChunk;
444
+ text: string;
445
+ }
446
+ export interface AgentToolCallEvent {
447
+ type: "tool_call";
448
+ toolCall: ToolUseBlock;
449
+ }
450
+ export interface AgentToolResultEvent {
451
+ type: "tool_result";
452
+ result: ToolResult;
453
+ }
454
+ export interface AgentToolResultMessageEvent {
455
+ type: "tool_result_message";
456
+ message: Message;
457
+ }
458
+ export interface AgentFinalMessageEvent {
459
+ type: "final_message";
460
+ message: IdentifiedMessage;
461
+ }
462
+ export interface AgentTurnCompleteEvent {
463
+ type: "turn_complete";
464
+ state: TurnState;
465
+ }
466
+ export type AgentLifecycleEvent = AgentAssistantChunkEvent | AgentAssistantMessageEvent | AgentFinalMessageEvent | AgentModelRequestEvent | AgentModelResponseEvent | AgentReasoningChunkEvent | AgentReasoningMessageEvent | AgentToolCallEvent | AgentToolUseChunkEvent | AgentToolUseMessageEvent | AgentToolResultEvent | AgentToolResultMessageEvent | AgentTurnCompleteEvent | AgentUserMessageEvent;
467
+ export type AgentEvent = AgentLifecycleEvent | ToolRuntimeEvent;
468
+ export type ToolRuntimeDispatchDecision = {
469
+ action: "reject";
470
+ reason?: string;
471
+ } | {
472
+ action: "run";
473
+ };
474
+ export type ToolRuntimeToolCallHandler = (toolCall: ToolUseBlock, ctx: ToolExecutionContext) => Promise<ToolRuntimeDispatchDecision | undefined> | ToolRuntimeDispatchDecision | undefined;
475
+ export type ToolRuntimeEventHandler = (event: ToolRuntimeEvent, ctx: ToolExecutionContext) => Promise<void> | void;
476
+ export type AgentEventHandler = (event: AgentEvent, ctx: AgentEventContext) => Promise<void> | void;
477
+ export interface ToolRuntime {
478
+ listToolSchemas(): ToolSchema[];
479
+ setTools(tools: AnyToolDefinition[]): void;
480
+ executeCalls(toolCalls: ToolUseBlock[], ctx: ToolExecutionContext): Promise<ToolResult[]>;
481
+ execute(toolCall: ToolUseBlock, ctx: ToolExecutionContext): Promise<ToolResult>;
482
+ }
483
+ export type InferJsonSchema<TSchema extends JsonSchema> = TSchema extends JsonSchemaString ? string : TSchema extends JsonSchemaNumber ? number : TSchema extends JsonSchemaBoolean ? boolean : TSchema extends JsonSchemaArray<infer TItem> ? InferJsonSchema<TItem>[] : TSchema extends JsonSchemaObject<infer TProperties, infer TRequired> ? Expand<RequiredProperties<TProperties, TRequired> & OptionalProperties<TProperties, TRequired>> : never;
484
+ export type Expand<TValue> = TValue extends infer TObject ? {
485
+ [TKey in keyof TObject]: TObject[TKey];
486
+ } : never;
487
+ export type RequiredKeyUnion<TRequired extends readonly string[] | undefined> = TRequired extends readonly string[] ? TRequired[number] : never;
488
+ export type OptionalKeyUnion<TProperties extends Record<string, JsonSchema>, TRequired extends readonly string[] | undefined> = Exclude<keyof TProperties, RequiredKeyUnion<TRequired>>;
489
+ export type RequiredProperties<TProperties extends Record<string, JsonSchema>, TRequired extends readonly string[] | undefined> = {
490
+ [TKey in Extract<keyof TProperties, RequiredKeyUnion<TRequired>>]: InferJsonSchema<TProperties[TKey]>;
491
+ };
492
+ export type OptionalProperties<TProperties extends Record<string, JsonSchema>, TRequired extends readonly string[] | undefined> = {
493
+ [TKey in OptionalKeyUnion<TProperties, TRequired>]?: InferJsonSchema<TProperties[TKey]>;
494
+ };
495
+ export type ToolOutputValue = JsonValue | ToolOutputEnvelope;
496
+ export type ToolGenerator<TYield extends ToolOutputValue = ToolOutputValue, TReturn extends ToolOutputValue | undefined = ToolOutputValue | undefined> = AsyncGenerator<TYield, TReturn, void>;
497
+ export interface ToolDefinition<TInput extends JsonObject = JsonObject, TYield extends ToolOutputValue = ToolOutputValue, TReturn extends ToolOutputValue | undefined = ToolOutputValue | undefined, TSchema extends JsonSchemaObject = JsonSchemaObject> {
498
+ name: string;
499
+ description: string;
500
+ inputSchema: TSchema;
501
+ execute(input: TInput, ctx: ToolExecutionContext): ToolGenerator<TYield, TReturn>;
502
+ }
503
+ export type AnyToolDefinition = ToolDefinition<JsonObject, ToolOutputValue, ToolOutputValue | undefined, JsonSchemaObject>;
504
+ export type Stage = "afterModelResponse" | "afterToolResult" | "afterTurnComplete" | "beforeAssistantAppend" | "beforeFinalOutput" | "beforeModelRequest" | "beforeToolExecution" | "beforeToolResultAppend" | "onUserMessage";
505
+ export interface PayloadByStage {
506
+ onUserMessage: Message;
507
+ beforeModelRequest: ChatRequest;
508
+ afterModelResponse: ChatResponse;
509
+ beforeToolExecution: ToolUseBlock;
510
+ afterToolResult: ToolResult;
511
+ beforeAssistantAppend: Message;
512
+ beforeFinalOutput: Message;
513
+ beforeToolResultAppend: Message;
514
+ afterTurnComplete: TurnState;
515
+ }
516
+ export interface ExtensionContext {
517
+ state: TurnState;
518
+ }
519
+ type Transformer$1<S extends Stage> = (payload: PayloadByStage[S], ctx: ExtensionContext) => PayloadByStage[S] | Promise<PayloadByStage[S]>;
520
+ export type Observer<S extends Stage> = (payload: PayloadByStage[S], ctx: ExtensionContext) => Promise<void> | void;
521
+ export interface TransformerExtensionRegistration<S extends Stage = Stage> {
522
+ id: string;
523
+ stage: S;
524
+ kind: "transformer";
525
+ order: number;
526
+ enabled: boolean;
527
+ run: Transformer$1<S>;
528
+ }
529
+ export interface ObserverExtensionRegistration<S extends Stage = Stage> {
530
+ id: string;
531
+ stage: S;
532
+ kind: "observer";
533
+ order: number;
534
+ enabled: boolean;
535
+ run: Observer<S>;
536
+ }
537
+ export type ExtensionRegistration<S extends Stage = Stage> = ObserverExtensionRegistration<S> | TransformerExtensionRegistration<S>;
538
+ export type AnyExtensionRegistration = {
539
+ [S in Stage]: ExtensionRegistration<S>;
540
+ }[Stage];
541
+ export interface ExtensionRegistry {
542
+ register(extension: AnyExtensionRegistration): void;
543
+ runTransformers<S extends Stage>(stage: S, payload: PayloadByStage[S], ctx: ExtensionContext): Promise<PayloadByStage[S]>;
544
+ runObservers<S extends Stage>(stage: S, payload: PayloadByStage[S], ctx: ExtensionContext): Promise<void>;
545
+ }
546
+ export interface RunTurnDeps {
547
+ registry: ExtensionRegistry;
548
+ chatModel: EngineChatModel;
549
+ toolRuntime: ToolRuntime;
550
+ onEvent?: AgentEventHandler;
551
+ }
552
+ export type AgentInput = MessageInput | string;
553
+ export interface AgentSendOptions {
554
+ streaming?: boolean;
555
+ signal?: AbortSignal;
556
+ }
557
+ export interface AgentOptions {
558
+ sessionId?: string;
559
+ systemPrompt?: string;
560
+ messages?: MessageInput[];
561
+ message?: AgentInput;
562
+ onEvent?: AgentEventHandler;
563
+ onToolCall?: ToolRuntimeToolCallHandler;
564
+ registry?: ExtensionRegistry;
565
+ extensions?: AnyExtensionRegistration[];
566
+ chatModel?: EngineChatModel;
567
+ tools?: AnyToolDefinition[];
568
+ }
569
+ export interface AgentDefinitionFactoryContext {
570
+ agentId: string;
571
+ parentSessionId?: string;
572
+ runId?: string;
573
+ toolCallId?: string;
574
+ }
575
+ export interface AgentDefinition {
576
+ id: string;
577
+ description?: string;
578
+ enabled?: boolean;
579
+ allowedChildAgentIds?: string[];
580
+ createOptions(ctx?: AgentDefinitionFactoryContext): AgentOptions;
581
+ }
582
+ export type ManagedRunStatus = "aborted" | "completed" | "failed" | "idle" | "running";
583
+ export interface ManagedRunError {
584
+ message: string;
585
+ }
586
+ export interface ManagedAgentRun {
587
+ runId: string;
588
+ agentId: string;
589
+ sessionId: string;
590
+ status: ManagedRunStatus;
591
+ depth: number;
592
+ parentRunId?: string;
593
+ originToolCallId?: string;
594
+ result?: TurnResult;
595
+ error?: ManagedRunError;
596
+ }
597
+ export interface ManagedAgentRunHandle {
598
+ readonly runId: string;
599
+ readonly agentId: string;
600
+ readonly sessionId: string;
601
+ send(input: AgentInput, options?: AgentSendOptions): Promise<TurnResult>;
602
+ snapshot(): ManagedAgentRun;
603
+ wait(signal?: AbortSignal): Promise<ManagedAgentRun>;
604
+ }
605
+ export interface ManagedRunEvent {
606
+ runId: string;
607
+ agentId: string;
608
+ sessionId: string;
609
+ parentRunId?: string;
610
+ originToolCallId?: string;
611
+ event: AgentEvent;
612
+ }
613
+ export type ManagedRunEventHandler = (event: ManagedRunEvent) => Promise<void> | void;
614
+ export interface RuntimeManagerOptions {
615
+ onEvent?: ManagedRunEventHandler;
616
+ }
617
+ export interface CreateManagedRunInput {
618
+ agentId: string;
619
+ parentRunId?: string;
620
+ originToolCallId?: string;
621
+ }
622
+ export interface CompileRequestInput {
623
+ sessionId: string;
624
+ turnId: string;
625
+ reasoning?: ReasoningConfig;
626
+ system?: SystemInput;
627
+ messages: MessageInput[];
628
+ tools?: ToolSchema[];
629
+ model?: string;
630
+ max_tokens?: number;
631
+ }
632
+ export interface OpenAiInputText {
633
+ type: "input_text";
634
+ text: string;
635
+ }
636
+ export interface OpenAiInputImage {
637
+ type: "input_image";
638
+ image_url: string;
639
+ detail?: string;
640
+ }
641
+ export interface OpenAiInputMessage {
642
+ type: "message";
643
+ role: MessageRole;
644
+ content: Array<OpenAiInputImage | OpenAiInputText>;
645
+ }
646
+ export interface OpenAiFunctionCall {
647
+ type: "function_call";
648
+ call_id: string;
649
+ name: string;
650
+ arguments: string;
651
+ }
652
+ export interface OpenAiFunctionCallOutput {
653
+ type: "function_call_output";
654
+ call_id: string;
655
+ output: string;
656
+ }
657
+ export interface OpenAiOutputTextPart {
658
+ type: "output_text";
659
+ text: string;
660
+ }
661
+ export interface OpenAiRefusalPart {
662
+ type: "refusal";
663
+ refusal: string;
664
+ }
665
+ export interface OpenAiOutputMessage {
666
+ type: "message";
667
+ content?: Array<OpenAiOutputTextPart | OpenAiRefusalPart>;
668
+ role?: string;
669
+ status?: string;
670
+ }
671
+ export interface OpenAiReasoningOutputItem {
672
+ type: "reasoning";
673
+ content?: Array<{
674
+ text?: string;
675
+ type?: string;
676
+ }>;
677
+ encrypted_content?: string;
678
+ id?: string;
679
+ status?: string;
680
+ summary?: OpenAiReasoningSummaryText[];
681
+ text?: string;
682
+ }
683
+ export type OpenAiResponsesOutputItem = JsonObject | OpenAiFunctionCall | OpenAiOutputMessage | OpenAiReasoningOutputItem;
684
+ export interface OpenAiResponsesReasoningParam {
685
+ effort?: OpenAiReasoningEffort;
686
+ generate_summary?: OpenAiReasoningSummary;
687
+ summary?: OpenAiReasoningSummary;
688
+ }
689
+ export interface OpenAiFunctionTool {
690
+ type: "function";
691
+ name: string;
692
+ description: string;
693
+ parameters: JsonSchemaObject;
694
+ }
695
+ export interface OpenAiResponsesRequest {
696
+ include?: string[];
697
+ model: string;
698
+ instructions: string;
699
+ input: Array<OpenAiFunctionCall | OpenAiFunctionCallOutput | OpenAiInputMessage | OpenAiResponsesOutputItem>;
700
+ max_output_tokens?: number;
701
+ reasoning?: OpenAiResponsesReasoningParam;
702
+ tools: OpenAiFunctionTool[];
703
+ }
704
+ export declare function mapAutoReasoningEffortToBudgetTokens(effort: AutoReasoningEffort): number;
705
+ export declare function resolveAnthropicThinkingConfig(reasoning: ReasoningConfig | undefined): AnthropicThinkingConfig | undefined;
706
+ export declare function resolveOpenAiReasoningConfig(reasoning: ReasoningConfig | undefined): OpenAiReasoningConfig | undefined;
12
707
 
13
- declare function mapAutoReasoningEffortToBudgetTokens(effort: AutoReasoningEffort): number;
14
- declare function resolveAnthropicThinkingConfig(reasoning: ReasoningConfig | undefined): AnthropicThinkingConfig | undefined;
15
- declare function resolveOpenAiReasoningConfig(reasoning: ReasoningConfig | undefined): OpenAiReasoningConfig | undefined;
708
+ export {
709
+ Transformer$1 as Transformer,
710
+ };
16
711
 
17
- export { AnthropicThinkingConfig, AutoReasoningEffort, OpenAiReasoningConfig, OperationAbortedError, ReasoningConfig, addAbortListener, isAbortError, mapAutoReasoningEffortToBudgetTokens, resolveAnthropicThinkingConfig, resolveOpenAiReasoningConfig, throwIfAborted, toAbortError };
712
+ export {};