PluginProbe
ThinkRank AI SEO – AI SEO Plugin for WordPress: Schema, XML Sitemaps, Meta Tags, Search Console & Local SEO / 2.10.0
ThinkRank AI SEO – AI SEO Plugin for WordPress: Schema, XML Sitemaps, Meta Tags, Search Console & Local SEO v2.10.0
2.10.0 2.9.0 2.8.0 2.7.0 2.6.0 2.5.0 2.4.0 2.3.0 2.2.0 2.1.1 2.1.0 2.0.2 2.0.1 2.0.0 1.32.0 1.31.0 1.30.0 1.29.0 1.28.0 1.27.0 1.26.0 1.25.0 trunk 1.0.0 1.0.1 All 51 releases
thinkrank / includes / abilities / settings / class-get-ai-budget.php

class-get-ai-budget.php in ThinkRank AI SEO – AI SEO Plugin for WordPress: Schema, XML Sitemaps, Meta Tags, Search Console & Local SEO 2.10.0, at includes/abilities/settings/class-get-ai-budget.php

100 lines 2.5 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Get AI budget ability.
4 *
5 * @package ThinkRank\Abilities\Settings
6 */
7
8 declare(strict_types=1);
9
10 namespace ThinkRank\Abilities\Settings;
11
12 use ThinkRank\Abilities\Ability_Base;
13 use ThinkRank\AI\Spend_Guard;
14
15 if ( ! defined( 'ABSPATH' ) ) {
16 exit; // Exit if accessed directly.
17 }
18
19 /**
20 * Reports what ThinkRank has spent against the site's AI limits today.
21 *
22 * Reads the live counter rather than the stored setting alone, so an agent
23 * asked "how much AI have we used today" gets the number the guard is actually
24 * enforcing against (#448).
25 */
26 class Get_Ai_Budget extends Ability_Base {
27
28 /**
29 * Constructor.
30 */
31 public function __construct() {
32 $this->id = 'thinkrank/get-ai-budget';
33 $this->label = __( 'Get ThinkRank AI Budget', 'thinkrank' );
34 $this->description = __( 'Retrieve ThinkRank AI spend limits and today\'s usage: whether AI is paused, the daily request ceiling (0 means no ceiling), requests used today, requests remaining, the per-minute limit, and when the daily count resets. Use update-ai-budget to change the limits or pause AI.', 'thinkrank' );
35 }
36
37 /**
38 * {@inheritDoc}
39 *
40 * @return array<string, bool|float|string>
41 */
42 public function get_annotations() {
43 return [
44 'readonly' => true,
45 'destructive' => false,
46 'idempotent' => true,
47 'priority' => 1.0,
48 'openWorldHint' => false,
49 ];
50 }
51
52 /**
53 * {@inheritDoc}
54 *
55 * @return array<string, mixed>
56 */
57 public function get_input_schema() {
58 return [
59 'type' => 'object',
60 'additionalProperties' => false,
61 'properties' => self::empty_properties(),
62 ];
63 }
64
65 /**
66 * {@inheritDoc}
67 *
68 * @return array<string, mixed>
69 */
70 public function get_output_schema() {
71 return [
72 'type' => 'object',
73 'properties' => [
74 'paused' => [ 'type' => 'boolean' ],
75 'daily_limit' => [ 'type' => 'integer' ],
76 'used_today' => [ 'type' => 'integer' ],
77 'remaining_today' => [ 'type' => [ 'integer', 'null' ] ],
78 'per_minute_limit' => [ 'type' => 'integer' ],
79 'resets_at' => [ 'type' => 'string' ],
80 'blocked' => [ 'type' => 'boolean' ],
81 'blocked_reason' => [
82 'type' => [ 'string', 'null' ],
83 'enum' => [ Spend_Guard::REASON_PAUSED, Spend_Guard::REASON_DAILY_LIMIT, null ],
84 ],
85 'message' => [ 'type' => 'string' ],
86 ],
87 ];
88 }
89
90 /**
91 * Execute ability.
92 *
93 * @param array<string, mixed> $input Ability input payload.
94 * @return array<string, mixed>
95 */
96 public function execute( $input ) {
97 return Spend_Guard::status();
98 }
99 }
100