@openai/agents-realtime 0.0.17 → 0.1.1
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 +3267 -2842
- package/dist/bundle/openai-realtime-agents.umd.js +7 -7
- package/dist/clientMessages.d.ts +89 -13
- package/dist/clientMessages.js +91 -0
- package/dist/clientMessages.js.map +1 -1
- package/dist/clientMessages.mjs +89 -1
- package/dist/clientMessages.mjs.map +1 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.js +4 -1
- 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 +64 -15
- package/dist/items.js +21 -4
- package/dist/items.js.map +1 -1
- package/dist/items.mjs +20 -3
- package/dist/items.mjs.map +1 -1
- package/dist/metadata.js +2 -2
- package/dist/metadata.js.map +1 -1
- package/dist/metadata.mjs +2 -2
- package/dist/metadata.mjs.map +1 -1
- package/dist/openaiRealtimeBase.d.ts +12 -25
- package/dist/openaiRealtimeBase.js +204 -60
- package/dist/openaiRealtimeBase.js.map +1 -1
- package/dist/openaiRealtimeBase.mjs +205 -61
- package/dist/openaiRealtimeBase.mjs.map +1 -1
- package/dist/openaiRealtimeEvents.d.ts +2463 -648
- package/dist/openaiRealtimeEvents.js +117 -29
- package/dist/openaiRealtimeEvents.js.map +1 -1
- package/dist/openaiRealtimeEvents.mjs +115 -27
- package/dist/openaiRealtimeEvents.mjs.map +1 -1
- package/dist/openaiRealtimeWebRtc.js +4 -10
- package/dist/openaiRealtimeWebRtc.js.map +1 -1
- package/dist/openaiRealtimeWebRtc.mjs +4 -10
- package/dist/openaiRealtimeWebRtc.mjs.map +1 -1
- package/dist/openaiRealtimeWebsocket.js +32 -11
- 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 +1 -1
- 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 +126 -11
- package/dist/realtimeSession.js.map +1 -1
- package/dist/realtimeSession.mjs +127 -12
- package/dist/realtimeSession.mjs.map +1 -1
- package/dist/realtimeSessionEvents.d.ts +21 -2
- 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/transportLayerEvents.d.ts +19 -1
- package/dist/utils.d.ts +5 -1
- package/dist/utils.js +34 -3
- package/dist/utils.js.map +1 -1
- package/dist/utils.mjs +32 -3
- package/dist/utils.mjs.map +1 -1
- package/package.json +2 -2
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,3 +1,94 @@
|
|
|
1
1
|
"use strict";
|
|
2
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
|
+
}
|
|
3
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,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,SAAgB,kBAAkB,CAChC,MAA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@ -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.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MAAM,CAAC,iBAAiB,CAAC;gBACtD,KAAK,EAAE,MAAM,CAAC,KAAK;gBACnB,KAAK,EAAE,MAAM,CAAC,KAAK;aACpB;SACF;KACF,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,oBAAoB,CAClC,MAAwC;IAExC,IAAI,CAAC,MAAM;QAAE,OAAO,SAAS,CAAC;IAC9B,IAAI,OAAO,MAAM,KAAK,QAAQ;QAC5B,OAAO,MAAuC,CAAC;IACjD,MAAM,CAAC,GAAG,MAAM,CAAC,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/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
|
@@ -33,7 +33,7 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
33
33
|
};
|
|
34
34
|
})();
|
|
35
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
-
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;
|
|
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
37
|
const utilImport = __importStar(require("./utils.js"));
|
|
38
38
|
var realtimeAgent_1 = require("./realtimeAgent.js");
|
|
39
39
|
Object.defineProperty(exports, "RealtimeAgent", { enumerable: true, get: function () { return realtimeAgent_1.RealtimeAgent; } });
|
|
@@ -59,4 +59,7 @@ Object.defineProperty(exports, "ModelBehaviorError", { enumerable: true, get: fu
|
|
|
59
59
|
Object.defineProperty(exports, "OutputGuardrailTripwireTriggered", { enumerable: true, get: function () { return agents_core_1.OutputGuardrailTripwireTriggered; } });
|
|
60
60
|
Object.defineProperty(exports, "tool", { enumerable: true, get: function () { return agents_core_1.tool; } });
|
|
61
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; } });
|
|
62
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":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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;
|
|
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
|
@@ -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;
|
package/dist/items.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.realtimeToolCallItem = exports.realtimeMessageItemSchema = exports.baseItemSchema = void 0;
|
|
3
|
+
exports.realtimeMcpCallApprovalRequestItem = exports.realtimeMcpCallItem = exports.realtimeToolCallItem = exports.realtimeMessageItemSchema = exports.baseItemSchema = void 0;
|
|
4
4
|
const zod_1 = require("zod");
|
|
5
5
|
exports.baseItemSchema = zod_1.z.object({
|
|
6
6
|
itemId: zod_1.z.string(),
|
|
@@ -31,8 +31,8 @@ exports.realtimeMessageItemSchema = zod_1.z.discriminatedUnion('role', [
|
|
|
31
31
|
type: zod_1.z.literal('message'),
|
|
32
32
|
role: zod_1.z.literal('assistant'),
|
|
33
33
|
status: zod_1.z.enum(['in_progress', 'completed', 'incomplete']),
|
|
34
|
-
content: zod_1.z.array(zod_1.z.object({ type: zod_1.z.literal('
|
|
35
|
-
type: zod_1.z.literal('
|
|
34
|
+
content: zod_1.z.array(zod_1.z.object({ type: zod_1.z.literal('output_text'), text: zod_1.z.string() }).or(zod_1.z.object({
|
|
35
|
+
type: zod_1.z.literal('output_audio'),
|
|
36
36
|
audio: zod_1.z.string().nullable().optional(),
|
|
37
37
|
transcript: zod_1.z.string().nullable().optional(),
|
|
38
38
|
}))),
|
|
@@ -42,9 +42,26 @@ exports.realtimeToolCallItem = zod_1.z.object({
|
|
|
42
42
|
itemId: zod_1.z.string(),
|
|
43
43
|
previousItemId: zod_1.z.string().nullable().optional(),
|
|
44
44
|
type: zod_1.z.literal('function_call'),
|
|
45
|
-
status: zod_1.z.enum(['in_progress', 'completed']),
|
|
45
|
+
status: zod_1.z.enum(['in_progress', 'completed', 'incomplete']),
|
|
46
46
|
arguments: zod_1.z.string(),
|
|
47
47
|
name: zod_1.z.string(),
|
|
48
48
|
output: zod_1.z.string().nullable(),
|
|
49
49
|
});
|
|
50
|
+
exports.realtimeMcpCallItem = zod_1.z.object({
|
|
51
|
+
itemId: zod_1.z.string(),
|
|
52
|
+
previousItemId: zod_1.z.string().nullable().optional(),
|
|
53
|
+
type: zod_1.z.enum(['mcp_call', 'mcp_tool_call']),
|
|
54
|
+
status: zod_1.z.enum(['in_progress', 'completed', 'incomplete']),
|
|
55
|
+
arguments: zod_1.z.string(),
|
|
56
|
+
name: zod_1.z.string(),
|
|
57
|
+
output: zod_1.z.string().nullable(),
|
|
58
|
+
});
|
|
59
|
+
exports.realtimeMcpCallApprovalRequestItem = zod_1.z.object({
|
|
60
|
+
itemId: zod_1.z.string(),
|
|
61
|
+
type: zod_1.z.literal('mcp_approval_request'),
|
|
62
|
+
serverLabel: zod_1.z.string(),
|
|
63
|
+
name: zod_1.z.string(),
|
|
64
|
+
arguments: zod_1.z.record(zod_1.z.string(), zod_1.z.any()),
|
|
65
|
+
approved: zod_1.z.boolean().optional().nullable(),
|
|
66
|
+
});
|
|
50
67
|
//# sourceMappingURL=items.js.map
|
package/dist/items.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"items.js","sourceRoot":"","sources":["../src/items.ts"],"names":[],"mappings":";;;AAAA,6BAAwB;AAEX,QAAA,cAAc,GAAG,OAAC,CAAC,MAAM,CAAC;IACrC,MAAM,EAAE,OAAC,CAAC,MAAM,EAAE;CACnB,CAAC,CAAC;AAEU,QAAA,yBAAyB,GAAG,OAAC,CAAC,kBAAkB,CAAC,MAAM,EAAE;IACpE,OAAC,CAAC,MAAM,CAAC;QACP,MAAM,EAAE,OAAC,CAAC,MAAM,EAAE;QAClB,cAAc,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE,CAAC,QAAQ,EAAE;QAChD,IAAI,EAAE,OAAC,CAAC,OAAO,CAAC,SAAS,CAAC;QAC1B,IAAI,EAAE,OAAC,CAAC,OAAO,CAAC,QAAQ,CAAC;QACzB,OAAO,EAAE,OAAC,CAAC,KAAK,CACd,OAAC,CAAC,MAAM,CAAC,EAAE,IAAI,EAAE,OAAC,CAAC,OAAO,CAAC,YAAY,CAAC,EAAE,IAAI,EAAE,OAAC,CAAC,MAAM,EAAE,EAAE,CAAC,CAC9D;KACF,CAAC;IACF,OAAC,CAAC,MAAM,CAAC;QACP,MAAM,EAAE,OAAC,CAAC,MAAM,EAAE;QAClB,cAAc,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE,CAAC,QAAQ,EAAE;QAChD,IAAI,EAAE,OAAC,CAAC,OAAO,CAA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
|
|
29
29
|
role: z.literal('assistant'),
|
|
30
30
|
status: z.enum(['in_progress', 'completed', 'incomplete']),
|
|
31
|
-
content: z.array(z.object({ type: z.literal('
|
|
32
|
-
type: z.literal('
|
|
31
|
+
content: z.array(z.object({ type: z.literal('output_text'), text: z.string() }).or(z.object({
|
|
32
|
+
type: z.literal('output_audio'),
|
|
33
33
|
audio: z.string().nullable().optional(),
|
|
34
34
|
transcript: z.string().nullable().optional(),
|
|
35
35
|
}))),
|
|
@@ -39,9 +39,26 @@ export const realtimeToolCallItem = z.object({
|
|
|
39
39
|
itemId: z.string(),
|
|
40
40
|
previousItemId: z.string().nullable().optional(),
|
|
41
41
|
type: z.literal('function_call'),
|
|
42
|
-
status: z.enum(['in_progress', 'completed']),
|
|
42
|
+
status: z.enum(['in_progress', 'completed', 'incomplete']),
|
|
43
43
|
arguments: z.string(),
|
|
44
44
|
name: z.string(),
|
|
45
45
|
output: z.string().nullable(),
|
|
46
46
|
});
|
|
47
|
+
export const realtimeMcpCallItem = z.object({
|
|
48
|
+
itemId: z.string(),
|
|
49
|
+
previousItemId: z.string().nullable().optional(),
|
|
50
|
+
type: z.enum(['mcp_call', 'mcp_tool_call']),
|
|
51
|
+
status: z.enum(['in_progress', 'completed', 'incomplete']),
|
|
52
|
+
arguments: z.string(),
|
|
53
|
+
name: z.string(),
|
|
54
|
+
output: z.string().nullable(),
|
|
55
|
+
});
|
|
56
|
+
export const realtimeMcpCallApprovalRequestItem = z.object({
|
|
57
|
+
itemId: z.string(),
|
|
58
|
+
type: z.literal('mcp_approval_request'),
|
|
59
|
+
serverLabel: z.string(),
|
|
60
|
+
name: z.string(),
|
|
61
|
+
arguments: z.record(z.string(), z.any()),
|
|
62
|
+
approved: z.boolean().optional().nullable(),
|
|
63
|
+
});
|
|
47
64
|
//# sourceMappingURL=items.mjs.map
|