Files
Plexum-openai-provider/scripts
hzhang 33de696653 feat: Plexum-openai-provider v0.1 — OpenAI codex CLI as backend
Plexum ProviderPlugin that wraps the local `codex` CLI binary
(OpenAI Codex CLI ≥ 0.135). Same CLI-driven pattern as
Plexum-gemini-provider and Plexum-anthropic-provider's contractor.

internal/runner/ (~200 LOC):
- Per Plexum turn, fork:
    codex exec [resume <thread_id>] \
      --skip-git-repo-check \
      --dangerously-bypass-approvals-and-sandbox \
      --json \
      [--model <m>] \
      "<last user msg>"
  in agent workspace, with stdin = /dev/null (codex would otherwise
  block waiting for additional input).
- Stream-parses JSONL events:
    thread.started        → save thread_id to .plexum-codex-session
    item.completed        → if type==agent_message, emit text_delta
    turn.completed        → capture usage (input/output/cached/reasoning)
    error / turn.failed   → emit canonical EventError
- Other event types (turn.started, item.started, reasoning, etc.)
  logged at debug, don't produce user-facing events for v1

cmd/plexum-openai-provider-plugin/ implements ProviderPluginWithAgent
(needs AgentContext.Workspace as cwd).

Model surface:
  default: ["codex"]  (no --model flag → CLI default; only thing
                       ChatGPT-account installs support)
  override via config.supported_models + config.model_args for
  API-key installs that want gpt-5 / o3 / etc.

HostConfig (all optional):
  binary           default "codex" (operator should set abs path for
                   systemd PATH)
  extra_args       appended before the prompt
  supported_models override the advertised model list
  model_args       map plexum id → CLI --model value

No api_key field — codex CLI handles auth via ~/.codex/ state
(ChatGPT login OR OPENAI_API_KEY env).

End-to-end verified against local install (ChatGPT login):

1. CLI turn 1:        "OpenAI built me."
2. CLI turn 2 (resume): "I said: 'OpenAI built me.'" (multi-turn ✓)
3. Fabric channel e2e: alice → cx agent → codex CLI → outbound REST →
   seq=23: "Use list comprehensions for concise, readable filtering and
            transformation of iterables."

Known: when daemon runs under systemd PATH doesn't include nvm/local
bin dirs; operator must set absolute binary path in config.json.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-31 20:44:42 +01:00
..