Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
53 commits
Select commit Hold shift + click to select a range
5bbca30
feat: add codex module
35C4n0r Aug 1, 2025
be3bc0a
feat: bun fmt
35C4n0r Aug 1, 2025
5ac3d7a
fix: fix typo
35C4n0r Aug 1, 2025
37f85c6
feat: add codex svg
35C4n0r Aug 1, 2025
13b776d
feat: update readme
35C4n0r Aug 1, 2025
4e45ffd
chore: update icon name
35C4n0r Aug 2, 2025
66bb40e
chore: rename codex_api_key to openai_api_key
35C4n0r Aug 2, 2025
b08aadf
chore: rename codex_api_key to openai_api_key
35C4n0r Aug 2, 2025
93b16cb
chore: update README.md
35C4n0r Aug 2, 2025
92e6bb5
chore: bump agentapi_version to v0.3.2
35C4n0r Aug 4, 2025
77393b4
fix: update README.md
35C4n0r Aug 5, 2025
b33bbda
wip: apply suggestions
35C4n0r Aug 5, 2025
dc154d0
fix: apply suggestions
35C4n0r Aug 5, 2025
ee138e1
Update registry/coder-labs/modules/codex/scripts/start.sh
35C4n0r Aug 7, 2025
d32f5d9
Update registry/coder-labs/modules/codex/main.tf
35C4n0r Aug 7, 2025
d08a225
Update registry/coder-labs/modules/codex/scripts/start.sh
35C4n0r Aug 7, 2025
a4481f7
Update registry/coder-labs/modules/codex/scripts/start.sh
35C4n0r Aug 7, 2025
2b7d213
Update registry/coder-labs/modules/codex/scripts/start.sh
35C4n0r Aug 7, 2025
79a3f8e
Update registry/coder-labs/modules/codex/scripts/install.sh
35C4n0r Aug 7, 2025
1a28cd2
Update registry/coder-labs/modules/codex/main.tf
35C4n0r Aug 7, 2025
49eafc5
Update registry/coder-labs/modules/codex/main.tf
35C4n0r Aug 7, 2025
723cdc4
Update registry/coder-labs/modules/codex/README.md
35C4n0r Aug 7, 2025
d4d9b73
Update registry/coder-labs/modules/codex/main.tf
35C4n0r Aug 7, 2025
d0846b7
Update registry/coder-labs/modules/codex/README.md
35C4n0r Aug 7, 2025
aa8a562
Merge branch 'main' into feat-codex-cli
35C4n0r Aug 8, 2025
0c6e9f9
Update registry/coder-labs/modules/codex/README.md
35C4n0r Aug 8, 2025
b73f6dd
fix: apply suggestions
35C4n0r Aug 8, 2025
340ecee
Update registry/coder-labs/modules/codex/README.md
35C4n0r Aug 8, 2025
1c85858
fix: README.md
35C4n0r Aug 8, 2025
3624b91
fix: add test for latest version
35C4n0r Aug 8, 2025
ace0930
fix: add support for codex 0.20.0
35C4n0r Aug 11, 2025
58d675e
fix: fix tests
35C4n0r Aug 11, 2025
55b7741
Update registry/coder-labs/modules/codex/main.tf
35C4n0r Aug 11, 2025
ff54181
Update registry/coder-labs/modules/codex/main.tf
35C4n0r Aug 11, 2025
bb460fe
chore: update README.md
35C4n0r Aug 11, 2025
0f23e73
Merge branch 'main' into feat-codex-cli
35C4n0r Aug 11, 2025
75472e4
Merge branch 'main' into feat-codex-cli
35C4n0r Aug 12, 2025
922063f
Merge branch 'main' into feat-codex-cli
35C4n0r Aug 13, 2025
82ff539
feat: better prompt
35C4n0r Aug 14, 2025
b567f6d
Merge branch 'main' into feat-codex-cli
DevelopmentCats Aug 14, 2025
ce60db3
feat: source bash in install script
35C4n0r Aug 14, 2025
202be74
Merge branch 'main' into feat-codex-cli
DevelopmentCats Aug 18, 2025
911110b
Merge branch 'main' into feat-codex-cli
DevelopmentCats Aug 19, 2025
bddde29
feat: add full_auto variable and argument
DevelopmentCats Aug 19, 2025
7342d95
chore: bun run fmt
DevelopmentCats Aug 19, 2025
75afc2a
fix: remove accidental base64 encoding of full_auto arg
DevelopmentCats Aug 19, 2025
f5a1bdd
fix: update default icon for app in codex module
DevelopmentCats Aug 19, 2025
2b47e77
fix: enhance README and install script for Codex module sandbox confi…
DevelopmentCats Aug 19, 2025
5e9f0dd
feat: add sandbox_mode, approval_policy, and network_access variables…
DevelopmentCats Aug 19, 2025
cac6483
docs: update README for Codex module configuration details
DevelopmentCats Aug 19, 2025
57e7fcd
chore: update default AgentAPI version to latest in Codex module
DevelopmentCats Aug 19, 2025
0a0657c
chore: bun run fmt
DevelopmentCats Aug 19, 2025
28edf08
feat: pin agentapi version
35C4n0r Aug 19, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .icons/openai.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
155 changes: 155 additions & 0 deletions registry/coder-labs/modules/codex/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,155 @@
---
display_name: Codex CLI
icon: ../../../../.icons/openai.svg
description: Run Codex CLI in your workspace with AgentAPI integration
verified: true
tags: [agent, codex, ai, openai, tasks]
---

