Scriptorium AI Provider for Codex
WordPress AI provider plugin backed by a hosted Codex broker
by htperkins · github.com/henryperkins/ai-provider-for-codex · website
★ 0stars
1forks
Install
No release zip yet. The repository archive installs, but the folder name will carry the branch suffix and updates will not flow:
wp plugin install https://github.com/henryperkins/ai-provider-for-codex/archive/refs/heads/main.zipWordPress AI Client provider plugin for Codex text models and capability-gated Codex image generation using a local sidecar runtime and ChatGPT-managed authentication and billing.
Architecture
LOCAL-SIDECAR-SPEC.mdis the implementation spec for the localhost sidecar architecture.- The WordPress plugin stores site runtime settings and per-user connection state locally.
- A localhost sidecar wraps
codex app-server, handles device-code login, and keeps auth isolated per WordPress user. - The plugin talks only to the local runtime for health checks, account snapshots, text generation, and capability-gated text-to-image generation.
- Status screens stay read-only and use stored local connection state; explicit connect checks, snapshot refreshes, and live runtime requests reconcile auth against the sidecar.
- Billing plan display is informational only and mirrors the latest account snapshot; if the runtime stops reporting a plan, the stored value is cleared.
- If the WordPress AI plugin's experimental Connector Approval feature is enabled, this plugin performs a one-time approval for its own
codexconnector during activation or the next normal boot. It does not pre-approve while the experiment is disabled, and if the approval is later revoked, runtime calls stay blocked until an administrator re-approves it underTools > Connector Approvalsor disables the experiment.
Included
scriptorium-ai-provider-for-codex.phpbootstrap with WordPress and AI Client checks- provider registration for
codex - Connectors integration for runtime status and user connection actions
- site settings for runtime base URL, bearer token, and fallback models
- local tables for per-user connections and connection snapshots
- snapshot-backed text model catalogs and a synthetic
codex-imagemodel when Codex reports image support - per-user device-code connect, refresh, and disconnect flows
- REST endpoints for connect, status, refresh, disconnect, and readiness checks
- local sidecar app under
sidecar/ - repeatable verification scripts in
scripts/verify.phpandscripts/verify.sh
Current Status
- Phase 1 functional cutover to the localhost runtime is complete.
- Phase 2 cleanup removed the remaining legacy compatibility aliases from the active plugin code and docs.
- Pending device-code sessions now recover cleanly after a sidecar restart when
auth.jsonalready exists for that user. - Text-to-image generation is available through
codex-imageonly for connected users whose current Codex app-server snapshot reportsimageGeneration: true.
Quick Start On A WordPress Host
- Install and activate the plugin in WordPress.
- On the same host as WordPress, install Python 3.11+ and the
codexCLI. - Create a localhost systemd service from
sidecar/systemd/codex-wp-sidecar.serviceand write/etc/codex-wp-sidecar.envwith the runtime settings. - Open
Settings > Codex Providerand confirm the runtime URL and bearer token were auto-detected from/etc/codex-wp-sidecar.env, or enter them manually. - Open
Settings > Connectorsand confirm Codex reports a healthy local runtime. - Each user then opens
Users > Codex Provider, clicksConnect Codex account, and completes the device-code login.
Verification
WP_PATH=/path/to/site ./scripts/verify.shwp --path=/path/to/site eval-file wp-content/plugins/scriptorium-ai-provider-for-codex/scripts/verify.phppython3 sidecar/scripts/test-image-generation.py
Automated Sidecar Setup
sidecar/systemd/codex-wp-sidecar.serviceprovides a systemd template for running the sidecar.- The plugin can auto-detect the runtime URL and bearer token from
/etc/codex-wp-sidecar.envwhen PHP can read that file. - The runtime status probe now checks
GET /healthz, so Connectors can reportRuntime unreachablebefore a user hits the connect action.