PluginProbe
OpenStation: Desktop Windows, Dock & Virtual Desktops for WP Admin / 1.1.10
OpenStation: Desktop Windows, Dock & Virtual Desktops for WP Admin v1.1.10
1.1.10 1.1.9 1.1.8 1.1.7 1.1.6 1.1.5 1.1.4 1.1.3 1.1.2 1.1.1 1.1.0 1.0.1 1.0.0 0.9.8 0.9.7 0.9.6 0.9.4 0.9.5 0.9.3 0.9.2 0.9.1 0.9.0 0.8.9 0.8.8 0.8.7 All 34 releases
← All changes | includes/ai-copilot/schema.php +14 -14 0.9.81.1.10 View file →
@@ -1,7 +1,7 @@
1 1 <?php
2 2 /**
3 - * Desktop Mode — AI Copilot: structured-output schema normalization.
3 + * OpenStation — AI Copilot: structured-output schema normalization.
4 4 *
5 5 * Every schema handed to `as_json_response()` becomes the provider's
6 6 * structured-output contract (`output_format.schema` on Anthropic, the
7 7 * equivalent response-schema field elsewhere). Providers validate that
@@ -13,22 +13,22 @@
13 13 * 'additionalProperties' must be explicitly set to false
14 14 *
15 15 * — and the whole request fails, not just the offending branch. That is a
16 16 * trap for the schemas we ship (one missing key anywhere in the tree kills
17 - * the feature) and worse for the filtered ones: `desktop_mode_ai_schema_comment`,
18 - * `desktop_mode_drafts_ai_schema`, and any plugin that adds a nested object
17 + * the feature) and worse for the filtered ones: `openstation_ai_schema_comment`,
18 + * `openstation_drafts_ai_schema`, and any plugin that adds a nested object
19 19 * would otherwise have to know the provider's strict-mode rules to add a
20 20 * property safely.
21 21 *
22 22 * So normalization runs at the choke point instead of relying on every
23 - * author getting it right: `desktop_mode_ai_normalize_response_schema()`
23 + * author getting it right: `openstation_ai_normalize_response_schema()`
24 24 * walks the tree and stamps `additionalProperties: false` on every object
25 25 * subschema, at every depth, after the filters have run.
26 26 *
27 27 * Tool INPUT schemas are a different contract with different rules — see
28 - * `desktop_mode_ai_normalize_tool_schema()` in search.php.
28 + * `openstation_ai_normalize_tool_schema()` in search.php.
29 29 *
30 - * @package WPDesktopMode
30 + * @package OpenStation
31 31 */
32 32
33 33 defined( 'ABSPATH' ) || exit;
34 34
@@ -51,10 +51,10 @@
51 51 *
52 52 * @param array $schema A structured-output (sub)schema.
53 53 * @return array The schema with `additionalProperties: false` on every object node.
54 54 */
55 -function desktop_mode_ai_normalize_response_schema( array $schema ) {
56 - if ( desktop_mode_ai_schema_is_object_node( $schema ) ) {
55 +function openstation_ai_normalize_response_schema( array $schema ) {
56 + if ( openstation_ai_schema_is_object_node( $schema ) ) {
57 57 $schema['additionalProperties'] = false;
58 58 if ( isset( $schema['properties'] ) && is_array( $schema['properties'] ) && array() !== $schema['properties'] ) {
59 59 // Strict structured output (OpenAI `strict: true`) also
60 60 // demands that `required` lists EVERY key in `properties` —
@@ -69,9 +69,9 @@
69 69 foreach ( array( 'properties', 'patternProperties', '$defs', 'definitions' ) as $map_key ) {
70 70 if ( isset( $schema[ $map_key ] ) && is_array( $schema[ $map_key ] ) ) {
71 71 foreach ( $schema[ $map_key ] as $name => $sub ) {
72 72 if ( is_array( $sub ) ) {
73 - $schema[ $map_key ][ $name ] = desktop_mode_ai_normalize_response_schema( $sub );
73 + $schema[ $map_key ][ $name ] = openstation_ai_normalize_response_schema( $sub );
74 74 }
75 75 }
76 76 }
77 77 }
@@ -82,14 +82,14 @@
82 82 if ( $is_list && array() !== $items ) {
83 83 // Tuple form — a list of schemas.
84 84 foreach ( $items as $i => $sub ) {
85 85 if ( is_array( $sub ) ) {
86 - $items[ $i ] = desktop_mode_ai_normalize_response_schema( $sub );
86 + $items[ $i ] = openstation_ai_normalize_response_schema( $sub );
87 87 }
88 88 }
89 89 $schema['items'] = $items;
90 90 } else {
91 - $schema['items'] = desktop_mode_ai_normalize_response_schema( $items );
91 + $schema['items'] = openstation_ai_normalize_response_schema( $items );
92 92 }
93 93 }
94 94
95 95 foreach ( array( 'oneOf', 'allOf', 'anyOf', 'prefixItems' ) as $list_key ) {
@@ -95,9 +95,9 @@
95 95 foreach ( array( 'oneOf', 'allOf', 'anyOf', 'prefixItems' ) as $list_key ) {
96 96 if ( isset( $schema[ $list_key ] ) && is_array( $schema[ $list_key ] ) ) {
97 97 foreach ( $schema[ $list_key ] as $i => $sub ) {
98 98 if ( is_array( $sub ) ) {
99 - $schema[ $list_key ][ $i ] = desktop_mode_ai_normalize_response_schema( $sub );
99 + $schema[ $list_key ][ $i ] = openstation_ai_normalize_response_schema( $sub );
100 100 }
101 101 }
102 102 }
103 103 }
@@ -102,9 +102,9 @@
102 102 }
103 103 }
104 104
105 105 if ( isset( $schema['not'] ) && is_array( $schema['not'] ) ) {
106 - $schema['not'] = desktop_mode_ai_normalize_response_schema( $schema['not'] );
106 + $schema['not'] = openstation_ai_normalize_response_schema( $schema['not'] );
107 107 }
108 108
109 109 return $schema;
110 110 }
@@ -119,9 +119,9 @@
119 119 *
120 120 * @param array $schema A structured-output (sub)schema.
121 121 * @return bool
122 122 */
123 -function desktop_mode_ai_schema_is_object_node( array $schema ) {
123 +function openstation_ai_schema_is_object_node( array $schema ) {
124 124 if ( isset( $schema['type'] ) ) {
125 125 $types = is_array( $schema['type'] ) ? $schema['type'] : array( $schema['type'] );
126 126 return in_array( 'object', $types, true );
127 127 }