PluginProbe
ZIP AI – AI Website Builder & AI Agent (Beta) / 0.0.8
ZIP AI – AI Website Builder & AI Agent (Beta) v0.0.8
0.0.10 0.0.9 trunk 0.0.4 0.0.5 0.0.6 0.0.7 0.0.8
zip-ai / lib / php-mcp-schema / src / Common / Tasks / DTO / TaskAugmentedRequestParams.php

TaskAugmentedRequestParams.php in ZIP AI – AI Website Builder & AI Agent (Beta) 0.0.8, at lib/php-mcp-schema/src/Common/Tasks/DTO/TaskAugmentedRequestParams.php

107 lines 3.0 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 declare(strict_types=1);
4
5 namespace WP\McpSchema\Common\Tasks\DTO;
6
7 use WP\McpSchema\Client\Tasks\DTO\TaskMetadata;
8 use WP\McpSchema\Common\JsonRpc\DTO\RequestParams;
9 use WP\McpSchema\Common\JsonRpc\DTO\RequestParamsMeta;
10 use WP\McpSchema\Common\Traits\ValidatesRequiredFields;
11
12 /**
13 * Common params for any task-augmented request.
14 *
15 * @since 2025-11-25
16 *
17 * @mcp-domain Common
18 * @mcp-subdomain Tasks
19 * @mcp-version 2025-11-25
20 */
21 class TaskAugmentedRequestParams extends RequestParams
22 {
23 use ValidatesRequiredFields;
24
25 /**
26 * If specified, the caller is requesting task-augmented execution for this request.
27 * The request will return a CreateTaskResult immediately, and the actual result can be
28 * retrieved later via tasks/result.
29 *
30 * Task augmentation is subject to capability negotiation - receivers MUST declare support
31 * for task augmentation of specific request types in their capabilities.
32 *
33 * @since 2025-11-25
34 *
35 * @var \WP\McpSchema\Client\Tasks\DTO\TaskMetadata|null
36 */
37 protected ?TaskMetadata $task;
38
39 /**
40 * @param \WP\McpSchema\Common\JsonRpc\DTO\RequestParamsMeta|null $_meta @since 2025-11-25
41 * @param \WP\McpSchema\Client\Tasks\DTO\TaskMetadata|null $task @since 2025-11-25
42 */
43 public function __construct(
44 ?RequestParamsMeta $_meta = null,
45 ?TaskMetadata $task = null
46 ) {
47 parent::__construct($_meta);
48 $this->task = $task;
49 }
50
51 /**
52 * Creates an instance from an array.
53 *
54 * @param array{
55 * _meta?: array<string, mixed>|\WP\McpSchema\Common\JsonRpc\DTO\RequestParamsMeta|null,
56 * task?: array<string, mixed>|\WP\McpSchema\Client\Tasks\DTO\TaskMetadata|null
57 * } $data
58 * @phpstan-param array<string, mixed> $data
59 * @return self
60 */
61 public static function fromArray(array $data): self
62 {
63 /** @var \WP\McpSchema\Common\JsonRpc\DTO\RequestParamsMeta|null $_meta */
64 $_meta = isset($data['_meta'])
65 ? (is_array($data['_meta'])
66 ? RequestParamsMeta::fromArray(self::asArray($data['_meta']))
67 : $data['_meta'])
68 : null;
69
70 /** @var \WP\McpSchema\Client\Tasks\DTO\TaskMetadata|null $task */
71 $task = isset($data['task'])
72 ? (is_array($data['task'])
73 ? TaskMetadata::fromArray(self::asArray($data['task']))
74 : $data['task'])
75 : null;
76
77 return new self(
78 $_meta,
79 $task
80 );
81 }
82
83 /**
84 * Converts the instance to an array.
85 *
86 * @return array<string, mixed>
87 */
88 public function toArray(): array
89 {
90 $result = parent::toArray();
91
92 if ($this->task !== null) {
93 $result['task'] = $this->task->toArray();
94 }
95
96 return $result;
97 }
98
99 /**
100 * @return \WP\McpSchema\Client\Tasks\DTO\TaskMetadata|null
101 */
102 public function getTask(): ?TaskMetadata
103 {
104 return $this->task;
105 }
106 }
107