PluginProbe ʕ •ᴥ•ʔ
CommerceBird – AI Command Center, ERP Integrations & B2B for WooCommerce (Zoho, Exact Online). / trunk
CommerceBird – AI Command Center, ERP Integrations & B2B for WooCommerce (Zoho, Exact Online). vtrunk
3.0.3 3.0.2 3.0.1 trunk 2.2.14 2.2.15 2.2.16 2.2.17 2.2.18 2.2.19 2.3.0 2.3.1 2.3.10 2.3.11 2.3.12 2.3.13 2.3.14 2.3.2 2.3.3 2.3.4 2.3.5 2.3.6 2.3.7 2.3.8 2.3.9 2.4.0 2.4.1 2.4.2 2.4.3 2.4.4 2.4.5 2.4.6 2.5.0 2.5.1 2.5.2 2.6.0 2.6.1 2.6.2 2.6.3 2.6.4 2.6.5 2.7.0 2.7.1 2.7.2 2.7.3 2.7.4 2.7.5 2.7.6 2.7.7 2.7.8 2.7.9 2.7.91 2.7.92 2.7.93 2.8.0 2.8.1 2.8.2 2.8.3 2.8.4 2.8.5 2.9.0 2.9.1 2.9.2 2.9.3 3.0.0
commercebird / vendor / wordpress / php-mcp-schema / src / Client / Sampling / DTO / ToolChoice.php
commercebird / vendor / wordpress / php-mcp-schema / src / Client / Sampling / DTO Last commit date
CreateMessageRequest.php 2 months ago CreateMessageRequestParams.php 2 months ago CreateMessageResult.php 2 months ago ModelHint.php 2 months ago ModelPreferences.php 2 months ago SamplingMessage.php 2 months ago ToolChoice.php 2 months ago ToolResultContent.php 2 months ago ToolUseContent.php 2 months ago
ToolChoice.php
89 lines
1 <?php
2
3 declare(strict_types=1);
4
5 namespace WP\McpSchema\Client\Sampling\DTO;
6
7 use WP\McpSchema\Common\AbstractDataTransferObject;
8 use WP\McpSchema\Common\Traits\ValidatesRequiredFields;
9
10 /**
11 * Controls tool selection behavior for sampling requests.
12 *
13 * @since 2025-11-25
14 *
15 * @mcp-domain Client
16 * @mcp-subdomain Sampling
17 * @mcp-version 2025-11-25
18 */
19 class ToolChoice extends AbstractDataTransferObject
20 {
21 use ValidatesRequiredFields;
22
23 /**
24 * Controls the tool use ability of the model:
25 * - "auto": Model decides whether to use tools (default)
26 * - "required": Model MUST use at least one tool before completing
27 * - "none": Model MUST NOT use any tools
28 *
29 * @since 2025-11-25
30 *
31 * @var 'auto'|'required'|'none'|null
32 */
33 protected ?string $mode;
34
35 /**
36 * @param 'auto'|'required'|'none'|null $mode @since 2025-11-25
37 */
38 public function __construct(
39 ?string $mode = null
40 ) {
41 $this->mode = $mode;
42 }
43
44 /**
45 * Creates an instance from an array.
46 *
47 * @param array{
48 * mode?: 'auto'|'required'|'none'|null
49 * } $data
50 * @phpstan-param array<string, mixed> $data
51 * @return self
52 */
53 public static function fromArray(array $data): self
54 {
55 /** @var 'auto'|'required'|'none'|null $mode */
56 $mode = isset($data['mode'])
57 ? self::asStringOrNull($data['mode'])
58 : null;
59
60 return new self(
61 $mode
62 );
63 }
64
65 /**
66 * Converts the instance to an array.
67 *
68 * @return array<string, mixed>
69 */
70 public function toArray(): array
71 {
72 $result = [];
73
74 if ($this->mode !== null) {
75 $result['mode'] = $this->mode;
76 }
77
78 return $result;
79 }
80
81 /**
82 * @return 'auto'|'required'|'none'|null
83 */
84 public function getMode(): ?string
85 {
86 return $this->mode;
87 }
88 }
89