13
13
use OpenAI \Responses \Responses \Output \OutputFileSearchToolCall ;
14
14
use OpenAI \Responses \Responses \Output \OutputFunctionToolCall ;
15
15
use OpenAI \Responses \Responses \Output \OutputImageGenerationToolCall ;
16
+ use OpenAI \Responses \Responses \Output \OutputMcpApprovalRequest ;
17
+ use OpenAI \Responses \Responses \Output \OutputMcpCall ;
18
+ use OpenAI \Responses \Responses \Output \OutputMcpListTools ;
16
19
use OpenAI \Responses \Responses \Output \OutputMessage ;
17
20
use OpenAI \Responses \Responses \Output \OutputMessageContentOutputText ;
18
21
use OpenAI \Responses \Responses \Output \OutputReasoning ;
21
24
use OpenAI \Responses \Responses \Tool \FileSearchTool ;
22
25
use OpenAI \Responses \Responses \Tool \FunctionTool ;
23
26
use OpenAI \Responses \Responses \Tool \ImageGenerationTool ;
A3E2
div>
27
+ use OpenAI \Responses \Responses \Tool \RemoteMcpTool ;
24
28
use OpenAI \Responses \Responses \Tool \WebSearchTool ;
25
29
use OpenAI \Responses \Responses \ToolChoice \FunctionToolChoice ;
26
30
use OpenAI \Responses \Responses \ToolChoice \HostedToolChoice ;
34
38
* @phpstan-import-type OutputMessageType from OutputMessage
35
39
* @phpstan-import-type OutputReasoningType from OutputReasoning
36
40
* @phpstan-import-type OutputWebSearchToolCallType from OutputWebSearchToolCall
41
+ * @phpstan-import-type OutputMcpListToolsType from OutputMcpListTools
42
+ * @phpstan-import-type OutputMcpApprovalRequestType from OutputMcpApprovalRequest
43
+ * @phpstan-import-type OutputMcpCallType from OutputMcpCall
37
44
* @phpstan-import-type OutputImageGenerationToolCallType from OutputImageGenerationToolCall
38
45
* @phpstan-import-type ComputerUseToolType from ComputerUseTool
39
46
* @phpstan-import-type FileSearchToolType from FileSearchTool
40
47
* @phpstan-import-type ImageGenerationToolType from ImageGenerationTool
48
+ * @phpstan-import-type RemoteMcpToolType from RemoteMcpTool
41
49
* @phpstan-import-type FunctionToolType from FunctionTool
42
50
* @phpstan-import-type WebSearchToolType from WebSearchTool
43
51
* @phpstan-import-type ErrorType from CreateResponseError
48
56
* @phpstan-import-type ReasoningType from CreateResponseReasoning
49
57
*
50
58
* @phpstan-type ToolChoiceType 'none'|'auto'|'required'|FunctionToolChoiceType|HostedToolChoiceType
51
- * @phpstan-type ToolsType array<int, ComputerUseToolType|FileSearchToolType|FunctionToolType|WebSearchToolType|ImageGenerationToolType>
52
- * @phpstan-type OutputType array<int, OutputComputerToolCallType|OutputFileSearchToolCallType|OutputFunctionToolCallType|OutputMessageType|OutputReasoningType|OutputWebSearchToolCallType|OutputImageGenerationToolCallType>
59
+ * @phpstan-type ToolsType array<int, ComputerUseToolType|FileSearchToolType|FunctionToolType|WebSearchToolType|ImageGenerationToolType|RemoteMcpToolType|ImageGenerationToolType >
60
+ * @phpstan-type OutputType array<int, OutputComputerToolCallType|OutputFileSearchToolCallType|OutputFunctionToolCallType|OutputMessageType|OutputReasoningType|OutputWebSearchToolCallType|OutputMcpListToolsType|OutputMcpApprovalRequestType|OutputMcpCallType| OutputImageGenerationToolCallType>
53
61
* @phpstan-type CreateResponseType array{id: string, object: 'response', created_at: int, status: 'completed'|'failed'|'in_progress'|'incomplete', error: ErrorType|null, incomplete_details: IncompleteDetailsType|null, instructions: string|null, max_output_tokens: int|null, model: string, output: OutputType, output_text: string|null, parallel_tool_calls: bool, previous_response_id: string|null, reasoning: ReasoningType|null, store: bool, temperature: float|null, text: ResponseFormatType, tool_choice: ToolChoiceType, tools: ToolsType, top_p: float|null, truncation: 'auto'|'disabled'|null, usage: UsageType|null, user: string|null, metadata: array<string, string>|null}
54
62
*
55
63
* @implements ResponseContract<CreateResponseType>
@@ -67,8 +75,8 @@ final class CreateResponse implements ResponseContract, ResponseHasMetaInformati
67
75
/**
68
76
* @param 'response' $object
69
77
* @param 'completed'|'failed'|'in_progress'|'incomplete' $status
70
- * @param array<int, OutputMessage|OutputComputerToolCall|OutputFileSearchToolCall|OutputWebSearchToolCall|OutputFunctionToolCall|OutputReasoning|OutputImageGenerationToolCall> $output
71
- * @param array<int, ComputerUseTool|FileSearchTool|FunctionTool|WebSearchTool|ImageGenerationTool> $tools
78
+ * @param array<int, OutputMessage|OutputComputerToolCall|OutputFileSearchToolCall|OutputWebSearchToolCall|OutputFunctionToolCall|OutputReasoning|OutputMcpListTools|OutputMcpApprovalRequest|OutputMcpCall| OutputImageGenerationToolCall> $output
79
+ * @param array<int, ComputerUseTool|FileSearchTool|FunctionTool|WebSearchTool|ImageGenerationTool|RemoteMcpTool|ImageGenerationTool > $tools
72
80
* @param 'auto'|'disabled'|null $truncation
73
81
* @param array<string, string> $metadata
74
82
*/
@@ -106,13 +114,16 @@ private function __construct(
106
114
public static function from (array $ attributes , MetaInformation $ meta ): self
107
115
{
108
116
$ output = array_map (
109
- fn (array $ output ): OutputMessage |OutputComputerToolCall |OutputFileSearchToolCall |OutputWebSearchToolCall |OutputFunctionToolCall |OutputReasoning |OutputImageGenerationToolCall => match ($ output ['type ' ]) {
117
+ fn (array $ output ): OutputMessage |OutputComputerToolCall |OutputFileSearchToolCall |OutputWebSearchToolCall |OutputFunctionToolCall |OutputReasoning |OutputMcpListTools | OutputMcpApprovalRequest | OutputMcpCall | OutputImageGenerationToolCall => match ($ output ['type ' ]) {
110
118
'message ' => OutputMessage::from ($ output ),
111
119
'file_search_call ' => OutputFileSearchToolCall::from ($ output ),
112
120
'function_call ' => OutputFunctionToolCall::from ($ output ),
113
121
'web_search_call ' => OutputWebSearchToolCall::from ($ output ),
114
122
'computer_call ' => OutputComputerToolCall::from ($ output ),
115
123
'reasoning ' => OutputReasoning::from ($ output ),
124
+ 'mcp_list_tools ' => OutputMcpListTools::from ($ output ),
125
+ 'mcp_approval_request ' => OutputMcpApprovalRequest::from ($ output ),
126
+ 'mcp_call ' => OutputMcpCall::from ($ output ),
116
127
'image_generation_call ' => OutputImageGenerationToolCall::from ($ output ),
117
128
},
118
129
$ attributes ['output ' ],
@@ -126,12 +137,13 @@ public static function from(array $attributes, MetaInformation $meta): self
126
137
: $ attributes ['tool_choice ' ];
127
138
128
139
$ tools = array_map (
129
- fn (array $ tool ): ComputerUseTool |FileSearchTool |FunctionTool |WebSearchTool |ImageGenerationTool => match ($ tool ['type ' ]) {
140
+ fn (array $ tool ): ComputerUseTool |FileSearchTool |FunctionTool |WebSearchTool |ImageGenerationTool | RemoteMcpTool => match ($ tool ['type ' ]) {
130
141
'file_search ' => FileSearchTool::from ($ tool ),
131
142
'web_search_preview ' , 'web_search_preview_2025_03_11 ' => WebSearchTool::from ($ tool ),
132
143
'function ' => FunctionTool::from ($ tool ),
133
144
'computer_use_preview ' => ComputerUseTool::from ($ tool ),
134
145
'image_generation ' => ImageGenerationTool::from ($ tool ),
146
+ 'mcp ' => RemoteMcpTool::from ($ tool ),
135
147
},
136
148
$ attributes ['tools ' ],
137
149
);
@@ -204,7 +216,7 @@ public function toArray(): array
204
216
'metadata ' => $ this ->metadata ?? [],
205
217
'model ' => $ this ->model ,
206
218
'output ' => array_map (
207
- fn (OutputMessage |OutputComputerToolCall |OutputFileSearchToolCall |OutputWebSearchToolCall |OutputFunctionToolCall |OutputReasoning |OutputImageGenerationToolCall $ output ): array => $ output ->toArray (),
219
+ fn (OutputMessage |OutputComputerToolCall |OutputFileSearchToolCall |OutputWebSearchToolCall |OutputFunctionToolCall |OutputReasoning |OutputMcpListTools | OutputMcpApprovalRequest | OutputMcpCall | OutputImageGenerationToolCall $ output ): array => $ output ->toArray (),
208
220
$ this ->output
209
221
),
210
222
'parallel_tool_calls ' => $ this ->parallelToolCalls ,
@@ -217,7 +229,7 @@ public function toArray(): array
217
229
? $ this ->toolChoice
218
230
: $ this ->toolChoice ->toArray (),
219
231
'tools ' => array_map (
220
- fn (ComputerUseTool |FileSearchTool |FunctionTool |WebSearchTool |ImageGenerationTool $ tool ): array => $ tool ->toArray (),
232
+ fn (ComputerUseTool |FileSearchTool |FunctionTool |WebSearchTool |ImageGenerationTool | RemoteMcpTool $ tool ): array => $ tool ->toArray (),
221
233
$ this ->tools
222
234
),
223
235
'top_p ' => $ this ->topP ,
0 commit comments