Add initial plugin implementation per the CTO engineering handoff (geomonitor/threads/2026-06-ai-visibility-v1/01-cto-eng-handoff.md). ## What - PGM_Probe_Provider interface + PGM_Probe_Result value object - PGM_Perplexity_Provider (sonar via OpenRouter/CF AI Gateway) - PGM_OpenRouter_Provider (GPT-search + Gemini-search, generic parameterised) - PGM_Gateway_Client: shared HTTP + exponential-backoff retry (mirrors PRAB) - PGM_Citation_Detector: domain extraction, is_cited(), get_our_position() - PGM_Cost_Ledger: MTD cost from DB, can_afford() pre-check, hard monthly cap - PGM_Probe_Runner: peptides×intents×models run, budget abort, in-run cache - PGM_Table_Manager: pgm_ai_visibility dbDelta, schema-version, drop_table() - PGM_Config: typed getters, seed_defaults() (12 peptides, 3 intents, 3 models) - PGM_Cron: weekly pgm_weekly_probe schedule/clear - PGM_Data_Collector + PGM_Dashboard_Panel interfaces (seam for future panels) - PGM_Collector_Registry: singleton registry - PGM_Ai_Visibility_Collector: trendline, standings, MTD cost (score formula) - PGM_Ai_Visibility_Panel: proxy note, Chart.js trendline, standings table - PGM_Admin_Page: GEO Monitor menu, Run now POST handler (nonce+capability) - uninstall.php: DROP TABLE + DELETE pgm_* options + wp_clear_scheduled_hook - Unit tests (6 files): citation detection, score calc, cost ledger + budget abort, provider response parsing (mock HTTP), cron, uninstall purge - ARCHITECTURE.md, CONVENTIONS.md, CONTEXT.md (score formula), README.md, CHANGELOG.md — same-commit per DoD - CI workflow: PHP lint (8.1/8.2/8.3) + PHPCS + 300-line check ## Security - Secrets from wp-config constants only; none hardcoded - manage_options + nonce on every admin action - Input sanitized; output escaped Agent-Session: geomonitor v0.1.0
57 lines
1.8 KiB
PHP
57 lines
1.8 KiB
PHP
<?php
|
|
declare(strict_types=1);
|
|
|
|
/**
|
|
* Contract for all LLM probe providers.
|
|
*
|
|
* Each provider implementation wraps one LLM backend (Perplexity sonar,
|
|
* OpenRouter GPT-search, OpenRouter Gemini-search, …). Swapping providers
|
|
* requires only a new class — the runner, ledger, and storage are agnostic.
|
|
*
|
|
* Who triggers: PGM_Probe_Runner for each (model, query) combination.
|
|
* Dependencies: None — pure interface.
|
|
*
|
|
* @see class-pgm-perplexity-provider.php — Perplexity sonar implementation.
|
|
* @see class-pgm-openrouter-provider.php — OpenRouter generic implementation.
|
|
* @see class-pgm-probe-runner.php — Dispatches to providers via this interface.
|
|
* @see CONTEXT.md — "provider", "probe".
|
|
* @package PeptideGeoMonitor
|
|
*/
|
|
interface PGM_Probe_Provider {
|
|
|
|
/**
|
|
* Send a search/retrieval query and return a structured probe result.
|
|
*
|
|
* Implementations MUST:
|
|
* - Extract cited source domains from the model's response.
|
|
* - Detect whether PGM_TARGET_DOMAIN appears in those sources.
|
|
* - Record our 1-based position (null when not cited).
|
|
* - Return the call's estimated USD cost.
|
|
* - Throw \RuntimeException on unrecoverable failure (caller logs + skips).
|
|
*
|
|
* @param string $query The natural-language query to send.
|
|
*
|
|
* @return PGM_Probe_Result
|
|
*
|
|
* @throws \RuntimeException When the API call fails after retries.
|
|
*/
|
|
public function probe( string $query ): PGM_Probe_Result;
|
|
|
|
/**
|
|
* Get a short human-readable name for this provider (e.g. "Perplexity sonar").
|
|
*
|
|
* @return string
|
|
*/
|
|
public function get_name(): string;
|
|
|
|
/**
|
|
* Check whether the required credentials/constants are configured.
|
|
*
|
|
* Returns false (never throws) so the runner can skip unconfigured
|
|
* providers without aborting the whole run.
|
|
*
|
|
* @return bool
|
|
*/
|
|
public function is_configured(): bool;
|
|
}
|