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/settings.php +32 -51 0.9.51.1.10 View file →
@@ -1,7 +1,7 @@
1 1 <?php
2 2 /**
3 - * Desktop Mode — AI Copilot settings + capability helpers.
3 + * OpenStation — AI Copilot settings + capability helpers.
4 4 *
5 5 * The Copilot no longer stores credentials of its own. WordPress 7.0 owns
6 6 * provider credentials (Settings → Connectors) and model routing
7 7 * (`wp_ai_client_prompt()`, which injects the configured key automatically).
@@ -9,9 +9,9 @@
9 9 * (`ai.enabled`) and expose the Core capability signals the shell uses to
10 10 * decide whether to surface the assistant at all. Provider + model selection
11 11 * is delegated entirely to the Core AI Client — nothing is persisted here.
12 12 *
13 - * @package WPDesktopMode
13 + * @package OpenStation
14 14 */
15 15
16 16 defined( 'ABSPATH' ) || exit;
17 17
@@ -21,15 +21,13 @@
21 21 * `enabled` defaults to `false`: the assistant is opt-in, turned on from
22 22 * OS Settings → Features (and only enable-able once a provider is configured).
23 23 * Provider + model selection is left entirely to the Core AI Client.
24 24 *
25 - * @since 0.5.0
26 - *
27 25 * @param int $user_id
28 26 * @return array{ enabled: bool }
29 27 */
30 -function desktop_mode_ai_get_settings( $user_id ) {
31 - $os = desktop_mode_get_os_settings( (int) $user_id );
28 +function openstation_ai_get_settings( $user_id ) {
29 + $os = openstation_get_os_settings( (int) $user_id );
32 30 $ai = isset( $os['ai'] ) && is_array( $os['ai'] ) ? $os['ai'] : array();
33 31 return array(
34 32 'enabled' => isset( $ai['enabled'] ) ? (bool) $ai['enabled'] : false,
35 33 );
@@ -42,13 +40,11 @@
42 40 * (credentials) and the Abilities API (tools, adopted in a follow-up). When
43 41 * any of these is missing — e.g. WordPress < 7.0, or AI disabled site-wide
44 42 * via `wp_supports_ai()` — the shell hides the assistant entirely.
45 43 *
46 - * @since 0.9.4
47 - *
48 44 * @return bool
49 45 */
50 -function desktop_mode_ai_is_available() {
46 +function openstation_ai_is_available() {
51 47 return function_exists( 'wp_ai_client_prompt' )
52 48 && function_exists( 'wp_get_connectors' )
53 49 && function_exists( 'wp_register_ability' )
54 50 && function_exists( 'wp_supports_ai' )
@@ -60,21 +56,19 @@
60 56 *
61 57 * The baseline capability gate: a no-network, deterministic
62 58 * `is_supported_for_text_generation()` probe against the AI Client registry
63 59 * (which Core populates from the configured Connectors). This is what plain
64 - * text-generation features — e.g. comment scoring, which only needs structured
65 - * text output — gate on. The agentic assistant needs more; see
66 - * {@see desktop_mode_ai_assistant_provider_configured()}.
60 + * text-generation features — the on-demand comment analysis ability, which
61 + * only needs structured text output — gate on. The agentic assistant needs more; see
62 + * {@see openstation_ai_assistant_provider_configured()}.
67 63 *
68 64 * Credentials are supplied by Core from the configured Connector; no API request
69 65 * is made.
70 66 *
71 - * @since 0.9.4
72 - *
73 67 * @return bool
74 68 */
75 -function desktop_mode_ai_provider_configured() {
76 - if ( ! desktop_mode_ai_is_available() ) {
69 +function openstation_ai_provider_configured() {
70 + if ( ! openstation_ai_is_available() ) {
77 71 return false;
78 72 }
79 73 return (bool) wp_ai_client_prompt( 'test' )->is_supported_for_text_generation();
80 74 }
@@ -92,20 +86,18 @@
92 86 *
93 87 * Falls back to the plain text-generation gate when the SDK's FunctionDeclaration
94 88 * class isn't present (e.g. older WordPress).
95 89 *
96 - * @since 0.9.4
97 - *
98 90 * @return bool
99 91 */
100 -function desktop_mode_ai_assistant_provider_configured() {
101 - if ( ! desktop_mode_ai_is_available() ) {
92 +function openstation_ai_assistant_provider_configured() {
93 + if ( ! openstation_ai_is_available() ) {
102 94 return false;
103 95 }
104 96
105 - $probe = desktop_mode_ai_capability_probe_declaration();
97 + $probe = openstation_ai_capability_probe_declaration();
106 98 if ( ! $probe ) {
107 - return desktop_mode_ai_provider_configured();
99 + return openstation_ai_provider_configured();
108 100 }
109 101
110 102 return (bool) wp_ai_client_prompt( 'test' )
111 103 ->using_function_declarations( $probe )
@@ -119,13 +111,11 @@
119 111 * support check additionally requires function-calling capability. Returns null
120 112 * when the SDK class isn't available, letting the caller fall back to a plain
121 113 * text-generation check.
122 114 *
123 - * @since 0.9.4
124 - *
125 115 * @return object|null A `FunctionDeclaration`, or null.
126 116 */
127 -function desktop_mode_ai_capability_probe_declaration() {
117 +function openstation_ai_capability_probe_declaration() {
128 118 $class = '\WordPress\AiClient\Tools\DTO\FunctionDeclaration';
129 119 if ( ! class_exists( $class ) ) {
130 120 return null;
131 121 }
@@ -144,18 +134,16 @@
144 134 * Whether the AI assistant is active for a given user.
145 135 *
146 136 * This is purely the per-user toggle (default off, opt-in). Availability of the Core
147 137 * APIs and whether a provider key is set are separate, orthogonal checks
148 - * ({@see desktop_mode_ai_is_available()} / {@see desktop_mode_ai_provider_configured()})
138 + * ({@see openstation_ai_is_available()} / {@see openstation_ai_provider_configured()})
149 139 * so callers can distinguish "user turned it off" from "not set up yet".
150 140 *
151 - * @since 0.5.0
152 - *
153 141 * @param int $user_id
154 142 * @return bool
155 143 */
156 -function desktop_mode_ai_is_enabled( $user_id ) {
157 - $ai = desktop_mode_ai_get_settings( (int) $user_id );
144 +function openstation_ai_is_enabled( $user_id ) {
145 + $ai = openstation_ai_get_settings( (int) $user_id );
158 146 return ! empty( $ai['enabled'] );
159 147 }
160 148
161 149 /**
@@ -167,26 +155,24 @@
167 155 *
168 156 * - `assistantProviderConfigured` — a provider that supports text generation
169 157 * *and* function calling (what the agentic assistant needs). Gates the Cmd+K
170 158 * assistant, its admin-bar icon, and the "AI assistant" toggle in Features.
171 - * - `providerConfigured` — the baseline text-generation gate. Comment scoring
172 - * (which only needs text output) gates on this; the client uses it for the
173 - * "Score new comments with AI" mirror.
159 + * - `providerConfigured` — the baseline text-generation gate, for the calls
160 + * that need text output but not function calling (the Drafts writing
161 + * assistant, the on-demand comment analysis ability).
174 162 *
175 163 * Provider + model selection is delegated to the Core AI Client, so there is no
176 164 * per-user preference to carry here.
177 165 *
178 - * @since 0.9.4
179 - *
180 166 * @param int|null $user_id Defaults to the current user.
181 167 * @return array{ available: bool, providerConfigured: bool, assistantProviderConfigured: bool, enabled: bool, connectorsUrl: string }
182 168 */
183 -function desktop_mode_ai_assistant_config( $user_id = null ) {
169 +function openstation_ai_assistant_config( $user_id = null ) {
184 170 $user_id = null === $user_id ? get_current_user_id() : (int) $user_id;
185 171
186 172 $connectors_url = admin_url( 'options-connectors.php' );
187 173
188 - if ( ! desktop_mode_ai_is_available() ) {
174 + if ( ! openstation_ai_is_available() ) {
189 175 return array(
190 176 'available' => false,
191 177 'providerConfigured' => false,
192 178 'assistantProviderConfigured' => false,
@@ -194,14 +180,14 @@
194 180 'connectorsUrl' => $connectors_url,
195 181 );
196 182 }
197 183
198 - $ai = desktop_mode_ai_get_settings( $user_id );
184 + $ai = openstation_ai_get_settings( $user_id );
199 185
200 186 return array(
201 187 'available' => true,
202 - 'providerConfigured' => desktop_mode_ai_provider_configured(),
203 - 'assistantProviderConfigured' => desktop_mode_ai_assistant_provider_configured(),
188 + 'providerConfigured' => openstation_ai_provider_configured(),
189 + 'assistantProviderConfigured' => openstation_ai_assistant_provider_configured(),
204 190 'enabled' => (bool) $ai['enabled'],
205 191 'connectorsUrl' => $connectors_url,
206 192 );
207 193 }
@@ -208,21 +194,19 @@
208 194
209 195 /**
210 196 * REST: GET `desktop-mode/v1/ai/status`.
211 197 *
212 - * Returns the current {@see desktop_mode_ai_assistant_config()} so the shell
198 + * Returns the current {@see openstation_ai_assistant_config()} so the shell
213 199 * can re-check provider availability without a page reload — e.g. after the
214 200 * user configures an AI provider in Settings → Connectors.
215 - *
216 - * @since 0.9.4
217 201 */
218 -function desktop_mode_register_ai_status_rest_route() {
202 +function openstation_register_ai_status_rest_route() {
219 203 register_rest_route(
220 204 'desktop-mode/v1',
221 205 '/ai/status',
222 206 array(
223 207 'methods' => WP_REST_Server::READABLE,
224 - 'callback' => 'desktop_mode_rest_ai_status',
208 + 'callback' => 'openstation_rest_ai_status',
225 209 'permission_callback' => static function () {
226 210 return is_user_logged_in() && current_user_can( 'read' );
227 211 },
228 212 )
@@ -227,17 +211,14 @@
227 211 },
228 212 )
229 213 );
230 214 }
231 -add_action( 'rest_api_init', 'desktop_mode_register_ai_status_rest_route' );
215 +add_action( 'rest_api_init', 'openstation_register_ai_status_rest_route' );
232 216
233 217 /**
234 218 * REST handler for the AI status probe.
235 219 *
236 - * @since 0.9.4
237 - *
238 220 * @return WP_REST_Response
239 221 */
240 -function desktop_mode_rest_ai_status() {
241 - return rest_ensure_response( desktop_mode_ai_assistant_config() );
222 +function openstation_rest_ai_status() {
223 + return rest_ensure_response( openstation_ai_assistant_config() );
242 224 }
243 -