| @@ -19,10 +19,10 @@ | ||
| 19 | 19 | * section inside WP Explorer (my-wordpress.php). |
| 20 | 20 | * |
| 21 | 21 | * The module is opt-in behind the `agents` extended option — while |
| 22 | 22 | * off, no user-meta registration, no REST routes and no chat window. |
| 23 | - * Two files load regardless of the flag: guard.php and | |
| 24 | - * my-wordpress.php. See below for why. | |
| 23 | + * Guard, WP Explorer discovery, and job cleanup load regardless of the flag. | |
| 24 | + * See below for why. | |
| 25 | 25 | * |
| 26 | 26 | * @package OpenStation |
| 27 | 27 | */ |
| 28 | 28 | |
| @@ -54,11 +54,25 @@ | ||
| 54 | 54 | * desktop user-tile renderer), and `data` is not in |
| 55 | 55 | * `wp_allowed_protocols()` — the data URI silently becomes an empty |
| 56 | 56 | * string and the avatar renders broken. |
| 57 | 57 | * |
| 58 | + * With an agent id, this is that agent's own Mio portrait when one has | |
| 59 | + * been written. Without one, or before the face file exists, it is the | |
| 60 | + * shipped robot glyph, which is what every agent wore before faces. | |
| 61 | + * | |
| 62 | + * @param int $user_id Agent user id, or 0 for the generic glyph. | |
| 58 | 63 | * @return string |
| 59 | 64 | */ |
| 60 | -function openstation_agent_avatar_url() { | |
| 65 | +function openstation_agent_avatar_url( $user_id = 0 ) { | |
| 66 | + // Called with no argument for the generic case: the WP Explorer | |
| 67 | + // section icon, and the fallback for an agent that has no face yet. | |
| 68 | + // A section icon wearing one agent's face would be wrong. | |
| 69 | + if ( $user_id > 0 && function_exists( 'openstation_agent_face_url' ) ) { | |
| 70 | + $face = openstation_agent_face_url( (int) $user_id ); | |
| 71 | + if ( '' !== $face ) { | |
| 72 | + return $face; | |
| 73 | + } | |
| 74 | + } | |
| 61 | 75 | return OPENSTATION_URL . 'assets/images/agent-avatar.svg'; |
| 62 | 76 | } |
| 63 | 77 | |
| 64 | 78 | /** |
| @@ -140,8 +154,10 @@ | ||
| 140 | 154 | * Loaded after the helpers above, which it needs to build the entity |
| 141 | 155 | * descriptor and the section config. |
| 142 | 156 | */ |
| 143 | 157 | require_once OPENSTATION_DIR . 'includes/agents/my-wordpress.php'; |
| 158 | +// Queued work must fail safely and retained data must expire even when disabled. | |
| 159 | +require_once OPENSTATION_DIR . 'includes/agents/jobs.php'; | |
| 144 | 160 | |
| 145 | 161 | /** |
| 146 | 162 | * Loads the agents module when the framework is enabled. |
| 147 | 163 | * |
| @@ -154,10 +170,12 @@ | ||
| 154 | 170 | |
| 155 | 171 | require_once OPENSTATION_DIR . 'includes/agents/store.php'; |
| 156 | 172 | require_once OPENSTATION_DIR . 'includes/agents/defaults.php'; |
| 157 | 173 | require_once OPENSTATION_DIR . 'includes/agents/identity.php'; |
| 174 | + require_once OPENSTATION_DIR . 'includes/agents/face.php'; | |
| 158 | 175 | require_once OPENSTATION_DIR . 'includes/agents/abilities.php'; |
| 159 | 176 | require_once OPENSTATION_DIR . 'includes/agents/runner.php'; |
| 177 | + require_once OPENSTATION_DIR . 'includes/agents/draft.php'; | |
| 160 | 178 | require_once OPENSTATION_DIR . 'includes/agents/rest.php'; |
| 161 | 179 | require_once OPENSTATION_DIR . 'includes/agents/conversations.php'; |
| 162 | 180 | require_once OPENSTATION_DIR . 'includes/agents/privacy.php'; |
| 163 | 181 | require_once OPENSTATION_DIR . 'includes/agents/run-window.php'; |