-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathclass-wp-codebox-parent-tool-bridge-contract.php
More file actions
91 lines (85 loc) · 3.87 KB
/
Copy pathclass-wp-codebox-parent-tool-bridge-contract.php
File metadata and controls
91 lines (85 loc) · 3.87 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
<?php
/**
* Parent tool bridge contract constants and schema helpers.
*
* @package WPCodebox
*/
defined( 'ABSPATH' ) || exit;
final class WP_Codebox_Parent_Tool_Bridge_Contract {
public const BRIDGE_SCHEMA = 'wp-codebox/parent-tool-bridge/v1';
public const BRIDGE_VERSION = 1;
public const REQUEST_SCHEMA = 'wp-codebox/parent-tool-request/v1';
public const REQUEST_VERSION = 1;
public const RESULT_SCHEMA = 'wp-codebox/parent-tool-result/v1';
public const RESULT_VERSION = 1;
/** @return array<string,mixed> */
public static function bridge_schema(): array {
return array(
'$id' => self::BRIDGE_SCHEMA,
'type' => 'object',
'required' => array( 'schema', 'version', 'allowed_tools', 'dispatcher', 'sandbox_env', 'authorization', 'redaction', 'metadata' ),
'properties' => array(
'schema' => array( 'type' => 'string', 'const' => self::BRIDGE_SCHEMA ),
'version' => array( 'type' => 'integer', 'const' => self::BRIDGE_VERSION ),
'allowed_tools' => array( 'type' => 'array', 'items' => array( 'type' => 'string' ) ),
'dispatcher' => array(
'type' => 'object',
'required' => array( 'owner', 'mode', 'request_schema', 'result_schema' ),
'properties' => array(
'owner' => array( 'type' => 'string', 'const' => 'wp-codebox' ),
'mode' => array( 'type' => 'string', 'enum' => array( 'host_endpoint', 'host_command' ) ),
'endpoint' => array( 'type' => 'object' ),
'command' => array( 'type' => 'object' ),
'request_schema' => array( 'type' => 'string', 'const' => self::REQUEST_SCHEMA ),
'result_schema' => array( 'type' => 'string', 'const' => self::RESULT_SCHEMA ),
'timeout_ms' => array( 'type' => 'integer', 'minimum' => 1 ),
),
),
'sandbox_env' => array( 'type' => 'object' ),
'authorization' => array( 'type' => 'object' ),
'redaction' => array( 'type' => 'object' ),
'metadata' => array( 'type' => 'object' ),
),
);
}
/** @return array<string,mixed> */
public static function request_schema(): array {
return array(
'$id' => self::REQUEST_SCHEMA,
'type' => 'object',
'required' => array( 'schema', 'version', 'request_id', 'tool', 'operation', 'input', 'sandbox_session', 'authorization', 'metadata' ),
'properties' => array(
'schema' => array( 'type' => 'string', 'const' => self::REQUEST_SCHEMA ),
'version' => array( 'type' => 'integer', 'const' => self::REQUEST_VERSION ),
'request_id' => array( 'type' => 'string' ),
'tool' => array( 'type' => 'string' ),
'operation' => array( 'type' => 'string' ),
'input' => (object) array(),
'sandbox_session' => array( 'type' => 'object' ),
'authorization' => array( 'type' => 'object' ),
'metadata' => array( 'type' => 'object' ),
),
);
}
/** @return array<string,mixed> */
public static function result_schema(): array {
return array(
'$id' => self::RESULT_SCHEMA,
'type' => 'object',
'required' => array( 'schema', 'version', 'request_id', 'tool', 'operation', 'status', 'artifacts', 'diagnostics', 'metadata' ),
'properties' => array(
'schema' => array( 'type' => 'string', 'const' => self::RESULT_SCHEMA ),
'version' => array( 'type' => 'integer', 'const' => self::RESULT_VERSION ),
'request_id' => array( 'type' => 'string' ),
'tool' => array( 'type' => 'string' ),
'operation' => array( 'type' => 'string' ),
'status' => array( 'type' => 'string', 'enum' => array( 'succeeded', 'failed', 'denied', 'unavailable', 'timeout' ) ),
'output' => (object) array(),
'error' => array( 'type' => 'object' ),
'artifacts' => array( 'type' => 'object' ),
'diagnostics' => array( 'type' => 'object' ),
'metadata' => array( 'type' => 'object' ),
),
);
}
}