Skip to content

Commit 700789e

Browse files
chore: polish and cleanup
1 parent 50e5fdb commit 700789e

File tree

4 files changed

+29
-37
lines changed

4 files changed

+29
-37
lines changed

registry/coder-labs/modules/codex/README.md

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,9 @@ module "codex" {
2525
- You must add the [Coder Login](https://registry.coder.com/modules/coder/coder-login) module to your template
2626
- OpenAI API key for Codex access
2727

28-
## Usage Examples
28+
## Examples
2929

30-
### **Simple Usage**
30+
### **Run standalone**
3131

3232
```tf
3333
module "codex" {
@@ -36,15 +36,14 @@ module "codex" {
3636
version = "1.0.2"
3737
agent_id = coder_agent.example.id
3838
openai_api_key = "..."
39-
codex_model = "o4-mini"
4039
install_codex = true
4140
codex_version = "latest"
4241
folder = "/home/coder/project"
4342
codex_system_prompt = "You are a helpful coding assistant. Start every response with `Codex says:`"
4443
}
4544
```
4645

47-
### **Tasks Integration**
46+
### **Tasks integration**
4847

4948
```tf
5049
data "coder_parameter" "ai_prompt" {
@@ -78,8 +77,7 @@ module "codex" {
7877
}
7978
```
8079

81-
> [!WARNING]
82-
> **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.
80+
> **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 _only_ in trusted environments and be aware of the security implications.
8381
8482
## How it Works
8583

@@ -138,7 +136,7 @@ module "codex" {
138136
```
139137

140138
> [!NOTE]
141-
> If no custom configuration is provided, the module uses secure defaults. The Coder MCP server is always included automatically.
139+
> If no custom configuration is provided, the module uses secure defaults. The Coder MCP server is always included automatically. For advanced options, see [Codex config docs](https://github.com/openai/codex/blob/main/codex-rs/config.md).
142140
143141
## Troubleshooting
144142

registry/coder-labs/modules/codex/main.tf

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ variable "codex_version" {
5555

5656
variable "base_config_toml" {
5757
type = string
58-
description = "Complete base TOML configuration for Codex (without mcp_servers section). If empty, uses minimal default configuration with workspace-write sandbox mode and on-request approval policy."
58+
description = "Complete base TOML configuration for Codex (without mcp_servers section). If empty, uses minimal default configuration with workspace-write sandbox mode and never approval policy. For advanced options, see https://github.com/openai/codex/blob/main/codex-rs/config.md"
5959
default = ""
6060
}
6161

@@ -67,7 +67,7 @@ variable "additional_mcp_servers" {
6767

6868
variable "openai_api_key" {
6969
type = string
70-
description = "Codex API Key"
70+
description = "OpenAI API key for Codex CLI"
7171
default = ""
7272
}
7373

@@ -85,7 +85,7 @@ variable "agentapi_version" {
8585

8686
variable "codex_model" {
8787
type = string
88-
description = "The model for Codex to use (e.g., o4-mini)."
88+
description = "The model for Codex to use. Defaults to gpt-5."
8989
default = ""
9090
}
9191

@@ -103,14 +103,13 @@ variable "post_install_script" {
103103

104104
variable "ai_prompt" {
105105
type = string
106-
description = "Task prompt for the Codex CLI"
106+
description = "Initial task prompt for Codex CLI when launched via Tasks"
107107
default = ""
108108
}
109109

110-
111110
variable "codex_system_prompt" {
112111
type = string
113-
description = "System prompt for Codex. It will be added to AGENTS.md in the specified folder."
112+
description = "System instructions written to AGENTS.md in the ~/.codex directory"
114113
default = ""
115114
}
116115

registry/coder-labs/modules/codex/scripts/install.sh

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -15,16 +15,15 @@ ARG_BASE_CONFIG_TOML=$(echo -n "$ARG_BASE_CONFIG_TOML" | base64 -d)
1515
ARG_ADDITIONAL_MCP_SERVERS=$(echo -n "$ARG_ADDITIONAL_MCP_SERVERS" | base64 -d)
1616
ARG_CODEX_INSTRUCTION_PROMPT=$(echo -n "$ARG_CODEX_INSTRUCTION_PROMPT" | base64 -d)
1717

18-
echo "--------------------------------"
19-
printf "install: %s\n" "$ARG_INSTALL"
20-
printf "codex_version: %s\n" "$ARG_CODEX_VERSION"
21-
printf "base_config_toml: %s\n" "$ARG_BASE_CONFIG_TOML"
22-
printf "additional_mcp_servers: %s\n" "$ARG_ADDITIONAL_MCP_SERVERS"
23-
printf "app_slug: %s\n" "$ARG_CODER_MCP_APP_STATUS_SLUG"
24-
printf "start_directory: %s\n" "$ARG_CODEX_START_DIRECTORY"
25-
printf "instruction_prompt: %s\n" "$ARG_CODEX_INSTRUCTION_PROMPT"
26-
27-
echo "--------------------------------"
18+
echo "=== Codex Module Configuration ==="
19+
printf "Install Codex: %s\n" "$ARG_INSTALL"
20+
printf "Codex Version: %s\n" "$ARG_CODEX_VERSION"
21+
printf "App Slug: %s\n" "$ARG_CODER_MCP_APP_STATUS_SLUG"
22+
printf "Start Directory: %s\n" "$ARG_CODEX_START_DIRECTORY"
23+
printf "Has Base Config: %s\n" "$([ -n "$ARG_BASE_CONFIG_TOML" ] && echo "Yes" || echo "No")"
24+
printf "Has Additional MCP: %s\n" "$([ -n "$ARG_ADDITIONAL_MCP_SERVERS" ] && echo "Yes" || echo "No")"
25+
printf "Has System Prompt: %s\n" "$([ -n "$ARG_CODEX_INSTRUCTION_PROMPT" ] && echo "Yes" || echo "No")"
26+
echo "======================================"
2827

2928
set +o nounset
3029

registry/coder-labs/modules/codex/scripts/start.sh

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,12 @@ printf "Version: %s\n" "$(codex --version)"
1818
set -o nounset
1919
ARG_CODEX_TASK_PROMPT=$(echo -n "$ARG_CODEX_TASK_PROMPT" | base64 -d)
2020

21-
echo "--------------------------------"
22-
printf "openai_api_key: %s\n" "$ARG_OPENAI_API_KEY"
23-
printf "codex_model: %s\n" "$ARG_CODEX_MODEL"
24-
printf "start_directory: %s\n" "$ARG_CODEX_START_DIRECTORY"
25-
printf "task_prompt: %s\n" "$ARG_CODEX_TASK_PROMPT"
26-
echo "--------------------------------"
21+
echo "=== Codex Launch Configuration ==="
22+
printf "OpenAI API Key: %s\n" "$([ -n "$ARG_OPENAI_API_KEY" ] && echo "Provided" || echo "Not provided")"
23+
printf "Codex Model: %s\n" "${ARG_CODEX_MODEL:-"Default"}"
24+
printf "Start Directory: %s\n" "$ARG_CODEX_START_DIRECTORY"
25+
printf "Has Task Prompt: %s\n" "$([ -n "$ARG_CODEX_TASK_PROMPT" ] && echo "Yes" || echo "No")"
26+
echo "======================================"
2727
set +o nounset
2828
CODEX_ARGS=()
2929

@@ -66,13 +66,9 @@ else
6666
printf "No task prompt given.\n"
6767
fi
6868

69-
if [ -n "$ARG_OPENAI_API_KEY" ]; then
70-
printf "openai_api_key provided !\n"
71-
else
72-
printf "openai_api_key not provided\n"
73-
fi
7469

75-
# use low width to fit in the tasks UI sidebar
76-
# we adjust the height to 930 due to a bug in codex, see: https://github.com/openai/codex/issues/1608
77-
printf "Starting codex with %s\n" "${CODEX_ARGS[@]}"
70+
# Terminal dimensions optimized for Coder Tasks UI sidebar:
71+
# - Width 67: fits comfortably in sidebar
72+
# - Height 1190: adjusted due to Codex terminal height bug (see: https://github.com/openai/codex/issues/1608)
73+
printf "Starting Codex with arguments: %s\n" "${CODEX_ARGS[*]}"
7874
agentapi server --term-width 67 --term-height 1190 -- codex "${CODEX_ARGS[@]}"

0 commit comments

Comments
 (0)