# Codex CLI

Run Codex CLI in your workspace to access OpenAI's models through the Codex interface, with custom pre/post install scripts. This module integrates with [AgentAPI](https://github.com/coder/agentapi) for Coder Tasks compatibility.

```tf
module "codex" {
source = "registry.coder.com/coder-labs/codex/coder"
version = "1.0.0"
agent_id = coder_agent.example.id
openai_api_key = var.openai_api_key
folder = "/home/coder/project"
}
```

## Prerequisites

- You must add the [Coder Login](https://registry.coder.com/modules/coder/coder-login) module to your template
- OpenAI API key for Codex access

## Usage Example

- Simple usage Example:

```tf
module "codex" {
count = data.coder_workspace.me.start_count
source = "registry.coder.com/coder-labs/codex/coder"
version = "1.0.0"
agent_id = coder_agent.example.id
openai_api_key = "..."
codex_model = "o4-mini"
install_codex = true
codex_version = "latest"
folder = "/home/coder/project"
codex_system_prompt = "You are a helpful coding assistant. Start every response with `Codex says:`"
}
```

- Example usage with Tasks:

```tf
# This
data "coder_parameter" "ai_prompt" {
type = "string"
name = "AI Prompt"
default = ""
description = "Initial prompt for the Codex CLI"
mutable = true
}

module "coder-login" {
count = data.coder_workspace.me.start_count
source = "registry.coder.com/coder/coder-login/coder"
version = "1.0.31"
agent_id = coder_agent.example.id
}

module "codex" {
source = "registry.coder.com/coder-labs/codex/coder"
agent_id = coder_agent.example.id
openai_api_key = "..."
ai_prompt = data.coder_parameter.ai_prompt.value
folder = "/home/coder/project"
approval_policy = "never" # Full auto mode
}
```

> [!WARNING]
> **Security Notice**: This module configures Codex with a `workspace-write` sandbox that allows AI tasks to read/write files in the specified folder. While the sandbox provides security boundaries, Codex can still modify files within the workspace. Use this module in trusted environments and be aware of the security implications.

## How it Works

- **Install**: The module installs Codex CLI and sets up the environment
- **System Prompt**: If `codex_system_prompt` and `folder` are set, creates the directory (if needed) and writes the prompt to `AGENTS.md`
- **Start**: Launches Codex CLI in the specified directory, wrapped by AgentAPI
- **Configuration**: Sets `OPENAI_API_KEY` environment variable and passes `--model` flag to Codex CLI (if variables provided)

## Sandbox Configuration

The module automatically configures Codex with a secure sandbox that allows AI tasks to work effectively:

- **Sandbox Mode**: `workspace-write` - Allows Codex to read/write files in the specified `folder`
- **Approval Policy**: `on-request` - Codex asks for permission before performing potentially risky operations
- **Network Access**: Enabled within the workspace for package installation and API calls

### Customizing Sandbox Behavior

You can customize the sandbox behavior using dedicated variables:

#### **Using Dedicated Variables (Recommended)**

For most use cases, use the dedicated sandbox variables:

```tf
module "codex" {
source = "registry.coder.com/coder-labs/codex/coder"
# ... other variables ...

# Containerized environments (fixes Landlock errors)
sandbox_mode = "danger-full-access"

# Or for read-only mode
# sandbox_mode = "read-only"

# Or for full auto mode
# approval_policy = "never"

# Or disable network access
# network_access = false
}
```

#### **Using extra_codex_settings_toml (Advanced)**

For advanced configuration or when you need to override multiple settings:

```tf
module "codex" {
source = "registry.coder.com/coder-labs/codex/coder"
# ... other variables ...

extra_codex_settings_toml = <<-EOT
# Any custom Codex configuration
model = "gpt-4"
disable_response_storage = true
EOT
}
```

> [!NOTE]
> The dedicated variables (`sandbox_mode`, `approval_policy`, `network_access`) are the recommended way to configure sandbox behavior. Use `extra_codex_settings_toml` only for advanced configuration that isn't covered by the dedicated variables.

## Troubleshooting

- Check installation and startup logs in `~/.codex-module/`
- Ensure your OpenAI API key has access to the specified model

> [!IMPORTANT]
> To use tasks with Codex CLI, ensure you have the `openai_api_key` variable set, and **you create a `coder_parameter` named `"AI Prompt"` and pass its value to the codex module's `ai_prompt` variable**. [Tasks Template Example](https://registry.coder.com/templates/coder-labs/tasks-docker).
> The module automatically configures Codex with your API key and model preferences.
> folder is a required variable for the module to function correctly.

## References

- [OpenAI API Documentation](https://platform.openai.com/docs)
- [AgentAPI Documentation](https://github.com/coder/agentapi)
- [Coder AI Agents Guide](https://coder.com/docs/tutorials/ai-agents)
Loading