@openai/agents-realtime 0.0.16 → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bundle/openai-realtime-agents.mjs +5564 -5299
- package/dist/bundle/openai-realtime-agents.umd.js +7 -7
- package/dist/clientMessages.d.ts +89 -13
- package/dist/clientMessages.js +93 -1
- package/dist/clientMessages.js.map +1 -1
- package/dist/clientMessages.mjs +89 -1
- package/dist/clientMessages.mjs.map +1 -1
- package/dist/guardrail.js +10 -5
- package/dist/guardrail.js.map +1 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.js +60 -8
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1 -0
- package/dist/index.mjs.map +1 -1
- package/dist/items.d.ts +65 -16
- package/dist/items.js +58 -38
- package/dist/items.js.map +1 -1
- package/dist/items.mjs +21 -4
- package/dist/items.mjs.map +1 -1
- package/dist/logger.js +5 -3
- package/dist/logger.js.map +1 -1
- package/dist/metadata.d.ts +0 -1
- package/dist/metadata.js +8 -6
- package/dist/metadata.js.map +1 -1
- package/dist/metadata.mjs +3 -4
- package/dist/metadata.mjs.map +1 -1
- package/dist/openaiRealtimeBase.d.ts +12 -25
- package/dist/openaiRealtimeBase.js +234 -84
- package/dist/openaiRealtimeBase.js.map +1 -1
- package/dist/openaiRealtimeBase.mjs +203 -60
- package/dist/openaiRealtimeBase.mjs.map +1 -1
- package/dist/openaiRealtimeEvents.d.ts +2464 -649
- package/dist/openaiRealtimeEvents.js +477 -384
- package/dist/openaiRealtimeEvents.js.map +1 -1
- package/dist/openaiRealtimeEvents.mjs +116 -28
- package/dist/openaiRealtimeEvents.mjs.map +1 -1
- package/dist/openaiRealtimeWebRtc.js +22 -21
- package/dist/openaiRealtimeWebRtc.js.map +1 -1
- package/dist/openaiRealtimeWebRtc.mjs +4 -10
- package/dist/openaiRealtimeWebRtc.mjs.map +1 -1
- package/dist/openaiRealtimeWebsocket.js +51 -26
- package/dist/openaiRealtimeWebsocket.js.map +1 -1
- package/dist/openaiRealtimeWebsocket.mjs +32 -11
- package/dist/openaiRealtimeWebsocket.mjs.map +1 -1
- package/dist/realtimeAgent.d.ts +1 -1
- package/dist/realtimeAgent.js +7 -3
- package/dist/realtimeAgent.js.map +1 -1
- package/dist/realtimeAgent.mjs +1 -1
- package/dist/realtimeAgent.mjs.map +1 -1
- package/dist/realtimeSession.d.ts +15 -3
- package/dist/realtimeSession.js +160 -40
- package/dist/realtimeSession.js.map +1 -1
- package/dist/realtimeSession.mjs +124 -11
- package/dist/realtimeSession.mjs.map +1 -1
- package/dist/realtimeSessionEvents.d.ts +21 -2
- package/dist/realtimeSessionEvents.js +2 -1
- package/dist/shims/shims-browser.js +7 -3
- package/dist/shims/shims-browser.js.map +1 -1
- package/dist/shims/shims-node.js +8 -3
- package/dist/shims/shims-node.js.map +1 -1
- package/dist/shims/shims-workerd.js +7 -3
- package/dist/shims/shims-workerd.js.map +1 -1
- package/dist/shims/shims.js +17 -1
- package/dist/shims/shims.js.map +1 -1
- package/dist/tool.d.ts +13 -0
- package/dist/tool.js +44 -0
- package/dist/tool.js.map +1 -0
- package/dist/tool.mjs +37 -0
- package/dist/tool.mjs.map +1 -0
- package/dist/transportLayer.d.ts +21 -2
- package/dist/transportLayer.js +2 -1
- package/dist/transportLayerEvents.d.ts +19 -1
- package/dist/transportLayerEvents.js +2 -1
- package/dist/utils.d.ts +5 -1
- package/dist/utils.js +59 -15
- package/dist/utils.js.map +1 -1
- package/dist/utils.mjs +32 -3
- package/dist/utils.mjs.map +1 -1
- package/package.json +20 -23
package/dist/clientMessages.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { JsonObjectSchema, ModelSettingsToolChoice } from '@openai/agents-core/types';
|
|
1
|
+
import { JsonObjectSchema, ModelSettingsToolChoice, Prompt } from '@openai/agents-core/types';
|
|
2
2
|
export type RealtimeClientMessage = {
|
|
3
3
|
type: string;
|
|
4
4
|
[key: string]: any;
|
|
@@ -6,12 +6,28 @@ export type RealtimeClientMessage = {
|
|
|
6
6
|
export type RealtimeUserInput = string | {
|
|
7
7
|
type: 'message';
|
|
8
8
|
role: 'user';
|
|
9
|
-
content: {
|
|
9
|
+
content: ({
|
|
10
10
|
type: 'input_text';
|
|
11
11
|
text: string;
|
|
12
|
-
}
|
|
12
|
+
} | {
|
|
13
|
+
type: 'input_image';
|
|
14
|
+
image: string;
|
|
15
|
+
providerData?: Record<string, any>;
|
|
16
|
+
})[];
|
|
13
17
|
};
|
|
14
|
-
export type
|
|
18
|
+
export type RealtimeAudioFormatDefinition = {
|
|
19
|
+
type: 'audio/pcm';
|
|
20
|
+
rate: number;
|
|
21
|
+
} | {
|
|
22
|
+
type: 'audio/pcmu';
|
|
23
|
+
} | {
|
|
24
|
+
type: 'audio/pcma';
|
|
25
|
+
};
|
|
26
|
+
/**
|
|
27
|
+
* @deprecated Use a {type: "audio/pcm"} format instead. String shorthands are deprecated.
|
|
28
|
+
*/
|
|
29
|
+
export type RealtimeAudioFormatLegacy = 'pcm16' | 'g711_ulaw' | 'g711_alaw' | (string & {});
|
|
30
|
+
export type RealtimeAudioFormat = RealtimeAudioFormatLegacy | RealtimeAudioFormatDefinition;
|
|
15
31
|
export type RealtimeTracingConfig = {
|
|
16
32
|
workflow_name?: string;
|
|
17
33
|
group_id?: string;
|
|
@@ -26,40 +42,79 @@ export type RealtimeInputAudioTranscriptionConfig = {
|
|
|
26
42
|
prompt?: string;
|
|
27
43
|
};
|
|
28
44
|
export type RealtimeTurnDetectionConfigAsIs = {
|
|
29
|
-
type?: 'semantic_vad' | 'server_vad';
|
|
45
|
+
type?: 'semantic_vad' | 'server_vad' | (string & {});
|
|
30
46
|
create_response?: boolean;
|
|
31
47
|
eagerness?: 'auto' | 'low' | 'medium' | 'high';
|
|
32
48
|
interrupt_response?: boolean;
|
|
33
49
|
prefix_padding_ms?: number;
|
|
34
50
|
silence_duration_ms?: number;
|
|
35
51
|
threshold?: number;
|
|
52
|
+
idle_timeout_ms?: number;
|
|
36
53
|
};
|
|
37
54
|
export type RealtimeTurnDetectionConfigCamelCase = {
|
|
38
|
-
type?: 'semantic_vad' | 'server_vad';
|
|
55
|
+
type?: 'semantic_vad' | 'server_vad' | (string & {});
|
|
39
56
|
createResponse?: boolean;
|
|
40
57
|
eagerness?: 'auto' | 'low' | 'medium' | 'high';
|
|
41
58
|
interruptResponse?: boolean;
|
|
42
59
|
prefixPaddingMs?: number;
|
|
43
60
|
silenceDurationMs?: number;
|
|
44
61
|
threshold?: number;
|
|
62
|
+
idleTimeoutMs?: number;
|
|
45
63
|
};
|
|
46
64
|
export type RealtimeTurnDetectionConfig = (RealtimeTurnDetectionConfigAsIs | RealtimeTurnDetectionConfigCamelCase) & Record<string, any>;
|
|
47
|
-
export type
|
|
65
|
+
export type RealtimeAudioInputConfig = {
|
|
66
|
+
format?: RealtimeAudioFormat;
|
|
67
|
+
noiseReduction?: RealtimeInputAudioNoiseReductionConfig | null;
|
|
68
|
+
transcription?: RealtimeInputAudioTranscriptionConfig;
|
|
69
|
+
turnDetection?: RealtimeTurnDetectionConfig;
|
|
70
|
+
};
|
|
71
|
+
export type RealtimeAudioOutputConfig = {
|
|
72
|
+
format?: RealtimeAudioFormat;
|
|
73
|
+
voice?: string;
|
|
74
|
+
speed?: number;
|
|
75
|
+
};
|
|
76
|
+
export type RealtimeAudioConfig = {
|
|
77
|
+
input?: RealtimeAudioInputConfig;
|
|
78
|
+
output?: RealtimeAudioOutputConfig;
|
|
79
|
+
};
|
|
80
|
+
export type RealtimeSessionConfigCommon = {
|
|
48
81
|
model: string;
|
|
49
82
|
instructions: string;
|
|
83
|
+
toolChoice: ModelSettingsToolChoice;
|
|
84
|
+
tools: RealtimeToolDefinition[];
|
|
85
|
+
tracing?: RealtimeTracingConfig | null;
|
|
86
|
+
providerData?: Record<string, any>;
|
|
87
|
+
prompt?: Prompt;
|
|
88
|
+
};
|
|
89
|
+
export type RealtimeSessionConfigDefinition = RealtimeSessionConfigCommon & {
|
|
90
|
+
outputModalities?: ('text' | 'audio')[];
|
|
91
|
+
audio?: RealtimeAudioConfig;
|
|
92
|
+
};
|
|
93
|
+
export type RealtimeSessionConfigDeprecated = RealtimeSessionConfigCommon & {
|
|
94
|
+
/** @deprecated Use outputModalities instead. */
|
|
50
95
|
modalities: ('text' | 'audio')[];
|
|
96
|
+
/** @deprecated Use audio.output.voice instead. */
|
|
51
97
|
voice: string;
|
|
52
|
-
|
|
53
|
-
|
|
98
|
+
/** @deprecated Use audio.input.format instead. */
|
|
99
|
+
inputAudioFormat: RealtimeAudioFormatLegacy;
|
|
100
|
+
/** @deprecated Use audio.output.format instead. */
|
|
101
|
+
outputAudioFormat: RealtimeAudioFormatLegacy;
|
|
102
|
+
/** @deprecated Use audio.input.transcription instead. */
|
|
54
103
|
inputAudioTranscription: RealtimeInputAudioTranscriptionConfig;
|
|
104
|
+
/** @deprecated Use audio.input.turnDetection instead. */
|
|
55
105
|
turnDetection: RealtimeTurnDetectionConfig;
|
|
56
|
-
|
|
57
|
-
tools: FunctionToolDefinition[];
|
|
58
|
-
tracing?: RealtimeTracingConfig | null;
|
|
59
|
-
providerData?: Record<string, any>;
|
|
106
|
+
/** @deprecated Use audio.input.noiseReduction instead. */
|
|
60
107
|
inputAudioNoiseReduction: RealtimeInputAudioNoiseReductionConfig | null;
|
|
108
|
+
/** @deprecated Use audio.output.speed instead. */
|
|
61
109
|
speed: number;
|
|
62
110
|
};
|
|
111
|
+
export type RealtimeSessionConfig = RealtimeSessionConfigDefinition | RealtimeSessionConfigDeprecated;
|
|
112
|
+
/**
|
|
113
|
+
* Convert any given config (old or new) to the new GA config shape.
|
|
114
|
+
* If a new config is provided, it will be returned as-is (normalized shallowly).
|
|
115
|
+
*/
|
|
116
|
+
export declare function toNewSessionConfig(config: Partial<RealtimeSessionConfig>): Partial<RealtimeSessionConfigDefinition>;
|
|
117
|
+
export declare function normalizeAudioFormat(format?: RealtimeAudioFormat | undefined): RealtimeAudioFormatDefinition | undefined;
|
|
63
118
|
export type FunctionToolDefinition = {
|
|
64
119
|
type: 'function';
|
|
65
120
|
name: string;
|
|
@@ -67,3 +122,24 @@ export type FunctionToolDefinition = {
|
|
|
67
122
|
parameters: JsonObjectSchema<any>;
|
|
68
123
|
strict: boolean;
|
|
69
124
|
};
|
|
125
|
+
export type HostedToolFilter = {
|
|
126
|
+
tool_names?: string[];
|
|
127
|
+
};
|
|
128
|
+
export type HostedMCPToolDefinition = {
|
|
129
|
+
type: 'mcp';
|
|
130
|
+
server_label: string;
|
|
131
|
+
server_url?: string;
|
|
132
|
+
headers?: Record<string, string>;
|
|
133
|
+
allowed_tools?: string[] | HostedToolFilter;
|
|
134
|
+
require_approval?: 'never' | 'always' | {
|
|
135
|
+
never?: HostedToolFilter;
|
|
136
|
+
always?: HostedToolFilter;
|
|
137
|
+
};
|
|
138
|
+
};
|
|
139
|
+
export type RealtimeToolDefinition = FunctionToolDefinition | HostedMCPToolDefinition;
|
|
140
|
+
export type RealtimeMcpToolInfo = {
|
|
141
|
+
name: string;
|
|
142
|
+
description?: string;
|
|
143
|
+
input_schema?: Record<string, any>;
|
|
144
|
+
[key: string]: any;
|
|
145
|
+
};
|
package/dist/clientMessages.js
CHANGED
|
@@ -1,2 +1,94 @@
|
|
|
1
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.toNewSessionConfig = toNewSessionConfig;
|
|
4
|
+
exports.normalizeAudioFormat = normalizeAudioFormat;
|
|
5
|
+
function isDefined(key, object) {
|
|
6
|
+
// @ts-expect-error fudging with types here for the index types
|
|
7
|
+
return key in object && typeof object[key] !== 'undefined';
|
|
8
|
+
}
|
|
9
|
+
function isDeprecatedConfig(config) {
|
|
10
|
+
return (isDefined('modalities', config) ||
|
|
11
|
+
isDefined('voice', config) ||
|
|
12
|
+
isDefined('inputAudioFormat', config) ||
|
|
13
|
+
isDefined('outputAudioFormat', config) ||
|
|
14
|
+
isDefined('inputAudioTranscription', config) ||
|
|
15
|
+
isDefined('turnDetection', config) ||
|
|
16
|
+
isDefined('inputAudioNoiseReduction', config) ||
|
|
17
|
+
isDefined('speed', config));
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Convert any given config (old or new) to the new GA config shape.
|
|
21
|
+
* If a new config is provided, it will be returned as-is (normalized shallowly).
|
|
22
|
+
*/
|
|
23
|
+
function toNewSessionConfig(config) {
|
|
24
|
+
if (!isDeprecatedConfig(config)) {
|
|
25
|
+
return {
|
|
26
|
+
model: config.model,
|
|
27
|
+
instructions: config.instructions,
|
|
28
|
+
toolChoice: config.toolChoice,
|
|
29
|
+
tools: config.tools,
|
|
30
|
+
tracing: config.tracing,
|
|
31
|
+
providerData: config.providerData,
|
|
32
|
+
prompt: config.prompt,
|
|
33
|
+
outputModalities: config.outputModalities,
|
|
34
|
+
audio: config.audio
|
|
35
|
+
? {
|
|
36
|
+
input: config.audio.input
|
|
37
|
+
? {
|
|
38
|
+
format: normalizeAudioFormat(config.audio.input.format),
|
|
39
|
+
noiseReduction: config.audio.input.noiseReduction ?? null,
|
|
40
|
+
transcription: config.audio.input.transcription,
|
|
41
|
+
turnDetection: config.audio.input.turnDetection,
|
|
42
|
+
}
|
|
43
|
+
: undefined,
|
|
44
|
+
output: config.audio.output
|
|
45
|
+
? {
|
|
46
|
+
format: normalizeAudioFormat(config.audio.output.format),
|
|
47
|
+
voice: config.audio.output.voice,
|
|
48
|
+
speed: config.audio.output.speed,
|
|
49
|
+
}
|
|
50
|
+
: undefined,
|
|
51
|
+
}
|
|
52
|
+
: undefined,
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
return {
|
|
56
|
+
model: config.model,
|
|
57
|
+
instructions: config.instructions,
|
|
58
|
+
toolChoice: config.toolChoice,
|
|
59
|
+
tools: config.tools,
|
|
60
|
+
tracing: config.tracing,
|
|
61
|
+
providerData: config.providerData,
|
|
62
|
+
prompt: config.prompt,
|
|
63
|
+
outputModalities: config.modalities,
|
|
64
|
+
audio: {
|
|
65
|
+
input: {
|
|
66
|
+
format: normalizeAudioFormat(config.inputAudioFormat),
|
|
67
|
+
noiseReduction: config.inputAudioNoiseReduction ?? null,
|
|
68
|
+
transcription: config.inputAudioTranscription,
|
|
69
|
+
turnDetection: config.turnDetection,
|
|
70
|
+
},
|
|
71
|
+
output: {
|
|
72
|
+
format: normalizeAudioFormat(config.outputAudioFormat),
|
|
73
|
+
voice: config.voice,
|
|
74
|
+
speed: config.speed,
|
|
75
|
+
},
|
|
76
|
+
},
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
function normalizeAudioFormat(format) {
|
|
80
|
+
if (!format)
|
|
81
|
+
return undefined;
|
|
82
|
+
if (typeof format === 'object')
|
|
83
|
+
return format;
|
|
84
|
+
const f = String(format);
|
|
85
|
+
if (f === 'pcm16')
|
|
86
|
+
return { type: 'audio/pcm', rate: 24000 };
|
|
87
|
+
if (f === 'g711_ulaw')
|
|
88
|
+
return { type: 'audio/pcmu' };
|
|
89
|
+
if (f === 'g711_alaw')
|
|
90
|
+
return { type: 'audio/pcma' };
|
|
91
|
+
// Default fallback: assume 24kHz PCM if unknown string
|
|
92
|
+
return { type: 'audio/pcm', rate: 24000 };
|
|
93
|
+
}
|
|
2
94
|
//# sourceMappingURL=clientMessages.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"clientMessages.js","sourceRoot":"","sources":["../src/clientMessages.ts"],"names":[],"mappings":""}
|
|
1
|
+
{"version":3,"file":"clientMessages.js","sourceRoot":"","sources":["../src/clientMessages.ts"],"names":[],"mappings":";;AA+LA,gDA0DC;AAED,oDAYC;AArGD,SAAS,SAAS,CAChB,GAEyC,EACzC,MAAsC;IAEtC,+DAA+D;IAC/D,OAAO,GAAG,IAAI,MAAM,IAAI,OAAO,MAAM,CAAC,GAAG,CAAC,KAAK,WAAW,CAAC;AAC7D,CAAC;AAED,SAAS,kBAAkB,CACzB,MAAsC;IAEtC,OAAO,CACL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AC,MAAM,CAAC,CAAC;IACzB,IAAI,CAAC,KAAK,OAAO;QAAE,OAAO,EAAE,IAAI,EAAE,WAAW,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC;IAC7D,IAAI,CAAC,KAAK,WAAW;QAAE,OAAO,EAAE,IAAI,EAAE,YAAY,EAAE,CAAC;IACrD,IAAI,CAAC,KAAK,WAAW;QAAE,OAAO,EAAE,IAAI,EAAE,YAAY,EAAE,CAAC;IACrD,uDAAuD;IACvD,OAAO,EAAE,IAAI,EAAE,WAAW,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC;AAC5C,CAAC"}
|
package/dist/clientMessages.mjs
CHANGED
|
@@ -1,2 +1,90 @@
|
|
|
1
|
-
|
|
1
|
+
function isDefined(key, object) {
|
|
2
|
+
// @ts-expect-error fudging with types here for the index types
|
|
3
|
+
return key in object && typeof object[key] !== 'undefined';
|
|
4
|
+
}
|
|
5
|
+
function isDeprecatedConfig(config) {
|
|
6
|
+
return (isDefined('modalities', config) ||
|
|
7
|
+
isDefined('voice', config) ||
|
|
8
|
+
isDefined('inputAudioFormat', config) ||
|
|
9
|
+
isDefined('outputAudioFormat', config) ||
|
|
10
|
+
isDefined('inputAudioTranscription', config) ||
|
|
11
|
+
isDefined('turnDetection', config) ||
|
|
12
|
+
isDefined('inputAudioNoiseReduction', config) ||
|
|
13
|
+
isDefined('speed', config));
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Convert any given config (old or new) to the new GA config shape.
|
|
17
|
+
* If a new config is provided, it will be returned as-is (normalized shallowly).
|
|
18
|
+
*/
|
|
19
|
+
export function toNewSessionConfig(config) {
|
|
20
|
+
if (!isDeprecatedConfig(config)) {
|
|
21
|
+
return {
|
|
22
|
+
model: config.model,
|
|
23
|
+
instructions: config.instructions,
|
|
24
|
+
toolChoice: config.toolChoice,
|
|
25
|
+
tools: config.tools,
|
|
26
|
+
tracing: config.tracing,
|
|
27
|
+
providerData: config.providerData,
|
|
28
|
+
prompt: config.prompt,
|
|
29
|
+
outputModalities: config.outputModalities,
|
|
30
|
+
audio: config.audio
|
|
31
|
+
? {
|
|
32
|
+
input: config.audio.input
|
|
33
|
+
? {
|
|
34
|
+
format: normalizeAudioFormat(config.audio.input.format),
|
|
35
|
+
noiseReduction: config.audio.input.noiseReduction ?? null,
|
|
36
|
+
transcription: config.audio.input.transcription,
|
|
37
|
+
turnDetection: config.audio.input.turnDetection,
|
|
38
|
+
}
|
|
39
|
+
: undefined,
|
|
40
|
+
output: config.audio.output
|
|
41
|
+
? {
|
|
42
|
+
format: normalizeAudioFormat(config.audio.output.format),
|
|
43
|
+
voice: config.audio.output.voice,
|
|
44
|
+
speed: config.audio.output.speed,
|
|
45
|
+
}
|
|
46
|
+
: undefined,
|
|
47
|
+
}
|
|
48
|
+
: undefined,
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
return {
|
|
52
|
+
model: config.model,
|
|
53
|
+
instructions: config.instructions,
|
|
54
|
+
toolChoice: config.toolChoice,
|
|
55
|
+
tools: config.tools,
|
|
56
|
+
tracing: config.tracing,
|
|
57
|
+
providerData: config.providerData,
|
|
58
|
+
prompt: config.prompt,
|
|
59
|
+
outputModalities: config.modalities,
|
|
60
|
+
audio: {
|
|
61
|
+
input: {
|
|
62
|
+
format: normalizeAudioFormat(config.inputAudioFormat),
|
|
63
|
+
noiseReduction: config.inputAudioNoiseReduction ?? null,
|
|
64
|
+
transcription: config.inputAudioTranscription,
|
|
65
|
+
turnDetection: config.turnDetection,
|
|
66
|
+
},
|
|
67
|
+
output: {
|
|
68
|
+
format: normalizeAudioFormat(config.outputAudioFormat),
|
|
69
|
+
voice: config.voice,
|
|
70
|
+
speed: config.speed,
|
|
71
|
+
},
|
|
72
|
+
},
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
export function normalizeAudioFormat(format) {
|
|
76
|
+
if (!format)
|
|
77
|
+
return undefined;
|
|
78
|
+
if (typeof format === 'object')
|
|
79
|
+
return format;
|
|
80
|
+
const f = String(format);
|
|
81
|
+
if (f === 'pcm16')
|
|
82
|
+
return { type: 'audio/pcm', rate: 24000 };
|
|
83
|
+
if (f === 'g711_ulaw')
|
|
84
|
+
return { type: 'audio/pcmu' };
|
|
85
|
+
if (f === 'g711_alaw')
|
|
86
|
+
return { type: 'audio/pcma' };
|
|
87
|
+
// Default fallback: assume 24kHz PCM if unknown string
|
|
88
|
+
return { type: 'audio/pcm', rate: 24000 };
|
|
89
|
+
}
|
|
2
90
|
//# sourceMappingURL=clientMessages.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"clientMessages.mjs","sourceRoot":"","sources":["../src/clientMessages.ts"],"names":[],"mappings":""}
|
|
1
|
+
{"version":3,"file":"clientMessages.mjs","sourceRoot":"","sources":["../src/clientMessages.ts"],"names":[],"mappings":"AAkKA,SAAS,SAAS,CAChB,GAEyC,EACzC,MAAsC;IAEtC,+DAA+D;IAC/D,OAAO,GAAG,IAAI,MAAM,IAAI,OAAO,MAAM,CAAC,GAAG,CAAC,KAAK,WAAW,CAAC;AAC7D,CAAC;AAED,SAAS,kBAAkB,CACzB,MAAsC;IAEtC,OAAO,CACL,SAAS,CAAC,YAAY,EAAE,MAAM,CAAC;QAC/B,SAAS,CAAC,OAAO,EAAE,MAAM,CAAC;QAC1B,SAAS,CAAC,kBAAkB,EAAE,MAAM,CAAC;QACrC,SAAS,CAAC,mBAAmB,EAAE,MAAM,CAAC;QACtC,SAAS,CAAC,yBAAyB,EAAE,MAAM,CAAC;QAC5C,SAAS,CAAC,eAAe,EAAE,MAAM,CAAC;QAClC,SAAS,CAAC,0BAA0B,EAAE,MAAM,CAAC;QAC7C,SAAS,CAAC,OAAO,EAAE,MAAM,CAAC,CAC3B,CAAC;AACJ,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,kBAAkB,CAChC,MAAsC;IAEtC,IAAI,CAAC,kBAAkB,CAAC,MAAM,CAAC,EAAE,CAAC;QAChC,OAAO;YACL,KAAK,EAA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exports, "__esModule", { value: true });
|
|
3
|
+
exports.getRealtimeGuardrailSettings = getRealtimeGuardrailSettings;
|
|
4
|
+
exports.defineRealtimeOutputGuardrail = defineRealtimeOutputGuardrail;
|
|
5
|
+
exports.getRealtimeGuardrailFeedbackMessage = getRealtimeGuardrailFeedbackMessage;
|
|
6
|
+
const agents_core_1 = require("@openai/agents-core");
|
|
7
|
+
function getRealtimeGuardrailSettings(settings) {
|
|
3
8
|
return {
|
|
4
9
|
debounceTextLength: settings.debounceTextLength ?? 100,
|
|
5
10
|
};
|
|
6
11
|
}
|
|
7
|
-
|
|
8
|
-
const baseGuardrail = defineOutputGuardrail(options);
|
|
12
|
+
function defineRealtimeOutputGuardrail({ policyHint: policyHintInput, ...options }) {
|
|
13
|
+
const baseGuardrail = (0, agents_core_1.defineOutputGuardrail)(options);
|
|
9
14
|
const policyHint = policyHintInput ?? baseGuardrail.name;
|
|
10
15
|
return {
|
|
11
16
|
...baseGuardrail,
|
|
@@ -23,7 +28,7 @@ export function defineRealtimeOutputGuardrail({ policyHint: policyHintInput, ...
|
|
|
23
28
|
* Generates a message that informs the model about why the guardrail was triggered and to
|
|
24
29
|
* correct the behavior.
|
|
25
30
|
*/
|
|
26
|
-
|
|
31
|
+
function getRealtimeGuardrailFeedbackMessage(result) {
|
|
27
32
|
return `
|
|
28
33
|
⚠️ Your last answer was blocked.
|
|
29
34
|
Failed Guardrail Reason: ${result.guardrail.policyHint}.
|
package/dist/guardrail.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"guardrail.js","sourceRoot":"","sources":["../src/guardrail.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"guardrail.js","sourceRoot":"","sources":["../src/guardrail.ts"],"names":[],"mappings":";;AAqBA,oEAMC;AAsBD,sEAiBC;AAMD,kFASC;AAjFD,qDAO6B;AAc7B,SAAgB,4BAA4B,CAC1C,QAAkD;IAElD,OAAO;QACL,kBAAkB,EAAE,QAAQ,CAAC,kBAAkB,IAAI,GAAG;KACvD,CAAC;AACJ,CAAC;AAsBD,SAAgB,6BAA6B,CAAC,EAC5C,UAAU,EAAE,eAAe,EAC3B,GAAG,OAAO,EACc;IACxB,MAAM,aAAa,GAAG,IAAA,mCAAqB,EAAC,OAAO,CAAC,CAAC;IACrD,MAAM,UAAU,GAAG,eAAe,IAAI,aAAa,CAAC,IAAI,CAAC;IACzD,OAAO;QACL,GAAG,aAAa;QAChB,UAAU;QACV,GAAG,EAAE,KAAK,EAAE,IAAI,EAAE,EAAE;YAClB,MAAM,MAAM,GAAG,MAAM,aAAa,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;YAC7C,OAAO;gBACL,GAAG,MAAM;gBACT,SAAS,EAAE,EAAE,GAAG,MAAM,CAAC,SAAS,EAAE,UAAU,EAAE;aAC/C,CAAC;QACJ,CAAC;KACF,CAAC;AACJ,CAAC;AAED;;;GAGG;AACH,SAAgB,mCAAmC,CACjD,MAAwD;IAExD,OAAO;;2BAEkB,MAAM,CAAC,SAAS,CAAC,UAAU;mBACnC,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,MAAM,CAAC,UAAU,IAAI,EAAE,CAAC;;CAEhE,CAAC,IAAI,EAAE,CAAC;AACT,CAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -8,7 +8,7 @@ export { OpenAIRealtimeWebRTC, OpenAIRealtimeWebRTCOptions, WebRTCState, } from
|
|
|
8
8
|
export { OpenAIRealtimeWebSocket, OpenAIRealtimeWebSocketOptions, WebSocketState, } from './openaiRealtimeWebsocket';
|
|
9
9
|
export { OpenAIRealtimeModels, OpenAIRealtimeBase, OpenAIRealtimeBaseOptions, OpenAIRealtimeEventTypes, DEFAULT_OPENAI_REALTIME_MODEL, DEFAULT_OPENAI_REALTIME_SESSION_CONFIG, } from './openaiRealtimeBase';
|
|
10
10
|
export { RealtimeOutputGuardrail } from './guardrail';
|
|
11
|
-
export { RealtimeItem, RealtimeToolCallItem, RealtimeMessageItem, RealtimeBaseItem, } from './items';
|
|
11
|
+
export { RealtimeItem, RealtimeToolCallItem, RealtimeMessageItem, RealtimeBaseItem, RealtimeMcpCallItem, } from './items';
|
|
12
12
|
export { ApiKey, RealtimeTransportLayerConnectOptions, RealtimeTransportLayer, } from './transportLayer';
|
|
13
13
|
export declare const utils: {
|
|
14
14
|
base64ToArrayBuffer: typeof utilImport.base64ToArrayBuffer;
|
|
@@ -16,3 +16,4 @@ export declare const utils: {
|
|
|
16
16
|
getLastTextFromAudioOutputMessage: typeof utilImport.getLastTextFromAudioOutputMessage;
|
|
17
17
|
};
|
|
18
18
|
export { FunctionTool, ModelBehaviorError, OutputGuardrailTripwireTriggered, tool, UserError, } from '@openai/agents-core';
|
|
19
|
+
export { backgroundResult, isBackgroundResult } from './tool';
|
package/dist/index.js
CHANGED
|
@@ -1,13 +1,65 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.isBackgroundResult = exports.backgroundResult = exports.UserError = exports.tool = exports.OutputGuardrailTripwireTriggered = exports.ModelBehaviorError = exports.utils = exports.DEFAULT_OPENAI_REALTIME_SESSION_CONFIG = exports.DEFAULT_OPENAI_REALTIME_MODEL = exports.OpenAIRealtimeBase = exports.OpenAIRealtimeWebSocket = exports.OpenAIRealtimeWebRTC = exports.RealtimeSession = exports.RealtimeAgent = void 0;
|
|
37
|
+
const utilImport = __importStar(require("./utils.js"));
|
|
38
|
+
var realtimeAgent_1 = require("./realtimeAgent.js");
|
|
39
|
+
Object.defineProperty(exports, "RealtimeAgent", { enumerable: true, get: function () { return realtimeAgent_1.RealtimeAgent; } });
|
|
40
|
+
var realtimeSession_1 = require("./realtimeSession.js");
|
|
41
|
+
Object.defineProperty(exports, "RealtimeSession", { enumerable: true, get: function () { return realtimeSession_1.RealtimeSession; } });
|
|
42
|
+
var openaiRealtimeWebRtc_1 = require("./openaiRealtimeWebRtc.js");
|
|
43
|
+
Object.defineProperty(exports, "OpenAIRealtimeWebRTC", { enumerable: true, get: function () { return openaiRealtimeWebRtc_1.OpenAIRealtimeWebRTC; } });
|
|
44
|
+
var openaiRealtimeWebsocket_1 = require("./openaiRealtimeWebsocket.js");
|
|
45
|
+
Object.defineProperty(exports, "OpenAIRealtimeWebSocket", { enumerable: true, get: function () { return openaiRealtimeWebsocket_1.OpenAIRealtimeWebSocket; } });
|
|
46
|
+
var openaiRealtimeBase_1 = require("./openaiRealtimeBase.js");
|
|
47
|
+
Object.defineProperty(exports, "OpenAIRealtimeBase", { enumerable: true, get: function () { return openaiRealtimeBase_1.OpenAIRealtimeBase; } });
|
|
48
|
+
Object.defineProperty(exports, "DEFAULT_OPENAI_REALTIME_MODEL", { enumerable: true, get: function () { return openaiRealtimeBase_1.DEFAULT_OPENAI_REALTIME_MODEL; } });
|
|
49
|
+
Object.defineProperty(exports, "DEFAULT_OPENAI_REALTIME_SESSION_CONFIG", { enumerable: true, get: function () { return openaiRealtimeBase_1.DEFAULT_OPENAI_REALTIME_SESSION_CONFIG; } });
|
|
50
|
+
exports.utils = {
|
|
8
51
|
base64ToArrayBuffer: utilImport.base64ToArrayBuffer,
|
|
9
52
|
arrayBufferToBase64: utilImport.arrayBufferToBase64,
|
|
10
53
|
getLastTextFromAudioOutputMessage: utilImport.getLastTextFromAudioOutputMessage,
|
|
11
54
|
};
|
|
12
|
-
|
|
55
|
+
// Re-exporting some core functionalities requires for building front-end
|
|
56
|
+
// realtime agents
|
|
57
|
+
var agents_core_1 = require("@openai/agents-core");
|
|
58
|
+
Object.defineProperty(exports, "ModelBehaviorError", { enumerable: true, get: function () { return agents_core_1.ModelBehaviorError; } });
|
|
59
|
+
Object.defineProperty(exports, "OutputGuardrailTripwireTriggered", { enumerable: true, get: function () { return agents_core_1.OutputGuardrailTripwireTriggered; } });
|
|
60
|
+
Object.defineProperty(exports, "tool", { enumerable: true, get: function () { return agents_core_1.tool; } });
|
|
61
|
+
Object.defineProperty(exports, "UserError", { enumerable: true, get: function () { return agents_core_1.UserError; } });
|
|
62
|
+
var tool_1 = require("./tool.js");
|
|
63
|
+
Object.defineProperty(exports, "backgroundResult", { enumerable: true, get: function () { return tool_1.backgroundResult; } });
|
|
64
|
+
Object.defineProperty(exports, "isBackgroundResult", { enumerable: true, get: function () { return tool_1.isBackgroundResult; } });
|
|
13
65
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,uDAAsC;AAEtC,oDAA4E;AAAnE,8GAAA,aAAa,OAAA;AAEtB,wDAK2B;AAJzB,kHAAA,eAAe,OAAA;AAyBjB,kEAIgC;AAH9B,4HAAA,oBAAoB,OAAA;AAKtB,wEAImC;AAHjC,kIAAA,uBAAuB,OAAA;AAKzB,8DAO8B;AAL5B,wHAAA,kBAAkB,OAAA;AAGlB,mIAAA,6BAA6B,OAAA;AAC7B,4IAAA,sCAAsC,OAAA;AAmB3B,QAAA,KAAK,GAAG;IACnB,mBAAmB,EAAE,UAAU,CAAC,mBAAmB;IACnD,mBAAmB,EAAE,UAAU,CAAC,mBAAmB;IACnD,iCAAiC,EAC/B,UAAU,CAAC,iCAAiC;CAC/C,CAAC;AAEF,yEAAyE;AACzE,kBAAkB;AAClB,mDAM6B;AAJ3B,iHAAA,kBAAkB,OAAA;AAClB,+HAAA,gCAAgC,OAAA;AAChC,mGAAA,IAAI,OAAA;AACJ,wGAAA,SAAS,OAAA;AAGX,kCAA8D;AAArD,wGAAA,gBAAgB,OAAA;AAAE,0GAAA,kBAAkB,OAAA"}
|
package/dist/index.mjs
CHANGED
|
@@ -10,4 +10,5 @@ export const utils = {
|
|
|
10
10
|
getLastTextFromAudioOutputMessage: utilImport.getLastTextFromAudioOutputMessage,
|
|
11
11
|
};
|
|
12
12
|
export { ModelBehaviorError, OutputGuardrailTripwireTriggered, tool, UserError, } from '@openai/agents-core';
|
|
13
|
+
export { backgroundResult, isBackgroundResult } from "./tool.mjs";
|
|
13
14
|
//# sourceMappingURL=index.mjs.map
|
package/dist/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"OAAO,KAAK,UAAU;OAEf,EAAE,aAAa,EAA8B;OAE7C,EACL,eAAe,GAIhB;OAqBM,EACL,oBAAoB,GAGrB;OAEM,EACL,uBAAuB,GAGxB;OAEM,EAEL,kBAAkB,EAGlB,6BAA6B,EAC7B,sCAAsC,GACvC;
|
|
1
|
+
{"version":3,"file":"index.mjs","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"OAAO,KAAK,UAAU;OAEf,EAAE,aAAa,EAA8B;OAE7C,EACL,eAAe,GAIhB;OAqBM,EACL,oBAAoB,GAGrB;OAEM,EACL,uBAAuB,GAGxB;OAEM,EAEL,kBAAkB,EAGlB,6BAA6B,EAC7B,sCAAsC,GACvC;AAkBD,MAAM,CAAC,MAAM,KAAK,GAAG;IACnB,mBAAmB,EAAE,UAAU,CAAC,mBAAmB;IACnD,mBAAmB,EAAE,UAAU,CAAC,mBAAmB;IACnD,iCAAiC,EAC/B,UAAU,CAAC,iCAAiC;CAC/C,CAAC;OAIK,EAEL,kBAAkB,EAClB,gCAAgC,EAChC,IAAI,EACJ,SAAS,GACV,MAAM,qBAAqB;OAErB,EAAE,gBAAgB,EAAE,kBAAkB,EAAE"}
|
package/dist/items.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { z } from '
|
|
1
|
+
import { z } from 'zod';
|
|
2
2
|
export declare const baseItemSchema: z.ZodObject<{
|
|
3
3
|
itemId: z.ZodString;
|
|
4
4
|
}, "strip", z.ZodTypeAny, {
|
|
@@ -102,24 +102,24 @@ export declare const realtimeMessageItemSchema: z.ZodDiscriminatedUnion<"role",
|
|
|
102
102
|
role: z.ZodLiteral<"assistant">;
|
|
103
103
|
status: z.ZodEnum<["in_progress", "completed", "incomplete"]>;
|
|
104
104
|
content: z.ZodArray<z.ZodUnion<[z.ZodObject<{
|
|
105
|
-
type: z.ZodLiteral<"
|
|
105
|
+
type: z.ZodLiteral<"output_text">;
|
|
106
106
|
text: z.ZodString;
|
|
107
107
|
}, "strip", z.ZodTypeAny, {
|
|
108
|
-
type: "
|
|
108
|
+
type: "output_text";
|
|
109
109
|
text: string;
|
|
110
110
|
}, {
|
|
111
|
-
type: "
|
|
111
|
+
type: "output_text";
|
|
112
112
|
text: string;
|
|
113
113
|
}>, z.ZodObject<{
|
|
114
|
-
type: z.ZodLiteral<"
|
|
114
|
+
type: z.ZodLiteral<"output_audio">;
|
|
115
115
|
audio: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
116
116
|
transcript: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
117
117
|
}, "strip", z.ZodTypeAny, {
|
|
118
|
-
type: "
|
|
118
|
+
type: "output_audio";
|
|
119
119
|
audio?: string | null | undefined;
|
|
120
120
|
transcript?: string | null | undefined;
|
|
121
121
|
}, {
|
|
122
|
-
type: "
|
|
122
|
+
type: "output_audio";
|
|
123
123
|
audio?: string | null | undefined;
|
|
124
124
|
transcript?: string | null | undefined;
|
|
125
125
|
}>]>, "many">;
|
|
@@ -129,10 +129,10 @@ export declare const realtimeMessageItemSchema: z.ZodDiscriminatedUnion<"role",
|
|
|
129
129
|
itemId: string;
|
|
130
130
|
role: "assistant";
|
|
131
131
|
content: ({
|
|
132
|
-
type: "
|
|
132
|
+
type: "output_text";
|
|
133
133
|
text: string;
|
|
134
134
|
} | {
|
|
135
|
-
type: "
|
|
135
|
+
type: "output_audio";
|
|
136
136
|
audio?: string | null | undefined;
|
|
137
137
|
transcript?: string | null | undefined;
|
|
138
138
|
})[];
|
|
@@ -143,10 +143,10 @@ export declare const realtimeMessageItemSchema: z.ZodDiscriminatedUnion<"role",
|
|
|
143
143
|
itemId: string;
|
|
144
144
|
role: "assistant";
|
|
145
145
|
content: ({
|
|
146
|
-
type: "
|
|
146
|
+
type: "output_text";
|
|
147
147
|
text: string;
|
|
148
148
|
} | {
|
|
149
|
-
type: "
|
|
149
|
+
type: "output_audio";
|
|
150
150
|
audio?: string | null | undefined;
|
|
151
151
|
transcript?: string | null | undefined;
|
|
152
152
|
})[];
|
|
@@ -156,28 +156,77 @@ export declare const realtimeToolCallItem: z.ZodObject<{
|
|
|
156
156
|
itemId: z.ZodString;
|
|
157
157
|
previousItemId: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
158
158
|
type: z.ZodLiteral<"function_call">;
|
|
159
|
-
status: z.ZodEnum<["in_progress", "completed"]>;
|
|
159
|
+
status: z.ZodEnum<["in_progress", "completed", "incomplete"]>;
|
|
160
160
|
arguments: z.ZodString;
|
|
161
161
|
name: z.ZodString;
|
|
162
162
|
output: z.ZodNullable<z.ZodString>;
|
|
163
163
|
}, "strip", z.ZodTypeAny, {
|
|
164
164
|
type: "function_call";
|
|
165
|
-
name: string;
|
|
166
|
-
status: "in_progress" | "completed";
|
|
167
165
|
output: string | null;
|
|
166
|
+
name: string;
|
|
167
|
+
status: "in_progress" | "completed" | "incomplete";
|
|
168
168
|
itemId: string;
|
|
169
169
|
arguments: string;
|
|
170
170
|
previousItemId?: string | null | undefined;
|
|
171
171
|
}, {
|
|
172
172
|
type: "function_call";
|
|
173
|
+
output: string | null;
|
|
173
174
|
name: string;
|
|
174
|
-
status: "in_progress" | "completed";
|
|
175
|
+
status: "in_progress" | "completed" | "incomplete";
|
|
176
|
+
itemId: string;
|
|
177
|
+
arguments: string;
|
|
178
|
+
previousItemId?: string | null | undefined;
|
|
179
|
+
}>;
|
|
180
|
+
export declare const realtimeMcpCallItem: z.ZodObject<{
|
|
181
|
+
itemId: z.ZodString;
|
|
182
|
+
previousItemId: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
183
|
+
type: z.ZodEnum<["mcp_call", "mcp_tool_call"]>;
|
|
184
|
+
status: z.ZodEnum<["in_progress", "completed", "incomplete"]>;
|
|
185
|
+
arguments: z.ZodString;
|
|
186
|
+
name: z.ZodString;
|
|
187
|
+
output: z.ZodNullable<z.ZodString>;
|
|
188
|
+
}, "strip", z.ZodTypeAny, {
|
|
189
|
+
type: "mcp_call" | "mcp_tool_call";
|
|
190
|
+
output: string | null;
|
|
191
|
+
name: string;
|
|
192
|
+
status: "in_progress" | "completed" | "incomplete";
|
|
193
|
+
itemId: string;
|
|
194
|
+
arguments: string;
|
|
195
|
+
previousItemId?: string | null | undefined;
|
|
196
|
+
}, {
|
|
197
|
+
type: "mcp_call" | "mcp_tool_call";
|
|
175
198
|
output: string | null;
|
|
199
|
+
name: string;
|
|
200
|
+
status: "in_progress" | "completed" | "incomplete";
|
|
176
201
|
itemId: string;
|
|
177
202
|
arguments: string;
|
|
178
203
|
previousItemId?: string | null | undefined;
|
|
179
204
|
}>;
|
|
205
|
+
export declare const realtimeMcpCallApprovalRequestItem: z.ZodObject<{
|
|
206
|
+
itemId: z.ZodString;
|
|
207
|
+
type: z.ZodLiteral<"mcp_approval_request">;
|
|
208
|
+
serverLabel: z.ZodString;
|
|
209
|
+
name: z.ZodString;
|
|
210
|
+
arguments: z.ZodRecord<z.ZodString, z.ZodAny>;
|
|
211
|
+
approved: z.ZodNullable<z.ZodOptional<z.ZodBoolean>>;
|
|
212
|
+
}, "strip", z.ZodTypeAny, {
|
|
213
|
+
type: "mcp_approval_request";
|
|
214
|
+
name: string;
|
|
215
|
+
itemId: string;
|
|
216
|
+
arguments: Record<string, any>;
|
|
217
|
+
serverLabel: string;
|
|
218
|
+
approved?: boolean | null | undefined;
|
|
219
|
+
}, {
|
|
220
|
+
type: "mcp_approval_request";
|
|
221
|
+
name: string;
|
|
222
|
+
itemId: string;
|
|
223
|
+
arguments: Record<string, any>;
|
|
224
|
+
serverLabel: string;
|
|
225
|
+
approved?: boolean | null | undefined;
|
|
226
|
+
}>;
|
|
180
227
|
export type RealtimeBaseItem = z.infer<typeof baseItemSchema>;
|
|
181
228
|
export type RealtimeMessageItem = z.infer<typeof realtimeMessageItemSchema>;
|
|
182
229
|
export type RealtimeToolCallItem = z.infer<typeof realtimeToolCallItem>;
|
|
183
|
-
export type
|
|
230
|
+
export type RealtimeMcpCallItem = z.infer<typeof realtimeMcpCallItem>;
|
|
231
|
+
export type RealtimeMcpCallApprovalRequestItem = z.infer<typeof realtimeMcpCallApprovalRequestItem>;
|
|
232
|
+
export type RealtimeItem = RealtimeMessageItem | RealtimeToolCallItem | RealtimeMcpCallItem | RealtimeMcpCallApprovalRequestItem;
|