mirror of
https://github.com/rennf93/roboco.git
synced 2026-08-03 07:23:24 +02:00
feat(providers): Codex CLI provider — OpenAI via ModelProvider.OPENAI (#659)
* feat(providers): Codex CLI provider — OpenAI via ModelProvider.OPENAI Mirrors the grok blueprint end to end: CodexCliProvider (RO ~/.codex mount, ANTHROPIC_* blanked), an orchestrator-side codex_auth.py refresher (JWT-exp staleness, atomic rewrite, lock-serialized single-use rotation, --check backstop; the CLI's own in-process refresh write no-ops on the RO mount by design — margins keep the orchestrator ahead of the CLI's 5-minute window), config.toml rendering with required=true gateway MCP servers, execpolicy deny rules (forbidden-only), per-role --sandbox (developer=workspace-write, review/doc roles read-only), codex exec --json with pinned ROBOCO_CODEX_CLI_MODEL (gpt-5.3-codex), usage summed from typed turn.completed events priced via the real 4-bucket split, dedicated image + entrypoint, registry/park/finalize/ compose/release wiring. V1 excludes interactive intake/secretary. Per adversarial review: migration 083 seeds the openai provider row enabled=True (without it every routing path 404'd — the whole feature was operationally dead code; grok needed the same seed in 039), the panel picker gained the OpenAI catalog group it silently lacked, and exit classification is structural — only stderr and error.message fields from error events are sniffed (word-boundaried patterns, exact auth phrases, bare 'login' dropped), so the model echoing on-topic words can never false-park the provider fleet-wide, proven by a benign-transcript test. Known open risk flagged, not claimed: whether codex's workspace-write OS sandbox excludes /app is unverified, and no hook mechanism exists to port the bash-guard defense-in-depth. * fix(providers): containment barrier on usage.json reads (code scanning) CodeQL flagged the codex usage read as path injection — correctly: os.path.basename does not neutralize '..', and the upstream segment validator isn't in CodeQL's taint model. The grok/codex reads collapse into one _read_usage_json_contained helper that resolves the built path and refuses anything outside the resolved usage root — a hostile id can never escape regardless of upstream drift. Traversal + containment regression tests added; a stray noqa in the test file replaced with a named constant per repo rule. * fix(providers): use realpath+startswith containment CodeQL recognizes The is_relative_to() guard was a real barrier but not in CodeQL's py/path-injection sanitizer model, so the alert persisted. Switch to the canonical os.path.realpath + startswith(root + os.sep) form, which CodeQL recognizes as a path-traversal barrier; behavior is identical (refuse any candidate resolving outside the usage root). * fix(providers): regexp-allowlist the usage-id segment (CodeQL barrier) Neither is_relative_to nor realpath+startswith was recognized by CodeQL's py/path-injection sanitizer model across the str->Path->open flow. Sanitize the tainted component at the source instead: the id must fullmatch a strict slug token ([A-Za-z0-9][A-Za-z0-9._-]*, no separators, no '..'), which CodeQL recognizes as a path-injection barrier; the realpath+startswith containment stays as defense-in-depth. * fix(providers): standalone regexp guard so CodeQL recognizes the barrier The sanitizer was one disjunct of a compound 'or' condition, which CodeQL's guard analysis does not trace as a barrier. Split the regexp fullmatch into its own single-condition guard (the redundant '..' check is dropped — the required alphanumeric first char already excludes it). --------- Co-authored-by: Renn F <rennf93@users.noreply.github.com>
This commit is contained in:
@@ -391,6 +391,20 @@ services:
|
||||
depends_on:
|
||||
- agent-grok-image
|
||||
|
||||
# ==========================================================================
|
||||
# Agent Codex Image Builder (OpenAI via the official codex CLI). One-shot
|
||||
# delivery roles only in V1 — no interactive prompter/secretary variant.
|
||||
# ==========================================================================
|
||||
agent-codex-image:
|
||||
build:
|
||||
context: .
|
||||
dockerfile: docker/agent-codex.Dockerfile
|
||||
image: roboco-agent-codex
|
||||
entrypoint: ["/bin/sh", "-c", 'echo "Agent Codex image built"']
|
||||
restart: "no"
|
||||
depends_on:
|
||||
- agent-base-image
|
||||
|
||||
# ==========================================================================
|
||||
# Sandbox PG Image Builder (kitchen-sink postgres for parameterized dev DBs)
|
||||
# Only pulled by the provisioner when a venture requests pg extensions; bare
|
||||
@@ -474,6 +488,9 @@ services:
|
||||
# SuperGrok auth (host ~/.grok) for Grok-CLI agents — the orchestrator
|
||||
# mounts <dir>/auth.json into each Grok agent. Run `grok login` on the host.
|
||||
ROBOCO_HOST_GROK_DIR: ${ROBOCO_HOST_GROK_DIR:-/home/renzof/.grok}
|
||||
# ChatGPT-subscription auth (host ~/.codex) for Codex-CLI agents — same
|
||||
# shape as ROBOCO_HOST_GROK_DIR. Run `codex login` on the host.
|
||||
ROBOCO_HOST_CODEX_DIR: ${ROBOCO_HOST_CODEX_DIR:-/home/renzof/.codex}
|
||||
ROBOCO_HOST_DATA_DIR: ${ROBOCO_HOST_DATA_DIR:-/volume1/roboco/data}
|
||||
# Public base URL for commit-trailer links. Default 127.0.0.1 produces
|
||||
# unusable links in commit message bodies; set to NAS LAN IP so
|
||||
@@ -669,6 +686,10 @@ services:
|
||||
# (grok_auth.refresh_if_stale) so agents never mount a dead credential;
|
||||
# each agent's own auth.json mount stays read-only.
|
||||
- ${ROBOCO_HOST_GROK_DIR:-/home/renzof/.grok}:${ROBOCO_HOST_GROK_DIR:-/home/renzof/.grok}
|
||||
# Codex CLI auth — same shape as the SuperGrok mount above. Read-WRITE:
|
||||
# the orchestrator auto-refreshes the access token in place
|
||||
# (codex_auth.refresh_if_stale); each agent's own mount stays read-only.
|
||||
- ${ROBOCO_HOST_CODEX_DIR:-/home/renzof/.codex}:${ROBOCO_HOST_CODEX_DIR:-/home/renzof/.codex}
|
||||
# Shared config directory for MCP configs (writable)
|
||||
- ${ROBOCO_DATA_DIR:-./data}/mcp-configs:/app/mcp-configs
|
||||
- ${ROBOCO_DATA_DIR:-./data}/vault:/app/vault
|
||||
@@ -681,6 +702,8 @@ services:
|
||||
# Per-agent GROK usage capture: each Grok agent writes usage.json under
|
||||
# <agent_id>/; the finalizer reads the captured tokens/cost back here.
|
||||
- ${ROBOCO_DATA_DIR:-./data}/grok-usage:/data/grok-usage
|
||||
# Per-agent CODEX usage capture — same shape as grok-usage above.
|
||||
- ${ROBOCO_DATA_DIR:-./data}/codex-usage:/data/codex-usage
|
||||
# Persistent logs — survive `docker compose down/up`. Orchestrator and
|
||||
# each spawned agent write structured logs here so we can audit past
|
||||
# runs instead of relying on ephemeral `docker logs`.
|
||||
|
||||
Reference in New Issue
Block a user