@zhivex-ai/core 0.5.0-next.0 → 0.5.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 +276 -0
- package/dist/observability.js.map +1 -0
- package/dist/realtime.d.ts +52 -0
- package/dist/realtime.d.ts.map +1 -0
- package/dist/realtime.js +304 -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 +589 -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,27 @@ 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
|
+
tools: boolean;
|
|
87
|
+
browserTokens: boolean;
|
|
88
|
+
};
|
|
89
|
+
agentCapabilities?: AgentCapabilities;
|
|
90
|
+
}
|
|
91
|
+
export interface AgentCapabilities {
|
|
92
|
+
supportTier: AgentSupportTier;
|
|
93
|
+
toolChoiceNone: boolean;
|
|
94
|
+
approvalRequests: boolean;
|
|
95
|
+
hostedWebSearch: boolean;
|
|
96
|
+
hostedFileSearch: boolean;
|
|
97
|
+
remoteMcp: boolean;
|
|
98
|
+
computerUse: boolean;
|
|
99
|
+
codeExecution: boolean;
|
|
100
|
+
toolsets: boolean;
|
|
101
|
+
}
|
|
102
|
+
export type AgentSupportTier = "tier-a" | "tier-b" | "tier-c";
|
|
91
103
|
export interface RetryOptions {
|
|
92
104
|
abortSignal?: AbortSignal;
|
|
93
105
|
timeoutMs?: number;
|
|
@@ -100,22 +112,6 @@ export interface ToolExecutionOptions {
|
|
|
100
112
|
timeoutMs?: number;
|
|
101
113
|
stopOnError?: boolean;
|
|
102
114
|
}
|
|
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
115
|
export interface StructuredOutputConfig<TSchema extends ZodTypeAny = ZodTypeAny> {
|
|
120
116
|
schema: TSchema;
|
|
121
117
|
mode: StructuredOutputMode;
|
|
@@ -138,6 +134,11 @@ export interface StreamToolResultEvent {
|
|
|
138
134
|
type: "tool-result";
|
|
139
135
|
toolResult: ToolExecutionResult;
|
|
140
136
|
}
|
|
137
|
+
export interface StreamProviderDataEvent {
|
|
138
|
+
type: "provider-data";
|
|
139
|
+
provider: string;
|
|
140
|
+
data: JsonValue;
|
|
141
|
+
}
|
|
141
142
|
export interface StreamFinishEvent {
|
|
142
143
|
type: "finish";
|
|
143
144
|
finishReason?: FinishReason;
|
|
@@ -148,7 +149,34 @@ export interface StreamErrorEvent {
|
|
|
148
149
|
type: "error";
|
|
149
150
|
error: Error;
|
|
150
151
|
}
|
|
151
|
-
export type StreamEvent = StreamTextDeltaEvent | StreamToolCallEvent | StreamToolResultEvent | StreamFinishEvent | StreamErrorEvent;
|
|
152
|
+
export type StreamEvent = StreamTextDeltaEvent | StreamToolCallEvent | StreamToolResultEvent | StreamProviderDataEvent | StreamFinishEvent | StreamErrorEvent;
|
|
153
|
+
export interface AgentRunStartEvent {
|
|
154
|
+
type: "agent-run-start";
|
|
155
|
+
currentStep: number;
|
|
156
|
+
maxSteps: number;
|
|
157
|
+
}
|
|
158
|
+
export interface AgentStepStartEvent {
|
|
159
|
+
type: "agent-step-start";
|
|
160
|
+
stepIndex: number;
|
|
161
|
+
}
|
|
162
|
+
export interface AgentStepFinishEvent {
|
|
163
|
+
type: "agent-step-finish";
|
|
164
|
+
step: AgentStep;
|
|
165
|
+
}
|
|
166
|
+
export interface AgentApprovalRequestEvent {
|
|
167
|
+
type: "agent-approval-request";
|
|
168
|
+
approval: AgentApprovalRequest;
|
|
169
|
+
}
|
|
170
|
+
export interface AgentApprovalResolvedEvent {
|
|
171
|
+
type: "agent-approval-resolved";
|
|
172
|
+
approval: AgentApprovalResponse;
|
|
173
|
+
}
|
|
174
|
+
export interface AgentRunFinishEvent {
|
|
175
|
+
type: "agent-run-finish";
|
|
176
|
+
status: AgentStatus;
|
|
177
|
+
state: AgentRunState;
|
|
178
|
+
}
|
|
179
|
+
export type AgentStreamEvent = StreamEvent | AgentRunStartEvent | AgentStepStartEvent | AgentStepFinishEvent | AgentApprovalRequestEvent | AgentApprovalResolvedEvent | AgentRunFinishEvent;
|
|
152
180
|
export interface StreamObjectDeltaEvent {
|
|
153
181
|
type: "object-delta";
|
|
154
182
|
textDelta: string;
|
|
@@ -264,13 +292,131 @@ export interface SpeechModel<TProviderOptions extends ProviderOptions = Provider
|
|
|
264
292
|
readonly capabilities: ModelCapabilities;
|
|
265
293
|
generateSpeech(input: SpeechModelInput<TProviderOptions>): Promise<SpeechResult>;
|
|
266
294
|
}
|
|
295
|
+
export interface AudioFrame {
|
|
296
|
+
data: string | Uint8Array | ArrayBuffer;
|
|
297
|
+
mediaType: string;
|
|
298
|
+
sampleRateHz?: number;
|
|
299
|
+
channels?: number;
|
|
300
|
+
isFinal?: boolean;
|
|
301
|
+
}
|
|
302
|
+
export interface RealtimeConnectOptions {
|
|
303
|
+
timeoutMs?: number;
|
|
304
|
+
signal?: AbortSignal;
|
|
305
|
+
subprotocols?: string[];
|
|
306
|
+
}
|
|
307
|
+
export interface RealtimeSessionConfig {
|
|
308
|
+
instructions?: string;
|
|
309
|
+
voice?: string;
|
|
310
|
+
tools?: ToolCollection;
|
|
311
|
+
toolChoice?: ToolChoice;
|
|
312
|
+
inputAudioMediaType?: string;
|
|
313
|
+
outputAudioMediaType?: string;
|
|
314
|
+
inputSampleRateHz?: number;
|
|
315
|
+
outputSampleRateHz?: number;
|
|
316
|
+
channels?: number;
|
|
317
|
+
turnDetection?: Record<string, unknown> | null;
|
|
318
|
+
providerOptions?: ProviderOptions;
|
|
319
|
+
metadata?: Record<string, JsonValue>;
|
|
320
|
+
autoResponse?: boolean;
|
|
321
|
+
}
|
|
322
|
+
export interface RealtimeTokenResult {
|
|
323
|
+
value: string;
|
|
324
|
+
expiresAtMs?: number;
|
|
325
|
+
rawResponse?: unknown;
|
|
326
|
+
}
|
|
327
|
+
export interface RealtimeSessionStartedEvent {
|
|
328
|
+
type: "realtime-start";
|
|
329
|
+
sessionId?: string;
|
|
330
|
+
providerMetadata?: Record<string, JsonValue>;
|
|
331
|
+
}
|
|
332
|
+
export interface RealtimeTextDeltaEvent {
|
|
333
|
+
type: "realtime-text-delta";
|
|
334
|
+
textDelta: string;
|
|
335
|
+
itemId?: string;
|
|
336
|
+
responseId?: string;
|
|
337
|
+
role?: "assistant";
|
|
338
|
+
providerMetadata?: Record<string, JsonValue>;
|
|
339
|
+
}
|
|
340
|
+
export interface RealtimeAudioOutputEvent {
|
|
341
|
+
type: "realtime-audio-output";
|
|
342
|
+
audio: Uint8Array;
|
|
343
|
+
mediaType: string;
|
|
344
|
+
sampleRateHz?: number;
|
|
345
|
+
channels?: number;
|
|
346
|
+
itemId?: string;
|
|
347
|
+
responseId?: string;
|
|
348
|
+
providerMetadata?: Record<string, JsonValue>;
|
|
349
|
+
}
|
|
350
|
+
export interface RealtimeTranscriptEvent {
|
|
351
|
+
type: "realtime-transcript";
|
|
352
|
+
text: string;
|
|
353
|
+
role: "user" | "assistant";
|
|
354
|
+
isFinal: boolean;
|
|
355
|
+
itemId?: string;
|
|
356
|
+
responseId?: string;
|
|
357
|
+
providerMetadata?: Record<string, JsonValue>;
|
|
358
|
+
}
|
|
359
|
+
export interface RealtimeToolCallEvent {
|
|
360
|
+
type: "realtime-tool-call";
|
|
361
|
+
toolCall: ToolCall;
|
|
362
|
+
}
|
|
363
|
+
export interface RealtimeToolResultEvent {
|
|
364
|
+
type: "realtime-tool-result";
|
|
365
|
+
toolResult: ToolExecutionResult;
|
|
366
|
+
}
|
|
367
|
+
export interface RealtimeResponseCompleteEvent {
|
|
368
|
+
type: "realtime-response-complete";
|
|
369
|
+
reason?: string;
|
|
370
|
+
providerMetadata?: Record<string, JsonValue>;
|
|
371
|
+
}
|
|
372
|
+
export interface RealtimeSessionResumptionEvent {
|
|
373
|
+
type: "realtime-session-resumption";
|
|
374
|
+
handle?: string;
|
|
375
|
+
resumable?: boolean;
|
|
376
|
+
providerMetadata?: Record<string, JsonValue>;
|
|
377
|
+
}
|
|
378
|
+
export interface RealtimeGoAwayEvent {
|
|
379
|
+
type: "realtime-go-away";
|
|
380
|
+
timeLeftMs?: number;
|
|
381
|
+
providerMetadata?: Record<string, JsonValue>;
|
|
382
|
+
}
|
|
383
|
+
export interface RealtimeSessionEndedEvent {
|
|
384
|
+
type: "realtime-end";
|
|
385
|
+
reason?: string;
|
|
386
|
+
providerMetadata?: Record<string, JsonValue>;
|
|
387
|
+
}
|
|
388
|
+
export interface RealtimeErrorEvent {
|
|
389
|
+
type: "realtime-error";
|
|
390
|
+
error?: Error;
|
|
391
|
+
message?: string;
|
|
392
|
+
providerMetadata?: Record<string, JsonValue>;
|
|
393
|
+
}
|
|
394
|
+
export type RealtimeEvent = RealtimeSessionStartedEvent | RealtimeTextDeltaEvent | RealtimeAudioOutputEvent | RealtimeTranscriptEvent | RealtimeToolCallEvent | RealtimeToolResultEvent | RealtimeResponseCompleteEvent | RealtimeSessionResumptionEvent | RealtimeGoAwayEvent | RealtimeSessionEndedEvent | RealtimeErrorEvent;
|
|
395
|
+
export interface RealtimeSession {
|
|
396
|
+
readonly provider: string;
|
|
397
|
+
readonly modelId: string;
|
|
398
|
+
readonly capabilities: ModelCapabilities;
|
|
399
|
+
readonly config: RealtimeSessionConfig;
|
|
400
|
+
sendAudio(frame: AudioFrame): Promise<void>;
|
|
401
|
+
sendText(text: string): Promise<void>;
|
|
402
|
+
sendToolResult(result: ToolExecutionResult): Promise<void>;
|
|
403
|
+
update(config: Partial<RealtimeSessionConfig>): Promise<void>;
|
|
404
|
+
eventStream(): AsyncIterable<RealtimeEvent>;
|
|
405
|
+
close(): Promise<void>;
|
|
406
|
+
}
|
|
407
|
+
export interface RealtimeModel {
|
|
408
|
+
readonly provider: string;
|
|
409
|
+
readonly modelId: string;
|
|
410
|
+
readonly capabilities: ModelCapabilities;
|
|
411
|
+
connect(config?: RealtimeSessionConfig, options?: RealtimeConnectOptions): Promise<RealtimeSession>;
|
|
412
|
+
createBrowserToken?(config?: RealtimeSessionConfig, options?: RealtimeConnectOptions): Promise<RealtimeTokenResult>;
|
|
413
|
+
}
|
|
267
414
|
export interface GroundedLanguageModel<TProviderOptions extends ProviderOptions = ProviderOptions> {
|
|
268
415
|
readonly provider: string;
|
|
269
416
|
readonly modelId: string;
|
|
270
417
|
readonly capabilities: ModelCapabilities;
|
|
271
418
|
generate(input: GroundedModelGenerateInput<TProviderOptions>): Promise<GroundedGenerateResult>;
|
|
272
419
|
}
|
|
273
|
-
export type AgentModel<TProviderOptions extends ProviderOptions = ProviderOptions> = LanguageModel<TProviderOptions> | GroundedLanguageModel<TProviderOptions>;
|
|
274
420
|
export interface EmbeddingModel {
|
|
275
421
|
readonly provider: string;
|
|
276
422
|
readonly modelId: string;
|
|
@@ -283,6 +429,7 @@ export interface ProviderAdapter {
|
|
|
283
429
|
embeddingModel?: (modelId: string) => EmbeddingModel;
|
|
284
430
|
transcriptionModel?: (modelId: string) => TranscriptionModel;
|
|
285
431
|
speechModel?: (modelId: string) => SpeechModel;
|
|
432
|
+
realtimeModel?: (modelId: string) => RealtimeModel;
|
|
286
433
|
groundedLanguageModel?: (modelId: string) => GroundedLanguageModel;
|
|
287
434
|
}
|
|
288
435
|
export type CallableProviderAdapter = ProviderAdapter & ((modelId: string) => LanguageModel);
|
|
@@ -290,18 +437,59 @@ export interface ToolDefinition<TSchema extends ZodTypeAny = ZodTypeAny, TResult
|
|
|
290
437
|
name: string;
|
|
291
438
|
description?: string;
|
|
292
439
|
schema: TSchema;
|
|
440
|
+
metadata?: Record<string, JsonValue>;
|
|
293
441
|
requiresApproval?: boolean;
|
|
294
|
-
|
|
295
|
-
execute: (input: z.infer<TSchema>, context?: ToolExecutionContext) => Promise<TResult> | TResult;
|
|
442
|
+
execute: (input: z.infer<TSchema>) => Promise<TResult> | TResult;
|
|
296
443
|
}
|
|
297
|
-
export type
|
|
444
|
+
export type HostedToolClass = "web-search" | "file-search" | "remote-mcp" | "computer-use" | "code-execution" | "toolset" | "custom";
|
|
445
|
+
export interface HostedToolDefinition<TConfig extends JsonValue = JsonValue> {
|
|
446
|
+
kind: "hosted";
|
|
447
|
+
name: string;
|
|
448
|
+
provider?: string;
|
|
449
|
+
type: string;
|
|
450
|
+
config?: TConfig;
|
|
451
|
+
toolClass?: HostedToolClass;
|
|
452
|
+
requiresApproval?: boolean;
|
|
453
|
+
metadata?: Record<string, JsonValue>;
|
|
454
|
+
}
|
|
455
|
+
export type AnyToolDefinition = ToolDefinition | HostedToolDefinition;
|
|
456
|
+
export type ToolSet = Record<string, AnyToolDefinition>;
|
|
457
|
+
export interface ToolRegistryLike {
|
|
458
|
+
get(name: string): AnyToolDefinition | undefined;
|
|
459
|
+
has(name: string): boolean;
|
|
460
|
+
entries(): Iterable<[string, AnyToolDefinition]>;
|
|
461
|
+
toToolSet(): ToolSet;
|
|
462
|
+
}
|
|
463
|
+
export type ToolCollection = ToolSet | ToolRegistryLike;
|
|
464
|
+
export interface ToolApprovalRequest {
|
|
465
|
+
toolCall: ToolCall;
|
|
466
|
+
tool: ToolDefinition;
|
|
467
|
+
input: JsonValue;
|
|
468
|
+
step: number;
|
|
469
|
+
model: LanguageModel | RealtimeModel;
|
|
470
|
+
request?: ModelGenerateInput;
|
|
471
|
+
realtimeConfig?: RealtimeSessionConfig;
|
|
472
|
+
}
|
|
473
|
+
export interface ToolApprovalDecision {
|
|
474
|
+
approved: boolean;
|
|
475
|
+
reason?: string;
|
|
476
|
+
metadata?: Record<string, JsonValue>;
|
|
477
|
+
}
|
|
478
|
+
export interface ToolApprovalEvent {
|
|
479
|
+
request: ToolApprovalRequest;
|
|
480
|
+
decision: ToolApprovalDecision;
|
|
481
|
+
}
|
|
482
|
+
export type ToolApprovalPolicy = (request: ToolApprovalRequest) => ToolApprovalDecision | boolean | Promise<ToolApprovalDecision | boolean>;
|
|
483
|
+
export type ToolApprovalObserver = (event: ToolApprovalEvent) => void | Promise<void>;
|
|
298
484
|
export type ProviderOptionsOf<TModel extends LanguageModel> = TModel extends LanguageModel<infer TProviderOptions> ? TProviderOptions : ProviderOptions;
|
|
299
485
|
export type GenerateTextOptions<TModel extends LanguageModel = LanguageModel> = RetryOptions & GenerateInputSource & {
|
|
300
486
|
model: TModel;
|
|
301
487
|
system?: string;
|
|
302
|
-
tools?:
|
|
488
|
+
tools?: ToolCollection;
|
|
303
489
|
toolChoice?: ToolChoice;
|
|
304
490
|
toolExecution?: ToolExecutionOptions;
|
|
491
|
+
toolApprovalPolicy?: ToolApprovalPolicy;
|
|
492
|
+
onToolApprovalDecision?: ToolApprovalObserver;
|
|
305
493
|
maxSteps?: number;
|
|
306
494
|
temperature?: number;
|
|
307
495
|
maxTokens?: number;
|
|
@@ -322,6 +510,336 @@ export interface GenerateTextOutput {
|
|
|
322
510
|
messages: ModelMessage[];
|
|
323
511
|
toolResults: ToolExecutionResult[];
|
|
324
512
|
}
|
|
513
|
+
export type AgentStatus = "running" | "completed" | "suspended" | "failed" | "cancelled";
|
|
514
|
+
export type AgentStepStatus = "running" | "completed" | "suspended" | "failed";
|
|
515
|
+
export interface AgentStepRequest {
|
|
516
|
+
messages: ModelMessage[];
|
|
517
|
+
toolChoice?: ToolChoice;
|
|
518
|
+
toolExecution?: ToolExecutionOptions;
|
|
519
|
+
temperature?: number;
|
|
520
|
+
maxTokens?: number;
|
|
521
|
+
reasoning?: ReasoningConfig;
|
|
522
|
+
providerOptions?: ProviderOptions;
|
|
523
|
+
timeoutMs?: number;
|
|
524
|
+
maxRetries?: number;
|
|
525
|
+
retryBackoffMs?: number;
|
|
526
|
+
}
|
|
527
|
+
export interface AgentStepResponse {
|
|
528
|
+
messages: ModelMessage[];
|
|
529
|
+
text?: string;
|
|
530
|
+
finishReason?: FinishReason;
|
|
531
|
+
providerFinishReason?: string;
|
|
532
|
+
usage?: TokenUsage;
|
|
533
|
+
}
|
|
534
|
+
export interface AgentStep {
|
|
535
|
+
index: number;
|
|
536
|
+
status: AgentStepStatus;
|
|
537
|
+
startedAt?: number;
|
|
538
|
+
finishedAt?: number;
|
|
539
|
+
request: AgentStepRequest;
|
|
540
|
+
response?: AgentStepResponse;
|
|
541
|
+
toolResults: ToolExecutionResult[];
|
|
542
|
+
error?: {
|
|
543
|
+
message: string;
|
|
544
|
+
};
|
|
545
|
+
}
|
|
546
|
+
export interface AgentRunState {
|
|
547
|
+
runId: string;
|
|
548
|
+
agentId?: string;
|
|
549
|
+
parentRunId?: string;
|
|
550
|
+
provider: string;
|
|
551
|
+
modelId: string;
|
|
552
|
+
status: AgentStatus;
|
|
553
|
+
messages: ModelMessage[];
|
|
554
|
+
steps: AgentStep[];
|
|
555
|
+
toolResults: ToolExecutionResult[];
|
|
556
|
+
currentStep: number;
|
|
557
|
+
maxSteps: number;
|
|
558
|
+
outputText: string;
|
|
559
|
+
finishReason?: FinishReason;
|
|
560
|
+
providerFinishReason?: string;
|
|
561
|
+
usage?: TokenUsage;
|
|
562
|
+
pendingApprovals: AgentApprovalRequest[];
|
|
563
|
+
metadata?: Record<string, JsonValue>;
|
|
564
|
+
handoff?: AgentHandoff;
|
|
565
|
+
startedAt?: number;
|
|
566
|
+
updatedAt?: number;
|
|
567
|
+
error?: {
|
|
568
|
+
message: string;
|
|
569
|
+
};
|
|
570
|
+
}
|
|
571
|
+
export interface AgentRunStore {
|
|
572
|
+
load(runId: string): Promise<AgentRunState | undefined> | AgentRunState | undefined;
|
|
573
|
+
save(state: AgentRunState): Promise<void> | void;
|
|
574
|
+
delete?(runId: string): Promise<void> | void;
|
|
575
|
+
}
|
|
576
|
+
export interface AgentMemoryContext {
|
|
577
|
+
runId: string;
|
|
578
|
+
agentId?: string;
|
|
579
|
+
state?: AgentRunState;
|
|
580
|
+
metadata?: Record<string, JsonValue>;
|
|
581
|
+
}
|
|
582
|
+
export interface AgentMemoryStore {
|
|
583
|
+
load(context: AgentMemoryContext): Promise<ModelMessage[]> | ModelMessage[];
|
|
584
|
+
save?(context: AgentMemoryContext & {
|
|
585
|
+
state: AgentRunState;
|
|
586
|
+
}): Promise<void> | void;
|
|
587
|
+
}
|
|
588
|
+
export interface SqliteStatementLike<TResult extends Record<string, unknown> = Record<string, unknown>> {
|
|
589
|
+
run(params?: readonly unknown[] | Record<string, unknown>): unknown;
|
|
590
|
+
get(params?: readonly unknown[] | Record<string, unknown>): TResult | undefined;
|
|
591
|
+
}
|
|
592
|
+
export interface SqliteDatabaseLike {
|
|
593
|
+
exec(sql: string): unknown;
|
|
594
|
+
prepare?<TResult extends Record<string, unknown> = Record<string, unknown>>(sql: string): SqliteStatementLike<TResult>;
|
|
595
|
+
query?<TResult extends Record<string, unknown> = Record<string, unknown>>(sql: string): SqliteStatementLike<TResult>;
|
|
596
|
+
}
|
|
597
|
+
export interface SqliteAgentRunStoreOptions {
|
|
598
|
+
db: SqliteDatabaseLike;
|
|
599
|
+
tableName?: string;
|
|
600
|
+
}
|
|
601
|
+
export interface SqliteAgentMemoryStoreOptions {
|
|
602
|
+
db: SqliteDatabaseLike;
|
|
603
|
+
tableName?: string;
|
|
604
|
+
key?: (context: AgentMemoryContext) => string;
|
|
605
|
+
selectMessages?: (state: AgentRunState) => ModelMessage[];
|
|
606
|
+
}
|
|
607
|
+
export interface PostgresQueryResultLike<TResult extends Record<string, unknown> = Record<string, unknown>> {
|
|
608
|
+
rows: TResult[];
|
|
609
|
+
}
|
|
610
|
+
export interface PostgresClientLike {
|
|
611
|
+
query<TResult extends Record<string, unknown> = Record<string, unknown>>(sql: string, params?: readonly unknown[]): Promise<PostgresQueryResultLike<TResult>> | PostgresQueryResultLike<TResult>;
|
|
612
|
+
}
|
|
613
|
+
export interface PostgresAgentRunStoreOptions {
|
|
614
|
+
client: PostgresClientLike;
|
|
615
|
+
tableName?: string;
|
|
616
|
+
}
|
|
617
|
+
export interface PostgresAgentMemoryStoreOptions {
|
|
618
|
+
client: PostgresClientLike;
|
|
619
|
+
tableName?: string;
|
|
620
|
+
key?: (context: AgentMemoryContext) => string;
|
|
621
|
+
selectMessages?: (state: AgentRunState) => ModelMessage[];
|
|
622
|
+
}
|
|
623
|
+
export interface AgentHandoff {
|
|
624
|
+
id: string;
|
|
625
|
+
fromRunId: string;
|
|
626
|
+
fromAgentId?: string;
|
|
627
|
+
toAgentId?: string;
|
|
628
|
+
summary: string;
|
|
629
|
+
contextMessages: ModelMessage[];
|
|
630
|
+
metadata?: Record<string, JsonValue>;
|
|
631
|
+
}
|
|
632
|
+
export interface AgentTelemetryRunStartEvent {
|
|
633
|
+
type: "run-start";
|
|
634
|
+
runId: string;
|
|
635
|
+
agentId?: string;
|
|
636
|
+
provider: string;
|
|
637
|
+
modelId: string;
|
|
638
|
+
maxSteps: number;
|
|
639
|
+
}
|
|
640
|
+
export interface AgentTelemetryStepStartEvent {
|
|
641
|
+
type: "step-start";
|
|
642
|
+
runId: string;
|
|
643
|
+
agentId?: string;
|
|
644
|
+
stepIndex: number;
|
|
645
|
+
}
|
|
646
|
+
export interface AgentTelemetryStepFinishEvent {
|
|
647
|
+
type: "step-finish";
|
|
648
|
+
runId: string;
|
|
649
|
+
agentId?: string;
|
|
650
|
+
step: AgentStep;
|
|
651
|
+
}
|
|
652
|
+
export interface AgentTelemetryApprovalRequestEvent {
|
|
653
|
+
type: "approval-request";
|
|
654
|
+
runId: string;
|
|
655
|
+
agentId?: string;
|
|
656
|
+
approval: AgentApprovalRequest;
|
|
657
|
+
}
|
|
658
|
+
export interface AgentTelemetryApprovalResolvedEvent {
|
|
659
|
+
type: "approval-resolved";
|
|
660
|
+
runId: string;
|
|
661
|
+
agentId?: string;
|
|
662
|
+
approval: AgentApprovalResponse;
|
|
663
|
+
}
|
|
664
|
+
export interface AgentTelemetryToolApprovalEvent {
|
|
665
|
+
type: "tool-approval";
|
|
666
|
+
runId: string;
|
|
667
|
+
agentId?: string;
|
|
668
|
+
toolCall: ToolCall;
|
|
669
|
+
approved: boolean;
|
|
670
|
+
reason?: string;
|
|
671
|
+
metadata?: Record<string, JsonValue>;
|
|
672
|
+
}
|
|
673
|
+
export interface AgentTelemetryMemoryLoadedEvent {
|
|
674
|
+
type: "memory-loaded";
|
|
675
|
+
runId: string;
|
|
676
|
+
agentId?: string;
|
|
677
|
+
messageCount: number;
|
|
678
|
+
}
|
|
679
|
+
export interface AgentGuardrailTrigger {
|
|
680
|
+
triggered: true;
|
|
681
|
+
reason?: string;
|
|
682
|
+
metadata?: Record<string, JsonValue>;
|
|
683
|
+
}
|
|
684
|
+
export interface AgentInputGuardrailRequest {
|
|
685
|
+
runId: string;
|
|
686
|
+
agentId?: string;
|
|
687
|
+
messages: ModelMessage[];
|
|
688
|
+
metadata?: Record<string, JsonValue>;
|
|
689
|
+
}
|
|
690
|
+
export interface AgentOutputGuardrailRequest {
|
|
691
|
+
runId: string;
|
|
692
|
+
agentId?: string;
|
|
693
|
+
state: AgentRunState;
|
|
694
|
+
output: AgentRunOutput | LiveAgentRunOutput;
|
|
695
|
+
metadata?: Record<string, JsonValue>;
|
|
696
|
+
}
|
|
697
|
+
export type AgentInputGuardrail = (request: AgentInputGuardrailRequest) => AgentGuardrailTrigger | void | Promise<AgentGuardrailTrigger | void>;
|
|
698
|
+
export type AgentOutputGuardrail = (request: AgentOutputGuardrailRequest) => AgentGuardrailTrigger | void | Promise<AgentGuardrailTrigger | void>;
|
|
699
|
+
export interface AgentTelemetryGuardrailTriggeredEvent {
|
|
700
|
+
type: "guardrail-triggered";
|
|
701
|
+
runId: string;
|
|
702
|
+
agentId?: string;
|
|
703
|
+
stage: "input" | "output";
|
|
704
|
+
reason?: string;
|
|
705
|
+
metadata?: Record<string, JsonValue>;
|
|
706
|
+
}
|
|
707
|
+
export interface AgentTelemetryStateSavedEvent {
|
|
708
|
+
type: "state-saved";
|
|
709
|
+
runId: string;
|
|
710
|
+
agentId?: string;
|
|
711
|
+
status: AgentStatus;
|
|
712
|
+
}
|
|
713
|
+
export interface AgentTelemetryHandoffEvent {
|
|
714
|
+
type: "handoff";
|
|
715
|
+
runId: string;
|
|
716
|
+
agentId?: string;
|
|
717
|
+
handoff: AgentHandoff;
|
|
718
|
+
}
|
|
719
|
+
export interface AgentTelemetryRunFinishEvent {
|
|
720
|
+
type: "run-finish";
|
|
721
|
+
runId: string;
|
|
722
|
+
agentId?: string;
|
|
723
|
+
status: AgentStatus;
|
|
724
|
+
state: AgentRunState;
|
|
725
|
+
}
|
|
726
|
+
export type AgentTelemetryEvent = AgentTelemetryRunStartEvent | AgentTelemetryStepStartEvent | AgentTelemetryStepFinishEvent | AgentTelemetryApprovalRequestEvent | AgentTelemetryApprovalResolvedEvent | AgentTelemetryToolApprovalEvent | AgentTelemetryMemoryLoadedEvent | AgentTelemetryGuardrailTriggeredEvent | AgentTelemetryStateSavedEvent | AgentTelemetryHandoffEvent | AgentTelemetryRunFinishEvent;
|
|
727
|
+
export type AgentTelemetryObserver = (event: AgentTelemetryEvent) => void | Promise<void>;
|
|
728
|
+
export interface AgentDefinition<TModel extends LanguageModel = LanguageModel> {
|
|
729
|
+
id?: string;
|
|
730
|
+
model: TModel;
|
|
731
|
+
instructions?: string;
|
|
732
|
+
tools?: ToolCollection;
|
|
733
|
+
maxSteps?: number;
|
|
734
|
+
temperature?: number;
|
|
735
|
+
maxTokens?: number;
|
|
736
|
+
reasoning?: ReasoningConfig;
|
|
737
|
+
toolExecution?: ToolExecutionOptions;
|
|
738
|
+
toolApprovalPolicy?: ToolApprovalPolicy;
|
|
739
|
+
inputGuardrails?: AgentInputGuardrail[];
|
|
740
|
+
outputGuardrails?: AgentOutputGuardrail[];
|
|
741
|
+
providerOptions?: ProviderOptionsOf<TModel>;
|
|
742
|
+
metadata?: Record<string, JsonValue>;
|
|
743
|
+
store?: AgentRunStore;
|
|
744
|
+
memory?: AgentMemoryStore;
|
|
745
|
+
onTelemetryEvent?: AgentTelemetryObserver;
|
|
746
|
+
}
|
|
747
|
+
export interface LiveAgentDefinition<TModel extends RealtimeModel = RealtimeModel> {
|
|
748
|
+
id?: string;
|
|
749
|
+
model: TModel;
|
|
750
|
+
instructions?: string;
|
|
751
|
+
tools?: ToolCollection;
|
|
752
|
+
toolChoice?: ToolChoice;
|
|
753
|
+
toolExecution?: ToolExecutionOptions;
|
|
754
|
+
toolApprovalPolicy?: ToolApprovalPolicy;
|
|
755
|
+
inputGuardrails?: AgentInputGuardrail[];
|
|
756
|
+
outputGuardrails?: AgentOutputGuardrail[];
|
|
757
|
+
providerOptions?: ProviderOptions;
|
|
758
|
+
metadata?: Record<string, JsonValue>;
|
|
759
|
+
store?: AgentRunStore;
|
|
760
|
+
memory?: AgentMemoryStore;
|
|
761
|
+
onTelemetryEvent?: AgentTelemetryObserver;
|
|
762
|
+
}
|
|
763
|
+
export interface AgentApprovalRequest {
|
|
764
|
+
provider: string;
|
|
765
|
+
id: string;
|
|
766
|
+
name: string;
|
|
767
|
+
arguments: string;
|
|
768
|
+
serverLabel?: string;
|
|
769
|
+
rawData: JsonValue;
|
|
770
|
+
}
|
|
771
|
+
export interface AgentApprovalResponse {
|
|
772
|
+
provider: string;
|
|
773
|
+
approvalRequestId: string;
|
|
774
|
+
approve: boolean;
|
|
775
|
+
id?: string;
|
|
776
|
+
reason?: string;
|
|
777
|
+
}
|
|
778
|
+
export type AgentRunInput<TModel extends LanguageModel = LanguageModel> = RetryOptions & GenerateInputSource & {
|
|
779
|
+
runId?: string;
|
|
780
|
+
state?: AgentRunState;
|
|
781
|
+
approvals?: AgentApprovalResponse[];
|
|
782
|
+
handoff?: AgentHandoff;
|
|
783
|
+
system?: string;
|
|
784
|
+
tools?: ToolCollection;
|
|
785
|
+
toolChoice?: ToolChoice;
|
|
786
|
+
toolExecution?: ToolExecutionOptions;
|
|
787
|
+
toolApprovalPolicy?: ToolApprovalPolicy;
|
|
788
|
+
maxSteps?: number;
|
|
789
|
+
temperature?: number;
|
|
790
|
+
maxTokens?: number;
|
|
791
|
+
reasoning?: ReasoningConfig;
|
|
792
|
+
providerOptions?: ProviderOptionsOf<TModel>;
|
|
793
|
+
metadata?: Record<string, JsonValue>;
|
|
794
|
+
};
|
|
795
|
+
export interface AgentRunOutput {
|
|
796
|
+
status: AgentStatus;
|
|
797
|
+
outputText: string;
|
|
798
|
+
finishReason?: FinishReason;
|
|
799
|
+
providerFinishReason?: string;
|
|
800
|
+
usage?: TokenUsage;
|
|
801
|
+
messages: ModelMessage[];
|
|
802
|
+
steps: AgentStep[];
|
|
803
|
+
toolResults: ToolExecutionResult[];
|
|
804
|
+
state: AgentRunState;
|
|
805
|
+
error?: {
|
|
806
|
+
message: string;
|
|
807
|
+
};
|
|
808
|
+
}
|
|
809
|
+
export type LiveAgentRunInput = GenerateInputSource & RetryOptions & {
|
|
810
|
+
runId?: string;
|
|
811
|
+
system?: string;
|
|
812
|
+
tools?: ToolCollection;
|
|
813
|
+
toolChoice?: ToolChoice;
|
|
814
|
+
toolExecution?: ToolExecutionOptions;
|
|
815
|
+
toolApprovalPolicy?: ToolApprovalPolicy;
|
|
816
|
+
providerOptions?: ProviderOptions;
|
|
817
|
+
metadata?: Record<string, JsonValue>;
|
|
818
|
+
realtime?: RealtimeSessionConfig;
|
|
819
|
+
connectOptions?: RealtimeConnectOptions;
|
|
820
|
+
};
|
|
821
|
+
export interface LiveAgentRunOutput {
|
|
822
|
+
status: AgentStatus;
|
|
823
|
+
outputText: string;
|
|
824
|
+
messages: ModelMessage[];
|
|
825
|
+
toolResults: ToolExecutionResult[];
|
|
826
|
+
state: AgentRunState;
|
|
827
|
+
error?: {
|
|
828
|
+
message: string;
|
|
829
|
+
};
|
|
830
|
+
}
|
|
831
|
+
export interface AgentStreamResult {
|
|
832
|
+
eventStream: AsyncIterable<AgentStreamEvent>;
|
|
833
|
+
textStream: AsyncIterable<string>;
|
|
834
|
+
collect: () => Promise<AgentRunOutput>;
|
|
835
|
+
}
|
|
836
|
+
export type AgentLiveEvent = AgentStreamEvent | RealtimeEvent;
|
|
837
|
+
export interface AgentLiveStreamResult {
|
|
838
|
+
eventStream: AsyncIterable<AgentLiveEvent>;
|
|
839
|
+
textStream: AsyncIterable<string>;
|
|
840
|
+
session: Promise<RealtimeSession>;
|
|
841
|
+
collect: () => Promise<LiveAgentRunOutput>;
|
|
842
|
+
}
|
|
325
843
|
export type TranscribeAudioOptions<TModel extends TranscriptionModel = TranscriptionModel> = RetryOptions & {
|
|
326
844
|
model: TModel;
|
|
327
845
|
audio: AudioInput;
|
|
@@ -500,6 +1018,13 @@ export interface UIMessageToolResultChunk {
|
|
|
500
1018
|
role: "tool";
|
|
501
1019
|
toolResult: ToolExecutionResult;
|
|
502
1020
|
}
|
|
1021
|
+
export interface UIMessageProviderDataChunk {
|
|
1022
|
+
type: "provider-data";
|
|
1023
|
+
messageId: string;
|
|
1024
|
+
role: "assistant";
|
|
1025
|
+
provider: string;
|
|
1026
|
+
data: JsonValue;
|
|
1027
|
+
}
|
|
503
1028
|
export interface UIMessageFinishChunk {
|
|
504
1029
|
type: "finish";
|
|
505
1030
|
messageId: string;
|
|
@@ -514,7 +1039,33 @@ export interface UIMessageErrorChunk {
|
|
|
514
1039
|
message: string;
|
|
515
1040
|
};
|
|
516
1041
|
}
|
|
517
|
-
export
|
|
1042
|
+
export interface UIAgentRunStartChunk {
|
|
1043
|
+
type: "agent-run-start";
|
|
1044
|
+
currentStep: number;
|
|
1045
|
+
maxSteps: number;
|
|
1046
|
+
}
|
|
1047
|
+
export interface UIAgentStepStartChunk {
|
|
1048
|
+
type: "agent-step-start";
|
|
1049
|
+
stepIndex: number;
|
|
1050
|
+
}
|
|
1051
|
+
export interface UIAgentStepFinishChunk {
|
|
1052
|
+
type: "agent-step-finish";
|
|
1053
|
+
step: AgentStep;
|
|
1054
|
+
}
|
|
1055
|
+
export interface UIAgentApprovalRequestChunk {
|
|
1056
|
+
type: "agent-approval-request";
|
|
1057
|
+
approval: AgentApprovalRequest;
|
|
1058
|
+
}
|
|
1059
|
+
export interface UIAgentApprovalResolvedChunk {
|
|
1060
|
+
type: "agent-approval-resolved";
|
|
1061
|
+
approval: AgentApprovalResponse;
|
|
1062
|
+
}
|
|
1063
|
+
export interface UIAgentRunFinishChunk {
|
|
1064
|
+
type: "agent-run-finish";
|
|
1065
|
+
status: AgentStatus;
|
|
1066
|
+
state: AgentRunState;
|
|
1067
|
+
}
|
|
1068
|
+
export type UIMessageChunk = UIMessageTextChunk | UIMessageToolCallChunk | UIMessageToolResultChunk | UIMessageProviderDataChunk | UIMessageFinishChunk | UIMessageErrorChunk | UIAgentRunStartChunk | UIAgentStepStartChunk | UIAgentStepFinishChunk | UIAgentApprovalRequestChunk | UIAgentApprovalResolvedChunk | UIAgentRunFinishChunk;
|
|
518
1069
|
export interface EmbedInput {
|
|
519
1070
|
values: string[];
|
|
520
1071
|
}
|
|
@@ -525,466 +1076,4 @@ export interface EmbedOptions extends RetryOptions {
|
|
|
525
1076
|
export interface EmbedOutput extends EmbedResult {
|
|
526
1077
|
values: string[];
|
|
527
1078
|
}
|
|
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
1079
|
//# sourceMappingURL=types.d.ts.map
|