Foundry.CodexProvider (foundry v0.1.1)

Copy Markdown

Spawns OpenAI Codex CLI as a subprocess and streams responses.

Uses codex exec --json so the LiveView can consume structured events while Codex runs with the target project as its working root.

Summary

Functions

Runs a conversation through Codex CLI.

Runs a conversation through Codex CLI and calls on_event as text arrives.

Functions

chat(messages, opts \\ [])

Runs a conversation through Codex CLI.

Options

  • :system_prompt - Foundry's system prompt
  • :timeout_ms - max wait time in milliseconds
  • :model - model override; nil uses Codex config/default
  • :profile - Codex profile override
  • :project_root - working directory for Codex
  • :sandbox - Codex sandbox mode, defaults to workspace-write
  • :executable - executable name/path, defaults to codex

Returns

{:ok, text, metadata} or {:error, reason}

stream(messages, opts \\ [], on_event)

Runs a conversation through Codex CLI and calls on_event as text arrives.

Events are:

  • {:delta, text} - newly streamed assistant text
  • {:trace, event} - structured Codex JSON event
  • {:result, text, metadata} - final successful response