PluginProbe
OpenStation: Desktop Windows, Dock & Virtual Desktops for WP Admin / 0.9.8
OpenStation: Desktop Windows, Dock & Virtual Desktops for WP Admin v0.9.8
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
desktop-mode / includes / agents / bootstrap.php

bootstrap.php in OpenStation: Desktop Windows, Dock & Virtual Desktops for WP Admin 0.9.8, at includes/agents/bootstrap.php

85 lines 3.1 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Desktop Mode — Agents module bootstrap.
4 *
5 * Agents are durable workers that live on the site as real WordPress
6 * users and act through the WordPress Abilities API under their own
7 * role and capabilities. Three layers:
8 *
9 * - Guard — the marker meta, the agent test, and every login /
10 * session block → guard.php (ALWAYS loaded)
11 * - Identity — the synthetic `wp_users` row itself → identity.php
12 * - Definition — everything else (system prompt, description, ability
13 * allowlist, triggers, model override, rate limit) as
14 * user meta on that row → store.php
15 *
16 * Plus the abilities bridge + runner (runner.php), a REST surface at
17 * `/desktop-mode/v1/agents` (rest.php), privacy hooks (privacy.php),
18 * the "Agent chat" native window (run-window.php), and the Agents
19 * section inside the site folder (my-wordpress.php).
20 *
21 * The module is opt-in behind the `agents` extended option — while
22 * off, no user-meta registration, no REST routes, no window, no
23 * site-folder entity. The one exception is guard.php: see below.
24 *
25 * @package WPDesktopMode
26 */
27
28 defined( 'ABSPATH' ) || exit;
29
30 /**
31 * The authentication guard loads unconditionally, ahead of the feature
32 * flag. Disabling the Agents framework does not delete the agent user
33 * rows, and an agent row whose login blocks unloaded with the feature
34 * would accept application passwords and password resets again. The
35 * blocks are a property of the rows, not of the feature.
36 */
37 require_once DESKTOP_MODE_DIR . 'includes/agents/guard.php';
38
39 /**
40 * Whether the Agents framework is enabled site-wide.
41 *
42 * Backed by the `agents` key of the extended options bundle
43 * (`desktop_mode_get_extended_options()`), default off — opt-in.
44 *
45 * @return bool
46 */
47 function desktop_mode_agents_enabled() {
48 $options = desktop_mode_get_extended_options();
49 $enabled = ! empty( $options['agents'] );
50
51 /**
52 * Filters whether the Agents framework is enabled site-wide.
53 *
54 * Runs on `plugins_loaded` (priority 5) to decide whether the
55 * agents module loads at all, and again at runtime wherever the
56 * enabled state is consulted.
57 *
58 * @param bool $enabled Whether the Agents framework is enabled.
59 */
60 return (bool) apply_filters( 'desktop_mode_agents_enabled', $enabled );
61 }
62
63 /**
64 * Loads the agents module when the framework is enabled.
65 *
66 * @access private
67 */
68 function desktop_mode_agents_load() {
69 if ( ! desktop_mode_agents_enabled() ) {
70 return;
71 }
72
73 require_once DESKTOP_MODE_DIR . 'includes/agents/store.php';
74 require_once DESKTOP_MODE_DIR . 'includes/agents/defaults.php';
75 require_once DESKTOP_MODE_DIR . 'includes/agents/identity.php';
76 require_once DESKTOP_MODE_DIR . 'includes/agents/abilities.php';
77 require_once DESKTOP_MODE_DIR . 'includes/agents/runner.php';
78 require_once DESKTOP_MODE_DIR . 'includes/agents/rest.php';
79 require_once DESKTOP_MODE_DIR . 'includes/agents/conversations.php';
80 require_once DESKTOP_MODE_DIR . 'includes/agents/privacy.php';
81 require_once DESKTOP_MODE_DIR . 'includes/agents/run-window.php';
82 require_once DESKTOP_MODE_DIR . 'includes/agents/my-wordpress.php';
83 }
84 add_action( 'plugins_loaded', 'desktop_mode_agents_load', 5 );
85