@zhivex-ai/core 0.5.0-next.0 → 0.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/agent-approval.d.ts +6 -0
- package/dist/agent-approval.d.ts.map +1 -0
- package/dist/agent-approval.js +38 -0
- package/dist/agent-approval.js.map +1 -0
- package/dist/agent-handoff.d.ts +11 -0
- package/dist/agent-handoff.d.ts.map +1 -0
- package/dist/agent-handoff.js +20 -0
- package/dist/agent-handoff.js.map +1 -0
- package/dist/agent-store.d.ts +20 -0
- package/dist/agent-store.d.ts.map +1 -0
- package/dist/agent-store.js +252 -0
- package/dist/agent-store.js.map +1 -0
- package/dist/agent.d.ts +8 -0
- package/dist/agent.d.ts.map +1 -0
- package/dist/agent.js +701 -0
- package/dist/agent.js.map +1 -0
- package/dist/catalog.js +1 -1
- package/dist/catalog.js.map +1 -1
- package/dist/errors.d.ts +8 -0
- package/dist/errors.d.ts.map +1 -1
- package/dist/errors.js +9 -0
- package/dist/errors.js.map +1 -1
- package/dist/generate-text.d.ts.map +1 -1
- package/dist/generate-text.js +86 -43
- package/dist/generate-text.js.map +1 -1
- package/dist/index.d.ts +13 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +10 -1
- package/dist/index.js.map +1 -1
- package/dist/live-agent.d.ts +3 -0
- package/dist/live-agent.d.ts.map +1 -0
- package/dist/live-agent.js +565 -0
- package/dist/live-agent.js.map +1 -0
- package/dist/mcp.d.ts +40 -0
- package/dist/mcp.d.ts.map +1 -0
- package/dist/mcp.js +167 -0
- package/dist/mcp.js.map +1 -0
- package/dist/messages.d.ts +9 -1
- package/dist/messages.d.ts.map +1 -1
- package/dist/messages.js +55 -0
- package/dist/messages.js.map +1 -1
- package/dist/observability.d.ts +51 -0
- package/dist/observability.d.ts.map +1 -0
- package/dist/observability.js +282 -0
- package/dist/observability.js.map +1 -0
- package/dist/realtime.d.ts +55 -0
- package/dist/realtime.d.ts.map +1 -0
- package/dist/realtime.js +316 -0
- package/dist/realtime.js.map +1 -0
- package/dist/stream.d.ts +5 -2
- package/dist/stream.d.ts.map +1 -1
- package/dist/stream.js +1 -0
- package/dist/stream.js.map +1 -1
- package/dist/tool-registry.d.ts +17 -0
- package/dist/tool-registry.d.ts.map +1 -0
- package/dist/tool-registry.js +74 -0
- package/dist/tool-registry.js.map +1 -0
- package/dist/types.d.ts +595 -500
- package/dist/types.d.ts.map +1 -1
- package/dist/ui.d.ts +4 -2
- package/dist/ui.d.ts.map +1 -1
- package/dist/ui.js +47 -0
- package/dist/ui.js.map +1 -1
- package/package.json +1 -1
package/dist/types.d.ts
CHANGED
|
@@ -28,19 +28,6 @@ export interface ToolExecutionResult {
|
|
|
28
28
|
};
|
|
29
29
|
isError: boolean;
|
|
30
30
|
}
|
|
31
|
-
export type ToolSandboxLevel = "read-only" | "write" | "network" | "admin";
|
|
32
|
-
export type ToolSideEffectLevel = "none" | "low" | "medium" | "high";
|
|
33
|
-
export interface ToolPolicy {
|
|
34
|
-
sandbox?: ToolSandboxLevel;
|
|
35
|
-
sideEffect?: ToolSideEffectLevel;
|
|
36
|
-
scopes?: string[];
|
|
37
|
-
tags?: string[];
|
|
38
|
-
}
|
|
39
|
-
export interface ToolProgressUpdate {
|
|
40
|
-
message?: string;
|
|
41
|
-
output?: JsonValue;
|
|
42
|
-
metadata?: Record<string, unknown>;
|
|
43
|
-
}
|
|
44
31
|
export type ToolChoice = "auto" | "none" | "required" | {
|
|
45
32
|
type: "tool";
|
|
46
33
|
toolName: string;
|
|
@@ -68,7 +55,12 @@ export interface ToolResultPart {
|
|
|
68
55
|
type: "tool-result";
|
|
69
56
|
toolResult: ToolExecutionResult;
|
|
70
57
|
}
|
|
71
|
-
export
|
|
58
|
+
export interface ProviderDataPart {
|
|
59
|
+
type: "provider-data";
|
|
60
|
+
provider: string;
|
|
61
|
+
data: JsonValue;
|
|
62
|
+
}
|
|
63
|
+
export type ContentPart = TextPart | ImagePart | FilePart | ToolCallPart | ToolResultPart | ProviderDataPart;
|
|
72
64
|
export interface ModelMessage {
|
|
73
65
|
role: MessageRole;
|
|
74
66
|
parts: ContentPart[];
|
|
@@ -87,7 +79,28 @@ export interface ModelCapabilities {
|
|
|
87
79
|
embeddings: boolean;
|
|
88
80
|
reasoning: boolean;
|
|
89
81
|
webSearch: boolean;
|
|
90
|
-
|
|
82
|
+
realtime?: {
|
|
83
|
+
sessions: boolean;
|
|
84
|
+
audioInput: boolean;
|
|
85
|
+
audioOutput: boolean;
|
|
86
|
+
imageInput: boolean;
|
|
87
|
+
tools: boolean;
|
|
88
|
+
browserTokens: boolean;
|
|
89
|
+
};
|
|
90
|
+
agentCapabilities?: AgentCapabilities;
|
|
91
|
+
}
|
|
92
|
+
export interface AgentCapabilities {
|
|
93
|
+
supportTier: AgentSupportTier;
|
|
94
|
+
toolChoiceNone: boolean;
|
|
95
|
+
approvalRequests: boolean;
|
|
96
|
+
hostedWebSearch: boolean;
|
|
97
|
+
hostedFileSearch: boolean;
|
|
98
|
+
remoteMcp: boolean;
|
|
99
|
+
computerUse: boolean;
|
|
100
|
+
codeExecution: boolean;
|
|
101
|
+
toolsets: boolean;
|
|
102
|
+
}
|
|
103
|
+
export type AgentSupportTier = "tier-a" | "tier-b" | "tier-c";
|
|
91
104
|
export interface RetryOptions {
|
|
92
105
|
abortSignal?: AbortSignal;
|
|
93
106
|
timeoutMs?: number;
|
|
@@ -100,22 +113,6 @@ export interface ToolExecutionOptions {
|
|
|
100
113
|
timeoutMs?: number;
|
|
101
114
|
stopOnError?: boolean;
|
|
102
115
|
}
|
|
103
|
-
export interface ToolExecutionContext {
|
|
104
|
-
runId: string;
|
|
105
|
-
sessionId: string;
|
|
106
|
-
step: number;
|
|
107
|
-
toolCallId: string;
|
|
108
|
-
toolName: string;
|
|
109
|
-
abortSignal?: AbortSignal;
|
|
110
|
-
metadata?: Record<string, unknown>;
|
|
111
|
-
session?: Pick<AgentSession, "id" | "status" | "summary" | "metadata" | "activeAgentStack">;
|
|
112
|
-
messages?: readonly ModelMessage[];
|
|
113
|
-
memory: {
|
|
114
|
-
search: (query?: string, options?: Omit<MemoryQuery, "query" | "sessionId">) => Promise<MemoryRecord[]>;
|
|
115
|
-
write?: (records: MemoryRecord | MemoryRecord[]) => Promise<void> | void;
|
|
116
|
-
};
|
|
117
|
-
emitProgress: (update: ToolProgressUpdate) => Promise<void> | void;
|
|
118
|
-
}
|
|
119
116
|
export interface StructuredOutputConfig<TSchema extends ZodTypeAny = ZodTypeAny> {
|
|
120
117
|
schema: TSchema;
|
|
121
118
|
mode: StructuredOutputMode;
|
|
@@ -138,6 +135,11 @@ export interface StreamToolResultEvent {
|
|
|
138
135
|
type: "tool-result";
|
|
139
136
|
toolResult: ToolExecutionResult;
|
|
140
137
|
}
|
|
138
|
+
export interface StreamProviderDataEvent {
|
|
139
|
+
type: "provider-data";
|
|
140
|
+
provider: string;
|
|
141
|
+
data: JsonValue;
|
|
142
|
+
}
|
|
141
143
|
export interface StreamFinishEvent {
|
|
142
144
|
type: "finish";
|
|
143
145
|
finishReason?: FinishReason;
|
|
@@ -148,7 +150,34 @@ export interface StreamErrorEvent {
|
|
|
148
150
|
type: "error";
|
|
149
151
|
error: Error;
|
|
150
152
|
}
|
|
151
|
-
export type StreamEvent = StreamTextDeltaEvent | StreamToolCallEvent | StreamToolResultEvent | StreamFinishEvent | StreamErrorEvent;
|
|
153
|
+
export type StreamEvent = StreamTextDeltaEvent | StreamToolCallEvent | StreamToolResultEvent | StreamProviderDataEvent | StreamFinishEvent | StreamErrorEvent;
|
|
154
|
+
export interface AgentRunStartEvent {
|
|
155
|
+
type: "agent-run-start";
|
|
156
|
+
currentStep: number;
|
|
157
|
+
maxSteps: number;
|
|
158
|
+
}
|
|
159
|
+
export interface AgentStepStartEvent {
|
|
160
|
+
type: "agent-step-start";
|
|
161
|
+
stepIndex: number;
|
|
162
|
+
}
|
|
163
|
+
export interface AgentStepFinishEvent {
|
|
164
|
+
type: "agent-step-finish";
|
|
165
|
+
step: AgentStep;
|
|
166
|
+
}
|
|
167
|
+
export interface AgentApprovalRequestEvent {
|
|
168
|
+
type: "agent-approval-request";
|
|
169
|
+
approval: AgentApprovalRequest;
|
|
170
|
+
}
|
|
171
|
+
export interface AgentApprovalResolvedEvent {
|
|
172
|
+
type: "agent-approval-resolved";
|
|
173
|
+
approval: AgentApprovalResponse;
|
|
174
|
+
}
|
|
175
|
+
export interface AgentRunFinishEvent {
|
|
176
|
+
type: "agent-run-finish";
|
|
177
|
+
status: AgentStatus;
|
|
178
|
+
state: AgentRunState;
|
|
179
|
+
}
|
|
180
|
+
export type AgentStreamEvent = StreamEvent | AgentRunStartEvent | AgentStepStartEvent | AgentStepFinishEvent | AgentApprovalRequestEvent | AgentApprovalResolvedEvent | AgentRunFinishEvent;
|
|
152
181
|
export interface StreamObjectDeltaEvent {
|
|
153
182
|
type: "object-delta";
|
|
154
183
|
textDelta: string;
|
|
@@ -264,13 +293,136 @@ export interface SpeechModel<TProviderOptions extends ProviderOptions = Provider
|
|
|
264
293
|
readonly capabilities: ModelCapabilities;
|
|
265
294
|
generateSpeech(input: SpeechModelInput<TProviderOptions>): Promise<SpeechResult>;
|
|
266
295
|
}
|
|
296
|
+
export interface AudioFrame {
|
|
297
|
+
data: string | Uint8Array | ArrayBuffer;
|
|
298
|
+
mediaType: string;
|
|
299
|
+
sampleRateHz?: number;
|
|
300
|
+
channels?: number;
|
|
301
|
+
isFinal?: boolean;
|
|
302
|
+
}
|
|
303
|
+
export interface MediaFrame {
|
|
304
|
+
data: string | Uint8Array | ArrayBuffer;
|
|
305
|
+
mediaType: string;
|
|
306
|
+
}
|
|
307
|
+
export interface RealtimeConnectOptions {
|
|
308
|
+
timeoutMs?: number;
|
|
309
|
+
signal?: AbortSignal;
|
|
310
|
+
subprotocols?: string[];
|
|
311
|
+
}
|
|
312
|
+
export interface RealtimeSessionConfig {
|
|
313
|
+
instructions?: string;
|
|
314
|
+
voice?: string;
|
|
315
|
+
tools?: ToolCollection;
|
|
316
|
+
toolChoice?: ToolChoice;
|
|
317
|
+
inputAudioMediaType?: string;
|
|
318
|
+
outputAudioMediaType?: string;
|
|
319
|
+
inputSampleRateHz?: number;
|
|
320
|
+
outputSampleRateHz?: number;
|
|
321
|
+
channels?: number;
|
|
322
|
+
turnDetection?: Record<string, unknown> | null;
|
|
323
|
+
providerOptions?: ProviderOptions;
|
|
324
|
+
metadata?: Record<string, JsonValue>;
|
|
325
|
+
autoResponse?: boolean;
|
|
326
|
+
}
|
|
327
|
+
export interface RealtimeTokenResult {
|
|
328
|
+
value: string;
|
|
329
|
+
expiresAtMs?: number;
|
|
330
|
+
rawResponse?: unknown;
|
|
331
|
+
}
|
|
332
|
+
export interface RealtimeSessionStartedEvent {
|
|
333
|
+
type: "realtime-start";
|
|
334
|
+
sessionId?: string;
|
|
335
|
+
providerMetadata?: Record<string, JsonValue>;
|
|
336
|
+
}
|
|
337
|
+
export interface RealtimeTextDeltaEvent {
|
|
338
|
+
type: "realtime-text-delta";
|
|
339
|
+
textDelta: string;
|
|
340
|
+
itemId?: string;
|
|
341
|
+
responseId?: string;
|
|
342
|
+
role?: "assistant";
|
|
343
|
+
providerMetadata?: Record<string, JsonValue>;
|
|
344
|
+
}
|
|
345
|
+
export interface RealtimeAudioOutputEvent {
|
|
346
|
+
type: "realtime-audio-output";
|
|
347
|
+
audio: Uint8Array;
|
|
348
|
+
mediaType: string;
|
|
349
|
+
sampleRateHz?: number;
|
|
350
|
+
channels?: number;
|
|
351
|
+
itemId?: string;
|
|
352
|
+
responseId?: string;
|
|
353
|
+
providerMetadata?: Record<string, JsonValue>;
|
|
354
|
+
}
|
|
355
|
+
export interface RealtimeTranscriptEvent {
|
|
356
|
+
type: "realtime-transcript";
|
|
357
|
+
text: string;
|
|
358
|
+
role: "user" | "assistant";
|
|
359
|
+
isFinal: boolean;
|
|
360
|
+
itemId?: string;
|
|
361
|
+
responseId?: string;
|
|
362
|
+
providerMetadata?: Record<string, JsonValue>;
|
|
363
|
+
}
|
|
364
|
+
export interface RealtimeToolCallEvent {
|
|
365
|
+
type: "realtime-tool-call";
|
|
366
|
+
toolCall: ToolCall;
|
|
367
|
+
}
|
|
368
|
+
export interface RealtimeToolResultEvent {
|
|
369
|
+
type: "realtime-tool-result";
|
|
370
|
+
toolResult: ToolExecutionResult;
|
|
371
|
+
}
|
|
372
|
+
export interface RealtimeResponseCompleteEvent {
|
|
373
|
+
type: "realtime-response-complete";
|
|
374
|
+
reason?: string;
|
|
375
|
+
providerMetadata?: Record<string, JsonValue>;
|
|
376
|
+
}
|
|
377
|
+
export interface RealtimeSessionResumptionEvent {
|
|
378
|
+
type: "realtime-session-resumption";
|
|
379
|
+
handle?: string;
|
|
380
|
+
resumable?: boolean;
|
|
381
|
+
providerMetadata?: Record<string, JsonValue>;
|
|
382
|
+
}
|
|
383
|
+
export interface RealtimeGoAwayEvent {
|
|
384
|
+
type: "realtime-go-away";
|
|
385
|
+
timeLeftMs?: number;
|
|
386
|
+
providerMetadata?: Record<string, JsonValue>;
|
|
387
|
+
}
|
|
388
|
+
export interface RealtimeSessionEndedEvent {
|
|
389
|
+
type: "realtime-end";
|
|
390
|
+
reason?: string;
|
|
391
|
+
providerMetadata?: Record<string, JsonValue>;
|
|
392
|
+
}
|
|
393
|
+
export interface RealtimeErrorEvent {
|
|
394
|
+
type: "realtime-error";
|
|
395
|
+
error?: Error;
|
|
396
|
+
message?: string;
|
|
397
|
+
providerMetadata?: Record<string, JsonValue>;
|
|
398
|
+
}
|
|
399
|
+
export type RealtimeEvent = RealtimeSessionStartedEvent | RealtimeTextDeltaEvent | RealtimeAudioOutputEvent | RealtimeTranscriptEvent | RealtimeToolCallEvent | RealtimeToolResultEvent | RealtimeResponseCompleteEvent | RealtimeSessionResumptionEvent | RealtimeGoAwayEvent | RealtimeSessionEndedEvent | RealtimeErrorEvent;
|
|
400
|
+
export interface RealtimeSession {
|
|
401
|
+
readonly provider: string;
|
|
402
|
+
readonly modelId: string;
|
|
403
|
+
readonly capabilities: ModelCapabilities;
|
|
404
|
+
readonly config: RealtimeSessionConfig;
|
|
405
|
+
sendAudio(frame: AudioFrame): Promise<void>;
|
|
406
|
+
sendMedia(frame: MediaFrame): Promise<void>;
|
|
407
|
+
sendText(text: string): Promise<void>;
|
|
408
|
+
sendToolResult(result: ToolExecutionResult): Promise<void>;
|
|
409
|
+
update(config: Partial<RealtimeSessionConfig>): Promise<void>;
|
|
410
|
+
eventStream(): AsyncIterable<RealtimeEvent>;
|
|
411
|
+
close(): Promise<void>;
|
|
412
|
+
}
|
|
413
|
+
export interface RealtimeModel {
|
|
414
|
+
readonly provider: string;
|
|
415
|
+
readonly modelId: string;
|
|
416
|
+
readonly capabilities: ModelCapabilities;
|
|
417
|
+
connect(config?: RealtimeSessionConfig, options?: RealtimeConnectOptions): Promise<RealtimeSession>;
|
|
418
|
+
createBrowserToken?(config?: RealtimeSessionConfig, options?: RealtimeConnectOptions): Promise<RealtimeTokenResult>;
|
|
419
|
+
}
|
|
267
420
|
export interface GroundedLanguageModel<TProviderOptions extends ProviderOptions = ProviderOptions> {
|
|
268
421
|
readonly provider: string;
|
|
269
422
|
readonly modelId: string;
|
|
270
423
|
readonly capabilities: ModelCapabilities;
|
|
271
424
|
generate(input: GroundedModelGenerateInput<TProviderOptions>): Promise<GroundedGenerateResult>;
|
|
272
425
|
}
|
|
273
|
-
export type AgentModel<TProviderOptions extends ProviderOptions = ProviderOptions> = LanguageModel<TProviderOptions> | GroundedLanguageModel<TProviderOptions>;
|
|
274
426
|
export interface EmbeddingModel {
|
|
275
427
|
readonly provider: string;
|
|
276
428
|
readonly modelId: string;
|
|
@@ -283,6 +435,7 @@ export interface ProviderAdapter {
|
|
|
283
435
|
embeddingModel?: (modelId: string) => EmbeddingModel;
|
|
284
436
|
transcriptionModel?: (modelId: string) => TranscriptionModel;
|
|
285
437
|
speechModel?: (modelId: string) => SpeechModel;
|
|
438
|
+
realtimeModel?: (modelId: string) => RealtimeModel;
|
|
286
439
|
groundedLanguageModel?: (modelId: string) => GroundedLanguageModel;
|
|
287
440
|
}
|
|
288
441
|
export type CallableProviderAdapter = ProviderAdapter & ((modelId: string) => LanguageModel);
|
|
@@ -290,18 +443,59 @@ export interface ToolDefinition<TSchema extends ZodTypeAny = ZodTypeAny, TResult
|
|
|
290
443
|
name: string;
|
|
291
444
|
description?: string;
|
|
292
445
|
schema: TSchema;
|
|
446
|
+
metadata?: Record<string, JsonValue>;
|
|
447
|
+
requiresApproval?: boolean;
|
|
448
|
+
execute: (input: z.infer<TSchema>) => Promise<TResult> | TResult;
|
|
449
|
+
}
|
|
450
|
+
export type HostedToolClass = "web-search" | "file-search" | "remote-mcp" | "computer-use" | "code-execution" | "toolset" | "custom";
|
|
451
|
+
export interface HostedToolDefinition<TConfig extends JsonValue = JsonValue> {
|
|
452
|
+
kind: "hosted";
|
|
453
|
+
name: string;
|
|
454
|
+
provider?: string;
|
|
455
|
+
type: string;
|
|
456
|
+
config?: TConfig;
|
|
457
|
+
toolClass?: HostedToolClass;
|
|
293
458
|
requiresApproval?: boolean;
|
|
294
|
-
|
|
295
|
-
|
|
459
|
+
metadata?: Record<string, JsonValue>;
|
|
460
|
+
}
|
|
461
|
+
export type AnyToolDefinition = ToolDefinition | HostedToolDefinition;
|
|
462
|
+
export type ToolSet = Record<string, AnyToolDefinition>;
|
|
463
|
+
export interface ToolRegistryLike {
|
|
464
|
+
get(name: string): AnyToolDefinition | undefined;
|
|
465
|
+
has(name: string): boolean;
|
|
466
|
+
entries(): Iterable<[string, AnyToolDefinition]>;
|
|
467
|
+
toToolSet(): ToolSet;
|
|
468
|
+
}
|
|
469
|
+
export type ToolCollection = ToolSet | ToolRegistryLike;
|
|
470
|
+
export interface ToolApprovalRequest {
|
|
471
|
+
toolCall: ToolCall;
|
|
472
|
+
tool: ToolDefinition;
|
|
473
|
+
input: JsonValue;
|
|
474
|
+
step: number;
|
|
475
|
+
model: LanguageModel | RealtimeModel;
|
|
476
|
+
request?: ModelGenerateInput;
|
|
477
|
+
realtimeConfig?: RealtimeSessionConfig;
|
|
478
|
+
}
|
|
479
|
+
export interface ToolApprovalDecision {
|
|
480
|
+
approved: boolean;
|
|
481
|
+
reason?: string;
|
|
482
|
+
metadata?: Record<string, JsonValue>;
|
|
483
|
+
}
|
|
484
|
+
export interface ToolApprovalEvent {
|
|
485
|
+
request: ToolApprovalRequest;
|
|
486
|
+
decision: ToolApprovalDecision;
|
|
296
487
|
}
|
|
297
|
-
export type
|
|
488
|
+
export type ToolApprovalPolicy = (request: ToolApprovalRequest) => ToolApprovalDecision | boolean | Promise<ToolApprovalDecision | boolean>;
|
|
489
|
+
export type ToolApprovalObserver = (event: ToolApprovalEvent) => void | Promise<void>;
|
|
298
490
|
export type ProviderOptionsOf<TModel extends LanguageModel> = TModel extends LanguageModel<infer TProviderOptions> ? TProviderOptions : ProviderOptions;
|
|
299
491
|
export type GenerateTextOptions<TModel extends LanguageModel = LanguageModel> = RetryOptions & GenerateInputSource & {
|
|
300
492
|
model: TModel;
|
|
301
493
|
system?: string;
|
|
302
|
-
tools?:
|
|
494
|
+
tools?: ToolCollection;
|
|
303
495
|
toolChoice?: ToolChoice;
|
|
304
496
|
toolExecution?: ToolExecutionOptions;
|
|
497
|
+
toolApprovalPolicy?: ToolApprovalPolicy;
|
|
498
|
+
onToolApprovalDecision?: ToolApprovalObserver;
|
|
305
499
|
maxSteps?: number;
|
|
306
500
|
temperature?: number;
|
|
307
501
|
maxTokens?: number;
|
|
@@ -322,6 +516,336 @@ export interface GenerateTextOutput {
|
|
|
322
516
|
messages: ModelMessage[];
|
|
323
517
|
toolResults: ToolExecutionResult[];
|
|
324
518
|
}
|
|
519
|
+
export type AgentStatus = "running" | "completed" | "suspended" | "failed" | "cancelled";
|
|
520
|
+
export type AgentStepStatus = "running" | "completed" | "suspended" | "failed";
|
|
521
|
+
export interface AgentStepRequest {
|
|
522
|
+
messages: ModelMessage[];
|
|
523
|
+
toolChoice?: ToolChoice;
|
|
524
|
+
toolExecution?: ToolExecutionOptions;
|
|
525
|
+
temperature?: number;
|
|
526
|
+
maxTokens?: number;
|
|
527
|
+
reasoning?: ReasoningConfig;
|
|
528
|
+
providerOptions?: ProviderOptions;
|
|
529
|
+
timeoutMs?: number;
|
|
530
|
+
maxRetries?: number;
|
|
531
|
+
retryBackoffMs?: number;
|
|
532
|
+
}
|
|
533
|
+
export interface AgentStepResponse {
|
|
534
|
+
messages: ModelMessage[];
|
|
535
|
+
text?: string;
|
|
536
|
+
finishReason?: FinishReason;
|
|
537
|
+
providerFinishReason?: string;
|
|
538
|
+
usage?: TokenUsage;
|
|
539
|
+
}
|
|
540
|
+
export interface AgentStep {
|
|
541
|
+
index: number;
|
|
542
|
+
status: AgentStepStatus;
|
|
543
|
+
startedAt?: number;
|
|
544
|
+
finishedAt?: number;
|
|
545
|
+
request: AgentStepRequest;
|
|
546
|
+
response?: AgentStepResponse;
|
|
547
|
+
toolResults: ToolExecutionResult[];
|
|
548
|
+
error?: {
|
|
549
|
+
message: string;
|
|
550
|
+
};
|
|
551
|
+
}
|
|
552
|
+
export interface AgentRunState {
|
|
553
|
+
runId: string;
|
|
554
|
+
agentId?: string;
|
|
555
|
+
parentRunId?: string;
|
|
556
|
+
provider: string;
|
|
557
|
+
modelId: string;
|
|
558
|
+
status: AgentStatus;
|
|
559
|
+
messages: ModelMessage[];
|
|
560
|
+
steps: AgentStep[];
|
|
561
|
+
toolResults: ToolExecutionResult[];
|
|
562
|
+
currentStep: number;
|
|
563
|
+
maxSteps: number;
|
|
564
|
+
outputText: string;
|
|
565
|
+
finishReason?: FinishReason;
|
|
566
|
+
providerFinishReason?: string;
|
|
567
|
+
usage?: TokenUsage;
|
|
568
|
+
pendingApprovals: AgentApprovalRequest[];
|
|
569
|
+
metadata?: Record<string, JsonValue>;
|
|
570
|
+
handoff?: AgentHandoff;
|
|
571
|
+
startedAt?: number;
|
|
572
|
+
updatedAt?: number;
|
|
573
|
+
error?: {
|
|
574
|
+
message: string;
|
|
575
|
+
};
|
|
576
|
+
}
|
|
577
|
+
export interface AgentRunStore {
|
|
578
|
+
load(runId: string): Promise<AgentRunState | undefined> | AgentRunState | undefined;
|
|
579
|
+
save(state: AgentRunState): Promise<void> | void;
|
|
580
|
+
delete?(runId: string): Promise<void> | void;
|
|
581
|
+
}
|
|
582
|
+
export interface AgentMemoryContext {
|
|
583
|
+
runId: string;
|
|
584
|
+
agentId?: string;
|
|
585
|
+
state?: AgentRunState;
|
|
586
|
+
metadata?: Record<string, JsonValue>;
|
|
587
|
+
}
|
|
588
|
+
export interface AgentMemoryStore {
|
|
589
|
+
load(context: AgentMemoryContext): Promise<ModelMessage[]> | ModelMessage[];
|
|
590
|
+
save?(context: AgentMemoryContext & {
|
|
591
|
+
state: AgentRunState;
|
|
592
|
+
}): Promise<void> | void;
|
|
593
|
+
}
|
|
594
|
+
export interface SqliteStatementLike<TResult extends Record<string, unknown> = Record<string, unknown>> {
|
|
595
|
+
run(params?: readonly unknown[] | Record<string, unknown>): unknown;
|
|
596
|
+
get(params?: readonly unknown[] | Record<string, unknown>): TResult | undefined;
|
|
597
|
+
}
|
|
598
|
+
export interface SqliteDatabaseLike {
|
|
599
|
+
exec(sql: string): unknown;
|
|
600
|
+
prepare?<TResult extends Record<string, unknown> = Record<string, unknown>>(sql: string): SqliteStatementLike<TResult>;
|
|
601
|
+
query?<TResult extends Record<string, unknown> = Record<string, unknown>>(sql: string): SqliteStatementLike<TResult>;
|
|
602
|
+
}
|
|
603
|
+
export interface SqliteAgentRunStoreOptions {
|
|
604
|
+
db: SqliteDatabaseLike;
|
|
605
|
+
tableName?: string;
|
|
606
|
+
}
|
|
607
|
+
export interface SqliteAgentMemoryStoreOptions {
|
|
608
|
+
db: SqliteDatabaseLike;
|
|
609
|
+
tableName?: string;
|
|
610
|
+
key?: (context: AgentMemoryContext) => string;
|
|
611
|
+
selectMessages?: (state: AgentRunState) => ModelMessage[];
|
|
612
|
+
}
|
|
613
|
+
export interface PostgresQueryResultLike<TResult extends Record<string, unknown> = Record<string, unknown>> {
|
|
614
|
+
rows: TResult[];
|
|
615
|
+
}
|
|
616
|
+
export interface PostgresClientLike {
|
|
617
|
+
query<TResult extends Record<string, unknown> = Record<string, unknown>>(sql: string, params?: readonly unknown[]): Promise<PostgresQueryResultLike<TResult>> | PostgresQueryResultLike<TResult>;
|
|
618
|
+
}
|
|
619
|
+
export interface PostgresAgentRunStoreOptions {
|
|
620
|
+
client: PostgresClientLike;
|
|
621
|
+
tableName?: string;
|
|
622
|
+
}
|
|
623
|
+
export interface PostgresAgentMemoryStoreOptions {
|
|
624
|
+
client: PostgresClientLike;
|
|
625
|
+
tableName?: string;
|
|
626
|
+
key?: (context: AgentMemoryContext) => string;
|
|
627
|
+
selectMessages?: (state: AgentRunState) => ModelMessage[];
|
|
628
|
+
}
|
|
629
|
+
export interface AgentHandoff {
|
|
630
|
+
id: string;
|
|
631
|
+
fromRunId: string;
|
|
632
|
+
fromAgentId?: string;
|
|
633
|
+
toAgentId?: string;
|
|
634
|
+
summary: string;
|
|
635
|
+
contextMessages: ModelMessage[];
|
|
636
|
+
metadata?: Record<string, JsonValue>;
|
|
637
|
+
}
|
|
638
|
+
export interface AgentTelemetryRunStartEvent {
|
|
639
|
+
type: "run-start";
|
|
640
|
+
runId: string;
|
|
641
|
+
agentId?: string;
|
|
642
|
+
provider: string;
|
|
643
|
+
modelId: string;
|
|
644
|
+
maxSteps: number;
|
|
645
|
+
}
|
|
646
|
+
export interface AgentTelemetryStepStartEvent {
|
|
647
|
+
type: "step-start";
|
|
648
|
+
runId: string;
|
|
649
|
+
agentId?: string;
|
|
650
|
+
stepIndex: number;
|
|
651
|
+
}
|
|
652
|
+
export interface AgentTelemetryStepFinishEvent {
|
|
653
|
+
type: "step-finish";
|
|
654
|
+
runId: string;
|
|
655
|
+
agentId?: string;
|
|
656
|
+
step: AgentStep;
|
|
657
|
+
}
|
|
658
|
+
export interface AgentTelemetryApprovalRequestEvent {
|
|
659
|
+
type: "approval-request";
|
|
660
|
+
runId: string;
|
|
661
|
+
agentId?: string;
|
|
662
|
+
approval: AgentApprovalRequest;
|
|
663
|
+
}
|
|
664
|
+
export interface AgentTelemetryApprovalResolvedEvent {
|
|
665
|
+
type: "approval-resolved";
|
|
666
|
+
runId: string;
|
|
667
|
+
agentId?: string;
|
|
668
|
+
approval: AgentApprovalResponse;
|
|
669
|
+
}
|
|
670
|
+
export interface AgentTelemetryToolApprovalEvent {
|
|
671
|
+
type: "tool-approval";
|
|
672
|
+
runId: string;
|
|
673
|
+
agentId?: string;
|
|
674
|
+
toolCall: ToolCall;
|
|
675
|
+
approved: boolean;
|
|
676
|
+
reason?: string;
|
|
677
|
+
metadata?: Record<string, JsonValue>;
|
|
678
|
+
}
|
|
679
|
+
export interface AgentTelemetryMemoryLoadedEvent {
|
|
680
|
+
type: "memory-loaded";
|
|
681
|
+
runId: string;
|
|
682
|
+
agentId?: string;
|
|
683
|
+
messageCount: number;
|
|
684
|
+
}
|
|
685
|
+
export interface AgentGuardrailTrigger {
|
|
686
|
+
triggered: true;
|
|
687
|
+
reason?: string;
|
|
688
|
+
metadata?: Record<string, JsonValue>;
|
|
689
|
+
}
|
|
690
|
+
export interface AgentInputGuardrailRequest {
|
|
691
|
+
runId: string;
|
|
692
|
+
agentId?: string;
|
|
693
|
+
messages: ModelMessage[];
|
|
694
|
+
metadata?: Record<string, JsonValue>;
|
|
695
|
+
}
|
|
696
|
+
export interface AgentOutputGuardrailRequest {
|
|
697
|
+
runId: string;
|
|
698
|
+
agentId?: string;
|
|
699
|
+
state: AgentRunState;
|
|
700
|
+
output: AgentRunOutput | LiveAgentRunOutput;
|
|
701
|
+
metadata?: Record<string, JsonValue>;
|
|
702
|
+
}
|
|
703
|
+
export type AgentInputGuardrail = (request: AgentInputGuardrailRequest) => AgentGuardrailTrigger | void | Promise<AgentGuardrailTrigger | void>;
|
|
704
|
+
export type AgentOutputGuardrail = (request: AgentOutputGuardrailRequest) => AgentGuardrailTrigger | void | Promise<AgentGuardrailTrigger | void>;
|
|
705
|
+
export interface AgentTelemetryGuardrailTriggeredEvent {
|
|
706
|
+
type: "guardrail-triggered";
|
|
707
|
+
runId: string;
|
|
708
|
+
agentId?: string;
|
|
709
|
+
stage: "input" | "output";
|
|
710
|
+
reason?: string;
|
|
711
|
+
metadata?: Record<string, JsonValue>;
|
|
712
|
+
}
|
|
713
|
+
export interface AgentTelemetryStateSavedEvent {
|
|
714
|
+
type: "state-saved";
|
|
715
|
+
runId: string;
|
|
716
|
+
agentId?: string;
|
|
717
|
+
status: AgentStatus;
|
|
718
|
+
}
|
|
719
|
+
export interface AgentTelemetryHandoffEvent {
|
|
720
|
+
type: "handoff";
|
|
721
|
+
runId: string;
|
|
722
|
+
agentId?: string;
|
|
723
|
+
handoff: AgentHandoff;
|
|
724
|
+
}
|
|
725
|
+
export interface AgentTelemetryRunFinishEvent {
|
|
726
|
+
type: "run-finish";
|
|
727
|
+
runId: string;
|
|
728
|
+
agentId?: string;
|
|
729
|
+
status: AgentStatus;
|
|
730
|
+
state: AgentRunState;
|
|
731
|
+
}
|
|
732
|
+
export type AgentTelemetryEvent = AgentTelemetryRunStartEvent | AgentTelemetryStepStartEvent | AgentTelemetryStepFinishEvent | AgentTelemetryApprovalRequestEvent | AgentTelemetryApprovalResolvedEvent | AgentTelemetryToolApprovalEvent | AgentTelemetryMemoryLoadedEvent | AgentTelemetryGuardrailTriggeredEvent | AgentTelemetryStateSavedEvent | AgentTelemetryHandoffEvent | AgentTelemetryRunFinishEvent;
|
|
733
|
+
export type AgentTelemetryObserver = (event: AgentTelemetryEvent) => void | Promise<void>;
|
|
734
|
+
export interface AgentDefinition<TModel extends LanguageModel = LanguageModel> {
|
|
735
|
+
id?: string;
|
|
736
|
+
model: TModel;
|
|
737
|
+
instructions?: string;
|
|
738
|
+
tools?: ToolCollection;
|
|
739
|
+
maxSteps?: number;
|
|
740
|
+
temperature?: number;
|
|
741
|
+
maxTokens?: number;
|
|
742
|
+
reasoning?: ReasoningConfig;
|
|
743
|
+
toolExecution?: ToolExecutionOptions;
|
|
744
|
+
toolApprovalPolicy?: ToolApprovalPolicy;
|
|
745
|
+
inputGuardrails?: AgentInputGuardrail[];
|
|
746
|
+
outputGuardrails?: AgentOutputGuardrail[];
|
|
747
|
+
providerOptions?: ProviderOptionsOf<TModel>;
|
|
748
|
+
metadata?: Record<string, JsonValue>;
|
|
749
|
+
store?: AgentRunStore;
|
|
750
|
+
memory?: AgentMemoryStore;
|
|
751
|
+
onTelemetryEvent?: AgentTelemetryObserver;
|
|
752
|
+
}
|
|
753
|
+
export interface LiveAgentDefinition<TModel extends RealtimeModel = RealtimeModel> {
|
|
754
|
+
id?: string;
|
|
755
|
+
model: TModel;
|
|
756
|
+
instructions?: string;
|
|
757
|
+
tools?: ToolCollection;
|
|
758
|
+
toolChoice?: ToolChoice;
|
|
759
|
+
toolExecution?: ToolExecutionOptions;
|
|
760
|
+
toolApprovalPolicy?: ToolApprovalPolicy;
|
|
761
|
+
inputGuardrails?: AgentInputGuardrail[];
|
|
762
|
+
outputGuardrails?: AgentOutputGuardrail[];
|
|
763
|
+
providerOptions?: ProviderOptions;
|
|
764
|
+
metadata?: Record<string, JsonValue>;
|
|
765
|
+
store?: AgentRunStore;
|
|
766
|
+
memory?: AgentMemoryStore;
|
|
767
|
+
onTelemetryEvent?: AgentTelemetryObserver;
|
|
768
|
+
}
|
|
769
|
+
export interface AgentApprovalRequest {
|
|
770
|
+
provider: string;
|
|
771
|
+
id: string;
|
|
772
|
+
name: string;
|
|
773
|
+
arguments: string;
|
|
774
|
+
serverLabel?: string;
|
|
775
|
+
rawData: JsonValue;
|
|
776
|
+
}
|
|
777
|
+
export interface AgentApprovalResponse {
|
|
778
|
+
provider: string;
|
|
779
|
+
approvalRequestId: string;
|
|
780
|
+
approve: boolean;
|
|
781
|
+
id?: string;
|
|
782
|
+
reason?: string;
|
|
783
|
+
}
|
|
784
|
+
export type AgentRunInput<TModel extends LanguageModel = LanguageModel> = RetryOptions & GenerateInputSource & {
|
|
785
|
+
runId?: string;
|
|
786
|
+
state?: AgentRunState;
|
|
787
|
+
approvals?: AgentApprovalResponse[];
|
|
788
|
+
handoff?: AgentHandoff;
|
|
789
|
+
system?: string;
|
|
790
|
+
tools?: ToolCollection;
|
|
791
|
+
toolChoice?: ToolChoice;
|
|
792
|
+
toolExecution?: ToolExecutionOptions;
|
|
793
|
+
toolApprovalPolicy?: ToolApprovalPolicy;
|
|
794
|
+
maxSteps?: number;
|
|
795
|
+
temperature?: number;
|
|
796
|
+
maxTokens?: number;
|
|
797
|
+
reasoning?: ReasoningConfig;
|
|
798
|
+
providerOptions?: ProviderOptionsOf<TModel>;
|
|
799
|
+
metadata?: Record<string, JsonValue>;
|
|
800
|
+
};
|
|
801
|
+
export interface AgentRunOutput {
|
|
802
|
+
status: AgentStatus;
|
|
803
|
+
outputText: string;
|
|
804
|
+
finishReason?: FinishReason;
|
|
805
|
+
providerFinishReason?: string;
|
|
806
|
+
usage?: TokenUsage;
|
|
807
|
+
messages: ModelMessage[];
|
|
808
|
+
steps: AgentStep[];
|
|
809
|
+
toolResults: ToolExecutionResult[];
|
|
810
|
+
state: AgentRunState;
|
|
811
|
+
error?: {
|
|
812
|
+
message: string;
|
|
813
|
+
};
|
|
814
|
+
}
|
|
815
|
+
export type LiveAgentRunInput = GenerateInputSource & RetryOptions & {
|
|
816
|
+
runId?: string;
|
|
817
|
+
system?: string;
|
|
818
|
+
tools?: ToolCollection;
|
|
819
|
+
toolChoice?: ToolChoice;
|
|
820
|
+
toolExecution?: ToolExecutionOptions;
|
|
821
|
+
toolApprovalPolicy?: ToolApprovalPolicy;
|
|
822
|
+
providerOptions?: ProviderOptions;
|
|
823
|
+
metadata?: Record<string, JsonValue>;
|
|
824
|
+
realtime?: RealtimeSessionConfig;
|
|
825
|
+
connectOptions?: RealtimeConnectOptions;
|
|
826
|
+
};
|
|
827
|
+
export interface LiveAgentRunOutput {
|
|
828
|
+
status: AgentStatus;
|
|
829
|
+
outputText: string;
|
|
830
|
+
messages: ModelMessage[];
|
|
831
|
+
toolResults: ToolExecutionResult[];
|
|
832
|
+
state: AgentRunState;
|
|
833
|
+
error?: {
|
|
834
|
+
message: string;
|
|
835
|
+
};
|
|
836
|
+
}
|
|
837
|
+
export interface AgentStreamResult {
|
|
838
|
+
eventStream: AsyncIterable<AgentStreamEvent>;
|
|
839
|
+
textStream: AsyncIterable<string>;
|
|
840
|
+
collect: () => Promise<AgentRunOutput>;
|
|
841
|
+
}
|
|
842
|
+
export type AgentLiveEvent = AgentStreamEvent | RealtimeEvent;
|
|
843
|
+
export interface AgentLiveStreamResult {
|
|
844
|
+
eventStream: AsyncIterable<AgentLiveEvent>;
|
|
845
|
+
textStream: AsyncIterable<string>;
|
|
846
|
+
session: Promise<RealtimeSession>;
|
|
847
|
+
collect: () => Promise<LiveAgentRunOutput>;
|
|
848
|
+
}
|
|
325
849
|
export type TranscribeAudioOptions<TModel extends TranscriptionModel = TranscriptionModel> = RetryOptions & {
|
|
326
850
|
model: TModel;
|
|
327
851
|
audio: AudioInput;
|
|
@@ -500,6 +1024,13 @@ export interface UIMessageToolResultChunk {
|
|
|
500
1024
|
role: "tool";
|
|
501
1025
|
toolResult: ToolExecutionResult;
|
|
502
1026
|
}
|
|
1027
|
+
export interface UIMessageProviderDataChunk {
|
|
1028
|
+
type: "provider-data";
|
|
1029
|
+
messageId: string;
|
|
1030
|
+
role: "assistant";
|
|
1031
|
+
provider: string;
|
|
1032
|
+
data: JsonValue;
|
|
1033
|
+
}
|
|
503
1034
|
export interface UIMessageFinishChunk {
|
|
504
1035
|
type: "finish";
|
|
505
1036
|
messageId: string;
|
|
@@ -514,7 +1045,33 @@ export interface UIMessageErrorChunk {
|
|
|
514
1045
|
message: string;
|
|
515
1046
|
};
|
|
516
1047
|
}
|
|
517
|
-
export
|
|
1048
|
+
export interface UIAgentRunStartChunk {
|
|
1049
|
+
type: "agent-run-start";
|
|
1050
|
+
currentStep: number;
|
|
1051
|
+
maxSteps: number;
|
|
1052
|
+
}
|
|
1053
|
+
export interface UIAgentStepStartChunk {
|
|
1054
|
+
type: "agent-step-start";
|
|
1055
|
+
stepIndex: number;
|
|
1056
|
+
}
|
|
1057
|
+
export interface UIAgentStepFinishChunk {
|
|
1058
|
+
type: "agent-step-finish";
|
|
1059
|
+
step: AgentStep;
|
|
1060
|
+
}
|
|
1061
|
+
export interface UIAgentApprovalRequestChunk {
|
|
1062
|
+
type: "agent-approval-request";
|
|
1063
|
+
approval: AgentApprovalRequest;
|
|
1064
|
+
}
|
|
1065
|
+
export interface UIAgentApprovalResolvedChunk {
|
|
1066
|
+
type: "agent-approval-resolved";
|
|
1067
|
+
approval: AgentApprovalResponse;
|
|
1068
|
+
}
|
|
1069
|
+
export interface UIAgentRunFinishChunk {
|
|
1070
|
+
type: "agent-run-finish";
|
|
1071
|
+
status: AgentStatus;
|
|
1072
|
+
state: AgentRunState;
|
|
1073
|
+
}
|
|
1074
|
+
export type UIMessageChunk = UIMessageTextChunk | UIMessageToolCallChunk | UIMessageToolResultChunk | UIMessageProviderDataChunk | UIMessageFinishChunk | UIMessageErrorChunk | UIAgentRunStartChunk | UIAgentStepStartChunk | UIAgentStepFinishChunk | UIAgentApprovalRequestChunk | UIAgentApprovalResolvedChunk | UIAgentRunFinishChunk;
|
|
518
1075
|
export interface EmbedInput {
|
|
519
1076
|
values: string[];
|
|
520
1077
|
}
|
|
@@ -525,466 +1082,4 @@ export interface EmbedOptions extends RetryOptions {
|
|
|
525
1082
|
export interface EmbedOutput extends EmbedResult {
|
|
526
1083
|
values: string[];
|
|
527
1084
|
}
|
|
528
|
-
export type AgentRunStatus = "queued" | "running" | "paused" | "waiting-approval" | "delegating" | "handed-off" | "completed" | "failed" | "canceled";
|
|
529
|
-
export type AgentStepType = "chat" | "plan" | "act" | "summarize" | "grounded";
|
|
530
|
-
export type AgentApprovalKind = "tool" | "delegate" | "handoff";
|
|
531
|
-
export type MemoryRecordKind = "note" | "summary" | "fact" | "result";
|
|
532
|
-
export interface AgentBudget {
|
|
533
|
-
maxSteps?: number;
|
|
534
|
-
maxDepth?: number;
|
|
535
|
-
maxParallelDelegations?: number;
|
|
536
|
-
maxTokens?: number;
|
|
537
|
-
maxToolCalls?: number;
|
|
538
|
-
deadline?: number;
|
|
539
|
-
}
|
|
540
|
-
export interface MemoryRecord {
|
|
541
|
-
id: string;
|
|
542
|
-
sessionId?: string;
|
|
543
|
-
agentName?: string;
|
|
544
|
-
kind: MemoryRecordKind;
|
|
545
|
-
content: string;
|
|
546
|
-
metadata?: Record<string, unknown>;
|
|
547
|
-
createdAt: number;
|
|
548
|
-
updatedAt?: number;
|
|
549
|
-
}
|
|
550
|
-
export interface MemoryQuery {
|
|
551
|
-
sessionId?: string;
|
|
552
|
-
agentName?: string;
|
|
553
|
-
query?: string;
|
|
554
|
-
limit?: number;
|
|
555
|
-
kinds?: MemoryRecordKind[];
|
|
556
|
-
metadata?: Record<string, unknown>;
|
|
557
|
-
}
|
|
558
|
-
export interface MemoryStore {
|
|
559
|
-
search(query: MemoryQuery): Promise<MemoryRecord[]> | MemoryRecord[];
|
|
560
|
-
put(records: MemoryRecord | MemoryRecord[]): Promise<void> | void;
|
|
561
|
-
get?(id: string): Promise<MemoryRecord | undefined> | MemoryRecord | undefined;
|
|
562
|
-
delete?(id: string): Promise<void> | void;
|
|
563
|
-
}
|
|
564
|
-
export interface AgentMemoryConfig {
|
|
565
|
-
enabled?: boolean;
|
|
566
|
-
maxMessages?: number;
|
|
567
|
-
maxResults?: number;
|
|
568
|
-
summaryPrefix?: string;
|
|
569
|
-
}
|
|
570
|
-
export interface AgentApprovalPolicy {
|
|
571
|
-
requireApproval?: AgentApprovalKind[];
|
|
572
|
-
toolNames?: string[];
|
|
573
|
-
delegateAgents?: string[];
|
|
574
|
-
handoffAgents?: string[];
|
|
575
|
-
}
|
|
576
|
-
export interface AgentToolPolicy {
|
|
577
|
-
allowedToolNames?: string[];
|
|
578
|
-
blockedToolNames?: string[];
|
|
579
|
-
allowedScopes?: string[];
|
|
580
|
-
requiredTags?: string[];
|
|
581
|
-
maxSideEffect?: ToolSideEffectLevel;
|
|
582
|
-
allowedSandboxLevels?: ToolSandboxLevel[];
|
|
583
|
-
}
|
|
584
|
-
export interface ApprovalRecord {
|
|
585
|
-
id: string;
|
|
586
|
-
requestId: string;
|
|
587
|
-
runId: string;
|
|
588
|
-
sessionId: string;
|
|
589
|
-
agentName: string;
|
|
590
|
-
step: number;
|
|
591
|
-
kind: AgentApprovalKind;
|
|
592
|
-
status: "approved" | "rejected" | "edited" | "pending";
|
|
593
|
-
toolName?: string;
|
|
594
|
-
targetAgent?: string;
|
|
595
|
-
input: JsonValue;
|
|
596
|
-
approvedInput?: JsonValue;
|
|
597
|
-
reason?: string;
|
|
598
|
-
createdAt: number;
|
|
599
|
-
decidedAt?: number;
|
|
600
|
-
}
|
|
601
|
-
export interface AgentModelUsageSummary {
|
|
602
|
-
provider: string;
|
|
603
|
-
modelId: string;
|
|
604
|
-
inputTokens: number;
|
|
605
|
-
outputTokens: number;
|
|
606
|
-
totalTokens: number;
|
|
607
|
-
estimatedCostUsd?: number;
|
|
608
|
-
}
|
|
609
|
-
export interface AgentRunMetrics {
|
|
610
|
-
startedAt: number;
|
|
611
|
-
finishedAt?: number;
|
|
612
|
-
durationMs: number;
|
|
613
|
-
stepCount: number;
|
|
614
|
-
toolCallCount: number;
|
|
615
|
-
toolResultCount: number;
|
|
616
|
-
toolErrorCount: number;
|
|
617
|
-
approvalCount: number;
|
|
618
|
-
approvalPendingCount: number;
|
|
619
|
-
delegateCount: number;
|
|
620
|
-
handoffCount: number;
|
|
621
|
-
inputTokens: number;
|
|
622
|
-
outputTokens: number;
|
|
623
|
-
totalTokens: number;
|
|
624
|
-
estimatedCostUsd?: number;
|
|
625
|
-
models: AgentModelUsageSummary[];
|
|
626
|
-
}
|
|
627
|
-
export interface AgentSession {
|
|
628
|
-
id: string;
|
|
629
|
-
schemaVersion?: number;
|
|
630
|
-
status: AgentRunStatus;
|
|
631
|
-
ownerAgentName: string;
|
|
632
|
-
messages: ModelMessage[];
|
|
633
|
-
summary?: string;
|
|
634
|
-
metadata?: Record<string, unknown>;
|
|
635
|
-
activeAgentStack: string[];
|
|
636
|
-
runIds: string[];
|
|
637
|
-
toolResults: ToolExecutionResult[];
|
|
638
|
-
approvalHistory: ApprovalRecord[];
|
|
639
|
-
lastRunMetrics?: AgentRunMetrics;
|
|
640
|
-
createdAt: number;
|
|
641
|
-
updatedAt: number;
|
|
642
|
-
}
|
|
643
|
-
export interface AgentStepRoute {
|
|
644
|
-
stepType?: AgentStepType;
|
|
645
|
-
model?: AgentModel;
|
|
646
|
-
useWebSearch?: boolean;
|
|
647
|
-
reasoning?: ReasoningConfig;
|
|
648
|
-
}
|
|
649
|
-
export interface AgentStepRouterContext {
|
|
650
|
-
agent: AgentDefinition;
|
|
651
|
-
session: AgentSession;
|
|
652
|
-
step: number;
|
|
653
|
-
defaultStepType: AgentStepType;
|
|
654
|
-
budget: AgentBudget;
|
|
655
|
-
lastToolResults: ToolExecutionResult[];
|
|
656
|
-
metadata?: Record<string, unknown>;
|
|
657
|
-
}
|
|
658
|
-
export interface AgentStepRouter {
|
|
659
|
-
(context: AgentStepRouterContext): Promise<AgentStepRoute> | AgentStepRoute;
|
|
660
|
-
}
|
|
661
|
-
export interface AgentDefaults {
|
|
662
|
-
temperature?: number;
|
|
663
|
-
maxTokens?: number;
|
|
664
|
-
maxSteps?: number;
|
|
665
|
-
reasoning?: ReasoningConfig;
|
|
666
|
-
toolChoice?: ToolChoice;
|
|
667
|
-
toolExecution?: ToolExecutionOptions;
|
|
668
|
-
}
|
|
669
|
-
export interface AgentDefinition {
|
|
670
|
-
name: string;
|
|
671
|
-
instructions: string;
|
|
672
|
-
model: AgentModel;
|
|
673
|
-
tools?: ToolSet;
|
|
674
|
-
defaults?: AgentDefaults;
|
|
675
|
-
memory?: AgentMemoryConfig;
|
|
676
|
-
delegates?: string[];
|
|
677
|
-
handoffs?: string[];
|
|
678
|
-
approvalPolicy?: AgentApprovalPolicy;
|
|
679
|
-
toolPolicy?: AgentToolPolicy;
|
|
680
|
-
stepRouter?: AgentStepRouter;
|
|
681
|
-
outputSchema?: StructuredOutputConfig;
|
|
682
|
-
metadata?: Record<string, unknown>;
|
|
683
|
-
}
|
|
684
|
-
export interface AgentRegistry {
|
|
685
|
-
register(agent: AgentDefinition): void;
|
|
686
|
-
get(name: string): AgentDefinition | undefined;
|
|
687
|
-
list(): AgentDefinition[];
|
|
688
|
-
}
|
|
689
|
-
export type AgentInputSource = {
|
|
690
|
-
prompt: string;
|
|
691
|
-
messages?: never;
|
|
692
|
-
} | {
|
|
693
|
-
prompt?: never;
|
|
694
|
-
messages: ModelMessage[];
|
|
695
|
-
} | {
|
|
696
|
-
prompt?: undefined;
|
|
697
|
-
messages?: undefined;
|
|
698
|
-
};
|
|
699
|
-
export interface ApprovalRequest {
|
|
700
|
-
id: string;
|
|
701
|
-
runId: string;
|
|
702
|
-
sessionId: string;
|
|
703
|
-
agentName: string;
|
|
704
|
-
step: number;
|
|
705
|
-
kind: AgentApprovalKind;
|
|
706
|
-
toolName?: string;
|
|
707
|
-
targetAgent?: string;
|
|
708
|
-
input: JsonValue;
|
|
709
|
-
metadata?: Record<string, unknown>;
|
|
710
|
-
createdAt: number;
|
|
711
|
-
}
|
|
712
|
-
export type ApprovalDecision = {
|
|
713
|
-
type: "approve";
|
|
714
|
-
input?: JsonValue;
|
|
715
|
-
reason?: string;
|
|
716
|
-
} | {
|
|
717
|
-
type: "reject";
|
|
718
|
-
reason?: string;
|
|
719
|
-
} | {
|
|
720
|
-
type: "edit-input";
|
|
721
|
-
input: JsonValue;
|
|
722
|
-
reason?: string;
|
|
723
|
-
};
|
|
724
|
-
export interface AgentPendingAction {
|
|
725
|
-
kind: AgentApprovalKind;
|
|
726
|
-
step: number;
|
|
727
|
-
stepType: AgentStepType;
|
|
728
|
-
toolCalls: ToolCall[];
|
|
729
|
-
nextToolCallIndex: number;
|
|
730
|
-
pendingToolResults: ToolExecutionResult[];
|
|
731
|
-
requestMessages: ModelMessage[];
|
|
732
|
-
approvalRequest: ApprovalRequest;
|
|
733
|
-
}
|
|
734
|
-
export interface AgentCheckpoint {
|
|
735
|
-
id: string;
|
|
736
|
-
schemaVersion?: number;
|
|
737
|
-
runId: string;
|
|
738
|
-
sessionId: string;
|
|
739
|
-
agentName: string;
|
|
740
|
-
status: AgentRunStatus;
|
|
741
|
-
step: number;
|
|
742
|
-
session: AgentSession;
|
|
743
|
-
steps: AgentRunStep[];
|
|
744
|
-
pendingApproval?: ApprovalRequest;
|
|
745
|
-
pendingAction?: AgentPendingAction;
|
|
746
|
-
metrics?: AgentRunMetrics;
|
|
747
|
-
metadata?: Record<string, unknown>;
|
|
748
|
-
createdAt: number;
|
|
749
|
-
}
|
|
750
|
-
export interface SessionStore {
|
|
751
|
-
get(id: string): Promise<AgentSession | undefined> | AgentSession | undefined;
|
|
752
|
-
set(session: AgentSession): Promise<void> | void;
|
|
753
|
-
update(id: string, updater: (session: AgentSession | undefined) => AgentSession): Promise<AgentSession> | AgentSession;
|
|
754
|
-
delete?(id: string): Promise<void> | void;
|
|
755
|
-
}
|
|
756
|
-
export interface CheckpointStore {
|
|
757
|
-
get(id: string): Promise<AgentCheckpoint | undefined> | AgentCheckpoint | undefined;
|
|
758
|
-
set(checkpoint: AgentCheckpoint): Promise<void> | void;
|
|
759
|
-
getLatest(runId: string): Promise<AgentCheckpoint | undefined> | AgentCheckpoint | undefined;
|
|
760
|
-
list(runId: string): Promise<AgentCheckpoint[]> | AgentCheckpoint[];
|
|
761
|
-
}
|
|
762
|
-
export interface AgentRunStep {
|
|
763
|
-
index: number;
|
|
764
|
-
type: AgentStepType;
|
|
765
|
-
startedAt: number;
|
|
766
|
-
finishedAt?: number;
|
|
767
|
-
model: {
|
|
768
|
-
provider: string;
|
|
769
|
-
modelId: string;
|
|
770
|
-
};
|
|
771
|
-
text?: string;
|
|
772
|
-
object?: JsonValue;
|
|
773
|
-
objectMode?: Exclude<StructuredOutputMode, "auto">;
|
|
774
|
-
finishReason?: FinishReason;
|
|
775
|
-
providerFinishReason?: string;
|
|
776
|
-
usage?: TokenUsage;
|
|
777
|
-
toolCalls: ToolCall[];
|
|
778
|
-
toolResults: ToolExecutionResult[];
|
|
779
|
-
delegatedTo?: string[];
|
|
780
|
-
handedOffTo?: string;
|
|
781
|
-
}
|
|
782
|
-
export type AgentRunInput = RetryOptions & AgentInputSource & {
|
|
783
|
-
sessionId?: string;
|
|
784
|
-
runId?: string;
|
|
785
|
-
parentRunId?: string;
|
|
786
|
-
metadata?: Record<string, unknown>;
|
|
787
|
-
budget?: AgentBudget;
|
|
788
|
-
resumeFromCheckpoint?: string;
|
|
789
|
-
};
|
|
790
|
-
export interface AgentRunResult {
|
|
791
|
-
runId: string;
|
|
792
|
-
sessionId: string;
|
|
793
|
-
agentName: string;
|
|
794
|
-
status: AgentRunStatus;
|
|
795
|
-
text: string;
|
|
796
|
-
object?: JsonValue;
|
|
797
|
-
objectMode?: Exclude<StructuredOutputMode, "auto">;
|
|
798
|
-
messages: ModelMessage[];
|
|
799
|
-
steps: AgentRunStep[];
|
|
800
|
-
toolResults: ToolExecutionResult[];
|
|
801
|
-
approvals: ApprovalRecord[];
|
|
802
|
-
metrics: AgentRunMetrics;
|
|
803
|
-
session: AgentSession;
|
|
804
|
-
pendingApproval?: ApprovalRequest;
|
|
805
|
-
checkpointId?: string;
|
|
806
|
-
handoffTo?: string;
|
|
807
|
-
parentRunId?: string;
|
|
808
|
-
}
|
|
809
|
-
export interface AgentRunStartedEvent {
|
|
810
|
-
type: "run-started";
|
|
811
|
-
runId: string;
|
|
812
|
-
sessionId: string;
|
|
813
|
-
agentName: string;
|
|
814
|
-
timestamp: number;
|
|
815
|
-
parentRunId?: string;
|
|
816
|
-
}
|
|
817
|
-
export interface AgentStepStartedEvent {
|
|
818
|
-
type: "step-started";
|
|
819
|
-
runId: string;
|
|
820
|
-
sessionId: string;
|
|
821
|
-
agentName: string;
|
|
822
|
-
step: number;
|
|
823
|
-
stepType: AgentStepType;
|
|
824
|
-
timestamp: number;
|
|
825
|
-
}
|
|
826
|
-
export interface AgentTextDeltaEvent {
|
|
827
|
-
type: "text-delta";
|
|
828
|
-
runId: string;
|
|
829
|
-
sessionId: string;
|
|
830
|
-
agentName: string;
|
|
831
|
-
step: number;
|
|
832
|
-
textDelta: string;
|
|
833
|
-
}
|
|
834
|
-
export interface AgentObjectPartialEvent {
|
|
835
|
-
type: "object-partial";
|
|
836
|
-
runId: string;
|
|
837
|
-
sessionId: string;
|
|
838
|
-
agentName: string;
|
|
839
|
-
step: number;
|
|
840
|
-
partialObject: PartialJsonValue;
|
|
841
|
-
}
|
|
842
|
-
export interface AgentObjectCompleteEvent {
|
|
843
|
-
type: "object-complete";
|
|
844
|
-
runId: string;
|
|
845
|
-
sessionId: string;
|
|
846
|
-
agentName: string;
|
|
847
|
-
step: number;
|
|
848
|
-
object: JsonValue;
|
|
849
|
-
}
|
|
850
|
-
export interface AgentToolCallEvent {
|
|
851
|
-
type: "tool-call";
|
|
852
|
-
runId: string;
|
|
853
|
-
sessionId: string;
|
|
854
|
-
agentName: string;
|
|
855
|
-
step: number;
|
|
856
|
-
toolCall: ToolCall;
|
|
857
|
-
}
|
|
858
|
-
export interface AgentToolProgressEvent {
|
|
859
|
-
type: "tool-progress";
|
|
860
|
-
runId: string;
|
|
861
|
-
sessionId: string;
|
|
862
|
-
agentName: string;
|
|
863
|
-
step: number;
|
|
864
|
-
toolCallId: string;
|
|
865
|
-
toolName: string;
|
|
866
|
-
update: ToolProgressUpdate;
|
|
867
|
-
}
|
|
868
|
-
export interface AgentToolResultEvent {
|
|
869
|
-
type: "tool-result";
|
|
870
|
-
runId: string;
|
|
871
|
-
sessionId: string;
|
|
872
|
-
agentName: string;
|
|
873
|
-
step: number;
|
|
874
|
-
toolResult: ToolExecutionResult;
|
|
875
|
-
}
|
|
876
|
-
export interface AgentApprovalRequiredEvent {
|
|
877
|
-
type: "approval-required";
|
|
878
|
-
runId: string;
|
|
879
|
-
sessionId: string;
|
|
880
|
-
agentName: string;
|
|
881
|
-
step: number;
|
|
882
|
-
request: ApprovalRequest;
|
|
883
|
-
}
|
|
884
|
-
export interface AgentApprovalDecidedEvent {
|
|
885
|
-
type: "approval-decided";
|
|
886
|
-
runId: string;
|
|
887
|
-
sessionId: string;
|
|
888
|
-
agentName: string;
|
|
889
|
-
step: number;
|
|
890
|
-
record: ApprovalRecord;
|
|
891
|
-
}
|
|
892
|
-
export interface AgentCheckpointSavedEvent {
|
|
893
|
-
type: "checkpoint-saved";
|
|
894
|
-
runId: string;
|
|
895
|
-
sessionId: string;
|
|
896
|
-
agentName: string;
|
|
897
|
-
checkpointId: string;
|
|
898
|
-
step: number;
|
|
899
|
-
timestamp: number;
|
|
900
|
-
}
|
|
901
|
-
export interface AgentMemoryWrittenEvent {
|
|
902
|
-
type: "memory-written";
|
|
903
|
-
runId: string;
|
|
904
|
-
sessionId: string;
|
|
905
|
-
agentName: string;
|
|
906
|
-
records: MemoryRecord[];
|
|
907
|
-
}
|
|
908
|
-
export interface AgentDelegateStartedEvent {
|
|
909
|
-
type: "delegate-started";
|
|
910
|
-
runId: string;
|
|
911
|
-
sessionId: string;
|
|
912
|
-
agentName: string;
|
|
913
|
-
step: number;
|
|
914
|
-
targetAgent: string;
|
|
915
|
-
}
|
|
916
|
-
export interface AgentDelegateFinishedEvent {
|
|
917
|
-
type: "delegate-finished";
|
|
918
|
-
runId: string;
|
|
919
|
-
sessionId: string;
|
|
920
|
-
agentName: string;
|
|
921
|
-
step: number;
|
|
922
|
-
targetAgent: string;
|
|
923
|
-
childRunId: string;
|
|
924
|
-
status: AgentRunStatus;
|
|
925
|
-
}
|
|
926
|
-
export interface AgentHandoffEvent {
|
|
927
|
-
type: "handoff";
|
|
928
|
-
runId: string;
|
|
929
|
-
sessionId: string;
|
|
930
|
-
agentName: string;
|
|
931
|
-
step: number;
|
|
932
|
-
targetAgent: string;
|
|
933
|
-
childRunId: string;
|
|
934
|
-
}
|
|
935
|
-
export interface AgentStepFinishedEvent {
|
|
936
|
-
type: "step-finished";
|
|
937
|
-
runId: string;
|
|
938
|
-
sessionId: string;
|
|
939
|
-
agentName: string;
|
|
940
|
-
step: number;
|
|
941
|
-
stepType: AgentStepType;
|
|
942
|
-
finishReason?: FinishReason;
|
|
943
|
-
providerFinishReason?: string;
|
|
944
|
-
usage?: TokenUsage;
|
|
945
|
-
timestamp: number;
|
|
946
|
-
}
|
|
947
|
-
export interface AgentRunFinishedEvent {
|
|
948
|
-
type: "run-finished";
|
|
949
|
-
runId: string;
|
|
950
|
-
sessionId: string;
|
|
951
|
-
agentName: string;
|
|
952
|
-
status: AgentRunStatus;
|
|
953
|
-
metrics: AgentRunMetrics;
|
|
954
|
-
timestamp: number;
|
|
955
|
-
}
|
|
956
|
-
export interface AgentRunErrorEvent {
|
|
957
|
-
type: "run-error";
|
|
958
|
-
runId: string;
|
|
959
|
-
sessionId: string;
|
|
960
|
-
agentName: string;
|
|
961
|
-
step: number;
|
|
962
|
-
error: {
|
|
963
|
-
message: string;
|
|
964
|
-
};
|
|
965
|
-
timestamp: number;
|
|
966
|
-
}
|
|
967
|
-
export interface AgentRunPausedEvent {
|
|
968
|
-
type: "run-paused";
|
|
969
|
-
runId: string;
|
|
970
|
-
sessionId: string;
|
|
971
|
-
agentName: string;
|
|
972
|
-
reason: "approval";
|
|
973
|
-
timestamp: number;
|
|
974
|
-
}
|
|
975
|
-
export interface AgentRunResumedEvent {
|
|
976
|
-
type: "run-resumed";
|
|
977
|
-
runId: string;
|
|
978
|
-
sessionId: string;
|
|
979
|
-
agentName: string;
|
|
980
|
-
checkpointId: string;
|
|
981
|
-
timestamp: number;
|
|
982
|
-
}
|
|
983
|
-
export type AgentEvent = AgentRunStartedEvent | AgentStepStartedEvent | AgentTextDeltaEvent | AgentObjectPartialEvent | AgentObjectCompleteEvent | AgentToolCallEvent | AgentToolProgressEvent | AgentToolResultEvent | AgentApprovalRequiredEvent | AgentApprovalDecidedEvent | AgentCheckpointSavedEvent | AgentMemoryWrittenEvent | AgentDelegateStartedEvent | AgentDelegateFinishedEvent | AgentHandoffEvent | AgentStepFinishedEvent | AgentRunFinishedEvent | AgentRunErrorEvent | AgentRunPausedEvent | AgentRunResumedEvent;
|
|
984
|
-
export interface AgentStreamResult {
|
|
985
|
-
eventStream: AsyncIterable<AgentEvent>;
|
|
986
|
-
partialObjectStream: AsyncIterable<PartialJsonValue>;
|
|
987
|
-
textStream: AsyncIterable<string>;
|
|
988
|
-
collect: () => Promise<AgentRunResult>;
|
|
989
|
-
}
|
|
990
1085
|
//# sourceMappingURL=types.d.ts.map
|