=== Aivexa ===
Contributors: vivek28042000
Tags: ai, chatbot, assistant, support, abilities
Requires at least: 7.0
Tested up to: 7.1
Requires PHP: 8.0
Stable tag: 1.0
License: GPLv2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html

Site chat assistant for WordPress using the WordPress AI Client, Connectors, and Abilities API.

== Description ==

Aivexa adds an AI assistant to your WordPress website. Visitors can ask questions, search public site content, perform safe calculations, and more through a lightweight chat interface.

This plugin uses the **WordPress AI Client** (`wp_ai_client_prompt()`). It does **not** call third-party AI provider hosts directly. Provider credentials are managed in **Settings → Connectors**.

Chat tools are registered through the **WordPress Abilities API** and executed only when the administrator enables them.

= How it works =

Visitor → Chat UI → WordPress REST API → Agent → WordPress AI Client → Connected provider → Abilities/tools → Final response

The AI does **not** have unrestricted access to WordPress. It can only use explicitly registered abilities that the administrator enables.

== Features ==

* WordPress AI Client integration (no direct provider HTTP client in plugin code)
* Provider credentials via Settings → Connectors
* Tools registered as WordPress Abilities
* Admin settings under Aivexa
* Frontend shortcode: `[aivexa]`
* Optional floating chat widget
* Lightweight Gutenberg block
* Conversation memory using transients
* Rate limiting for anonymous users
* Admin test interface with safe trace output
* Privacy notice and local usage statistics
* Graceful failure when AI is unavailable

== Installation ==

1. Upload the plugin ZIP via **Plugins → Add New → Upload Plugin**
2. Activate **Aivexa**
3. Open **Settings → Connectors** and configure an AI provider (for example OpenAI)
4. Go to **Aivexa → Settings**
5. Enable the agent and configure tools
6. Add `[aivexa]` to a page or enable the floating widget

== Configuration ==

1. Configure an AI provider under **Settings → Connectors**
2. Enable the agent in Aivexa settings
3. Optionally set a preferred model name
4. Customize the agent name, welcome message, and system instructions
5. Enable the tools you want the assistant to use
6. Configure rate limits and logging as needed
7. Click **Test AI Connection**

== Using the Chat Assistant ==

Use the shortcode:

`[aivexa]`

Or enable the floating widget in settings to show a site-wide chat button.

== Available Tools (Abilities) ==

* **Calculator** — safe math without code execution
* **Site Search** — search public posts and pages
* **Post Search** — search public blog posts
* **Page Search** — search public pages
* **Site Information** — safe public site metadata
* **Contact Tool** — controlled contact submission with explicit confirmation

== External services ==

Aivexa does not hard-code third-party AI endpoints. Requests are sent through the WordPress AI Client to whichever AI provider the site owner connects under **Settings → Connectors**.

If you connect OpenAI (or another provider) through Connectors:

* User messages may be sent to that provider
* Public website content may be sent when search tools are used
* Retention and privacy are governed by that provider and by WordPress Connectors
* Review the provider’s current terms and privacy policy before enabling AI

This plugin is not affiliated with or endorsed by OpenAI or other AI providers.

== Privacy ==

= Local WordPress retention =

* Conversation transcripts and conversation IDs are stored **locally** as WordPress transients for up to **24 hours**.
* Local transients are used for session isolation, conversation continuity, optional admin traces, and privacy export/erase.
* Logging is optional and disabled by default. Optional logs stay in the WordPress database until cleared or the plugin is uninstalled.
* The plugin does not sell user data.
* The plugin does not phone home or send analytics to the plugin author.

= Provider retention =

* User messages may be sent to the connected AI provider through the WordPress AI Client.
* Deleting a local WordPress transient does **not** delete data already sent to a provider.
* Configure your site privacy policy accordingly. Site owners remain responsible for privacy, consent, and legal compliance.

== Security ==

* Provider API keys are managed by WordPress Connectors, not stored by this plugin
* REST endpoints use nonces and permission callbacks
* Input validation, sanitization, and output escaping throughout
* No arbitrary code execution
* Retrieved website content is treated as untrusted data
* Rate limiting helps prevent abuse

== Frequently Asked Questions ==

= Does this store my OpenAI API key? =

No. Configure providers under **Settings → Connectors**. Aivexa uses the WordPress AI Client.

= Can the AI access my entire WordPress admin? =

No. It can only use the abilities/tools you enable.

= What happens if AI is unavailable? =

Visitors see a friendly error message. Your site continues to function normally.

== Troubleshooting ==

* Confirm WordPress 7.0+ and that `wp_ai_client_prompt()` is available
* Open **Settings → Connectors** and verify a provider is connected
* Use **Test AI Connection** in Aivexa settings
* Check that the agent is enabled
* Confirm your hosting allows outbound HTTPS for the connected provider

== Developer Documentation ==

REST namespace: `aivexa/v1`

Endpoints:

* `POST /wp-json/aivexa/v1/chat`
* `POST /wp-json/aivexa/v1/clear-conversation`
* `GET /wp-json/aivexa/v1/status`

Abilities namespace: `aivexa/*`

== Changelog ==

= 1.0 =
* Initial public WordPress.org release as Aivexa
* WordPress AI Client (`wp_ai_client_prompt()`), Connectors, and Abilities API
* Activation shows an admin notice (not wp_die) when the AI Client API is unavailable
* Shortcode `[aivexa]`, optional floating widget, and admin tools/settings
