From 2e8d99bab7981c6af92378b4786c5b4fd5dc3275 Mon Sep 17 00:00:00 2001 From: weiwenli Date: Thu, 9 Apr 2026 03:07:53 +0800 Subject: [PATCH 1/2] fix: expose agentapi_port in codex/auggie/gemini/opencode modules --- registry/coder-labs/modules/auggie/main.tf | 7 +++++++ registry/coder-labs/modules/codex/main.tf | 7 +++++++ registry/coder-labs/modules/gemini/main.tf | 7 +++++++ registry/coder-labs/modules/opencode/main.tf | 7 +++++++ 4 files changed, 28 insertions(+) diff --git a/registry/coder-labs/modules/auggie/main.tf b/registry/coder-labs/modules/auggie/main.tf index 8ecb3ba0a..602d391f1 100644 --- a/registry/coder-labs/modules/auggie/main.tf +++ b/registry/coder-labs/modules/auggie/main.tf @@ -73,6 +73,12 @@ variable "agentapi_version" { } } +variable "agentapi_port" { + type = number + description = "The port used by AgentAPI." + default = 3284 +} + variable "pre_install_script" { type = string description = "Custom script to run before installing Auggie." @@ -194,6 +200,7 @@ module "agentapi" { module_dir_name = local.module_dir_name install_agentapi = var.install_agentapi agentapi_version = var.agentapi_version + agentapi_port = var.agentapi_port pre_install_script = var.pre_install_script post_install_script = var.post_install_script start_script = <<-EOT diff --git a/registry/coder-labs/modules/codex/main.tf b/registry/coder-labs/modules/codex/main.tf index b5f71cb3c..1c44151ec 100644 --- a/registry/coder-labs/modules/codex/main.tf +++ b/registry/coder-labs/modules/codex/main.tf @@ -134,6 +134,12 @@ variable "agentapi_version" { default = "v0.12.1" } +variable "agentapi_port" { + type = number + description = "The port used by AgentAPI." + default = 3284 +} + variable "codex_model" { type = string description = "The model for Codex to use. Defaults to gpt-5.3-codex." @@ -254,6 +260,7 @@ module "agentapi" { install_agentapi = var.install_agentapi agentapi_subdomain = var.subdomain agentapi_version = var.agentapi_version + agentapi_port = var.agentapi_port enable_state_persistence = var.enable_state_persistence pre_install_script = var.pre_install_script post_install_script = var.post_install_script diff --git a/registry/coder-labs/modules/gemini/main.tf b/registry/coder-labs/modules/gemini/main.tf index dbc81bc79..fc1d03c25 100644 --- a/registry/coder-labs/modules/gemini/main.tf +++ b/registry/coder-labs/modules/gemini/main.tf @@ -84,6 +84,12 @@ variable "agentapi_version" { default = "v0.10.0" } +variable "agentapi_port" { + type = number + description = "The port used by AgentAPI." + default = 3284 +} + variable "gemini_model" { type = string description = "The model to use for Gemini (e.g., gemini-2.5-pro)." @@ -191,6 +197,7 @@ module "agentapi" { module_dir_name = local.module_dir_name install_agentapi = var.install_agentapi agentapi_version = var.agentapi_version + agentapi_port = var.agentapi_port pre_install_script = var.pre_install_script post_install_script = var.post_install_script install_script = <<-EOT diff --git a/registry/coder-labs/modules/opencode/main.tf b/registry/coder-labs/modules/opencode/main.tf index df7f946f2..596cc8f6b 100644 --- a/registry/coder-labs/modules/opencode/main.tf +++ b/registry/coder-labs/modules/opencode/main.tf @@ -89,6 +89,12 @@ variable "agentapi_version" { default = "v0.11.2" } +variable "agentapi_port" { + type = number + description = "The port used by AgentAPI." + default = 3284 +} + variable "ai_prompt" { type = string description = "Initial task prompt for OpenCode." @@ -163,6 +169,7 @@ module "agentapi" { module_dir_name = local.module_dir_name install_agentapi = var.install_agentapi agentapi_version = var.agentapi_version + agentapi_port = var.agentapi_port pre_install_script = var.pre_install_script post_install_script = var.post_install_script start_script = <<-EOT From a5aba0e8ad5e6eeaf79e4c18ab25a4f96e9a4128 Mon Sep 17 00:00:00 2001 From: weiwenli Date: Thu, 9 Apr 2026 13:21:34 +0800 Subject: [PATCH 2/2] fix: propagate agentapi_port to install scripts and MCP configs Pass ARG_AGENTAPI_PORT from main.tf install_script blocks into each module's install.sh, replacing hardcoded localhost:3284 references with ${ARG_AGENTAPI_PORT:-3284}. This ensures the MCP client-side URL matches the configured AgentAPI port end-to-end. Changes per module: - codex: main.tf (pass env var) + install.sh (use env var) - auggie: main.tf (pass env var) + install.sh (use env var) - gemini: main.tf (pass env var + fix inline JSON) + install.sh (use env var) - opencode: main.tf (pass env var) + install.sh (use env var) --- registry/coder-labs/modules/auggie/main.tf | 1 + registry/coder-labs/modules/auggie/scripts/install.sh | 2 +- registry/coder-labs/modules/codex/main.tf | 1 + registry/coder-labs/modules/codex/scripts/install.sh | 2 +- registry/coder-labs/modules/gemini/main.tf | 3 ++- registry/coder-labs/modules/gemini/scripts/install.sh | 2 +- registry/coder-labs/modules/opencode/main.tf | 1 + registry/coder-labs/modules/opencode/scripts/install.sh | 2 +- 8 files changed, 9 insertions(+), 5 deletions(-) diff --git a/registry/coder-labs/modules/auggie/main.tf b/registry/coder-labs/modules/auggie/main.tf index 602d391f1..910d87ec0 100644 --- a/registry/coder-labs/modules/auggie/main.tf +++ b/registry/coder-labs/modules/auggie/main.tf @@ -234,6 +234,7 @@ module "agentapi" { ARG_MCP_APP_STATUS_SLUG='${local.app_slug}' \ ARG_AUGGIE_RULES='${base64encode(var.rules)}' \ ARG_MCP_CONFIG='${var.mcp != null ? base64encode(replace(var.mcp, "'", "'\\''")) : ""}' \ + ARG_AGENTAPI_PORT='${var.agentapi_port}' \ /tmp/install.sh EOT } diff --git a/registry/coder-labs/modules/auggie/scripts/install.sh b/registry/coder-labs/modules/auggie/scripts/install.sh index b2f80ebe9..1917bd484 100644 --- a/registry/coder-labs/modules/auggie/scripts/install.sh +++ b/registry/coder-labs/modules/auggie/scripts/install.sh @@ -85,7 +85,7 @@ function create_coder_mcp() { "command": "coder", "env": { "CODER_MCP_APP_STATUS_SLUG": "${ARG_MCP_APP_STATUS_SLUG}", - "CODER_MCP_AI_AGENTAPI_URL": "http://localhost:3284", + "CODER_MCP_AI_AGENTAPI_URL": "http://localhost:${ARG_AGENTAPI_PORT:-3284}", "CODER_AGENT_URL": "${CODER_AGENT_URL:-}", "CODER_AGENT_TOKEN": "${CODER_AGENT_TOKEN:-}" } diff --git a/registry/coder-labs/modules/codex/main.tf b/registry/coder-labs/modules/codex/main.tf index 1c44151ec..a377db788 100644 --- a/registry/coder-labs/modules/codex/main.tf +++ b/registry/coder-labs/modules/codex/main.tf @@ -307,6 +307,7 @@ module "agentapi" { ARG_CODEX_START_DIRECTORY='${local.workdir}' \ ARG_MODEL_REASONING_EFFORT='${var.model_reasoning_effort}' \ ARG_CODEX_INSTRUCTION_PROMPT='${base64encode(var.codex_system_prompt)}' \ + ARG_AGENTAPI_PORT='${var.agentapi_port}' \ /tmp/install.sh EOT } diff --git a/registry/coder-labs/modules/codex/scripts/install.sh b/registry/coder-labs/modules/codex/scripts/install.sh index 9a191a024..923fbbe2b 100644 --- a/registry/coder-labs/modules/codex/scripts/install.sh +++ b/registry/coder-labs/modules/codex/scripts/install.sh @@ -129,7 +129,7 @@ append_mcp_servers_section() { ARG_CODER_MCP_APP_STATUS_SLUG="" CODER_MCP_AI_AGENTAPI_URL="" else - CODER_MCP_AI_AGENTAPI_URL="http://localhost:3284" + CODER_MCP_AI_AGENTAPI_URL="http://localhost:${ARG_AGENTAPI_PORT:-3284}" fi cat << EOF >> "$config_path" diff --git a/registry/coder-labs/modules/gemini/main.tf b/registry/coder-labs/modules/gemini/main.tf index fc1d03c25..77a7b352a 100644 --- a/registry/coder-labs/modules/gemini/main.tf +++ b/registry/coder-labs/modules/gemini/main.tf @@ -164,7 +164,7 @@ locals { "enabled": true, "env": { "CODER_MCP_APP_STATUS_SLUG": "${local.app_slug}", - "CODER_MCP_AI_AGENTAPI_URL": "http://localhost:3284" + "CODER_MCP_AI_AGENTAPI_URL": "http://localhost:${var.agentapi_port}" }, "name": "Coder", "timeout": 3000, @@ -214,6 +214,7 @@ module "agentapi" { ADDITIONAL_EXTENSIONS='${base64encode(replace(var.additional_extensions != null ? var.additional_extensions : "", "'", "'\\''"))}' \ GEMINI_START_DIRECTORY='${var.folder}' \ GEMINI_SYSTEM_PROMPT='${base64encode(var.gemini_system_prompt)}' \ + ARG_AGENTAPI_PORT='${var.agentapi_port}' \ /tmp/install.sh EOT start_script = <<-EOT diff --git a/registry/coder-labs/modules/gemini/scripts/install.sh b/registry/coder-labs/modules/gemini/scripts/install.sh index 7b70a6af4..b1953de06 100644 --- a/registry/coder-labs/modules/gemini/scripts/install.sh +++ b/registry/coder-labs/modules/gemini/scripts/install.sh @@ -142,7 +142,7 @@ function add_system_prompt_if_exists() { function configure_mcp() { export CODER_MCP_APP_STATUS_SLUG="gemini" - export CODER_MCP_AI_AGENTAPI_URL="http://localhost:3284" + export CODER_MCP_AI_AGENTAPI_URL="http://localhost:${ARG_AGENTAPI_PORT:-3284}" coder exp mcp configure gemini "${GEMINI_START_DIRECTORY}" } diff --git a/registry/coder-labs/modules/opencode/main.tf b/registry/coder-labs/modules/opencode/main.tf index 596cc8f6b..2c0ac91c9 100644 --- a/registry/coder-labs/modules/opencode/main.tf +++ b/registry/coder-labs/modules/opencode/main.tf @@ -201,6 +201,7 @@ module "agentapi" { ARG_WORKDIR='${local.workdir}' \ ARG_AUTH_JSON='${var.auth_json != null ? base64encode(replace(var.auth_json, "'", "'\\''")) : ""}' \ ARG_OPENCODE_CONFIG='${var.config_json != null ? base64encode(replace(var.config_json, "'", "'\\''")) : ""}' \ + ARG_AGENTAPI_PORT='${var.agentapi_port}' \ /tmp/install.sh EOT } diff --git a/registry/coder-labs/modules/opencode/scripts/install.sh b/registry/coder-labs/modules/opencode/scripts/install.sh index 473e5ac49..b74341126 100755 --- a/registry/coder-labs/modules/opencode/scripts/install.sh +++ b/registry/coder-labs/modules/opencode/scripts/install.sh @@ -94,7 +94,7 @@ setup_coder_mcp_server() { # Set environment variables based on task reporting setting echo "Configuring OpenCode task reporting" export CODER_MCP_APP_STATUS_SLUG="$ARG_MCP_APP_STATUS_SLUG" - export CODER_MCP_AI_AGENTAPI_URL="http://localhost:3284" + export CODER_MCP_AI_AGENTAPI_URL="http://localhost:${ARG_AGENTAPI_PORT:-3284}" echo "Coder integration configured for task reporting" # Add coder MCP server configuration to the JSON file