From 9be5edb0056f55b0ae7ee1f2b5c722189e34b852 Mon Sep 17 00:00:00 2001 From: 35C4n0r Date: Fri, 6 Feb 2026 12:28:18 +0000 Subject: [PATCH] feat(coder/modules/claude-code): migrate claude-code to agentapi v3 --- registry/coder/modules/claude-code/main.tf | 51 +++++++++++-------- .../modules/claude-code/scripts/start.sh | 25 +++++++-- 2 files changed, 51 insertions(+), 25 deletions(-) diff --git a/registry/coder/modules/claude-code/main.tf b/registry/coder/modules/claude-code/main.tf index 07e3eb5a..fe482327 100644 --- a/registry/coder/modules/claude-code/main.tf +++ b/registry/coder/modules/claude-code/main.tf @@ -354,27 +354,12 @@ locals { ) } -module "agentapi" { - source = "registry.coder.com/coder/agentapi/coder" - version = "2.0.0" - agent_id = var.agent_id - web_app_slug = local.app_slug - web_app_order = var.order - web_app_group = var.group - web_app_icon = var.icon - web_app_display_name = var.web_app_display_name - folder = local.workdir - cli_app = var.cli_app - cli_app_slug = var.cli_app ? "${local.app_slug}-cli" : null - cli_app_display_name = var.cli_app ? var.cli_app_display_name : null - agentapi_subdomain = var.subdomain - module_dir_name = local.module_dir_name - install_agentapi = var.install_agentapi - agentapi_version = var.agentapi_version - pre_install_script = var.pre_install_script - post_install_script = var.post_install_script - start_script = <<-EOT +module "agent-helper" { + source = "git::https://github.com/coder/registry.git//registry/coder/modules/agent-helper?ref=35C4n0r/feat-agent-helper-module" + pre_install_script = var.pre_install_script + post_install_script = var.post_install_script + start_script = <<-EOT #!/bin/bash set -o errexit set -o pipefail @@ -397,7 +382,7 @@ module "agentapi" { /tmp/start.sh EOT - install_script = <<-EOT + install_script = <<-EOT #!/bin/bash set -o errexit set -o pipefail @@ -418,6 +403,30 @@ module "agentapi" { ARG_ENABLE_AIBRIDGE='${var.enable_aibridge}' \ /tmp/install.sh EOT + agent_id = var.agent_id + agent_name = local.app_slug + module_dir_name = local.module_dir_name +} + +module "agentapi" { + source = "git::https://github.com/coder/registry.git//registry/coder/modules/agentapi?ref=35C4n0r/feat-agentapi-architecture-improv" + # version = "2.0.0" + + agent_id = var.agent_id + web_app_slug = local.app_slug + web_app_order = var.order + web_app_group = var.group + web_app_icon = var.icon + web_app_display_name = var.web_app_display_name + folder = local.workdir + cli_app = var.cli_app + cli_app_slug = var.cli_app ? "${local.app_slug}-cli" : null + cli_app_display_name = var.cli_app ? var.cli_app_display_name : null + agentapi_subdomain = var.subdomain + module_dir_name = local.module_dir_name + agentapi_server_type = "claude" + install_agentapi = var.install_agentapi + agentapi_version = var.agentapi_version } output "task_app_id" { diff --git a/registry/coder/modules/claude-code/scripts/start.sh b/registry/coder/modules/claude-code/scripts/start.sh index a38e7146..2b66289a 100644 --- a/registry/coder/modules/claude-code/scripts/start.sh +++ b/registry/coder/modules/claude-code/scripts/start.sh @@ -11,6 +11,7 @@ command_exists() { command -v "$1" > /dev/null 2>&1 } +MODULE_PATH="$HOME/.claude-module" ARG_RESUME_SESSION_ID=${ARG_RESUME_SESSION_ID:-} ARG_CONTINUE=${ARG_CONTINUE:-false} ARG_DANGEROUSLY_SKIP_PERMISSIONS=${ARG_DANGEROUSLY_SKIP_PERMISSIONS:-} @@ -243,12 +244,28 @@ function start_agentapi() { BOUNDARY_CMD=("$CODER_NO_CAPS" "boundary") fi - agentapi server --type claude --term-width 67 --term-height 1190 -- \ - "${BOUNDARY_CMD[@]}" "${BOUNDARY_ARGS[@]}" -- \ - claude "${ARGS[@]}" + # Build properly quoted command arguments + boundary_cmd=$(printf '%q ' "${BOUNDARY_CMD[@]}" "${BOUNDARY_ARGS[@]}") + claude_args=$(printf '%q ' "${ARGS[@]}") + + # Write command to agent-command.sh with boundary + cat > "$MODULE_PATH/agent-command.sh" << EOF +#!/bin/bash +${BOUNDARY_CMD[@]} -- claude ${ARGS[@]} +EOF else - agentapi server --type claude --term-width 67 --term-height 1190 -- claude "${ARGS[@]}" + # Build properly quoted command arguments + claude_args=$(printf '%q ' "${ARGS[@]}") + + # Write command to agent-command.sh without boundary + cat > "$MODULE_PATH/agent-command.sh" << EOF +#!/bin/bash +claude ${ARGS[@]} +EOF fi + + chmod +x "$MODULE_PATH/agent-command.sh" + printf "Agent command written to %s\n" "$MODULE_PATH/agent-command.sh" } validate_claude_installation