@ever-works/codex-plugin
Full pipeline plugin that delegates work generation to the Codex CLI. A single Codex session researches, creates, and updates work item JSON files inside a temporary workspace.
Plugin metadata
| Field | Value |
|---|---|
| ID | codex |
| Category | pipeline |
| Capabilities | pipeline, form-schema-provider, device-auth |
| Author | Ever Works Team |
| License | AGPL-3.0 |
| Built-in | yes |
| Auto-enable | no |
Pipeline Steps
The plugin runs 6 sequential steps:
| # | Step | Description | Optional |
|---|---|---|---|
| 1 | Setup Codex | Downloads/caches the Codex CLI binary and resolves authentication | No |
| 2 | Prepare Context | Creates a temp workspace, seeds existing items and metadata | No |
| 3 | Generate Items | Executes Codex CLI to research and generate items as JSON files | No |
| 4 | Collect Results | Reads generated JSON files back into the pipeline result | No |
| 5 | Capture Screenshots | Takes screenshots for generated items (via screenshot provider) | Yes |
| 6 | Cleanup | Removes the temporary workspace | Yes |
During step 3, a taxonomy watcher monitors the workspace for new item files and keeps _meta/ taxonomy files (categories, tags, brands) in sync in real time. Progress is reported per item as files appear.
Authentication
Codex supports two authentication modes:
API Key
Provide an OpenAI API key in plugin settings (apiKey field).
Get one from platform.openai.com/account/api-keys.
Local Codex Auth
If no API key is configured, the plugin can use local Codex CLI auth stored in a managed per-user CODEX_HOME. Authenticate via the onboarding wizard or manually:
codex login
The plugin materializes an isolated CODEX_HOME for each Ever Works user under its managed temp work, so local Codex auth does not rely on a shared ~/.codex/auth.json.
The onboarding UI provides a 3-step flow: choose auth mode, configure credentials, and verify the connection.
Settings
| Setting | Type | Scope | Description |
|---|---|---|---|
authMode | string | user | api-key or local (hidden, set by onboarding wizard) |
apiKey | string | user | OpenAI API key (secret, supports env var OPENAI_API_KEY) |
model | string | global | Model for generation (default: gpt-5.4) |
unsafeBypassSandbox | boolean | hidden | Bypass Codex sandboxing on incompatible hosts |
Supported Models
- GPT-5.4 (default) - 400k context
- Codex Mini Latest - 200k context
- GPT-5.2 Codex - 400k context
Form Schema
The plugin provides a user-facing form with two configurable fields:
| Field | Type | Default | Validation | Description |
|---|---|---|---|---|
target_items | number | 50 | 1-500 | Target number of new items to generate |
capture_screenshots | boolean | false | - | Take screenshots for generated items |
Prompt System
Prompts are managed through a prompt facade (e.g., Langfuse). When no external prompt is found, hardcoded defaults are used as fallback.
Prompt keys:
codex.system- System prompt templatecodex.user- User prompt template
Both support variable substitution for work context, existing items, categories, tags, and brands.
Binary Management
The plugin automatically downloads and caches the Codex CLI binary:
- Binaries are cached in
/tmp/codex-generator/bin/ - Supports Linux (x64/arm64) and macOS (x64/arm64)
- Falls back to a system-installed
codexcommand if download fails - Default CLI version:
0.120.0
Error Handling
- Non-zero exit codes: Treated as soft warnings. If items were still produced, the result succeeds with warnings attached.
- Sandbox write blocks: Detected and logged, but never retried with sandbox bypass on their own. The detector reads Codex's stdout/stderr, which is model-produced text that injected content (a fetched page, a README) can steer, so it cannot be allowed to escalate a run to
--dangerously-bypass-approvals-and-sandbox. Bypass happens only when the operator explicitly enablesunsafeBypassSandbox(then every run starts bypassed). See Sandbox bypass. - Structured output recovery: If Codex completes without writing item files, the plugin attempts a second pass using
--output-schemaand--output-last-messageto recover structured output. - Masked secrets: The
getRealSecrethelper filters out UI placeholder values (••••) before using credentials.
Project Structure
src/
codex.plugin.ts # Main plugin class (IPlugin, IPipelinePlugin, IFormSchemaProvider, ILocalAuthProvider)
types.ts # Step IDs, constants
steps.ts # Pipeline step definitions
form-schema.ts # Form fields, groups, validation
prompt-keys.ts # Prompt facade keys
device-auth.ts # Device auth flow (codex login --device-auth)
index.ts # Public exports
prompt/
system-prompt.ts # Default prompts and variable builders
utils/
binary-manager.ts # CLI binary download and caching
pipeline-helpers.ts # State management, auth resolution, progress reporting
process-runner.ts # Codex CLI subprocess execution
workspace-manager.ts # Workspace I/O (create, seed, read, cleanup)
screenshot-capture.ts # Screenshot facade integration
taxonomy-sync.ts # Merge new categories/tags/brands into _meta files
taxonomy-watcher.ts # Filesystem watcher for live taxonomy sync
platform.ts # Platform detection helpers
subprocess-env.ts # Environment variable setup for subprocesses
scripts/
smoke-codex.mjs # Manual smoke test script
Development
# Build
pnpm build
# Type-check
pnpm type-check
# Run tests
pnpm test
# Watch mode
pnpm test:watch
# Coverage
pnpm test:coverage
Sandbox bypass
Codex runs inside its own sandbox unless told otherwise. Two paths can run it with
--dangerously-bypass-approvals-and-sandbox (full host access, no approvals):
- Generation pipeline — only when the operator sets
unsafeBypassSandbox: true(hidden setting, defaultfalse). The plugin no longer escalates on its own when Codex's output says writes were blocked: that output is model text, and a prompt-injected model could print exactly those phrases. A declined escalation is logged as a warning; structured-output recovery still runs, sandboxed. - Code-edit path (
executeCodeEdit) — always passes the bypass flag today. It edits a workspace the platform provisioned for the run and needs unrestricted writes there. Treat any host running code-edit as giving the Codex process the plugin's own OS privileges: run it in a container/VM with no credentials or networks it should not reach. This behaviour is unchanged and documented here so it is a known, reviewed trade-off.
Smoke Test
Validate real Codex CLI integration locally:
pnpm smoke
For hosts requiring sandbox bypass:
CODEX_SMOKE_BYPASS_SANDBOX=1 pnpm smoke
Requires either OPENAI_API_KEY in the environment or local Codex auth (codex login).
Troubleshooting
| Symptom | Likely cause | Fix |
|---|---|---|
Generation never starts / stays at 0% | codex not selected as the active pipeline plugin for this work | Open the work → Plugins → pipeline capability and set codex as the active pipeline; or set it as the global pipeline default in Settings → Plugins |
Step fails with No AI / search / screenshot provider configured | Pipeline depends on capability plugins that are not enabled or have no credentials | Enable and configure the matching capability plugin (AI provider, search, screenshot, content-extractor) for the work or globally |
| Step output looks wrong / generic | Form-field tuning not set; pipeline using defaults that don't match the work's domain | Open the Generator Form for the work, set domain-specific fields (categories, target keywords, source URLs), and re-run the affected step |
Subprocess error: command not found | Codex Generator CLI not installed on the host running the API | Install the Codex Generator CLI on the API host and ensure it is on PATH; verify by running which <cli> from the same shell that launches pnpm dev:api |
| Authentication / device-auth flow stalls | Device-auth code never confirmed in the upstream IDE / browser | Re-run the device-auth flow from Settings → Plugins → codex → Connect, then complete the prompt in the upstream service before the code expires |
| Pipeline cannot resume after host restart | Checkpoint not persisted (only the standard pipeline persists checkpoints today) | Cancel the stuck run and re-trigger generation; for production reliability prefer standard-pipeline |
Documentation
License
AGPL-3.0