=== HitlGate Order Review for WooCommerce ===
Contributors: mike36292
Tags: woocommerce, order-management, fraud-prevention, mcp, human-in-the-loop
Requires at least: 6.9
Tested up to: 7.0
Requires PHP: 8.1
Stable tag: 1.0.2
License: GPLv2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html

Human-in-the-loop review queue for WooCommerce high-risk and high-AOV orders.

== Description ==

HitlGate Order Review for WooCommerce helps store operators pause and review risky WooCommerce orders before fulfillment or money-moving actions.

This plugin is not affiliated with AgentOps (agentops.ai), WordPress, WooCommerce, or Automattic.

**Core HITL (works without any required external SaaS)**

* Intake thresholds enqueue orders (minimum amount, AOV spike, optional gateway risk meta, force meta).
* Masked evidence packs for reviewers (PII redacted where applicable).
* Admin queue under **WooCommerce → HitlGate Order Review**.
* Money-moving actions (cancel, partial refund) use a single-use confirm token and the `agentops_confirm_money` capability.
* Intake is fail-open: exceptions are logged and never block checkout.

**Optional integrations**

* **WooCommerce MCP / WordPress Abilities** — expose review tools to Cursor/Claude when Woo MCP is enabled.
* **Natural-language settings** — optional; uses the WordPress AI Client / Connectors (no direct third-party API keys in this plugin).
* **Readiness connector** — optional inbound HMAC webhook to store a catalog readiness summary.
* **WooCommerce Subscriptions** — soft dependency for failed renewal / on-hold enqueue and confirm-gated pause/cancel.

== External services ==

This plugin can optionally connect to third-party services. Core order review does **not** require any external service.

= WordPress AI Client / Connectors (optional) =

Used only if you use natural-language settings proposals.

* **What it is used for:** Turning a plain-language settings request into a proposed settings diff for you to preview and confirm.
* **What data is sent:** The settings schema description and your natural-language prompt are sent through the WordPress AI Client to whichever AI provider you configured under **Settings → Connectors**. Order customer PII is not sent by this feature.
* **When:** Only when an administrator submits a natural-language settings proposal.
* **Default:** No AI provider is called until you configure a connector (for example OpenAI, Anthropic, or Google provider plugins) under Settings → Connectors. This plugin does **not** store third-party AI API keys or call provider endpoints directly.
* Follow the terms and privacy policy of the AI provider you connect via Connectors.

= Optional readiness summary webhook (optional) =

If you configure a webhook secret, an external readiness scanner you control may POST a catalog readiness summary into your site.

* **What it is used for:** Showing a readiness score in evidence packs and optionally influencing intake when you lower the critical-SKU threshold.
* **What data is sent:** Your site does not initiate outbound catalog scans from this plugin. The external service (if you use one) may read public/product data according to that service’s own setup; this plugin only accepts an inbound signed summary.
* **When:** When the configured service posts to `/wp-json/agentops/v1/readiness-summary`.
* Document the terms and privacy policy of whichever readiness service you connect. This plugin does not require a specific vendor.

== Installation ==

1. Upload the `hitlgate-order-review` folder to `/wp-content/plugins/` (or install the zip via **Plugins → Add New → Upload Plugin**).
2. The release zip already includes Composer autoload under `vendor/` — you do **not** need to run `composer install` on the server.
3. Activate **WooCommerce**, then activate **HitlGate Order Review for WooCommerce**.
4. Administrators receive the `agentops_confirm_money` capability on activation.
5. Open **WooCommerce → HitlGate Order Review → Settings** and set intake thresholds.

== Frequently Asked Questions ==

= Does this plugin require an external SaaS? =

No. Core human-in-the-loop review works plugin-only. Natural-language settings use the WordPress AI Client if you configure a provider under Settings → Connectors. The readiness webhook is optional.

= What are the requirements? =

WordPress 6.9+, PHP 8.1+, and WooCommerce 10.3+. WooCommerce Subscriptions is optional.

= Who can confirm cancel or refund actions? =

Users with the `agentops_confirm_money` capability (granted to administrators on activation).

= Does uninstall delete my data? =

By default, uninstall keeps plugin tables and options. To drop data on uninstall, set option `agentops_remove_data` to a truthy value first (example: `wp option update agentops_remove_data 1`).

= What data leaves my site? =

By default, none for core HITL. If you use natural-language settings, prompts are sent via the WordPress AI Client to the provider configured under Settings → Connectors. See **External services**.

= How do I use MCP / Cursor? =

Enable WooCommerce MCP per WooCommerce docs, point your MCP client at the store endpoint, then use the registered abilities (list queue, evidence, draft cancel/refund, confirm-action, settings propose/apply).

== Screenshots ==

1. Review queue listing pending high-risk orders.
2. Order metabox showing a masked evidence pack.
3. Confirm gate flow for draft cancel or partial refund.
4. Settings screen for intake thresholds and token TTL.
5. Optional MCP / Abilities tool flow for agent-assisted review.

== Changelog ==

= 1.0.2 =
* Natural-language settings now use the WordPress AI Client / Connectors instead of a direct third-party HTTP client.
* Removed plugin settings fields for LLM base URL, model, and API key.

= 1.0.1 =
* Plugin Check fixes: output escaping, prepared SQL claim path, ABSPATH guard.
* WordPress.org review follow-up packaging.

= 1.0.0 =
* First WordPress.org submission as HitlGate Order Review for WooCommerce.
* Human-in-the-loop intake, review queue, masked evidence packs, and Admin UI.
* Confirm-token gate for cancel and partial refund.
* Optional readiness HMAC webhook connector.
* Optional natural-language settings propose → apply.
* Optional WooCommerce Subscriptions HITL.
* Public abilities for WooCommerce MCP clients.

== Upgrade Notice ==

= 1.0.2 =
Natural-language settings now require an AI provider under Settings → Connectors. Direct LLM API key fields were removed.

= 1.0.1 =
Plugin Check and review follow-up fixes. Safe to update from 1.0.0.

= 1.0.0 =
Initial public release. Configure intake thresholds after activation.
