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